void Update() { if (gameController.gameState != GameController.GameState.play) { return; } if (animate) { if (!ClawRotation.instance.drill_L && !ClawRotation.instance.drill_R) { if (objectBehaviour.AreAllHolesRemoved()) { score++; Debug.Log("All holes have been removed!"); ++gameController.objectsRepaired; gameController.gameState = GameController.GameState.moveScrewdriverUp; objectController.GameplayTimer += 3.0f; uiManager.SpawnPoints(3, Color.green); } B_Ready_2.active = B_Ready_1.active = false; animate = false; } } else { if (!objectController.Interpolate) { if (Input.GetKeyDown(KeyCode.Return) || inputManager.GetButtonDown(InputManager.Gamepads.Gamepad_1, InputManager.Buttons.A) || inputManager.GetButtonDown(InputManager.Gamepads.Gamepad_1, InputManager.Buttons.B) || inputManager.GetButtonDown(InputManager.Gamepads.Gamepad_1, InputManager.Buttons.Y) || inputManager.GetButtonDown(InputManager.Gamepads.Gamepad_1, InputManager.Buttons.X)) { objectReady = !objectReady; B_Ready_1.active = !B_Ready_1.active; audioSrc.clip = readySfx; audioSrc.Play(); } } if (!screwdriverController.Interpolate) { if (Input.GetKeyDown(KeyCode.Space) || inputManager.GetButtonDown(InputManager.Gamepads.Gamepad_2, InputManager.Buttons.A) || inputManager.GetButtonDown(InputManager.Gamepads.Gamepad_2, InputManager.Buttons.B) || inputManager.GetButtonDown(InputManager.Gamepads.Gamepad_2, InputManager.Buttons.Y) || inputManager.GetButtonDown(InputManager.Gamepads.Gamepad_2, InputManager.Buttons.X)) { screwdriverReady = !screwdriverReady; B_Ready_2.active = !B_Ready_2.active; audioSrc.clip = readySfx; audioSrc.Play(); } } if (objectReady && screwdriverReady) { bool none = true; RaycastHit raycastHit; if (Physics.Raycast( screwdriverController.redScrewdriver.transform.position, Vector3.left, out raycastHit, Mathf.Infinity)) { if (raycastHit.transform.gameObject.name == "RedHole(Clone)") { // TODO: el gameobject es el tornillo red. CHISPAS currentRedSparks = Instantiate(sparks, raycastHit.transform.transform.position, Quaternion.identity); currentRedSparks.Play(); ClawRotation.instance.DrillRight(); Debug.Log("Red hole hit"); objectBehaviour.RemoveHole(raycastHit.transform.gameObject); animate = true; none = false; } } if (Physics.Raycast( screwdriverController.blueScrewdriver.transform.position, Vector3.right, out raycastHit, Mathf.Infinity)) { if (raycastHit.transform.gameObject.name == "BlueHole(Clone)") { // TODO: tornillo blue quan es fica. CHISPAS currentBlueSparks = Instantiate(sparks, raycastHit.transform.position, Quaternion.identity); currentBlueSparks.Play(); ClawRotation.instance.DrillLeft(); Debug.Log("Blue hole hit"); objectBehaviour.RemoveHole(raycastHit.transform.gameObject); animate = true; none = false; } } if (none) { objectController.GameplayTimer -= 5.0f; uiManager.SpawnPoints(-5, Color.red); B_Ready_2.active = B_Ready_1.active = false; audioSrc.clip = wrongSfx; audioSrc.Play(); } objectReady = screwdriverReady = false; } } }