diff --git a/Assets/Battle/BattleController.cs b/Assets/Battle/BattleController.cs index 22d4405..2083a6f 100644 --- a/Assets/Battle/BattleController.cs +++ b/Assets/Battle/BattleController.cs @@ -34,8 +34,6 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe private HandPlayability heroHandPlayability; private HandPlayability monsterHandPlayability; private TurnIntentions monsterIntentions; - private BattleClock clock; - private BuffManager buffManager; private ParticipantActivity participantActivity; private delegate void BattleStateChangedAction(); @@ -51,9 +49,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe this.heroCardDatabase = new HeroCardDatabase(); this.monsterCardDatabase = new MonsterCardDatabase(); - this.clock = new BattleClock(); - this.buffManager = new BuffManager(this.clock); - this.state = new BattleState(this.buffManager); + this.state = new BattleState(); this.heroEnergy = new EnergyPool(); this.heroEnergyUI.Init(this.heroEnergy); @@ -157,7 +153,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe } private IEnumerator RunBattleRound() { - this.clock.AdvanceRound(); + this.state.Clock.AdvanceRound(); this.state.AdvanceToTeamTurn(TeamChoice.Heroes); this.damageTriggers.RemoveAll(t => t.Expiration == TriggerExpiration.StartOfNextHeroTurn); @@ -180,13 +176,13 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe this.state.AdvanceToTeamTurn(TeamChoice.Monsters); yield return RunMonsterTurn(); - this.clock.AdvanceToStep(RoundStep.EndOfRound); + this.state.Clock.AdvanceToStep(RoundStep.EndOfRound); this.participantActivity.NextRound(); } private IEnumerator RunHeroTurn() { // Start of hero turn - this.clock.AdvanceToStep(RoundStep.StartOfHeroTurn); + this.state.Clock.AdvanceToStep(RoundStep.StartOfHeroTurn); OnBattleStateChanged(); this.monsterIntentions.ResumeIntentions(); @@ -221,14 +217,14 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe hero.TickStatuses(); } - this.clock.AdvanceToStep(RoundStep.EndOfHeroTurn); + this.state.Clock.AdvanceToStep(RoundStep.EndOfHeroTurn); OnBattleStateChanged(); this.monsterIntentions.PauseIntentions(); } private IEnumerator RunMonsterTurn() { - this.clock.AdvanceToStep(RoundStep.StartOfMonsterTurn); + this.state.Clock.AdvanceToStep(RoundStep.StartOfMonsterTurn); OnBattleStateChanged(); yield return new WaitForSeconds(0.5f); @@ -270,7 +266,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe monster.TickStatuses(); } - this.clock.AdvanceToStep(RoundStep.EndOfMonsterTurn); + this.state.Clock.AdvanceToStep(RoundStep.EndOfMonsterTurn); OnBattleStateChanged(); } @@ -478,7 +474,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe int amount = effect.Amount; 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); foreach (DamageTrigger dt in this.damageTriggers) { @@ -536,7 +532,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe } 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) { diff --git a/Assets/Battle/BattleState.cs b/Assets/Battle/BattleState.cs index 3c62ee0..c3fe506 100644 --- a/Assets/Battle/BattleState.cs +++ b/Assets/Battle/BattleState.cs @@ -8,10 +8,12 @@ public class BattleState private TeamChoice mTeamsTurn = TeamChoice.Monsters; private bool mPlayedEmotion; private int mRound = 0; + private BattleClock clock; private BuffManager buffManager; - public BattleState(BuffManager buffManager) { - this.buffManager = buffManager; + public BattleState() { + this.clock = new BattleClock(); + this.buffManager = new BuffManager(this.clock); } public bool IsTeamsTurn(TeamChoice team) { @@ -44,5 +46,6 @@ public class BattleState } } + public BattleClock Clock {get => this.clock;} public BuffManager BuffManager {get => this.buffManager;} }