Exemple #1
0
    public void ApplyDamage(float damage)
    {
        if (damage == 0)
        {
            return;
        }
        DamageStates state = (damage > 0) ? (DamageStates.Hurt):(DamageStates.Heal);
        byte         ind   = 0;

        healthCurrent -= damage;
        state          = (healthCurrent > 0) ? (state):(DamageStates.Dead);
        switch (state)
        {
        case DamageStates.Heal:
            ind = (byte)Random.Range(0, soundsHeal.Length); break;

        case DamageStates.Hurt:
            ind = (byte)Random.Range(0, soundsHurt.Length >> 1); break;

        case DamageStates.Crit:
            ind = (byte)Random.Range(soundsHurt.Length >> 1, soundsHurt.Length); break;

        case DamageStates.Dead:
            ind = (byte)soundsHurt.Length; break;
        }
        au.PlayOneShot(soundsHurt[(int)ind], (Mathf.Abs((int)damage) >> 2) / au.volume);
    }
Exemple #2
0
        public EDamageState GetDamageState()
        {
            var dmgState = EDamageState.None;

            foreach (var bodyPart in BodyParts)
            {
                dmgState = DamageStates.GetWorstDamageState(dmgState, bodyPart.GetDamageState());
            }
            return(dmgState);
        }
 public string HpSystemToRichString(HpSystem hpSystem)
 {
     return(RichStrings.WithColor($"[{hpSystem.HpCurrent}/{hpSystem.HpBase}]", DamageStates.DamageStateToColor(hpSystem.GetDamageState())));
 }
 public string GetStatusString(EDamageState damageState)
 {
     return(_statusField + DamageStates.DamageStateToStrWithColor(damageState));
 }