This commit is contained in:
tibz 2026-09-25 02:33:04 -05:00
parent 55bc9c11bf
commit b745fb9443
15 changed files with 359 additions and 205 deletions

View File

@ -11,8 +11,8 @@ namespace Johnmagotchi.Data.BattleObjects
{ {
public enum AttackTypeEnum public enum AttackTypeEnum
{ {
DIRECT = 0, DIRECT = 0, // can move and fire on same turn
INDIRECT = 1 INDIRECT = 1 // must be stationary to attack
} }
public enum SpecialAttackPropertiesEnum public enum SpecialAttackPropertiesEnum
@ -23,6 +23,12 @@ namespace Johnmagotchi.Data.BattleObjects
KILLER = 3, KILLER = 3,
ARMOR_BANE = 4 ARMOR_BANE = 4
} }
public enum DamageType
{
SLASH = 0,
PIERCE = 1,
ENERGY = 2,
}
public static AttackTypeEnum ParseAttackTypes(string enumString) public static AttackTypeEnum ParseAttackTypes(string enumString)
{ {
@ -34,5 +40,14 @@ namespace Johnmagotchi.Data.BattleObjects
Enum.TryParse(enumString, out SpecialAttackPropertiesEnum props); Enum.TryParse(enumString, out SpecialAttackPropertiesEnum props);
return props; return props;
} }
public static DamageType ParseDamageTypes(string enumString)
{
{
Enum.TryParse(enumString, out DamageType props);
return props;
}
}
} }
} }

View File

@ -1,2 +1,3 @@
ID,AttackName,BaseDamage,BaseHitCount,BaseSpeed,BaseAccuracy,AttackRangeMin,AttackRangeMax,AttackType,SpecialProperties ID,AttackName,BaseDamage,BaseHitCount,BaseSpeed,BaseAccuracy,AttackRangeMin,AttackRangeMax,AttackType,SpecialProperties,DamageType
1,Sword,1,1,1,100,1,1,DIRECT,NONE 1,Sword,1,1,1,100,1,1,DIRECT,NONE,SLASH
2,Gun,1,1,1,100,2,3,INDIRECT,NONE,PIERCE
1 ID AttackName BaseDamage BaseHitCount BaseSpeed BaseAccuracy AttackRangeMin AttackRangeMax AttackType SpecialProperties DamageType
2 1 Sword 1 1 1 100 1 1 DIRECT NONE SLASH
3 2 Gun 1 1 1 100 2 3 INDIRECT NONE PIERCE

View File

