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();
|
||||
|
||||
|
|
|
|||
24
Assets/Battle/BattleParameters.cs
Normal file
24
Assets/Battle/BattleParameters.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
public class BattleParameters {
|
||||
private MonsterId[] monsterIds;
|
||||
private MCardId[] mCardIds;
|
||||
private int[] mCardOwnerIndexes;
|
||||
|
||||
public BattleParameters() {
|
||||
|
||||
}
|
||||
|
||||
public void SetMonsters(MonsterId[] monsterIds, MCardId[] mCardIds, int[] mCardOwnerIndexes) {
|
||||
if (mCardIds.Length != mCardOwnerIndexes.Length) {
|
||||
throw new System.ArgumentException(
|
||||
"mCardIds and mCardOwnerIndexes need to have the same length");
|
||||
}
|
||||
|
||||
this.monsterIds = monsterIds;
|
||||
this.mCardIds = mCardIds;
|
||||
this.mCardOwnerIndexes = mCardOwnerIndexes;
|
||||
}
|
||||
|
||||
public MonsterId[] MonsterIds {get => this.monsterIds;}
|
||||
public MCardId[] MCardIds {get => this.mCardIds;}
|
||||
public int[] MCardOwnerIndexes {get => this.mCardOwnerIndexes;}
|
||||
}
|
||||
11
Assets/Battle/BattleParameters.cs.meta
Normal file
11
Assets/Battle/BattleParameters.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 27e7d9637e99afb46ab6521f276bcdbd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
16
Assets/Battle/BattleSetup.cs
Normal file
16
Assets/Battle/BattleSetup.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class BattleSetup {
|
||||
private static BattleParameters sParameters;
|
||||
|
||||
public static void StartBattle(BattleParameters parameters) {
|
||||
sParameters = parameters;
|
||||
SceneManager.LoadScene("BattleScene");
|
||||
}
|
||||
|
||||
public static BattleParameters RetrieveParameters() {
|
||||
BattleParameters result = sParameters;
|
||||
sParameters = null;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
11
Assets/Battle/BattleSetup.cs.meta
Normal file
11
Assets/Battle/BattleSetup.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d20269def60ce9b418f46f701f6eba0e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Add table
Add a link
Reference in a new issue