more cleanup and refactoring
This commit is contained in:
parent
6b7595ab77
commit
cfd615bf07
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using Johnmagotchi.GameContent.Objects.Units.BattleObjects;
|
||||
using Johnmagotchi.GameContent.Objects.BattleObjects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
|
|
|||
|
|
@ -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++) {
|
||||
// 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;
|
||||
// int hitRoll = BattleLogic.Random.Next(100) + 1; // random int 1 - 100
|
||||
// int hitThreshold = attack.BaseAccuracy + Attacker.stats.baseStats.Speed - Defender.stats.baseStats.Speed;
|
||||
|
||||
// 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
|
||||
// // 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;
|
||||
// int critThreshold = 95;
|
||||
|
||||
|
||||
if (hitRoll < hitThreshold) //handle misses
|
||||
{
|
||||
// if (hitRoll < hitThreshold) //handle misses
|
||||
// {
|
||||
|
||||
results.addResult(BattleResults.resultType.MISS, 0, isCounter);
|
||||
}
|
||||
else if (hitRoll >= critThreshold) //Handle Crits
|
||||
{
|
||||
// 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 (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 to defending unit, then add to result report
|
||||
Defender.stats.status.CurrentHealth -= TotalCritDamage;
|
||||
results.addResult(BattleResults.resultType.CRITICAL, TotalCritDamage, isCounter);
|
||||
// //apply Damage to defending unit, then add to result report
|
||||
// Defender.stats.status.CurrentHealth -= TotalCritDamage;
|
||||
// results.addResult(BattleResults.resultType.CRITICAL, TotalCritDamage, isCounter);
|
||||
|
||||
}
|
||||
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);
|
||||
// }
|
||||
// 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);
|
||||
|
||||
//Apply damage + report to animation handler
|
||||
Defender.stats.status.CurrentHealth -= BaseDamage;
|
||||
results.addResult(BattleResults.resultType.ATTACK, BaseDamage, isCounter);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
// //Apply damage + report to animation handler
|
||||
// Defender.stats.status.CurrentHealth -= BaseDamage;
|
||||
// results.addResult(BattleResults.resultType.ATTACK, BaseDamage, isCounter);
|
||||
// }
|
||||
// }
|
||||
// return;
|
||||
//}
|
||||
|
||||
private static int CalculateDamage( Unit Attacker, Unit Defender, AttackObj attack)
|
||||
{
|
||||
int damage = 0;
|
||||
// private static int CalculateDamage( Unit Attacker, Unit Defender, AttackObj attack)
|
||||
// {
|
||||
// int damage = 0;
|
||||
|
||||
damage += attack.BaseDamage;
|
||||
damage += Attacker.stats.baseStats.Attack;
|
||||
// damage += attack.BaseDamage;
|
||||
// damage += Attacker.stats.baseStats.Attack;
|
||||
|
||||
damage -= Defender.stats.baseStats.Defense;
|
||||
// damage -= Defender.stats.baseStats.Defense;
|
||||
|
||||
|
||||
if (damage < 0) damage = 0;
|
||||
return damage ;
|
||||
}
|
||||
// if (damage < 0) damage = 0;
|
||||
// return damage ;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
@ -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<AttackObj> LoadAttacks()
|
||||
{
|
||||
List<AttackObj> AttackList = new List<AttackObj>();
|
||||
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<SkillObj> SkillList = new List<SkillObj>();
|
||||
|
||||
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<SupportObj> SupportList = new List<SupportObj>();
|
||||
|
||||
|
||||
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);
|
||||
|
|
@ -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
|
||||
{
|
||||
|
|
@ -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
|
||||
{
|
||||
|
|
@ -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<Unit> playerUnits;
|
||||
private List<Unit> enemyUnits;
|
||||
private List<Unit> npcUnits;
|
||||
private List<Unit> Units;
|
||||
//private List<Unit> playerUnits;
|
||||
//private List<Unit> enemyUnits;
|
||||
//private List<Unit> 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<Unit>();
|
||||
this.npcUnits = new List<Unit>();
|
||||
this.enemyUnits = new List<Unit>();
|
||||
this.Units = new List<Unit>();
|
||||
//this.playerUnits = new List<Unit>();
|
||||
//this.npcUnits = new List<Unit>();
|
||||
//this.enemyUnits = new List<Unit>();
|
||||
}
|
||||
|
||||
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<string> player = new List<string>();
|
||||
List<string> enemy = new List<string>();
|
||||
List<string> npc = new List<string>();
|
||||
List<string> units_str = new List<string>();
|
||||
|
||||
foreach (Unit unit in playerUnits) {
|
||||
player.Add(unit.GetAsSerialized());
|
||||
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<Unit> OutPlayerUnits = new List<Unit>();
|
||||
List<Unit> OutEnemyUnits = new List<Unit>();
|
||||
List<Unit> OutNpcUnits = new List<Unit>();
|
||||
List<Unit> outUnits = new List<Unit>();
|
||||
|
||||
List<string> players = JsonSerializer.Deserialize<List<string>>(serializedPlayerUnits);
|
||||
List<string> enemies = JsonSerializer.Deserialize<List<string>>(serializedEnemyUnits);
|
||||
List<string> npcs = JsonSerializer.Deserialize<List<string>>(serializedNpcUnits);
|
||||
List<string> unitsString = JsonSerializer.Deserialize<List<string>>(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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// TO DO -- THIS SHOULD BE DELETED AFTER REFACTOR TO *BASE UNIT*
|
||||
/// </summary>
|
||||
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<UnitObject>(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<Texture2D>(path);
|
||||
this.internalID = screenManager.getUnitId();
|
||||
TurnEndedEffect = screenManager.contentRef.Load<Effect>("Shaders/Units/UnitTurnEnded_S");
|
||||
IsInit = true;
|
||||
|
||||
}
|
||||
|
||||
public void ReinitSprite()
|
||||
{
|
||||
spriteBatch = new SpriteBatch(_screenManager.GraphicsDevice);
|
||||
string path = getSpriteTexturePath();
|
||||
sprite = _screenManager.contentRef.Load<Texture2D>(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";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
{
|
||||
|
|
@ -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<UnitCurrentStatus>(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);
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
namespace Johnmagotchi.GameContent.Objects.Units.BattleObjects
|
||||
namespace Johnmagotchi.GameContent.Objects.Units.Stats
|
||||
{
|
||||
public class UnitStatBlock{
|
||||
|
||||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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<Unit> unitList = new List<Unit>();
|
||||
|
||||
|
||||
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);
|
||||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<Unit> AvailableNewUnits;
|
||||
public List<UnitLoadout> AvailableLoadouts;
|
||||
private UnitFactionType UnitFaction;
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user