@ -11,6 +11,7 @@ using TibzGame.Core.ScreenManager;
using Johnmagotchi.GameContent.Units; using Johnmagotchi.GameContent.Units;
using Johnmagotchi.Core.tools; using Johnmagotchi.Core.tools;
using System.Runtime.ExceptionServices; using System.Runtime.ExceptionServices;
using Johnmagotchi.GameContent.Objects.Units;
namespace Johnmagotchi.GameContent.Objects namespace Johnmagotchi.GameContent.Objects
@ -28,9 +29,9 @@ namespace Johnmagotchi.GameContent.Objects
private MapTile [,] MapTileGrid; private MapTile [,] MapTileGrid;
private List<UnitObject> playerUnits; private List<Unit> playerUnits;
private List<UnitObject> enemyUnits; private List<Unit> enemyUnits;
private List<UnitObject> npcUnits; private List<Unit> npcUnits;
private SpriteBatch _spriteBatch; private SpriteBatch _spriteBatch;
private ScreenManager _screenManager; private ScreenManager _screenManager;
@ -51,9 +52,9 @@ namespace Johnmagotchi.GameContent.Objects
this.height = h; // default min height (shooting for 360 x 640 res, 40x40 pixel grid) this.height = h; // default min height (shooting for 360 x 640 res, 40x40 pixel grid)
this.width = w; this.width = w;
MapTileGrid = new MapTile[width,height]; MapTileGrid = new MapTile[width,height];
this.playerUnits = new List<UnitObject>(); this.playerUnits = new List<Unit>();
this.npcUnits = new List<UnitObject>(); this.npcUnits = new List<Unit>();
this.enemyUnits = new List<UnitObject>(); this.enemyUnits = new List<Unit>();
} }
public void Init(ScreenManager ScreenManager){ public void Init(ScreenManager ScreenManager){
@ -74,15 +75,15 @@ namespace Johnmagotchi.GameContent.Objects
public void Update() public void Update()
{ {
foreach (UnitObject unit in playerUnits) foreach (Unit unit in playerUnits)
{ {
unit.Update(); unit.Update();
} }
foreach (UnitObject unit in enemyUnits) foreach (Unit unit in enemyUnits)
{ {
unit.Update(); unit.Update();
} }
foreach (UnitObject unit in npcUnits) foreach (Unit unit in npcUnits)
{ {
unit.Update(); unit.Update();
} }
@ -161,18 +162,18 @@ namespace Johnmagotchi.GameContent.Objects
public void DrawUnits(int xOffset, int yOffset) { public void DrawUnits(int xOffset, int yOffset) {
foreach(UnitObject unit in playerUnits) { foreach(Unit unit in playerUnits) {
int xLocation = (unit.xPos * MapTile.TILE_WIDTH_PX) + xOffset; int xLocation = (unit.xPos * MapTile.TILE_WIDTH_PX) + xOffset;
int yLocation = (unit.yPos * MapTile.TILE_HEIGHT_PX) + yOffset; int yLocation = (unit.yPos * MapTile.TILE_HEIGHT_PX) + yOffset;
unit.DrawAt( xLocation, yLocation); unit.DrawAt( xLocation, yLocation);
} }
foreach (UnitObject unit in enemyUnits) foreach (Unit unit in enemyUnits)
{ {
int xLocation = (unit.xPos * MapTile.TILE_WIDTH_PX) + xOffset; int xLocation = (unit.xPos * MapTile.TILE_WIDTH_PX) + xOffset;
int yLocation = (unit.yPos * MapTile.TILE_HEIGHT_PX) + yOffset; int yLocation = (unit.yPos * MapTile.TILE_HEIGHT_PX) + yOffset;
unit.DrawAt( xLocation, yLocation); unit.DrawAt( xLocation, yLocation);
} }
foreach (UnitObject unit in npcUnits) foreach (Unit unit in npcUnits)
{ {
int xLocation = (unit.xPos * MapTile.TILE_WIDTH_PX) + xOffset; int xLocation = (unit.xPos * MapTile.TILE_WIDTH_PX) + xOffset;
int yLocation = (unit.yPos * MapTile.TILE_HEIGHT_PX) + yOffset; int yLocation = (unit.yPos * MapTile.TILE_HEIGHT_PX) + yOffset;
@ -229,13 +230,13 @@ namespace Johnmagotchi.GameContent.Objects
List<string> enemy = new List<string>(); List<string> enemy = new List<string>();
List<string> npc = new List<string>(); List<string> npc = new List<string>();
foreach (UnitObject unit in playerUnits) { foreach (Unit unit in playerUnits) {
player.Add(unit.GetAsSerialized()); player.Add(unit.GetAsSerialized());
} }
foreach (UnitObject unit in enemyUnits) { foreach (Unit unit in enemyUnits) {
enemy.Add(unit.GetAsSerialized()); enemy.Add(unit.GetAsSerialized());
} }
foreach (UnitObject unit in npcUnits) foreach (Unit unit in npcUnits)
{ {
npc.Add(unit.GetAsSerialized()); npc.Add(unit.GetAsSerialized());
} }
@ -248,31 +249,32 @@ namespace Johnmagotchi.GameContent.Objects
} }
public void DeserializeUnitData() { public void DeserializeUnitData() {
TibzLog.Debug("Deserializing unit data"); TibzLog.Debug("Deserializing unit data");
List<UnitObject> OutPlayerUnits = new List<UnitObject>(); List<Unit> OutPlayerUnits = new List<Unit>();
List<UnitObject> OutEnemyUnits = new List<UnitObject>(); List<Unit> OutEnemyUnits = new List<Unit>();
List<UnitObject> OutNpcUnits = new List<UnitObject>(); List<Unit> OutNpcUnits = new List<Unit>();
List<string> players = JsonSerializer.Deserialize<List<string>>(serializedPlayerUnits); List<string> players = JsonSerializer.Deserialize<List<string>>(serializedPlayerUnits);
List<string> enemies = JsonSerializer.Deserialize<List<string>>(serializedEnemyUnits); List<string> enemies = JsonSerializer.Deserialize<List<string>>(serializedEnemyUnits);
List<string> npcs = JsonSerializer.Deserialize<List<string>>(serializedNpcUnits); List<string> npcs = JsonSerializer.Deserialize<List<string>>(serializedNpcUnits);
foreach(string entry in players) { foreach(string entry in players) {
UnitObject newUnit = new UnitObject(entry); Unit newUnit = new Unit(entry);
TibzLog.Debug(JsonSerializer.Serialize(newUnit)); TibzLog.Debug(JsonSerializer.Serialize(newUnit));
OutPlayerUnits.Add(newUnit); // makes new instance from serialized string OutPlayerUnits.Add(newUnit); // makes new instance from serialized string
newUnit.InitSprite(_screenManager, UnitObject.UnitTeam.PLAYER); newUnit.InitSprite(_screenManager);
} }
foreach (string entry in enemies) foreach (string entry in enemies)
{ {
UnitObject newUnit = new UnitObject(entry); Unit newUnit = new Unit(entry);
OutEnemyUnits.Add(newUnit); // makes new instance from serialized string OutEnemyUnits.Add(newUnit); // makes new instance from serialized string
newUnit.InitSprite(_screenManager, UnitObject.UnitTeam.ENEMY); newUnit.InitSprite(_screenManager);
} }
foreach (string entry in npcs) foreach (string entry in npcs)
{ {
UnitObject newUnit = new UnitObject(entry); Unit newUnit = new Unit(entry);
OutNpcUnits.Add(newUnit); // makes new instance from serialized string OutNpcUnits.Add(newUnit); // makes new instance from serialized string
newUnit.InitSprite(_screenManager,UnitObject.UnitTeam.NPC); newUnit.InitSprite(_screenManager);
} }
playerUnits = OutPlayerUnits; playerUnits = OutPlayerUnits;
@ -282,70 +284,72 @@ namespace Johnmagotchi.GameContent.Objects
TibzLog.Debug("P:" + playerUnits.Count + " E:" + enemyUnits.Count + " N:" + npcUnits.Count); TibzLog.Debug("P:" + playerUnits.Count + " E:" + enemyUnits.Count + " N:" + npcUnits.Count);
} }
public void AddPlayerUnit(UnitObject unitRef, int xpos, int ypos) public void AddPlayerUnit(Unit unitRef, int xpos, int ypos)
{ {
if (! CheckIfUnitCanBePlaced(unitRef, xpos, ypos)) if (! CheckIfUnitCanBePlaced(unitRef, xpos, ypos))
{ {
return; return;
} }
UnitObject unit = new UnitObject(unitRef); Unit unit = new Unit(unitRef);
unit.SetShaderSet(UnitObject.SpriteShaderSets.PLAYER_NORMAL); unit.SetShaderSet(Unit.SpriteShaderSets.PLAYER_NORMAL);
unit.xPos = xpos; unit.xPos = xpos;
unit.yPos = ypos; unit.yPos = ypos;
if (unit.isUnique == true) //if (unit.isUnique == true)
{ //{
//check then replace // //check then replace
for (int i = 0; i < playerUnits.Count; i++) // for (int i = 0; i < playerUnits.Count; i++)
{ // {
if (playerUnits[i].id == unit.id ) // if (playerUnits[i].id == unit.id )
{ // {
playerUnits[i].xPos = xpos; // playerUnits[i].xPos = xpos;
playerUnits[i].yPos = ypos; // playerUnits[i].yPos = ypos;
return; // dont add // return; // dont add
} // }
} // }
playerUnits.Add(unit); // else add // playerUnits.Add(unit); // else add
} //}
else { //else { playerUnits.Add(unit);
//}
playerUnits.Add(unit); playerUnits.Add(unit);
} unit.stats.status.team = Units.BattleObjects.UnitCurrentStatus.UnitTeam.PLAYER;
unit.InitSprite(_screenManager, UnitObject.UnitTeam.PLAYER);
unit.InitSprite(_screenManager);
} }
public void AddEnemyUnit(UnitObject unitRef, int xpos, int ypos) public void AddEnemyUnit(Unit unitRef, int xpos, int ypos)
{ {
if (!CheckIfUnitCanBePlaced(unitRef, xpos, ypos)) if (!CheckIfUnitCanBePlaced(unitRef, xpos, ypos))
{ {
return; return;
} }
UnitObject unit = new UnitObject(unitRef); Unit unit = new Unit(unitRef);
unit.SetShaderSet(UnitObject.SpriteShaderSets.ENEMY_NORMAL); unit.SetShaderSet(Unit.SpriteShaderSets.ENEMY_NORMAL);
unit.xPos = xpos; unit.xPos = xpos;
unit.yPos = ypos; unit.yPos = ypos;
if (unit.isUnique == true) //if (unit.isUnique == true)
{ //{
//check then replace // //check then replace
for (int i = 0; i < enemyUnits.Count; i++) // for (int i = 0; i < enemyUnits.Count; i++)
{ // {
if (enemyUnits[i].id == unit.id) // if (enemyUnits[i].id == unit.id)
{ // {
enemyUnits[i].xPos = xpos; // enemyUnits[i].xPos = xpos;
enemyUnits[i].yPos = ypos; // enemyUnits[i].yPos = ypos;
return; // dont add // return; // dont add
} // }
} // }
enemyUnits.Add(unit); // else add // enemyUnits.Add(unit); // else add
} //}
else //else
{ //{
enemyUnits.Add(unit); enemyUnits.Add(unit);
} unit.stats.status.team = Units.BattleObjects.UnitCurrentStatus.UnitTeam.ENEMY;
unit.InitSprite(_screenManager, UnitObject.UnitTeam.ENEMY); unit.InitSprite(_screenManager);
} }
public void AddNpcUnit(UnitObject unitRef, int xpos, int ypos) public void AddNpcUnit(Unit unitRef, int xpos, int ypos)
{ {
if (!CheckIfUnitCanBePlaced(unitRef, xpos, ypos)) if (!CheckIfUnitCanBePlaced(unitRef, xpos, ypos))
@ -353,35 +357,36 @@ namespace Johnmagotchi.GameContent.Objects
return; return;
} }
UnitObject unit = new UnitObject(unitRef); Unit unit = new Unit(unitRef);
unit.SetShaderSet(UnitObject.SpriteShaderSets.NPC_NORMAL); unit.SetShaderSet(Unit.SpriteShaderSets.NPC_NORMAL);
unit.xPos = xpos; unit.xPos = xpos;
unit.yPos = ypos; unit.yPos = ypos;
if (unit.isUnique == true) //if (unit.isUnique == true)
{ //{
//check then replace // //check then replace
for (int i = 0; i < npcUnits.Count; i++) // for (int i = 0; i < npcUnits.Count; i++)
{ // {
if (npcUnits[i].id == unit.id) // if (npcUnits[i].id == unit.id)
{ // {
enemyUnits[i] = unit; // enemyUnits[i] = unit;
return; // dont add // return; // dont add
} // }
} // }
npcUnits.Add(unit); // else add // npcUnits.Add(unit); // else add
} //}
else //else
{ //{
npcUnits.Add(unit); npcUnits.Add(unit);
} // }
unit.InitSprite(_screenManager, UnitObject.UnitTeam.NPC); unit.InitSprite(_screenManager);
unit.stats.status.team = Units.BattleObjects.UnitCurrentStatus.UnitTeam.NPC;
TibzLog.Debug("NPC obj count: {0}", npcUnits.Count); TibzLog.Debug("NPC obj count: {0}", npcUnits.Count);
} }
public void deleteUnit(UnitObject unitRef) { public void deleteUnit(Unit unitRef) {
int removePlayerIndex = -1; int removePlayerIndex = -1;
int removeEnemyIndex = -1; int removeEnemyIndex = -1;
@ -416,7 +421,7 @@ namespace Johnmagotchi.GameContent.Objects
if (removeNpcIndex != -1) { npcUnits.RemoveAt(removeNpcIndex); } if (removeNpcIndex != -1) { npcUnits.RemoveAt(removeNpcIndex); }
} }
private bool CheckIfUnitCanBePlaced(UnitObject unit, int x, int y) { private bool CheckIfUnitCanBePlaced(Unit unit, int x, int y) {
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. 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; return false;
@ -432,14 +437,14 @@ namespace Johnmagotchi.GameContent.Objects
} }
public bool CheckIfPlayerUnits(int CursorX, int CursorY) public bool CheckIfPlayerUnits(int CursorX, int CursorY)
{ {
foreach (UnitObject Unit in playerUnits) { foreach (Unit Unit in playerUnits) {
if (Unit.xPos == CursorX && Unit.yPos == CursorY) { return true; } if (Unit.xPos == CursorX && Unit.yPos == CursorY) { return true; }
} }
return false; return false;
} }
public bool CheckIfEnemyUnits(int CursorX, int CursorY) public bool CheckIfEnemyUnits(int CursorX, int CursorY)
{ {
foreach (UnitObject Unit in enemyUnits) foreach (Unit Unit in enemyUnits)
{ {
if (Unit.xPos == CursorX && Unit.yPos == CursorY) { return true; } if (Unit.xPos == CursorX && Unit.yPos == CursorY) { return true; }
} }
@ -447,23 +452,23 @@ namespace Johnmagotchi.GameContent.Objects
} }
public bool CheckIfNpcUnits(int CursorX, int CursorY) public bool CheckIfNpcUnits(int CursorX, int CursorY)
{ {
foreach (UnitObject Unit in npcUnits) foreach (Unit Unit in npcUnits)
{ {
if (Unit.xPos == CursorX && Unit.yPos == CursorY) { return true; } if (Unit.xPos == CursorX && Unit.yPos == CursorY) { return true; }
} }
return false; return false;
} }
public UnitObject getUnitAtLocation(int CursorX, int CursorY) { public Unit getUnitAtLocation(int CursorX, int CursorY) {
foreach (UnitObject Unit in playerUnits) foreach (Unit Unit in playerUnits)
{ {
if (Unit.xPos == CursorX && Unit.yPos == CursorY) { return Unit; } if (Unit.xPos == CursorX && Unit.yPos == CursorY) { return Unit; }
} }
foreach (UnitObject Unit in enemyUnits) foreach (Unit Unit in enemyUnits)
{ {
if (Unit.xPos == CursorX && Unit.yPos == CursorY) { return Unit; } if (Unit.xPos == CursorX && Unit.yPos == CursorY) { return Unit; }
} }
foreach (UnitObject Unit in npcUnits) foreach (Unit Unit in npcUnits)
{ {
if (Unit.xPos == CursorX && Unit.yPos == CursorY) { return Unit; } if (Unit.xPos == CursorX && Unit.yPos == CursorY) { return Unit; }
} }
@ -472,7 +477,7 @@ namespace Johnmagotchi.GameContent.Objects
public void moveUnit(UnitObject unitcopy, int x, int y) public void moveUnit(UnitObject unitcopy, int x, int y)
{ {
foreach (UnitObject Unit in playerUnits) foreach (Unit Unit in playerUnits)
{ {
if (Unit.internalID == unitcopy.internalID) if (Unit.internalID == unitcopy.internalID)
{ {
@ -480,11 +485,11 @@ namespace Johnmagotchi.GameContent.Objects
Unit.yPos = y; Unit.yPos = y;
} }
} }
foreach (UnitObject Unit in enemyUnits) foreach (Unit Unit in enemyUnits)
{ {
if (Unit.internalID == unitcopy.internalID) { } if (Unit.internalID == unitcopy.internalID) { }
} }
foreach (UnitObject Unit in npcUnits) foreach (Unit Unit in npcUnits)
{ {
if (Unit.internalID == unitcopy.internalID) { } if (Unit.internalID == unitcopy.internalID) { }
} }

View File

@ -1,5 +1,6 @@
using Johnmagotchi.Core.tools; using Johnmagotchi.Core.tools;
using Johnmagotchi.GameContent.Logic; using Johnmagotchi.GameContent.Logic;
using Johnmagotchi.GameContent.Objects.Units;
using Johnmagotchi.GameContent.Units; using Johnmagotchi.GameContent.Units;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -15,7 +16,7 @@ namespace Johnmagotchi.GameContent.Objects.Maps
} }
UnitObject selectedUnit; Unit selectedUnit;
BattleMap currentMap; BattleMap currentMap;
public int movesRemaining; public int movesRemaining;
public int x; public int x;
@ -141,11 +142,11 @@ namespace Johnmagotchi.GameContent.Objects.Maps
private int getMovesRemaining(MapTile destTile , int x, int y) { private int getMovesRemaining(MapTile destTile , int x, int y) {
// check if occupied by another uint // check if occupied by another uint
UnitObject targetUnit = currentMap.getUnitAtLocation(x, y); Unit targetUnit = currentMap.getUnitAtLocation(x, y);
if (targetUnit != null) { if (targetUnit != null) {
if ( if (
(selectedUnit.team == UnitObject.UnitTeam.PLAYER && targetUnit.team == UnitObject.UnitTeam.ENEMY) || (selectedUnit.team == Unit.UnitTeam.PLAYER && targetUnit.stats.status.team == Units.BattleObjects.UnitCurrentStatus.UnitTeam.ENEMY) ||
(selectedUnit.team == UnitObject.UnitTeam.ENEMY && (targetUnit.team == UnitObject.UnitTeam.PLAYER || targetUnit.team == UnitObject.UnitTeam.NPC)) (selectedUnit.team == Unit.UnitTeam.ENEMY && (targetUnit.team == UnitObject.UnitTeam.PLAYER || targetUnit.team == UnitObject.UnitTeam.NPC))
) )
{ {
return 0; return 0;

View File

@ -20,6 +20,7 @@ namespace Johnmagotchi.GameContent.Objects.Units.BattleObjects
public int AttackRangeMax; public int AttackRangeMax;
public AttackTypeEnum AttackType; public AttackTypeEnum AttackType;
public SpecialAttackPropertiesEnum SpecialProperties; public SpecialAttackPropertiesEnum SpecialProperties;
public DamageType DamageType;
} }
} }

View File

@ -7,11 +7,12 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using static Johnmagotchi.Data.BattleObjects.AttackDefines;
using static Johnmagotchi.Data.BattleObjects.SupportDefines; using static Johnmagotchi.Data.BattleObjects.SupportDefines;
namespace Johnmagotchi.GameContent.Objects.Units.BattleObjects namespace Johnmagotchi.GameContent.Objects.Units.BattleObjects
{ {
public class BattleObjectManager public static class BattleObjectManager
{ {
public static List<AttackObj> AllAttacks; public static List<AttackObj> AllAttacks;
@ -62,6 +63,7 @@ namespace Johnmagotchi.GameContent.Objects.Units.BattleObjects
int AttackRangeMaxIndex = -1; int AttackRangeMaxIndex = -1;
int AttackTypeIndex = -1; int AttackTypeIndex = -1;
int SpecialPropertiesIndex = -1; int SpecialPropertiesIndex = -1;
int DamageTypeIndex = -1;
bool AreColumnIndexesSet = false; bool AreColumnIndexesSet = false;
@ -90,6 +92,7 @@ namespace Johnmagotchi.GameContent.Objects.Units.BattleObjects
if (values[i].Trim() == "AttackRangeMax") { AttackRangeMaxIndex = i; } if (values[i].Trim() == "AttackRangeMax") { AttackRangeMaxIndex = i; }
if (values[i].Trim() == "AttackType") { AttackTypeIndex = i; } if (values[i].Trim() == "AttackType") { AttackTypeIndex = i; }
if (values[i].Trim() == "SpecialProperties") { SpecialPropertiesIndex = i; } if (values[i].Trim() == "SpecialProperties") { SpecialPropertiesIndex = i; }
if (values[i].Trim() == "DamageType") { DamageTypeIndex = i; }
} }
AreColumnIndexesSet = true; AreColumnIndexesSet = true;
@ -108,6 +111,7 @@ namespace Johnmagotchi.GameContent.Objects.Units.BattleObjects
attack.AttackRangeMax = Int32.Parse(values[AttackRangeMaxIndex]); attack.AttackRangeMax = Int32.Parse(values[AttackRangeMaxIndex]);
attack.AttackType = AttackDefines.ParseAttackTypes(values[AttackTypeIndex]); attack.AttackType = AttackDefines.ParseAttackTypes(values[AttackTypeIndex]);
attack.SpecialProperties = AttackDefines.ParseSpecialAttackProperties(values[SpecialPropertiesIndex]); attack.SpecialProperties = AttackDefines.ParseSpecialAttackProperties(values[SpecialPropertiesIndex]);
attack.DamageType = AttackDefines.ParseDamageTypes(values[DamageTypeIndex]);
AttackList.Add(attack); AttackList.Add(attack);
} }

View File

@ -2,7 +2,6 @@ namespace Johnmagotchi.GameContent.Objects.Units.BattleObjects
{ {
public class UnitStatBlock{ public class UnitStatBlock{
public string Name { get; set; }
public int MaxHealth {get; set;} public int MaxHealth {get; set;}
public int Attack {get; set;} public int Attack {get; set;}
public int Defense {get; set;} public int Defense {get; set;}

View File

@ -51,11 +51,6 @@ namespace Johnmagotchi.GameContent.Objects.Units.Loadouts.PlayerClasses
public List<SupportObj> ClassSupports; // default public List<SupportObj> ClassSupports; // default
public List<SkillObj> ClassSkills; // default public List<SkillObj> ClassSkills; // default
public UnitStatBlock StatBoosts; // This is a unit stat block that will be added? to the base stats of a unit.
List<int> defaultAttackIds;
List<int> defaultSupportIds;
List<int> defaultSkillIds;
@ -65,9 +60,9 @@ namespace Johnmagotchi.GameContent.Objects.Units.Loadouts.PlayerClasses
ClassAttacks = new List<AttackObj>(); ClassAttacks = new List<AttackObj>();
ClassSupports = new List<SupportObj>(); ClassSupports = new List<SupportObj>();
ClassSkills = new List<SkillObj>(); ClassSkills = new List<SkillObj>();
StatBoosts = new UnitStatBlock();
InitClassSpecificFields(); InitClassSpecificFields();
InitClassDefaultAttacks();
} }
public void SetAndInitLoadout( UnitLoadout loadout) { public void SetAndInitLoadout( UnitLoadout loadout) {
@ -85,53 +80,69 @@ namespace Johnmagotchi.GameContent.Objects.Units.Loadouts.PlayerClasses
switch (ClassType) { switch (ClassType) {
case PlayerClassType.RR_KNIGHT: case PlayerClassType.RR_KNIGHT:
PrimaryColor = ModuleColor.RED; SecondaryColor = ModuleColor.RED; PrimaryColor = ModuleColor.RED;
SecondaryColor = ModuleColor.RED;
break; break;
case PlayerClassType.RB_MERC: case PlayerClassType.RB_MERC:
PrimaryColor = ModuleColor.RED; SecondaryColor = ModuleColor.BLUE; PrimaryColor = ModuleColor.RED;
SecondaryColor = ModuleColor.BLUE;
break; break;
case PlayerClassType.RY_GRAPPLER: case PlayerClassType.RY_GRAPPLER:
PrimaryColor = ModuleColor.RED; SecondaryColor = ModuleColor.YELLOW; PrimaryColor = ModuleColor.RED;
SecondaryColor = ModuleColor.YELLOW;
break; break;
case PlayerClassType.RG_SHIELD: case PlayerClassType.RG_SHIELD:
PrimaryColor = ModuleColor.RED; SecondaryColor = ModuleColor.GREEN; PrimaryColor = ModuleColor.RED;
SecondaryColor = ModuleColor.GREEN;
break; break;
case PlayerClassType.RP_PYRO: case PlayerClassType.RP_PYRO:
PrimaryColor = ModuleColor.RED; SecondaryColor = ModuleColor.PURPLE; PrimaryColor = ModuleColor.RED;
SecondaryColor = ModuleColor.PURPLE;
break; break;
case PlayerClassType.BB_HECK_DIVER: case PlayerClassType.BB_HECK_DIVER:
PrimaryColor = ModuleColor.BLUE; SecondaryColor = ModuleColor.BLUE; PrimaryColor = ModuleColor.BLUE;
SecondaryColor = ModuleColor.BLUE;
break; break;
case PlayerClassType.BY_SPECIALIST: case PlayerClassType.BY_SPECIALIST:
PrimaryColor = ModuleColor.BLUE; SecondaryColor = ModuleColor.YELLOW; PrimaryColor = ModuleColor.BLUE;
SecondaryColor = ModuleColor.YELLOW;
break; break;
case PlayerClassType.BG_ORORO_MUNROE: case PlayerClassType.BG_ORORO_MUNROE:
PrimaryColor = ModuleColor.BLUE; SecondaryColor = ModuleColor.GREEN; PrimaryColor = ModuleColor.BLUE;
SecondaryColor = ModuleColor.GREEN;
break; break;
case PlayerClassType.BP_GRENADIER: case PlayerClassType.BP_GRENADIER:
PrimaryColor = ModuleColor.BLUE; SecondaryColor = ModuleColor.PURPLE; PrimaryColor = ModuleColor.BLUE;
SecondaryColor = ModuleColor.PURPLE;
break; break;
case PlayerClassType.YY_ASSASSIN: case PlayerClassType.YY_ASSASSIN:
PrimaryColor = ModuleColor.YELLOW; SecondaryColor = ModuleColor.YELLOW; PrimaryColor = ModuleColor.YELLOW;
SecondaryColor = ModuleColor.YELLOW;
break; break;
case PlayerClassType.YG_SPY: case PlayerClassType.YG_SPY:
PrimaryColor = ModuleColor.YELLOW; SecondaryColor = ModuleColor.GREEN; PrimaryColor = ModuleColor.YELLOW;
SecondaryColor = ModuleColor.GREEN;
break; break;
case PlayerClassType.YP_SURVIVALIST: case PlayerClassType.YP_SURVIVALIST:
PrimaryColor = ModuleColor.YELLOW; SecondaryColor = ModuleColor.PURPLE; PrimaryColor = ModuleColor.YELLOW;
SecondaryColor = ModuleColor.PURPLE;
break; break;
case PlayerClassType.GG_HEALER: case PlayerClassType.GG_HEALER:
PrimaryColor = ModuleColor.GREEN; SecondaryColor = ModuleColor.GREEN; PrimaryColor = ModuleColor.GREEN;
SecondaryColor = ModuleColor.GREEN;
break; break;
case PlayerClassType.GP_MOIRAINE_HERSELF: case PlayerClassType.GP_MOIRAINE_HERSELF:
PrimaryColor = ModuleColor.GREEN; SecondaryColor = ModuleColor.PURPLE; PrimaryColor = ModuleColor.GREEN;
SecondaryColor = ModuleColor.PURPLE;
break; break;
case PlayerClassType.PP_ELEMENTALIST: case PlayerClassType.PP_ELEMENTALIST:
PrimaryColor = ModuleColor.PURPLE; SecondaryColor = ModuleColor.PURPLE; PrimaryColor = ModuleColor.PURPLE;
SecondaryColor = ModuleColor.PURPLE;
break; break;
case PlayerClassType.CL_COMMONER: case PlayerClassType.CL_COMMONER:
TibzLog.Debug("Commoner built"); TibzLog.Debug("Commoner built");
PrimaryColor = ModuleColor.COLORLESS; SecondaryColor = ModuleColor.COLORLESS; PrimaryColor = ModuleColor.COLORLESS;
SecondaryColor = ModuleColor.COLORLESS;
break; break;
@ -175,6 +186,67 @@ namespace Johnmagotchi.GameContent.Objects.Units.Loadouts.PlayerClasses
} }
} }
private void InitClassDefaultAttacks()
{
AttackObj attack = null;
switch (ClassType)
{
case PlayerClassType.RR_KNIGHT:
attack = BattleObjectManager.AllAttacks.Find(a => a.ID == 1);
break;
case PlayerClassType.RB_MERC:
attack = BattleObjectManager.AllAttacks.Find(a => a.ID == 1);
break;
case PlayerClassType.RY_GRAPPLER:
attack = BattleObjectManager.AllAttacks.Find(a => a.ID == 1);
break;
case PlayerClassType.RG_SHIELD:
attack = BattleObjectManager.AllAttacks.Find(a => a.ID == 1);
break;
case PlayerClassType.RP_PYRO:
attack = BattleObjectManager.AllAttacks.Find(a => a.ID == 1);
break;
case PlayerClassType.BB_HECK_DIVER:
attack = BattleObjectManager.AllAttacks.Find(a => a.ID == 2);
break;
case PlayerClassType.BY_SPECIALIST:
attack = BattleObjectManager.AllAttacks.Find(a => a.ID == 2);
break;
case PlayerClassType.BG_ORORO_MUNROE:
attack = BattleObjectManager.AllAttacks.Find(a => a.ID == 2);
break;
case PlayerClassType.BP_GRENADIER:
attack = BattleObjectManager.AllAttacks.Find(a => a.ID == 2);
break;
case PlayerClassType.YY_ASSASSIN:
attack = BattleObjectManager.AllAttacks.Find(a => a.ID == 2);
break;
case PlayerClassType.YG_SPY:
attack = BattleObjectManager.AllAttacks.Find(a => a.ID == 2);
break;
case PlayerClassType.YP_SURVIVALIST:
attack = BattleObjectManager.AllAttacks.Find(a => a.ID == 2);
break;
case PlayerClassType.GG_HEALER:
break;
case PlayerClassType.GP_MOIRAINE_HERSELF:
break;
case PlayerClassType.PP_ELEMENTALIST:
break;
case PlayerClassType.CL_COMMONER:
attack = BattleObjectManager.AllAttacks.Find(a => a.ID == 1);
break;
}
if (attack != null)
this.ClassAttacks.Add(attack);
}
} }
} }

View File

@ -32,13 +32,9 @@ namespace Johnmagotchi.GameContent.Objects.Units.Loadouts
public UnitLoadout(PlayerClassType pclass) { public UnitLoadout(PlayerClassType pclass) {
PlayerClass = new PlayerClass(pclass); PlayerClass = new PlayerClass(pclass);
AvailableAttacks = new List<AttackObj>(); AvailableAttacks = PlayerClass.ClassAttacks;
AvailableSupports = new List<SupportObj>(); AvailableSupports = PlayerClass.ClassSupports;
ActiveSkills = new List<SkillObj>(); ActiveSkills = PlayerClass.ClassSkills;
AvailableAttacks.Concat(PlayerClass.ClassAttacks);
AvailableSupports.Concat(PlayerClass.ClassSupports);
ActiveSkills.Concat(PlayerClass.ClassSkills);
//TODO - get from module //TODO - get from module
} }

View File

@ -7,35 +7,22 @@ using System.Collections;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using static Johnmagotchi.GameContent.Objects.Units.BattleObjects.UnitStatBlock; using static Johnmagotchi.GameContent.Objects.Units.BattleObjects.UnitStatBlock;
using Johnmagotchi.GameContent.Objects.Units.Loadouts.PlayerClasses; using Johnmagotchi.GameContent.Objects.Units.Loadouts.PlayerClasses;
using Johnmagotchi.GameContent.Objects.Units;
namespace Johnmagotchi.GameContent.Units namespace Johnmagotchi.GameContent.Units
{ {
public class UnitLoader public class UnitLoader
{ {
public static List<string> GetTest(){ public static List<string> GetTest() {
// MAC OS also prly Linux - var path = Path.Combine(Directory.GetCurrentDirectory(), "GameContent/Objects/Units/UnitDefines.csv"); // MAC OS also prly Linux - var path = Path.Combine(Directory.GetCurrentDirectory(), "GameContent/Objects/Units/UnitDefines.csv");
//System.Console.WriteLine("PATH: {0}", Directory.GetCurrentDirectory()); //System.Console.WriteLine("PATH: {0}", Directory.GetCurrentDirectory());
//var path = "..\\..\\..\\GameContent\\Objects\\Units\\UnitDefines.csv"; //var path = "..\\..\\..\\GameContent\\Objects\\Units\\UnitDefines.csv";
List<string> listA = new List<string>(); List<string> listA = new List<string>();
//List<string> listB = new List<string>();
//System.Console.WriteLine("path: {0} ", path);
//using(var reader = new StreamReader(path))
//{
// while (!reader.EndOfStream)
// {
// var line = reader.ReadLine();
// var values = line.Split(',');
// listA.Add(values[0]);
// listB.Add(values[1]);
// }
//}
return listA; return listA;
} }
public static List<UnitObject> LoadBaseUnits(){ public static List<UnitObject> LoadBaseUnits() {
List<UnitObject> unitList = new List<UnitObject>(); List<UnitObject> unitList = new List<UnitObject>();
System.Console.WriteLine("PATH: {0}", Directory.GetCurrentDirectory()); System.Console.WriteLine("PATH: {0}", Directory.GetCurrentDirectory());
var path = "..\\..\\..\\Data\\BattleObjects\\UnitDefinitions.csv"; var path = "..\\..\\..\\Data\\BattleObjects\\UnitDefinitions.csv";
@ -91,7 +78,7 @@ namespace Johnmagotchi.GameContent.Units
unit.id = Int32.Parse(values[IdIndex]); unit.id = Int32.Parse(values[IdIndex]);
unit.name = values[NameIndex]; unit.name = values[NameIndex];
unit.playerClassEnum = PlayerClass.GetClassFromShortHand(values[ClassIndex]); unit.playerClassEnum = PlayerClass.GetClassFromShortHand(values[ClassIndex]);
unit.isUnique = ( values[isUniqueIndex].ToLower() == "true"); unit.isUnique = (values[isUniqueIndex].ToLower() == "true");
unit.stats.MaxHealth = Int32.Parse(values[HealthIndex]); unit.stats.MaxHealth = Int32.Parse(values[HealthIndex]);
unit.stats.Attack = Int32.Parse(values[AttackIndex]); unit.stats.Attack = Int32.Parse(values[AttackIndex]);
unit.stats.Defense = Int32.Parse(values[DefenseIndex]); unit.stats.Defense = Int32.Parse(values[DefenseIndex]);
@ -99,27 +86,86 @@ namespace Johnmagotchi.GameContent.Units
unit.stats.Movement = Int32.Parse(values[MovementIndex]); unit.stats.Movement = Int32.Parse(values[MovementIndex]);
unit.stats.setMovementTypeFromFile(values[MovementTypeIndex]); unit.stats.setMovementTypeFromFile(values[MovementTypeIndex]);
switch (unit.id){
case 0:
// Add texture
break;
case 1:
//add texture
break;
case 2:
break;
// add texture
default:
break;
}
unitList.Add(unit); unitList.Add(unit);
} }
} }
} }
return unitList; return unitList;
} }
public static List <Unit> LoadUnitList ()
{
List<Unit> unitList = new List<Unit>();
System.Console.WriteLine("PATH: {0}", Directory.GetCurrentDirectory());
var path = "..\\..\\..\\Data\\BattleObjects\\UnitDefinitions.csv";
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
{
Unit unit = new Unit();
unit.UnitID = Int32.Parse(values[IdIndex]);
unit.stats.Name = values[NameIndex];
unit.name = values[NameIndex];
unit.stats.classId = PlayerClass.GetClassFromShortHand(values[ClassIndex]);
// unit.isUnique = (values[isUniqueIndex].ToLower() == "true");
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.setMovementTypeFromFile(values[MovementTypeIndex]);
unitList.Add(unit);
}
}
}
return unitList;
}
} }
} }

View File

@ -16,15 +16,14 @@ using static Johnmagotchi.GameContent.Objects.Units.Loadouts.PlayerClasses.Playe
namespace Johnmagotchi.GameContent.Objects.Units.GameLogic namespace Johnmagotchi.GameContent.Objects.Units.GameLogic
{ {
internal abstract class BaseUnitGameObject public abstract class BaseUnitGameObject
{ {
//defined stats //defined stats
public int internalID; // used to reference this object internally 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; } public string name { get; set; }
private UnitStats stats; public UnitStats stats;
public PlayerClassType playerClassEnum { get; set; } public PlayerClassType playerClassEnum { get; set; }

View File

@ -9,19 +9,21 @@ using static Johnmagotchi.GameContent.Objects.Units.Loadouts.PlayerClasses.Playe
namespace Johnmagotchi.GameContent.Objects.Units.Stats namespace Johnmagotchi.GameContent.Objects.Units.Stats
{ {
internal class UnitStats public class UnitStats
{ {
internal UnitStatBlock statblock; public string Name { get; set; }
internal UnitCurrentStatus status; public UnitStatBlock baseStats;
internal UnitLoadout loadout; public UnitCurrentStatus status;
internal PlayerClassType classId; public UnitLoadout loadout;
public PlayerClassType classId;
public UnitStats() public UnitStats()
{ {
// Default Stats // Default Stats
classId = PlayerClassType.CL_COMMONER; classId = PlayerClassType.CL_COMMONER;
statblock = new UnitStatBlock(); baseStats = new UnitStatBlock();
status = new UnitCurrentStatus(statblock); status = new UnitCurrentStatus(baseStats);
loadout = new UnitLoadout(classId); loadout = new UnitLoadout(classId);
} }

View File

@ -6,25 +6,28 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Text.Json;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Transactions; using System.Transactions;
using TibzGame.Core.ScreenManager;
namespace Johnmagotchi.GameContent.Objects.Units namespace Johnmagotchi.GameContent.Objects.Units
{ {
internal class Unit : BaseUnitGameObject public class Unit : BaseUnitGameObject
{ {
internal UnitStats stats; public int UnitID;
public Unit() public Unit() : base()
{ {
SetStats(new UnitStats()); this.SetStats(new UnitStats());
} }
public Unit(Unit template) public Unit(Unit template) : base()
{ {
SetStats(template.GetStats()); SetStats(template.GetStats());
} }
public Unit(string serializeStatdData) public Unit(string serializeStatdData) : base()
{ {
SetStats(LoadStatsFromSerialized(serializeStatdData)); SetStats(LoadStatsFromSerialized(serializeStatdData));
} }
@ -36,7 +39,14 @@ namespace Johnmagotchi.GameContent.Objects.Units
public UnitStats LoadStatsFromSerialized(string data) public UnitStats LoadStatsFromSerialized(string data)
{ {
Unit temp = JsonSerializer.Deserialize<Unit>(data);
this.stats = temp.stats;
return new UnitStats(); return new UnitStats();
} }
public void Init(ScreenManager screenManager) {
this.InitSprite(screenManager);
}
} }
} }

View File

@ -45,7 +45,6 @@ namespace Johnmagotchi.GameContent.Screens.MapScreens.BattleMapScreen
public override void Draw() public override void Draw()
{ {
throw new NotImplementedException();
} }
public override void Init() public override void Init()

View File

@ -10,6 +10,7 @@ using System.IO;
using System; using System;
using Johnmagotchi.GameContent.Objects.Units.Loadouts; using Johnmagotchi.GameContent.Objects.Units.Loadouts;
using Johnmagotchi.GameContent.Objects.Units.BattleObjects; using Johnmagotchi.GameContent.Objects.Units.BattleObjects;
using Johnmagotchi.GameContent.Objects.Units;
namespace Johnmagotchi.Screen.BattleMapScreens namespace Johnmagotchi.Screen.BattleMapScreens
{ {
@ -32,7 +33,8 @@ namespace Johnmagotchi.Screen.BattleMapScreens
private int selectedUnitIndex; private int selectedUnitIndex;
private EditorToolType CurrentTool; private EditorToolType CurrentTool;
private MapEditorInfoText InfoText; private MapEditorInfoText InfoText;
public List<UnitObject> AvailableUnits; public List<UnitObject> AvailableOldUnits;
public List<Unit> AvailableNewUnits;
public List<UnitLoadout> AvailableLoadouts; public List<UnitLoadout> AvailableLoadouts;
private UnitFactionType UnitFaction; private UnitFactionType UnitFaction;
@ -54,13 +56,15 @@ namespace Johnmagotchi.Screen.BattleMapScreens
{ {
InfoText.Init(screenManager); InfoText.Init(screenManager);
selectedTileType = TileType.GRASS; selectedTileType = TileType.GRASS;
AvailableUnits = UnitLoader.LoadBaseUnits(); AvailableOldUnits = UnitLoader.LoadBaseUnits();
AvailableNewUnits = UnitLoader.LoadUnitList();
TibzLog.Debug(AvailableNewUnits);
selectedUnitIndex = 0; selectedUnitIndex = 0;
UnitFaction = UnitFactionType.PLAYER; UnitFaction = UnitFactionType.PLAYER;
foreach (UnitObject unit in AvailableUnits) { foreach (UnitObject unit in AvailableOldUnits) {
TibzLog.Debug(" Unit id: {0}, name: {1}, health: {2}, atk: {3}, def: {4}, spd {5}, unique: {6}, movementType {7} ", TibzLog.Debug(" Unit id: {0}, name: {1}, health: {2}, atk: {3}, def: {4}, spd {5}, unique: {6}, movementType {7} ",
unit.id, unit.name, unit.stats.MaxHealth, unit.stats.Attack, unit.stats.Defense,unit.stats.Speed , unit.isUnique, unit.stats.movementType); unit.id, unit.name, unit.stats.MaxHealth, unit.stats.Attack, unit.stats.Defense,unit.stats.Speed , unit.isUnique, unit.stats.movementType);
} }
@ -92,7 +96,7 @@ namespace Johnmagotchi.Screen.BattleMapScreens
if (screenManager.inputs.editorInputs.special1.isJustPressed) if (screenManager.inputs.editorInputs.special1.isJustPressed)
{ {
selectedUnitIndex ++; selectedUnitIndex ++;
if (selectedUnitIndex > AvailableUnits.Count -1) { if (selectedUnitIndex > AvailableNewUnits.Count -1) {
selectedUnitIndex = 0; selectedUnitIndex = 0;
} }
} }
@ -101,7 +105,7 @@ namespace Johnmagotchi.Screen.BattleMapScreens
selectedUnitIndex --; selectedUnitIndex --;
if (selectedUnitIndex < 0) if (selectedUnitIndex < 0)
{ {
selectedUnitIndex = AvailableUnits.Count - 1; selectedUnitIndex = AvailableNewUnits.Count - 1;
} }
} }
@ -125,15 +129,15 @@ namespace Johnmagotchi.Screen.BattleMapScreens
{ {
if (UnitFaction == UnitFactionType.PLAYER) if (UnitFaction == UnitFactionType.PLAYER)
{ {
CurrentMap.AddPlayerUnit(AvailableUnits[selectedUnitIndex], cursorIndexX, cursorIndexY); CurrentMap.AddPlayerUnit(AvailableNewUnits[selectedUnitIndex], cursorIndexX, cursorIndexY);
} }
else if (UnitFaction == UnitFactionType.ENEMY) else if (UnitFaction == UnitFactionType.ENEMY)
{ {
CurrentMap.AddEnemyUnit(AvailableUnits[selectedUnitIndex], cursorIndexX, cursorIndexY); CurrentMap.AddEnemyUnit(AvailableNewUnits[selectedUnitIndex], cursorIndexX, cursorIndexY);
} }
else if (UnitFaction == UnitFactionType.NPC) else if (UnitFaction == UnitFactionType.NPC)
{ {
CurrentMap.AddNpcUnit(AvailableUnits[selectedUnitIndex], cursorIndexX, cursorIndexY); CurrentMap.AddNpcUnit(AvailableNewUnits[selectedUnitIndex], cursorIndexX, cursorIndexY);
} }
// CurrentMap.ChangeTileType(this.cursorIndexX, this.cursorIndexY, this.selectedTileType); // CurrentMap.ChangeTileType(this.cursorIndexX, this.cursorIndexY, this.selectedTileType);
} }
@ -145,7 +149,7 @@ namespace Johnmagotchi.Screen.BattleMapScreens
if (screenManager.inputs.editorInputs.confirm.isJustPressed) if (screenManager.inputs.editorInputs.confirm.isJustPressed)
{ {
UnitObject deleteUnit = CurrentMap.getUnitAtLocation(cursorIndexX, cursorIndexY); Unit deleteUnit = CurrentMap.getUnitAtLocation(cursorIndexX, cursorIndexY);
if (deleteUnit != null) if (deleteUnit != null)
{ {
CurrentMap.deleteUnit(deleteUnit); CurrentMap.deleteUnit(deleteUnit);
@ -180,7 +184,7 @@ namespace Johnmagotchi.Screen.BattleMapScreens
} }
if (CurrentTool == EditorToolType.UNIT_ADD) if (CurrentTool == EditorToolType.UNIT_ADD)
{ {
InfoText.Draw(CursorQuadrant, 15, 30, "Current Unit : " + AvailableUnits[selectedUnitIndex].name); InfoText.Draw(CursorQuadrant, 15, 30, "Current Unit : " + AvailableOldUnits[selectedUnitIndex].name);
InfoText.Draw(CursorQuadrant, 15, 60, "Current Faction : " + UnitFaction); InfoText.Draw(CursorQuadrant, 15, 60, "Current Faction : " + UnitFaction);
} }
} }
@ -201,7 +205,7 @@ namespace Johnmagotchi.Screen.BattleMapScreens
try try
{ {
var path = "..\\..\\..\\Data\\SaveMapData\\map-" + saveslot + ".json"; var path = "..\\..\\..\\Data\\SaveMapData\\map-" + saveslot + ".json";
//Pass the file path and file name to the StreamReader constructor //Pass the file~~ path and file name to the StreamReader constructor
StreamReader sr = new StreamReader(path); StreamReader sr = new StreamReader(path);
//We should only need to read the first line of text //We should only need to read the first line of text
string line = sr.ReadLine(); string line = sr.ReadLine();