fourth commit
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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<PackedScene>("res://Enemy.tscn");
|
||||
public List<Enemy> _enemies = new();
|
||||
public Random _rng = new();
|
||||
@@ -15,7 +15,7 @@ public partial class Main : Node
|
||||
{
|
||||
base._Ready();
|
||||
_commander = GetNode<Commander>("Commander");
|
||||
_grid = GetNode<GridMap>("GridMap");
|
||||
_grid = GetNode<GridMap2D>("GridMap2D");
|
||||
_commander.GlobalPosition = _grid.GlobalPosition;
|
||||
_commander.TurnDone += ChangeTurn;
|
||||
AddEnemy();
|
||||
|
||||
@@ -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]
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user