Add heroes to BattleParameters
This commit is contained in:
parent
84782a9bb3
commit
ba0252298c
10 changed files with 155 additions and 105 deletions
|
|
@ -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<BattleHero, GameObject>();
|
||||
this.heroUIs = new Dictionary<BattleHero, HeroInfoUI>();
|
||||
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<HeroCard>(
|
||||
this.heroCardDatabase, cardIds.Cast<int>().ToArray(), cardOwners);
|
||||
this.heroCardDatabase, parameters.HCardIds.Cast<int>().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())) {
|
||||
|
|
|
|||
|
|
@ -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;}
|
||||
|
|
|
|||
61
Assets/Battle/DebugBattle.cs
Normal file
61
Assets/Battle/DebugBattle.cs
Normal file
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
11
Assets/Battle/DebugBattle.cs.meta
Normal file
11
Assets/Battle/DebugBattle.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1d71d39191f1f0d48b2763622aed3a2b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -28,24 +28,6 @@ public enum HCardId {
|
|||
|
||||
public class HeroCardDatabase : CardDatabase<HeroCard>
|
||||
{
|
||||
// TODO: Get rid of this and instead input who owns each card.
|
||||
private static Dictionary<HCardId, HeroId> CARD_TO_HERO = new Dictionary<HCardId, HeroId>() {
|
||||
{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<HeroCard>
|
|||
throw new System.ArgumentException("HCardId unknown", "id");
|
||||
}
|
||||
}
|
||||
|
||||
public static HeroId GetHeroIdOfCard(HCardId id) {
|
||||
return CARD_TO_HERO[id];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
8
Assets/Party.meta
Normal file
8
Assets/Party.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ca69790a0da44c64d98ba7318780c5a1
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
36
Assets/Party/PartyManager.cs
Normal file
36
Assets/Party/PartyManager.cs
Normal file
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
11
Assets/Party/PartyManager.cs.meta
Normal file
11
Assets/Party/PartyManager.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a10ced1b94393234ab9065b74abb8b9e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
1
TODO.txt
1
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue