Compare commits

..

No commits in common. "e54ba4652fc2b6781d0420f9ab6166c9ac16f051" and "6b7595ab773138ad6276d1bfc0a3f6457b87d575" have entirely different histories.

26 changed files with 757 additions and 292 deletions

View File

@ -6,7 +6,7 @@ using System.Reflection.Metadata;
using System.Text;
using Johnmagotchi.Core.tools;
using Johnmagotchi.Data;
using Johnmagotchi.GameContent.Objects.BattleObjects;
using Johnmagotchi.GameContent.Objects.Units.BattleObjects;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

View File

@ -1,4 +1,4 @@
using Johnmagotchi.GameContent.Objects.BattleObjects;
using Johnmagotchi.GameContent.Objects.Units.BattleObjects;
using System;
using System.Collections.Generic;
using System.Linq;

View File

@ -1,4 +1,6 @@
using Johnmagotchi.GameContent.Objects.Units;
using Johnmagotchi.GameContent.Objects.Units.BattleObjects;
using Johnmagotchi.GameContent.Units;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@ -14,8 +16,7 @@ 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)
{
public static BattleResults RunBattle(ref Unit Attacker, ref Unit Defender, AttackObj attack, AttackObj counterAttack) {
// these are debugs, should be parsed from attack + unit combos
bool IsCounterAttackOccuring = true;
@ -24,99 +25,98 @@ 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
{
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);
// results.addResult(BattleResults.resultType.MISS, 0, isCounter);
// }
// else if (hitRoll >= critThreshold) //Handle Crits
// {
//apply Damage to defending unit, then add to result report
Defender.stats.status.CurrentHealth -= TotalCritDamage;
results.addResult(BattleResults.resultType.CRITICAL, TotalCritDamage, isCounter);
// 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);
}
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 to defending unit, then add to result report
// Defender.stats.status.CurrentHealth -= TotalCritDamage;
// results.addResult(BattleResults.resultType.CRITICAL, TotalCritDamage, isCounter);
//Apply damage + report to animation handler
Defender.stats.status.CurrentHealth -= BaseDamage;
results.addResult(BattleResults.resultType.ATTACK, BaseDamage, isCounter);
}
}
return;
}
// }
// 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);
private static int CalculateDamage( Unit Attacker, Unit Defender, AttackObj attack)
{
int damage = 0;
// //Apply damage + report to animation handler
// Defender.stats.status.CurrentHealth -= BaseDamage;
// results.addResult(BattleResults.resultType.ATTACK, BaseDamage, isCounter);
// }
// }
// return;
//}
damage += attack.BaseDamage;
damage += Attacker.stats.baseStats.Attack;
// private static int CalculateDamage( Unit Attacker, Unit Defender, AttackObj attack)
// {
// int damage = 0;
// damage += attack.BaseDamage;
// damage += Attacker.stats.baseStats.Attack;
// damage -= Defender.stats.baseStats.Defense;
damage -= Defender.stats.baseStats.Defense;
// if (damage < 0) damage = 0;
// return damage ;
// }
//}
if (damage < 0) damage = 0;
return damage ;
}
}
}

View File

@ -4,7 +4,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static Johnmagotchi.GameContent.Objects.Units.Stats.UnitStatBlock;
using static Johnmagotchi.GameContent.Objects.Units.BattleObjects.UnitStatBlock;
namespace Johnmagotchi.GameContent.Logic
{

View File

@ -8,6 +8,7 @@ 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;
@ -21,14 +22,16 @@ namespace Johnmagotchi.GameContent.Objects
public int height{ get; set; }
public string serializedMapTiles{ get; set; }
public string serializedUnits { get; set; }
public string serializedPlayerUnits { get; set; }
public string serializedEnemyUnits{ get; set; }
public string serializedNpcUnits { get; set; }
private MapTile [,] MapTileGrid;
private List<Unit> Units;
//private List<Unit> playerUnits;
//private List<Unit> enemyUnits;
//private List<Unit> npcUnits;
private List<Unit> playerUnits;
private List<Unit> enemyUnits;
private List<Unit> npcUnits;
private SpriteBatch _spriteBatch;
private ScreenManager _screenManager;
@ -49,10 +52,9 @@ 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.Units = new List<Unit>();
//this.playerUnits = new List<Unit>();
//this.npcUnits = new List<Unit>();
//this.enemyUnits = new List<Unit>();
this.playerUnits = new List<Unit>();
this.npcUnits = new List<Unit>();
this.enemyUnits = new List<Unit>();
}
public void Init(ScreenManager ScreenManager){
@ -73,7 +75,15 @@ namespace Johnmagotchi.GameContent.Objects
public void Update()
{
foreach (Unit unit in Units)
foreach (Unit unit in playerUnits)
{
unit.Update();
}
foreach (Unit unit in enemyUnits)
{
unit.Update();
}
foreach (Unit unit in npcUnits)
{
unit.Update();
}
@ -151,11 +161,24 @@ namespace Johnmagotchi.GameContent.Objects
public void DrawUnits(int xOffset, int yOffset) {
foreach(Unit unit in Units) {
foreach(Unit unit in playerUnits) {
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)
@ -203,30 +226,62 @@ namespace Johnmagotchi.GameContent.Objects
}
public void SerializeUnitData() {
List<string> units_str = new List<string>();
foreach (Unit unit in Units) {
units_str.Add(unit.GetAsSerialized());
List<string> player = new List<string>();
List<string> enemy = new List<string>();
List<string> npc = new List<string>();
foreach (Unit unit in playerUnits) {
player.Add(unit.GetAsSerialized());
}
serializedUnits = JsonSerializer.Serialize(units_str);
TibzLog.Debug("Units: " + Units.Count);
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);
}
public void DeserializeUnitData() {
TibzLog.Debug("Deserializing unit data");
List<Unit> outUnits = new List<Unit>();
List<Unit> OutPlayerUnits = new List<Unit>();
List<Unit> OutEnemyUnits = new List<Unit>();
List<Unit> OutNpcUnits = new List<Unit>();
List<string> unitsString = JsonSerializer.Deserialize<List<string>>(serializedUnits);
List<string> players = JsonSerializer.Deserialize<List<string>>(serializedPlayerUnits);
List<string> enemies = JsonSerializer.Deserialize<List<string>>(serializedEnemyUnits);
List<string> npcs = JsonSerializer.Deserialize<List<string>>(serializedNpcUnits);
foreach(string entry in unitsString) {
foreach(string entry in players) {
Unit newUnit = new Unit(entry);
TibzLog.Debug(JsonSerializer.Serialize(newUnit));
outUnits.Add(newUnit); // makes new instance from serialized string
OutPlayerUnits.Add(newUnit); // makes new instance from serialized string
newUnit.InitSprite(_screenManager);
}
Units = outUnits;
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);
}
public void AddPlayerUnit(Unit unitRef, int xpos, int ypos)
@ -240,8 +295,25 @@ namespace Johnmagotchi.GameContent.Objects
unit.SetShaderSet(Unit.SpriteShaderSets.PLAYER_NORMAL);
unit.xPos = xpos;
unit.yPos = ypos;
unit.stats.status.team = Objects.Units.Stats.UnitCurrentStatus.UnitTeam.PLAYER;
Units.Add(unit);
//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.InitSprite(_screenManager);
}
@ -256,8 +328,24 @@ namespace Johnmagotchi.GameContent.Objects
unit.SetShaderSet(Unit.SpriteShaderSets.ENEMY_NORMAL);
unit.xPos = xpos;
unit.yPos = ypos;
unit.stats.status.team = Objects.Units.Stats.UnitCurrentStatus.UnitTeam.ENEMY;
Units.Add(unit);
//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.InitSprite(_screenManager);
}
@ -273,29 +361,68 @@ namespace Johnmagotchi.GameContent.Objects
unit.SetShaderSet(Unit.SpriteShaderSets.NPC_NORMAL);
unit.xPos = xpos;
unit.yPos = ypos;
unit.stats.status.team = Objects.Units.Stats.UnitCurrentStatus.UnitTeam.NPC;
Units.Add(unit);
//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.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 removeUnitIndex = -1;
int removePlayerIndex = -1;
int removeEnemyIndex = -1;
int removeNpcIndex = -1;
for (int i = 0; i < Units.Count; i++)
for (int i = 0; i < playerUnits.Count; i++)
{
if (unitRef.internalID == Units[i].internalID)
if (unitRef.internalID == playerUnits[i].internalID)
{
removeUnitIndex = i;
removePlayerIndex = i;
break;
}
}
if (removeUnitIndex != -1) { Units.RemoveAt(removeUnitIndex); }
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); }
}
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;
}
@ -305,28 +432,52 @@ namespace Johnmagotchi.GameContent.Objects
}
public bool CheckIfAnyUnits(int CursorX, int CursorY) {
foreach (Unit Unit in Units)
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)
{
if (Unit.xPos == CursorX && Unit.yPos == CursorY) { return true; }
}
return false;
}
public Unit getUnitAtLocation(int CursorX, int CursorY) {
foreach (Unit Unit in Units)
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)
{
if (Unit.xPos == CursorX && Unit.yPos == CursorY) { return Unit; }
}
return null;
}
public void moveUnit(Unit unitcopy, int x, int y)
{
foreach (Unit Unit in Units)
foreach (Unit Unit in playerUnits)
{
if (Unit.internalID == unitcopy.internalID)
{
@ -334,7 +485,14 @@ 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) {
@ -356,7 +514,9 @@ namespace Johnmagotchi.GameContent.Objects
clone.serializedMapTiles = this.serializedMapTiles;
clone.deserializeMapTiles();
clone.serializedUnits = this.serializedUnits;
clone.serializedPlayerUnits = this.serializedPlayerUnits;
clone.serializedNpcUnits = this.serializedNpcUnits;
clone.serializedEnemyUnits = this.serializedEnemyUnits;
clone.DeserializeUnitData();
return clone;

View File

@ -1,6 +1,7 @@
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;
@ -144,9 +145,9 @@ namespace Johnmagotchi.GameContent.Objects.Maps
Unit targetUnit = currentMap.getUnitAtLocation(x, y);
if (targetUnit != null) {
if (
(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))
(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))
)
{
return 0;

View File

@ -1,5 +1,6 @@
using Johnmagotchi.Core.tools;
using Johnmagotchi.GameContent.Objects.Units;
using Johnmagotchi.GameContent.Units;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
@ -62,11 +63,11 @@ namespace Johnmagotchi.GameContent.Objects.UI
if (HighlightedUnit == null) { return; }
Texture2D texture = UnitDisplayTexture;
if (HighlightedUnit.stats.status.team == Units.Stats.UnitCurrentStatus.UnitTeam.ENEMY)
if (HighlightedUnit.stats.status.team == Units.BattleObjects.UnitCurrentStatus.UnitTeam.ENEMY)
{
texture = EnemyDisplayTexture;
}
if (HighlightedUnit.stats.status.team == Units.Stats.UnitCurrentStatus.UnitTeam.NPC)
if (HighlightedUnit.stats.status.team == Units.BattleObjects.UnitCurrentStatus.UnitTeam.NPC)
{
texture = NpcDisplayTexture;
}

View File

@ -5,7 +5,7 @@ using System.Text;
using System.Threading.Tasks;
using static Johnmagotchi.Data.BattleObjects.AttackDefines;
namespace Johnmagotchi.GameContent.Objects.BattleObjects
namespace Johnmagotchi.GameContent.Objects.Units.BattleObjects
{
public class AttackObj
{

View File

@ -1,12 +1,16 @@
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.BattleObjects
namespace Johnmagotchi.GameContent.Objects.Units.BattleObjects
{
public static class BattleObjectManager
{
@ -44,9 +48,9 @@ namespace Johnmagotchi.GameContent.Objects.BattleObjects
public static List<AttackObj> LoadAttacks()
{
List<AttackObj> AttackList = new List<AttackObj>();
Console.WriteLine("PATH: {0}", Directory.GetCurrentDirectory());
System.Console.WriteLine("PATH: {0}", Directory.GetCurrentDirectory());
var path = "..\\..\\..\\Data\\BattleObjects\\AttackDefinitions.csv";
Console.WriteLine("path: {0} ", path);
System.Console.WriteLine("path: {0} ", path);
// these let us resolve which column is which
int IDIndex = -1;
@ -97,17 +101,17 @@ namespace Johnmagotchi.GameContent.Objects.BattleObjects
{
AttackObj attack = new AttackObj();
attack.ID = int.Parse(values[IDIndex]);
attack.ID = Int32.Parse(values[IDIndex]);
attack.AttackName = values[AttackNameIndex];
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]);
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]);
AttackList.Add(attack);
}
@ -121,9 +125,9 @@ namespace Johnmagotchi.GameContent.Objects.BattleObjects
{
List<SkillObj> SkillList = new List<SkillObj>();
Console.WriteLine("PATH: {0}", Directory.GetCurrentDirectory());
System.Console.WriteLine("PATH: {0}", Directory.GetCurrentDirectory());
var path = "..\\..\\..\\Data\\BattleObjects\\SkillDefinitions.csv";
Console.WriteLine("path: {0} ", path);
System.Console.WriteLine("path: {0} ", path);
// ID,SkillName,SkillType,Value,Description
// these let us resolve which column is which
@ -165,10 +169,10 @@ namespace Johnmagotchi.GameContent.Objects.BattleObjects
{
SkillObj skill = new SkillObj();
skill.ID = int.Parse(values[IDIndex]);
skill.ID = Int32.Parse(values[IDIndex]);
skill.SkillName = values[SkillNameIndex];
skill.SkillType = SkillDefines.ParseSkillTypes(values[SkillTypeIndex]);
skill.Value = int.Parse(values[ValueIndex]);
skill.Value = Int32.Parse(values[ValueIndex]);
skill.Description = values[DescriptionIndex];
SkillList.Add(skill);
@ -183,9 +187,9 @@ namespace Johnmagotchi.GameContent.Objects.BattleObjects
List<SupportObj> SupportList = new List<SupportObj>();
Console.WriteLine("PATH: {0}", Directory.GetCurrentDirectory());
System.Console.WriteLine("PATH: {0}", Directory.GetCurrentDirectory());
var path = "..\\..\\..\\Data\\BattleObjects\\SupportDefinitions.csv";
Console.WriteLine("path: {0} ", path);
System.Console.WriteLine("path: {0} ", path);
//ID,SupportName,SupportTarget,SupportType,Value,Description
// these let us resolve which column is which
@ -230,11 +234,11 @@ namespace Johnmagotchi.GameContent.Objects.BattleObjects
{
SupportObj support = new SupportObj();
support.ID = int.Parse(values[IDIndex]);
support.ID = Int32.Parse(values[IDIndex]);
support.Name = values[SupportlNameIndex];
support.type = ParseSupportTypes(values[SupportTypeIndex]);
support.target = ParseSupportTargets(values[SupportTargetIndex]);
support.Value = int.Parse(values[ValueIndex]);
support.type = SupportDefines.ParseSupportTypes(values[SupportTypeIndex]);
support.target = SupportDefines.ParseSupportTargets(values[SupportTargetIndex]);
support.Value = Int32.Parse(values[ValueIndex]);
support.Description = values[DescriptionIndex];
SupportList.Add(support);

View File

@ -5,7 +5,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Johnmagotchi.GameContent.Objects.BattleObjects
namespace Johnmagotchi.GameContent.Objects.Units.BattleObjects
{
public class SkillObj
{

View File

@ -5,7 +5,7 @@ using System.Text;
using System.Threading.Tasks;
using static Johnmagotchi.Data.BattleObjects.SupportDefines;
namespace Johnmagotchi.GameContent.Objects.BattleObjects
namespace Johnmagotchi.GameContent.Objects.Units.BattleObjects
{
public class SupportObj
{

View File

@ -1,4 +1,5 @@
using Johnmagotchi.Core.tools;
using Johnmagotchi.GameContent.Units;
using System;
using System.Collections.Generic;
using System.Linq;
@ -7,7 +8,7 @@ using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
namespace Johnmagotchi.GameContent.Objects.Units.Stats
namespace Johnmagotchi.GameContent.Objects.Units.BattleObjects
{
public class UnitCurrentStatus
{
@ -34,10 +35,10 @@ namespace Johnmagotchi.GameContent.Objects.Units.Stats
this.CurrentShieldCount = CurrentShieldCount;
}
public void setFromSerialized(Unit temp, string data) {
public void setFromSerialized(UnitObject 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);
}

View File

@ -1,4 +1,4 @@
namespace Johnmagotchi.GameContent.Objects.Units.Stats
namespace Johnmagotchi.GameContent.Objects.Units.BattleObjects
{
public class UnitStatBlock{

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Johnmagotchi.GameContent.Objects.Units.Stats.Loadouts
namespace Johnmagotchi.GameContent.Objects.Units.Loadouts
{
public class LoadoutModule
{

View File

@ -1,10 +1,10 @@
using Johnmagotchi.Core.tools;
using Johnmagotchi.GameContent.Objects.BattleObjects;
using Johnmagotchi.GameContent.Objects.Units.Stats.Loadouts;
using Johnmagotchi.GameContent.Objects.Units.BattleObjects;
using Johnmagotchi.GameContent.Objects.Units.Loadouts;
using System.Collections.Generic;
using System.Linq;
namespace Johnmagotchi.GameContent.Objects.Units.Stats.Loadouts.PlayerClasses
namespace Johnmagotchi.GameContent.Objects.Units.Loadouts.PlayerClasses
{
public class PlayerClass
{
@ -245,7 +245,7 @@ namespace Johnmagotchi.GameContent.Objects.Units.Stats.Loadouts.PlayerClasses
}
if (attack != null)
ClassAttacks.Add(attack);
this.ClassAttacks.Add(attack);
}
}

View File

@ -1,15 +1,15 @@
using Johnmagotchi.Core.tools;
using Johnmagotchi.GameContent.Objects.BattleObjects;
using Johnmagotchi.GameContent.Objects.Units.Stats.Loadouts.PlayerClasses;
using Johnmagotchi.GameContent.Objects.Units.BattleObjects;
using Johnmagotchi.GameContent.Objects.Units.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.Stats.Loadouts.PlayerClasses.PlayerClass;
using static Johnmagotchi.GameContent.Objects.Units.Loadouts.PlayerClasses.PlayerClass;
namespace Johnmagotchi.GameContent.Objects.Units.Stats.Loadouts
namespace Johnmagotchi.GameContent.Objects.Units.Loadouts
{
public class UnitLoadout
{
@ -95,9 +95,9 @@ namespace Johnmagotchi.GameContent.Objects.Units.Stats.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());
}
}
}

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Johnmagotchi.GameContent.Objects.Units.Stats.Loadouts
namespace Johnmagotchi.GameContent.Objects.Units.Loadouts
{
internal class UnitLoadoutManager
{

View File

@ -0,0 +1,170 @@
using System;
using System.IO;
using System.Collections.Generic;
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;
namespace Johnmagotchi.GameContent.Units
{
public class UnitLoader
{
public static List<string> GetTest() {
// MAC OS also prly Linux - var path = Path.Combine(Directory.GetCurrentDirectory(), "GameContent/Objects/Units/UnitDefines.csv");
//System.Console.WriteLine("PATH: {0}", Directory.GetCurrentDirectory());
//var path = "..\\..\\..\\GameContent\\Objects\\Units\\UnitDefines.csv";
List<string> listA = new List<string>();
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>();
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.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.setMovementTypeFromFile(values[MovementTypeIndex]);
unitList.Add(unit);
}
}
}
return unitList;
}
}
}

View File

@ -0,0 +1,226 @@
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";
}
}
}

View File

@ -1,4 +1,6 @@
using Johnmagotchi.GameContent.Objects.Units.Stats.Loadouts;
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;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@ -9,9 +11,8 @@ using System.Text;
using System.Text.Json;
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;
using static Johnmagotchi.GameContent.Objects.Units.BattleObjects.UnitCurrentStatus;
using static Johnmagotchi.GameContent.Objects.Units.Loadouts.PlayerClasses.PlayerClass;
namespace Johnmagotchi.GameContent.Objects.Units.GameLogic
{
@ -30,8 +31,11 @@ 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;
@ -60,20 +64,8 @@ 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;
TibzLog.Debug("set from template- " + playerClassEnum );
}
public void SetStats(UnitStats newStats)
public void SetStats(UnitStats newStats)
{
stats = newStats;
hasStats = true;

View File

@ -1,10 +1,11 @@
using Johnmagotchi.GameContent.Objects.Units.Stats.Loadouts;
using Johnmagotchi.GameContent.Objects.Units.BattleObjects;
using Johnmagotchi.GameContent.Objects.Units.Loadouts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static Johnmagotchi.GameContent.Objects.Units.Stats.Loadouts.PlayerClasses.PlayerClass;
using static Johnmagotchi.GameContent.Objects.Units.Loadouts.PlayerClasses.PlayerClass;
namespace Johnmagotchi.GameContent.Objects.Units.Stats
{

View File

@ -1,6 +1,7 @@
using Johnmagotchi.GameContent.Objects.Units.GameLogic;
using Johnmagotchi.GameContent.Objects.Units.Stats.Loadouts;
using Johnmagotchi.GameContent.Objects.Units.Loadouts;
using Johnmagotchi.GameContent.Objects.Units.Stats;
using Johnmagotchi.GameContent.Units;
using System;
using System.Collections.Generic;
using System.Linq;
@ -22,7 +23,7 @@ namespace Johnmagotchi.GameContent.Objects.Units
this.SetStats(new UnitStats());
}
public Unit(Unit template) : base(template)
public Unit(Unit template) : base()
{
SetStats(template.GetStats());
}

View File

@ -1,98 +0,0 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Diagnostics;
using Johnmagotchi.Core.tools;
using System.Collections;
using System.Net.Http.Headers;
using static Johnmagotchi.GameContent.Objects.Units.Stats.UnitStatBlock;
using Johnmagotchi.GameContent.Objects.Units.Stats.Loadouts.PlayerClasses;
namespace Johnmagotchi.GameContent.Objects.Units
{
public class UnitLoader
{
public static List<string> GetTest() {
// MAC OS also prly Linux - var path = Path.Combine(Directory.GetCurrentDirectory(), "GameContent/Objects/Units/UnitDefines.csv");
//System.Console.WriteLine("PATH: {0}", Directory.GetCurrentDirectory());
//var path = "..\\..\\..\\GameContent\\Objects\\Units\\UnitDefines.csv";
List<string> listA = new List<string>();
return listA;
}
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);
// 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 = 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.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]);
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);
}
}
}
return unitList;
}
}
}

View File

@ -11,6 +11,7 @@ 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;

View File

@ -4,6 +4,7 @@ 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;
@ -251,7 +252,7 @@ namespace Johnmagotchi.GameContent.Screens.BattleMapScreens.BattleMapScreen
if (isConfirmed)
{
// BattleLogic.RunBattle(selectedToMoveUnit,attackedUnit, selectedAttack, defenderAttack);
BattleLogic.RunBattle(ref selectedToMoveUnit, ref attackedUnit);
BattleLogic.RunBattle(ref selectedToMoveUnit, ref attackedUnit, null, null);
screenManager.addScreen(new MapScreens.BattleMapScreen.BattleAnimationScreen());
}

View File

@ -1,5 +1,6 @@
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;
@ -7,6 +8,8 @@ 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
@ -31,6 +34,7 @@ namespace Johnmagotchi.Screen.BattleMapScreens
private EditorToolType CurrentTool;
private MapEditorInfoText InfoText;
public List<Unit> AvailableNewUnits;
public List<UnitLoadout> AvailableLoadouts;
private UnitFactionType UnitFaction;