/// <summary> /// Sequences the animations in AnimSequence. /// </summary> /// <param name="anims">{animation, length} pairs</param> /// <returns>yield</returns> private IEnumerator AnimatorWaiter(IEnumerable anims) { if (AnimSequence == null || _animatorManager.WalkedAway()) { yield break; } foreach (Pair <string, float> pair in anims) { if (!_animatorManager.GetBoolAnimator("talk")) { yield break; } _animatorManager.CrossfadeAnimator(pair.GetA(), 0.03f, -1); _animatorManager.SetBoolAnimator("loop", true); //Wait for a set amount of seconds before starting the other animation. yield return(new WaitForSeconds(pair.GetB())); _animatorManager.SetBoolAnimator("loop", false); } }
private static void HandleInput(AnimatorManager animatorManager) { if (Input.GetKeyDown(KeyCode.Space)) { animatorManager.CrossfadeAnimator("talking", 0.1f, -1); } if (Input.GetKeyDown("1")) { // This animation is very long so it looks like it is stuck in this state, // but it is not. animatorManager.PlayOnce("sitting_talking", 0.1f, -1); } if (Input.GetKeyDown("2")) { animatorManager.PlayOnce("Walk", 0.1f, -1); } if (Input.GetKeyDown("3")) { animatorManager.PlayOnce("Run", 0.1f, -1); } if (Input.GetKeyDown("4")) { animatorManager.PlayOnce("Afraid", 0.1f, -1); } if (Input.GetKeyDown("5")) { animatorManager.PlayOnce("Happy", 0.1f, -1); } if (Input.GetKeyDown("6")) { animatorManager.PlayOnce("Sad", 0.1f, -1); } if (Input.GetKeyDown("7")) { animatorManager.PlayOnce("Surprise", 0.1f, -1); } if (Input.GetKeyDown("8")) { animatorManager.PlayOnce("Angry", 0.1f, -1); } if (Input.GetKeyDown("9")) { animatorManager.PlayOnce("Cubeintro", 0f, -1); } if (Input.GetKeyDown(KeyCode.C)) { ApplicationManager.Instance.ChangeCoach(); } if (Input.GetKeyDown(KeyCode.B)) { ApplicationManager.Instance.ChangeBackground(); } if (Input.GetKeyDown(KeyCode.K)) { ApplicationManager.Instance.WalkAway(); } if (Input.GetKeyDown(KeyCode.L)) { ApplicationManager.Instance.WalkBack(); } if (Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.W)) { animatorManager.CrossfadeAnimator("Walk", 0.05f, -1); } if (Input.GetKeyUp(KeyCode.UpArrow) || Input.GetKeyUp(KeyCode.W)) { animatorManager.CrossfadeAnimator("idle", 0.2f, -1); } // Press R to reset the position and rotation of the avatar. if (Input.GetKeyDown(KeyCode.R)) { ApplicationManager.Instance.ResetPosition(); } }