/// <summary> /// Handles user input (mouses clicks) and calls the relevant methods to update cubes wall. /// </summary> void Update() { if (!cubesWallHandler.IsDoneCreatingCubes) { return; } bool calculationDone = cubesWallHandler.Update(); if (Input.GetMouseButtonDown(0) && calculationDone) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit objectHit; if (Physics.Raycast(ray, out objectHit)) { GameObject hitGameObject = objectHit.transform.gameObject; if (cubesWallHandler.IsCubeOnWallHit(hitGameObject)) { AudioManager.Instance.PlayEffect(AudioManager.SoundEffect.SHOOT); Camera.main.GetComponent <Animator>().SetTrigger("IsCubeShot"); gunHandler.StartFire(hitGameObject); cubesWallHandler.HandleCubeHit(hitGameObject); } } } }