public void PlayAnimation(NPCAnimations.AnimationIndex animationIndex, int fps = -1) { if (currentAnimation != animationIndex) { animationControl.StopAnimation(); NPCAnimations.AnimationSequence sequence = animationsList.RetrieveAnimationSequence(animationIndex); animationControl.SetAnimationList(sequence.textures); animationControl.SetSpeed(sequence.speed); animationControl.PlayAnimation(); currentAnimation = animationIndex; } if (fps > 0) animationControl.SetFPS(fps); }
// Use this for initialization void Start() { // If the dialogue has replies if (wrongReplies != null) { remainingReplies = wrongReplies.Count; if (rightReply != null) { // Add the right reply replies.Add(rightReply); rightReply.SetIndex(0); rightReply.id = 0; remainingReplies++; } int counter; for (counter = 0; counter < wrongReplies.Count; counter++) wrongReplies [counter].id = counter + 1; Reply tempReply; // Randomize the list of wrong replies if (rightReply != null) { for (counter = 0; counter < wrongReplies.Count; counter++) { int randomindex = Random.Range(counter, wrongReplies.Count); tempReply = wrongReplies [randomindex]; wrongReplies [randomindex] = wrongReplies [counter]; wrongReplies [counter] = tempReply; } } // Populate the list of replies int addedIndex = (rightReply == null) ? 0 : 1; for (counter = 0; counter < numDisplayedReplies - addedIndex; counter++) { wrongReplies [counter].SetIndex(counter + addedIndex); replies.Add(wrongReplies [counter]); } // Randomize the list of replies if (rightReply != null) { for (counter = (Mathf.Min(numDisplayedReplies, remainingReplies) - 1); counter > 0; counter--) { int k = Random.Range(0, counter + 1); //Debug.Log ("Random index:" + k + " Current index:" + counter); tempReply = replies [k]; replies [k] = replies [counter]; replies [counter] = tempReply; replies [counter].SetIndex(counter); replies [k].SetIndex(k); } } } remainingReplies = Mathf.Min(remainingReplies, 4); // If there is no portrait after the voice over, then set the voice over to the initial portrait if (audioPortrait == null) audioPortrait = playerPortrait; if (playerFinalAnimation == NPCAnimations.AnimationIndex.NONE) playerFinalAnimation = playerInitialAnimation; }