Skip to content

Commit

Permalink
#6: Fix item drop location issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Danil Ko committed Mar 7, 2021
1 parent 1bc4a88 commit db9185a
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 11 deletions.
30 changes: 29 additions & 1 deletion ui/TitleScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public class TitleScreen : Control
enum GameModeState { Server, Client }
private GameModeState gameModeState;

private OptionButton playerTeams;

public override void _Ready()
{
network = (Network)GetNode("/root/NETWORK");
Expand All @@ -17,12 +19,38 @@ public override void _Ready()

// Ensure the pause is false to recover from disconnection
GetTree().Paused = false;

playerTeams = (OptionButton)GetNode("CanvasLayer/PanelPlayer/optPlayerTeam");
_populatePlayerTeams();
}

private void setPlayerInfo()
{
network.gamestateNetworkPlayer.name = ((LineEdit)GetNode("CanvasLayer/PanelPlayer/txtPlayerName")).Text;
network.gamestateNetworkPlayer.team = (int)(((SpinBox)GetNode("CanvasLayer/PanelPlayer/txtPlayerTeam")).Value);
network.gamestateNetworkPlayer.team = playerTeams.Selected;
}

private void _populatePlayerTeams()
{
playerTeams.Connect("item_selected", this, "_playerTeamSelected");

for (int index = 0; index < (int)(Team.TeamCode.NEUTRAL); index++)
{


Team.TeamCode team = (Team.TeamCode)index;
playerTeams.AddItem("" + team);
}

// Pre Select the 0 index
playerTeams.Select(0);
_playerTeamSelected(0);
}

private void _playerTeamSelected(int index)
{
TextureRect textureRect = (TextureRect)GetNode("CanvasLayer/PanelPlayer/optTextrect");
textureRect.Modulate = Team.TeamColor[index];
}

private void readyToPlay()
Expand Down
29 changes: 19 additions & 10 deletions ui/TitleScreen.tscn
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[gd_scene load_steps=9 format=2]
[gd_scene load_steps=10 format=2]

[ext_resource path="res://assets/fonts/Kenney Future.ttf" type="DynamicFontData" id=1]
[ext_resource path="res://map/SimulateGameWorld.tscn" type="PackedScene" id=2]
[ext_resource path="res://assets/fonts/Kenney Rocket.ttf" type="DynamicFontData" id=3]
[ext_resource path="res://ui/TitleScreen.cs" type="Script" id=4]
[ext_resource path="res://assets/ui/grey_box.png" type="Texture" id=5]

[sub_resource type="DynamicFont" id=1]
size = 86
Expand Down Expand Up @@ -60,17 +61,17 @@ anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
margin_left = -365.683
margin_left = -473.901
margin_top = -128.751
margin_right = 397.317
margin_right = 462.099
margin_bottom = -30.7504
custom_fonts/font = SubResource( 1 )
custom_colors/font_color = Color( 1, 1, 1, 1 )
custom_colors/font_outline_modulate = Color( 0, 0, 0, 1 )
custom_colors/font_color_shadow = Color( 0, 0, 0, 1 )
custom_constants/shadow_offset_x = 3
custom_constants/shadow_offset_y = 3
text = "Mach Battle"
text = "Machine Battle"
align = 1
uppercase = true
__meta__ = {
Expand Down Expand Up @@ -218,16 +219,24 @@ __meta__ = {
"_edit_use_anchors_": false
}

[node name="txtPlayerTeam" type="SpinBox" parent="CanvasLayer/PanelPlayer"]
margin_left = 180.0
margin_top = 22.0
margin_right = 301.0
margin_bottom = 46.0
max_value = 3.0
[node name="optPlayerTeam" type="OptionButton" parent="CanvasLayer/PanelPlayer"]
margin_left = 211.218
margin_top = 21.1199
margin_right = 370.218
margin_bottom = 41.1199
__meta__ = {
"_edit_use_anchors_": false
}

[node name="optTextrect" type="TextureRect" parent="CanvasLayer/PanelPlayer"]
margin_left = 183.971
margin_top = 21.827
margin_right = 221.971
margin_bottom = 57.827
rect_scale = Vector2( 0.5, 0.5 )
texture = ExtResource( 5 )
stretch_mode = 1

[node name="PanelHost" type="Panel" parent="CanvasLayer"]
visible = false
margin_left = 29.0
Expand Down

0 comments on commit db9185a

Please sign in to comment.