Exemplo n.º 1
0
    /// <summary>
    /// Makes the enemy pop up from the ground.
    /// </summary>
    /// <returns></returns>
    private IEnumerator PopUp()
    {
        //How much time the enemy waits before it pops out of the ground
        const float WAIT_TIME_BEFORE_POPPING = 0.15f;

        //the enemy is already above ground
        if (_aboveGround)
        {
            yield break;
        }

        yield return(new WaitForSeconds(WAIT_TIME_BEFORE_POPPING));

        //Activate hitbox before animation starts
        Enemy.Hitbox.gameObject.SetActive(true);

        //deactivate HUD
        Enemy.HUD.SetActive(true);

        _inTransitionAnimation = true;

        //Use idleanimation as jumping sprite
        _animator.Animation = IdleAnimation;

        //Make enemy jump
        Enemy.Rigidbody.SetVelocityY(PopUpJumpVelocity);
        Enemy.Rigidbody.SetVelocityX(0);

        //wait for the enemy to hit the ground
        yield return(new WaitUntil(() => this.OnGround2D()));

        //Create dust
        _exploder.ExplodeBig();

        //start chasing
        _animator.Animation    = ChaseAnimation;
        _aboveGround           = true;
        _inTransitionAnimation = false;
    }
Exemplo n.º 2
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();
            }
        }
    }