void OnUnitDied(DeathEventInfo deathEventInfo) { Debug.Log("CombatManager Alerted to Character Death: " + deathEventInfo.UnitGO.name); if (deathEventInfo.TeamName == TeamName.Friendly) { // Dead character is freindly // Update Dictionary of player charcters RemoveFromPlayerCharacterList(deathEventInfo.UnitGO); // Update Characater status if (playerMonsterinfoList.ContainsKey(deathEventInfo.UnitGO.name)) { playerMonsterinfoList[deathEventInfo.UnitGO.name].IsSummoned = false; playerMonsterinfoList[deathEventInfo.UnitGO.name].IsDead = true; } } else if (deathEventInfo.TeamName == TeamName.Enemy) { // Dead charcter in an enemy // Update Dictionary of enemy charcters RemoveFromEnemyCharacterList(deathEventInfo.UnitGO); } // Remove from charcter Order List RemoveFromCharacterTurnOrder(deathEventInfo.UnitGO); // Remove object Destroy(deathEventInfo.UnitGO); }
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 UnregisterEventCallbacks() { DeathEventInfo.UnregisterListener(OnUnitDied); HPChangedEventInfo.UnregisterListener(OnHPChange); MPChangedEventInfo.UnregisterListener(OnMPChange); UnitSpawnEventInfo.UnregisterListener(OnUnitSpawn); CharacterTurnOverEventInfo.UnregisterListener(OnTurnOver); }
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); }
void OnUnitDied(DeathEventInfo deathEventInfo) { Debug.Log("BattleUIController Alerted to Character Death: " + deathEventInfo.UnitGO.name); // check if chacter that died is the currently selected character, // if so, the 'abilityState' must return to character select if (deathEventInfo.UnitGO == SelectedCharacter) { TransferAbilityState(abilityState, AbilityState.CharcterSelect); } // Update UI // TODO... ReThink // I HATE this GameObject.Destroy(GameObject.Find(deathEventInfo.TeamName + "_" + deathEventInfo.UnitGO.GetComponent <Character>().GetUniqueID + "_Panel")); }
public void UnregisterEventCallbacks() { UnitSpawnEventInfo.UnregisterListener(OnUnitSpawn); DeathEventInfo.UnregisterListener(OnUnitDied); }
void RegisterEventCallbacks() { UnitSpawnEventInfo.RegisterListener(OnUnitSpawn); DeathEventInfo.RegisterListener(OnUnitDied); }