private void OnTriggerEnter(Collider other) { if (other.gameObject.GetComponent <DirectedAgent>()) { // if a game object with a DirectedAgent component (e.g. AI) ¯\_(ツ)_/¯ } else if (other.GetComponent <GettingHelp>()) { // if a human reaches the end GettingHelp playerHelp = other.GetComponent <GettingHelp>(); playerHelp.setGameOver(true); GOController.timeToWin = playerHelp.getTime(); SceneManager.LoadScene("GameOver"); } }
// Use this for initialization void Start() { Cursor.visible = false; // initializing maze InitializeMaze(); // building the maze with the hunt and kill algorithm MazeAlgorithm ma = new HuntAndKillMazeAlgorithm(mazeCells); ma.CreateMaze(); // building the navmesh for the navAgent surface.BuildNavMesh(); // instantiating the endobject at endpoint endObject = Instantiate(endObject, endPoint, Quaternion.identity); // giving the endobject audio source to the player playerHelp = player.GetComponent <GettingHelp>(); playerHelp.setEnding(endObject.GetComponent <AudioSource>()); }