Create TurnIntentions
This commit is contained in:
parent
838c30af99
commit
94b3309bb7
9 changed files with 181 additions and 32 deletions
|
|
@ -24,11 +24,13 @@ public class HandControls<BaseCardT> where BaseCardT : BaseCard
|
|||
private TeamChoice team;
|
||||
private int insightLevel;
|
||||
private HandPlayability<BaseCardT> playability;
|
||||
private TurnIntentions<BaseCardT> intentions;
|
||||
private float scale;
|
||||
|
||||
public HandControls(BattleDeck<BaseCardT> deck, GameObject uiCanvas, GameObject cardPrefab,
|
||||
HandControlsPosition position, TeamChoice team, int insightLevel,
|
||||
HandPlayability<BaseCardT> playability, float scale) {
|
||||
HandPlayability<BaseCardT> playability, TurnIntentions<BaseCardT> intentions,
|
||||
float scale) {
|
||||
this.deck = deck;
|
||||
this.uiCanvas = uiCanvas;
|
||||
this.cardPrefab = cardPrefab;
|
||||
|
|
@ -36,6 +38,7 @@ public class HandControls<BaseCardT> where BaseCardT : BaseCard
|
|||
this.team = team;
|
||||
this.insightLevel = insightLevel;
|
||||
this.playability = playability;
|
||||
this.intentions = intentions;
|
||||
this.scale = scale;
|
||||
|
||||
deck.OnHandPileChanged += this.UpdateState;
|
||||
|
|
@ -43,6 +46,9 @@ public class HandControls<BaseCardT> where BaseCardT : BaseCard
|
|||
if (playability != null) {
|
||||
playability.OnPlayabilityChanged += this.UpdateState;
|
||||
}
|
||||
if (intentions != null) {
|
||||
intentions.OnIntentionsChanged += this.UpdateState;
|
||||
}
|
||||
}
|
||||
|
||||
private Vector3 CalculateHandCardPosition(int index, int count) {
|
||||
|
|
@ -96,18 +102,36 @@ public class HandControls<BaseCardT> where BaseCardT : BaseCard
|
|||
private void UpdateState() {
|
||||
this.hand = this.deck.GetHandPile().ToList();
|
||||
RenderHand();
|
||||
UpdateCardPlayability();
|
||||
UpdateCardPlayabilityAndIntentions();
|
||||
}
|
||||
|
||||
private void UpdateCardPlayability() {
|
||||
if (this.hand == null || this.playability == null) {
|
||||
private void UpdateCardPlayabilityAndIntentions() {
|
||||
if (this.hand == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.hand.Count; i++) {
|
||||
BaseCardT card = this.hand[i];
|
||||
CardUI cardUI = this.cardsInHandUIs[i].GetComponent<CardUI>();
|
||||
cardUI.Playable = this.playability.IsPlayable(card);
|
||||
PlayabilityState cardPlayability = this.playability.GetCardPlayability(card);
|
||||
if (this.intentions == null) {
|
||||
if (cardPlayability == PlayabilityState.PlayableImmediately) {
|
||||
cardUI.State = PlayableState.Playable;
|
||||
} else {
|
||||
cardUI.State = PlayableState.Unplayable;
|
||||
}
|
||||
} else {
|
||||
if (cardPlayability == PlayabilityState.PlayableImmediately
|
||||
|| cardPlayability == PlayabilityState.PlayableInOwnTurn) {
|
||||
if (this.intentions.WillUseCard(card)) {
|
||||
cardUI.State = PlayableState.IntendedToPlay;
|
||||
} else {
|
||||
cardUI.State = PlayableState.Playable;
|
||||
}
|
||||
} else {
|
||||
cardUI.State = PlayableState.Unplayable;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue