diff --git a/Assets/Battle/BattleController.cs b/Assets/Battle/BattleController.cs index 0362376..6160991 100644 --- a/Assets/Battle/BattleController.cs +++ b/Assets/Battle/BattleController.cs @@ -43,75 +43,9 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe BattleParameters parameters = BattleSetup.RetrieveParameters(); if (parameters == null) { Debug.Log("Using default battle"); - - MonsterId[] monsterIds = new MonsterId[3] { - MonsterId.Golem, - MonsterId.Bat, - MonsterId.Bat, - }; - - MCardId[] mCardIds = new MCardId[10] { - MCardId.GraniteDefense, - MCardId.GraniteDefense, - MCardId.GolemCharge, - MCardId.GolemFist, - - MCardId.VampireFangs, - MCardId.VampireFangs, - MCardId.Whirlwind, - - MCardId.VampireFangs, - MCardId.VampireFangs, - MCardId.Whirlwind, - }; - int[] mCardOwnerIndexes = new int[10] { - 0, 0, 0, 0, - 1, 1, 1, - 2, 2, 2, - }; - parameters = new BattleParameters(); - parameters.SetMonsters(monsterIds, mCardIds, mCardOwnerIndexes); + parameters = DebugBattle.CreateParameters(); } - HeroId[] heroIds = new HeroId[3] { - HeroId.Alchemist, - HeroId.NPCGuard, - HeroId.NPCGuard, - }; - - HCardId[] cardIds = new HCardId[11] { - HCardId.Eagerness, - HCardId.Eagerness, - HCardId.LeadShot, - HCardId.LeadShot, - HCardId.SmokeBomb, - HCardId.Eagerness, - HCardId.SwordSlash, - HCardId.ShieldBlock, - HCardId.Eagerness, - HCardId.SwordSlash, - HCardId.ShieldBlock, - }; - - // HeroId[] heroIds = new HeroId[3] { - // HeroId.Brute, - // HeroId.Alchemist, - // HeroId.Shaman, - // }; - - // HCardId[] cardIds = new HCardId[10] { - // HCardId.CrashingPunch, - // HCardId.LightningHatchet, - // HCardId.BlindFury, - // HCardId.Cover, - // HCardId.Cover, - // HCardId.Thunderstorm, - // HCardId.Scarring, - // HCardId.Scarring, - // HCardId.Meditate, - // HCardId.IronskinDraught, - // }; - this.heroCardDatabase = new HeroCardDatabase(); this.monsterCardDatabase = new MonsterCardDatabase(); @@ -126,11 +60,11 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe this.insightLevel = new InsightLevel(1); - this.heroes = new BattleHero[heroIds.Length]; + this.heroes = new BattleHero[parameters.HeroIds.Length]; this.heroSprites = new Dictionary(); this.heroUIs = new Dictionary(); for (int i = 0; i < this.heroes.Length; i++) { - HeroId id = heroIds[i]; + HeroId id = parameters.HeroIds[i]; BattleHero hero = new BattleHero(id); hero.Init(); @@ -175,13 +109,13 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe monsterUI.Init(sprite, monster); this.monsterUIs[monster] = monsterUI; } - - BattleParticipant[] cardOwners = new BattleParticipant[cardIds.Length]; - for (int i = 0; i < cardIds.Length; i++) { - cardOwners[i] = FindHeroByClass(HeroCardDatabase.GetHeroIdOfCard(cardIds[i])); + + BattleParticipant[] cardOwners = new BattleParticipant[parameters.HCardIds.Length]; + for (int i = 0; i < parameters.HCardIds.Length; i++) { + cardOwners[i] = this.heroes[parameters.HCardOwnerIndexes[i]]; } this.heroDeck = new BattleDeck( - this.heroCardDatabase, cardIds.Cast().ToArray(), cardOwners); + this.heroCardDatabase, parameters.HCardIds.Cast().ToArray(), cardOwners); BattleParticipant[] mCardOwners = new BattleParticipant[parameters.MCardIds.Length]; for (int i = 0; i < parameters.MCardIds.Length; i++) { @@ -212,13 +146,6 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe sprite.transform.position = pos; } - private BattleParticipant FindHeroByClass(HeroId heroId) { - foreach (BattleHero battleHero in this.heroes) { - if (battleHero.GetId() == heroId) return battleHero; - } - return null; - } - // Start is called before the first frame update void Start() { @@ -389,7 +316,7 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe foreach (BattleParticipant p in this.monsters) { p.CheckState(); } - + if (System.Array.TrueForAll(this.heroes, h => !h.IsAlive())) { BattleResult.FinishBattle(new BattleResult(false)); } else if (System.Array.TrueForAll(this.monsters, m => !m.IsAlive())) { diff --git a/Assets/Battle/BattleParameters.cs b/Assets/Battle/BattleParameters.cs index 8655534..52e3fdf 100644 --- a/Assets/Battle/BattleParameters.cs +++ b/Assets/Battle/BattleParameters.cs @@ -1,4 +1,7 @@ public class BattleParameters { + private HeroId[] heroIds; + private HCardId[] hCardIds; + private int[] hCardOwnerIndexes; private MonsterId[] monsterIds; private MCardId[] mCardIds; private int[] mCardOwnerIndexes; @@ -7,6 +10,17 @@ public class BattleParameters { } + public void SetHeroes(HeroId[] heroIds, HCardId[] hCardIds, int[] hCardOwnerIndexes) { + if (hCardIds.Length != hCardOwnerIndexes.Length) { + throw new System.ArgumentException( + "hCardIds and hCardOwnerIndexes need to have the same length"); + } + + this.heroIds = heroIds; + this.hCardIds = hCardIds; + this.hCardOwnerIndexes = hCardOwnerIndexes; + } + public void SetMonsters(MonsterId[] monsterIds, MCardId[] mCardIds, int[] mCardOwnerIndexes) { if (mCardIds.Length != mCardOwnerIndexes.Length) { throw new System.ArgumentException( @@ -18,6 +32,9 @@ public class BattleParameters { this.mCardOwnerIndexes = mCardOwnerIndexes; } + public HeroId[] HeroIds {get => this.heroIds;} + public HCardId[] HCardIds {get => this.hCardIds;} + public int[] HCardOwnerIndexes {get => this.hCardOwnerIndexes;} public MonsterId[] MonsterIds {get => this.monsterIds;} public MCardId[] MCardIds {get => this.mCardIds;} public int[] MCardOwnerIndexes {get => this.mCardOwnerIndexes;} diff --git a/Assets/Battle/DebugBattle.cs b/Assets/Battle/DebugBattle.cs new file mode 100644 index 0000000..5ec3ae9 --- /dev/null +++ b/Assets/Battle/DebugBattle.cs @@ -0,0 +1,61 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class DebugBattle +{ + public static BattleParameters CreateParameters() { + HeroId[] heroIds = new HeroId[3] { + HeroId.Brute, + HeroId.Alchemist, + HeroId.Shaman, + }; + + HCardId[] hCardIds = new HCardId[10] { + HCardId.CrashingPunch, + HCardId.LightningHatchet, + HCardId.BlindFury, + HCardId.Cover, + HCardId.Cover, + HCardId.Thunderstorm, + HCardId.Scarring, + HCardId.Scarring, + HCardId.Meditate, + HCardId.IronskinDraught, + }; + + int[] hCardOwnerIndexes = new int[10] { + 0, 2, 0, 0, 0, 2, 0, 0, 2, 1, + }; + + MonsterId[] monsterIds = new MonsterId[3] { + MonsterId.Golem, + MonsterId.Bat, + MonsterId.Bat, + }; + + MCardId[] mCardIds = new MCardId[10] { + MCardId.GraniteDefense, + MCardId.GraniteDefense, + MCardId.GolemCharge, + MCardId.GolemFist, + + MCardId.VampireFangs, + MCardId.VampireFangs, + MCardId.Whirlwind, + + MCardId.VampireFangs, + MCardId.VampireFangs, + MCardId.Whirlwind, + }; + int[] mCardOwnerIndexes = new int[10] { + 0, 0, 0, 0, + 1, 1, 1, + 2, 2, 2, + }; + BattleParameters parameters = new BattleParameters(); + parameters.SetHeroes(heroIds, hCardIds, hCardOwnerIndexes); + parameters.SetMonsters(monsterIds, mCardIds, mCardOwnerIndexes); + return parameters; + } +} diff --git a/Assets/Battle/DebugBattle.cs.meta b/Assets/Battle/DebugBattle.cs.meta new file mode 100644 index 0000000..b99d61c --- /dev/null +++ b/Assets/Battle/DebugBattle.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1d71d39191f1f0d48b2763622aed3a2b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Battle/HeroCardDatabase.cs b/Assets/Battle/HeroCardDatabase.cs index 77c895d..30e5fec 100644 --- a/Assets/Battle/HeroCardDatabase.cs +++ b/Assets/Battle/HeroCardDatabase.cs @@ -28,24 +28,6 @@ public enum HCardId { public class HeroCardDatabase : CardDatabase { - // TODO: Get rid of this and instead input who owns each card. - private static Dictionary CARD_TO_HERO = new Dictionary() { - {HCardId.CrashingPunch, HeroId.Brute}, - {HCardId.Cover, HeroId.Brute}, - {HCardId.LightningStrike, HeroId.Shaman}, - {HCardId.Scarring, HeroId.Brute}, - {HCardId.Thunderstorm, HeroId.Shaman}, - {HCardId.BlindFury, HeroId.Brute}, - {HCardId.Meditate, HeroId.Shaman}, - {HCardId.LightningHatchet, HeroId.Shaman}, - {HCardId.IronskinDraught, HeroId.Alchemist}, - {HCardId.SwordSlash, HeroId.NPCGuard}, - {HCardId.ShieldBlock, HeroId.NPCGuard}, - {HCardId.LeadShot, HeroId.Alchemist}, - {HCardId.SmokeBomb, HeroId.Alchemist}, - {HCardId.Eagerness, HeroId.Alchemist}, - }; - public override HeroCard CreateCard(int id, BattleParticipant owner) { HCardId heroCardId = (HCardId) id; switch (heroCardId) @@ -82,8 +64,4 @@ public class HeroCardDatabase : CardDatabase throw new System.ArgumentException("HCardId unknown", "id"); } } - - public static HeroId GetHeroIdOfCard(HCardId id) { - return CARD_TO_HERO[id]; - } } diff --git a/Assets/Party.meta b/Assets/Party.meta new file mode 100644 index 0000000..dc412a5 --- /dev/null +++ b/Assets/Party.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ca69790a0da44c64d98ba7318780c5a1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Party/PartyManager.cs b/Assets/Party/PartyManager.cs new file mode 100644 index 0000000..ec88231 --- /dev/null +++ b/Assets/Party/PartyManager.cs @@ -0,0 +1,36 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class PartyManager +{ + public static void SetupBattleParameters(BattleParameters parameters) { + HeroId[] heroIds = new HeroId[3] { + HeroId.Alchemist, + HeroId.NPCGuard, + HeroId.NPCGuard, + }; + + HCardId[] cardIds = new HCardId[11] { + HCardId.Eagerness, + HCardId.Eagerness, + HCardId.LeadShot, + HCardId.LeadShot, + HCardId.SmokeBomb, + HCardId.Eagerness, + HCardId.SwordSlash, + HCardId.ShieldBlock, + HCardId.Eagerness, + HCardId.SwordSlash, + HCardId.ShieldBlock, + }; + + int[] cardOwnerIndexes = new int[11] { + 0, 0, 0, 0, 0, + 1, 1, 1, + 2, 2, 2, + }; + + parameters.SetHeroes(heroIds, cardIds, cardOwnerIndexes); + } +} diff --git a/Assets/Party/PartyManager.cs.meta b/Assets/Party/PartyManager.cs.meta new file mode 100644 index 0000000..a682645 --- /dev/null +++ b/Assets/Party/PartyManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a10ced1b94393234ab9065b74abb8b9e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Story/Scenes/Scene_Chapter1_Cave.cs b/Assets/Story/Scenes/Scene_Chapter1_Cave.cs index aeb8320..37825da 100644 --- a/Assets/Story/Scenes/Scene_Chapter1_Cave.cs +++ b/Assets/Story/Scenes/Scene_Chapter1_Cave.cs @@ -14,6 +14,8 @@ public class Scene_Chapter1_Cave: StoryScene private BattleParameters BuildBattleGolemBats() { BattleParameters battleParameters = new BattleParameters(); + PartyManager.SetupBattleParameters(battleParameters); + MonsterId[] monsterIds = new MonsterId[3] { MonsterId.Golem, MonsterId.Bat, diff --git a/TODO.txt b/TODO.txt index b769aed..377aa53 100644 --- a/TODO.txt +++ b/TODO.txt @@ -3,6 +3,5 @@ - Show which cards enemies will use - Show on who enemies will use the cards - Extend BattleState to be more than hero turn true/false -- Create BattleParameters - Highlight which card is targeting - Allow cancelling targeting \ No newline at end of file