More heroEnergy and monsterEnergy into BattleState
This commit is contained in:
parent
679fc526cc
commit
f1ef7d7d46
3 changed files with 20 additions and 21 deletions
|
|
@ -28,8 +28,6 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
private BattleMonster[] monsters;
|
private BattleMonster[] monsters;
|
||||||
|
|
||||||
private BattleState state;
|
private BattleState state;
|
||||||
private EnergyPool heroEnergy;
|
|
||||||
private EnergyPool monsterEnergy;
|
|
||||||
private InsightLevel insightLevel;
|
private InsightLevel insightLevel;
|
||||||
private HandPlayability<HeroCard> heroHandPlayability;
|
private HandPlayability<HeroCard> heroHandPlayability;
|
||||||
private HandPlayability<MonsterCard> monsterHandPlayability;
|
private HandPlayability<MonsterCard> monsterHandPlayability;
|
||||||
|
|
@ -51,12 +49,8 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
|
|
||||||
this.state = new BattleState();
|
this.state = new BattleState();
|
||||||
|
|
||||||
this.heroEnergy = new EnergyPool();
|
this.heroEnergyUI.Init(this.state.HeroEnergy);
|
||||||
this.heroEnergyUI.Init(this.heroEnergy);
|
this.monsterEnergyUI.Init(this.state.MonsterEnergy);
|
||||||
this.heroEnergy.OnEnergyChanged += this.heroEnergyUI.NotifyEnergyChanged;
|
|
||||||
this.monsterEnergy = new EnergyPool();
|
|
||||||
this.monsterEnergyUI.Init(this.monsterEnergy);
|
|
||||||
this.monsterEnergy.OnEnergyChanged += this.monsterEnergyUI.NotifyEnergyChanged;
|
|
||||||
|
|
||||||
this.insightLevel = new InsightLevel(STARTING_INSIGHT);
|
this.insightLevel = new InsightLevel(STARTING_INSIGHT);
|
||||||
|
|
||||||
|
|
@ -98,14 +92,14 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
this.playArea = new PlayArea();
|
this.playArea = new PlayArea();
|
||||||
|
|
||||||
this.heroHandPlayability = new HandPlayability<HeroCard>(
|
this.heroHandPlayability = new HandPlayability<HeroCard>(
|
||||||
this.state, this.heroEnergy, TeamChoice.Heroes, this.heroDeck);
|
this.state, this.state.HeroEnergy, TeamChoice.Heroes, this.heroDeck);
|
||||||
this.OnBattleStateChanged += this.heroHandPlayability.NotifyBattleStateChanged;
|
this.OnBattleStateChanged += this.heroHandPlayability.NotifyBattleStateChanged;
|
||||||
this.monsterHandPlayability = new HandPlayability<MonsterCard>(
|
this.monsterHandPlayability = new HandPlayability<MonsterCard>(
|
||||||
this.state, this.monsterEnergy, TeamChoice.Monsters, this.monsterDeck);
|
this.state, this.state.MonsterEnergy, TeamChoice.Monsters, this.monsterDeck);
|
||||||
this.OnBattleStateChanged += this.monsterHandPlayability.NotifyBattleStateChanged;
|
this.OnBattleStateChanged += this.monsterHandPlayability.NotifyBattleStateChanged;
|
||||||
|
|
||||||
this.monsterIntentions = new TurnIntentions<MonsterCard>(
|
this.monsterIntentions = new TurnIntentions<MonsterCard>(
|
||||||
this.monsterDeck, this.monsterEnergy, this.monsterHandPlayability);
|
this.monsterDeck, this.state.MonsterEnergy, this.monsterHandPlayability);
|
||||||
|
|
||||||
this.battlePlayerControls.Init(
|
this.battlePlayerControls.Init(
|
||||||
this.heroDeck, this.monsterDeck, this.playArea, this.insightLevel,
|
this.heroDeck, this.monsterDeck, this.playArea, this.insightLevel,
|
||||||
|
|
@ -157,8 +151,8 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
|
|
||||||
this.damageTriggers.RemoveAll(t => t.Expiration == TriggerExpiration.StartOfNextHeroTurn);
|
this.damageTriggers.RemoveAll(t => t.Expiration == TriggerExpiration.StartOfNextHeroTurn);
|
||||||
|
|
||||||
heroEnergy.Replenish();
|
this.state.HeroEnergy.Replenish();
|
||||||
monsterEnergy.Replenish();
|
this.state.MonsterEnergy.Replenish();
|
||||||
|
|
||||||
if (STABLE_HAND_STYLE) {
|
if (STABLE_HAND_STYLE) {
|
||||||
if (this.state.Clock.Now.RoundNumber > 1) {
|
if (this.state.Clock.Now.RoundNumber > 1) {
|
||||||
|
|
@ -287,7 +281,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
throw new System.InvalidOperationException("Cannot use card " + card.GetDisplayName());
|
throw new System.InvalidOperationException("Cannot use card " + card.GetDisplayName());
|
||||||
}
|
}
|
||||||
|
|
||||||
this.heroEnergy.PayForCard(card);
|
this.state.HeroEnergy.PayForCard(card);
|
||||||
this.heroDeck.RemoveCardFromHand(card);
|
this.heroDeck.RemoveCardFromHand(card);
|
||||||
this.participantActivity.NotifyParticipantUsedCard(card.Owner, card);
|
this.participantActivity.NotifyParticipantUsedCard(card.Owner, card);
|
||||||
yield return card.Use(this, this, battlePlayerControls);
|
yield return card.Use(this, this, battlePlayerControls);
|
||||||
|
|
@ -317,7 +311,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerator UseMonsterCard(MonsterCard card) {
|
public IEnumerator UseMonsterCard(MonsterCard card) {
|
||||||
this.monsterEnergy.PayForCard(card);
|
this.state.MonsterEnergy.PayForCard(card);
|
||||||
this.monsterDeck.RemoveCardFromHand(card);
|
this.monsterDeck.RemoveCardFromHand(card);
|
||||||
yield return card.Use(this, this);
|
yield return card.Use(this, this);
|
||||||
if (card.IsPermanent()) {
|
if (card.IsPermanent()) {
|
||||||
|
|
@ -384,9 +378,6 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
: this.monsters.Cast<BattleParticipant>().ToArray());
|
: this.monsters.Cast<BattleParticipant>().ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public EnergyPool HeroEnergy {get => this.heroEnergy;}
|
|
||||||
public EnergyPool MonsterEnergy {get => this.monsterEnergy;}
|
|
||||||
|
|
||||||
// IBattleEffectApplier
|
// IBattleEffectApplier
|
||||||
public void Apply(IBattleEffect effect) {
|
public void Apply(IBattleEffect effect) {
|
||||||
effect.Apply(this);
|
effect.Apply(this);
|
||||||
|
|
@ -399,15 +390,15 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
}
|
}
|
||||||
|
|
||||||
this.state.NotifyPlayedEmotion(effect.Team);
|
this.state.NotifyPlayedEmotion(effect.Team);
|
||||||
EnergyPool pool = (effect.Team == TeamChoice.Heroes ? this.heroEnergy : this.monsterEnergy);
|
EnergyPool pool = (effect.Team == TeamChoice.Heroes ? this.state.HeroEnergy : this.state.MonsterEnergy);
|
||||||
pool.MaxEnergy += effect.Amount;
|
pool.MaxEnergy += effect.Amount;
|
||||||
pool.Energy += effect.Amount;
|
pool.Energy += effect.Amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void IncreaseHeroMaxEnergy(IncreaseMaxEnergyEffect effect) {
|
public void IncreaseHeroMaxEnergy(IncreaseMaxEnergyEffect effect) {
|
||||||
this.heroEnergy.MaxEnergy += effect.Amount;
|
this.state.HeroEnergy.MaxEnergy += effect.Amount;
|
||||||
if (effect.Immediate) {
|
if (effect.Immediate) {
|
||||||
this.heroEnergy.Energy += effect.Amount;
|
this.state.HeroEnergy.Energy += effect.Amount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,14 @@ public class BattleState
|
||||||
private bool playedEmotion;
|
private bool playedEmotion;
|
||||||
private BattleClock clock;
|
private BattleClock clock;
|
||||||
private BuffManager buffManager;
|
private BuffManager buffManager;
|
||||||
|
private EnergyPool heroEnergy;
|
||||||
|
private EnergyPool monsterEnergy;
|
||||||
|
|
||||||
public BattleState() {
|
public BattleState() {
|
||||||
this.clock = new BattleClock();
|
this.clock = new BattleClock();
|
||||||
this.buffManager = new BuffManager(this.clock);
|
this.buffManager = new BuffManager(this.clock);
|
||||||
|
this.heroEnergy = new EnergyPool();
|
||||||
|
this.monsterEnergy = new EnergyPool();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsTeamsTurnToPlay(TeamChoice team) {
|
public bool IsTeamsTurnToPlay(TeamChoice team) {
|
||||||
|
|
@ -41,4 +45,7 @@ public class BattleState
|
||||||
|
|
||||||
public BattleClock Clock {get => this.clock;}
|
public BattleClock Clock {get => this.clock;}
|
||||||
public BuffManager BuffManager {get => this.buffManager;}
|
public BuffManager BuffManager {get => this.buffManager;}
|
||||||
|
|
||||||
|
public EnergyPool HeroEnergy {get => this.heroEnergy;}
|
||||||
|
public EnergyPool MonsterEnergy {get => this.monsterEnergy;}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ public class EnergyUI : MonoBehaviour
|
||||||
|
|
||||||
public void Init(EnergyPool pool) {
|
public void Init(EnergyPool pool) {
|
||||||
this.pool = pool;
|
this.pool = pool;
|
||||||
|
pool.OnEnergyChanged += this.NotifyEnergyChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue