Exemplo n.º 1
0
 public void ReduceCooldown(int usedAttack)
 {
     if (currentCooldown > minCooldown)      // Decreases cooldown count.
     {
         currentCooldown -= usedAttack;
         cooldownBar.SetCooldown(currentCooldown);
         skillSound.Play();
     }
     else if (currentCooldown <= minCooldown)
     {
         currentCooldown = minCooldown;  // Makes sure the cooldown count does not go below 0.
     }
 }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        //Get Movement unputs
        horizontalMove = Input.GetAxisRaw("Horizontal");
        verticalMove   = Input.GetAxisRaw("Vertical");
        //Get Action inputs
        LeftClickDown     = Input.GetButton("Fire1");
        LeftClick         = Input.GetButton("Fire1");
        RightClick        = Input.GetButton("Fire2");
        RightClickRelease = Input.GetButtonUp("Fire2");
        RightClickDown    = Input.GetButtonDown("Fire2");
        SpacebarDown      = Input.GetButtonDown("Jump");

        //Player rotation to mouse
        Vector3 mousePos = Input.mousePosition;

        mousePos.z = 0;
        direction  = Camera.main.ScreenToWorldPoint(mousePos) - transform.position;
        direction.Normalize();

        PlayerRigidBody.mass = 1;


        if (direction != Vector2.zero)
        {
            transform.rotation = Quaternion.LookRotation(Vector3.forward, direction);
        }
        else
        {
            PlayerRigidBody.freezeRotation = false;
        }

        // if(SpacebarDown == true && !Dodging){
        //     Dodging = true;
        //     dodgeCooldown = 0.25f;
        //  DodgeDirection = NewPos;
        //  DodgeDirection.Normalize ();
        // }


        //PlaYer movement
        //if (!Dashing && !Dodging)
        //{
        NewPos = Vector3.Normalize(new Vector2(horizontalMove * playerspeed, verticalMove * playerspeed));
        PlayerRigidBody.velocity = playerspeed * NewPos;
        if (horizontalMove != 0f || verticalMove != 0f)
        {
            animator.SetBool("isWalking", true);
        }
        else
        {
            animator.SetBool("isWalking", false);
        }

        //}

        // if(Dodging){
        //     PlayerRigidBody.velocity = 35 * DodgeDirection;
        //  dodgeCooldown -= Time.fixedDeltaTime;
        //     if(dodgeCooldown <= 0){
        //         Dodging=false;
        //     }

        // }


        if (LeftClickDown && !gameManager.IsPaused())
        {
            ShootShotgun();
        }

        if (!gameManager.IsPaused())
        {
            if (heatcooldowndelaytimer > 0)
            {
                heatcooldowndelaytimer = heatcooldowndelaytimer - Time.deltaTime;
            }
            else if (heat > 0)
            {
                heatCooldownAccel = heatCooldownAccel + (0.4f * Time.deltaTime);
                if (heat - heatCooldownAccel < 0)
                {
                    heat = 0;
                }
                else
                {
                    heat = heat - heatCooldownAccel;
                }
            }
        }

        cooldown = cooldown - Time.deltaTime;
        float heatPercentage = heat / heatMax;

        cooldownBar.SetCooldown(heatPercentage);
        GunSizzlan.volume = (0.5f * (heatPercentage));

        if (heat >= 100)
        {
            isCoolingDown = true;
        }

        if (heat <= 0)
        {
            isCoolingDown = false;
        }

        if (isRegenerating && regenAmountRemaining > 0f)
        {
            float regenAmount = Time.deltaTime * 20f;
            regenAmountRemaining -= regenAmount;
            if (regenAmountRemaining <= 0f)
            {
                regenAmountRemaining = 0f;
                isRegenerating       = false;
            }
            health += regenAmount;
            if (health > maxHealth)
            {
                health = maxHealth;
            }
            healthbar.SetHealth(health / maxHealth);
        }
    }