Пример #1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "Hazard")
        {
            Debug.Log("Hit Hazard");
            if (Shield == true)
            {
                collisionAudio.PlayOneShot(shieldBreak);
                Shield = false;
            }
            else if (Invincible == false)
            {
                collisionAudio.PlayOneShot(kidOof);
                timer.SubtractTime();
            }
        }

        // Power Up Collisions
        if (collision.gameObject.tag == "PowerupShield")
        {
            collisionAudio.PlayOneShot(shieldSound);
            Debug.Log("Hit Shield Powerup");
            Shield = true;
        }
        if (collision.gameObject.tag == "PowerupInv")
        {
            collisionAudio.PlayOneShot(invincibleSound);
            Debug.Log("Hit Invincible Powerup");
            Invincible = true;
            StartCoroutine(ExecuteAfterTime(5));
        }
        if (collision.gameObject.tag == "PowerupShotgun")
        {
            collisionAudio.PlayOneShot(shieldSound);
            Debug.Log("Hit Shotgun Powerup");
            // TODO Shotgun Powerup
            shootingScript.ActivateShotgun();
            collisionAudio.PlayOneShot(frenzyAudioClip, 1.0f);
        }
        if (collision.gameObject.tag == "PowerupFrenzy")
        {
            collisionAudio.PlayOneShot(shieldSound);
            Debug.Log("Hit Frenzy Powerup");
            shootingScript.StartCoroutine("FrenzyTimer");
            // TODO Frenzy Powerup
            collisionAudio.PlayOneShot(shotgunAudioClip, 1.0f);
        }
        if (collision.gameObject.tag == "PowerupTimeSlow")
        {
            collisionAudio.PlayOneShot(shieldSound);
            Debug.Log("Hit TimeSlow Powerup");
            // TODO Time Slow Powerup
            timer.SlowTimer();
            spawningObject.StartSlowTimer();
        }

        IEnumerator ExecuteAfterTime(float time)
        {
            yield return(new WaitForSeconds(time));

            Invincible = false;
        }
    }