fixed issue with display / initializing unit with base class
This commit is contained in:
parent
cfd615bf07
commit
e54ba4652f
|
|
@ -334,6 +334,7 @@ namespace Johnmagotchi.GameContent.Objects
|
|||
Unit.yPos = y;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public MapTile getTile(int x, int y) {
|
||||
|
|
@ -355,9 +356,7 @@ namespace Johnmagotchi.GameContent.Objects
|
|||
clone.serializedMapTiles = this.serializedMapTiles;
|
||||
clone.deserializeMapTiles();
|
||||
|
||||
clone.serializedPlayerUnits = this.serializedPlayerUnits;
|
||||
clone.serializedNpcUnits = this.serializedNpcUnits;
|
||||
clone.serializedEnemyUnits = this.serializedEnemyUnits;
|
||||
clone.serializedUnits = this.serializedUnits;
|
||||
clone.DeserializeUnitData();
|
||||
|
||||
return clone;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ using System.Threading.Tasks;
|
|||
using TibzGame.Core.ScreenManager;
|
||||
using static Johnmagotchi.GameContent.Objects.Units.Stats.UnitCurrentStatus;
|
||||
using static Johnmagotchi.GameContent.Objects.Units.Stats.Loadouts.PlayerClasses.PlayerClass;
|
||||
using Johnmagotchi.Core.tools;
|
||||
|
||||
namespace Johnmagotchi.GameContent.Objects.Units.GameLogic
|
||||
{
|
||||
|
|
@ -29,11 +30,8 @@ namespace Johnmagotchi.GameContent.Objects.Units.GameLogic
|
|||
public int xPos { set; get; }
|
||||
public int yPos { set; get; }
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
//drawing and state management
|
||||
public SpriteShaderSets shaderSet;
|
||||
public Texture2D sprite;
|
||||
|
|
@ -62,8 +60,20 @@ namespace Johnmagotchi.GameContent.Objects.Units.GameLogic
|
|||
xPos = 0;
|
||||
yPos = 0;
|
||||
}
|
||||
public BaseUnitGameObject(Unit template)
|
||||
{
|
||||
IsInit = false;
|
||||
hasStats = false;
|
||||
xPos = 0;
|
||||
yPos = 0;
|
||||
name = template.name;
|
||||
playerClassEnum = template.playerClassEnum;
|
||||
|
||||
public void SetStats(UnitStats newStats)
|
||||
TibzLog.Debug("set from template- " + playerClassEnum );
|
||||
}
|
||||
|
||||
|
||||
public void SetStats(UnitStats newStats)
|
||||
{
|
||||
stats = newStats;
|
||||
hasStats = true;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace Johnmagotchi.GameContent.Objects.Units
|
|||
this.SetStats(new UnitStats());
|
||||
|
||||
}
|
||||
public Unit(Unit template) : base()
|
||||
public Unit(Unit template) : base(template)
|
||||
{
|
||||
SetStats(template.GetStats());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,82 +21,10 @@ namespace Johnmagotchi.GameContent.Objects.Units
|
|||
|
||||
return listA;
|
||||
}
|
||||
//public static List<UnitObject> LoadBaseUnits() {
|
||||
// List<UnitObject> unitList = new List<UnitObject>();
|
||||
// System.Console.WriteLine("PATH: {0}", Directory.GetCurrentDirectory());
|
||||
// var path = "..\\..\\..\\Data\\BattleObjects\\UnitDefinitions.csv";
|
||||
// List<string> listA = new List<string>();
|
||||
// List<string> listB = new List<string>();
|
||||
// System.Console.WriteLine("path: {0} ", path);
|
||||
|
||||
// // these let us resolve which column is which
|
||||
// int IdIndex = -1;
|
||||
// int NameIndex = -1;
|
||||
// int ClassIndex = -1;
|
||||
// int isUniqueIndex = -1;
|
||||
// int HealthIndex = -1;
|
||||
// int AttackIndex = -1;
|
||||
// int DefenseIndex = -1;
|
||||
// int SpeedIndex = -1;
|
||||
// int MovementIndex = -1;
|
||||
// int MovementTypeIndex = -1;
|
||||
|
||||
// bool AreColumnIndexesSet = false;
|
||||
|
||||
// using (var reader = new StreamReader(path))
|
||||
// {
|
||||
|
||||
// while (!reader.EndOfStream)
|
||||
// {
|
||||
// var line = reader.ReadLine();
|
||||
// var values = line.Split(',');
|
||||
|
||||
// if (AreColumnIndexesSet == false)
|
||||
// {
|
||||
// //These strings MUST match /GameContent/Data/UnitDefines.CSV
|
||||
// // That file MUST have these in the first row.
|
||||
// for (int i = 0; i < values.Length; i++) {
|
||||
|
||||
// if (values[i].Trim() == "ID") { IdIndex = i; }
|
||||
// if (values[i].Trim() == "NAME") { NameIndex = i; }
|
||||
// if (values[i].Trim() == "CLASS") { ClassIndex = i; }
|
||||
// if (values[i].Trim() == "IS_UNIQUE") { isUniqueIndex = i; }
|
||||
// if (values[i].Trim() == "HEALTH") { HealthIndex = i; }
|
||||
// if (values[i].Trim() == "ATTACK") { AttackIndex = i; }
|
||||
// if (values[i].Trim() == "DEFENSE") { DefenseIndex = i; }
|
||||
// if (values[i].Trim() == "SPEED") { SpeedIndex = i; }
|
||||
// if (values[i].Trim() == "MOVEMENT") { MovementIndex = i; }
|
||||
// if (values[i].Trim() == "MOVEMENT_TYPE") { MovementTypeIndex = i; }
|
||||
|
||||
|
||||
// }
|
||||
// AreColumnIndexesSet = true;
|
||||
// }
|
||||
// else {
|
||||
// UnitObject unit = new UnitObject();
|
||||
// unit.id = Int32.Parse(values[IdIndex]);
|
||||
// unit.name = unit.stats = values[NameIndex];
|
||||
// unit.playerClassEnum = PlayerClass.GetClassFromShortHand(values[ClassIndex]);
|
||||
// unit.isUnique = (values[isUniqueIndex].ToLower() == "true");
|
||||
// unit.stats.MaxHealth = Int32.Parse(values[HealthIndex]);
|
||||
// unit.stats.Attack = Int32.Parse(values[AttackIndex]);
|
||||
// unit.stats.Defense = Int32.Parse(values[DefenseIndex]);
|
||||
// unit.stats.Speed = Int32.Parse(values[SpeedIndex]);
|
||||
// unit.stats.Movement = Int32.Parse(values[MovementIndex]);
|
||||
// unit.stats.setMovementTypeFromFile(values[MovementTypeIndex]);
|
||||
|
||||
// unitList.Add(unit);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return unitList;
|
||||
//}
|
||||
|
||||
public static List <Unit> LoadUnitList ()
|
||||
{
|
||||
List<Unit> unitList = new List<Unit>();
|
||||
|
||||
|
||||
Console.WriteLine("PATH: {0}", Directory.GetCurrentDirectory());
|
||||
var path = "..\\..\\..\\Data\\BattleObjects\\UnitDefinitions.csv";
|
||||
Console.WriteLine("path: {0} ", path);
|
||||
|
|
@ -117,7 +45,6 @@ namespace Johnmagotchi.GameContent.Objects.Units
|
|||
|
||||
using (var reader = new StreamReader(path))
|
||||
{
|
||||
|
||||
while (!reader.EndOfStream)
|
||||
{
|
||||
var line = reader.ReadLine();
|
||||
|
|
@ -151,6 +78,8 @@ namespace Johnmagotchi.GameContent.Objects.Units
|
|||
unit.stats.classId = PlayerClass.GetClassFromShortHand(values[ClassIndex]);
|
||||
// unit.isUnique = (values[isUniqueIndex].ToLower() == "true");
|
||||
unit.name = unit.stats.Name = values[NameIndex];
|
||||
unit.playerClassEnum = PlayerClass.GetClassFromShortHand(values[ClassIndex]);
|
||||
TibzLog.Debug("loaded class - " + unit.playerClassEnum);
|
||||
unit.stats.baseStats.MaxHealth = int.Parse(values[HealthIndex]);
|
||||
unit.stats.baseStats.Attack = int.Parse(values[AttackIndex]);
|
||||
unit.stats.baseStats.Defense = int.Parse(values[DefenseIndex]);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user