Example #1
0
    void Update()
    {
        if (Input.GetButton("Fire1"))
        {
            currentHoldTime += Time.deltaTime;
            if (currentHoldTime >= holdTime)
            {
                UIController.instance.setGlowMaterial(UIController.BULLET_BAR_TYPE, true);
            }
        }

        if (Input.GetButtonUp("Fire1"))
        {
            if (currentHoldTime >= holdTime)
            {
                //deploy superbullet
                ObjectPooler.instance.instantiateFromPool(superBulletTag, spawnPoint.position, spawnPoint.rotation);
                playerAudio.playSfxSound(.4f);
            }
            else
            {
                //deploy normal bullet
                ObjectPooler.instance.instantiateFromPool(bulletTag, spawnPoint.position, spawnPoint.rotation);
                playerAudio.playSfxSound(.18f);
            }
            PlayerEnergy.instance.takeDamage(energyCost);
            animator.SetBool("isShooting", true);
            Invoke("stopShooting", .35f);
            currentHoldTime = 0;
            UIController.instance.setGlowMaterial(UIController.BULLET_BAR_TYPE, false);
        }
        UIController.instance.setBar(UIController.BULLET_BAR_TYPE, Mathf.Clamp(currentHoldTime, 0, holdTime));
    }
Example #2
0
 public void takeDamage(int damage)
 {
     health -= damage;
     enemyAudio.playSfxSound();
     if (health <= 0 && !dead)
     {
         die();
     }
 }