public virtual void HandleGrounded() { //Return if already grounded if (Grounded == true) { return; } Grounded = true; //Check if the winged entity and its grounded version have entries in the Tattle database bool wingedInTattle = TattleDatabase.HasTattleDescription(Entity.Name); bool groundedInTattle = TattleDatabase.HasTattleDescription(GroundedEntity?.Name); //If the winged entity has an entry and the grounded version doesn't, remove its ShowHP property if (wingedInTattle == true && groundedInTattle == false) { Entity.SubtractShowHPProperty(); } //If the winged entity doesn't have an entry and the grounded version does, add its ShowHP property else if (wingedInTattle == false && groundedInTattle == true) { Entity.AddShowHPProperty(); } if (GroundedEntity != null) { Entity.Name = GroundedEntity.Name; //Set the vulnerability to the same as the grounded entity. The grounded entity shouldn't have a winged vulnerabilty Entity.EntityProperties.SetVulnerableDamageEffects(GroundedEntity.EntityProperties.GetVulnerableDamageEffects()); } //Change HeightState Entity.ChangeHeightState(Enumerations.HeightStates.Grounded); //Queue the BattleEvent to move the entity down BattleManager.Instance.battleEventManager.QueueBattleEvent((int)BattleGlobals.BattleEventPriorities.Damage - 1, new BattleManager.BattleState[] { BattleManager.BattleState.Turn, BattleManager.BattleState.TurnEnd }, new GroundedBattleEvent(Entity, new Vector2(Entity.BattlePosition.X, BattleManager.Instance.EnemyStartPos.Y))); //Queue the BattleEvent to remove the wings BattleManager.Instance.battleEventManager.QueueBattleEvent((int)BattleGlobals.BattleEventPriorities.Damage - 1, new BattleManager.BattleState[] { BattleManager.BattleState.Turn, BattleManager.BattleState.TurnEnd }, new RemoveWingsBattleEvent(this, Entity)); //Remove the damage event, since we don't need it anymore Entity.DamageTakenEvent -= OnDamageTaken; }
protected override void OnEnd() { base.OnEnd(); Entity.SetBattlePosition(GroundedPos); Entity.Position = GroundedPos; //Change HeightState Entity.ChangeHeightState(Enumerations.HeightStates.Grounded); if (Entity.IsDead == false) { Entity.AnimManager.PlayAnimation(Entity.GetIdleAnim()); } ElapsedTime = 0f; StartPos = GroundedPos = Vector2.Zero; HurtAnim = null; Entity = null; }