Пример #1
0
    private void HandleBoomJump()
    {
        Movement();
        if (canJump)
        {
            canJump = !canJump;
            OnPlayerJump?.Invoke(canJump);
            ExplosionAnimator.SetBool("isTriggered", true);
            // Trigger Explosion Sound Here
            BoomJumpSource.Play();
            RB.velocity = new Vector2(RB.velocity.x, 0);
            RB.AddForce(Vector2.up * explosiveForce, ForceMode2D.Impulse);
            // Damage player
            DamagePlayer(explosiveDamage);
        }

        Collider2D[] cols = Physics2D.OverlapCapsuleAll(ExplosionCollider.bounds.center, ExplosionCollider.size, CapsuleDirection2D.Horizontal, 0);
        foreach (Collider2D col in cols)
        {
            if (col.GetComponent <TNT>() != null)
            {
                TNT tnt = col.GetComponent <TNT>();
                tnt.Detonate(true);
            }
        }


        if (PlayerAnimator.GetCurrentAnimatorStateInfo(0).normalizedTime > 1)
        {
            if (!grounded)
            {
                SetState(PlayerStates.IN_AIR);
            }
        }
    }
Пример #2
0
 private void HandleBombJumpCoolDownTimer()
 {
     if (!canJump)
     {
         if (currentState != PlayerStates.SPIKE_DEAD || currentState != PlayerStates.BOOM_DEAD)
         {
             if (bombCoolDownTimer > 0)
             {
                 bombCoolDownTimer -= Time.deltaTime;
             }
             else
             {
                 ExplosionAnimator.SetBool("isTriggered", false);
                 canJump           = true;
                 bombCoolDownTimer = bombCoolDownTime;
                 OnPlayerJump?.Invoke(canJump);
             }
         }
     }
 }