Exemple #1
0
 // Start is called before the first frame update
 void Start()
 {
     rb = GetComponent <Rigidbody>();
     scoreController  = GetComponent <ScoreController>();
     audioManager     = FindObjectOfType <AudioManager>();
     healthController = FindObjectOfType <HealthController>();
     scoreController.UpdateScoreDisplay();
 }
Exemple #2
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.CompareTag("Ally"))
     {
         //destroy the object we collected
         Destroy(other.gameObject);
         //play pop sound
         audioManager.Play("PlusOne");
         //increase the score
         scoreController.IncreaseScore();
         //update UI
         scoreController.UpdateScoreDisplay();
     }
     else if (other.gameObject.CompareTag("Enemy"))
     {
         Destroy(other.gameObject);
         audioManager.Play("MinusTen");
         healthController.DeductHealth();
         scoreController.DecreaseScore();
         scoreController.UpdateScoreDisplay();
     }
 }