Esempio n. 1
0
File: Enemy.cs Progetto: sarinade/vl
    protected bool TryHitPlayer()
    {
        float sqrMagToPlayer = (Player.Instance.transform.position - transform.position).sqrMagnitude;

        if (sqrMagToPlayer <= playerCollisionThreshold)
        {
            float normalizedHP = Mathf.Clamp01((float)hp / (float)enemyParams.HP);
            flashEffect.Flash(normalizedHP);

            Player.Instance.Hit(enemyParams.Damage);
            Dispose();

            return(true);
        }

        return(false);
    }
Esempio n. 2
0
    public void Hit(int damage)
    {
        hp -= damage;
        HUD.Instance.SetHPProgress((float)hp / playerParams.HP);

        flashEffect.Flash();

        if (hp <= 0)
        {
            GameLoop.Instance.EndGame(0.1f, false);
        }
    }
Esempio n. 3
0
        public void TakeDamage(Damage dmg, Motor dealer, Vector3 origin = default(Vector3))
        {
            foreach (State s in states)
            {
                dmg = s.AlterTakenDamage(dmg, dealer, origin);
            }

            if (dmg.amount > 0)
            {
                flashEffect.Flash();
                currentHP -= dmg.amount;
            }

            if (currentHP <= 0 && canDie)
            {
                Die();
            }
        }
        private void ApplyAllDamages()
        {
            float newHP = currentHP;

            if (frameDamage.Count > 0)
            {
                foreach (KeyValuePair <int, DamageDealer> pair in frameDamage)
                {
                    if (pair.Value.dmg.amount > 0)
                    {
                        newHP -= pair.Value.dmg.amount;

                        AddDamageToDisplay(pair.Value.dmg);

                        // Try to interrupt
                        TryToInterrupt(pair.Value.dmg);
                    }
                }

                frameDamage.Clear();

                if (newHP < currentHP)
                {
                    IncreaseRageDamageTaken(currentHP - newHP);

                    flashEffect.Flash();

                    currentHP = newHP;
                }

                if (currentHP <= 0)
                {
                    isDead = true;
                    motor.Die();
                    Destroy(statusBarGO);
                }
            }
        }
 public void ShieldFlash()
 {
     shieldFlashEffect.Flash();
 }