Remove hero/monster CardDatabase from BattleController
This commit is contained in:
parent
db92332783
commit
04d00ebede
2 changed files with 20 additions and 26 deletions
|
|
@ -16,9 +16,6 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
public BattleSprites battleSprites;
|
||||
|
||||
// Private
|
||||
private HeroCardDatabase heroCardDatabase;
|
||||
private MonsterCardDatabase monsterCardDatabase;
|
||||
|
||||
private BattleState state;
|
||||
private HandPlayability<HeroCard> heroHandPlayability;
|
||||
private HandPlayability<MonsterCard> monsterHandPlayability;
|
||||
|
|
@ -35,9 +32,6 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
parameters = CheatBattle.CreateParameters();
|
||||
}
|
||||
|
||||
this.heroCardDatabase = new HeroCardDatabase();
|
||||
this.monsterCardDatabase = new MonsterCardDatabase();
|
||||
|
||||
this.state = new BattleState(parameters);
|
||||
|
||||
this.heroEnergyUI.Init(this.state.HeroEnergy);
|
||||
|
|
@ -45,20 +39,6 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
|
||||
this.battleSprites.Init(this.state.Heroes, this.state.Monsters, this.state);
|
||||
|
||||
BattleParticipant[] cardOwners = new BattleParticipant[parameters.HCardIds.Length];
|
||||
for (int i = 0; i < parameters.HCardIds.Length; i++) {
|
||||
cardOwners[i] = this.state.Heroes[parameters.HCardOwnerIndexes[i]];
|
||||
}
|
||||
BattleDeck<HeroCard> heroDeck = new BattleDeck<HeroCard>(
|
||||
this.heroCardDatabase, parameters.HCardIds.Cast<int>().ToArray(), cardOwners);
|
||||
|
||||
BattleParticipant[] mCardOwners = new BattleParticipant[parameters.MCardIds.Length];
|
||||
for (int i = 0; i < parameters.MCardIds.Length; i++) {
|
||||
mCardOwners[i] = this.state.Monsters[parameters.MCardOwnerIndexes[i]];
|
||||
}
|
||||
BattleDeck<MonsterCard> monsterDeck = new BattleDeck<MonsterCard>(
|
||||
this.monsterCardDatabase, parameters.MCardIds.Cast<int>().ToArray(), mCardOwners);
|
||||
this.state.SetDecks(heroDeck, monsterDeck);
|
||||
this.participantActivity = new ParticipantActivity();
|
||||
|
||||
this.heroHandPlayability = new HandPlayability<HeroCard>(
|
||||
|
|
@ -397,9 +377,9 @@ public class BattleController : MonoBehaviour, IBattleEffectApplier, IBattleEffe
|
|||
if (effect.Participant == null) return;
|
||||
|
||||
if (effect.Participant.Team == TeamChoice.Heroes) {
|
||||
this.AcquireCardsTyped(effect, this.state.HeroDeck, this.heroCardDatabase);
|
||||
this.AcquireCardsTyped(effect, this.state.HeroDeck, new HeroCardDatabase());
|
||||
} else {
|
||||
this.AcquireCardsTyped(effect, this.state.MonsterDeck, this.monsterCardDatabase);
|
||||
this.AcquireCardsTyped(effect, this.state.MonsterDeck, new MonsterCardDatabase());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
public class BattleState: MonsterViewpoint
|
||||
|
|
@ -35,6 +36,10 @@ public class BattleState: MonsterViewpoint
|
|||
this.playArea = new PlayArea();
|
||||
this.insightLevel = new InsightLevel(STARTING_INSIGHT);
|
||||
|
||||
InitHeroesAndMonsters(parameters);
|
||||
}
|
||||
|
||||
private void InitHeroesAndMonsters(BattleParameters parameters) {
|
||||
this.heroes = new BattleHero[parameters.HeroIds.Length];
|
||||
for (int i = 0; i < this.heroes.Length; i++) {
|
||||
HeroId id = parameters.HeroIds[i];
|
||||
|
|
@ -52,11 +57,20 @@ public class BattleState: MonsterViewpoint
|
|||
monster.Init();
|
||||
this.monsters[i] = monster;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetDecks(BattleDeck<HeroCard> heroDeck, BattleDeck<MonsterCard> monsterDeck) {
|
||||
this.heroDeck = heroDeck;
|
||||
this.monsterDeck = monsterDeck;
|
||||
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>(
|
||||
new HeroCardDatabase(), parameters.HCardIds.Cast<int>().ToArray(), cardOwners);
|
||||
|
||||
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>(
|
||||
new MonsterCardDatabase(), parameters.MCardIds.Cast<int>().ToArray(), mCardOwners);
|
||||
}
|
||||
|
||||
public bool IsTeamsTurnToPlay(TeamChoice team) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue