void Start() { Assert.IsNotNull(landButton); Assert.IsNotNull(restartButton); Assert.IsNotNull(leaveButton); sLeaveButton = leaveButton.GetComponent <LeaveButton>(); sRestartButton = restartButton.GetComponent <RestartButton>(); sLandButton = landButton.GetComponent <LandButton>(); mainMenuOn = false; showAllMainMenuElements(false); }
void Awake() { //menuAudio = GetComponent<AudioSource>(); restartTimer = menuTimer; status_text = StatusText.GetComponent <Text>(); pauseLoader = PauseButton.GetComponent <Transform>().FindChild("pause_Loader").GetComponent <Image>(); playLoader = PlayButton.GetComponent <Transform>().FindChild("play_Loader").GetComponent <Image>(); restartLoader = RestartButton.GetComponent <Transform>().FindChild("restart_Loader").GetComponent <Image>(); homeLoaderPM = HomeButtonPM.GetComponent <Transform>().FindChild("home_Loader").GetComponent <Image>(); homeLoaderGO = HomeButtonGO.GetComponent <Transform>().FindChild("home_Loader").GetComponent <Image>(); }
void Update() { PlayerCamera = Camera.main.transform; if (canRestart) { canRestart = false; SceneManager.LoadScene(SceneManager.GetActiveScene().name); } //--------------Handling Objects in Line of Sight--------------------- Selectables = GameObject.FindGameObjectsWithTag("Selectable"); foreach (GameObject Selectable in Selectables) { Selectable.GetComponent <Renderer>().material.shader = Shader.Find("Diffuse"); } Ray ray; RaycastHit hit; ray = new Ray(PlayerCamera.position, PlayerCamera.rotation * Vector3.forward); //detecting raycast hits if (Physics.Raycast(ray, out hit)) { GameObject hitObject = hit.collider.gameObject; //if object in sightline has selectable tag, highlight it if (hitObject.CompareTag("Selectable")) { hitObject.GetComponent <Renderer> ().material.shader = Shader.Find("OutlinedSilhouetted"); } if (Input.GetButtonDown("Fire1")) { //click start button to knock over starting domino if (hitObject.name.ToString() == startButton.name.ToString()) { for (int i = 0; i < startingDomino.Length; i++) { startingDomino [i].FallDownByButtonPush(); } startButton.GetComponent <StartButton> ().ClickButton(); } //click reset button to reset scene if (hitObject.name.ToString() == restartButton.name.ToString()) { Debug.Log("Restart"); restartButton.GetComponent <RestartButton> ().ClickButton(); StartCoroutine(Delay()); } } else if (Input.GetButtonDown("DestroyDomino")) { //remove currently placed dominos if (hitObject.name.Contains("Domino")) { Destroy(hitObject); dominoCount += 1; } } } //----------------------------------------------- if (GhostOn) { float movementSpeed = 0.1f; float tiltAngle = 30f; float smooth = 2f; //Get inputs float LeftRightShift = Input.GetAxis("LeftStickX"); float ForwardBackShift = Input.GetAxis("LeftStickY"); float YRotation = Input.GetAxis("RightStickX"); //move ghost left/right and towards/further away from the camera Ghost.position += movementSpeed * LeftRightShift * PlayerCamera.right; Ghost.position += movementSpeed * ForwardBackShift * PlayerCamera.forward; //rotate ghost Quaternion target = Quaternion.Euler(Ghost.rotation.eulerAngles + new Vector3(0f, YRotation * tiltAngle, 0f)); Ghost.rotation = Quaternion.Slerp(Ghost.rotation, target, Time.deltaTime * smooth); // places ghost on highest thing in its horizontal position Ray DownRay = new Ray(new Vector3(Ghost.position.x, 50f, Ghost.position.z), Vector3.down); RaycastHit hitDown; if (Physics.Raycast(DownRay, out hitDown, 51f)) { Ghost.position = new Vector3(Ghost.position.x, hitDown.point.y + 0.2f, Ghost.position.z); } else { Ghost.GetComponent <GhostScript> ().placable = false; } //Place domino, place next ghost and destory current ghost. if (Input.GetButtonDown("Fire1") && Ghost.GetComponent <GhostScript> ().placable) { dominoCount -= 1; Instantiate(DominoPrefab, Ghost.position, Ghost.rotation); SubsequentGhostPlacement(); } } }