Finish merging BattleClock and BattleState
This commit is contained in:
parent
658978682b
commit
5962ea9fd6
4 changed files with 17 additions and 25 deletions
|
|
@ -154,7 +154,6 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
|
|
||||||
private IEnumerator RunBattleRound() {
|
private IEnumerator RunBattleRound() {
|
||||||
this.state.Clock.AdvanceRound();
|
this.state.Clock.AdvanceRound();
|
||||||
this.state.AdvanceToTeamTurn(TeamChoice.Heroes);
|
|
||||||
|
|
||||||
this.damageTriggers.RemoveAll(t => t.Expiration == TriggerExpiration.StartOfNextHeroTurn);
|
this.damageTriggers.RemoveAll(t => t.Expiration == TriggerExpiration.StartOfNextHeroTurn);
|
||||||
|
|
||||||
|
|
@ -162,7 +161,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
monsterEnergy.Replenish();
|
monsterEnergy.Replenish();
|
||||||
|
|
||||||
if (STABLE_HAND_STYLE) {
|
if (STABLE_HAND_STYLE) {
|
||||||
if (this.state.Round > 1) {
|
if (this.state.Clock.Now.RoundNumber > 1) {
|
||||||
this.heroDeck.DrawCards(3);
|
this.heroDeck.DrawCards(3);
|
||||||
this.monsterDeck.DrawCards(3);
|
this.monsterDeck.DrawCards(3);
|
||||||
}
|
}
|
||||||
|
|
@ -173,7 +172,6 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
|
|
||||||
yield return RunHeroTurn();
|
yield return RunHeroTurn();
|
||||||
|
|
||||||
this.state.AdvanceToTeamTurn(TeamChoice.Monsters);
|
|
||||||
yield return RunMonsterTurn();
|
yield return RunMonsterTurn();
|
||||||
|
|
||||||
this.state.Clock.AdvanceToStep(RoundStep.EndOfRound);
|
this.state.Clock.AdvanceToStep(RoundStep.EndOfRound);
|
||||||
|
|
@ -183,6 +181,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
private IEnumerator RunHeroTurn() {
|
private IEnumerator RunHeroTurn() {
|
||||||
// Start of hero turn
|
// Start of hero turn
|
||||||
this.state.Clock.AdvanceToStep(RoundStep.StartOfHeroTurn);
|
this.state.Clock.AdvanceToStep(RoundStep.StartOfHeroTurn);
|
||||||
|
this.state.ClearEmotionPlayed();
|
||||||
OnBattleStateChanged();
|
OnBattleStateChanged();
|
||||||
this.monsterIntentions.ResumeIntentions();
|
this.monsterIntentions.ResumeIntentions();
|
||||||
|
|
||||||
|
|
@ -224,15 +223,16 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerator RunMonsterTurn() {
|
private IEnumerator RunMonsterTurn() {
|
||||||
this.state.Clock.AdvanceToStep(RoundStep.StartOfMonsterTurn);
|
|
||||||
OnBattleStateChanged();
|
|
||||||
yield return new WaitForSeconds(0.5f);
|
yield return new WaitForSeconds(0.5f);
|
||||||
|
|
||||||
// Start of monster turn
|
// Start of monster turn
|
||||||
|
this.state.Clock.AdvanceToStep(RoundStep.StartOfMonsterTurn);
|
||||||
|
this.state.ClearEmotionPlayed();
|
||||||
foreach (BattleMonster monster in this.monsters) {
|
foreach (BattleMonster monster in this.monsters) {
|
||||||
monster.ResetBlock();
|
monster.ResetBlock();
|
||||||
}
|
}
|
||||||
OnBattleStateChanged();
|
OnBattleStateChanged();
|
||||||
|
yield return new WaitForSeconds(0.5f);
|
||||||
|
|
||||||
// Monsters play an emotion
|
// Monsters play an emotion
|
||||||
List<MonsterCard> monsterHand = this.monsterDeck.GetHandPile();
|
List<MonsterCard> monsterHand = this.monsterDeck.GetHandPile();
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,7 @@ using UnityEngine;
|
||||||
|
|
||||||
public class BattleState
|
public class BattleState
|
||||||
{
|
{
|
||||||
private TeamChoice mTeamsTurn = TeamChoice.Monsters;
|
private bool playedEmotion;
|
||||||
private bool mPlayedEmotion;
|
|
||||||
private int mRound = 0;
|
|
||||||
private BattleClock clock;
|
private BattleClock clock;
|
||||||
private BuffManager buffManager;
|
private BuffManager buffManager;
|
||||||
|
|
||||||
|
|
@ -16,12 +14,16 @@ public class BattleState
|
||||||
this.buffManager = new BuffManager(this.clock);
|
this.buffManager = new BuffManager(this.clock);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsTeamsTurn(TeamChoice team) {
|
public bool IsTeamsTurnToPlay(TeamChoice team) {
|
||||||
return team == mTeamsTurn;
|
if (team == TeamChoice.Heroes) {
|
||||||
|
return this.clock.Now.RoundStep == RoundStep.StartOfHeroTurn;
|
||||||
|
} else {
|
||||||
|
return this.clock.Now.RoundStep == RoundStep.StartOfMonsterTurn;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanPlayEmotion(TeamChoice team) {
|
public bool CanPlayEmotion(TeamChoice team) {
|
||||||
return !mPlayedEmotion && IsTeamsTurn(team);
|
return !playedEmotion && IsTeamsTurnToPlay(team);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void NotifyPlayedEmotion(TeamChoice team) {
|
public void NotifyPlayedEmotion(TeamChoice team) {
|
||||||
|
|
@ -30,20 +32,11 @@ public class BattleState
|
||||||
+ "cannot play emotion");
|
+ "cannot play emotion");
|
||||||
}
|
}
|
||||||
|
|
||||||
mPlayedEmotion = true;
|
playedEmotion = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Round {get => mRound;}
|
public void ClearEmotionPlayed() {
|
||||||
|
this.playedEmotion = false;
|
||||||
public void AdvanceToTeamTurn(TeamChoice team) {
|
|
||||||
if (team == mTeamsTurn) {
|
|
||||||
throw new System.InvalidOperationException("Already in turn of team " + team);
|
|
||||||
}
|
|
||||||
mTeamsTurn = team;
|
|
||||||
mPlayedEmotion = false;
|
|
||||||
if (team == TeamChoice.Heroes) {
|
|
||||||
mRound++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BattleClock Clock {get => this.clock;}
|
public BattleClock Clock {get => this.clock;}
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ public class HandPlayability<BaseCardT> where BaseCardT : BaseCard {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool canPlayNow = this.battleState.IsTeamsTurn(this.team);
|
bool canPlayNow = this.battleState.IsTeamsTurnToPlay(this.team);
|
||||||
if (card.Type == CardType.Emotion) {
|
if (card.Type == CardType.Emotion) {
|
||||||
canPlayNow = canPlayNow && this.battleState.CanPlayEmotion(this.team);
|
canPlayNow = canPlayNow && this.battleState.CanPlayEmotion(this.team);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
1
TODO.txt
1
TODO.txt
|
|
@ -11,7 +11,6 @@ Battle
|
||||||
- Make Enchantments be dropped as an effect like Defaults
|
- Make Enchantments be dropped as an effect like Defaults
|
||||||
- No need to start coroutine for targeting
|
- No need to start coroutine for targeting
|
||||||
- Indicate which Default is triggering
|
- Indicate which Default is triggering
|
||||||
- Merge BattleClock with BattleState
|
|
||||||
|
|
||||||
Story
|
Story
|
||||||
- Make dialogue show letter by letter.
|
- Make dialogue show letter by letter.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue