Mark cards that are not playable
This commit is contained in:
parent
aa78658949
commit
45b91ed352
9 changed files with 162 additions and 14 deletions
|
|
@ -20,19 +20,27 @@ public class HandControls<BaseCardT> where BaseCardT : BaseCard
|
|||
|
||||
private List<BaseCardT> hand;
|
||||
private List<GameObject> cardsInHandUIs;
|
||||
private TeamChoice team;
|
||||
private int insightLevel;
|
||||
private HandPlayability<BaseCardT> playability;
|
||||
|
||||
public HandControls(GameObject uiCanvas, GameObject cardPrefab, HandControlsPosition position,
|
||||
int insightLevel) {
|
||||
TeamChoice team, int insightLevel, HandPlayability<BaseCardT> playability) {
|
||||
this.uiCanvas = uiCanvas;
|
||||
this.cardPrefab = cardPrefab;
|
||||
this.position = position;
|
||||
this.team = team;
|
||||
this.insightLevel = insightLevel;
|
||||
this.playability = playability;
|
||||
|
||||
if (playability != null) {
|
||||
playability.OnPlayabilityChanged += UpdateCardPlayability;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetHand(List<BaseCardT> hand) {
|
||||
this.hand = hand;
|
||||
DrawHand();
|
||||
RenderHand();
|
||||
}
|
||||
|
||||
private Vector3 CalculateHandCardPosition(int index, int count) {
|
||||
|
|
@ -51,11 +59,11 @@ public class HandControls<BaseCardT> where BaseCardT : BaseCard
|
|||
get => this.insightLevel;
|
||||
set {
|
||||
this.insightLevel = value;
|
||||
DrawHand();
|
||||
RenderHand();
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawHand() {
|
||||
private void RenderHand() {
|
||||
if (this.hand == null) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -81,5 +89,18 @@ public class HandControls<BaseCardT> where BaseCardT : BaseCard
|
|||
int cardIndex = i;
|
||||
cardUI.GetComponent<Button>().onClick.AddListener(delegate {OnCardClicked(card);});
|
||||
}
|
||||
UpdateCardPlayability();
|
||||
}
|
||||
|
||||
private void UpdateCardPlayability() {
|
||||
if (this.hand == null || this.playability == 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue