public void Modify(int amount)
    {
        m_currentHealth += amount;

        Mathf.Clamp(m_currentHealth, 0, m_maxHealth);

        if (amount < 0)
        {
            if (OnTakeDamage != null)
            {
                OnTakeDamage.Invoke();
            }
        }
        else if (amount > 0)
        {
            if (OnHeal != null)
            {
                OnHeal.Invoke();
            }
        }
        else
        {
            Debug.Log("Modify called with 0");
        }

        if (OnValueChange != null)
        {
            OnValueChange.Invoke(PercentHealth);
        }

        if (m_currentHealth <= 0 && OnDeath != null)
        {
            OnDeath.Invoke();
        }
    }
Esempio n. 2
0
        /// <summary>
        /// Apply a delta health object to this controller
        /// </summary>
        /// <param name="dHealth"></param>
        public void ApplyDeltaHealth(DeltaHealth dHealth)
        {
            float delta = dHealth.GetDelta(this);

            health += delta;

            if (maxHealth >= 0f)
            {
                health = Mathf.Max(maxHealth, health);
            }

            if (health <= 0f)
            {
                OnDeath(this, dHealth);
            }

            if (delta != 0f)
            {
                OnDelta?.Invoke(this, dHealth);
            }
            if (delta > 0f)
            {
                OnHeal?.Invoke(this, dHealth);
            }
            else if (delta < 0f)
            {
                OnHurt?.Invoke(this, dHealth);
            }
        }
Esempio n. 3
0
    public void Heal(int amount)
    {
        int effectiveAmount = maxHealth - (currentHealth + amount) + amount;

        currentHealth += effectiveAmount;

        OnHeal?.Invoke(amount, effectiveAmount);
    }
Esempio n. 4
0
        public void Heal(float healing)
        {
            HP += healing;

            HP = HP > MaxHP ? MaxHP : HP;

            OnHeal.Invoke();
        }
Esempio n. 5
0
 public virtual void Healt(float amount)
 {
     this.amount += amount;
     if (this.amount > 100)
     {
         this.amount = 100;
     }
     OnHeal?.Invoke();
 }
Esempio n. 6
0
 public void Heal(float _amount)
 {
     CurrentHealthPoints += _amount;
     if (CurrentHealthPoints > MaxHealthPoints)
     {
         CurrentHealthPoints = MaxHealthPoints;
     }
     OnHeal?.Invoke(ID, CurrentHealthPoints);
 }
Esempio n. 7
0
    public void Fill(bool invokeEvents = true)
    {
        int prev = Current;

        Current = Max;
        Debug.Log($"Heals {Current - prev} health | Before: {prev} | After: {Current}.");

        OnHeal?.Invoke(prev, Current);
        OnChanged?.Invoke(prev, Current);
    }
Esempio n. 8
0
    public void Heal(int amount)
    {
        int prev = Current;

        Current = Mathf.Clamp(Current + amount, 0, Max);
        Debug.Log($"Heals {amount} health | Before: {prev} | After: {Current}.");

        OnHeal?.Invoke(prev, Current);
        OnChanged?.Invoke(prev, Current);
    }
Esempio n. 9
0
    public void TakeHealing(float proposedAmount, Monster source)
    {
        var actualHealing = (int)proposedAmount;

        Health += actualHealing;
        OnHeal?.Invoke(this, new OnHealEventArgs()
        {
            HealAmount = actualHealing, RemainingHealth = Health, DamageSource = source
        });
    }
Esempio n. 10
0
    /// <summary>
    /// Makes this object be healed and restore its health.
    /// </summary>
    /// <param name="_heal">Amount of health point to restore.</param>
    public virtual void Heal(int _heal)
    {
        if (PhotonNetwork.isMasterClient)
        {
            TDS_RPCManager.Instance?.RPCPhotonView.RPC("CallMethodOnline", PhotonTargets.Others, TDS_RPCManager.GetInfo(photonView, this.GetType(), "Heal"), new object[] { _heal });
        }

        HealthCurrent += _heal;
        OnHeal?.Invoke(_heal);
    }
Esempio n. 11
0
        public void RestoreHealth(int health)
        {
            CurrentHealth += health;
            if (CurrentHealth > maxHealth)
            {
                CurrentHealth = maxHealth;
            }

            OnHeal?.Invoke(this, health);
            OnHealthChanged?.Invoke(this);
        }
