Move Heroes and Monster to BattleState
This commit is contained in:
parent
c2fc8b0904
commit
2e5a971581
2 changed files with 72 additions and 62 deletions
|
|
@ -3,9 +3,12 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class BattleState
|
||||
public class BattleState: MonsterViewpoint
|
||||
{
|
||||
private bool playedEmotion;
|
||||
|
||||
private BattleHero[] heroes;
|
||||
|
||||
private BattleMonster[] monsters;
|
||||
private BattleClock clock;
|
||||
private BuffManager buffManager;
|
||||
private EnergyPool heroEnergy;
|
||||
|
|
@ -15,9 +18,11 @@ public class BattleState
|
|||
private PlayArea playArea;
|
||||
private InsightLevel insightLevel;
|
||||
|
||||
private bool playedEmotion;
|
||||
|
||||
private int STARTING_INSIGHT = 3;
|
||||
|
||||
public BattleState() {
|
||||
public BattleState(BattleParameters parameters) {
|
||||
this.clock = new BattleClock();
|
||||
this.buffManager = new BuffManager(this.clock);
|
||||
this.heroEnergy = new EnergyPool();
|
||||
|
|
@ -25,6 +30,23 @@ public class BattleState
|
|||
this.playArea = new PlayArea();
|
||||
this.insightLevel = new InsightLevel(STARTING_INSIGHT);
|
||||
|
||||
this.heroes = new BattleHero[parameters.HeroIds.Length];
|
||||
for (int i = 0; i < this.heroes.Length; i++) {
|
||||
HeroId id = parameters.HeroIds[i];
|
||||
|
||||
BattleHero hero = new BattleHero(id);
|
||||
hero.Init();
|
||||
this.heroes[i] = hero;
|
||||
}
|
||||
|
||||
this.monsters = new BattleMonster[parameters.MonsterIds.Length];
|
||||
for (int i = 0; i < this.monsters.Length; i++) {
|
||||
MonsterId id = parameters.MonsterIds[i];
|
||||
|
||||
BattleMonster monster = MonsterDatabase.createMonsterScript(id);
|
||||
monster.Init();
|
||||
this.monsters[i] = monster;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetDecks(BattleDeck<HeroCard> heroDeck, BattleDeck<MonsterCard> monsterDeck) {
|
||||
|
|
@ -57,6 +79,27 @@ public class BattleState
|
|||
this.playedEmotion = false;
|
||||
}
|
||||
|
||||
public void MoveTeamToNewPositions(TeamChoice team, int[] newPositions) {
|
||||
int n = newPositions.Length;
|
||||
if (team == TeamChoice.Heroes) {
|
||||
BattleHero[] newHeroes = new BattleHero[n];
|
||||
for (int i = 0; i < n; i++) {
|
||||
BattleHero hero = this.heroes[i];
|
||||
newHeroes[newPositions[i]] = hero;
|
||||
}
|
||||
this.heroes = newHeroes;
|
||||
} else {
|
||||
BattleMonster[] newMonsters = new BattleMonster[n];
|
||||
for (int i = 0; i < n; i++) {
|
||||
BattleMonster monster = this.monsters[i];
|
||||
newMonsters[newPositions[i]] = monster;
|
||||
}
|
||||
this.monsters = newMonsters;
|
||||
}
|
||||
}
|
||||
|
||||
public BattleHero[] Heroes {get => this.heroes;}
|
||||
public BattleMonster[] Monsters {get => this.monsters;}
|
||||
public BattleClock Clock {get => this.clock;}
|
||||
public BuffManager BuffManager {get => this.buffManager;}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue