Create BattleController#monsterDeck
This commit is contained in:
parent
de072a80f7
commit
28db788635
3 changed files with 22 additions and 4 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffectResolver, MonsterViewpoint
|
public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffectResolver, MonsterViewpoint
|
||||||
|
|
@ -7,6 +8,8 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
public HeroId[] heroIds;
|
public HeroId[] heroIds;
|
||||||
public MonsterId[] monsterIds;
|
public MonsterId[] monsterIds;
|
||||||
public CardId[] cardIds;
|
public CardId[] cardIds;
|
||||||
|
public MCardId[] mCardIds;
|
||||||
|
public int[] mCardOwnerIndexes;
|
||||||
|
|
||||||
public HeroInfoUI heroUIPrefab;
|
public HeroInfoUI heroUIPrefab;
|
||||||
public GameObject uiCanvas;
|
public GameObject uiCanvas;
|
||||||
|
|
@ -15,6 +18,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
private HeroCardDatabase heroCardDatabase;
|
private HeroCardDatabase heroCardDatabase;
|
||||||
private MonsterCardDatabase monsterCardDatabase;
|
private MonsterCardDatabase monsterCardDatabase;
|
||||||
private BattleDeck<HeroCard> heroDeck;
|
private BattleDeck<HeroCard> heroDeck;
|
||||||
|
private BattleDeck<MonsterCard> monsterDeck;
|
||||||
private PlayArea playArea;
|
private PlayArea playArea;
|
||||||
|
|
||||||
public BattleHero[] heroes;
|
public BattleHero[] heroes;
|
||||||
|
|
@ -77,7 +81,19 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
||||||
for (int i = 0; i < this.cardIds.Length; i++) {
|
for (int i = 0; i < this.cardIds.Length; i++) {
|
||||||
cardOwners[i] = FindHeroByClass(HeroCardDatabase.GetHeroIdOfCard(this.cardIds[i]));
|
cardOwners[i] = FindHeroByClass(HeroCardDatabase.GetHeroIdOfCard(this.cardIds[i]));
|
||||||
}
|
}
|
||||||
this.heroDeck = new BattleDeck<HeroCard>(this.heroCardDatabase, this.cardIds, cardOwners);
|
this.heroDeck = new BattleDeck<HeroCard>(
|
||||||
|
this.heroCardDatabase, this.cardIds.Cast<int>().ToArray(), cardOwners);
|
||||||
|
|
||||||
|
BattleParticipant[] mCardOwners = new BattleParticipant[this.mCardIds.Length];
|
||||||
|
if (this.mCardIds.Length != this.mCardOwnerIndexes.Length) {
|
||||||
|
throw new System.ArgumentException(
|
||||||
|
"mCardIds and mCardOwnerIndexes need to have the same length");
|
||||||
|
}
|
||||||
|
for (int i = 0; i < this.mCardIds.Length; i++) {
|
||||||
|
mCardOwners[i] = this.monsters[this.mCardOwnerIndexes[i]];
|
||||||
|
}
|
||||||
|
this.monsterDeck = new BattleDeck<MonsterCard>(
|
||||||
|
this.monsterCardDatabase, this.mCardIds.Cast<int>().ToArray(), mCardOwners);
|
||||||
|
|
||||||
this.playArea = new PlayArea();
|
this.playArea = new PlayArea();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,13 +17,13 @@ public class BattleDeck<BaseCardT> where BaseCardT : BaseCard
|
||||||
private List<BaseCardT> handPile;
|
private List<BaseCardT> handPile;
|
||||||
private List<BaseCardT> discardPile;
|
private List<BaseCardT> discardPile;
|
||||||
|
|
||||||
public BattleDeck(CardDatabase<BaseCardT> cardDatabase, CardId[] cardIds, BattleParticipant[] cardOwners) {
|
public BattleDeck(CardDatabase<BaseCardT> cardDatabase, int[] cardIds, BattleParticipant[] cardOwners) {
|
||||||
this.drawPile = new List<BaseCardT>();
|
this.drawPile = new List<BaseCardT>();
|
||||||
this.handPile = new List<BaseCardT>();
|
this.handPile = new List<BaseCardT>();
|
||||||
this.discardPile = new List<BaseCardT>();
|
this.discardPile = new List<BaseCardT>();
|
||||||
|
|
||||||
for (int i = 0; i < cardIds.Length; i++) {
|
for (int i = 0; i < cardIds.Length; i++) {
|
||||||
BaseCardT newCard = cardDatabase.CreateCard((int) cardIds[i], cardOwners[i]);
|
BaseCardT newCard = cardDatabase.CreateCard(cardIds[i], cardOwners[i]);
|
||||||
this.drawPile.Add(newCard);
|
this.drawPile.Add(newCard);
|
||||||
}
|
}
|
||||||
this.drawPile.Shuffle();
|
this.drawPile.Shuffle();
|
||||||
|
|
|
||||||
|
|
@ -305,7 +305,9 @@ MonoBehaviour:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
heroIds: 010000000000000002000000
|
heroIds: 010000000000000002000000
|
||||||
monsterIds: 000000000100000000000000
|
monsterIds: 000000000100000000000000
|
||||||
cardIds: 00000000000000000000000000000000000000000100000001000000010000000100000002000000
|
cardIds: 00000000000000000000000000000000010000000100000001000000030000000300000004000000
|
||||||
|
mCardIds: 00000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||||
|
mCardOwnerIndexes: 00000000000000000000000000000000000000000200000002000000020000000200000002000000
|
||||||
heroUIPrefab: {fileID: 6641511084601005557, guid: ef1b469b45cedee418e4c4adf577cd00,
|
heroUIPrefab: {fileID: 6641511084601005557, guid: ef1b469b45cedee418e4c4adf577cd00,
|
||||||
type: 3}
|
type: 3}
|
||||||
uiCanvas: {fileID: 35522588}
|
uiCanvas: {fileID: 35522588}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue