diff --git a/Assets/UI/TextBox.png b/Assets/UI/TextBox.png new file mode 100644 index 0000000..2e9859c Binary files /dev/null and b/Assets/UI/TextBox.png differ diff --git a/Assets/UI/TextBox.png.import b/Assets/UI/TextBox.png.import new file mode 100644 index 0000000..6d23a88 --- /dev/null +++ b/Assets/UI/TextBox.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/TextBox.png-2ad7bec0b4178924442104273f95e7b4.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Assets/UI/TextBox.png" +dest_files=[ "res://.import/TextBox.png-2ad7bec0b4178924442104273f95e7b4.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/Code Combat.csproj b/Code Combat.csproj new file mode 100644 index 0000000..ad87733 --- /dev/null +++ b/Code Combat.csproj @@ -0,0 +1,6 @@ + + + net472 + CodeCombat + + \ No newline at end of file diff --git a/Code Combat.csproj.old b/Code Combat.csproj.old new file mode 100644 index 0000000..8a6563a --- /dev/null +++ b/Code Combat.csproj.old @@ -0,0 +1,6 @@ + + + net472 + CodeCombat + + \ No newline at end of file diff --git a/Code Combat.sln b/Code Combat.sln new file mode 100644 index 0000000..8587323 --- /dev/null +++ b/Code Combat.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Code Combat", "Code Combat.csproj", "{C43DDD98-445D-4980-B226-93C668245C1D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + ExportDebug|Any CPU = ExportDebug|Any CPU + ExportRelease|Any CPU = ExportRelease|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C43DDD98-445D-4980-B226-93C668245C1D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C43DDD98-445D-4980-B226-93C668245C1D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C43DDD98-445D-4980-B226-93C668245C1D}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU + {C43DDD98-445D-4980-B226-93C668245C1D}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU + {C43DDD98-445D-4980-B226-93C668245C1D}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU + {C43DDD98-445D-4980-B226-93C668245C1D}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU + EndGlobalSection +EndGlobal diff --git a/Levels/ArenaManager.cs b/Levels/ArenaManager.cs index 3de1493..b59af01 100644 --- a/Levels/ArenaManager.cs +++ b/Levels/ArenaManager.cs @@ -1,4 +1,6 @@ using System.Collections.Generic; +using System; +using System.IO; using CodeBlitz.Objects; using Godot; @@ -8,27 +10,24 @@ public class ArenaManager : Node2D { List YellowTeam = new List(); List RedTeam = new List(); + private List _troopNames = new List(); private PackedScene _archerScene; private PackedScene _basicScene; private PackedScene _tankScene; private PackedScene _wizardScene; private PackedScene _knightScene; + private List _inputList = new List(); private PackedScene _smokeScene; + private Random _random = new Random(); private string _attacker = "Yellow"; private string _defender = "Red"; private WorldManager _worldManager; private Highlight _worldHighlight; private PlayerHighlight _playerHighlight; - private Entity currentEntity; private Entity previousEntity; private int _troopsMoved = 0; - private int _troopIndex = 0; - private bool _canAttack = false; - private bool _canChoosetarget = false; - private bool _canChooseLoc = false; - private bool _canWalk = false; - private bool _unitSelected = false; - private string _state = string.Empty; + private int _troopsSpawned = 0; + private bool isSpawn = true; private string _currentTeamSpawning = "Yellow"; [Signal] public delegate void DisplayTroopList(string team); [Signal] public delegate void UpdateTroopList(string team); @@ -48,14 +47,72 @@ public override void _Ready() _knightScene = ResourceLoader.Load("res://Objects/Knight.tscn"); _smokeScene = ResourceLoader.Load("res://Objects/Smoke.tscn"); Connect(nameof(GameOver), this, nameof(_end_Game)); + + StreamReader sr = new StreamReader("Troop Names.txt"); + string line; + while ((line = sr.ReadLine()) != null) + { + _troopNames.Add(line); + } } + public override void _Input(InputEvent @event) + { + if(isSpawn && @event is InputEventMouse eventKey && eventKey.IsPressed()) + { + var position = _worldManager.WorldToMap(eventKey.Position); + if(!_worldManager.ExistsInArray(position, _worldManager.Obstacles) + && !_worldManager.ExistsInArray(position, _worldManager.Players)) + { + Entity entity; + Vector2 half = (_worldManager.CellSize / 2) / 2; + string name = _troopNames[_random.Next(0, _troopNames.Count - 1)]; + _troopNames.Remove(name); + if(_currentTeamSpawning == "Yellow") + { + entity = GetInstance(Troops.YellowTeam[_troopsSpawned]).Instance() as Entity; + entity.Name = Troops.YellowTeam[_troopsSpawned]; + YellowTeam.Add(entity); + } + else + { + entity = GetInstance(Troops.RedTeam[_troopsSpawned]).Instance() as Entity; + entity.Name = Troops.RedTeam[_troopsSpawned]; + RedTeam.Add(entity); + } + entity.Name = name; + entity.GetNode