diff --git a/Assets/Battle/BattleController.cs b/Assets/Battle/BattleController.cs index 461be0f..a7c461f 100644 --- a/Assets/Battle/BattleController.cs +++ b/Assets/Battle/BattleController.cs @@ -1,5 +1,6 @@ using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffectResolver, MonsterViewpoint @@ -7,6 +8,8 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe public HeroId[] heroIds; public MonsterId[] monsterIds; public CardId[] cardIds; + public MCardId[] mCardIds; + public int[] mCardOwnerIndexes; public HeroInfoUI heroUIPrefab; public GameObject uiCanvas; @@ -15,6 +18,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe private HeroCardDatabase heroCardDatabase; private MonsterCardDatabase monsterCardDatabase; private BattleDeck heroDeck; + private BattleDeck monsterDeck; private PlayArea playArea; public BattleHero[] heroes; @@ -77,7 +81,19 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe for (int i = 0; i < this.cardIds.Length; i++) { cardOwners[i] = FindHeroByClass(HeroCardDatabase.GetHeroIdOfCard(this.cardIds[i])); } - this.heroDeck = new BattleDeck(this.heroCardDatabase, this.cardIds, cardOwners); + this.heroDeck = new BattleDeck( + this.heroCardDatabase, this.cardIds.Cast().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( + this.monsterCardDatabase, this.mCardIds.Cast().ToArray(), mCardOwners); this.playArea = new PlayArea(); diff --git a/Assets/Battle/BattleDeck.cs b/Assets/Battle/BattleDeck.cs index 1fc005f..3282d6a 100644 --- a/Assets/Battle/BattleDeck.cs +++ b/Assets/Battle/BattleDeck.cs @@ -17,13 +17,13 @@ public class BattleDeck where BaseCardT : BaseCard private List handPile; private List discardPile; - public BattleDeck(CardDatabase cardDatabase, CardId[] cardIds, BattleParticipant[] cardOwners) { + public BattleDeck(CardDatabase cardDatabase, int[] cardIds, BattleParticipant[] cardOwners) { this.drawPile = new List(); this.handPile = new List(); this.discardPile = new List(); 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.Shuffle(); diff --git a/Assets/Battle/BattleScene.unity b/Assets/Battle/BattleScene.unity index 4648982..cff30c0 100644 --- a/Assets/Battle/BattleScene.unity +++ b/Assets/Battle/BattleScene.unity @@ -305,7 +305,9 @@ MonoBehaviour: m_EditorClassIdentifier: heroIds: 010000000000000002000000 monsterIds: 000000000100000000000000 - cardIds: 00000000000000000000000000000000000000000100000001000000010000000100000002000000 + cardIds: 00000000000000000000000000000000010000000100000001000000030000000300000004000000 + mCardIds: 00000000000000000000000000000000000000000000000000000000000000000000000000000000 + mCardOwnerIndexes: 00000000000000000000000000000000000000000200000002000000020000000200000002000000 heroUIPrefab: {fileID: 6641511084601005557, guid: ef1b469b45cedee418e4c4adf577cd00, type: 3} uiCanvas: {fileID: 35522588}