예제 #1
0
        protected override void OnUpdate()
        {
            //Heal then end immediately
            EntityHealed.HealHP(HPHeal);

            End();
        }
        protected override void OnEnd()
        {
            base.OnEnd();

            //Get revival data from the item
            IRevivalItem revivalData = RevivalItem as IRevivalItem;

            if (revivalData != null && revivalData.RevivalHPRestored > 0)
            {
                RevivedEntity.HealHP(revivalData.RevivalHPRestored);

                //Play the idle animation
                RevivedEntity.AnimManager.PlayAnimation(RevivedEntity.GetIdleAnim());

                //Remove the item
                //NOTE: For now just handle players and remove from the inventory - enemies will need to remove their held items
                Inventory.Instance.RemoveItem(RevivalItem);
            }
            else
            {
                Debug.LogError($"{RevivalItem.Name} does not implement {nameof(IRevivalItem)} or heals 0 or less HP, so the BattleEntity can't be revived!");
            }

            //Clear references
            RevivedEntity = null;
            RevivalItem   = null;
        }
예제 #3
0
        /// <summary>
        /// Heals a set of BattleEntities with this MoveAction.
        /// <para>Healing moves cannot miss.</para>
        /// </summary>
        /// <param name="healingData">The HealingData containing HP, FP, and more.</param>
        /// <param name="entities">The BattleEntities to heal.</param>
        public void PerformHeal(HealingData healingData, BattleEntity[] entities)
        {
            for (int i = 0; i < entities.Length; i++)
            {
                BattleEntity entityHealed = entities[i];

                //Heal HP and FP
                entityHealed.HealHP(healingData.HPHealed);
                entityHealed.HealFP(healingData.FPHealed);

                //Heal Status Effects
                StatusTypes[] statusesHealed = healingData.StatusEffectsHealed;
                if (statusesHealed != null)
                {
                    for (int j = 0; j < statusesHealed.Length; j++)
                    {
                        StatusTypes statusHealed = statusesHealed[j];

                        entityHealed.EntityProperties.RemoveStatus(statusHealed, true);
                    }
                }
            }
        }
예제 #4
0
        protected override void OnEnd()
        {
            base.OnEnd();

            //Remove the item over the BattleEntity's head
            if (RevivalItemShown != null)
            {
                RevivedEntity.BManager.battleUIManager.RemoveUIElement(RevivalItemShown);
                RevivalItemShown = null;
            }

            //Revive the BattleEntity only if it's currently in battle
            if (RevivedEntity.IsInBattle == true)
            {
                //Get revival data from the item
                IRevivalItem revivalData = RevivalItem as IRevivalItem;
                if (revivalData != null)
                {
                    //If the revival item heals 0 or fewer HP, log a warning
                    if (revivalData.RevivalHPRestored <= 0)
                    {
                        Debug.LogWarning($"{RevivalItem.Name} heals 0 or fewer HP, so {RevivedEntity.Name} won't actually be revived!");
                    }

                    //Heal HP
                    RevivedEntity.HealHP(revivalData.RevivalHPRestored);

                    //Play the idle animation
                    RevivedEntity.AnimManager.PlayAnimation(RevivedEntity.GetIdleAnim());

                    //Remove the item
                    //For players, remove it from the inventory
                    if (RevivedEntity.EntityType == Enumerations.EntityTypes.Player)
                    {
                        Inventory.Instance.RemoveItem(RevivalItem);
                    }
                    //It has to be an enemy, so remove its held item
                    else
                    {
                        BattleEnemy revivedEnemy = (BattleEnemy)RevivedEntity;
                        revivedEnemy.SetHeldCollectible(null);
                    }
                }
                else
                {
                    Debug.LogError($"{RevivalItem.Name} does not implement {nameof(IRevivalItem)}, so {RevivedEntity.Name} can't be revived!");
                }

                //Failsafe; handle a dead BattleEntity in the event the RevivalItem doesn't actually revive or heal
                if (RevivedEntity.IsDead == true)
                {
                    RevivedEntity.BManager.HandleEntityDeath(RevivedEntity);
                }
            }
            else
            {
                Debug.LogWarning($"{RevivedEntity.Name} isn't in battle and thus won't be revived!");
            }

            //Clear references
            RevivedEntity = null;
            RevivalItem   = null;
        }