private IEnumerator Tween(GraphEngine graphEngine) { Vector3 start = Target.position; Vector3 end = Destination.position; float elapsedTime = 0; while (elapsedTime < Duration) { elapsedTime = Mathf.Clamp(elapsedTime + Time.deltaTime, 0, Duration); float normalized = Mathf.Clamp(elapsedTime / Duration, 0, 1); Vector3 interpPosition = start * (1 - normalized) + end * (normalized); if (Target != null) { Target.position = interpPosition; } else { elapsedTime = Duration; } yield return(null); } if (PauseGraph) { graphEngine.UnlockNode(); } }
/// <summary> /// Waits the predetermined number of seconds before playing the next node. /// </summary> private IEnumerator Wait(GraphEngine graphEngine) { if (graphEngine.LockNode()) { yield return(new WaitForSeconds(Seconds)); graphEngine.UnlockNode(); } }
//------------------------------------------------------------------------- // Helper Methods //------------------------------------------------------------------------- private IEnumerator Shake(GraphEngine graphEngine) { GameManager.CurrentTargettingCamera.CameraShake(Duration, DelayBefore, Intensity); while (GameManager.CurrentTargettingCamera.Shaking) { yield return(null); } yield return(new WaitForSeconds(DelayAfter)); if (PauseGraph) { graphEngine.UnlockNode(); } }
//------------------------------------------------------------------------- // Helper Methods //------------------------------------------------------------------------- private IEnumerator TryWalk(GraphEngine graphEngine) { UnityTask walking = WalkToPosition.WalkTo(target, Speed, graphEngine, PauseGraph, DelayAfter); while (walking.Running) { yield return(null); } if (FacingAfter != Facing.None) { GameManager.Player.SetFacing(FacingAfter); } yield return(new WaitForSeconds(DelayAfter)); if (PauseGraph) { graphEngine.UnlockNode(); } }
//------------------------------------------------------------------------- // Helper Methods //------------------------------------------------------------------------- private IEnumerator Jump(GraphEngine graphEngine) { GameManager.Player.EnableJump(DialogManager.Instance); IInputComponent playerInput = GameManager.Player.PlayerInput; IInputComponent vInput = new VirtualInput(); GameManager.Player.PlayerInput = vInput; GameManager.GamePad.PressButton("Jump"); yield return(null); GameManager.Player.PlayerInput = playerInput; GameManager.Player.DisableJump(DialogManager.Instance); if (DelayAfter > 0) { yield return(new WaitForSeconds(DelayAfter)); } graphEngine.UnlockNode(); }
//------------------------------------------------------------------------- // Helper Methods //------------------------------------------------------------------------- /// <summary> /// Play a timeline! /// </summary> /// <param name="graphEngine">The graphing engine that called this node.</param> /// <returns></returns> private IEnumerator PlayTimeline(GraphEngine graphEngine) { bool containsPlayer = TimelineContainsPlayer(); if (containsPlayer && StartPosition != null) { UnityTask walk = WalkToPosition.WalkTo(StartPosition, InputSpeed, graphEngine, true, WaitBefore); while (walk.Running) { yield return(null); } } UnityTask play = new UnityTask(Play(graphEngine)); while (play.Running) { yield return(null); } graphEngine.UnlockNode(); }