Esempio n. 1
0
        public SecuenceNode Update(float deltaT)
        {
            if (_currentTransition == null)
            {
                foreach (var tr in _transitions)
                {
                    if (tr.IsTriggered())
                    {
                        _currentTransition = tr;
                    }
                }
            }

            SecuenceNode next = null;

            if (_currentTransition != null)
            {
                //it's in transition
                if (!_currentTransition.Blend(deltaT))
                {
                    //the transition has ended
                    //move to the next state
                    next = _currentTransition.DestNode;
                    _currentTransition = null;
                }
            }
            else
            {
                OnBeforeUpdate(deltaT);

                //its playing the state and there aren't any transitions triggered
                UpdateAnimations(deltaT, _animations.Count == 1 ? -1 : 1, 1);

                OnAfterUpdate(deltaT);
            }

            return(next);
        }
Esempio n. 2
0
 public SecuenceNode TransitionTo(SecuenceTransition transition)
 {
     _transitions.AddLast(transition);
     return(this);
 }
Esempio n. 3
0
 public bool RemoveTransition(SecuenceTransition transition)
 {
     return(_transitions.Remove(transition));
 }
Esempio n. 4
0
 public void AddTransition(SecuenceTransition transition)
 {
     transition.SourceNode = this;
     _transitions.AddLast(transition);
 }
Esempio n. 5
0
        public SecuenceStateMachine WithTransition(string sourceNode, string destNode, SecuenceTransition transition)
        {
            transition.SourceNode = _nodes[sourceNode];
            transition.DestNode   = _nodes[destNode];

            transition.Name = sourceNode + "->" + destNode;

            transition.SourceNode.AddTransition(transition);

            return(this);
        }