Exemplo n.º 1
0
 // responsible for the stamina verification and consuption
 private int staminaUse(float amount)
 {
     if (staminaBar.EnoughStamina())
     {
         staminaBar.UseStamina(amount);
         return(0);
     }
     return(1);
 }
Exemplo n.º 2
0
    private void Move()
    {
        bool clicado;

        // Running
        if (Input.GetKey(KeyCode.LeftShift))
        {
            clicado = true;
            {
                if (direction.x != 0 && onGround)
                {
                    if (staminaBar.EnoughStamina() && clicado)
                    {
                        staminaBar.UseStamina(runStaminaCost);
                        rb.velocity = new Vector2(direction.x * runSpeed, rb.velocity.y);
                    }
                    else
                    {
                        clicado = false;
                    }
                }
            }
        }
        // Walking
        else
        {
            rb.velocity = new Vector2(direction.x * walkSpeed, rb.velocity.y);
        }

        if ((direction.x > 0 && !facingRight) || (direction.x < 0 && facingRight))
        {
            Flip();
        }
    }
 private void RiftSetup()
 {
     stam.UseStamina(riftStamCost);
     this.gameObject.GetComponent <SpriteRenderer>().sprite = null;
     riftTrails.SetActive(true);
     Invoke("RiftTrigger", 0.1f);
 }
Exemplo n.º 4
0
 private void Jump()
 {
     if ((Input.GetButtonDown("Jump")) && onGround)
     {
         CreateDust();
         rb.velocity = new Vector2(rb.velocity.x, 0);
         if (staminaBar.EnoughStamina())
         {
             staminaBar.UseStamina(jumpStaminaCost);
             rb.AddForce(Vector2.up * jumpForce, ForceMode2D.Impulse);
         }
     }
     // is going up and jump button is still pressed
     else if ((Input.GetButton("Jump")) && !onGround && (rb.velocity.y > .1f))
     {
         if (staminaBar.EnoughStamina())
         {
             staminaBar.UseStamina(jumpStaminaFactor);
         }
     }
 }
 private void Update()
 {
     if (jogadorStats.playerLevel >= 1)
     {
         if (Input.GetKeyDown(KeyCode.LeftShift))
         {
             staminaBar.gameObject.SetActive(true);
             staminaBar.UseStamina(staminaCost);
             if (staminaBar.notEnoughStamina != true)
             {
                 StartCoroutine(Cast());
             }
         }
     }
 }
Exemplo n.º 6
0
 public override void UseStamina(int stamina)
 {
     instance.UseStamina(1);
 }