Esempio n. 12
0
            private static int OnApplyHeal(void *pEffectListHandler, void *pObject, void *pGameEffect, int bLoadingGame)
            {
                CGameEffect gameEffect = CGameEffect.FromPointer(pGameEffect);
                CNWSObject  target     = CNWSObject.FromPointer(pObject);

                OnHeal eventData = ProcessEvent(new OnHeal
                {
                    Healer     = gameEffect.m_oidCreator.ToNwObject <NwObject>() !,
                    Target     = target.ToNwObject <NwGameObject>() !,
                    HealAmount = gameEffect.GetInteger(0),
                });
Esempio n. 13
0
        public void Heal(Character targetCharacter, int amount)
        {
            var hpBeforeHeal = targetCharacter.HealthPoints.Value;

            targetCharacter.HealthPoints.Value += amount;
            var hpAfterHeal = targetCharacter.HealthPoints.Value;
            var diff        = hpAfterHeal - hpBeforeHeal;

            MessageLogger.Log(targetCharacter != this
                                ? $"{this.FormattedFirstName()} ulecza {targetCharacter.FormattedFirstName()} o <color=blue><b>{diff}</b></color> punktów życia!"
                                : $"{this.FormattedFirstName()} ulecza się o <color=blue><b>{diff}</b></color> punktów życia!");
            OnHeal?.Invoke(targetCharacter, diff);
        }
Esempio n. 14
0
    public void Heal(CreatureStats from, CreatureStats to, int number)
    {
        int newHP = to.HP + number;

        if (newHP > to.maxHP)
        {
            to.HP = to.maxHP;
        }
        else
        {
            to.HP = newHP;
        }
        OnHeal?.Invoke(to, number);
    }
Esempio n. 15
0
 public void Heal(float health)
 {
     Lost -= health;
     OnHeal?.Invoke();
     if (Lost <= 0f)
     {
         Lost = 0f;
         if (!IsAlive)
         {
             IsAlive = true;
             OnRevive?.Invoke();
         }
     }
 }
Esempio n. 16
0
        public bool Heal(int amount, ISource _source)
        {
            if (IsDead)
            {
                Debug.Log($"Health is dead"); return(false);
            }

            Resource.Gain(amount, _source);
            OnHeal?.Invoke(amount, _source);
            if (Resource.Current <= 0)
            {
                Die();
            }
            return(true);
        }
Esempio n. 17
0
    public void Heal(int amount)
    {
        if (amount == -1)
        {
            amount = MaxHitPoints - CurrentHitPoints;
        }


        if (CurrentHitPoints < MaxHitPoints)
        {
            amount = Math.Min(amount, MaxHitPoints - CurrentHitPoints);
            OnHeal?.Invoke(amount);
            CurrentHitPoints += amount;
            Grid.instance.EnqueueEvent(new GameEvent(GameEvent.EventType.HEAL, this));
        }
    }
Esempio n. 18
0
        public void Heal(IHealingSource source)
        {
            if (source == null)
            {
                return;
            }

            float healing = Mathf.Abs(source.BaseHealing);

            foreach (var modifier in _healingModifiers)
            {
                healing = modifier(source, healing);
            }

            HandleHealing(source, healing);
            OnHeal.SafeInvoke(source, healing);
        }
Esempio n. 19
0
 /// <summary>
 /// Heal the player and so increases his life
 /// </summary>
 /// <param name="_healValue">Value of the health to heal (Increase value)</param>
 protected virtual void Heal(int _healValue)
 {
     Health += _healValue;
     OnHeal?.Invoke();
 }
        public void Parse(long timestamp, List <string> args)
        {
            if (BasicCombatlogEntry.TryParse(args, out BasicCombatlogEntry entry))
            {
                AmeisenLogger.I.Log("CombatLogParser", $"[{timestamp}] Parsing CombatLog: {JsonSerializer.Serialize(args)}", LogLevel.Verbose);

                switch (entry.Type)
                {
                case CombatlogEntryType.PARTY:
                    switch (entry.Subtype)
                    {
                    case CombatlogEntrySubtype.KILL:
                        AmeisenLogger.I.Log("CombatLogParser", $"OnPartyKill({entry.SourceGuid}, {entry.DestinationGuid})");
                        OnPartyKill?.Invoke(entry.SourceGuid, entry.DestinationGuid);
                        break;
                    }
                    break;

                case CombatlogEntryType.UNIT:
                    switch (entry.Subtype)
                    {
                    case CombatlogEntrySubtype.DIED:
                        AmeisenLogger.I.Log("CombatLogParser", $"OnUnitDied({entry.SourceGuid})");
                        OnUnitDied?.Invoke(entry.SourceGuid);
                        break;
                    }
                    break;

                case CombatlogEntryType.SWING:
                    switch (entry.Subtype)
                    {
                    case CombatlogEntrySubtype.DAMAGE:
                        if (int.TryParse(entry.Args[(int)CombatlogField.SwingDamageAmount], out int damage))
                        {
                            AmeisenLogger.I.Log("CombatLogParser", $"OnDamage({entry.SourceGuid}, {entry.DestinationGuid}, {entry.Args[(int)CombatlogField.SwingDamageAmount]})");
                            OnDamage?.Invoke(entry.SourceGuid, entry.DestinationGuid, -1, damage, 0);
                        }
                        break;
                    }
                    break;

                case CombatlogEntryType.SPELL:
                    switch (entry.Subtype)
                    {
                    case CombatlogEntrySubtype.DAMAGE:
                        if (int.TryParse(entry.Args[(int)CombatlogField.SpellAmount], out int spellAmount) &&
                            int.TryParse(entry.Args[(int)CombatlogField.SpellAmountOver], out int spellAmountOver) &&
                            int.TryParse(entry.Args[(int)CombatlogField.SpellSpellId], out int spellSpellId))
                        {
                            AmeisenLogger.I.Log("CombatLogParser", $"OnDamage({entry.SourceGuid}, {entry.DestinationGuid}, {entry.Args[(int)CombatlogField.SpellSpellId]}, {entry.Args[(int)CombatlogField.SpellAmount]}, {entry.Args[(int)CombatlogField.SpellAmountOver]})");
                            OnDamage?.Invoke(entry.SourceGuid, entry.DestinationGuid, spellSpellId, spellAmount, spellAmountOver);
                        }
                        break;

                    case CombatlogEntrySubtype.HEAL:
                        if (int.TryParse(entry.Args[(int)CombatlogField.SpellAmount], out int spellAmount2) &&
                            int.TryParse(entry.Args[(int)CombatlogField.SpellAmountOver], out int spellAmountOver2) &&
                            int.TryParse(entry.Args[(int)CombatlogField.SpellSpellId], out int spellSpellId2))
                        {
                            AmeisenLogger.I.Log("CombatLogParser", $"OnHeal({entry.SourceGuid}, {entry.DestinationGuid}, {entry.Args[(int)CombatlogField.SpellSpellId]}, {entry.Args[(int)CombatlogField.SpellAmount]}, {entry.Args[(int)CombatlogField.SpellAmountOver]})");
                            OnHeal?.Invoke(entry.SourceGuid, entry.DestinationGuid, spellSpellId2, spellAmount2, spellAmountOver2);
                        }
                        break;
                    }
                    break;
                }
            }
            else
            {
                AmeisenLogger.I.Log("CombatLogParser", $"Parsing failed: {JsonSerializer.Serialize(args)}", LogLevel.Warning);
            }
        }
Esempio n. 21
0
 public void Heal(float value)
 {
     health += value;
     OnHeal?.Invoke(gameObject, health - value, health);
 }
Esempio n. 22
0
 public void Heal()
 {
     OnHeal?.Invoke();
 }
 public void Heal(int amount)
 {
     OnHeal?.Invoke();
     _health += amount;
     _health  = _health > maxHealth ? maxHealth : _health;
 }
Esempio n. 24
0
 public void Heal(int value)
 {
     Hp += value;
     Hp  = Mathf.Min(Hp, MaxHp);
     OnHeal?.Invoke(this, value);
 }
 internal void OnHeal_Trigger(PlayerState player, int healthGain) => OnHeal?.Handle(args: new object[] { player, healthGain }, unique: true);