From facb2e227e65817210d381271c50187cf410996e Mon Sep 17 00:00:00 2001 From: cojoedmo Date: Fri, 29 May 2026 10:51:25 -0400 Subject: [PATCH] commit no. 5 --- circle25r.png => Art/circle25r.png | Bin .../circle25r.png.import | 6 +- Art/tower.png | Bin 0 -> 394 bytes Art/tower.png.import | 40 ++++++++++++++ Commander.cs | 52 +++++++++--------- Enemy.cs | 4 +- EnemyController.cs | 28 ++++++++++ EnemyController.cs.uid | 1 + GridMap2D.cs | 44 ++++++++++++--- Main.cs | 49 ++++++----------- PlayerController.cs | 41 ++++++++++++++ PlayerController.cs.uid | 1 + Tower.cs | 51 +++++++++++++++++ Tower.cs.uid | 1 + TurnController.cs | 14 +++++ TurnController.cs.uid | 1 + attack.tscn | 6 +- commander.tscn | 2 +- enemy.tscn | 4 +- enemy_controller.tscn | 6 ++ grid_map_2d.tscn | 25 +++++++++ grid_marker.tscn | 5 -- main.tscn | 12 ++-- player_controller.tscn | 9 +++ project.godot | 5 ++ tower.tscn | 22 ++++++++ turn_controller.tscn | 6 ++ 27 files changed, 348 insertions(+), 87 deletions(-) rename circle25r.png => Art/circle25r.png (100%) rename circle25r.png.import => Art/circle25r.png.import (77%) create mode 100644 Art/tower.png create mode 100644 Art/tower.png.import create mode 100644 EnemyController.cs create mode 100644 EnemyController.cs.uid create mode 100644 PlayerController.cs create mode 100644 PlayerController.cs.uid create mode 100644 Tower.cs create mode 100644 Tower.cs.uid create mode 100644 TurnController.cs create mode 100644 TurnController.cs.uid create mode 100644 enemy_controller.tscn create mode 100644 player_controller.tscn create mode 100644 tower.tscn create mode 100644 turn_controller.tscn diff --git a/circle25r.png b/Art/circle25r.png similarity index 100% rename from circle25r.png rename to Art/circle25r.png diff --git a/circle25r.png.import b/Art/circle25r.png.import similarity index 77% rename from circle25r.png.import rename to Art/circle25r.png.import index 0024eec..479a92e 100644 --- a/circle25r.png.import +++ b/Art/circle25r.png.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://nwj4n7if8kqd" -path="res://.godot/imported/circle25r.png-c9fb4b684a66f0e267203a51f53bbccb.ctex" +path="res://.godot/imported/circle25r.png-46081a6a20364337907fce72e91acb21.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://circle25r.png" -dest_files=["res://.godot/imported/circle25r.png-c9fb4b684a66f0e267203a51f53bbccb.ctex"] +source_file="res://Art/circle25r.png" +dest_files=["res://.godot/imported/circle25r.png-46081a6a20364337907fce72e91acb21.ctex"] [params] diff --git a/Art/tower.png b/Art/tower.png new file mode 100644 index 0000000000000000000000000000000000000000..d9a59cce738519649f55698633b4d44d7d45e3da GIT binary patch literal 394 zcmeAS@N?(olHy`uVBq!ia0vp^MnIgx!3HFcyhx4)QjEnx?oNz1PwLbIIV|apzK#qG z8~eHcB(ehe3dtTpz6=aiY77hwEes65fI?NMQuI#T^Wm&i+{tJ15gdTXhIEGZ*dVAiI%PCO6^W2BuHDDE#=0iO-cVNuk5(Q9e6L+g$$7=ipQV%oD&L;^K`zS*}z$TZbHRr5l?gD*-<&ml{}{%I5J7Wsf9yO$)!U; fkt~L%d?kbD^@-8%YEzqmer51<^>bP0l+XkK<(PjS literal 0 HcmV?d00001 diff --git a/Art/tower.png.import b/Art/tower.png.import new file mode 100644 index 0000000..df3183a --- /dev/null +++ b/Art/tower.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://32m5teus1cjj" +path="res://.godot/imported/tower.png-1ce12b6368f31409eabfb5a04a69654e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Art/tower.png" +dest_files=["res://.godot/imported/tower.png-1ce12b6368f31409eabfb5a04a69654e.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Commander.cs b/Commander.cs index e499f34..e313bdc 100644 --- a/Commander.cs +++ b/Commander.cs @@ -5,43 +5,38 @@ public partial class Commander : Sprite2D { [Signal] public delegate void TurnDoneEventHandler(); - public bool _aiming = false; public int _health = 10; public PackedScene _attackScene = GD.Load("res://Attack.tscn"); - public Attack _currentAttack; + public Attack _attack; + public override void _Process(double delta) { base._Process(delta); - if (_currentAttack != null) + if (_attack != null) { - if (Input.IsActionJustPressed("leftClick")){ - if (_currentAttack._hovered){ - _aiming = true; - } - } - if (_aiming){ - Vector2 offset = (_currentAttack.GlobalPosition - GetGlobalMousePosition()) * 500; - if (Input.IsActionJustReleased("leftClick")){ - ShootCurrentAttack(offset); - } - } - if (_currentAttack.Position.Y > GetViewportRect().Size.Y + 50){ - _currentAttack.QueueFree(); - _currentAttack = null; - EmitSignal(SignalName.TurnDone); + if (_attack.Position.Y > GetViewportRect().Size.Y + 50) + { + _attack.QueueFree(); + _attack = null; } } - } + public void StartTurn() { - if (_currentAttack == null){ + + } + + public void LoadAttack() + { + if (_attack == null) + { GD.Print("Loading attack"); - _currentAttack = _attackScene.Instantiate(); - _currentAttack._commanderOwner = this; - _currentAttack.GravityScale = 0; - AddChild(_currentAttack); + _attack = _attackScene.Instantiate(); + _attack._commanderOwner = this; + _attack.GravityScale = 0; + AddChild(_attack); } } @@ -56,8 +51,13 @@ public partial class Commander : Sprite2D } public void ShootCurrentAttack(Vector2 FORCE){ + GD.Print("Shooting attack"); - _currentAttack.Shoot(FORCE); - _aiming = false; + _attack.Shoot(FORCE); + } + + public void UnloadAttack() + { + _attack.QueueFree(); } } diff --git a/Enemy.cs b/Enemy.cs index cb1234d..f795e3b 100644 --- a/Enemy.cs +++ b/Enemy.cs @@ -8,13 +8,11 @@ public partial class Enemy : StaticBody2D public int _damage = 1, _health = 2; public Vector2 _speed = Vector2.Up, _range = Vector2.Up; public float _movement = 0; - public GridMap2D _grid; public GridMarker _gridMarker; public Commander _commander; public override void _PhysicsProcess(double delta) { base._PhysicsProcess(delta); - } public void Attack(Commander COMMANDER) @@ -40,6 +38,6 @@ public partial class Enemy : StaticBody2D public void TakeTurn() { - PlaceOrMove(_grid._gridMarkers[(int)(_gridMarker._address.Y + _speed.Y)][(int)(_gridMarker._address.X + _speed.X)]); + // PlaceOrMove(_gridMarker._gridMarkers[(int)(_gridMarker._address.Y + _speed.Y)][(int)(_gridMarker._address.X + _speed.X)]); } } diff --git a/EnemyController.cs b/EnemyController.cs new file mode 100644 index 0000000..657210e --- /dev/null +++ b/EnemyController.cs @@ -0,0 +1,28 @@ +using Godot; +using System; +using System.Collections.Generic; + +public partial class EnemyController : TurnController +{ + + public PackedScene _enemyScene = GD.Load("res://Enemy.tscn"); + public List _enemies = new(); + public void AddEnemy() + { + Enemy newEnemy = _enemyScene.Instantiate(); + // newEnemy.PlaceOrMove(_grid._gridMarkers.Last()[_rng.Next(_grid._gridMarkers.Last().Count)]); + // newEnemy._commander = _commander; + // newEnemy._grid = _grid; + _enemies.Add(newEnemy); + AddChild(newEnemy); + } + public override void StartTurn() + { + + } + + public void Initiate() + { + + } +} diff --git a/EnemyController.cs.uid b/EnemyController.cs.uid new file mode 100644 index 0000000..fe5a92d --- /dev/null +++ b/EnemyController.cs.uid @@ -0,0 +1 @@ +uid://brsi76xcgx3et diff --git a/GridMap2D.cs b/GridMap2D.cs index 948ec1e..26f23d3 100644 --- a/GridMap2D.cs +++ b/GridMap2D.cs @@ -1,36 +1,64 @@ using Godot; using System; using System.Collections.Generic; +using System.Linq; public partial class GridMap2D : Node2D { - [Export] - public bool _showMarkers = true; public int _cellSize = 16; + public Vector2 _sizeInPixels, _sizeInCells; public Area2D _playArea; public GridMarker _gridMarker; + public List _leftEdges = new(), _rightEdges = new(); public List> _gridMarkers = new(); public override void _Ready() { base._Ready(); _playArea = GetNode("PlayArea"); + + StaticBody2D firstOnLeft = GetNode("LeftEdge1"); + StaticBody2D firstOnRight = GetNode("RightEdge1"); + _leftEdges.Add(firstOnLeft); + _rightEdges.Add(firstOnRight); + CollisionShape2D firstOnLeftBounds = firstOnLeft.GetNode("Bounds"); + CollisionShape2D firstOnRightBounds = firstOnRight.GetNode("Bounds"); + _gridMarker = GetNode("GridMarker"); - CollisionShape2D bounds = _playArea.GetNode("Bounds"); - int gridCellsX = (int)bounds.Shape.GetRect().Size.X / _cellSize, gridCellsY = (int)bounds.Shape.GetRect().Size.Y / _cellSize; - for (int i = 0; i < gridCellsY; i++) + CollisionShape2D playAreaBounds = _playArea.GetNode("Bounds"); + _sizeInPixels = new Vector2((int)playAreaBounds.Shape.GetRect().Size.X, (int)playAreaBounds.Shape.GetRect().Size.Y); + _sizeInCells = new Vector2(_sizeInPixels.X / _cellSize, _sizeInPixels.Y / _cellSize); + for (int i = 0; i < _sizeInCells.Y; i++) { _gridMarkers.Add([]); - for (int j = 0; j < gridCellsX; j++) + for (int j = 0; j < _sizeInCells.X; j++) { 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")+(_showMarkers ? "ff" : "00")); + newGridMarker.Position = new Vector2(_playArea.Position.X - playAreaBounds.Shape.GetRect().Size.X / 2 + (j+.5f)*_cellSize, _playArea.Position.Y - playAreaBounds.Shape.GetRect().Size.Y / 2 + (i+.5f)*_cellSize); _gridMarkers[i].Add(newGridMarker); AddChild(newGridMarker); } } + + int leftEdgeSectionSizeY = (int)firstOnLeftBounds.Shape.GetRect().Size.Y, rightEdgeSectionSizeY = (int)firstOnRightBounds.Shape.GetRect().Size.Y; + int leftEdgeSectionsCount = (int)_sizeInPixels.Y / leftEdgeSectionSizeY, rightEdgeSectionsCount = (int)_sizeInPixels.Y / rightEdgeSectionSizeY; + + for (int i = 1; i < leftEdgeSectionsCount; i++) + { + StaticBody2D newLeftSection = (StaticBody2D)firstOnLeft.Duplicate(); + newLeftSection.Position += new Vector2(0, leftEdgeSectionSizeY * i); + _leftEdges.Add(newLeftSection); + AddChild(newLeftSection); + } + for (int i = 1; i < rightEdgeSectionsCount; i++) + { + StaticBody2D newRightSection = (StaticBody2D)firstOnRight.Duplicate(); + newRightSection.Position += new Vector2(0, rightEdgeSectionSizeY * i); + _rightEdges.Add(newRightSection); + AddChild(newRightSection); + } + _gridMarker.QueueFree(); } } diff --git a/Main.cs b/Main.cs index edfdb08..8db59e1 100644 --- a/Main.cs +++ b/Main.cs @@ -5,21 +5,27 @@ using System.Linq; public partial class Main : Node { - public bool _isCommanderTurn = true; - public Commander _commander; public GridMap2D _grid; - public PackedScene _enemyScene = GD.Load("res://Enemy.tscn"); - public List _enemies = new(); + public PlayerController _playerController; + public EnemyController _enemyController; + public TurnController _turnController; public Random _rng = new(); public override void _Ready() { base._Ready(); - _commander = GetNode("Commander"); _grid = GetNode("GridMap2D"); - _commander.GlobalPosition = _grid.GlobalPosition; - _commander.TurnDone += ChangeTurn; - AddEnemy(); - _commander.StartTurn(); + _playerController = GetNode("PlayerController"); + _enemyController = GetNode("EnemyController"); + + _playerController._grid = _grid; + _enemyController._grid = _grid; + + _playerController.TurnDone += ChangeTurn; + _enemyController.TurnDone += ChangeTurn; + + _enemyController.Initiate(); + _playerController.SetUpTowers(); + ChangeTurn(); } public override void _Process(double delta) @@ -33,33 +39,14 @@ public partial class Main : Node public void ChangeTurn() { - _isCommanderTurn = !_isCommanderTurn; - if (_isCommanderTurn) + if (_turnController != _playerController) { - GD.Print("Starting Commander turn"); - _commander.StartTurn(); + _playerController.StartTurn(); } else { - GD.Print("Starting Enemy turn"); - for (int i = 0; i < _enemies.Count; i++) - { - _enemies[i].TakeTurn(); - } - - AddEnemy(); - ChangeTurn(); + _enemyController.StartTurn(); } } - public void AddEnemy() - { - Enemy newEnemy = _enemyScene.Instantiate(); - newEnemy.TurnDone += ChangeTurn; - newEnemy.PlaceOrMove(_grid._gridMarkers.Last()[_rng.Next(_grid._gridMarkers.Last().Count)]); - newEnemy._commander = _commander; - newEnemy._grid = _grid; - _enemies.Add(newEnemy); - AddChild(newEnemy); - } } diff --git a/PlayerController.cs b/PlayerController.cs new file mode 100644 index 0000000..a73c1e6 --- /dev/null +++ b/PlayerController.cs @@ -0,0 +1,41 @@ +using Godot; +using System; +using System.Collections.Generic; + +public partial class PlayerController : TurnController +{ + public PackedScene _commanderScene = GD.Load("res://Commander.tscn"); + public List _towers = new(); + + public override void _Ready() + { + base._Ready(); + } + + public void SetUpTowers(int TOWER_COUNT = 8) + { + Tower tower = GetNode("Tower1"); + Vector2 towerPositionCorrection = tower._area.GetNode("Bounds").Shape.GetRect().Size / 2 * (Vector2.Right + Vector2.Up); + float spaceBetweenTowers = _grid._sizeInPixels.X / (TOWER_COUNT - 1); + tower.Position = _grid.Position - _grid._sizeInPixels / 2 + towerPositionCorrection; + + _towers.Add(tower); + for (int i = 1; i < TOWER_COUNT; i++) + { + Tower newTower = (Tower)tower.Duplicate(); + newTower.Position += new Vector2(spaceBetweenTowers * i - towerPositionCorrection.X * i / (TOWER_COUNT - 1) * 2, 0); + _towers.Add(newTower); + AddChild(newTower); + } + + Commander newCommander = _commanderScene.Instantiate(); + _towers[3]._commander = newCommander; + _towers[3].AddChild(newCommander); + } + + public override void StartTurn() + { + + } + +} diff --git a/PlayerController.cs.uid b/PlayerController.cs.uid new file mode 100644 index 0000000..7cd237c --- /dev/null +++ b/PlayerController.cs.uid @@ -0,0 +1 @@ +uid://cfohujgs5dygx diff --git a/Tower.cs b/Tower.cs new file mode 100644 index 0000000..2622b2b --- /dev/null +++ b/Tower.cs @@ -0,0 +1,51 @@ +using Godot; +using System; + +public partial class Tower : Sprite2D +{ + public bool _hovered, _aiming; + public Commander _commander; + public Area2D _area; + public override void _Ready() + { + base._Ready(); + _area = GetNode("Area"); + } + public override void _Process(double delta) + { + base._Process(delta); + + if (Input.IsActionJustPressed("leftClick")) + { + if (_hovered) + { + _aiming = true; + _commander.LoadAttack(); + } + } + if (_aiming) + { + if (Input.IsActionJustReleased("rightClick")) + { + Vector2 offset = (GlobalPosition - GetGlobalMousePosition()) * 500; + _commander.ShootCurrentAttack(offset); + _aiming = false; + } + else if (Input.IsActionJustReleased("leftClick")) + { + _commander.UnloadAttack(); + _aiming = false; + } + } + + + } + + public void OnMouseEntered(){ + _hovered = true; + } + public void OnMouseExited(){ + _hovered = true; + } + +} diff --git a/Tower.cs.uid b/Tower.cs.uid new file mode 100644 index 0000000..4ad91fb --- /dev/null +++ b/Tower.cs.uid @@ -0,0 +1 @@ +uid://b2gj1526x4ix1 diff --git a/TurnController.cs b/TurnController.cs new file mode 100644 index 0000000..3ccb424 --- /dev/null +++ b/TurnController.cs @@ -0,0 +1,14 @@ +using Godot; +using System; + +public partial class TurnController : Node2D +{ + [Signal] + public delegate void TurnDoneEventHandler(); + public GridMap2D _grid; + + public virtual void StartTurn() + { + + } +} diff --git a/TurnController.cs.uid b/TurnController.cs.uid new file mode 100644 index 0000000..4859441 --- /dev/null +++ b/TurnController.cs.uid @@ -0,0 +1 @@ +uid://b5h6v6w5h76cg diff --git a/attack.tscn b/attack.tscn index 6539129..eb1d2d1 100644 --- a/attack.tscn +++ b/attack.tscn @@ -1,13 +1,12 @@ [gd_scene format=3 uid="uid://cevk7yax5tvej"] [ext_resource type="Script" uid="uid://dm2gyxmgwbmg8" path="res://Attack.cs" id="1_63pi1"] -[ext_resource type="Texture2D" uid="uid://nwj4n7if8kqd" path="res://circle25r.png" id="2_hqc8w"] +[ext_resource type="Texture2D" uid="uid://nwj4n7if8kqd" path="res://Art/circle25r.png" id="2_hqc8w"] [sub_resource type="CircleShape2D" id="CircleShape2D_7yfhp"] -radius = 25.0 +radius = 14.0 [node name="Attack" type="RigidBody2D" unique_id=1225359241] -scale = Vector2(0.56, 0.56) input_pickable = true contact_monitor = true max_contacts_reported = 100 @@ -17,6 +16,7 @@ script = ExtResource("1_63pi1") shape = SubResource("CircleShape2D_7yfhp") [node name="Sprite2D" type="Sprite2D" parent="." unique_id=1583277900] +scale = Vector2(0.56, 0.56) texture = ExtResource("2_hqc8w") [connection signal="body_entered" from="." to="." method="TakeAction"] diff --git a/commander.tscn b/commander.tscn index dce1ded..d3c7b1e 100644 --- a/commander.tscn +++ b/commander.tscn @@ -1,6 +1,6 @@ [gd_scene format=3 uid="uid://c78e3u1owgiek"] -[ext_resource type="Script" uid="uid://b2kj0rc3g1hkm" path="res://Commander.cs" id="1_4flbx"] +[ext_resource type="Script" path="res://Commander.cs" id="1_4flbx"] [node name="Commander" type="Sprite2D" unique_id=1378094015] script = ExtResource("1_4flbx") diff --git a/enemy.tscn b/enemy.tscn index ad03dac..6ce5ddc 100644 --- a/enemy.tscn +++ b/enemy.tscn @@ -1,7 +1,7 @@ -[gd_scene format=3 uid="uid://bpce6ise18ks"] +[gd_scene format=3 uid="uid://drt7w0eqp13tu"] [ext_resource type="Script" uid="uid://dfba4vq6jv0a6" path="res://Enemy.cs" id="1_4gyqm"] -[ext_resource type="Texture2D" uid="uid://nwj4n7if8kqd" path="res://circle25r.png" id="1_7k104"] +[ext_resource type="Texture2D" uid="uid://nwj4n7if8kqd" path="res://Art/circle25r.png" id="1_7k104"] [sub_resource type="PhysicsMaterial" id="PhysicsMaterial_7k104"] bounce = 0.5 diff --git a/enemy_controller.tscn b/enemy_controller.tscn new file mode 100644 index 0000000..61af164 --- /dev/null +++ b/enemy_controller.tscn @@ -0,0 +1,6 @@ +[gd_scene format=3 uid="uid://c6b188d2a20eq"] + +[ext_resource type="Script" uid="uid://brsi76xcgx3et" path="res://EnemyController.cs" id="1_tkpyo"] + +[node name="EnemyController" type="Node2D" unique_id=197453707] +script = ExtResource("1_tkpyo") diff --git a/grid_map_2d.tscn b/grid_map_2d.tscn index 00a8a1c..2447125 100644 --- a/grid_map_2d.tscn +++ b/grid_map_2d.tscn @@ -6,6 +6,15 @@ [sub_resource type="RectangleShape2D" id="RectangleShape2D_q4dkg"] size = Vector2(1600, 800) +[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_7h2rc"] +bounce = 0.4 + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_7h2rc"] +size = Vector2(400, 16) + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_fjt81"] +size = Vector2(400, 16) + [node name="GridMap2D" type="Node2D" unique_id=1123610167] script = ExtResource("1_lq4m8") @@ -14,4 +23,20 @@ script = ExtResource("1_lq4m8") [node name="Bounds" type="CollisionShape2D" parent="PlayArea" unique_id=1902214362] shape = SubResource("RectangleShape2D_q4dkg") +[node name="LeftEdge1" type="StaticBody2D" parent="." unique_id=1883047200] +physics_material_override = SubResource("PhysicsMaterial_7h2rc") + +[node name="Bounds" type="CollisionShape2D" parent="LeftEdge1" unique_id=1546734575] +position = Vector2(-1000, -392) +shape = SubResource("RectangleShape2D_7h2rc") +debug_color = Color(0.98836404, 0, 0.30800217, 0.41960785) + +[node name="RightEdge1" type="StaticBody2D" parent="." unique_id=258284814] +physics_material_override = SubResource("PhysicsMaterial_7h2rc") + +[node name="Bounds" type="CollisionShape2D" parent="RightEdge1" unique_id=773927888] +position = Vector2(1000, -392) +shape = SubResource("RectangleShape2D_fjt81") +debug_color = Color(0.9882353, 0, 0.30980393, 0.41960785) + [node name="GridMarker" parent="." unique_id=1390656323 instance=ExtResource("2_gc0wv")] diff --git a/grid_marker.tscn b/grid_marker.tscn index e7710e6..636bb76 100644 --- a/grid_marker.tscn +++ b/grid_marker.tscn @@ -1,11 +1,6 @@ [gd_scene format=3 uid="uid://bxqhci3fya80t"] -[ext_resource type="Texture2D" uid="uid://nwj4n7if8kqd" path="res://circle25r.png" id="1_0j65c"] [ext_resource type="Script" uid="uid://cob0pwghnubxa" path="res://GridMarker.cs" id="1_u0re5"] [node name="GridMarker" type="Marker2D" unique_id=1390656323] script = ExtResource("1_u0re5") - -[node name="Sprite2D" type="Sprite2D" parent="." unique_id=1491405727] -scale = Vector2(0.1, 0.1) -texture = ExtResource("1_0j65c") diff --git a/main.tscn b/main.tscn index 02782ce..64a1f16 100644 --- a/main.tscn +++ b/main.tscn @@ -1,14 +1,16 @@ [gd_scene format=3 uid="uid://dcp7p6al4i0b7"] [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_2d.tscn" id="3_h2yge"] +[ext_resource type="PackedScene" uid="uid://c6b188d2a20eq" path="res://enemy_controller.tscn" id="4_1bvp3"] +[ext_resource type="PackedScene" uid="uid://b7kvx7p0b2086" path="res://player_controller.tscn" id="4_lquwl"] [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="GridMap2D" parent="." unique_id=1123610167 instance=ExtResource("3_h2yge")] -position = Vector2(960, 510) -_showMarkers = false +position = Vector2(960, 600) + +[node name="EnemyController" parent="." unique_id=1894449838 instance=ExtResource("4_1bvp3")] + +[node name="PlayerController" parent="." unique_id=364781168 instance=ExtResource("4_lquwl")] diff --git a/player_controller.tscn b/player_controller.tscn new file mode 100644 index 0000000..fbd9b1c --- /dev/null +++ b/player_controller.tscn @@ -0,0 +1,9 @@ +[gd_scene format=3 uid="uid://b7kvx7p0b2086"] + +[ext_resource type="Script" uid="uid://cfohujgs5dygx" path="res://PlayerController.cs" id="1_lvefo"] +[ext_resource type="PackedScene" uid="uid://d06n7p75u130s" path="res://tower.tscn" id="2_f0yg5"] + +[node name="PlayerController" type="Node2D" unique_id=317732890] +script = ExtResource("1_lvefo") + +[node name="Tower1" parent="." unique_id=1315831332 instance=ExtResource("2_f0yg5")] diff --git a/project.godot b/project.godot index 74a703a..84e0849 100644 --- a/project.godot +++ b/project.godot @@ -37,6 +37,11 @@ escape={ "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) ] } +rightClick={ +"deadzone": 0.2, +"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":2,"position":Vector2(109, 18),"global_position":Vector2(118, 66),"factor":1.0,"button_index":2,"canceled":false,"pressed":true,"double_click":false,"script":null) +] +} [physics] diff --git a/tower.tscn b/tower.tscn new file mode 100644 index 0000000..189c90a --- /dev/null +++ b/tower.tscn @@ -0,0 +1,22 @@ +[gd_scene format=3 uid="uid://d06n7p75u130s"] + +[ext_resource type="Script" uid="uid://b2gj1526x4ix1" path="res://Tower.cs" id="1_k1sas"] +[ext_resource type="Texture2D" uid="uid://32m5teus1cjj" path="res://Art/tower.png" id="1_vedim"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_vedim"] +size = Vector2(50, 99) + +[node name="Tower" type="Sprite2D" unique_id=1315831332] +self_modulate = Color(0, 0, 0, 1) +texture = ExtResource("1_vedim") +script = ExtResource("1_k1sas") + +[node name="Area" type="Area2D" parent="." unique_id=620986087] + +[node name="Bounds" type="CollisionShape2D" parent="Area" unique_id=1639875880] +position = Vector2(0, 0.5) +shape = SubResource("RectangleShape2D_vedim") +debug_color = Color(0.6411928, 0.52469516, 0, 0.41960785) + +[connection signal="mouse_entered" from="Area" to="." method="OnMouseEntered"] +[connection signal="mouse_exited" from="Area" to="." method="OnMouseExited"] diff --git a/turn_controller.tscn b/turn_controller.tscn new file mode 100644 index 0000000..9ce6cd3 --- /dev/null +++ b/turn_controller.tscn @@ -0,0 +1,6 @@ +[gd_scene format=3 uid="uid://cgqc3wcgqn3q5"] + +[ext_resource type="Script" uid="uid://b5h6v6w5h76cg" path="res://TurnController.cs" id="1_yctlu"] + +[node name="TurnController" type="Node2D" unique_id=197453707] +script = ExtResource("1_yctlu")