Skip to content

Commit 61003f6

Browse files
committed
Add separate field for custom games
1 parent 757e190 commit 61003f6

7 files changed

Lines changed: 95 additions & 38 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using Godot;
2+
using TurnBase;
3+
4+
[SceneReference("CustomField.tscn")]
5+
public partial class CustomField
6+
{
7+
public override void _Ready()
8+
{
9+
base._Ready();
10+
this.FillMembers();
11+
}
12+
public override void GameLogCurrentField(IField field)
13+
{
14+
base.GameLogCurrentField(field);
15+
16+
var mainField = (Field2D)field;
17+
var needUpdateBitmask = false;
18+
for (var x = 0; x < mainField.Width; x++)
19+
{
20+
for (var y = 0; y < mainField.Height; y++)
21+
{
22+
var pos = new Vector2(x, y);
23+
if (this.field.GetCellv(pos) == 4 && mainField.walls[x, y])
24+
{
25+
this.field.SetCellv(pos, -1);
26+
}
27+
if (this.field.GetCellv(pos) == -1 && !mainField.walls[x, y])
28+
{
29+
this.field.SetCellv(pos, 4);
30+
this.beach.SetCellv(pos, -1);
31+
this.castle.SetCellv(pos, -1);
32+
this.castle.SetCellv(pos + Vector2.Down, -1);
33+
this.castle.SetCellv(pos + Vector2.Up, -1);
34+
this.castle.SetCellv(pos + Vector2.Left, -1);
35+
this.castle.SetCellv(pos + Vector2.Right, -1);
36+
needUpdateBitmask = true;
37+
}
38+
}
39+
}
40+
if (needUpdateBitmask)
41+
{
42+
this.beach.UpdateBitmaskRegion();
43+
this.castle.UpdateBitmaskRegion();
44+
}
45+
}
46+
}

TurnBase.KaNoBu.Godot/Presentation/CustomField.tscn

Lines changed: 16 additions & 0 deletions
Large diffs are not rendered by default.

TurnBase.KaNoBu.Godot/Presentation/GameField.cs

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -83,33 +83,17 @@ public void PlayersInitialized()
8383
this.field.RemoveChildren();
8484
}
8585

86-
public void GameLogCurrentField(IField field)
86+
public virtual void GameLogCurrentField(IField field)
8787
{
8888
var mainField = (Field2D)field;
8989
this.memorizedField.SynchronizeField(mainField);
90-
var needCameraLimitUpdate = false;
9190
if (this.field.GetChildCount() == 0)
9291
{
9392
for (var x = 0; x < mainField.Width; x++)
9493
{
9594
for (var y = 0; y < mainField.Height; y++)
9695
{
9796
var pos = new Vector2(x, y);
98-
if (this.field.GetCellv(pos) == 4 && mainField.walls[x, y])
99-
{
100-
this.field.SetCellv(pos, -1);
101-
}
102-
if (this.field.GetCellv(pos) == -1 && !mainField.walls[x, y])
103-
{
104-
this.field.SetCellv(pos, 4);
105-
this.beach.SetCellv(pos, -1);
106-
this.castle.SetCellv(pos, -1);
107-
this.castle.SetCellv(pos + Vector2.Down, -1);
108-
this.castle.SetCellv(pos + Vector2.Up, -1);
109-
this.castle.SetCellv(pos + Vector2.Left, -1);
110-
this.castle.SetCellv(pos + Vector2.Right, -1);
111-
needCameraLimitUpdate = true;
112-
}
11397

11498
var originalShip = mainField[x, y] as KaNoBuFigure;
11599
if (originalShip == null)
@@ -129,11 +113,6 @@ public void GameLogCurrentField(IField field)
129113
}
130114
}
131115
}
132-
if (needCameraLimitUpdate)
133-
{
134-
this.beach.UpdateBitmaskRegion();
135-
this.castle.UpdateBitmaskRegion();
136-
}
137116

138117
this.UpdateKnownShips();
139118
}

TurnBase.KaNoBu.Godot/Presentation/GameField.tscn

Lines changed: 6 additions & 8 deletions
Large diffs are not rendered by default.

TurnBase.KaNoBu.Godot/Presentation/Levels/Level1.tscn

Lines changed: 12 additions & 5 deletions
Large diffs are not rendered by default.

TurnBase.KaNoBu.Godot/Presentation/Levels/Level2.tscn

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
[gd_scene load_steps=6 format=2]
1+
[gd_scene load_steps=7 format=2]
22

33
[ext_resource path="res://Presentation/Levels/LevelBase.tscn" type="PackedScene" id=1]
44
[ext_resource path="res://Presentation/Levels/Level2.cs" type="Script" id=2]
55
[ext_resource path="res://Presentation/Unit.tscn" type="PackedScene" id=3]
66
[ext_resource path="res://assets/Fonts/Xolonium-Regular.ttf" type="DynamicFontData" id=4]
7+
[ext_resource path="res://gd-timerLabel/TimerLabel.tscn" type="PackedScene" id=5]
78

89
[sub_resource type="DynamicFont" id=2]
910
font_data = ExtResource( 4 )
@@ -54,5 +55,15 @@ position = Vector2( 487, 346 )
5455
UnitType = 2
5556
PlayerNumber = 1
5657

57-
[node name="TimerLabel" parent="." index="5"]
58+
[node name="TimerLabel" parent="." index="5" instance=ExtResource( 5 )]
59+
margin_left = -66.0
60+
margin_top = -58.0
61+
margin_right = 62.0
62+
margin_bottom = -38.0
63+
rect_scale = Vector2( 5, 5 )
64+
custom_colors/font_color = Color( 1, 1, 1, 1 )
65+
custom_colors/font_color_shadow = Color( 0, 0, 0, 1 )
5866
custom_fonts/font = SubResource( 2 )
67+
text = "Timer label"
68+
align = 1
69+
valign = 1

TurnBase.KaNoBu.Godot/Presentation/Main.tscn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[ext_resource path="res://Presentation/Main.cs" type="Script" id=1]
44
[ext_resource path="res://gd-draggableCamera/DraggableCamera.tscn" type="PackedScene" id=2]
5-
[ext_resource path="res://Presentation/GameField.tscn" type="PackedScene" id=3]
5+
[ext_resource path="res://Presentation/CustomField.tscn" type="PackedScene" id=3]
66
[ext_resource path="res://Presentation/UI.tscn" type="PackedScene" id=4]
77

88
[node name="Main" type="Node"]

0 commit comments

Comments
 (0)