예제 #1
0
        /// <summary>
        /// Deals damage to the Entity, subtracting from its HP
        /// </summary
        /// <param name="affectableInfo">Contains the Entity and what it dealt damage with</param>
        /// <param name="damage">The amount of total damage dealt</param>
        /// <param name="damagetype">The type of damage dealt</param>
        /// <param name="element">The element of the damage</param>
        public void TakeDamage(AffectableInfo affectableInfo, int damage, DamageTypes damagetype, Elements element)
        {
            int totaldamage = CalculateDamageReceived(damage, damagetype, element);

            ModifyHP(CurHP - totaldamage);

            BattleUIManager.Instance.AddElement(new UIDamageTextDisplay(damagetype, element, .75f, totaldamage.ToString(),
                                                                        new Vector2f(Position.X, Position.Y - 50f), Globals.BASE_UI_LAYER + .6f));

            OnDamageReceived(affectableInfo, totaldamage, damagetype, element);
        }
예제 #2
0
        public override void UseEffect(AffectableInfo affectableInfo, params BattleEntity[] Entities)
        {
            for (int i = 0; i < Entities.Length; i++)
            {
                Entities[i].Restore(affectableInfo, HPRestored, MPRestored);

                Debug.Log($"Healed {Entities[i].Name} for {HPRestored} HP and {MPRestored} MP!");

                //Cure StatusEffects if this effect should cure any
                if (StatusesCured != null)
                {
                    Entities[i].CureStatuses(affectableInfo, StatusesCured);
                }
            }
        }
예제 #3
0
        //Battle-combat related methods
        /// <summary>
        /// Restores an Entity's HP and MP values by the given amount
        /// </summary>
        /// <param name="affectableInfo">Contains the Entity and what it restored HP/MP with</param>
        /// <param name="hp">The amount of HP to restore</param>
        /// <param name="mp">The amount of MP to restore</param>
        public void Restore(AffectableInfo affectableInfo, uint hp, uint mp)
        {
            ModifyHP(CurHP + (int)hp);
            ModifyMP(CurMP + (int)mp);

            if (hp != 0)
            {
                //Emerald green
                BattleUIManager.Instance.AddElement(new UIDamageTextDisplay(.75f, hp.ToString(),
                                                                            new Vector2f(Position.X, Position.Y - 50f), new Color(85, 212, 63, 255), Globals.BASE_UI_LAYER + .6f));
            }
            if (mp != 0)
            {
                //Turquoise-ish
                BattleUIManager.Instance.AddElement(new UIDamageTextDisplay(.75f, mp.ToString(),
                                                                            new Vector2f(Position.X, Position.Y - 50f), new Color(72, 241, 241, 255), Globals.BASE_UI_LAYER + .6f));
            }
        }
예제 #4
0
        public override void UseEffect(AffectableInfo affectableInfo, params BattleEntity[] Entities)
        {
            for (int i = 0; i < Entities.Length; i++)
            {
                uint hpRestored = (uint)(Entities[i].MaxHP * PercentageHP);
                uint mpRestored = (uint)(Entities[i].MaxMP * PercentageMP);

                Entities[i].Restore(affectableInfo, hpRestored, mpRestored);

                Debug.Log($"Healed {Entities[i].Name} for {hpRestored} HP and {mpRestored} MP!");

                //Cure StatusEffects if this effect should cure any
                if (StatusesCured != null)
                {
                    Entities[i].CureStatuses(affectableInfo, StatusesCured);
                }
            }
        }
 public override void UseEffect(AffectableInfo affectableInfo, params BattleEntity[] Entities)
 {
     if (Status != null)
     {
         for (int i = 0; i < Entities.Length; i++)
         {
             float percent = (float)Math.Round(Globals.Randomizer.NextDouble() * 100f);
             if (StatusPercent > percent)
             {
                 Entities[i].InflictStatus(affectableInfo, Status);
             }
         }
     }
     else
     {
         Debug.LogError($"Status for Spell {Name} by {affectableInfo.Affector.Name} is null!");
     }
 }
