Пример #1
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Spider")
        {
            SpiderBehaviour spiderScript = other.GetComponent <SpiderBehaviour>();

            if (spiderScript.spiderTrigger && !spiderScript.isVulnerable)
            {
                spiderScript.spiderTrigger = false;
                PlayerFlash flash = gameObject.GetComponent <PlayerFlash>();
                flash.StartCoroutine("FlashPlayer");
                if (!audioSrc.isPlaying)
                {
                    audioSrc.clip = hurtSpider;
                    audioSrc.Play();
                }
                health -= 1;
            }
        }
        else if (other.tag == "Projectile")
        {
            if (!projTrigger)
            {
                PlayerFlash flash = gameObject.GetComponent <PlayerFlash>();
                flash.StartCoroutine("FlashPlayer");
                health -= 1;
                if (!audioSrc.isPlaying)
                {
                    audioSrc.clip = hurtWorm;
                    audioSrc.Play();
                }
                projTrigger = true;
            }
        }
    }
Пример #2
0
 // Use this for initialization
 void Start()
 {
     deathAudioToggle   = false;
     audioSrc           = GetComponent <AudioSource> ();
     flash              = gameObject.GetComponent <PlayerFlash>();
     health             = startingHealth;
     healthBar.maxValue = startingHealth;
     healthBar.minValue = 0;
 }