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(); }
public SkyGuy() { Name = "Sky Guy"; AIBehavior = new SkyGuyAI(this); WingedBehavior = new SkyGuyWingedBehavior(this); ChangeHeightState(Enumerations.HeightStates.Airborne); EntityProperties.AddStatusProperty(Enumerations.StatusTypes.Sleep, new StatusPropertyHolder(70d, 0)); EntityProperties.AddStatusProperty(Enumerations.StatusTypes.Stop, new StatusPropertyHolder(90d, 0)); EntityProperties.AddStatusProperty(Enumerations.StatusTypes.Dizzy, new StatusPropertyHolder(90d, 1)); EntityProperties.AddStatusProperty(Enumerations.StatusTypes.Fright, new StatusPropertyHolder(80d, 0)); EntityProperties.AddStatusProperty(Enumerations.StatusTypes.Paralyzed, new StatusPropertyHolder(90d, 1)); EntityProperties.AddStatusProperty(Enumerations.StatusTypes.Tiny, new StatusPropertyHolder(75d, 0)); EntityProperties.AddStatusProperty(Enumerations.StatusTypes.Lifted, new StatusPropertyHolder(90d, 0)); EntityProperties.AddStatusProperty(Enumerations.StatusTypes.Blown, new StatusPropertyHolder(90d, 0)); LoadAnimations(); //Create the Balloon Balloon = new SkyGuyBalloon(Layer - .0001f); //Mark that the Balloon is a helper for the Sky Guy Balloon.EntityProperties.AddAdditionalProperty(Enumerations.AdditionalProperty.HelperEntity, this); //Subscribe to see when the Balloon's dies Balloon.HealthStateChangedEvent -= OnBalloonHealthStateChanged; Balloon.HealthStateChangedEvent += OnBalloonHealthStateChanged; //See when it changes battle; we need this to remove the Balloon from the previous battle ChangedBattleManagerEvent -= OnBattleChanged; ChangedBattleManagerEvent += OnBattleChanged; }