private void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("PickUp")) { PickUp pickup = other.gameObject.GetComponent <PickUp>(); if (pickup != null) { score += pickup.Collect(); ServiceLocator.Get <GameManager>().UpdateScoreDisplay(score); } } if (other.gameObject.CompareTag("Death")) { if (lifes <= 0) { Debug.Log("YOU LOSE!"); } gameObject.transform.position = gameController.GetComponent <GameManager>().respawn.transform.position; lifes--; ServiceLocator.Get <GameManager>().UpdateLifeDisplay(lifes); } if (other.gameObject.CompareTag("Portal")) { ServiceLocator.Get <GameManager>().NextLevel(); } }
private void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("PickUp")) { PickUp pickup = other.gameObject.GetComponent <PickUp>(); if (pickup != null) { playerPoints += pickup.Collect(); ServiceLocator.Get <UIManager>().UpdateScoreDisplay(playerPoints); } } if (other.gameObject.CompareTag("Portal")) { ServiceLocator.Get <LevelManager>().Level++; if (ServiceLocator.Get <LevelManager>().Level == 2) { ServiceLocator.Get <UIManager>().SetEndUi(1); } else if (ServiceLocator.Get <LevelManager>().Level >= 3) { ServiceLocator.Get <UIManager>().SetEndUi(2); } //Invoke("StopTheGame",0.3f); StartCoroutine(LoadScene()); } }
private void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("PickUp")) { PickUp pickup = other.gameObject.GetComponent <PickUp>(); if (pickup != null) { playerPoints += pickup.Collect(); ServiceLocator.Get <UIManager>().UpdateScoreDisplay(playerPoints); Destroy(other); } } }
private void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("PickUp")) { PickUp pickUp = other.gameObject.GetComponent <PickUp>(); if (pickUp != null) { score += pickUp.Collect(); ServiceLocator.Get <UIManager>().UpdateScoreDisplay(score); } } if (other.gameObject.CompareTag("Hazard")) { Time.timeScale = 0; Debug.Log("you lose"); } }