private void UpdateDirectionKeys() { if (KeyboardEventHandler == null) { return; } var keyUp = false; foreach (var direction in DirectionExt.Values) { var keys = directionKeys[direction]; if (InputExt.IsAnyKeyDown(keys)) { pressedKeys.Add(direction); } else if (InputExt.IsAnyKeyUp(keys)) { pressedKeys.Remove(direction); keyUp = true; } } if (pressedKeys.Count > 0) { var movement = pressedKeys.Last; PanArgs args; if (movement == previousMovement) { args = new PanArgs(HandyDetector.Gesture.Press, PanArgs.State.Hold, Vector2.zero, Vector2.zero, Vector2.zero); } else { var delta = movement.Reverse().ToVector2(); args = new PanArgs(HandyDetector.Gesture.Press, PanArgs.State.Move, Vector2.zero, Vector2.zero, delta * 10); } KeyboardEventHandler.OnGesturePan(args); previousMovement = pressedKeys.Last; } else if (keyUp) { var args = new PanArgs(HandyDetector.Gesture.Press, PanArgs.State.Up, Vector2.zero, Vector2.zero, Vector2.zero); KeyboardEventHandler.OnGesturePan(args); previousMovement = null; } }
public void Update(float textSpeed) { //Debug.Log(displayedText); //Debug.Log(currentEntry); //if (currentEntry == null) { // Debug.Log("Impossibru!"); //} if (currentEntry != null && displayedText.Length != currentEntry.Content.Length) { string previous = displayedText; float chars = (Time.time - entryStartTime) * textSpeed; if (chars < currentEntry.Content.Length) { displayedText = currentEntry.Content.Substring(0, (int)chars); } else { displayedText = currentEntry.Content; return; } isTalking = (previous != displayedText); if (IsTalking) { if (!voiceOutput.isPlaying) { voiceOutput.clip = currentEntry.Author.VoiceSample; voiceOutput.pitch = UnityEngine.Random.Range(1.25f, 1.75f); voiceOutput.Play(); } } } fastforward = Input.GetMouseButtonDown(0) || InputExt.IsAnyKeyDown(KeyCode.Space, KeyCode.Return); }