void OnUnitDied(DeathEventInfo deathEventInfo) { Debug.Log("BattlefieldController Alerted to Character Death: " + deathEventInfo.UnitGO.name); // Find UnitSlot by CharacterGO, // Reset slot back to unoccupied GameObject unitSlot = FindSlotFromCharacter(deathEventInfo.UnitGO); if (unitSlot != null) { unitSlot.GetComponent <UnitSlot>().SetIsOccupied(false); } // If dead unit was an enemy, check how many enemies are left(unoccupied slots), if none we win if (deathEventInfo.UnitGO.GetComponent <Character>().GetTeam == TeamName.Enemy) { if (FindUnoccupiedEnemySlotCount() >= (rows * columns)) { // All enemies are dead, the player has won the battle BattleWonEventInfo bwei = new BattleWonEventInfo(); bwei.EventDescription = "The player has won the battle"; bwei.FireEvent(); } } }
void OnBattleWon(BattleWonEventInfo battleWonEventInfo) { Debug.Log("BattleUIController Alerted to Hero Death!"); // Close all existing windows ActionPanel.SetActive(false); MenuPanel.SetActive(false); // Open Victory Window VictoryPanel.SetActive(true); VictoryPanel.GetComponentInChildren <Button>().onClick.AddListener(VictoryButtonPressed); }
public void UnregisterEventCallbacks() { SelectedObjectEventInfo.UnregisterListener(OnHighlightSelected); CharacterReadyEventInfo.UnregisterListener(OnCharacterReady); BattleWonEventInfo.UnregisterListener(OnBattleWon); HPChangedEventInfo.UnregisterListener(OnHPChange); MPChangedEventInfo.UnregisterListener(OnMPChange); HeroDeathEventInfo.UnregisterListener(OnHeroDeath); DeathEventInfo.UnregisterListener(OnUnitDied); UnitSpawnEventInfo.UnregisterListener(OnUnitSpawn); }