void Update() { if (ZeldaInput.GetCommand_Trigger(ZeldaInput.Cmd_Trigger.MenuNavSelect)) { ShowSavedGamesScreen(); } }
void ProcessInput() { if (Input.GetKeyDown(KeyCode.Alpha1)) { EquipSword("WoodenSword"); } if (Input.GetKeyDown(KeyCode.Alpha2)) { EquipSword("WhiteSword"); } if (Input.GetKeyDown(KeyCode.Alpha3)) { EquipSword("MagicSword"); } if (Input.GetKeyDown(KeyCode.Alpha4)) { EquipSword(null); } if (ZeldaInput.GetCommand_Trigger(ZeldaInput.Cmd_Trigger.ToggleGodMode)) { ToggleGodMode(); } if (ZeldaInput.GetCommand_Trigger(ZeldaInput.Cmd_Trigger.ToggleGhostMode)) { ToggleGhostMode(); } if (ZeldaInput.GetCommand_Trigger(ZeldaInput.Cmd_Trigger.ToggleFlying)) { ToggleFlying(); } ProcessKeypadInput(); }
void Update() { if (Input.GetKeyUp(KeyCode.Alpha0)) { SwitchInputMode(); } _cmdTriggerOutput = GetString_CmdTrigger(); _cmdBoolOutput = GetString_CmdBool(); _cmdFloatOutput = GetString_CmdFloat(); int i = 0; foreach (Cmd_Trigger t in Enum.GetValues(typeof(Cmd_Trigger))) { if (ZeldaInput.GetCommand_Trigger(t)) { _triggerTimeStamps[i] = _triggerDisplayDuration; } else { _triggerTimeStamps[i] -= Time.deltaTime; _triggerTimeStamps[i] = Mathf.Max(_triggerTimeStamps[i], 0); } i++; } }
void Update() { if (axes == RotationAxes.MouseXAndY) { float rotationX = transform.localEulerAngles.y + ZeldaInput.GetCommand_Float(ZeldaInput.Cmd_Float.LookHorizontal) * sensitivityX; //float rotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivityX; rotationY += Input.GetAxis("Mouse Y") * sensitivityY; rotationY = Mathf.Clamp(rotationY, minimumY, maximumY); transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0); //print("axes = MouseXAndY: rotX = " + rotationX + ", rotY = " + rotationY); } else if (axes == RotationAxes.MouseX) { float rotationX = ZeldaInput.GetCommand_Float(ZeldaInput.Cmd_Float.LookHorizontal) * sensitivityX; //float rotationX = Input.GetAxis("Mouse X") * sensitivityX; transform.Rotate(0, rotationX, 0); //print("axes = MouseX: rotX = " + rotationX + ", rotY = " + 0); } else if (axes == RotationAxes.MouseY) { float rotationX = transform.localEulerAngles.y; rotationY += Input.GetAxis("Mouse Y") * sensitivityY; rotationY = Mathf.Clamp(rotationY, minimumY, maximumY); transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0); //print("axes = MouseY: rotX = " + rotationX + ", rotY = " + rotationY); } }
void UpdateCursor() { float moveVert = ZeldaInput.GetCommand_Float(ZeldaInput.Cmd_Float.MenuNavVertical); Vector2 dir = new Vector2(0, -moveVert); if (_cursor.TryMoveCursor(dir)) { PlaySelectSound(); } }
string GetString_CmdFloat() { string s = " --- Zelda CmdFloat ---\n"; foreach (Cmd_Float f in Enum.GetValues(typeof(Cmd_Float))) { s += f.ToString() + " = " + ZeldaInput.GetCommand_Float(f).ToString("F3") + SEPERATOR; } return(s); }
string GetString_CmdBool() { string s = " --- Zelda CmdBool ---\n"; foreach (Cmd_Bool b in Enum.GetValues(typeof(Cmd_Bool))) { s += b.ToString() + " = " + ZeldaInput.GetCommand_Bool(b) + SEPERATOR; } return(s); }
void UpdateCursor() { if (ControlsViewActive) { return; } float moveVert = ZeldaInput.GetCommand_Float(ZeldaInput.Cmd_Float.MenuNavVertical); IndexDirection2 dir = new IndexDirection2(0, moveVert); _optionsView.MoveCursor(dir); }
bool WasOptionsButtonJustPressed() { if (ZeldaInput.AreAnyTouchControllersActive()) { // TODO: Integrate OVRInput (Oculus Touch Controllers) with ZeldaInput return(OVRInput.GetDown(OVRInput.RawButton.X)); } else { return(ZeldaInput.GetCommand_Trigger(ZeldaInput.Cmd_Trigger.ToggleOptionsMenu)); } }
void Update() { UpdateCursor(); if (ZeldaInput.GetCommand_Trigger(ZeldaInput.Cmd_Trigger.MenuNavSelect)) { PlaySelectSound(); LoadEntry(CursorIndex); } else if (Application.isEditor && ZeldaInput.GetCommand_Trigger(ZeldaInput.Cmd_Trigger.EraseSaveEntry)) // TODO { EraseEntry(CursorIndex); } }
void Update() { if (!OptionsViewActive) { return; } UpdateCursor(); if (ZeldaInput.GetCommand_Trigger(ZeldaInput.Cmd_Trigger.MenuNavSelect)) { _optionsView.ClickSelectedButton(); } }
void ProcessUserInput() { if (ZeldaInput.GetCommand_Trigger(ZeldaInput.Cmd_Trigger.SwordAttack)) { AttackWithSword(); } if (_equippedItem != null) { Weapon_Gun_Bow bow = (weapon == null) ? null : weapon.GetComponent <Weapon_Gun_Bow>(); if (weapon != null) { // Aim WeaponB /*Transform t = _playerController.WeaponContainerLeft; * t.forward = _playerController.LineOfSight; * if (bow == null) * { * Vector3 fwd = t.forward; * fwd.y = 0; * t.forward = fwd; * }*/ } // Use Item? bool doUseItem = false; /*if (bow != null) * { * doUseItem = ZeldaInput.GetButtonUp(ZeldaInput.Button.UseItemB); * } * else * { * doUseItem = ZeldaInput.GetButtonDown(ZeldaInput.Button.UseItemB); * }*/ doUseItem = ZeldaInput.GetCommand_Trigger(ZeldaInput.Cmd_Trigger.UseItemB); if (doUseItem) { if (weapon != null) { AttackWithWeaponB(); } _inventory.UseItemB(); } } }
void UpdateCursor() { int numSelectableItems = GetSelectableItems().Count; if (numSelectableItems == 0) { return; } float moveHorz = ZeldaInput.GetCommand_Float(ZeldaInput.Cmd_Float.MenuNavHorizontal); float moveVert = ZeldaInput.GetCommand_Float(ZeldaInput.Cmd_Float.MenuNavVertical); IndexDirection2 dir = new IndexDirection2(moveHorz, moveVert); View.MoveCursor(dir); }
void UpdateLikeLikeTrap() { if (!IsInLikeLikeTrap) { return; } if (ZeldaInput.GetCommand_Trigger(ZeldaInput.Cmd_Trigger.SwordAttack)) { if (++_likeLikeTrapCounter >= LIKE_LIKE_ESCAPE_COUNT) { IsInLikeLikeTrap = false; } } }
void Update() { // TODO: Implement a system for sending input events to active views. if (WasOptionsButtonJustPressed()) { if (IsPauseAllowed_Options) { TogglePause_Options(); } } else if (ZeldaInput.GetCommand_Trigger(ZeldaInput.Cmd_Trigger.ToggleInventory)) { if (IsPauseAllowed_Inventory && !IsPaused_Options) { TogglePause_Inventory(); } } }
OVRHapticsClip CreateRumbleClip() { OVRHapticsClip clip = null; for (int i = 0; i < SAMPLES_COUNT; i++) { float t = 1; //float t = 1 - (float)i / SAMPLES_COUNT; // Linear "crescendo" t *= _rumbleStrength; _samples[i] = (byte)(255 * t); } if (ZeldaInput.AreAnyTouchControllersActive()) { clip = new OVRHapticsClip(_samples, SAMPLES_COUNT); } return(clip); }
void Update() { if (!ZeldaInput.AreAnyTouchControllersActive()) { return; } if (!OVRInput.GetControllerPositionTracked(OVRInput.Controller.RTouch)) { return; } _controllerPos = OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch); if (_prevControllerPos != Vector3.zero) { _controllerVelocity = (_controllerPos - _prevControllerPos) / Time.deltaTime; } //UpdateScale(_controllerVelocity); }
public override void UpdateMovement() { if (HaltUpdateMovement) { return; } float moveHorzAxis = ZeldaInput.GetCommand_Float(ZeldaInput.Cmd_Float.MoveHorizontal); float moveVertAxis = ZeldaInput.GetCommand_Float(ZeldaInput.Cmd_Float.MoveVertical); bool moveForward = moveVertAxis > 0; bool moveLeft = moveHorzAxis < 0; bool moveBack = moveVertAxis < 0; bool moveRight = moveHorzAxis > 0; MoveScale = 1.0f; if ((moveForward && moveLeft) || (moveForward && moveRight) || (moveBack && moveLeft) || (moveBack && moveRight)) { MoveScale = 0.70710678f; } MoveScale *= SimulationRate * Time.deltaTime; // Compute this for key movement float moveInfluence = Acceleration * 0.1f * MoveScale * MoveScaleMultiplier; // Run if (ZeldaInput.GetCommand_Bool(ZeldaInput.Cmd_Bool.Run)) { moveInfluence *= RunMultiplier; } Quaternion ort = transform.rotation; Vector3 ortEuler = ort.eulerAngles; ortEuler.z = ortEuler.x = 0f; ort = Quaternion.Euler(ortEuler); if (moveForward) { MoveThrottle += ort * (transform.lossyScale.z * moveInfluence * Vector3.forward); } if (moveBack) { MoveThrottle += ort * (transform.lossyScale.z * moveInfluence * BackAndSideDampen * Vector3.back); } if (moveLeft) { MoveThrottle += ort * (transform.lossyScale.x * moveInfluence * BackAndSideDampen * Vector3.left); } if (moveRight) { MoveThrottle += ort * (transform.lossyScale.x * moveInfluence * BackAndSideDampen * Vector3.right); } // Jump if (ZeldaInput.GetCommand_Trigger(ZeldaInput.Cmd_Trigger.Jump)) { Jump(); } // Rotation Vector3 euler = transform.rotation.eulerAngles; float rotateInfluence = SimulationRate * Time.deltaTime * RotationAmount * RotationScaleMultiplier; //if (!SkipMouseRotation) //{ // euler.y += Input.GetAxis("Mouse X") * rotateInfluence * 3.25f; //} moveInfluence = SimulationRate * Time.deltaTime * Acceleration * 0.1f * MoveScale * MoveScaleMultiplier; float lookHorzAxis = ZeldaInput.GetCommand_Float(ZeldaInput.Cmd_Float.LookHorizontal); float deltaRotation = lookHorzAxis * rotateInfluence * 3.25f; euler.y += deltaRotation; transform.rotation = Quaternion.Euler(euler); }
protected override void UpdateController() { Transform crt = CameraRig.transform; if (OVRManager.isHmdPresent && useProfileData) { if (InitialPose == null) { // Save the initial pose so it can be recovered if useProfileData is turned off later InitialPose = new OVRPose() { position = crt.localPosition, orientation = crt.localRotation }; } var p = crt.localPosition; if (OVRManager.instance.trackingOriginType == OVRManager.TrackingOrigin.EyeLevel) { p.y = OVRManager.profile.eyeHeight - (0.5f * Controller.height) + Controller.center.y; } else if (OVRManager.instance.trackingOriginType == OVRManager.TrackingOrigin.FloorLevel) { p.y = -(0.5f * Controller.height) + Controller.center.y; } crt.localPosition = p; } else if (InitialPose != null) { // Return to the initial pose if useProfileData was turned off at runtime crt.localPosition = InitialPose.Value.position; crt.localRotation = InitialPose.Value.orientation; InitialPose = null; } SetCameraHeight(CameraRig.centerEyeAnchor.localPosition.y); UpdateMovement(); Vector3 motion = Vector3.zero; float motorDamp = (1.0f + (Damping * SimulationRate * Time.deltaTime)); MoveThrottle.x /= motorDamp; MoveThrottle.y = (MoveThrottle.y > 0.0f) ? (MoveThrottle.y / motorDamp) : MoveThrottle.y; MoveThrottle.z /= motorDamp; motion += MoveThrottle * SimulationRate * Time.deltaTime; // Flying if (flyingEnabled) { float triggersAxis = ZeldaInput.GetCommand_Float(ZeldaInput.Cmd_Float.Fly); if (Mathf.Abs(triggersAxis) > 0.1f) { motion.y += triggersAxis * FLY_SPEED; } FallSpeed = 0; } else { // Gravity if (gravityEnabled) { if (IsGrounded && FallSpeed <= 0) { FallSpeed = ((Physics.gravity.y * (GravityModifier * 0.002f))); } else { FallSpeed += ((Physics.gravity.y * (GravityModifier * 0.002f)) * SimulationRate * Time.deltaTime); } } motion.y += FallSpeed * SimulationRate * Time.deltaTime; // Offset correction for uneven ground float bumpUpOffset = 0.0f; if (IsGrounded && MoveThrottle.y <= transform.lossyScale.y * 0.001f) { bumpUpOffset = Mathf.Max(Controller.stepOffset, new Vector3(motion.x, 0, motion.z).magnitude); motion -= bumpUpOffset * Vector3.up; } } Vector3 predictedXZ = Vector3.Scale((Controller.transform.localPosition + motion), new Vector3(1, 0, 1)); // Move contoller Controller.Move(motion); LastAttemptedMotion = motion; Vector3 actualXZ = Vector3.Scale(Controller.transform.localPosition, new Vector3(1, 0, 1)); if (predictedXZ != actualXZ) { MoveThrottle += (actualXZ - predictedXZ) / (SimulationRate * Time.deltaTime); } }