Add some art, fix UI anchors
This commit is contained in:
parent
c31747bc19
commit
0ca4c3276d
22 changed files with 542 additions and 65 deletions
|
|
@ -14,6 +14,7 @@ public class HandControls<BaseCardT> where BaseCardT : BaseCard
|
|||
public delegate void CardClickedAction(BaseCardT card);
|
||||
public event CardClickedAction OnCardClicked;
|
||||
|
||||
private BattleDeck<BaseCardT> deck;
|
||||
private GameObject uiCanvas;
|
||||
private GameObject cardPrefab;
|
||||
private HandControlsPosition position;
|
||||
|
|
@ -24,8 +25,9 @@ public class HandControls<BaseCardT> where BaseCardT : BaseCard
|
|||
private int insightLevel;
|
||||
private HandPlayability<BaseCardT> playability;
|
||||
|
||||
public HandControls(GameObject uiCanvas, GameObject cardPrefab, HandControlsPosition position,
|
||||
public HandControls(BattleDeck<BaseCardT> deck, GameObject uiCanvas, GameObject cardPrefab, HandControlsPosition position,
|
||||
TeamChoice team, int insightLevel, HandPlayability<BaseCardT> playability) {
|
||||
this.deck = deck;
|
||||
this.uiCanvas = uiCanvas;
|
||||
this.cardPrefab = cardPrefab;
|
||||
this.position = position;
|
||||
|
|
@ -33,16 +35,13 @@ public class HandControls<BaseCardT> where BaseCardT : BaseCard
|
|||
this.insightLevel = insightLevel;
|
||||
this.playability = playability;
|
||||
|
||||
deck.OnHandPileChanged += this.UpdateState;
|
||||
|
||||
if (playability != null) {
|
||||
playability.OnPlayabilityChanged += UpdateCardPlayability;
|
||||
playability.OnPlayabilityChanged += this.UpdateState;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetHand(List<BaseCardT> hand) {
|
||||
this.hand = hand;
|
||||
RenderHand();
|
||||
}
|
||||
|
||||
private Vector3 CalculateHandCardPosition(int index, int count) {
|
||||
const int SPACING = 8;
|
||||
const int DELTA = BattleCardPrefabConstants.CARD_WIDTH + SPACING;
|
||||
|
|
@ -89,6 +88,11 @@ public class HandControls<BaseCardT> where BaseCardT : BaseCard
|
|||
int cardIndex = i;
|
||||
cardUI.GetComponent<Button>().onClick.AddListener(delegate {OnCardClicked(card);});
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateState() {
|
||||
this.hand = this.deck.GetHandPile().ToList();
|
||||
RenderHand();
|
||||
UpdateCardPlayability();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue