Example #1
0
    public void dealDamage(int amount)
    {
        if (!lost)
        {
            if (!firstdamage)
            {
                announcer.PlaySound(8);
                firstdamage = true;
            }
            health -= amount;

            /*
             * IPL.rightHand.LongHapticPulse(1, NewtonVR.NVRButtons.Trigger);
             * IPL.leftHand.TriggerHapticPulse(1, NewtonVR.NVRButtons.Trigger);
             */
            SteamVR_Controller.Input(3).TriggerHapticPulse(2000);
            SteamVR_Controller.Input(4).TriggerHapticPulse(2000);
            PlaySound(GetComponent <AudioSource>(), sounds[0], true);
            healthText.text = "HP: " + health;
            if (health <= 5 && !firstBigDamage)
            {
                firstBigDamage   = true;
                healthText.color = Color.red;
                announcer.PlaySound(9);
            }
            if (health == 1)
            {
                announcer.PlaySound(10);
            }
            if (health <= 0)
            {
                announcer.PlaySound(11);
                //Time.timeScale = .1f;
                StartCoroutine("FadeMusic");
                StartCoroutine("DelayForLose");
                GetComponent <ScreenFader>().fadeIn = false;
            }
        }
    }