Create TurnIntentions

This commit is contained in:
henriquenakashima 2020-09-30 23:56:59 -04:00
parent 838c30af99
commit 94b3309bb7
9 changed files with 181 additions and 32 deletions

View file

@ -39,6 +39,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
private InsightLevel insightLevel;
private HandPlayability<HeroCard> heroHandPlayability;
private HandPlayability<MonsterCard> monsterHandPlayability;
private TurnIntentions<MonsterCard> monsterIntentions;
private delegate void BattleStateChangedAction();
private event BattleStateChangedAction OnBattleStateChanged;
@ -137,9 +138,12 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
this.state, this.monsterEnergy, TeamChoice.Monsters, this.monsterDeck);
this.OnBattleStateChanged += this.monsterHandPlayability.NotifyBattleStateChanged;
this.monsterIntentions = new TurnIntentions<MonsterCard>(
this.monsterDeck, this.monsterEnergy);
this.battlePlayerControls.Init(
this.heroDeck, this.monsterDeck, this.playArea, this.insightLevel,
this.heroHandPlayability, this.monsterHandPlayability,
this.heroHandPlayability, this.monsterHandPlayability, this.monsterIntentions,
this.uiCanvas.transform.localScale.x);
this.insightLevel.OnChanged += this.battlePlayerControls.NotifyInsightLevelChanged;
}
@ -147,9 +151,9 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
private void PositionSprite(TeamChoice team, GameObject sprite, int i) {
Vector3 pos;
if (team == TeamChoice.Heroes) {
pos = new Vector3(-1 + -3 + 3 * i, -1.8f, 0);
pos = new Vector3(-0.8f + -3 + 3 * i, -1.8f, 0);
} else {
pos = new Vector3(+1 + -3 + 3 * i, 1.2f, 0);
pos = new Vector3(+0.8f + -3 + 3 * i, 1.2f, 0);
}
sprite.transform.position = pos;
}
@ -211,6 +215,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
private IEnumerator RunHeroTurn() {
// Start of hero turn
OnBattleStateChanged();
this.monsterIntentions.ResumeIntentions();
foreach (BattleHero hero in this.heroes) {
hero.ResetBlock();
@ -242,6 +247,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
hero.TickStatuses();
}
OnBattleStateChanged();
this.monsterIntentions.PauseIntentions();
}
private IEnumerator RunMonsterTurn() {
@ -313,11 +319,11 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
}
public bool CanUseHeroCard(HeroCard card) {
return this.heroHandPlayability.IsPlayable(card);
return this.heroHandPlayability.IsPlayableImmediately(card);
}
public bool CanUseMonsterCard(MonsterCard card) {
return this.monsterHandPlayability.IsPlayable(card);
return this.monsterHandPlayability.IsPlayableImmediately(card);
}
public BattleDeck<HeroCard> GetHeroDeck() {