예제 #6
0
        /// <summary>
        /// Inflicts one or more StatusEffects on the entity
        /// </summary>
        /// <param name="affectableInfo">Contains the Entity and what it inflicted the statuses with</param>
        /// <param name="statuses">The StatusEffects to inflict on the entity</param>
        public void InflictStatus(AffectableInfo affectableInfo, params StatusEffect[] statuses)
        {
            //Don't inflict statuses if dead
            if (IsDead == true)
            {
                Debug.LogWarning($"Entity: {Name} is dead and cannot be inflicted with any StatusEffects!");
                return;
            }

            for (int i = 0; i < statuses.Length; i++)
            {
                StatusEffect status = statuses[i];

                if (status == null)
                {
                    Debug.LogError($"Status being inflicted on {Name} at index {i} is null!");
                    continue;
                }

                //Copy the status for a new reference
                status = statuses[i].Copy();

                Type statusType = status.GetType();

                if (AfflictedStatuses.ContainsKey(statusType))
                {
                    AfflictedStatuses[statusType].Refresh();
                    Debug.Log($"Refreshed status {AfflictedStatuses[statusType].Name} on {Name}!");
                }
                else
                {
                    status.StatusFinishedEvent += OnStatusFinished;
                    AfflictedStatuses.Add(statusType, status);
                    AfflictedStatuses[statusType].SetAfflicter(affectableInfo.Affector);
                    AfflictedStatuses[statusType].SetReceiver(this);
                    AfflictedStatuses[statusType].OnInflict();
                    Debug.Log($"Inflicted status {AfflictedStatuses[statusType].Name} on {Name}!");
                }
            }
        }
예제 #7
0
        /// <summary>
        /// Removes one or more StatusEffects on an entity.
        /// This method is the public one for use in curing StatusEffects via Items, Spells, and etc.
        /// </summary>
        /// <param name="affectableInfo">Contains the Entity and what it cured the StatusEffects with</param>
        /// <param name="statuses">The names of the StatusEffects to cure</param>
        public void CureStatuses(AffectableInfo affectableInfo, params Type[] statuses)
        {
            string curedstatuses = "Status Effects";

            if (statuses != null && statuses.Length > 0)
            {
                curedstatuses = string.Empty;
                if (statuses.Length == 1)
                {
                    curedstatuses = statuses[0].Name;
                }
                else
                {
                    for (int i = 0; i < statuses.Length; i++)
                    {
                        curedstatuses += (i == (statuses.Length - 1) ? "and " + statuses[i].Name : statuses[i].Name + ", ");
                    }
                }
            }

            Debug.Log($"{affectableInfo.Affector?.Name} cured {curedstatuses} on {Name} with {affectableInfo.AffectableObj?.Name}!");

            RemoveStatus(statuses);
        }
예제 #8
0
        public override void UseEffect(AffectableInfo affectableInfo, params BattleEntity[] Entities)
        {
            for (int i = 0; i < Entities.Length; i++)
            {
                int entityDamage = 0;
                if (BasedOnEntityDamage == true)
                {
                    entityDamage = affectableInfo.Affector.CalculateDamageDealt(DamageType, Element);
                }

                //Calculate damage and add this Effect's damage
                Entities[i].TakeDamage(affectableInfo, entityDamage + Damage, DamageType, Element);

                //If no Status (only damage), don't bother inflicting
                if (Status != null)
                {
                    float percent = (float)Math.Round(Randomizer.NextDouble() * 100f);
                    if (StatusPercent > percent)
                    {
                        Entities[i].InflictStatus(affectableInfo, Status);
                    }
                }
            }
        }
예제 #9
0
 /// <summary>
 /// What occurs when the Entity receives damage
 /// </summary
 /// <param name="affectableInfo">Contains the Entity and what it dealt damage with</param>
 /// <param name="totaldamage">The amount of total damage received</param>
 /// <param name="damagetype">The type of damage dealt</param>
 /// <param name="element">The element of the damage</param>
 public virtual void OnDamageReceived(AffectableInfo affectableInfo, int totaldamage, DamageTypes damagetype, Elements element)
 {
     Debug.Log($"{Name} received {totaldamage} damage!");
 }
예제 #10
0
        /// <summary>
        /// Drains MP from the Entity
        /// </summary>
        /// <param name="affectableInfo">Contains the Entity and what it drained MP with</param>
        /// <param name="mp">The total amount of MP to drain</param>
        public void DrainMP(AffectableInfo affectableInfo, int mp)
        {
            ModifyMP(CurMP - mp);

            Debug.Log($"{Name} was drained of {mp} MP!");
        }
예제 #11
0
 /// <summary>
 /// What happens to the entities when the EntityEffect is used on them
 /// </summary>
 /// <param name="affectableInfo">Contains the Entity and how it used the EntityEffect</param>
 /// <param name="Entities">The entities to use the EntityEffect on</param>
 public abstract void UseEffect(AffectableInfo affectableInfo, params BattleEntity[] Entities);