BattleSprites now observes hero and monster positions
This commit is contained in:
parent
2e5a971581
commit
6aa13cdbb7
3 changed files with 30 additions and 15 deletions
|
|
@ -5,6 +5,9 @@ using UnityEngine;
|
|||
|
||||
public class BattleState: MonsterViewpoint
|
||||
{
|
||||
public delegate void Procedure();
|
||||
public event Procedure OnHeroPositionsSet;
|
||||
public event Procedure OnMonsterPositionsSet;
|
||||
|
||||
private BattleHero[] heroes;
|
||||
|
||||
|
|
@ -88,6 +91,7 @@ public class BattleState: MonsterViewpoint
|
|||
newHeroes[newPositions[i]] = hero;
|
||||
}
|
||||
this.heroes = newHeroes;
|
||||
TriggerOnHeroPositionsSet();
|
||||
} else {
|
||||
BattleMonster[] newMonsters = new BattleMonster[n];
|
||||
for (int i = 0; i < n; i++) {
|
||||
|
|
@ -95,9 +99,18 @@ public class BattleState: MonsterViewpoint
|
|||
newMonsters[newPositions[i]] = monster;
|
||||
}
|
||||
this.monsters = newMonsters;
|
||||
TriggerOnMonsterPositionsSet();
|
||||
}
|
||||
}
|
||||
|
||||
private void TriggerOnHeroPositionsSet() {
|
||||
if (OnHeroPositionsSet != null) OnHeroPositionsSet();
|
||||
}
|
||||
|
||||
private void TriggerOnMonsterPositionsSet() {
|
||||
if (OnMonsterPositionsSet != null) OnMonsterPositionsSet();
|
||||
}
|
||||
|
||||
public BattleHero[] Heroes {get => this.heroes;}
|
||||
public BattleMonster[] Monsters {get => this.monsters;}
|
||||
public BattleClock Clock {get => this.clock;}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue