コード例 #1
0
 // called when tracker collides with certain points that act as triggers
 private void OnTriggerEnter(Collider other)
 {
     // if end point is reached from start point, resets mid points, plays sound, increases player score and instantiates particle effect
     if (other.CompareTag("End Point") && !endPointReached)
     {
         endPointReached = true;
         sessionController.ActivateMidPoints(true);
         sessionController.AddPlayerScore(20);
         redAsteroidSound.Play();
         Instantiate(redPickUpEffect, transform.position, transform.rotation);
     }
     if (other.CompareTag("Mid Point")) // when mid point is collided with, adds player score, plays sound and instantiates particle effect
     {
         other.gameObject.SetActive(false);
         sessionController.AddPlayerScore(10);
         greenAsteroidSound.Play();
         Instantiate(greenPickUpEffect, transform.position, transform.rotation);
     }
     if (other.CompareTag("Start Point") && endPointReached) // if start point is reached from end point, resets mid points, plays sound, increases player score, instantiates particle effect and increases rep number
     {
         endPointReached = false;
         sessionController.ActivateMidPoints(true);
         sessionController.AddPlayerScore(20);
         sessionController.AddRepetition();
         successSound.Play();
         Instantiate(redPickUpEffect, transform.position, transform.rotation);
     }
 }