예제 #1
0
    /// <summary>
    /// <inheritdoc />
    /// </summary>
    /// <param name="hurtbox"></param>
    protected override void OnReceiveDamage(Hurtbox hurtbox)
    {
        //Dead men don't scream
        if (Commons.PlayerHealth.IsDead)
        {
            return;
        }

        //Play sound
        _multiSoundPlayer.PlaySound();

        //Hitboxes are not active when noclip is enabled
        if (Cheats.Noclip)
        {
            return;
        }

        GrantInvincibilityFrames();
        Commons.PlayerHealth.DealDamage(hurtbox.GetDamage(this));

        if (Commons.PlayerHealth.IsDead)
        {
            //Player is dead. Explode
            if (_exploder)
            {
                _exploder.ExplodeBig();
            }
        }
        else
        {
            //Player was hurt. Splinter
            if (_exploder && !hurtbox.IgnoresInvincibilityFrames)
            {
                _exploder.ExplodeSmall();
            }
        }
    }
예제 #2
0
 /// <summary>
 /// Finds how much damage the enemy will deal
 /// </summary>
 public void RecacheDamage()
 {
     _cachedDamage = Hurtbox.GetDamage(FindObjectOfType <PlayerHitbox>());
 }
예제 #3
0
    /// <summary>
    /// <inheritdoc />
    /// </summary>
    /// <param name="hurtbox"></param>
    protected override void OnReceiveDamage(Hurtbox hurtbox)
    {
        //Play damage sound
        if (_multiSoundPlayer && !(hurtbox is PlayerInvincibilityHurtbox && !Commons.PowerUpManager.HasPowerUp(PowerUp.Invincibility)))
        {
            _multiSoundPlayer.PlaySound(-1, 1, 0.5f);
        }

        if (!(hurtbox is PlayerInvincibilityHurtbox))
        {
            MakeEnemyBlindChase();
        }

        if (TriggersAdrenalineMusic && !(hurtbox is GlobalHurtbox) && hurtbox.GetDamage(this) != 0)
        {
            Commons.SoundtrackPlayer.AddAdrenalineTrigger(this, 5f);
        }

        //Dead men don't scream
        if (_health.IsDead)
        {
            return;
        }

        //Give I-frames
        GrantInvincibilityFrames();

        //Deal damage
        int damage = hurtbox.GetDamage(this);

        _health.DealDamage(damage);

        //Create damage pop-up
        CreateDamagePopNumber(damage);

        if (_health.IsDead)
        {
            //Explode
            foreach (var i in GetComponentsInChildren <ParticleExplosion>())
            {
                i.ExplodeBig();
            }

            //Drop items
            foreach (var i in GetComponentsInChildren <DropLootTableOnDeath>())
            {
                i.DropItem();
            }

            //Destroy the object
            Destroy(transform.parent.gameObject);
        }
        else
        {
            if (hurtbox.IgnoresInvincibilityFrames)
            {
                return;
            }

            //Drop some scraps
            foreach (var i in GetComponentsInChildren <ParticleExplosion>())
            {
                i.ExplodeSmall();
            }
        }
    }