예제 #1
0
    void OnTriggerEnter(Collider other)
    {
        _type = other.gameObject.tag;

        switch (_type)
        {
        //colliding with collectibles
        case "Sapphire":
            other.gameObject.SetActive(false);
            scoringRef.Sapphirecount++;
            scoringRef.SetCountText();
            scoringRef.playSoundEffect();
            break;

        case "Ruby":
            other.gameObject.SetActive(false);
            scoringRef.Rubycount++;
            scoringRef.SetCountText();
            scoringRef.playSoundEffect();
            break;

        case "Emerald":
            other.gameObject.SetActive(false);
            scoringRef.Emeraldcount++;
            scoringRef.SetCountText();
            scoringRef.playSoundEffect();
            break;

        case "Ameythyst":
            other.gameObject.SetActive(false);
            scoringRef.Ameythystcount++;
            scoringRef.SetCountText();
            scoringRef.playSoundEffect();
            break;

        case "Diamond":
            other.gameObject.SetActive(false);
            scoringRef.Diamondcount++;
            scoringRef.SetCountText();
            scoringRef.playSoundEffect();
            break;

        /*case "Gold":
         *  other.gameObject.SetActive(false);
         *  scoringRef.Goldcount++;
         *  scoringRef.SetCountText();
         *  scoringRef.playSoundEffect();
         *  break;
         * case "Quartz":
         *  other.gameObject.SetActive(false);
         *  scoringRef.Quartzcount++;
         *  scoringRef.SetCountText();
         *  scoringRef.playSoundEffect();
         *  break;*/
        //colliding with health/fuel pick-up
        case "Steak":
            if (!scoringRef.Health3.enabled)
            {
                other.gameObject.SetActive(false);
                scoringRef.HealthCount++;
                scoringRef.SetCountText();
            }

            //check to see which health display needs to be re-enabled
            if (scoringRef.Health2.enabled == false)
            {
                scoringRef.Health2.enabled = true;
            }
            else
            if (scoringRef.Health3.enabled == false)
            {
                scoringRef.Health3.enabled = true;
            }
            break;

        case "Fuel":
            fuelCan = other.gameObject;
            other.gameObject.GetComponent <MeshRenderer>().enabled = false;
            scoringRef.FuelCount += 6;
            scoringRef.FuelUpdate();
            pickupCountDown = true;
            break;

        //if player hit the kill box
        case "KillBox":
            scoringRef.HealthCount     = 0;
            scoringRef.Health1.enabled = false;
            scoringRef.Health2.enabled = false;
            scoringRef.Health3.enabled = false;
            scoringRef.KillPlayer();
            if (scoringRef.LivesCount > 0)
            {
                scoringRef.ResetHealth();
            }
            break;
        }
    }