Create basic Story classes and parameterize monsters in Battle scene
This commit is contained in:
parent
6181a7d50c
commit
0d7f4f4954
17 changed files with 268 additions and 48 deletions
|
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffectResolver, MonsterViewpoint
|
||||
{
|
||||
|
|
@ -39,6 +40,39 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
private event BattleStateChangedAction OnBattleStateChanged;
|
||||
|
||||
void Awake() {
|
||||
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);
|
||||
}
|
||||
|
||||
HeroId[] heroIds = new HeroId[3] {
|
||||
HeroId.Alchemist,
|
||||
HeroId.NPCGuard,
|
||||
|
|
@ -78,43 +112,6 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
// HCardId.IronskinDraught,
|
||||
// };
|
||||
|
||||
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,
|
||||
};
|
||||
// MCardId[] mCardIds = new MCardId[5] {
|
||||
// MCardId.Whirlwind,
|
||||
// MCardId.Whirlwind,
|
||||
// MCardId.Whirlwind,
|
||||
// MCardId.Whirlwind,
|
||||
// MCardId.Whirlwind,
|
||||
// };
|
||||
// int[] mCardOwnerIndexes = new int[5] {
|
||||
// 1, 1,
|
||||
// 2, 2, 2,
|
||||
// };
|
||||
|
||||
this.heroCardDatabase = new HeroCardDatabase();
|
||||
this.monsterCardDatabase = new MonsterCardDatabase();
|
||||
|
||||
|
|
@ -154,11 +151,11 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
this.heroUIs[hero] = heroUI;
|
||||
}
|
||||
|
||||
this.monsters = new BattleMonster[monsterIds.Length];
|
||||
this.monsters = new BattleMonster[parameters.MonsterIds.Length];
|
||||
this.monsterSprites = new Dictionary<BattleMonster, GameObject>();
|
||||
this.monsterUIs = new Dictionary<BattleMonster, HeroInfoUI>();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
MonsterId id = monsterIds[i];
|
||||
MonsterId id = parameters.MonsterIds[i];
|
||||
|
||||
BattleMonster monster = MonsterDatabase.createMonsterScript(id);
|
||||
monster.Init();
|
||||
|
|
@ -186,16 +183,12 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
this.heroDeck = new BattleDeck<HeroCard>(
|
||||
this.heroCardDatabase, cardIds.Cast<int>().ToArray(), cardOwners);
|
||||
|
||||
BattleParticipant[] mCardOwners = new BattleParticipant[mCardIds.Length];
|
||||
if (mCardIds.Length != mCardOwnerIndexes.Length) {
|
||||
throw new System.ArgumentException(
|
||||
"mCardIds and mCardOwnerIndexes need to have the same length");
|
||||
}
|
||||
for (int i = 0; i < mCardIds.Length; i++) {
|
||||
mCardOwners[i] = this.monsters[mCardOwnerIndexes[i]];
|
||||
BattleParticipant[] mCardOwners = new BattleParticipant[parameters.MCardIds.Length];
|
||||
for (int i = 0; i < parameters.MCardIds.Length; i++) {
|
||||
mCardOwners[i] = this.monsters[parameters.MCardOwnerIndexes[i]];
|
||||
}
|
||||
this.monsterDeck = new BattleDeck<MonsterCard>(
|
||||
this.monsterCardDatabase, mCardIds.Cast<int>().ToArray(), mCardOwners);
|
||||
this.monsterCardDatabase, parameters.MCardIds.Cast<int>().ToArray(), mCardOwners);
|
||||
|
||||
this.playArea = new PlayArea();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue