more changes for unit refactor
This commit is contained in:
parent
b745fb9443
commit
e6cb367885
|
|
@ -1,4 +1,5 @@
|
|||
using Johnmagotchi.GameContent.Objects.Units.BattleObjects;
|
||||
using Johnmagotchi.GameContent.Objects.Units;
|
||||
using Johnmagotchi.GameContent.Objects.Units.BattleObjects;
|
||||
using Johnmagotchi.GameContent.Units;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
|
@ -15,7 +16,7 @@ namespace Johnmagotchi.GameContent.Logic
|
|||
{
|
||||
private static double CriticalMultiplier = 1.5;
|
||||
public static Random Random = new Random();
|
||||
public static BattleResults RunBattle(ref UnitObject Attacker, ref UnitObject Defender, AttackObj attack, AttackObj counterAttack) {
|
||||
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;
|
||||
|
|
@ -51,7 +52,7 @@ namespace Johnmagotchi.GameContent.Logic
|
|||
|
||||
// this is each step
|
||||
public static void HandleAttackPhase(
|
||||
ref UnitObject Attacker, ref UnitObject Defender, AttackObj attack,
|
||||
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
|
||||
|
|
@ -59,7 +60,7 @@ namespace Johnmagotchi.GameContent.Logic
|
|||
for (int i = 0; i < hitcount; i++) {
|
||||
|
||||
int hitRoll = BattleLogic.Random.Next(100) + 1; // random int 1 - 100
|
||||
int hitThreshold = attack.BaseAccuracy + Attacker.stats.Speed - Defender.stats.Speed;
|
||||
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)
|
||||
|
|
@ -77,19 +78,19 @@ namespace Johnmagotchi.GameContent.Logic
|
|||
else if (hitRoll >= critThreshold) //Handle Crits
|
||||
{
|
||||
|
||||
if (Defender.currentStatus.CurrentShieldCount > 1) Defender.currentStatus.CurrentShieldCount--; // as is, crits ignore shields but should still tick a shield down
|
||||
if (Defender.currentStatus.CurrentShieldCount < 0) Defender.currentStatus.CurrentShieldCount = 0;
|
||||
if (Defender.stats.status.CurrentShieldCount > 1) Defender.stats.status.CurrentShieldCount--; // as is, crits ignore shields but should still tick a shield down
|
||||
if (Defender.stats.status.CurrentShieldCount < 0) Defender.stats.status.CurrentShieldCount = 0;
|
||||
int BaseDamage = CalculateDamage(Attacker,Defender,attack);
|
||||
int TotalCritDamage = (int) Math.Ceiling (BaseDamage * CriticalMultiplier);
|
||||
|
||||
//apply Damage to defending unit, then add to result report
|
||||
Defender.currentStatus.CurrentHealth -= TotalCritDamage;
|
||||
Defender.stats.status.CurrentHealth -= TotalCritDamage;
|
||||
results.addResult(BattleResults.resultType.CRITICAL, TotalCritDamage, isCounter);
|
||||
|
||||
}
|
||||
else if (Defender.currentStatus.CurrentShieldCount > 1) // Shielded
|
||||
else if (Defender.stats.status.CurrentShieldCount > 1) // Shielded
|
||||
{
|
||||
Defender.currentStatus.CurrentShieldCount--;
|
||||
Defender.stats.status.CurrentShieldCount--;
|
||||
results.addResult(BattleResults.resultType.SHIELDED,1, isCounter); // 1 siginfies 1 shield lost
|
||||
}
|
||||
else // normal attack
|
||||
|
|
@ -97,21 +98,21 @@ namespace Johnmagotchi.GameContent.Logic
|
|||
int BaseDamage = CalculateDamage(Attacker, Defender, attack);
|
||||
|
||||
//Apply damage + report to animation handler
|
||||
Defender.currentStatus.CurrentHealth -= BaseDamage;
|
||||
Defender.stats.status.CurrentHealth -= BaseDamage;
|
||||
results.addResult(BattleResults.resultType.ATTACK, BaseDamage, isCounter);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
private static int CalculateDamage( UnitObject Attacker, UnitObject Defender, AttackObj attack)
|
||||
private static int CalculateDamage( Unit Attacker, Unit Defender, AttackObj attack)
|
||||
{
|
||||
int damage = 0;
|
||||
|
||||
damage += attack.BaseDamage;
|
||||
damage += Attacker.stats.Attack;
|
||||
damage += Attacker.stats.baseStats.Attack;
|
||||
|
||||
damage -= Defender.stats.Defense;
|
||||
damage -= Defender.stats.baseStats.Defense;
|
||||
|
||||
|
||||
if (damage < 0) damage = 0;
|
||||
|
|
|
|||
|
|
@ -475,7 +475,7 @@ namespace Johnmagotchi.GameContent.Objects
|
|||
return null;
|
||||
}
|
||||
|
||||
public void moveUnit(UnitObject unitcopy, int x, int y)
|
||||
public void moveUnit(Unit unitcopy, int x, int y)
|
||||
{
|
||||
foreach (Unit Unit in playerUnits)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ namespace Johnmagotchi.GameContent.Objects.Maps
|
|||
public int movesRemaining;
|
||||
public int x;
|
||||
public int y;
|
||||
public MapMovementNode(UnitObject selectedUnit, BattleMap currentMap, int moveRemaining, int x, int y) {
|
||||
public MapMovementNode(Unit selectedUnit, BattleMap currentMap, int moveRemaining, int x, int y) {
|
||||
|
||||
this.selectedUnit = selectedUnit;
|
||||
this.currentMap = currentMap;
|
||||
|
|
@ -145,8 +145,9 @@ namespace Johnmagotchi.GameContent.Objects.Maps
|
|||
Unit targetUnit = currentMap.getUnitAtLocation(x, y);
|
||||
if (targetUnit != null) {
|
||||
if (
|
||||
(selectedUnit.team == Unit.UnitTeam.PLAYER && targetUnit.stats.status.team == Units.BattleObjects.UnitCurrentStatus.UnitTeam.ENEMY) ||
|
||||
(selectedUnit.team == Unit.UnitTeam.ENEMY && (targetUnit.team == UnitObject.UnitTeam.PLAYER || targetUnit.team == UnitObject.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;
|
||||
|
|
@ -158,7 +159,7 @@ namespace Johnmagotchi.GameContent.Objects.Maps
|
|||
// MovementCostTable.getMoveCost(selectedUnit.stats.movementType, destTile.Type);
|
||||
|
||||
// note that the return value MUST be <= moves remaining, or else we risk infinite recursion
|
||||
return movesRemaining - MovementCostTable.getMoveCost(selectedUnit.stats.movementType, destTile.Type);
|
||||
return movesRemaining - MovementCostTable.getMoveCost(selectedUnit.stats.baseStats.movementType, destTile.Type);
|
||||
}
|
||||
|
||||
private List<Tuple<int, int>> RemoveDuplicates( List<Tuple<int, int>> oldList)
|
||||
|
|
@ -190,9 +191,10 @@ namespace Johnmagotchi.GameContent.Objects.Maps
|
|||
|
||||
private void addAttackRangesToList( ref List<Tuple<int, int>> list) {
|
||||
|
||||
for (int i = selectedUnit.DirectAttackRangeMin; i <= selectedUnit.DirectAttackRangeMax; i++) {
|
||||
getCircleRange(ref list, i);
|
||||
}
|
||||
//TODO -- add attack ranges based on available attacks
|
||||
//for (int i = selectedUnit.stats.baseStatsDirectAttackRangeMin; i <= selectedUnit.DirectAttackRangeMax; i++) {
|
||||
// getCircleRange(ref list, i);
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using Johnmagotchi.Core.tools;
|
||||
using Johnmagotchi.GameContent.Objects.Units;
|
||||
using Johnmagotchi.GameContent.Units;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
|
@ -21,7 +22,7 @@ namespace Johnmagotchi.GameContent.Objects.UI
|
|||
Texture2D NpcDisplayTexture;
|
||||
protected SpriteFont kemco;
|
||||
protected SpriteFont pixsplit;
|
||||
UnitObject HighlightedUnit;
|
||||
Unit HighlightedUnit;
|
||||
|
||||
|
||||
Boolean showDisplay;
|
||||
|
|
@ -44,7 +45,7 @@ namespace Johnmagotchi.GameContent.Objects.UI
|
|||
|
||||
}
|
||||
|
||||
public void Update(UnitObject unit) {
|
||||
public void Update(Unit unit) {
|
||||
if (unit == null) {
|
||||
showDisplay = false;
|
||||
return;
|
||||
|
|
@ -62,7 +63,7 @@ namespace Johnmagotchi.GameContent.Objects.UI
|
|||
if (HighlightedUnit == null) { return; }
|
||||
|
||||
Texture2D texture = UnitDisplayTexture;
|
||||
if (HighlightedUnit.team == UnitObject.UnitTeam.ENEMY)
|
||||
if (HighlightedUnit.stats.status.team == Unit.UnitTeam.ENEMY)
|
||||
{
|
||||
texture = EnemyDisplayTexture;
|
||||
}
|
||||
|
|
@ -95,7 +96,7 @@ namespace Johnmagotchi.GameContent.Objects.UI
|
|||
DrawText(posX, posY, HighlightedUnit.playerClassEnum.ToString());
|
||||
posX += (int)Math.Round(.05 * DISPLAY_WIDTH);
|
||||
posY += (15 * ScreenManager.BASE_ZOOM_LEVEL);
|
||||
string DisplayString = HighlightedUnit.currentStatus.CurrentHealth + " HP - " + HighlightedUnit.stats.MaxHealth + " MAX";
|
||||
string DisplayString = HighlightedUnit.stats.status.CurrentHealth + " HP - " + HighlightedUnit.stats.baseStats.MaxHealth + " MAX";
|
||||
DrawText(posX, posY, DisplayString);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ using Johnmagotchi.Core.tools;
|
|||
using Johnmagotchi.GameContent.Logic;
|
||||
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;
|
||||
|
|
@ -20,8 +21,8 @@ namespace Johnmagotchi.GameContent.Screens.BattleMapScreens.BattleMapScreen
|
|||
END_ACTION,
|
||||
}
|
||||
|
||||
UnitObject selectedToMoveUnit;
|
||||
UnitObject attackedUnit;
|
||||
Unit selectedToMoveUnit;
|
||||
Unit attackedUnit;
|
||||
private Tuple<int, int> originalLocation;
|
||||
private List<Tuple<int, int>> validMoves;
|
||||
private List<Tuple<int, int>> validAttacks;
|
||||
|
|
@ -59,11 +60,11 @@ namespace Johnmagotchi.GameContent.Screens.BattleMapScreens.BattleMapScreen
|
|||
TibzLog.Debug("Select Pressed");
|
||||
|
||||
|
||||
UnitObject newSelectedUnit = CurrentMap.getUnitAtLocation(cursorIndexX, cursorIndexY);
|
||||
TibzLog.Debug(newSelectedUnit.UnitLoadout.AvailableAttacks);
|
||||
if (newSelectedUnit != null && newSelectedUnit.isTurnOver == false && selectedToMoveUnit == null)
|
||||
Unit newSelectedUnit = CurrentMap.getUnitAtLocation(cursorIndexX, cursorIndexY);
|
||||
// TibzLog.Debug( newSelectedUnit.stats.loadout.AvailableAttacks);
|
||||
if (newSelectedUnit != null && newSelectedUnit.stats.status.isTurnOver == false && selectedToMoveUnit == null)
|
||||
{
|
||||
selectedToMoveUnit = newSelectedUnit;
|
||||
// selectedToMoveUnit
|
||||
this.originalLocation = new Tuple<int, int>(cursorIndexX, cursorIndexY);
|
||||
|
||||
ShowAllMoveHighlights();
|
||||
|
|
@ -93,7 +94,7 @@ namespace Johnmagotchi.GameContent.Screens.BattleMapScreens.BattleMapScreen
|
|||
ShowDirectAttackHighlights();
|
||||
// This menu directly calls:
|
||||
//AfterMoveWait(), AfterMoveAttack(), AfterMoveWait()
|
||||
TibzLog.Debug(selectedToMoveUnit.UnitLoadout.AvailableAttacks);
|
||||
TibzLog.Debug(selectedToMoveUnit.stats.loadout.AvailableAttacks);
|
||||
screenManager.addScreen(
|
||||
new AfterMovementMenu(
|
||||
this,
|
||||
|
|
@ -166,29 +167,29 @@ namespace Johnmagotchi.GameContent.Screens.BattleMapScreens.BattleMapScreen
|
|||
// throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public List<Tuple<int, int>> GetValidMoveCoordinates(UnitObject unit, Tuple<int, int> coords)
|
||||
public List<Tuple<int, int>> GetValidMoveCoordinates(Unit unit, Tuple<int, int> coords)
|
||||
{
|
||||
List<Tuple<int, int>> validTiles = new List<Tuple<int, int>>();
|
||||
int x = coords.Item1;
|
||||
int y = coords.Item2;
|
||||
|
||||
int range = unit.stats.Movement;
|
||||
int range = unit.stats.baseStats.Movement;
|
||||
|
||||
// tree traversal time
|
||||
TibzLog.Debug(" - BM screen - ");
|
||||
TibzLog.Debug(unit.stats.movementType);
|
||||
TibzLog.Debug(unit.stats.baseStats.movementType);
|
||||
MapMovementNode rootNode = new MapMovementNode(unit, CurrentMap, range, x, y);
|
||||
rootNode.GetMoveLocations(MapMovementNode.ParentNodeLocation.ROOT, ref validTiles);
|
||||
|
||||
return validTiles;
|
||||
}
|
||||
|
||||
public List<Tuple<int, int>> GetValidAttackHighlights(UnitObject unit, Tuple<int, int> coords)
|
||||
public List<Tuple<int, int>> GetValidAttackHighlights(Unit unit, Tuple<int, int> coords)
|
||||
{
|
||||
List<Tuple<int, int>> validTiles = new List<Tuple<int, int>>();
|
||||
int x = coords.Item1;
|
||||
int y = coords.Item2;
|
||||
int range = unit.stats.Movement;
|
||||
int range = unit.stats.baseStats.Movement;
|
||||
MapMovementNode rootNode = new MapMovementNode(unit, CurrentMap, range, x, y);
|
||||
rootNode.getDirectAttackLocations(MapMovementNode.ParentNodeLocation.ROOT, ref validTiles);
|
||||
|
||||
|
|
@ -229,7 +230,7 @@ namespace Johnmagotchi.GameContent.Screens.BattleMapScreens.BattleMapScreen
|
|||
private void finishMovement()
|
||||
{
|
||||
|
||||
this.selectedToMoveUnit.isTurnOver = true;
|
||||
this.selectedToMoveUnit.stats.status.isTurnOver = true;
|
||||
this.selectedToMoveUnit = null;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user