Move things to make space for monster hand

This commit is contained in:
henriquenakashima 2020-09-20 14:00:49 -04:00
parent 6135ea1b24
commit c0afc58c01
2 changed files with 22 additions and 10 deletions

View file

@ -51,7 +51,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
heroSprites[i] = HeroDatabase.createHeroSprite(id); heroSprites[i] = HeroDatabase.createHeroSprite(id);
heroSprites[i].name = "Hero" + i + "_Sprite"; heroSprites[i].name = "Hero" + i + "_Sprite";
heroSprites[i].transform.position = new Vector3(-1 + -3 + 3 * i, 0, 0); heroSprites[i].transform.position = new Vector3(-1 + -3 + 3 * i, -1.8f, 0);
BattleParticipantSprite bps = heroSprites[i].AddComponent<BattleParticipantSprite>(); BattleParticipantSprite bps = heroSprites[i].AddComponent<BattleParticipantSprite>();
bps.Init(battlePlayerControls, heroes[i]); bps.Init(battlePlayerControls, heroes[i]);
bps.OnSpriteClicked += battlePlayerControls.NotifyParticipantSpriteClicked; bps.OnSpriteClicked += battlePlayerControls.NotifyParticipantSpriteClicked;
@ -71,7 +71,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
monsterSprites[i] = MonsterDatabase.createMonsterSprite(id); monsterSprites[i] = MonsterDatabase.createMonsterSprite(id);
monsterSprites[i].name = "Monster" + i + "_Sprite"; monsterSprites[i].name = "Monster" + i + "_Sprite";
monsterSprites[i].transform.position = new Vector3(+1 + -3 + 3 * i, 3, 0); monsterSprites[i].transform.position = new Vector3(+1 + -3 + 3 * i, 1.2f, 0);
BattleParticipantSprite bps = monsterSprites[i].AddComponent<BattleParticipantSprite>(); BattleParticipantSprite bps = monsterSprites[i].AddComponent<BattleParticipantSprite>();
bps.Init(battlePlayerControls, monsters[i]); bps.Init(battlePlayerControls, monsters[i]);
bps.OnSpriteClicked += battlePlayerControls.NotifyParticipantSpriteClicked; bps.OnSpriteClicked += battlePlayerControls.NotifyParticipantSpriteClicked;
@ -100,10 +100,11 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
this.playArea = new PlayArea(); this.playArea = new PlayArea();
this.battlePlayerControls.Init(this.heroDeck, this.playArea); this.battlePlayerControls.Init(this.heroDeck, this.monsterDeck, this.playArea);
this.battlePlayerControls.OnCardUsed += this.NotifyHeroCardUsed; this.battlePlayerControls.OnCardUsed += this.NotifyHeroCardUsed;
this.battlePlayerControls.OnTurnPassed += this.NotifyHeroTurnPassed; this.battlePlayerControls.OnTurnPassed += this.NotifyHeroTurnPassed;
this.heroDeck.OnHandPileChanged += this.battlePlayerControls.NotifyHandPileChanged; this.heroDeck.OnHandPileChanged += this.battlePlayerControls.NotifyHeroHandPileChanged;
this.monsterDeck.OnHandPileChanged += this.battlePlayerControls.NotifyMonsterHandPileChanged;
} }
private BattleParticipant FindHeroByClass(HeroId heroId) { private BattleParticipant FindHeroByClass(HeroId heroId) {

View file

@ -18,12 +18,15 @@ public class BattlePlayerControls : MonoBehaviour
public event TurnPassedAction OnTurnPassed; public event TurnPassedAction OnTurnPassed;
private BattleDeck<HeroCard> heroDeck; private BattleDeck<HeroCard> heroDeck;
private BattleDeck<MonsterCard> monsterDeck;
private List<GameObject> cardsInHandUIs; private List<GameObject> cardsInHandUIs;
private PlayArea playArea; private PlayArea playArea;
private Dictionary<BaseCard, GameObject> cardsInPlayUIs; private Dictionary<BaseCard, GameObject> cardsInPlayUIs;
public void Init(BattleDeck<HeroCard> heroDeck, PlayArea playArea) { public void Init(
BattleDeck<HeroCard> heroDeck, BattleDeck<MonsterCard> monsterDeck, PlayArea playArea) {
this.heroDeck = heroDeck; this.heroDeck = heroDeck;
this.monsterDeck = monsterDeck;
this.playArea = playArea; this.playArea = playArea;
this.cardsInPlayUIs = new Dictionary<BaseCard, GameObject>(); this.cardsInPlayUIs = new Dictionary<BaseCard, GameObject>();
@ -42,7 +45,7 @@ public class BattlePlayerControls : MonoBehaviour
} }
private void SetHand(List<HeroCard> hand) { private void SetHeroHand(List<HeroCard> hand) {
if (this.cardsInHandUIs != null) { if (this.cardsInHandUIs != null) {
foreach (GameObject cardInHandUI in this.cardsInHandUIs) { foreach (GameObject cardInHandUI in this.cardsInHandUIs) {
Destroy(cardInHandUI); Destroy(cardInHandUI);
@ -61,6 +64,10 @@ public class BattlePlayerControls : MonoBehaviour
} }
} }
private void SetMonsterHand(List<MonsterCard> hand) {
// TODO
}
private const int CARD_WIDTH = 122; private const int CARD_WIDTH = 122;
private const int CARD_HEIGHT = 155; private const int CARD_HEIGHT = 155;
@ -69,7 +76,7 @@ public class BattlePlayerControls : MonoBehaviour
const int DELTA = CARD_WIDTH + SPACING; const int DELTA = CARD_WIDTH + SPACING;
return new Vector3(Screen.width * 0.5f - DELTA / 2 * (count - 1) + DELTA * index, return new Vector3(Screen.width * 0.5f - DELTA / 2 * (count - 1) + DELTA * index,
160, SPACING + CARD_HEIGHT / 2,
0); 0);
} }
@ -105,8 +112,12 @@ public class BattlePlayerControls : MonoBehaviour
return this.singleTargeting != null && this.singleTargeting.CanTarget(participant); return this.singleTargeting != null && this.singleTargeting.CanTarget(participant);
} }
public void NotifyHandPileChanged() { public void NotifyHeroHandPileChanged() {
SetHand(this.heroDeck.GetHandPile().Cast<HeroCard>().ToList()); SetHeroHand(this.heroDeck.GetHandPile().ToList());
}
public void NotifyMonsterHandPileChanged() {
SetMonsterHand(this.monsterDeck.GetHandPile().ToList());
} }
private void NotifyPlayAreaChanged() { private void NotifyPlayAreaChanged() {