|
|
|
|
@ -61,7 +61,7 @@ public partial class FightHappening : Node
|
|
|
|
|
private static FightWorld.FightHappeningData HappeningData =>
|
|
|
|
|
FightWorld.Instance.fightHappeningData ?? throw new NoFightHappeningException();
|
|
|
|
|
|
|
|
|
|
private static FightWorld.Fighter CurrentFighter => HappeningData.fighterStack.Current;
|
|
|
|
|
private static FightWorld.Fighter CurrentFighter => HappeningData.fighterTurn.Current;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
@ -88,7 +88,7 @@ public partial class FightHappening : Node
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override void _Ready()
|
|
|
|
|
{
|
|
|
|
|
SetupInstance();
|
|
|
|
|
@ -110,7 +110,7 @@ public partial class FightHappening : Node
|
|
|
|
|
action.Reset();
|
|
|
|
|
ChangeState(FightState.ActionCheckDetails);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void DetailFilled()
|
|
|
|
|
{
|
|
|
|
|
RequireState(FightState.InputActionDetail);
|
|
|
|
|
@ -204,7 +204,7 @@ public partial class FightHappening : Node
|
|
|
|
|
{
|
|
|
|
|
ChangeState(FightState.FightersEnter);
|
|
|
|
|
}
|
|
|
|
|
else if (CurrentFighter.isEnemy)
|
|
|
|
|
else if (CurrentFighter.IsInFormation(HappeningData.enemyFighterFormation))
|
|
|
|
|
{
|
|
|
|
|
ChangeState(FightState.EnemyActionSelect);
|
|
|
|
|
}
|
|
|
|
|
@ -219,7 +219,7 @@ public partial class FightHappening : Node
|
|
|
|
|
break;
|
|
|
|
|
case FightState.ActionCheckDetails:
|
|
|
|
|
RequireNotNull(HappeningData.actionStaging);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ActionAbort())
|
|
|
|
|
ChangeState(FightState.InputActionSelect);
|
|
|
|
|
else if (ActionNeededDetail())
|
|
|
|
|
@ -249,10 +249,15 @@ public partial class FightHappening : Node
|
|
|
|
|
_ = AdvanceToStateWhenDone(FightState.StateCheck, actionTime);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case FightState.EnemyWin:
|
|
|
|
|
// TODO: remove and find proper solution
|
|
|
|
|
ReviveVesna();
|
|
|
|
|
break;
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Game Logic
|
|
|
|
|
@ -262,19 +267,23 @@ public partial class FightHappening : Node
|
|
|
|
|
// ally
|
|
|
|
|
var enteringAllyFighters = new List<FightWorld.Fighter>();
|
|
|
|
|
var allyFighters = FightWorld.Instance.allyFighters;
|
|
|
|
|
if (!allyFighters.vesnaFighter.entered)
|
|
|
|
|
if (!allyFighters.vesnaFighter.IsInFormation(HappeningData.allyFighterFormation))
|
|
|
|
|
{
|
|
|
|
|
enteringAllyFighters.Add(allyFighters.vesnaFighter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// enemy
|
|
|
|
|
const int totalEnemySpace = 3;
|
|
|
|
|
var enemySpaceLeft = totalEnemySpace - HappeningData.enemyGroup.GetEnteredAmount();
|
|
|
|
|
var enemySpaceLeft = HappeningData.enemyFighterFormation.GetEmptySlotCount();
|
|
|
|
|
|
|
|
|
|
return new FightersEnterStaging
|
|
|
|
|
{
|
|
|
|
|
enteringAllyFighters = enteringAllyFighters,
|
|
|
|
|
enteringEnemyFighters = HappeningData.enemyGroup.GetUptoUnenteredFighters(enemySpaceLeft).ToList()
|
|
|
|
|
enteringEnemyFighters = HappeningData.enemyGroup.fighters
|
|
|
|
|
.WhereIsAlive()
|
|
|
|
|
.WhereIsNotInFormation(HappeningData.enemyFighterFormation)
|
|
|
|
|
.Take(enemySpaceLeft)
|
|
|
|
|
.ToList()
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -283,21 +292,25 @@ public partial class FightHappening : Node
|
|
|
|
|
Debug.Assert(HappeningData.fightersEnterStaging != null);
|
|
|
|
|
foreach (var fighter in HappeningData.fightersEnterStaging.enteringAllyFighters)
|
|
|
|
|
{
|
|
|
|
|
fighter.entered = true;
|
|
|
|
|
HappeningData.fighterStack.AddAsLast(fighter);
|
|
|
|
|
var emptySlotIndex = HappeningData.allyFighterFormation.GetFirstEmptySlot();
|
|
|
|
|
if (emptySlotIndex < 0) throw new Exception("No empty slot for ally fighter to enter");
|
|
|
|
|
HappeningData.allyFighterFormation.SetFighterAtPosition(emptySlotIndex, fighter);
|
|
|
|
|
HappeningData.fighterTurn.AddAsLast(fighter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var fighter in HappeningData.fightersEnterStaging.enteringEnemyFighters)
|
|
|
|
|
{
|
|
|
|
|
fighter.entered = true;
|
|
|
|
|
HappeningData.fighterStack.AddAsLast(fighter);
|
|
|
|
|
var emptySlotIndex = HappeningData.enemyFighterFormation.GetFirstEmptySlot();
|
|
|
|
|
if (emptySlotIndex < 0) throw new Exception("No empty slot for enemy fighter to enter");
|
|
|
|
|
HappeningData.enemyFighterFormation.SetFighterAtPosition(emptySlotIndex, fighter);
|
|
|
|
|
HappeningData.fighterTurn.AddAsLast(fighter);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ExecuteNextFighter()
|
|
|
|
|
{
|
|
|
|
|
HappeningData.fighterStack.Next();
|
|
|
|
|
CurrentFighter.actionPointsLeft = CurrentFighter.maxActionPoints;
|
|
|
|
|
HappeningData.fighterTurn.Next();
|
|
|
|
|
CurrentFighter.actionPointsLeft = FightWorld.Fighter.MaxActionPoints;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ExecuteAction()
|
|
|
|
|
@ -325,6 +338,14 @@ public partial class FightHappening : Node
|
|
|
|
|
return HappeningData.actionStaging.NextDetail();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO: remove
|
|
|
|
|
private void ReviveVesna()
|
|
|
|
|
{
|
|
|
|
|
var vesnaFighter = FightWorld.Instance.allyFighters.vesnaFighter;
|
|
|
|
|
vesnaFighter.health = vesnaFighter.maxHealth;
|
|
|
|
|
GD.Print("Vesna has been revived. This is for the current prototype only");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion // Game Logic
|
|
|
|
|
|
|
|
|
|
#region Utility
|
|
|
|
|
@ -337,7 +358,7 @@ public partial class FightHappening : Node
|
|
|
|
|
throw new Exception(
|
|
|
|
|
$"Can not call this Method while in state {HappeningData.fightState}. Only available in {string.Join(" ,", states)}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void RequireNotNull(Object? o)
|
|
|
|
|
{
|
|
|
|
|
if (o != null)
|
|
|
|
|
@ -362,6 +383,4 @@ public partial class FightHappening : Node
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|