diff --git a/Enemy.cs b/Enemy.cs index 7362707..cb1234d 100644 --- a/Enemy.cs +++ b/Enemy.cs @@ -8,7 +8,7 @@ public partial class Enemy : StaticBody2D public int _damage = 1, _health = 2; public Vector2 _speed = Vector2.Up, _range = Vector2.Up; public float _movement = 0; - public GridMap _grid; + public GridMap2D _grid; public GridMarker _gridMarker; public Commander _commander; public override void _PhysicsProcess(double delta) diff --git a/GridMap.cs b/GridMap2D.cs similarity index 85% rename from GridMap.cs rename to GridMap2D.cs index 346fa19..948ec1e 100644 --- a/GridMap.cs +++ b/GridMap2D.cs @@ -2,8 +2,10 @@ using Godot; using System; using System.Collections.Generic; -public partial class GridMap : Node2D +public partial class GridMap2D : Node2D { + [Export] + public bool _showMarkers = true; public int _cellSize = 16; public Area2D _playArea; public GridMarker _gridMarker; @@ -24,7 +26,7 @@ public partial class GridMap : Node2D GridMarker newGridMarker = (GridMarker)_gridMarker.Duplicate(); newGridMarker._address = new Vector2(j, i); newGridMarker.Position = new Vector2(_playArea.Position.X - bounds.Shape.GetRect().Size.X / 2 + (j+.5f)*_cellSize, _playArea.Position.Y - bounds.Shape.GetRect().Size.Y / 2 + (i+.5f)*_cellSize); - newGridMarker.Modulate = new Color((i+j)%2 == 0 ? "#ffffff" : "#000000"); + newGridMarker.Modulate = new Color(((i+j)%2 == 0 ? "#ffffff" : "#000000")+(_showMarkers ? "ff" : "00")); _gridMarkers[i].Add(newGridMarker); AddChild(newGridMarker); } diff --git a/GridMap.cs.uid b/GridMap2D.cs.uid similarity index 100% rename from GridMap.cs.uid rename to GridMap2D.cs.uid diff --git a/Main.cs b/Main.cs index 4cde227..edfdb08 100644 --- a/Main.cs +++ b/Main.cs @@ -7,7 +7,7 @@ public partial class Main : Node { public bool _isCommanderTurn = true; public Commander _commander; - public GridMap _grid; + public GridMap2D _grid; public PackedScene _enemyScene = GD.Load("res://Enemy.tscn"); public List _enemies = new(); public Random _rng = new(); @@ -15,7 +15,7 @@ public partial class Main : Node { base._Ready(); _commander = GetNode("Commander"); - _grid = GetNode("GridMap"); + _grid = GetNode("GridMap2D"); _commander.GlobalPosition = _grid.GlobalPosition; _commander.TurnDone += ChangeTurn; AddEnemy(); diff --git a/grid_map.tscn b/grid_map_2d.tscn similarity index 84% rename from grid_map.tscn rename to grid_map_2d.tscn index bda39c6..00a8a1c 100644 --- a/grid_map.tscn +++ b/grid_map_2d.tscn @@ -1,13 +1,12 @@ [gd_scene format=3 uid="uid://la8pwcc0tjuu"] -[ext_resource type="Script" uid="uid://bnaxgcafcvtfv" path="res://GridMap.cs" id="1_lq4m8"] +[ext_resource type="Script" uid="uid://bnaxgcafcvtfv" path="res://GridMap2D.cs" id="1_lq4m8"] [ext_resource type="PackedScene" uid="uid://bxqhci3fya80t" path="res://grid_marker.tscn" id="2_gc0wv"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_q4dkg"] size = Vector2(1600, 800) -[node name="GridMap" type="Node2D" unique_id=1123610167] -position = Vector2(960, 510) +[node name="GridMap2D" type="Node2D" unique_id=1123610167] script = ExtResource("1_lq4m8") [node name="PlayArea" type="Area2D" parent="." unique_id=1719758298] diff --git a/main.tscn b/main.tscn index 463f088..02782ce 100644 --- a/main.tscn +++ b/main.tscn @@ -2,12 +2,13 @@ [ext_resource type="Script" uid="uid://cg1m762ed04kv" path="res://Main.cs" id="1_ig7tw"] [ext_resource type="PackedScene" uid="uid://c78e3u1owgiek" path="res://commander.tscn" id="2_0xm2m"] -[ext_resource type="PackedScene" uid="uid://la8pwcc0tjuu" path="res://grid_map.tscn" id="3_h2yge"] +[ext_resource type="PackedScene" uid="uid://la8pwcc0tjuu" path="res://grid_map_2d.tscn" id="3_h2yge"] [node name="Main" type="Node" unique_id=535208469] script = ExtResource("1_ig7tw") [node name="Commander" parent="." unique_id=203629164 instance=ExtResource("2_0xm2m")] -[node name="GridMap" parent="." unique_id=1123610167 instance=ExtResource("3_h2yge")] +[node name="GridMap2D" parent="." unique_id=1123610167 instance=ExtResource("3_h2yge")] position = Vector2(960, 510) +_showMarkers = false