Cleanup BattleState
This commit is contained in:
parent
8a86423e7d
commit
6bf1a8672f
1 changed files with 15 additions and 28 deletions
|
|
@ -5,50 +5,37 @@ using UnityEngine;
|
||||||
|
|
||||||
public class BattleState
|
public class BattleState
|
||||||
{
|
{
|
||||||
// public delegate void BattleStateChangedAction();
|
private TeamChoice mTeamsTurn = TeamChoice.Monsters;
|
||||||
// public event BattleStateChangedAction OnBattleStateChanged;
|
private bool mPlayedEmotion;
|
||||||
private bool heroTurn;
|
private int mRound = 0;
|
||||||
private bool playedEmotion;
|
|
||||||
private int round = 0;
|
|
||||||
|
|
||||||
public bool IsTeamsTurn(TeamChoice team) {
|
public bool IsTeamsTurn(TeamChoice team) {
|
||||||
if (team == TeamChoice.Heroes) {
|
return team == mTeamsTurn;
|
||||||
return this.HeroTurn;
|
|
||||||
} else {
|
|
||||||
return !this.HeroTurn;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanPlayEmotion(TeamChoice team) {
|
public bool CanPlayEmotion(TeamChoice team) {
|
||||||
return !this.playedEmotion && IsTeamsTurn(team);
|
return !mPlayedEmotion && IsTeamsTurn(team);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void NotifyPlayedEmotion(TeamChoice team) {
|
public void NotifyPlayedEmotion(TeamChoice team) {
|
||||||
if (!this.CanPlayEmotion(team)) {
|
if (!CanPlayEmotion(team)) {
|
||||||
throw new System.InvalidOperationException("BattleState received NotifyPlayedEmotion but "
|
throw new System.InvalidOperationException("BattleState received NotifyPlayedEmotion but "
|
||||||
+ "cannot play emotion");
|
+ "cannot play emotion");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.playedEmotion = true;
|
mPlayedEmotion = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HeroTurn {get => this.heroTurn;}
|
public int Round {get => mRound;}
|
||||||
|
|
||||||
public int Round {get => this.round;}
|
|
||||||
|
|
||||||
public void AdvanceToTeamTurn(TeamChoice team) {
|
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) {
|
if (team == TeamChoice.Heroes) {
|
||||||
if (this.heroTurn) {
|
mRound++;
|
||||||
throw new System.InvalidOperationException("Already in hero turn");
|
}
|
||||||
}
|
|
||||||
this.heroTurn = true;
|
|
||||||
this.round++;
|
|
||||||
} else {
|
|
||||||
if (!this.heroTurn) {
|
|
||||||
throw new System.InvalidOperationException("Already in monster turn");
|
|
||||||
}
|
|
||||||
this.heroTurn = false;
|
|
||||||
}
|
|
||||||
this.playedEmotion = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue