Exemplo n.º 1
0
    void Update()
    {
        if (!GetComponent <PlayerCollisions>().IsPaused&& !GetComponent <PlayerCollisions>().gameOverScreen.activeSelf)
        {
            //Mana Regeneration
            if (mana < maxMana)
            {
                mana += manaRegenRate;
            }
            else
            {
                mana = maxMana;
            }

            manaMeter.value = mana;
            if (reloadTime > 0)
            {
                reloadTime -= Time.deltaTime;
                if (reloadTime <= 0)
                {
                    Ammo = maxAmmo;
                }
            }
            else
            {
                if (Input.GetButtonDown("Fire1") && weapon.CanFire(this))                //Pistol Fire
                {
                    weapon.FireWeapon(this);
                    weapon.PlayAudio(pistolAudio);
                }
                else if (Input.GetButtonDown("Fire1") && ammo <= 0)//Play 'Out of Ammo' when such is true
                {
                    pistolAudio.clip = outOfAmmoSFX[Random.Range(0, outOfAmmoSFX.Length)];
                    pistolAudio.Play();
                }
                if (Input.GetButtonDown("Fire2") && shieldSpell.CanFire(this))                //Force Push
                {
                    shieldSpell.FireWeapon(this);
                    shieldSpell.PlayAudio(shieldAudio);
                }
                if (Input.GetButtonDown("Reload"))                //Reload
                {
                    reloadTime = reloadRate;
                    if (ammo < maxAmmo)
                    {
                        pistolAudio.clip = reloadSFX[Random.Range(0, reloadSFX.Length)];
                        pistolAudio.Play();
                    }
                }
                if (Input.GetButtonDown("Fireball") && firebalSpell.CanFire(this))//Fireball
                {
                    firebalSpell.FireWeapon(this);
                    firebalSpell.PlayAudio(fireballAudio);
                }
            }

            weapon.UpdateCooldown(Time.deltaTime);
        }
    }