public override void CleanUp() { ChangedBattleManagerEvent -= OnBattleChanged; if (Balloon != null) { Balloon.HealthStateChangedEvent -= OnBalloonHealthStateChanged; //Remove the balloon from battle if it's not dead if (Balloon.IsDead == false) { //Remove the balloon from the SkyGuy's current battle if (IsInBattle == true) { BManager.RemoveEntity(Balloon, true); } //Kill off the balloon Balloon.Die(); } Balloon = null; } base.CleanUp(); WingedBehavior?.CleanUp(); }
private void OnBalloonHealthStateChanged(Enumerations.HealthStates newHealthState) { //If the Balloon dies, unsubscribe from the event and ground the Sky Guy if (newHealthState == Enumerations.HealthStates.Dead) { Balloon.HealthStateChangedEvent -= OnBalloonHealthStateChanged; ChangedBattleManagerEvent -= OnBattleChanged; //If the Sky Guy is already dead, don't handle grounding it if (IsDead == false) { WingedBehavior.HandleGrounded(); } //Set to null since we don't need the Balloon anymore Balloon = null; } }