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())) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue