Beispiel #1
0
        /// <summary>
        /// Runs the animation scripts
        /// </summary>
        /// <param name="gameTime">The game time</param>
        public override void Update(GameTime gameTime)
        {
            // Execute scripts only if the animation is started and is running
            if (_started && _running)
            {
                if (_scriptNodes.Count == _nodeIndex)
                {
                    // The last path node has been reached
                    Stop();

                    if (_repeatAnimation)
                    {
                        // Here we go again!
                        Start();
                    }

                    if (OnEnd != null)
                    {
                        OnEnd(this, EventArgs.Empty);
                    }
                }
                else
                {
                    // Get the current script node
                    BaseScriptNode currentNode = _scriptNodes[_nodeIndex];

                    // Perform the scripted animation
                    currentNode.Update(gameTime, _target);

                    if (currentNode.ScriptDone)
                    {
                        // The script is done, jump to the next one
                        _nodeIndex++;
                    }
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// Add a script node to the animator
 /// </summary>
 /// <param name="node"></param>
 public void Add(BaseScriptNode node)
 {
     _scriptNodes.Add(node);
 }
Beispiel #3
0
 /// <summary>
 /// Add a script node to the animator
 /// </summary>
 /// <param name="node"></param>
 public void Add(BaseScriptNode node)
 {
     _scriptNodes.Add(node);
 }