Draw monster hand
This commit is contained in:
parent
fb453702ba
commit
c7d2302326
3 changed files with 31 additions and 12 deletions
|
|
@ -157,7 +157,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
hero.ResetBlock();
|
||||
}
|
||||
|
||||
// Heroes act until they pas
|
||||
// Heroes act until they pass
|
||||
while (!this.heroPassedTurn) {
|
||||
yield return null;
|
||||
}
|
||||
|
|
@ -177,7 +177,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
monster.ResetBlock();
|
||||
}
|
||||
|
||||
// Start of monster turn
|
||||
// Monsters act until they pass
|
||||
List<MonsterCard> monsterHand = this.monsterDeck.GetHandPile();
|
||||
for (int i = 0; i < monsterHand.Count; i++) {
|
||||
MonsterCard monsterCard = monsterHand[i];
|
||||
|
|
@ -185,6 +185,9 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
yield return UseMonsterCard(monsterCard);
|
||||
}
|
||||
}
|
||||
|
||||
// End of monster turn
|
||||
this.monsterDeck.DiscardHand();
|
||||
}
|
||||
|
||||
public void NotifyHeroCardUsed(HeroCard card) {
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ public class BattlePlayerControls : MonoBehaviour
|
|||
private PlayArea playArea;
|
||||
|
||||
private HandControls<HeroCard> heroHandControls;
|
||||
private HandControls<MonsterCard> monsterHandControls;
|
||||
private Dictionary<BaseCard, GameObject> cardsInPlayUIs;
|
||||
|
||||
public void Init(
|
||||
|
|
@ -30,8 +31,10 @@ public class BattlePlayerControls : MonoBehaviour
|
|||
this.monsterDeck = monsterDeck;
|
||||
this.playArea = playArea;
|
||||
|
||||
this.heroHandControls = new HandControls<HeroCard>(this.uiCanvas, this.cardPrefab);
|
||||
this.heroHandControls.OnCardClicked += OnCardClicked;
|
||||
this.heroHandControls = new HandControls<HeroCard>(this.uiCanvas, this.cardPrefab, HandControlsPosition.Bottom);
|
||||
this.heroHandControls.OnCardClicked += OnHeroCardClicked;
|
||||
this.monsterHandControls = new HandControls<MonsterCard>(this.uiCanvas, this.cardPrefab, HandControlsPosition.Top);
|
||||
this.monsterHandControls.OnCardClicked += OnMonsterCardClicked;
|
||||
this.cardsInPlayUIs = new Dictionary<BaseCard, GameObject>();
|
||||
}
|
||||
|
||||
|
|
@ -52,7 +55,7 @@ public class BattlePlayerControls : MonoBehaviour
|
|||
// TODO
|
||||
}
|
||||
|
||||
private void OnCardClicked(HeroCard card) {
|
||||
private void OnHeroCardClicked(HeroCard card) {
|
||||
if (this.singleTargeting == null) {
|
||||
if (this.battleController.CanUseHeroCard(card)) {
|
||||
OnCardUsed(card);
|
||||
|
|
@ -60,6 +63,9 @@ public class BattlePlayerControls : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
private void OnMonsterCardClicked(MonsterCard card) {
|
||||
}
|
||||
|
||||
private SingleTargeting singleTargeting;
|
||||
|
||||
public IEnumerator ChooseTarget(SingleTargeting targeting) {
|
||||
|
|
@ -85,11 +91,11 @@ public class BattlePlayerControls : MonoBehaviour
|
|||
}
|
||||
|
||||
public void NotifyHeroHandPileChanged() {
|
||||
this.heroHandControls.SetHeroHand(this.heroDeck.GetHandPile().ToList());
|
||||
this.heroHandControls.SetHand(this.heroDeck.GetHandPile().ToList());
|
||||
}
|
||||
|
||||
public void NotifyMonsterHandPileChanged() {
|
||||
SetMonsterHand(this.monsterDeck.GetHandPile().ToList());
|
||||
this.monsterHandControls.SetHand(this.monsterDeck.GetHandPile().ToList());
|
||||
}
|
||||
|
||||
private void NotifyPlayAreaChanged() {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@ using System.Linq;
|
|||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public enum HandControlsPosition {
|
||||
Top,
|
||||
Bottom,
|
||||
}
|
||||
|
||||
public class HandControls<BaseCardT> where BaseCardT : BaseCard
|
||||
{
|
||||
public delegate void CardClickedAction(BaseCardT card);
|
||||
|
|
@ -11,15 +16,17 @@ public class HandControls<BaseCardT> where BaseCardT : BaseCard
|
|||
|
||||
private GameObject uiCanvas;
|
||||
private GameObject cardPrefab;
|
||||
private HandControlsPosition position;
|
||||
|
||||
private List<GameObject> cardsInHandUIs;
|
||||
|
||||
public HandControls(GameObject uiCanvas, GameObject cardPrefab) {
|
||||
public HandControls(GameObject uiCanvas, GameObject cardPrefab, HandControlsPosition position) {
|
||||
this.uiCanvas = uiCanvas;
|
||||
this.cardPrefab = cardPrefab;
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public void SetHeroHand(List<BaseCardT> hand) {
|
||||
public void SetHand(List<BaseCardT> hand) {
|
||||
if (this.cardsInHandUIs != null) {
|
||||
foreach (GameObject cardInHandUI in this.cardsInHandUIs) {
|
||||
GameObject.Destroy(cardInHandUI);
|
||||
|
|
@ -42,8 +49,11 @@ public class HandControls<BaseCardT> where BaseCardT : BaseCard
|
|||
const int SPACING = 8;
|
||||
const int DELTA = BattleCardPrefabConstants.CARD_WIDTH + SPACING;
|
||||
|
||||
return new Vector3(Screen.width * 0.5f - DELTA / 2 * (count - 1) + DELTA * index,
|
||||
SPACING + BattleCardPrefabConstants.CARD_HEIGHT / 2,
|
||||
0);
|
||||
float x = Screen.width * 0.5f - DELTA / 2 * (count - 1) + DELTA * index;
|
||||
float y = (this.position == HandControlsPosition.Bottom
|
||||
? SPACING + BattleCardPrefabConstants.CARD_HEIGHT / 2
|
||||
: Screen.height - SPACING - BattleCardPrefabConstants.CARD_HEIGHT / 2);
|
||||
|
||||
return new Vector3(x, y, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue