private void SweepForwardGesture(KinematicsTracker tracker) { if (OnSweepForward != null) { OnSweepForward(tracker); } }
private void SweepVerticalGesture(KinematicsTracker tracker) { if (OnSweepVertical != null) { OnSweepVertical(tracker); } }
private void FistCloseGesture(KinematicsTracker tracker) { if (OnCloseFist != null) { OnCloseFist(tracker); } }
private void OnDiscarded(KinematicsTracker palm) { if (GameFSM.Instance.Current.Hand.Count > HandIndex && Cmp.IsSelected) { GameFSM.Instance.StartCoroutine(DiscardCoroutine(palm.GetAverageVelocity(InputController.Instance.GestureDuration).x)); } }
private void SweepSideGesture(KinematicsTracker tracker) { if (OnSweepSideways != null) { OnSweepSideways(tracker); } }
private void GestureResponse(KinematicsTracker palm) { if (touching.Contains(palm)) { ChooseElementsState state = (ChooseElementsState)GameFSM.Instance.CurrentState; state.OnChosen(this, Choice); } }
protected override void OnExitTrigger(KinematicsTracker tracker) { base.OnExitTrigger(tracker); if (touching.Count == 0) { sizeTw.Target = 0.0f; } }
private void OnGestured(KinematicsTracker tracker) { if (gameObject.activeSelf && touching.Contains(tracker) && GameFSM.Instance.CurrentState is ChooseToDiscardState) { GameFSM.Instance.StartCoroutine(DrawCardsCoroutine(GameFSM.Instance.Current)); } }
private void OnGestured(KinematicsTracker tracker) { if (gameObject.activeSelf && touching.Contains(tracker) && GameFSM.Instance.CurrentState is ChooseToDiscardState) { GameFSM.Instance.StartCoroutine(DrawCardsCoroutine(GameFSM.Instance.Current)); } }
void Update() { if (DisableAllGestures) { return; } for (int i = 0; i < PalmTrackers.Length; ++i) { KinematicsTracker palmT = PalmTrackers[i], fingerT = FingerTrackers[i]; if (palmT != null) { palmT.Debugging = Debugging; if (trackerCalmTime[i] <= 0.0f) { Vector3 avgVel = palmT.GetAverageVelocity(GestureDuration); Vector3 palmPos = palmT.PositionLogs[palmT.GetLogIndex(0)], fingerPos = fingerT.PositionLogs[fingerT.GetLogIndex(0)]; if (Mathf.Abs(avgVel.x) >= VelThreshold) { SweepSideGesture(palmT); trackerCalmTime[i] = CalmTime; } else if (Mathf.Abs(avgVel.y) >= VelThreshold) { SweepVerticalGesture(palmT); trackerCalmTime[i] = CalmTime; } else if (Mathf.Abs(avgVel.z) >= VelThreshold) { SweepForwardGesture(palmT); trackerCalmTime[i] = CalmTime; } else if ((Horz(palmPos) - Horz(fingerPos)).sqrMagnitude <= (FistCloseDistThreshold * FistCloseDistThreshold)) { fistCloseTime[i] += Time.deltaTime; if (fistCloseTime[i] >= CloseFistTime) { fistCloseTime[i] = 0.0f; trackerCalmTime[i] = CalmTime; FistCloseGesture(palmT); } } } else { trackerCalmTime[i] -= Time.deltaTime; } } } }
protected override void Awake() { base.Awake(); if (HandControls == null) { Debug.LogError("'HandControls' in 'InputController' component is null!"); } if (LaserPointerHandPrefab == null) { Debug.LogError("'LaserPointerHandPrefab' is null!"); } HandControls.onCreateHand += (handModel => { if (handModel.gameObject.GetComponent <RigidHand>() != null) { return; } Instantiate <GameObject>(LaserPointerHandPrefab).transform.parent = handModel.palm; KinematicsTracker palmTrack = handModel.palm.gameObject.AddComponent <KinematicsTracker>(), fingerTrack = handModel.fingers[2].bones[FingerModel.NUM_BONES - 1].gameObject.AddComponent <KinematicsTracker>(); if (PalmTrackers[0] == null) { PalmTrackers[0] = palmTrack; FingerTrackers[0] = fingerTrack; trackerCalmTime[0] = CalmTime; fistCloseTime[0] = 0.0f; } else { if (PalmTrackers[1] != null) { Debug.LogError("More than two hands!"); } else { PalmTrackers[1] = palmTrack; FingerTrackers[1] = fingerTrack; trackerCalmTime[1] = CalmTime; fistCloseTime[1] = 0.0f; } } }); }
private void OnSelected(KinematicsTracker palm) { if (touching.Contains(palm) && gameObject.activeInHierarchy && Tweenee != MyTransform && GameFSM.Instance.Current.Hand.Count > HandIndex) { if (Cmp.IsSelected) { TweenTarget = 0.0f; Cmp.IsSelected = false; } else { TweenTarget = 1.0f; Cmp.IsSelected = true; } } }
private void OnGesture(KinematicsTracker palm) { Player current = GameFSM.Instance.Current; if (touching.Contains(palm)) { switch (ThisChoice) { case Choices.ChangeCharacters: //TODO: Handle. break; case Choices.GainEnergy: current.Energy[current.SecondChar] += GameConsts.Instance.Characters[current.SecondChar].PassiveEnergyPerTurn; break; default: throw new NotImplementedException("Unknown choice " + ThisChoice); } //TODO: Change state. GameFSM.Instance.CurrentState = null; } }
private void OnGesture(KinematicsTracker palm) { Player current = GameFSM.Instance.Current; if (touching.Contains(palm)) { switch (ThisChoice) { case Choices.ChangeCharacters: //TODO: Handle. break; case Choices.GainEnergy: current.Energy[current.SecondChar] += GameConsts.Instance.Characters[current.SecondChar].PassiveEnergyPerTurn; break; default: throw new NotImplementedException("Unknown choice " + ThisChoice); } //TODO: Change state. GameFSM.Instance.CurrentState = null; } }
protected override void OnEnterTrigger(KinematicsTracker tracker) { base.OnEnterTrigger(tracker); sizeTw.Target = 1.0f; }
private void OnDiscarded(KinematicsTracker palm) { if (GameFSM.Instance.Current.Hand.Count > HandIndex && Cmp.IsSelected) { GameFSM.Instance.StartCoroutine(DiscardCoroutine(palm.GetAverageVelocity(InputController.Instance.GestureDuration).x)); } }
private void OnSelected(KinematicsTracker palm) { if (touching.Contains(palm) && gameObject.activeInHierarchy && Tweenee != MyTransform && GameFSM.Instance.Current.Hand.Count > HandIndex) { if (Cmp.IsSelected) { TweenTarget = 0.0f; Cmp.IsSelected = false; } else { TweenTarget = 1.0f; Cmp.IsSelected = true; } } }
/// <summary> /// Reacts to a sideways sweeping gesture. /// </summary> public virtual void OnSweepSideways(KinematicsTracker palmMovement) { }
/// <summary> /// Reacts to a vertical sweeping gesture. /// </summary> public virtual void OnSweepVertical(KinematicsTracker palmMovement) { }
protected virtual void OnExitTrigger(KinematicsTracker tracker) { }
protected override void OnEnterTrigger(KinematicsTracker tracker) { base.OnEnterTrigger(tracker); sizeTw.Target = 1.0f; }
private Vector3 GetWorldForward(KinematicsTracker tracker) { return tracker.ForwardLogs[tracker.GetLogIndex(0)]; }
protected override void OnExitTrigger(KinematicsTracker tracker) { base.OnExitTrigger(tracker); if (touching.Count == 0) sizeTw.Target = 0.0f; }
/// <summary> /// Reacts to a closing fist gesture. /// </summary> public virtual void OnCloseFist(KinematicsTracker palmMovement) { }
void Start() { Hand = GetComponent<HandModel>(); EyeCenter = transform.parent.parent.parent; PalmTracker = AddTrackerTo(Hand.palm.gameObject); FingerTrackers = new KinematicsTracker[5]; IsFingerPointing = new bool[5]; for (int i = 0; i < 5; ++i) { FingerTrackers[i] = AddTrackerTo(Hand, i); IsFingerPointing[i] = false; } mySpells = SpellConstants.Instance.Spells.Select(sp => sp.MakeCopy()).ToList(); }
private Vector3 GetWorldPos(KinematicsTracker tracker) { return tracker.PositionLogs[tracker.GetLogIndex(0)]; }
protected virtual void OnDuringTrigger(KinematicsTracker tracker) { }
/// <summary> /// Reacts to a closing fist gesture. /// </summary> public virtual void OnCloseFist(KinematicsTracker palmMovement) { }
protected virtual void OnExitTrigger(KinematicsTracker tracker) { }
/// <summary> /// Reacts to a forward/back sweeping gesture. /// </summary> public virtual void OnSweepForward(KinematicsTracker palmMovement) { }
/// <summary> /// Reacts to a forward/back sweeping gesture. /// </summary> public virtual void OnSweepForward(KinematicsTracker palmMovement) { }
protected virtual void OnDuringTrigger(KinematicsTracker tracker) { }
protected override void OnExitTrigger(KinematicsTracker tracker) { UnityEngine.Debug.Log("Exited trigger"); }
/// <summary> /// Reacts to a sideways sweeping gesture. /// </summary> public virtual void OnSweepSideways(KinematicsTracker palmMovement) { }
/// <summary> /// Reacts to a vertical sweeping gesture. /// </summary> public virtual void OnSweepVertical(KinematicsTracker palmMovement) { }
protected override void OnExitTrigger(KinematicsTracker tracker) { UnityEngine.Debug.Log("Exited trigger"); }