From cfd615bf0721a588aaffc9e8cb9907cccff67c47 Mon Sep 17 00:00:00 2001 From: tibz Date: Sun, 27 Sep 2026 12:35:08 -0500 Subject: [PATCH] more cleanup and refactoring --- .../Core/ScreenManager/ScreenManager.cs | 2 +- .../Data/BattleObjects/SkillDefines.cs | 2 +- Johnmagotchi/GameContent/Logic/BattleLogic.cs | 152 +++++------ .../GameContent/Logic/MovementCostTable.cs | 2 +- .../BattleObjects/AttackObj.cs | 2 +- .../BattleObjects/BattleObjectManager.cs | 50 ++-- .../{UglyUnits => }/BattleObjects/SkillObj.cs | 2 +- .../BattleObjects/SupportObj.cs | 2 +- .../GameContent/Objects/Maps/BattleMap.cs | 245 +++--------------- .../Objects/Maps/MapMovementNode.cs | 7 +- .../GameContent/Objects/UI/UnitDisplay.cs | 5 +- .../Objects/UglyUnits/UnitObject.cs | 226 ---------------- .../Units/GameLogic/BaseUnitGameObject.cs | 8 +- .../Stats}/Loadouts/LoadoutModule.cs | 2 +- .../Loadouts/PlayerClasses/PlayerClass.cs | 8 +- .../Stats}/Loadouts/UnitLoadout.cs | 14 +- .../Stats}/Loadouts/UnitLoadoutManager.cs | 2 +- .../Stats}/UnitCurrentStatus.cs | 7 +- .../Stats}/UnitStatBlock.cs | 2 +- .../Objects/Units/Stats/UnitStats.cs | 5 +- .../GameContent/Objects/Units/Unit.cs | 3 +- .../{UglyUnits => Units}/UnitLoader.cs | 23 +- .../Screens/MapScreens/BaseMapScreen.cs | 1 - .../BattleMapScreen/BattleMapScreen.cs | 3 +- .../MapScreens/MapEditor/MapEditorScreen.cs | 4 - 25 files changed, 188 insertions(+), 591 deletions(-) rename Johnmagotchi/GameContent/Objects/{UglyUnits => }/BattleObjects/AttackObj.cs (90%) rename Johnmagotchi/GameContent/Objects/{UglyUnits => }/BattleObjects/BattleObjectManager.cs (81%) rename Johnmagotchi/GameContent/Objects/{UglyUnits => }/BattleObjects/SkillObj.cs (85%) rename Johnmagotchi/GameContent/Objects/{UglyUnits => }/BattleObjects/SupportObj.cs (88%) delete mode 100644 Johnmagotchi/GameContent/Objects/UglyUnits/UnitObject.cs rename Johnmagotchi/GameContent/Objects/{UglyUnits => Units/Stats}/Loadouts/LoadoutModule.cs (95%) rename Johnmagotchi/GameContent/Objects/{UglyUnits => Units/Stats}/Loadouts/PlayerClasses/PlayerClass.cs (97%) rename Johnmagotchi/GameContent/Objects/{UglyUnits => Units/Stats}/Loadouts/UnitLoadout.cs (88%) rename Johnmagotchi/GameContent/Objects/{UglyUnits => Units/Stats}/Loadouts/UnitLoadoutManager.cs (73%) rename Johnmagotchi/GameContent/Objects/{UglyUnits/BattleObjects => Units/Stats}/UnitCurrentStatus.cs (83%) rename Johnmagotchi/GameContent/Objects/{UglyUnits/BattleObjects => Units/Stats}/UnitStatBlock.cs (94%) rename Johnmagotchi/GameContent/Objects/{UglyUnits => Units}/UnitLoader.cs (88%) diff --git a/Johnmagotchi/Core/ScreenManager/ScreenManager.cs b/Johnmagotchi/Core/ScreenManager/ScreenManager.cs index e23c741..8ffd907 100644 --- a/Johnmagotchi/Core/ScreenManager/ScreenManager.cs +++ b/Johnmagotchi/Core/ScreenManager/ScreenManager.cs @@ -6,7 +6,7 @@ using System.Reflection.Metadata; using System.Text; using Johnmagotchi.Core.tools; using Johnmagotchi.Data; -using Johnmagotchi.GameContent.Objects.Units.BattleObjects; +using Johnmagotchi.GameContent.Objects.BattleObjects; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; diff --git a/Johnmagotchi/Data/BattleObjects/SkillDefines.cs b/Johnmagotchi/Data/BattleObjects/SkillDefines.cs index fb592be..6143b5d 100644 --- a/Johnmagotchi/Data/BattleObjects/SkillDefines.cs +++ b/Johnmagotchi/Data/BattleObjects/SkillDefines.cs @@ -1,4 +1,4 @@ -using Johnmagotchi.GameContent.Objects.Units.BattleObjects; +using Johnmagotchi.GameContent.Objects.BattleObjects; using System; using System.Collections.Generic; using System.Linq; diff --git a/Johnmagotchi/GameContent/Logic/BattleLogic.cs b/Johnmagotchi/GameContent/Logic/BattleLogic.cs index 7c28696..bcb0ff4 100644 --- a/Johnmagotchi/GameContent/Logic/BattleLogic.cs +++ b/Johnmagotchi/GameContent/Logic/BattleLogic.cs @@ -1,6 +1,4 @@ using Johnmagotchi.GameContent.Objects.Units; -using Johnmagotchi.GameContent.Objects.Units.BattleObjects; -using Johnmagotchi.GameContent.Units; using System; using System.Collections.Generic; using System.Diagnostics; @@ -16,7 +14,8 @@ namespace Johnmagotchi.GameContent.Logic { private static double CriticalMultiplier = 1.5; public static Random Random = new Random(); - public static BattleResults RunBattle(ref Unit Attacker, ref Unit Defender, AttackObj attack, AttackObj counterAttack) { + public static BattleResults RunBattle(ref Unit Attacker, ref Unit Defender) + { // these are debugs, should be parsed from attack + unit combos bool IsCounterAttackOccuring = true; @@ -25,98 +24,99 @@ namespace Johnmagotchi.GameContent.Logic BattleResults results = new BattleResults(); // battle results will determine how the battles are animated - // for each combat, we need to do each attack phase that occurs apply results here + //// for each combat, we need to do each attack phase that occurs apply results here - //Initial Attack - HandleAttackPhase(ref Attacker, ref Defender, attack, ref results, false); + ////Initial Attack + //HandleAttackPhase(ref Attacker, ref Defender, attack, ref results, false); - //Enemy's counter attack - if (IsCounterAttackOccuring) - { - HandleAttackPhase(ref Defender, ref Attacker, counterAttack, ref results, true); - } - // FE style double attack - if (IsDoubleAttackOccuring) - { - HandleAttackPhase(ref Attacker, ref Defender, attack, ref results, false); - } - // FE style Double Counter Attack - if (IsDoubleCounterAttackOccuring) - { - HandleAttackPhase(ref Defender, ref Attacker, counterAttack, ref results, true); - } + ////Enemy's counter attack + //if (IsCounterAttackOccuring) + //{ + // HandleAttackPhase(ref Defender, ref Attacker, counterAttack, ref results, true); + //} + //// FE style double attack + //if (IsDoubleAttackOccuring) + //{ + // HandleAttackPhase(ref Attacker, ref Defender, attack, ref results, false); + //} + //// FE style Double Counter Attack + //if (IsDoubleCounterAttackOccuring) + //{ + // HandleAttackPhase(ref Defender, ref Attacker, counterAttack, ref results, true); + //} return results; } - + // this is each step - public static void HandleAttackPhase( - ref Unit Attacker, ref Unit Defender, AttackObj attack, - ref BattleResults results, bool isCounter) - { - int hitcount = attack.BaseHitCount; // anything that adjusts how many times an attack happens PER PHASE should be adjusted here + //public static void HandleAttackPhase( + // ref Unit Attacker, ref Unit Defender, AttackObj attack, + // ref BattleResults results, bool isCounter) + //{ + // int hitcount = attack.BaseHitCount; // anything that adjusts how many times an attack happens PER PHASE should be adjusted here - for (int i = 0; i < hitcount; i++) { - - int hitRoll = BattleLogic.Random.Next(100) + 1; // random int 1 - 100 - int hitThreshold = attack.BaseAccuracy + Attacker.stats.baseStats.Speed - Defender.stats.baseStats.Speed; + // for (int i = 0; i < hitcount; i++) { - // this should be adjusted, in FE games its usally something like...... - // ATTACKER = Hit + (Skill × 2) + (Luck / 2) + (Support bonus)+(Weapon triangle advantage/ disadvantage) +(S level bonus) - // DEFENDER = ((Attack speed × 2) +(Luck) + (Terrain bonus) +(Support bonus) +Tactician bonus) ) - // hit perentage = attacker - defender + // int hitRoll = BattleLogic.Random.Next(100) + 1; // random int 1 - 100 + // int hitThreshold = attack.BaseAccuracy + Attacker.stats.baseStats.Speed - Defender.stats.baseStats.Speed; - int critThreshold = 95; + // // this should be adjusted, in FE games its usally something like...... + // // ATTACKER = Hit + (Skill × 2) + (Luck / 2) + (Support bonus)+(Weapon triangle advantage/ disadvantage) +(S level bonus) + // // DEFENDER = ((Attack speed × 2) +(Luck) + (Terrain bonus) +(Support bonus) +Tactician bonus) ) + // // hit perentage = attacker - defender + + // int critThreshold = 95; - if (hitRoll < hitThreshold) //handle misses - { - - results.addResult(BattleResults.resultType.MISS, 0, isCounter); - } - else if (hitRoll >= critThreshold) //Handle Crits - { - - if (Defender.stats.status.CurrentShieldCount > 1) Defender.stats.status.CurrentShieldCount--; // as is, crits ignore shields but should still tick a shield down - if (Defender.stats.status.CurrentShieldCount < 0) Defender.stats.status.CurrentShieldCount = 0; - int BaseDamage = CalculateDamage(Attacker,Defender,attack); - int TotalCritDamage = (int) Math.Ceiling (BaseDamage * CriticalMultiplier); + // if (hitRoll < hitThreshold) //handle misses + // { - //apply Damage to defending unit, then add to result report - Defender.stats.status.CurrentHealth -= TotalCritDamage; - results.addResult(BattleResults.resultType.CRITICAL, TotalCritDamage, isCounter); + // results.addResult(BattleResults.resultType.MISS, 0, isCounter); + // } + // else if (hitRoll >= critThreshold) //Handle Crits + // { - } - else if (Defender.stats.status.CurrentShieldCount > 1) // Shielded - { - Defender.stats.status.CurrentShieldCount--; - results.addResult(BattleResults.resultType.SHIELDED,1, isCounter); // 1 siginfies 1 shield lost - } - else // normal attack - { - int BaseDamage = CalculateDamage(Attacker, Defender, attack); + // if (Defender.stats.status.CurrentShieldCount > 1) Defender.stats.status.CurrentShieldCount--; // as is, crits ignore shields but should still tick a shield down + // if (Defender.stats.status.CurrentShieldCount < 0) Defender.stats.status.CurrentShieldCount = 0; + // int BaseDamage = CalculateDamage(Attacker,Defender,attack); + // int TotalCritDamage = (int) Math.Ceiling (BaseDamage * CriticalMultiplier); - //Apply damage + report to animation handler - Defender.stats.status.CurrentHealth -= BaseDamage; - results.addResult(BattleResults.resultType.ATTACK, BaseDamage, isCounter); - } - } - return; - } + // //apply Damage to defending unit, then add to result report + // Defender.stats.status.CurrentHealth -= TotalCritDamage; + // results.addResult(BattleResults.resultType.CRITICAL, TotalCritDamage, isCounter); - private static int CalculateDamage( Unit Attacker, Unit Defender, AttackObj attack) - { - int damage = 0; + // } + // else if (Defender.stats.status.CurrentShieldCount > 1) // Shielded + // { + // Defender.stats.status.CurrentShieldCount--; + // results.addResult(BattleResults.resultType.SHIELDED,1, isCounter); // 1 siginfies 1 shield lost + // } + // else // normal attack + // { + // int BaseDamage = CalculateDamage(Attacker, Defender, attack); - damage += attack.BaseDamage; - damage += Attacker.stats.baseStats.Attack; + // //Apply damage + report to animation handler + // Defender.stats.status.CurrentHealth -= BaseDamage; + // results.addResult(BattleResults.resultType.ATTACK, BaseDamage, isCounter); + // } + // } + // return; + //} - damage -= Defender.stats.baseStats.Defense; + // private static int CalculateDamage( Unit Attacker, Unit Defender, AttackObj attack) + // { + // int damage = 0; + + // damage += attack.BaseDamage; + // damage += Attacker.stats.baseStats.Attack; + + // damage -= Defender.stats.baseStats.Defense; - if (damage < 0) damage = 0; - return damage ; - } + // if (damage < 0) damage = 0; + // return damage ; + // } + //} } } diff --git a/Johnmagotchi/GameContent/Logic/MovementCostTable.cs b/Johnmagotchi/GameContent/Logic/MovementCostTable.cs index 5c2c06c..a610f5a 100644 --- a/Johnmagotchi/GameContent/Logic/MovementCostTable.cs +++ b/Johnmagotchi/GameContent/Logic/MovementCostTable.cs @@ -4,7 +4,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using static Johnmagotchi.GameContent.Objects.Units.BattleObjects.UnitStatBlock; +using static Johnmagotchi.GameContent.Objects.Units.Stats.UnitStatBlock; namespace Johnmagotchi.GameContent.Logic { diff --git a/Johnmagotchi/GameContent/Objects/UglyUnits/BattleObjects/AttackObj.cs b/Johnmagotchi/GameContent/Objects/BattleObjects/AttackObj.cs similarity index 90% rename from Johnmagotchi/GameContent/Objects/UglyUnits/BattleObjects/AttackObj.cs rename to Johnmagotchi/GameContent/Objects/BattleObjects/AttackObj.cs index 536dfd4..1ce8aec 100644 --- a/Johnmagotchi/GameContent/Objects/UglyUnits/BattleObjects/AttackObj.cs +++ b/Johnmagotchi/GameContent/Objects/BattleObjects/AttackObj.cs @@ -5,7 +5,7 @@ using System.Text; using System.Threading.Tasks; using static Johnmagotchi.Data.BattleObjects.AttackDefines; -namespace Johnmagotchi.GameContent.Objects.Units.BattleObjects +namespace Johnmagotchi.GameContent.Objects.BattleObjects { public class AttackObj { diff --git a/Johnmagotchi/GameContent/Objects/UglyUnits/BattleObjects/BattleObjectManager.cs b/Johnmagotchi/GameContent/Objects/BattleObjects/BattleObjectManager.cs similarity index 81% rename from Johnmagotchi/GameContent/Objects/UglyUnits/BattleObjects/BattleObjectManager.cs rename to Johnmagotchi/GameContent/Objects/BattleObjects/BattleObjectManager.cs index fad73c6..404af27 100644 --- a/Johnmagotchi/GameContent/Objects/UglyUnits/BattleObjects/BattleObjectManager.cs +++ b/Johnmagotchi/GameContent/Objects/BattleObjects/BattleObjectManager.cs @@ -1,16 +1,12 @@ using Johnmagotchi.Core.tools; using Johnmagotchi.Data.BattleObjects; -using Johnmagotchi.GameContent.Units; using System; using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using static Johnmagotchi.Data.BattleObjects.AttackDefines; using static Johnmagotchi.Data.BattleObjects.SupportDefines; -namespace Johnmagotchi.GameContent.Objects.Units.BattleObjects +namespace Johnmagotchi.GameContent.Objects.BattleObjects { public static class BattleObjectManager { @@ -48,9 +44,9 @@ namespace Johnmagotchi.GameContent.Objects.Units.BattleObjects public static List LoadAttacks() { List AttackList = new List(); - System.Console.WriteLine("PATH: {0}", Directory.GetCurrentDirectory()); + Console.WriteLine("PATH: {0}", Directory.GetCurrentDirectory()); var path = "..\\..\\..\\Data\\BattleObjects\\AttackDefinitions.csv"; - System.Console.WriteLine("path: {0} ", path); + Console.WriteLine("path: {0} ", path); // these let us resolve which column is which int IDIndex = -1; @@ -101,17 +97,17 @@ namespace Johnmagotchi.GameContent.Objects.Units.BattleObjects { AttackObj attack = new AttackObj(); - attack.ID = Int32.Parse(values[IDIndex]); + attack.ID = int.Parse(values[IDIndex]); attack.AttackName = values[AttackNameIndex]; - attack.BaseDamage = Int32.Parse(values[BaseDamageIndex]); - attack.BaseHitCount = Int32.Parse(values[BaseHitCountIndex]); - attack.BaseSpeed = Int32.Parse(values[BaseSpeedIndex]); - attack.BaseAccuracy = Int32.Parse(values[BaseAccuracyIndex]); - attack.AttackRangeMin = Int32.Parse(values[AttackRangeMinIndex]); - attack.AttackRangeMax = Int32.Parse(values[AttackRangeMaxIndex]); - attack.AttackType = AttackDefines.ParseAttackTypes(values[AttackTypeIndex]); - attack.SpecialProperties = AttackDefines.ParseSpecialAttackProperties(values[SpecialPropertiesIndex]); - attack.DamageType = AttackDefines.ParseDamageTypes(values[DamageTypeIndex]); + attack.BaseDamage = int.Parse(values[BaseDamageIndex]); + attack.BaseHitCount = int.Parse(values[BaseHitCountIndex]); + attack.BaseSpeed = int.Parse(values[BaseSpeedIndex]); + attack.BaseAccuracy = int.Parse(values[BaseAccuracyIndex]); + attack.AttackRangeMin = int.Parse(values[AttackRangeMinIndex]); + attack.AttackRangeMax = int.Parse(values[AttackRangeMaxIndex]); + attack.AttackType = ParseAttackTypes(values[AttackTypeIndex]); + attack.SpecialProperties = ParseSpecialAttackProperties(values[SpecialPropertiesIndex]); + attack.DamageType = ParseDamageTypes(values[DamageTypeIndex]); AttackList.Add(attack); } @@ -125,9 +121,9 @@ namespace Johnmagotchi.GameContent.Objects.Units.BattleObjects { List SkillList = new List(); - System.Console.WriteLine("PATH: {0}", Directory.GetCurrentDirectory()); + Console.WriteLine("PATH: {0}", Directory.GetCurrentDirectory()); var path = "..\\..\\..\\Data\\BattleObjects\\SkillDefinitions.csv"; - System.Console.WriteLine("path: {0} ", path); + Console.WriteLine("path: {0} ", path); // ID,SkillName,SkillType,Value,Description // these let us resolve which column is which @@ -169,10 +165,10 @@ namespace Johnmagotchi.GameContent.Objects.Units.BattleObjects { SkillObj skill = new SkillObj(); - skill.ID = Int32.Parse(values[IDIndex]); + skill.ID = int.Parse(values[IDIndex]); skill.SkillName = values[SkillNameIndex]; skill.SkillType = SkillDefines.ParseSkillTypes(values[SkillTypeIndex]); - skill.Value = Int32.Parse(values[ValueIndex]); + skill.Value = int.Parse(values[ValueIndex]); skill.Description = values[DescriptionIndex]; SkillList.Add(skill); @@ -187,9 +183,9 @@ namespace Johnmagotchi.GameContent.Objects.Units.BattleObjects List SupportList = new List(); - System.Console.WriteLine("PATH: {0}", Directory.GetCurrentDirectory()); + Console.WriteLine("PATH: {0}", Directory.GetCurrentDirectory()); var path = "..\\..\\..\\Data\\BattleObjects\\SupportDefinitions.csv"; - System.Console.WriteLine("path: {0} ", path); + Console.WriteLine("path: {0} ", path); //ID,SupportName,SupportTarget,SupportType,Value,Description // these let us resolve which column is which @@ -234,11 +230,11 @@ namespace Johnmagotchi.GameContent.Objects.Units.BattleObjects { SupportObj support = new SupportObj(); - support.ID = Int32.Parse(values[IDIndex]); + support.ID = int.Parse(values[IDIndex]); support.Name = values[SupportlNameIndex]; - support.type = SupportDefines.ParseSupportTypes(values[SupportTypeIndex]); - support.target = SupportDefines.ParseSupportTargets(values[SupportTargetIndex]); - support.Value = Int32.Parse(values[ValueIndex]); + support.type = ParseSupportTypes(values[SupportTypeIndex]); + support.target = ParseSupportTargets(values[SupportTargetIndex]); + support.Value = int.Parse(values[ValueIndex]); support.Description = values[DescriptionIndex]; SupportList.Add(support); diff --git a/Johnmagotchi/GameContent/Objects/UglyUnits/BattleObjects/SkillObj.cs b/Johnmagotchi/GameContent/Objects/BattleObjects/SkillObj.cs similarity index 85% rename from Johnmagotchi/GameContent/Objects/UglyUnits/BattleObjects/SkillObj.cs rename to Johnmagotchi/GameContent/Objects/BattleObjects/SkillObj.cs index 19caf99..2442f23 100644 --- a/Johnmagotchi/GameContent/Objects/UglyUnits/BattleObjects/SkillObj.cs +++ b/Johnmagotchi/GameContent/Objects/BattleObjects/SkillObj.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Johnmagotchi.GameContent.Objects.Units.BattleObjects +namespace Johnmagotchi.GameContent.Objects.BattleObjects { public class SkillObj { diff --git a/Johnmagotchi/GameContent/Objects/UglyUnits/BattleObjects/SupportObj.cs b/Johnmagotchi/GameContent/Objects/BattleObjects/SupportObj.cs similarity index 88% rename from Johnmagotchi/GameContent/Objects/UglyUnits/BattleObjects/SupportObj.cs rename to Johnmagotchi/GameContent/Objects/BattleObjects/SupportObj.cs index 131cbd3..f70013b 100644 --- a/Johnmagotchi/GameContent/Objects/UglyUnits/BattleObjects/SupportObj.cs +++ b/Johnmagotchi/GameContent/Objects/BattleObjects/SupportObj.cs @@ -5,7 +5,7 @@ using System.Text; using System.Threading.Tasks; using static Johnmagotchi.Data.BattleObjects.SupportDefines; -namespace Johnmagotchi.GameContent.Objects.Units.BattleObjects +namespace Johnmagotchi.GameContent.Objects.BattleObjects { public class SupportObj { diff --git a/Johnmagotchi/GameContent/Objects/Maps/BattleMap.cs b/Johnmagotchi/GameContent/Objects/Maps/BattleMap.cs index dc69345..e94caff 100644 --- a/Johnmagotchi/GameContent/Objects/Maps/BattleMap.cs +++ b/Johnmagotchi/GameContent/Objects/Maps/BattleMap.cs @@ -8,7 +8,6 @@ using System.Threading.Tasks; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using TibzGame.Core.ScreenManager; -using Johnmagotchi.GameContent.Units; using Johnmagotchi.Core.tools; using System.Runtime.ExceptionServices; using Johnmagotchi.GameContent.Objects.Units; @@ -22,16 +21,14 @@ namespace Johnmagotchi.GameContent.Objects public int height{ get; set; } public string serializedMapTiles{ get; set; } - public string serializedPlayerUnits { get; set; } - public string serializedEnemyUnits{ get; set; } - public string serializedNpcUnits { get; set; } - + public string serializedUnits { get; set; } private MapTile [,] MapTileGrid; - private List playerUnits; - private List enemyUnits; - private List npcUnits; + private List Units; + //private List playerUnits; + //private List enemyUnits; + //private List npcUnits; private SpriteBatch _spriteBatch; private ScreenManager _screenManager; @@ -52,9 +49,10 @@ namespace Johnmagotchi.GameContent.Objects this.height = h; // default min height (shooting for 360 x 640 res, 40x40 pixel grid) this.width = w; MapTileGrid = new MapTile[width,height]; - this.playerUnits = new List(); - this.npcUnits = new List(); - this.enemyUnits = new List(); + this.Units = new List(); + //this.playerUnits = new List(); + //this.npcUnits = new List(); + //this.enemyUnits = new List(); } public void Init(ScreenManager ScreenManager){ @@ -75,15 +73,7 @@ namespace Johnmagotchi.GameContent.Objects public void Update() { - foreach (Unit unit in playerUnits) - { - unit.Update(); - } - foreach (Unit unit in enemyUnits) - { - unit.Update(); - } - foreach (Unit unit in npcUnits) + foreach (Unit unit in Units) { unit.Update(); } @@ -161,24 +151,11 @@ namespace Johnmagotchi.GameContent.Objects public void DrawUnits(int xOffset, int yOffset) { - - foreach(Unit unit in playerUnits) { + foreach(Unit unit in Units) { int xLocation = (unit.xPos * MapTile.TILE_WIDTH_PX) + xOffset; int yLocation = (unit.yPos * MapTile.TILE_HEIGHT_PX) + yOffset; unit.DrawAt( xLocation, yLocation); } - foreach (Unit unit in enemyUnits) - { - int xLocation = (unit.xPos * MapTile.TILE_WIDTH_PX) + xOffset; - int yLocation = (unit.yPos * MapTile.TILE_HEIGHT_PX) + yOffset; - unit.DrawAt( xLocation, yLocation); - } - foreach (Unit unit in npcUnits) - { - int xLocation = (unit.xPos * MapTile.TILE_WIDTH_PX) + xOffset; - int yLocation = (unit.yPos * MapTile.TILE_HEIGHT_PX) + yOffset; - unit.DrawAt(xLocation, yLocation); - } } public void ChangeTileType(int x, int y, TileType newType) @@ -226,62 +203,30 @@ namespace Johnmagotchi.GameContent.Objects } public void SerializeUnitData() { - List player = new List(); - List enemy = new List(); - List npc = new List(); - - foreach (Unit unit in playerUnits) { - player.Add(unit.GetAsSerialized()); + List units_str = new List(); + + foreach (Unit unit in Units) { + units_str.Add(unit.GetAsSerialized()); } - foreach (Unit unit in enemyUnits) { - enemy.Add(unit.GetAsSerialized()); - } - foreach (Unit unit in npcUnits) - { - npc.Add(unit.GetAsSerialized()); - } - serializedPlayerUnits = JsonSerializer.Serialize(player); - serializedEnemyUnits = JsonSerializer.Serialize(enemy); - serializedNpcUnits = JsonSerializer.Serialize(npc); - - TibzLog.Debug("P:" + player.Count + " E:" + enemy.Count + " N:" + npc.Count); + + serializedUnits = JsonSerializer.Serialize(units_str); + TibzLog.Debug("Units: " + Units.Count); } public void DeserializeUnitData() { TibzLog.Debug("Deserializing unit data"); - List OutPlayerUnits = new List(); - List OutEnemyUnits = new List(); - List OutNpcUnits = new List(); + List outUnits = new List(); - List players = JsonSerializer.Deserialize>(serializedPlayerUnits); - List enemies = JsonSerializer.Deserialize>(serializedEnemyUnits); - List npcs = JsonSerializer.Deserialize>(serializedNpcUnits); + List unitsString = JsonSerializer.Deserialize>(serializedUnits); - foreach(string entry in players) { + foreach(string entry in unitsString) { Unit newUnit = new Unit(entry); TibzLog.Debug(JsonSerializer.Serialize(newUnit)); - OutPlayerUnits.Add(newUnit); // makes new instance from serialized string + outUnits.Add(newUnit); // makes new instance from serialized string newUnit.InitSprite(_screenManager); } - foreach (string entry in enemies) - { - Unit newUnit = new Unit(entry); - OutEnemyUnits.Add(newUnit); // makes new instance from serialized string - newUnit.InitSprite(_screenManager); - } - foreach (string entry in npcs) - { - Unit newUnit = new Unit(entry); - OutNpcUnits.Add(newUnit); // makes new instance from serialized string - newUnit.InitSprite(_screenManager); - } - - playerUnits = OutPlayerUnits; - enemyUnits = OutEnemyUnits; - npcUnits = OutNpcUnits; - - TibzLog.Debug("P:" + playerUnits.Count + " E:" + enemyUnits.Count + " N:" + npcUnits.Count); + Units = outUnits; } public void AddPlayerUnit(Unit unitRef, int xpos, int ypos) @@ -295,25 +240,8 @@ namespace Johnmagotchi.GameContent.Objects unit.SetShaderSet(Unit.SpriteShaderSets.PLAYER_NORMAL); unit.xPos = xpos; unit.yPos = ypos; - //if (unit.isUnique == true) - //{ - // //check then replace - // for (int i = 0; i < playerUnits.Count; i++) - // { - // if (playerUnits[i].id == unit.id ) - // { - // playerUnits[i].xPos = xpos; - // playerUnits[i].yPos = ypos; - // return; // dont add - // } - // } - // playerUnits.Add(unit); // else add - //} - //else { playerUnits.Add(unit); - //} - playerUnits.Add(unit); - unit.stats.status.team = Units.BattleObjects.UnitCurrentStatus.UnitTeam.PLAYER; - + unit.stats.status.team = Objects.Units.Stats.UnitCurrentStatus.UnitTeam.PLAYER; + Units.Add(unit); unit.InitSprite(_screenManager); } @@ -328,24 +256,8 @@ namespace Johnmagotchi.GameContent.Objects unit.SetShaderSet(Unit.SpriteShaderSets.ENEMY_NORMAL); unit.xPos = xpos; unit.yPos = ypos; - //if (unit.isUnique == true) - //{ - // //check then replace - // for (int i = 0; i < enemyUnits.Count; i++) - // { - // if (enemyUnits[i].id == unit.id) - // { - // enemyUnits[i].xPos = xpos; - // enemyUnits[i].yPos = ypos; - // return; // dont add - // } - // } - // enemyUnits.Add(unit); // else add - //} - //else - //{ - enemyUnits.Add(unit); - unit.stats.status.team = Units.BattleObjects.UnitCurrentStatus.UnitTeam.ENEMY; + unit.stats.status.team = Objects.Units.Stats.UnitCurrentStatus.UnitTeam.ENEMY; + Units.Add(unit); unit.InitSprite(_screenManager); } @@ -361,68 +273,29 @@ namespace Johnmagotchi.GameContent.Objects unit.SetShaderSet(Unit.SpriteShaderSets.NPC_NORMAL); unit.xPos = xpos; unit.yPos = ypos; - - //if (unit.isUnique == true) - //{ - // //check then replace - // for (int i = 0; i < npcUnits.Count; i++) - // { - // if (npcUnits[i].id == unit.id) - // { - // enemyUnits[i] = unit; - // return; // dont add - // } - // } - // npcUnits.Add(unit); // else add - //} - //else - //{ - npcUnits.Add(unit); - // } + unit.stats.status.team = Objects.Units.Stats.UnitCurrentStatus.UnitTeam.NPC; + Units.Add(unit); unit.InitSprite(_screenManager); - unit.stats.status.team = Units.BattleObjects.UnitCurrentStatus.UnitTeam.NPC; - - TibzLog.Debug("NPC obj count: {0}", npcUnits.Count); - } public void deleteUnit(Unit unitRef) { - int removePlayerIndex = -1; - int removeEnemyIndex = -1; - int removeNpcIndex = -1; + int removeUnitIndex = -1; - for (int i = 0; i < playerUnits.Count; i++) + for (int i = 0; i < Units.Count; i++) { - if (unitRef.internalID == playerUnits[i].internalID) + if (unitRef.internalID == Units[i].internalID) { - removePlayerIndex = i; + removeUnitIndex = i; break; } } - for (int i = 0; i < enemyUnits.Count; i++) - { - if (unitRef.internalID == enemyUnits[i].internalID) - { - removeEnemyIndex = i; - break; - } - } - for (int i = 0; i < npcUnits.Count; i++) - { - if (unitRef.internalID == npcUnits[i].internalID) - { - removeNpcIndex = i; - break; - } - } - if (removePlayerIndex != -1) { playerUnits.RemoveAt(removePlayerIndex); } - if (removeEnemyIndex != -1) { enemyUnits.RemoveAt(removeEnemyIndex); } - if (removeNpcIndex != -1) { npcUnits.RemoveAt(removeNpcIndex); } + + if (removeUnitIndex != -1) { Units.RemoveAt(removeUnitIndex); } } private bool CheckIfUnitCanBePlaced(Unit unit, int x, int y) { - + if (x < 0 || y < 0 ||x > width || y>height) return false; if (MapTileGrid[x,y].Type == TileType.SEA ) { // add a && unit.Traversal type or whatever, so we check if this unit CAN stand on said tile. return false; } @@ -432,52 +305,28 @@ namespace Johnmagotchi.GameContent.Objects } - public bool CheckIfAnyUnits(int x, int y) { - return CheckIfPlayerUnits(x, y) || CheckIfEnemyUnits(x,y)|| CheckIfNpcUnits(x,y) ; - } - public bool CheckIfPlayerUnits(int CursorX, int CursorY) - { - foreach (Unit Unit in playerUnits) { - if (Unit.xPos == CursorX && Unit.yPos == CursorY) { return true; } - } - return false; - } - public bool CheckIfEnemyUnits(int CursorX, int CursorY) - { - foreach (Unit Unit in enemyUnits) - { - if (Unit.xPos == CursorX && Unit.yPos == CursorY) { return true; } - } - return false; - } - public bool CheckIfNpcUnits(int CursorX, int CursorY) - { - foreach (Unit Unit in npcUnits) + public bool CheckIfAnyUnits(int CursorX, int CursorY) { + foreach (Unit Unit in Units) { if (Unit.xPos == CursorX && Unit.yPos == CursorY) { return true; } } return false; } + public Unit getUnitAtLocation(int CursorX, int CursorY) { - foreach (Unit Unit in playerUnits) - { - if (Unit.xPos == CursorX && Unit.yPos == CursorY) { return Unit; } - } - foreach (Unit Unit in enemyUnits) - { - if (Unit.xPos == CursorX && Unit.yPos == CursorY) { return Unit; } - } - foreach (Unit Unit in npcUnits) + foreach (Unit Unit in Units) { if (Unit.xPos == CursorX && Unit.yPos == CursorY) { return Unit; } } + + return null; } public void moveUnit(Unit unitcopy, int x, int y) { - foreach (Unit Unit in playerUnits) + foreach (Unit Unit in Units) { if (Unit.internalID == unitcopy.internalID) { @@ -485,14 +334,6 @@ namespace Johnmagotchi.GameContent.Objects Unit.yPos = y; } } - foreach (Unit Unit in enemyUnits) - { - if (Unit.internalID == unitcopy.internalID) { } - } - foreach (Unit Unit in npcUnits) - { - if (Unit.internalID == unitcopy.internalID) { } - } } public MapTile getTile(int x, int y) { diff --git a/Johnmagotchi/GameContent/Objects/Maps/MapMovementNode.cs b/Johnmagotchi/GameContent/Objects/Maps/MapMovementNode.cs index de3d5aa..2633f97 100644 --- a/Johnmagotchi/GameContent/Objects/Maps/MapMovementNode.cs +++ b/Johnmagotchi/GameContent/Objects/Maps/MapMovementNode.cs @@ -1,7 +1,6 @@ using Johnmagotchi.Core.tools; using Johnmagotchi.GameContent.Logic; using Johnmagotchi.GameContent.Objects.Units; -using Johnmagotchi.GameContent.Units; using System; using System.Collections.Generic; using System.Windows.Forms.VisualStyles; @@ -145,9 +144,9 @@ namespace Johnmagotchi.GameContent.Objects.Maps Unit targetUnit = currentMap.getUnitAtLocation(x, y); if (targetUnit != null) { if ( - (selectedUnit.stats.status.team == Units.BattleObjects.UnitCurrentStatus.UnitTeam.PLAYER && targetUnit.stats.status.team == Units.BattleObjects.UnitCurrentStatus.UnitTeam.ENEMY) || - (selectedUnit.stats.status.team == Units.BattleObjects.UnitCurrentStatus.UnitTeam.ENEMY && (targetUnit.stats.status.team == Units.BattleObjects.UnitCurrentStatus.UnitTeam.PLAYER || - targetUnit.stats.status.team == Units.BattleObjects.UnitCurrentStatus.UnitTeam.NPC)) + (selectedUnit.stats.status.team == Units.Stats.UnitCurrentStatus.UnitTeam.PLAYER && targetUnit.stats.status.team == Units.Stats.UnitCurrentStatus.UnitTeam.ENEMY) || + (selectedUnit.stats.status.team == Units.Stats.UnitCurrentStatus.UnitTeam.ENEMY && (targetUnit.stats.status.team == Units.Stats.UnitCurrentStatus.UnitTeam.PLAYER || + targetUnit.stats.status.team == Units.Stats.UnitCurrentStatus.UnitTeam.NPC)) ) { return 0; diff --git a/Johnmagotchi/GameContent/Objects/UI/UnitDisplay.cs b/Johnmagotchi/GameContent/Objects/UI/UnitDisplay.cs index f165f8f..93d99a7 100644 --- a/Johnmagotchi/GameContent/Objects/UI/UnitDisplay.cs +++ b/Johnmagotchi/GameContent/Objects/UI/UnitDisplay.cs @@ -1,6 +1,5 @@ using Johnmagotchi.Core.tools; using Johnmagotchi.GameContent.Objects.Units; -using Johnmagotchi.GameContent.Units; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; @@ -63,11 +62,11 @@ namespace Johnmagotchi.GameContent.Objects.UI if (HighlightedUnit == null) { return; } Texture2D texture = UnitDisplayTexture; - if (HighlightedUnit.stats.status.team == Units.BattleObjects.UnitCurrentStatus.UnitTeam.ENEMY) + if (HighlightedUnit.stats.status.team == Units.Stats.UnitCurrentStatus.UnitTeam.ENEMY) { texture = EnemyDisplayTexture; } - if (HighlightedUnit.stats.status.team == Units.BattleObjects.UnitCurrentStatus.UnitTeam.NPC) + if (HighlightedUnit.stats.status.team == Units.Stats.UnitCurrentStatus.UnitTeam.NPC) { texture = NpcDisplayTexture; } diff --git a/Johnmagotchi/GameContent/Objects/UglyUnits/UnitObject.cs b/Johnmagotchi/GameContent/Objects/UglyUnits/UnitObject.cs deleted file mode 100644 index 76f36a5..0000000 --- a/Johnmagotchi/GameContent/Objects/UglyUnits/UnitObject.cs +++ /dev/null @@ -1,226 +0,0 @@ - - - -using Johnmagotchi.Core.tools; -using Johnmagotchi.GameContent.Objects; -using Johnmagotchi.GameContent.Objects.Units.BattleObjects; -using Johnmagotchi.GameContent.Objects.Units.Loadouts; -using Johnmagotchi.GameContent.Objects.Units.Loadouts.PlayerClasses; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System.Collections.Generic; -using System.ComponentModel; -using System.Security.Cryptography.X509Certificates; -using System.Text.Json; -using System.Text.Json.Serialization; -using TibzGame.Core.ScreenManager; -using static Johnmagotchi.GameContent.Objects.Units.Loadouts.PlayerClasses.PlayerClass; - -namespace Johnmagotchi.GameContent.Units -{ - /// - /// TO DO -- THIS SHOULD BE DELETED AFTER REFACTOR TO *BASE UNIT* - /// - public class UnitObject{ - //defined stats - public int internalID; // used to reference this object internally - public int id { get; set; } // used to reference this unit as "Byleth" or "Marth" or whatever, you know? - public string name { get; set; } - - - // REMOVING TEMPORARILY - public UnitStatBlock stats { set; get; } - public UnitCurrentStatus currentStatus { get; set; } - public bool isUnique { set; get; } - public UnitTeam team { set; get; } - public PlayerClassType playerClassEnum { get; set; } - - // Stats for battle screens - - public bool isTurnOver { set; get; } - // public statusEnum status {get;set;} - public int xPos { set; get; } - public int yPos { set; get; } - - PlayerClass playerClassInstance; - public UnitLoadout UnitLoadout { get; set; } - - public string serializedUnitLoadout { get; set;} - -// ------------------------------------------------------------------------------------------------------------- - - - - //drawing and state management - public SpriteShaderSets shaderSet; - public Texture2D sprite; - private Effect TurnEndedEffect; - - private SpriteBatch spriteBatch; - private ScreenManager _screenManager; - private bool IsInit; - - // DEBUG VARS - // this needs to be expanded for attacks/ items eventually, does not need saved atm - public int DirectAttackRangeMin = 2; - public int DirectAttackRangeMax = 4; - public int IndirectAttackRangeMin; - public int IndirectAttackRangeMax; - - - public enum UnitTeam - { - PLAYER, - ENEMY, - NPC - } - public enum SpriteShaderSets { - PLAYER_NORMAL, - ENEMY_NORMAL, - NPC_NORMAL - } - - - public UnitObject(){ - IsInit = false; - xPos = 0; - yPos = 0; - stats = new UnitStatBlock(); - currentStatus = new UnitCurrentStatus(stats); - // playerClassInstance = new PlayerClass(playerClassEnum); - - } - - public UnitObject(UnitObject template) { - IsInit = false; - CopyFromTemplate(template); - isTurnOver = false; - playerClassInstance = new PlayerClass(playerClassEnum); - UnitLoadout = new UnitLoadout(playerClassEnum); - currentStatus = new UnitCurrentStatus(stats); - - } - - - public UnitObject(string serializedData) - { - IsInit = false; - SetFromSerialized(serializedData); - - //this.currentStatus = new UnitCurrentStatus(stats); - this.UnitLoadout = new UnitLoadout(playerClassEnum); - - } - - public string GetAsSerialized() - { - string json = JsonSerializer.Serialize(this); - return json; - } - - public void SetFromSerialized(string data) - { - UnitObject temp = JsonSerializer.Deserialize(data); - CopyFromTemplate(temp); // get base stats - isTurnOver = temp.isTurnOver; - return ; - } - - - public void setTeam(UnitTeam team) - { - this.team = team; - this.ReinitSprite(); - } - - public void SetShaderSet(SpriteShaderSets inSet) { - shaderSet = inSet; - } - - public void InitSprite(ScreenManager screenManager, UnitTeam team) { - _screenManager = screenManager; - spriteBatch = new SpriteBatch(screenManager.GraphicsDevice); - this.team = team; - string path = getSpriteTexturePath(); - sprite = screenManager.contentRef.Load(path); - this.internalID = screenManager.getUnitId(); - TurnEndedEffect = screenManager.contentRef.Load("Shaders/Units/UnitTurnEnded_S"); - IsInit = true; - - } - - public void ReinitSprite() - { - spriteBatch = new SpriteBatch(_screenManager.GraphicsDevice); - string path = getSpriteTexturePath(); - sprite = _screenManager.contentRef.Load(path); - IsInit = true; - } - - public void Update() { - - - } - - public void CopyFromTemplate(UnitObject template) - { - this.id = template.id; - this.name = template.name; - this.stats = template.stats; - this.xPos = template.xPos; - this.yPos = template.yPos; - this.isUnique = template.isUnique; - this.playerClassEnum = template.playerClassEnum; - this.currentStatus = template.currentStatus; - - //this.sprite = template.sprite; - } - - public void DrawAt( int x, int y) { - if (IsInit == false) return; - - SpriteEffects effects = getSpriteShaderEffects(shaderSet); - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp); - - // all rectangles should do the scaling from world coordinates to screen coordinates - Rectangle rect = _screenManager.GetScaledRectangle(x, y, MapTile.TILE_WIDTH_PX, MapTile.TILE_HEIGHT_PX); - - //TibzLog.Debug("Scaled xPos: {0}, yPos: {1}" , tileRect.X, tileRect.Y); - // Texture2D currentTexture; - - if (isTurnOver) { - //apply shader - TurnEndedEffect.CurrentTechnique.Passes[0].Apply(); - } - - spriteBatch.Draw( - sprite, rect, null, Color.White, 0, new Vector2(0, 0), - effects, 1); - - spriteBatch.End(); - } - - - private SpriteEffects getSpriteShaderEffects(SpriteShaderSets shaderEnum) { - - return SpriteEffects.None; - - } - public string getSpriteTexturePath() - { - if (team == UnitTeam.PLAYER) - { - return "Units/unit-test"; - } - if (team == UnitTeam.ENEMY) - { - return "Units/unit-test-enemy"; - } - if (team == UnitTeam.NPC) - { - return "Units/unit-test-npc"; - } - return "Units/unit-test"; - } - } -} \ No newline at end of file diff --git a/Johnmagotchi/GameContent/Objects/Units/GameLogic/BaseUnitGameObject.cs b/Johnmagotchi/GameContent/Objects/Units/GameLogic/BaseUnitGameObject.cs index 603f032..7928ccb 100644 --- a/Johnmagotchi/GameContent/Objects/Units/GameLogic/BaseUnitGameObject.cs +++ b/Johnmagotchi/GameContent/Objects/Units/GameLogic/BaseUnitGameObject.cs @@ -1,6 +1,4 @@ -using Johnmagotchi.GameContent.Objects.Units.BattleObjects; -using Johnmagotchi.GameContent.Objects.Units.Loadouts; -using Johnmagotchi.GameContent.Objects.Units.Loadouts.PlayerClasses; +using Johnmagotchi.GameContent.Objects.Units.Stats.Loadouts; using Johnmagotchi.GameContent.Objects.Units.Stats; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -11,8 +9,8 @@ using System.Text; using System.Text.Json; using System.Threading.Tasks; using TibzGame.Core.ScreenManager; -using static Johnmagotchi.GameContent.Objects.Units.BattleObjects.UnitCurrentStatus; -using static Johnmagotchi.GameContent.Objects.Units.Loadouts.PlayerClasses.PlayerClass; +using static Johnmagotchi.GameContent.Objects.Units.Stats.UnitCurrentStatus; +using static Johnmagotchi.GameContent.Objects.Units.Stats.Loadouts.PlayerClasses.PlayerClass; namespace Johnmagotchi.GameContent.Objects.Units.GameLogic { diff --git a/Johnmagotchi/GameContent/Objects/UglyUnits/Loadouts/LoadoutModule.cs b/Johnmagotchi/GameContent/Objects/Units/Stats/Loadouts/LoadoutModule.cs similarity index 95% rename from Johnmagotchi/GameContent/Objects/UglyUnits/Loadouts/LoadoutModule.cs rename to Johnmagotchi/GameContent/Objects/Units/Stats/Loadouts/LoadoutModule.cs index 74e0718..4eb2645 100644 --- a/Johnmagotchi/GameContent/Objects/UglyUnits/Loadouts/LoadoutModule.cs +++ b/Johnmagotchi/GameContent/Objects/Units/Stats/Loadouts/LoadoutModule.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Johnmagotchi.GameContent.Objects.Units.Loadouts +namespace Johnmagotchi.GameContent.Objects.Units.Stats.Loadouts { public class LoadoutModule { diff --git a/Johnmagotchi/GameContent/Objects/UglyUnits/Loadouts/PlayerClasses/PlayerClass.cs b/Johnmagotchi/GameContent/Objects/Units/Stats/Loadouts/PlayerClasses/PlayerClass.cs similarity index 97% rename from Johnmagotchi/GameContent/Objects/UglyUnits/Loadouts/PlayerClasses/PlayerClass.cs rename to Johnmagotchi/GameContent/Objects/Units/Stats/Loadouts/PlayerClasses/PlayerClass.cs index 115f994..f2fab38 100644 --- a/Johnmagotchi/GameContent/Objects/UglyUnits/Loadouts/PlayerClasses/PlayerClass.cs +++ b/Johnmagotchi/GameContent/Objects/Units/Stats/Loadouts/PlayerClasses/PlayerClass.cs @@ -1,10 +1,10 @@ using Johnmagotchi.Core.tools; -using Johnmagotchi.GameContent.Objects.Units.BattleObjects; -using Johnmagotchi.GameContent.Objects.Units.Loadouts; +using Johnmagotchi.GameContent.Objects.BattleObjects; +using Johnmagotchi.GameContent.Objects.Units.Stats.Loadouts; using System.Collections.Generic; using System.Linq; -namespace Johnmagotchi.GameContent.Objects.Units.Loadouts.PlayerClasses +namespace Johnmagotchi.GameContent.Objects.Units.Stats.Loadouts.PlayerClasses { public class PlayerClass { @@ -245,7 +245,7 @@ namespace Johnmagotchi.GameContent.Objects.Units.Loadouts.PlayerClasses } if (attack != null) - this.ClassAttacks.Add(attack); + ClassAttacks.Add(attack); } } diff --git a/Johnmagotchi/GameContent/Objects/UglyUnits/Loadouts/UnitLoadout.cs b/Johnmagotchi/GameContent/Objects/Units/Stats/Loadouts/UnitLoadout.cs similarity index 88% rename from Johnmagotchi/GameContent/Objects/UglyUnits/Loadouts/UnitLoadout.cs rename to Johnmagotchi/GameContent/Objects/Units/Stats/Loadouts/UnitLoadout.cs index 14d5937..9480fd3 100644 --- a/Johnmagotchi/GameContent/Objects/UglyUnits/Loadouts/UnitLoadout.cs +++ b/Johnmagotchi/GameContent/Objects/Units/Stats/Loadouts/UnitLoadout.cs @@ -1,15 +1,15 @@ using Johnmagotchi.Core.tools; -using Johnmagotchi.GameContent.Objects.Units.BattleObjects; -using Johnmagotchi.GameContent.Objects.Units.Loadouts.PlayerClasses; +using Johnmagotchi.GameContent.Objects.BattleObjects; +using Johnmagotchi.GameContent.Objects.Units.Stats.Loadouts.PlayerClasses; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.Json.Serialization; using System.Threading.Tasks; -using static Johnmagotchi.GameContent.Objects.Units.Loadouts.PlayerClasses.PlayerClass; +using static Johnmagotchi.GameContent.Objects.Units.Stats.Loadouts.PlayerClasses.PlayerClass; -namespace Johnmagotchi.GameContent.Objects.Units.Loadouts +namespace Johnmagotchi.GameContent.Objects.Units.Stats.Loadouts { public class UnitLoadout { @@ -95,9 +95,9 @@ namespace Johnmagotchi.GameContent.Objects.Units.Loadouts } public void saveAllToCSV() { - AvailibleAttackIDsCSV = String.Join(",", AvailableAttacks.Select(atk => atk.ID).ToArray()); - AvailaibeSupportIDsCSV = String.Join(",", AvailableSupports.Select(spt => spt.ID).ToArray()); - ActiveSkillsIDsCSV = String.Join(",", ActiveSkills.Select(skill => skill.ID).ToArray()); + AvailibleAttackIDsCSV = string.Join(",", AvailableAttacks.Select(atk => atk.ID).ToArray()); + AvailaibeSupportIDsCSV = string.Join(",", AvailableSupports.Select(spt => spt.ID).ToArray()); + ActiveSkillsIDsCSV = string.Join(",", ActiveSkills.Select(skill => skill.ID).ToArray()); } } } diff --git a/Johnmagotchi/GameContent/Objects/UglyUnits/Loadouts/UnitLoadoutManager.cs b/Johnmagotchi/GameContent/Objects/Units/Stats/Loadouts/UnitLoadoutManager.cs similarity index 73% rename from Johnmagotchi/GameContent/Objects/UglyUnits/Loadouts/UnitLoadoutManager.cs rename to Johnmagotchi/GameContent/Objects/Units/Stats/Loadouts/UnitLoadoutManager.cs index 626c268..e7658d0 100644 --- a/Johnmagotchi/GameContent/Objects/UglyUnits/Loadouts/UnitLoadoutManager.cs +++ b/Johnmagotchi/GameContent/Objects/Units/Stats/Loadouts/UnitLoadoutManager.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Johnmagotchi.GameContent.Objects.Units.Loadouts +namespace Johnmagotchi.GameContent.Objects.Units.Stats.Loadouts { internal class UnitLoadoutManager { diff --git a/Johnmagotchi/GameContent/Objects/UglyUnits/BattleObjects/UnitCurrentStatus.cs b/Johnmagotchi/GameContent/Objects/Units/Stats/UnitCurrentStatus.cs similarity index 83% rename from Johnmagotchi/GameContent/Objects/UglyUnits/BattleObjects/UnitCurrentStatus.cs rename to Johnmagotchi/GameContent/Objects/Units/Stats/UnitCurrentStatus.cs index 4b95463..84ba76d 100644 --- a/Johnmagotchi/GameContent/Objects/UglyUnits/BattleObjects/UnitCurrentStatus.cs +++ b/Johnmagotchi/GameContent/Objects/Units/Stats/UnitCurrentStatus.cs @@ -1,5 +1,4 @@ using Johnmagotchi.Core.tools; -using Johnmagotchi.GameContent.Units; using System; using System.Collections.Generic; using System.Linq; @@ -8,7 +7,7 @@ using System.Text.Json; using System.Text.Json.Serialization; using System.Threading.Tasks; -namespace Johnmagotchi.GameContent.Objects.Units.BattleObjects +namespace Johnmagotchi.GameContent.Objects.Units.Stats { public class UnitCurrentStatus { @@ -35,10 +34,10 @@ namespace Johnmagotchi.GameContent.Objects.Units.BattleObjects this.CurrentShieldCount = CurrentShieldCount; } - public void setFromSerialized(UnitObject temp, string data) { + public void setFromSerialized(Unit temp, string data) { UnitCurrentStatus parsedData = JsonSerializer.Deserialize(data); - temp.currentStatus.CurrentHealth = parsedData.CurrentHealth;// Update current stats + // temp.currentStatus.CurrentHealth = parsedData.CurrentHealth;// Update current stats CurrentShieldCount = 0; TibzLog.Debug("HP on deserialized: " + parsedData.CurrentHealth); } diff --git a/Johnmagotchi/GameContent/Objects/UglyUnits/BattleObjects/UnitStatBlock.cs b/Johnmagotchi/GameContent/Objects/Units/Stats/UnitStatBlock.cs similarity index 94% rename from Johnmagotchi/GameContent/Objects/UglyUnits/BattleObjects/UnitStatBlock.cs rename to Johnmagotchi/GameContent/Objects/Units/Stats/UnitStatBlock.cs index afdeaf5..eb6122c 100644 --- a/Johnmagotchi/GameContent/Objects/UglyUnits/BattleObjects/UnitStatBlock.cs +++ b/Johnmagotchi/GameContent/Objects/Units/Stats/UnitStatBlock.cs @@ -1,4 +1,4 @@ -namespace Johnmagotchi.GameContent.Objects.Units.BattleObjects +namespace Johnmagotchi.GameContent.Objects.Units.Stats { public class UnitStatBlock{ diff --git a/Johnmagotchi/GameContent/Objects/Units/Stats/UnitStats.cs b/Johnmagotchi/GameContent/Objects/Units/Stats/UnitStats.cs index 46e1c2a..3189847 100644 --- a/Johnmagotchi/GameContent/Objects/Units/Stats/UnitStats.cs +++ b/Johnmagotchi/GameContent/Objects/Units/Stats/UnitStats.cs @@ -1,11 +1,10 @@ -using Johnmagotchi.GameContent.Objects.Units.BattleObjects; -using Johnmagotchi.GameContent.Objects.Units.Loadouts; +using Johnmagotchi.GameContent.Objects.Units.Stats.Loadouts; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using static Johnmagotchi.GameContent.Objects.Units.Loadouts.PlayerClasses.PlayerClass; +using static Johnmagotchi.GameContent.Objects.Units.Stats.Loadouts.PlayerClasses.PlayerClass; namespace Johnmagotchi.GameContent.Objects.Units.Stats { diff --git a/Johnmagotchi/GameContent/Objects/Units/Unit.cs b/Johnmagotchi/GameContent/Objects/Units/Unit.cs index ab09df1..93032dd 100644 --- a/Johnmagotchi/GameContent/Objects/Units/Unit.cs +++ b/Johnmagotchi/GameContent/Objects/Units/Unit.cs @@ -1,7 +1,6 @@ using Johnmagotchi.GameContent.Objects.Units.GameLogic; -using Johnmagotchi.GameContent.Objects.Units.Loadouts; +using Johnmagotchi.GameContent.Objects.Units.Stats.Loadouts; using Johnmagotchi.GameContent.Objects.Units.Stats; -using Johnmagotchi.GameContent.Units; using System; using System.Collections.Generic; using System.Linq; diff --git a/Johnmagotchi/GameContent/Objects/UglyUnits/UnitLoader.cs b/Johnmagotchi/GameContent/Objects/Units/UnitLoader.cs similarity index 88% rename from Johnmagotchi/GameContent/Objects/UglyUnits/UnitLoader.cs rename to Johnmagotchi/GameContent/Objects/Units/UnitLoader.cs index e4a9adc..8c8c83f 100644 --- a/Johnmagotchi/GameContent/Objects/UglyUnits/UnitLoader.cs +++ b/Johnmagotchi/GameContent/Objects/Units/UnitLoader.cs @@ -5,11 +5,10 @@ using System.Diagnostics; using Johnmagotchi.Core.tools; using System.Collections; using System.Net.Http.Headers; -using static Johnmagotchi.GameContent.Objects.Units.BattleObjects.UnitStatBlock; -using Johnmagotchi.GameContent.Objects.Units.Loadouts.PlayerClasses; -using Johnmagotchi.GameContent.Objects.Units; +using static Johnmagotchi.GameContent.Objects.Units.Stats.UnitStatBlock; +using Johnmagotchi.GameContent.Objects.Units.Stats.Loadouts.PlayerClasses; -namespace Johnmagotchi.GameContent.Units +namespace Johnmagotchi.GameContent.Objects.Units { public class UnitLoader { @@ -98,9 +97,9 @@ namespace Johnmagotchi.GameContent.Units List unitList = new List(); - System.Console.WriteLine("PATH: {0}", Directory.GetCurrentDirectory()); + Console.WriteLine("PATH: {0}", Directory.GetCurrentDirectory()); var path = "..\\..\\..\\Data\\BattleObjects\\UnitDefinitions.csv"; - System.Console.WriteLine("path: {0} ", path); + Console.WriteLine("path: {0} ", path); // these let us resolve which column is which int IdIndex = -1; @@ -148,15 +147,15 @@ namespace Johnmagotchi.GameContent.Units else { Unit unit = new Unit(); - unit.UnitID = Int32.Parse(values[IdIndex]); + unit.UnitID = int.Parse(values[IdIndex]); unit.stats.classId = PlayerClass.GetClassFromShortHand(values[ClassIndex]); // unit.isUnique = (values[isUniqueIndex].ToLower() == "true"); unit.name = unit.stats.Name = values[NameIndex]; - unit.stats.baseStats.MaxHealth = Int32.Parse(values[HealthIndex]); - unit.stats.baseStats.Attack = Int32.Parse(values[AttackIndex]); - unit.stats.baseStats.Defense = Int32.Parse(values[DefenseIndex]); - unit.stats.baseStats.Speed = Int32.Parse(values[SpeedIndex]); - unit.stats.baseStats.Movement = Int32.Parse(values[MovementIndex]); + unit.stats.baseStats.MaxHealth = int.Parse(values[HealthIndex]); + unit.stats.baseStats.Attack = int.Parse(values[AttackIndex]); + unit.stats.baseStats.Defense = int.Parse(values[DefenseIndex]); + unit.stats.baseStats.Speed = int.Parse(values[SpeedIndex]); + unit.stats.baseStats.Movement = int.Parse(values[MovementIndex]); unit.stats.baseStats.setMovementTypeFromFile(values[MovementTypeIndex]); unitList.Add(unit); diff --git a/Johnmagotchi/GameContent/Screens/MapScreens/BaseMapScreen.cs b/Johnmagotchi/GameContent/Screens/MapScreens/BaseMapScreen.cs index 7e62815..9c19171 100644 --- a/Johnmagotchi/GameContent/Screens/MapScreens/BaseMapScreen.cs +++ b/Johnmagotchi/GameContent/Screens/MapScreens/BaseMapScreen.cs @@ -11,7 +11,6 @@ using TibzGame.Core.Inputs; using TibzGame.Core.ScreenManager; using Johnmagotchi.GameContent.Objects; using System.Text.Json; -using Johnmagotchi.GameContent.Units; using Johnmagotchi.GameContent.Objects.UI; using Johnmagotchi.Core.tools; diff --git a/Johnmagotchi/GameContent/Screens/MapScreens/BattleMapScreen/BattleMapScreen.cs b/Johnmagotchi/GameContent/Screens/MapScreens/BattleMapScreen/BattleMapScreen.cs index 44bdda7..6145d47 100644 --- a/Johnmagotchi/GameContent/Screens/MapScreens/BattleMapScreen/BattleMapScreen.cs +++ b/Johnmagotchi/GameContent/Screens/MapScreens/BattleMapScreen/BattleMapScreen.cs @@ -4,7 +4,6 @@ using Johnmagotchi.GameContent.Objects; using Johnmagotchi.GameContent.Objects.Maps; using Johnmagotchi.GameContent.Objects.Units; using Johnmagotchi.GameContent.Screens.Menu.BattleMap; -using Johnmagotchi.GameContent.Units; using Johnmagotchi.Screen.BattleMapScreens; using System; using System.Collections.Generic; @@ -252,7 +251,7 @@ namespace Johnmagotchi.GameContent.Screens.BattleMapScreens.BattleMapScreen if (isConfirmed) { // BattleLogic.RunBattle(selectedToMoveUnit,attackedUnit, selectedAttack, defenderAttack); - BattleLogic.RunBattle(ref selectedToMoveUnit, ref attackedUnit, null, null); + BattleLogic.RunBattle(ref selectedToMoveUnit, ref attackedUnit); screenManager.addScreen(new MapScreens.BattleMapScreen.BattleAnimationScreen()); } diff --git a/Johnmagotchi/GameContent/Screens/MapScreens/MapEditor/MapEditorScreen.cs b/Johnmagotchi/GameContent/Screens/MapScreens/MapEditor/MapEditorScreen.cs index a4b5fb2..18d9a94 100644 --- a/Johnmagotchi/GameContent/Screens/MapScreens/MapEditor/MapEditorScreen.cs +++ b/Johnmagotchi/GameContent/Screens/MapScreens/MapEditor/MapEditorScreen.cs @@ -1,6 +1,5 @@ using Johnmagotchi.GameContent.Objects; using System.Collections.Generic; -using Johnmagotchi.GameContent.Units; using Johnmagotchi.Core.tools; using Johnmagotchi.GameContent.Screens.Menu; using Johnmagotchi.GameContent.Screens.BattleMapScreens.MapEditor; @@ -8,8 +7,6 @@ using Microsoft.VisualBasic; using static System.Net.Mime.MediaTypeNames; using System.IO; using System; -using Johnmagotchi.GameContent.Objects.Units.Loadouts; -using Johnmagotchi.GameContent.Objects.Units.BattleObjects; using Johnmagotchi.GameContent.Objects.Units; namespace Johnmagotchi.Screen.BattleMapScreens @@ -34,7 +31,6 @@ namespace Johnmagotchi.Screen.BattleMapScreens private EditorToolType CurrentTool; private MapEditorInfoText InfoText; public List AvailableNewUnits; - public List AvailableLoadouts; private UnitFactionType UnitFaction;