Move BattleClock and BuffManager into BattleState
This commit is contained in:
parent
f212d73515
commit
658978682b
2 changed files with 14 additions and 15 deletions
|
|
@ -34,8 +34,6 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
private HandPlayability<HeroCard> heroHandPlayability;
|
private HandPlayability<HeroCard> heroHandPlayability;
|
||||||
private HandPlayability<MonsterCard> monsterHandPlayability;
|
private HandPlayability<MonsterCard> monsterHandPlayability;
|
||||||
private TurnIntentions<MonsterCard> monsterIntentions;
|
private TurnIntentions<MonsterCard> monsterIntentions;
|
||||||
private BattleClock clock;
|
|
||||||
private BuffManager buffManager;
|
|
||||||
private ParticipantActivity participantActivity;
|
private ParticipantActivity participantActivity;
|
||||||
|
|
||||||
private delegate void BattleStateChangedAction();
|
private delegate void BattleStateChangedAction();
|
||||||
|
|
@ -51,9 +49,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
this.heroCardDatabase = new HeroCardDatabase();
|
this.heroCardDatabase = new HeroCardDatabase();
|
||||||
this.monsterCardDatabase = new MonsterCardDatabase();
|
this.monsterCardDatabase = new MonsterCardDatabase();
|
||||||
|
|
||||||
this.clock = new BattleClock();
|
this.state = new BattleState();
|
||||||
this.buffManager = new BuffManager(this.clock);
|
|
||||||
this.state = new BattleState(this.buffManager);
|
|
||||||
|
|
||||||
this.heroEnergy = new EnergyPool();
|
this.heroEnergy = new EnergyPool();
|
||||||
this.heroEnergyUI.Init(this.heroEnergy);
|
this.heroEnergyUI.Init(this.heroEnergy);
|
||||||
|
|
@ -157,7 +153,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerator RunBattleRound() {
|
private IEnumerator RunBattleRound() {
|
||||||
this.clock.AdvanceRound();
|
this.state.Clock.AdvanceRound();
|
||||||
this.state.AdvanceToTeamTurn(TeamChoice.Heroes);
|
this.state.AdvanceToTeamTurn(TeamChoice.Heroes);
|
||||||
|
|
||||||
this.damageTriggers.RemoveAll(t => t.Expiration == TriggerExpiration.StartOfNextHeroTurn);
|
this.damageTriggers.RemoveAll(t => t.Expiration == TriggerExpiration.StartOfNextHeroTurn);
|
||||||
|
|
@ -180,13 +176,13 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
this.state.AdvanceToTeamTurn(TeamChoice.Monsters);
|
this.state.AdvanceToTeamTurn(TeamChoice.Monsters);
|
||||||
yield return RunMonsterTurn();
|
yield return RunMonsterTurn();
|
||||||
|
|
||||||
this.clock.AdvanceToStep(RoundStep.EndOfRound);
|
this.state.Clock.AdvanceToStep(RoundStep.EndOfRound);
|
||||||
this.participantActivity.NextRound();
|
this.participantActivity.NextRound();
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerator RunHeroTurn() {
|
private IEnumerator RunHeroTurn() {
|
||||||
// Start of hero turn
|
// Start of hero turn
|
||||||
this.clock.AdvanceToStep(RoundStep.StartOfHeroTurn);
|
this.state.Clock.AdvanceToStep(RoundStep.StartOfHeroTurn);
|
||||||
OnBattleStateChanged();
|
OnBattleStateChanged();
|
||||||
this.monsterIntentions.ResumeIntentions();
|
this.monsterIntentions.ResumeIntentions();
|
||||||
|
|
||||||
|
|
@ -221,14 +217,14 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
hero.TickStatuses();
|
hero.TickStatuses();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.clock.AdvanceToStep(RoundStep.EndOfHeroTurn);
|
this.state.Clock.AdvanceToStep(RoundStep.EndOfHeroTurn);
|
||||||
|
|
||||||
OnBattleStateChanged();
|
OnBattleStateChanged();
|
||||||
this.monsterIntentions.PauseIntentions();
|
this.monsterIntentions.PauseIntentions();
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerator RunMonsterTurn() {
|
private IEnumerator RunMonsterTurn() {
|
||||||
this.clock.AdvanceToStep(RoundStep.StartOfMonsterTurn);
|
this.state.Clock.AdvanceToStep(RoundStep.StartOfMonsterTurn);
|
||||||
OnBattleStateChanged();
|
OnBattleStateChanged();
|
||||||
yield return new WaitForSeconds(0.5f);
|
yield return new WaitForSeconds(0.5f);
|
||||||
|
|
||||||
|
|
@ -270,7 +266,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
monster.TickStatuses();
|
monster.TickStatuses();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.clock.AdvanceToStep(RoundStep.EndOfMonsterTurn);
|
this.state.Clock.AdvanceToStep(RoundStep.EndOfMonsterTurn);
|
||||||
OnBattleStateChanged();
|
OnBattleStateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -478,7 +474,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
|
|
||||||
int amount = effect.Amount;
|
int amount = effect.Amount;
|
||||||
if (effect.Source != null) {
|
if (effect.Source != null) {
|
||||||
amount += this.buffManager.GetTotalBuffAmountOfType(effect.Source, BuffType.Power);
|
amount += this.state.BuffManager.GetTotalBuffAmountOfType(effect.Source, BuffType.Power);
|
||||||
}
|
}
|
||||||
int damageDealt = effect.Target.DealDamage(amount);
|
int damageDealt = effect.Target.DealDamage(amount);
|
||||||
foreach (DamageTrigger dt in this.damageTriggers) {
|
foreach (DamageTrigger dt in this.damageTriggers) {
|
||||||
|
|
@ -536,7 +532,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BuffParticipant(BuffParticipantEffect effect) {
|
public void BuffParticipant(BuffParticipantEffect effect) {
|
||||||
this.buffManager.AddBuff(effect, this.clock.Now);
|
this.state.BuffManager.AddBuff(effect, this.state.Clock.Now);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Rotate(RotateEffect effect) {
|
public void Rotate(RotateEffect effect) {
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,12 @@ public class BattleState
|
||||||
private TeamChoice mTeamsTurn = TeamChoice.Monsters;
|
private TeamChoice mTeamsTurn = TeamChoice.Monsters;
|
||||||
private bool mPlayedEmotion;
|
private bool mPlayedEmotion;
|
||||||
private int mRound = 0;
|
private int mRound = 0;
|
||||||
|
private BattleClock clock;
|
||||||
private BuffManager buffManager;
|
private BuffManager buffManager;
|
||||||
|
|
||||||
public BattleState(BuffManager buffManager) {
|
public BattleState() {
|
||||||
this.buffManager = buffManager;
|
this.clock = new BattleClock();
|
||||||
|
this.buffManager = new BuffManager(this.clock);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsTeamsTurn(TeamChoice team) {
|
public bool IsTeamsTurn(TeamChoice team) {
|
||||||
|
|
@ -44,5 +46,6 @@ public class BattleState
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BattleClock Clock {get => this.clock;}
|
||||||
public BuffManager BuffManager {get => this.buffManager;}
|
public BuffManager BuffManager {get => this.buffManager;}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue