Пример #1
0
    public void ModifyHealth(int amount, Stats.DamageType damageType)
    {
        if (amount >= 0)
        {
            currentHealth += amount;
        }
        else
        {
            if (!isImmortal && !isInvinsible)
            {
                currentHealth += amount;
            }
        }

        currentHealth = Mathf.Clamp(currentHealth, 0, GetMaxHealth());
        OnHealthModified(new HealthData
        {
            currentHealth       = currentHealth,
            maxHealth           = GetMaxHealth(),
            percentageHealth    = GetHealthPercentage(),
            amountHealthChanged = amount,
            isInvinsible        = isInvinsible,
            damageType          = damageType
        });

        if (currentHealth <= 0 && !isDead)
        {
            isDead = true;
            myEntity.Kill();
        }
    }
Пример #2
0
    public void Hit(int amount, Stats.DamageType damageType, List <WeaponSlot.WeaponBuff> weaponBuffs = null)
    {
        photonView.RPC("HitRPC", RpcTarget.All, CalculateAmount(amount), health.isInvinsible, (int)damageType);

        if (weaponBuffs != null)
        {
            statusEffects.ApplyWeaponBuffs(weaponBuffs);
        }
    }
Пример #3
0
 public Style GetStyle(Stats.DamageType _damageType)
 {
     for (int i = 0; i < styles.Length; i++)
     {
         if (styles[i].damageType == _damageType)
         {
             return(styles[i]);
         }
     }
     print("No style found!");
     return(styles[0]);
 }
Пример #4
0
 public void Hurt(Unit aggressor, Stats.DamageType damageType, int value)
 {
     if (occupant)
     {
         if (occupant is Unit)
         {
             ((Unit)occupant).Hurt(aggressor, damageType, value);
         }
         else
         {
             occupant.health -= value;
         }
     }
 }
Пример #5
0
    public void Hurt(Unit aggressor, Stats.DamageType damageType, int value)
    {
        health -= value;
        if (health <= 0)
        {
            health = 0;
            Die(aggressor);
        }
        if (luaLoaded)
        {
            DynValue result = CallFunction("OnHurt", this, aggressor, damageType, value);

            if (result.Type == DataType.String)
            {
                Debug.Log(result.String);
            }
        }
    }
Пример #6
0
    public int CalculateDamage(Stats.DamageType damageType)
    {
        switch (damageType)
        {
        case Stats.DamageType.Melee:

            return((int)(stats.DamageEffectiveness * (stats.strength + (int)(0.2 * stats.agility))));

        case Stats.DamageType.Ranged:

            return((int)(stats.DamageEffectiveness * (stats.agility + (int)(0.2 * stats.strength))));

        case Stats.DamageType.Secondary:

            return((int)(stats.DamageEffectiveness * (stats.willpower * 2 + (int)(0.5 * stats.strength) + (int)(0.5 * stats.agility))));
        }

        return(0);
    }