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
|
public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffectResolver, MonsterViewpoint
|
||||||
{
|
{
|
||||||
|
private bool STABLE_HAND_STYLE = false;
|
||||||
|
private int STARTING_INSIGHT = 1;
|
||||||
|
|
||||||
// Inspector public
|
// Inspector public
|
||||||
public HeroInfoUI heroUIPrefab;
|
public HeroInfoUI heroUIPrefab;
|
||||||
public GameObject uiCanvas;
|
public GameObject uiCanvas;
|
||||||
|
|
@ -59,7 +62,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
this.monsterEnergyUI.Init(this.monsterEnergy);
|
this.monsterEnergyUI.Init(this.monsterEnergy);
|
||||||
this.monsterEnergy.OnEnergyChanged += this.monsterEnergyUI.NotifyEnergyChanged;
|
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.heroes = new BattleHero[parameters.HeroIds.Length];
|
||||||
this.heroSprites = new Dictionary<BattleHero, GameObject>();
|
this.heroSprites = new Dictionary<BattleHero, GameObject>();
|
||||||
|
|
@ -171,6 +174,11 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerator RunBattleRounds() {
|
private IEnumerator RunBattleRounds() {
|
||||||
|
if (STABLE_HAND_STYLE) {
|
||||||
|
this.heroDeck.DrawCards(7);
|
||||||
|
this.monsterDeck.DrawCards(7);
|
||||||
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
yield return RunBattleRound();
|
yield return RunBattleRound();
|
||||||
}
|
}
|
||||||
|
|
@ -184,8 +192,15 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
heroEnergy.Replenish();
|
heroEnergy.Replenish();
|
||||||
monsterEnergy.Replenish();
|
monsterEnergy.Replenish();
|
||||||
|
|
||||||
this.heroDeck.DrawHand();
|
if (STABLE_HAND_STYLE) {
|
||||||
this.monsterDeck.DrawHand();
|
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();
|
yield return RunHeroTurn();
|
||||||
|
|
||||||
|
|
@ -218,7 +233,11 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
}
|
}
|
||||||
|
|
||||||
// End of hero turn
|
// 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) {
|
foreach (BattleHero hero in this.heroes) {
|
||||||
hero.TickStatuses();
|
hero.TickStatuses();
|
||||||
}
|
}
|
||||||
|
|
@ -246,7 +265,11 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
}
|
}
|
||||||
|
|
||||||
// End of monster turn
|
// 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) {
|
foreach (BattleMonster monster in this.monsters) {
|
||||||
monster.TickStatuses();
|
monster.TickStatuses();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class BattleDeck<BaseCardT> where BaseCardT : BaseCard
|
public class BattleDeck<BaseCardT> where BaseCardT : BaseCard
|
||||||
|
|
@ -43,8 +44,8 @@ public class BattleDeck<BaseCardT> where BaseCardT : BaseCard
|
||||||
return discardPile;
|
return discardPile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawHand() {
|
public void DrawCards(int number) {
|
||||||
for (int i = 0; i < DEFAULT_HAND_DRAWN; i++) {
|
for (int i = 0; i < number; i++) {
|
||||||
DrawCardInternal();
|
DrawCardInternal();
|
||||||
}
|
}
|
||||||
TriggerHandPileChanged();
|
TriggerHandPileChanged();
|
||||||
|
|
@ -52,9 +53,7 @@ public class BattleDeck<BaseCardT> where BaseCardT : BaseCard
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawCard() {
|
public void DrawCard() {
|
||||||
DrawCardInternal();
|
DrawCards(1);
|
||||||
TriggerHandPileChanged();
|
|
||||||
TriggerDrawPileChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawCardInternal() {
|
private void DrawCardInternal() {
|
||||||
|
|
@ -88,10 +87,19 @@ public class BattleDeck<BaseCardT> where BaseCardT : BaseCard
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DiscardHand() {
|
public void DiscardHand() {
|
||||||
this.discardPile.InsertRange(0, this.handPile);
|
DiscardInExcessOf(0);
|
||||||
this.handPile.Clear();
|
}
|
||||||
TriggerHandPileChanged();
|
|
||||||
TriggerDiscardPileChanged();
|
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) {
|
public void PutCardOnTopOfDrawPile(BaseCardT card) {
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ public class BattlePlayerControls : MonoBehaviour
|
||||||
this.heroHandControls.OnCardClicked += OnHeroCardClicked;
|
this.heroHandControls.OnCardClicked += OnHeroCardClicked;
|
||||||
this.monsterHandControls = new HandControls<MonsterCard>(
|
this.monsterHandControls = new HandControls<MonsterCard>(
|
||||||
monsterDeck, this.uiCanvas, this.cardPrefab, HandControlsPosition.Top,
|
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.monsterHandControls.OnCardClicked += OnMonsterCardClicked;
|
||||||
this.cardsInPlayUIs = new Dictionary<BaseCard, GameObject>();
|
this.cardsInPlayUIs = new Dictionary<BaseCard, GameObject>();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue