Mark cards that are not playable
This commit is contained in:
parent
aa78658949
commit
45b91ed352
9 changed files with 162 additions and 14 deletions
|
|
@ -27,11 +27,15 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
private Dictionary<BattleMonster, GameObject> monsterSprites;
|
||||
private Dictionary<BattleMonster, HeroInfoUI> monsterUIs;
|
||||
|
||||
private bool heroTurn;
|
||||
private BattleState state;
|
||||
private bool heroPassedTurn;
|
||||
private EnergyPool heroEnergy;
|
||||
private EnergyPool monsterEnergy;
|
||||
private InsightLevel insightLevel;
|
||||
private HandPlayability<HeroCard> heroHandPlayability;
|
||||
|
||||
private delegate void BattleStateChangedAction();
|
||||
private event BattleStateChangedAction OnBattleStateChanged;
|
||||
|
||||
void Awake() {
|
||||
HeroId[] heroIds = new HeroId[3] {
|
||||
|
|
@ -93,6 +97,8 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
this.heroCardDatabase = new HeroCardDatabase();
|
||||
this.monsterCardDatabase = new MonsterCardDatabase();
|
||||
|
||||
this.state = new BattleState();
|
||||
|
||||
this.heroEnergy = new EnergyPool();
|
||||
this.heroEnergyUI.Init(this.heroEnergy);
|
||||
this.heroEnergy.OnEnergyChanged += this.heroEnergyUI.NotifyEnergyChanged;
|
||||
|
|
@ -169,14 +175,18 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
this.monsterCardDatabase, mCardIds.Cast<int>().ToArray(), mCardOwners);
|
||||
|
||||
this.playArea = new PlayArea();
|
||||
this.heroHandPlayability = new HandPlayability<HeroCard>(
|
||||
this.state, this.heroEnergy, TeamChoice.Heroes, this.heroDeck);
|
||||
|
||||
this.battlePlayerControls.Init(
|
||||
this.heroDeck, this.monsterDeck, this.playArea, this.insightLevel);
|
||||
this.heroDeck, this.monsterDeck, this.playArea, this.insightLevel,
|
||||
this.heroHandPlayability);
|
||||
this.battlePlayerControls.OnCardUsed += this.NotifyHeroCardUsed;
|
||||
this.battlePlayerControls.OnTurnPassed += this.NotifyHeroTurnPassed;
|
||||
this.insightLevel.OnChanged += this.battlePlayerControls.NotifyInsightLevelChanged;
|
||||
this.heroDeck.OnHandPileChanged += this.battlePlayerControls.NotifyHeroHandPileChanged;
|
||||
this.monsterDeck.OnHandPileChanged += this.battlePlayerControls.NotifyMonsterHandPileChanged;
|
||||
this.OnBattleStateChanged += this.heroHandPlayability.NotifyBattleStateChanged;
|
||||
}
|
||||
|
||||
private void PositionSprite(TeamChoice team, GameObject sprite, int i) {
|
||||
|
|
@ -214,7 +224,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
}
|
||||
|
||||
private IEnumerator RunBattleRound() {
|
||||
this.heroTurn = true;
|
||||
this.state.HeroTurn = true;
|
||||
|
||||
this.damageTriggers.RemoveAll(t => t.Expiration == TriggerExpiration.StartOfNextHeroTurn);
|
||||
|
||||
|
|
@ -225,12 +235,13 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
|
||||
yield return RunHeroTurn();
|
||||
|
||||
this.heroTurn = false;
|
||||
this.state.HeroTurn = false;
|
||||
yield return RunMonsterTurn();
|
||||
}
|
||||
|
||||
private IEnumerator RunHeroTurn() {
|
||||
// Start of hero turn
|
||||
OnBattleStateChanged();
|
||||
|
||||
// TODO: Play emotions from hand
|
||||
if (this.heroEnergy.MaxEnergy < 9) {
|
||||
|
|
@ -239,6 +250,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
foreach (BattleHero hero in this.heroes) {
|
||||
hero.ResetBlock();
|
||||
}
|
||||
OnBattleStateChanged();
|
||||
|
||||
// Heroes act until they pass
|
||||
while (!this.heroPassedTurn) {
|
||||
|
|
@ -251,9 +263,11 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
foreach (BattleHero hero in this.heroes) {
|
||||
hero.TickStatuses();
|
||||
}
|
||||
OnBattleStateChanged();
|
||||
}
|
||||
|
||||
private IEnumerator RunMonsterTurn() {
|
||||
OnBattleStateChanged();
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
|
||||
// Start of monster turn
|
||||
|
|
@ -263,6 +277,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
foreach (BattleMonster monster in this.monsters) {
|
||||
monster.ResetBlock();
|
||||
}
|
||||
OnBattleStateChanged();
|
||||
|
||||
// Monsters act until they pass
|
||||
List<MonsterCard> monsterHand = this.monsterDeck.GetHandPile();
|
||||
|
|
@ -270,6 +285,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
MonsterCard monsterCard = monsterHand[i];
|
||||
if (CanUseMonsterCard(monsterCard)) {
|
||||
yield return UseMonsterCard(monsterCard);
|
||||
OnBattleStateChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -278,6 +294,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
foreach (BattleMonster monster in this.monsters) {
|
||||
monster.TickStatuses();
|
||||
}
|
||||
OnBattleStateChanged();
|
||||
}
|
||||
|
||||
public void NotifyHeroCardUsed(HeroCard card) {
|
||||
|
|
@ -298,6 +315,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
}
|
||||
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
OnBattleStateChanged();
|
||||
CheckState();
|
||||
}
|
||||
|
||||
|
|
@ -316,17 +334,17 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
}
|
||||
|
||||
public void NotifyHeroTurnPassed() {
|
||||
if (this.heroTurn) {
|
||||
if (this.state.HeroTurn) {
|
||||
this.heroPassedTurn = true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanUseHeroCard(HeroCard card) {
|
||||
return this.heroTurn && card.Owner.CanUseCard(card) && this.heroEnergy.CanPayForCard(card);
|
||||
return this.heroHandPlayability.IsPlayable(card);
|
||||
}
|
||||
|
||||
public bool CanUseMonsterCard(MonsterCard card) {
|
||||
return !this.heroTurn && card.Owner.CanUseCard(card) && this.monsterEnergy.CanPayForCard(card);
|
||||
return !this.state.HeroTurn && card.Owner.CanUseCard(card) && this.monsterEnergy.CanPayForCard(card);
|
||||
}
|
||||
|
||||
public BattleDeck<HeroCard> GetHeroDeck() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue