// Update is called once per frame void Update() { if (isInProximity) { if (!hasConfirmedEvent) { if (SwipeScript.Instance.GetSwipe() == SwipeDirection.Left || Input.GetKeyDown(KeyCode.A)) { curEvent = EventType.SwipeLeft; hasConfirmedEvent = true; } else if (SwipeScript.Instance.GetSwipe() == SwipeDirection.Right || Input.GetKeyDown(KeyCode.D)) { curEvent = EventType.SwipeRight; hasConfirmedEvent = true; } else { curEvent = EventType.MoveForward; hasConfirmedEvent = false; } } } else { hasConfirmedEvent = false; curEvent = EventType.None; } if (curEvent != EventType.None) { switch (curEvent) { case EventType.SwipeLeft: if (hasConfirmedEvent) { pointingNode = touchedNodes[0].data.leftNode((int)playerDirection); playerDirection = (Direction)(((int)playerDirection + 3) % (int)Direction.Total); curEvent = EventType.None; } break; case EventType.SwipeRight: if (hasConfirmedEvent) { pointingNode = touchedNodes[0].data.rightNode((int)playerDirection); playerDirection = (Direction)(((int)playerDirection + 1) % (int)Direction.Total); curEvent = EventType.None; } break; case EventType.MoveForward: pointingNode = touchedNodes[0].data.forwardNode((int)playerDirection); break; } } if (pointingNode) { GameManagerScript.Instance.player.RotateTowards(pointingNode.transform.position); } }
public void RegisterNode(WaypointNodeScript node) { tracePlayerNodes.Add(node); touchedNodes.Add(node); }
public void UnregisterNode(WaypointNodeScript node) { touchedNodes.Remove(node); }
IEnumerable<YieldInstruction> WalkPath() { var timeLeft = PianoInterval * 100; while (timeLeft > 0) { var startPos = GetFromPoint(); var endPos = GetTargetPoint(); var length = (endPos - startPos).magnitude; var currNode = GetFromNode(); var targetNode = GetToNode(); if (currNode != lastVisitedNode) { lastVisitedNode = currNode; if (currNode.LookBack) { StartCoroutine(DoPiano().GetEnumerator()); yield break; } } var realMoveSpeed = WalkSpeed * currNode.WalkModifier; PathProgression += realMoveSpeed * GetFromNode().WalkModifier / length * Time.deltaTime; PathProgression = Mathf.Clamp(PathProgression, 0, Path.transform.childCount - 1); updateOrientationUsingPathProgression(); yield return null; timeLeft -= Time.deltaTime; } }