private void Start() { foreach (GameObject piece in pieces) { piece.SetActive(false); } GoalPizza pizza = GameObject.FindGameObjectWithTag("MainPizza").GetComponent <GoalPizza>(); state = pizza.CurrentState(); pieces[state].SetActive(true); }
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; } }
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; }