private void updateButtonTrigger(ref UniMoveController move) { if (move.GetButtonDown(PSMoveButton.Trigger)) { buttonTriggerIsDown = true; } if (move.GetButtonUp(PSMoveButton.Trigger)) { buttonTriggerIsDown = false; } }
// Update is called once per frame void Update() { if (!isGameOver && move != null) { if (move.GetButtonDown(PSMoveButton.Move)) { move.ResetOrientation(); canMove = true; } if (canMove) { if (move.GetButtonDown(PSMoveButton.Circle)) { circleButtonDown = true; } if (circleButtonDown) { turboBar.GetComponent <Image>().fillAmount -= 0.2f; actualVelocity = turboVelocity; if (turboBar.GetComponent <Image>().fillAmount <= 0) { actualVelocity = standardVelocity; circleButtonDown = false; } } turboBar.GetComponent <Image>().fillAmount += 0.01f; if (move.GetButtonDown(PSMoveButton.Cross)) { switch (activeCamera) { case 0: insideCamera.enabled = false; topCamera.enabled = false; farCamera.enabled = false; outsideCamera.enabled = true; canvas.GetComponent <Canvas>().worldCamera = outsideCamera; break; case 1: insideCamera.enabled = true; topCamera.enabled = false; farCamera.enabled = false; outsideCamera.enabled = false; canvas.GetComponent <Canvas>().worldCamera = insideCamera; break; case 2: insideCamera.enabled = false; topCamera.enabled = false; farCamera.enabled = true; outsideCamera.enabled = false; canvas.GetComponent <Canvas>().worldCamera = farCamera; break; case 3: insideCamera.enabled = false; topCamera.enabled = true; farCamera.enabled = false; outsideCamera.enabled = false; canvas.GetComponent <Canvas>().worldCamera = topCamera; break; } if (insideCamera.enabled) { cockpit.SetActive(true); } else { cockpit.SetActive(false); } activeCamera++; if (activeCamera == 4) { activeCamera = 0; } } if (move.Trigger > 0) { if (!isReloading) { if (shootBar.GetComponent <Image>().fillAmount > 0) { if (!isPlayingSound) { audioSource.GetComponent <AudioController>().SetLoop(true); audioSource.GetComponent <AudioController>().PlayAudioClip(1); // play laser sound isPlayingSound = true; move.SetRumble(1f); } shootBar.GetComponent <Image>().fillAmount -= 0.01f; Instantiate(bullet, bulletSpawnerLeft.transform.position, bulletSpawnerLeft.transform.rotation); Instantiate(bullet, bulletSpawnerRight.transform.position, bulletSpawnerRight.transform.rotation); } } else { audioSource.GetComponent <AudioController>().SetLoop(false); isPlayingSound = false; move.SetRumble(0f); } } else { audioSource.GetComponent <AudioController>().SetLoop(false); isPlayingSound = false; move.SetRumble(0f); } if (shootBar.GetComponent <Image>().fillAmount <= 0 && !isReloading) { StartCoroutine("reloadBar"); } rigidbody.velocity = transform.forward * actualVelocity; float Ymove = move.Orientation.y; //probar mas adelante con el Round a ver si funciona mejor o no float Xrotation = transform.rotation.x; if (move.GetButtonDown(PSMoveButton.Square)) { Zrotation = 1; } if (move.GetButtonDown(PSMoveButton.Triangle)) { Zrotation = -1; } if (move.GetButtonUp(PSMoveButton.Triangle) || move.GetButtonUp(PSMoveButton.Square)) { Zrotation = 0; } transform.Rotate(move.Orientation.x * 10f, move.Orientation.y * 10f, Zrotation); } } }
// Update is called once per frame void Update() { if (droneIndex >= moves.Count) { return; } UniMoveController move = moves[droneIndex]; timer += Time.deltaTime; timerNoPress += Time.deltaTime; // Trigger is held down, do control if (move.Trigger > 0.9f && !doingAflip) { move.SetLED(MoveControllerColor); if (!isInAir) { isInAir = true; Debug.Log("Lift off"); SendToNode("/startdrone", 1); } if (timer > 0.2f) { if (move.Acceleration.x > 0.02f) { SendToNode("/left", move.Acceleration.x * move.Acceleration.x * 2.2f * power); } else if (move.Acceleration.x < -0.02f) { SendToNode("/right", (move.Acceleration.x * move.Acceleration.x * 2.2f * power)); } else { SendToNode("/left", 0); SendToNode("/right", 0); } if (move.Acceleration.y < -0.02f) { SendToNode("/front", move.Acceleration.y * move.Acceleration.y * 2.2f * power); } else if (move.Acceleration.y > 0.02f) { SendToNode("/back", move.Acceleration.y * move.Acceleration.y * 2.2f * power); } else { SendToNode("/front", 0); SendToNode("/back", 0); } } } if (move.GetButtonDown(PSMoveButton.Square)) { if (timer > 0.2f) { SendToNode("/counterClockwise", 0.5f); } } else if (move.GetButtonUp(PSMoveButton.Square)) { SendToNode("/counterClockwise", 0); } else if (move.GetButtonDown(PSMoveButton.Triangle)) { if (timer > 0.2f) { SendToNode("/clockwise", 0.5f); } } else if (move.GetButtonUp(PSMoveButton.Triangle)) { SendToNode("/clockwise", 0); } else if (move.GetButtonDown(PSMoveButton.Cross)) { if (timer > 0.2f) { SendToNode("/down", 0.2f); } } else if (move.GetButtonUp(PSMoveButton.Cross)) { SendToNode("/down", 0); } else if (move.GetButtonDown(PSMoveButton.Circle)) { if (timer > 0.2f) { SendToNode("/up", 0.2f); } } else if (move.GetButtonUp(PSMoveButton.Circle)) { SendToNode("/up", 0); SendToNode("/stop", 0); } else if (move.GetButtonUp(PSMoveButton.Move)) { SendToNode("/land", 1); } else if (move.GetButtonUp(PSMoveButton.Select)) { SendToNode("/flip", 1); } else if (move.GetButtonUp(PSMoveButton.Start)) { SendToNode("/wave", 1); } else if (move.Trigger <= 0.8f && !doingAflip) { if (timer > 0.2f) { SendToNode("/stop", 0); } move.SetLED(MoveControllerColor * 0.2f); } if (move.GetButtonUp(PSMoveButton.PS)) { isInAir = false; //TODO: Make panic SendToNode("/land", 1); } prevTrigger = move.Trigger; }
private void updateButtonTrigger(ref UniMoveController move) { if (move.GetButtonDown(PSMoveButton.Trigger)) { buttonTriggerIsDown = true; } if (move.GetButtonUp(PSMoveButton.Trigger)) { buttonTriggerIsDown = false; } }