Move InsightLevel into BattleState

This commit is contained in:
henriquenakashima 2020-10-13 21:32:42 -04:00
parent cb88ae78b6
commit c2fc8b0904
3 changed files with 10 additions and 8 deletions

View file

@ -7,7 +7,6 @@ using UnityEngine.SceneManagement;
public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffectResolver, MonsterViewpoint public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffectResolver, MonsterViewpoint
{ {
private bool STABLE_HAND_STYLE = true; private bool STABLE_HAND_STYLE = true;
private int STARTING_INSIGHT = 3;
// Inspector public // Inspector public
public GameObject uiCanvas; public GameObject uiCanvas;
@ -25,7 +24,6 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
private BattleMonster[] monsters; private BattleMonster[] monsters;
private BattleState state; private BattleState state;
private InsightLevel insightLevel;
private HandPlayability<HeroCard> heroHandPlayability; private HandPlayability<HeroCard> heroHandPlayability;
private HandPlayability<MonsterCard> monsterHandPlayability; private HandPlayability<MonsterCard> monsterHandPlayability;
private TurnIntentions<MonsterCard> monsterIntentions; private TurnIntentions<MonsterCard> monsterIntentions;
@ -49,8 +47,6 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
this.heroEnergyUI.Init(this.state.HeroEnergy); this.heroEnergyUI.Init(this.state.HeroEnergy);
this.monsterEnergyUI.Init(this.state.MonsterEnergy); this.monsterEnergyUI.Init(this.state.MonsterEnergy);
this.insightLevel = new InsightLevel(STARTING_INSIGHT);
this.heroes = new BattleHero[parameters.HeroIds.Length]; this.heroes = new BattleHero[parameters.HeroIds.Length];
for (int i = 0; i < this.heroes.Length; i++) { for (int i = 0; i < this.heroes.Length; i++) {
HeroId id = parameters.HeroIds[i]; HeroId id = parameters.HeroIds[i];
@ -98,10 +94,9 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
this.state.MonsterDeck, this.state.MonsterEnergy, this.monsterHandPlayability); this.state.MonsterDeck, this.state.MonsterEnergy, this.monsterHandPlayability);
this.battlePlayerControls.Init( this.battlePlayerControls.Init(
this.state.HeroDeck, this.state.MonsterDeck, this.state.PlayArea, this.insightLevel, this.state.HeroDeck, this.state.MonsterDeck, this.state.PlayArea, this.state.InsightLevel,
this.heroHandPlayability, this.monsterHandPlayability, this.monsterIntentions, this.heroHandPlayability, this.monsterHandPlayability, this.monsterIntentions,
this.uiCanvas.transform.localScale.x); this.uiCanvas.transform.localScale.x);
this.insightLevel.OnChanged += this.battlePlayerControls.NotifyInsightLevelChanged;
} }
// Start is called before the first frame update // Start is called before the first frame update
@ -114,7 +109,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
BattleResult.FinishBattle(new BattleResult(true)); BattleResult.FinishBattle(new BattleResult(true));
}; };
cheat.OnInsightCode += delegate { cheat.OnInsightCode += delegate {
this.insightLevel.Modify(+5); this.state.InsightLevel.Modify(+5);
}; };
cheat.OnOneHPCode += delegate { cheat.OnOneHPCode += delegate {
foreach (BattleMonster m in this.monsters) { foreach (BattleMonster m in this.monsters) {
@ -398,7 +393,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
} }
public void ModifyInsight(ModifyInsightEffect effect) { public void ModifyInsight(ModifyInsightEffect effect) {
this.insightLevel.Modify(effect.Amount); this.state.InsightLevel.Modify(effect.Amount);
} }
public void DrawCards(DrawCardsEffect effect) { public void DrawCards(DrawCardsEffect effect) {

View file

@ -45,6 +45,7 @@ public class BattlePlayerControls : MonoBehaviour
this.monsterHandControls.OnCardClicked += OnMonsterCardClicked; this.monsterHandControls.OnCardClicked += OnMonsterCardClicked;
this.cardsInPlayUIs = new Dictionary<BaseCard, GameObject>(); this.cardsInPlayUIs = new Dictionary<BaseCard, GameObject>();
insightLevel.OnChanged += this.NotifyInsightLevelChanged;
NotifyInsightLevelChanged(); NotifyInsightLevelChanged();
} }

View file

@ -13,6 +13,9 @@ public class BattleState
private BattleDeck<HeroCard> heroDeck; private BattleDeck<HeroCard> heroDeck;
private BattleDeck<MonsterCard> monsterDeck; private BattleDeck<MonsterCard> monsterDeck;
private PlayArea playArea; private PlayArea playArea;
private InsightLevel insightLevel;
private int STARTING_INSIGHT = 3;
public BattleState() { public BattleState() {
this.clock = new BattleClock(); this.clock = new BattleClock();
@ -20,6 +23,8 @@ public class BattleState
this.heroEnergy = new EnergyPool(); this.heroEnergy = new EnergyPool();
this.monsterEnergy = new EnergyPool(); this.monsterEnergy = new EnergyPool();
this.playArea = new PlayArea(); this.playArea = new PlayArea();
this.insightLevel = new InsightLevel(STARTING_INSIGHT);
} }
public void SetDecks(BattleDeck<HeroCard> heroDeck, BattleDeck<MonsterCard> monsterDeck) { public void SetDecks(BattleDeck<HeroCard> heroDeck, BattleDeck<MonsterCard> monsterDeck) {
@ -60,4 +65,5 @@ public class BattleState
public BattleDeck<HeroCard> HeroDeck {get => this.heroDeck;} public BattleDeck<HeroCard> HeroDeck {get => this.heroDeck;}
public BattleDeck<MonsterCard> MonsterDeck {get => this.monsterDeck;} public BattleDeck<MonsterCard> MonsterDeck {get => this.monsterDeck;}
public PlayArea PlayArea {get => this.playArea;} public PlayArea PlayArea {get => this.playArea;}
public InsightLevel InsightLevel {get => this.insightLevel;}
} }