Implement both styles of battle
This commit is contained in:
parent
6bf1a8672f
commit
838c30af99
3 changed files with 46 additions and 15 deletions
|
|
@ -6,6 +6,9 @@ using UnityEngine.SceneManagement;
|
|||
|
||||
public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffectResolver, MonsterViewpoint
|
||||
{
|
||||
private bool STABLE_HAND_STYLE = false;
|
||||
private int STARTING_INSIGHT = 1;
|
||||
|
||||
// Inspector public
|
||||
public HeroInfoUI heroUIPrefab;
|
||||
public GameObject uiCanvas;
|
||||
|
|
@ -59,7 +62,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
this.monsterEnergyUI.Init(this.monsterEnergy);
|
||||
this.monsterEnergy.OnEnergyChanged += this.monsterEnergyUI.NotifyEnergyChanged;
|
||||
|
||||
this.insightLevel = new InsightLevel(1);
|
||||
this.insightLevel = new InsightLevel(STARTING_INSIGHT);
|
||||
|
||||
this.heroes = new BattleHero[parameters.HeroIds.Length];
|
||||
this.heroSprites = new Dictionary<BattleHero, GameObject>();
|
||||
|
|
@ -171,6 +174,11 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
}
|
||||
|
||||
private IEnumerator RunBattleRounds() {
|
||||
if (STABLE_HAND_STYLE) {
|
||||
this.heroDeck.DrawCards(7);
|
||||
this.monsterDeck.DrawCards(7);
|
||||
}
|
||||
|
||||
while (true) {
|
||||
yield return RunBattleRound();
|
||||
}
|
||||
|
|
@ -184,8 +192,15 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
heroEnergy.Replenish();
|
||||
monsterEnergy.Replenish();
|
||||
|
||||
this.heroDeck.DrawHand();
|
||||
this.monsterDeck.DrawHand();
|
||||
if (STABLE_HAND_STYLE) {
|
||||
if (this.state.Round > 1) {
|
||||
this.heroDeck.DrawCards(2);
|
||||
this.monsterDeck.DrawCards(2);
|
||||
}
|
||||
} else {
|
||||
this.heroDeck.DrawCards(5);
|
||||
this.monsterDeck.DrawCards(5);
|
||||
}
|
||||
|
||||
yield return RunHeroTurn();
|
||||
|
||||
|
|
@ -218,7 +233,11 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
}
|
||||
|
||||
// End of hero turn
|
||||
this.heroDeck.DiscardHand();
|
||||
if (STABLE_HAND_STYLE) {
|
||||
this.heroDeck.DiscardInExcessOf(7);
|
||||
} else {
|
||||
this.heroDeck.DiscardHand();
|
||||
}
|
||||
foreach (BattleHero hero in this.heroes) {
|
||||
hero.TickStatuses();
|
||||
}
|
||||
|
|
@ -246,7 +265,11 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
}
|
||||
|
||||
// End of monster turn
|
||||
this.monsterDeck.DiscardHand();
|
||||
if (STABLE_HAND_STYLE) {
|
||||
this.monsterDeck.DiscardInExcessOf(7);
|
||||
} else {
|
||||
this.monsterDeck.DiscardHand();
|
||||
}
|
||||
foreach (BattleMonster monster in this.monsters) {
|
||||
monster.TickStatuses();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
public class BattleDeck<BaseCardT> where BaseCardT : BaseCard
|
||||
|
|
@ -43,8 +44,8 @@ public class BattleDeck<BaseCardT> where BaseCardT : BaseCard
|
|||
return discardPile;
|
||||
}
|
||||
|
||||
public void DrawHand() {
|
||||
for (int i = 0; i < DEFAULT_HAND_DRAWN; i++) {
|
||||
public void DrawCards(int number) {
|
||||
for (int i = 0; i < number; i++) {
|
||||
DrawCardInternal();
|
||||
}
|
||||
TriggerHandPileChanged();
|
||||
|
|
@ -52,9 +53,7 @@ public class BattleDeck<BaseCardT> where BaseCardT : BaseCard
|
|||
}
|
||||
|
||||
public void DrawCard() {
|
||||
DrawCardInternal();
|
||||
TriggerHandPileChanged();
|
||||
TriggerDrawPileChanged();
|
||||
DrawCards(1);
|
||||
}
|
||||
|
||||
private void DrawCardInternal() {
|
||||
|
|
@ -88,10 +87,19 @@ public class BattleDeck<BaseCardT> where BaseCardT : BaseCard
|
|||
}
|
||||
|
||||
public void DiscardHand() {
|
||||
this.discardPile.InsertRange(0, this.handPile);
|
||||
this.handPile.Clear();
|
||||
TriggerHandPileChanged();
|
||||
TriggerDiscardPileChanged();
|
||||
DiscardInExcessOf(0);
|
||||
}
|
||||
|
||||
public void DiscardInExcessOf(int max) {
|
||||
int numberToDiscard = this.handPile.Count - max;
|
||||
|
||||
if (numberToDiscard > 0) {
|
||||
IEnumerable<BaseCardT> rangeToDiscard = this.handPile.GetRange(0, numberToDiscard);
|
||||
this.discardPile.InsertRange(0, rangeToDiscard.Reverse());
|
||||
this.handPile.RemoveRange(0, numberToDiscard);
|
||||
TriggerHandPileChanged();
|
||||
TriggerDiscardPileChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void PutCardOnTopOfDrawPile(BaseCardT card) {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public class BattlePlayerControls : MonoBehaviour
|
|||
this.heroHandControls.OnCardClicked += OnHeroCardClicked;
|
||||
this.monsterHandControls = new HandControls<MonsterCard>(
|
||||
monsterDeck, this.uiCanvas, this.cardPrefab, HandControlsPosition.Top,
|
||||
TeamChoice.Monsters, 1, monsterHandPlayability, this.scale);
|
||||
TeamChoice.Monsters, insightLevel.Level, monsterHandPlayability, this.scale);
|
||||
this.monsterHandControls.OnCardClicked += OnMonsterCardClicked;
|
||||
this.cardsInPlayUIs = new Dictionary<BaseCard, GameObject>();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue