private void FixedUpdate() { if (eating) { timer++; if (timer >= ticksPerPiece) { timer -= ticksPerPiece; completed--; pieces[completed].SetActive(false); if (completed == 0) { RoomTower tower = GameObject.FindGameObjectWithTag("RoomStack").GetComponent <RoomTower>(); tower.GenerateLevel(0); finished = false; returned = true; eating = false; timer = 0; } } } }
private void OnTriggerEnter(Collider other) { //Destroy(gameObject); if (!collected) { RoomTower tower = GameObject.FindGameObjectWithTag("RoomStack").GetComponent <RoomTower>(); tower.pizzaTaken(); GoalPizza pizza = GameObject.FindGameObjectWithTag("MainPizza").GetComponent <GoalPizza>(); pizza.AddPiece(); pieces[state].SetActive(false); collected = true; } }
public void RandomizeConnections(RoomTower tower) { int left = 3; while (left > 0) { float chance = Random.Range(0.0f, 100.0f); Door door = doors[Random.Range(0, doors.Length)]; if (door.symmetricDoor != null) { continue; } left--; if (door.symmetricDoor != null) { return; } door.Activate(); if (chance < 25f) { door.symmetricDoor = exitDoor; } else if (chance < 45f) { door.symmetricDoor = entryDoor; } else if (chance < 75.0f) { door.symmetricDoor = tower.rooms[Random.Range(roomIndex, tower.rooms.Length)].GetComponent <RoomController>().entryDoor; } else { door.symmetricDoor = tower.rooms[tower.rooms.Length - 1].GetComponent <RoomController>().entryDoor; } } }
private void OnTriggerEnter(Collider other) { if (!returned) { returned = true; PortalManager.CloseAllDoors(); RoomTower tower = GameObject.FindGameObjectWithTag("RoomStack").GetComponent <RoomTower>(); if (!finished) { TextMessage.AddMessage((8 - completed) + " pieces left to collect, go back."); if (completed != 0) { tower.GenerateLevel(completed); } } else { // Player won the game. PortalManager.MergeDoors(tower.GetStartRoomDoor(), tower.GetStartRoomDoor()); } } }
void Update() { RaycastHit hit; string message = ""; if (Input.GetKeyDown(KeyCode.R)) { GameObject.FindGameObjectWithTag("MainPizza").GetComponent <GoalPizza>().ResetLevel(); RoomTower tower = GameObject.FindGameObjectWithTag("RoomStack").GetComponent <RoomTower>(); tower.DeactivateDoorsInRooms(); tower.TeleportToStart(transform); } if (Physics.Raycast(camera.transform.position, camera.transform.forward, out hit, range)) { if (Input.GetKeyDown(KeyCode.E)) { if (hit.transform.tag == "Door") { if (isCodeCorrect()) { hit.transform.GetComponent <Door>().Open(true); resetCode(); } else { hit.transform.GetComponent <Door>().Open(false); } } } if (hit.transform.tag == "MainPizza") { GoalPizza pizza = hit.transform.GetComponent <GoalPizza>(); if (pizza != null && pizza.CurrentState() == 8) { message = "Press E to eat pizza and start again."; if (Input.GetKeyDown(KeyCode.E)) { pizza.EatPizza(); } } } else if (hit.transform.tag == "LeftLamp") { if (Input.GetKeyDown(KeyCode.E)) { inputCode(1); } } else if (hit.transform.tag == "RightLamp") { if (Input.GetKeyDown(KeyCode.E)) { inputCode(0); } } } interactText.text = message; }