コード例 #1
0
 public SecuenceTransition(SecuenceNode source, SecuenceNode dest, float duration, Func <SecuenceTransition, bool> trigger)
 {
     _sourceNode     = source;
     _destNode       = dest;
     _transitionTime = duration;
     _trigger        = trigger;
 }
コード例 #2
0
        public SecuenceStateMachine WithState(string name, Action <SecuenceNode> action)
        {
            SecuenceNode node = new SecuenceNode(name);

            WithState(node);
            action(node);
            return(this);
        }
コード例 #3
0
        public bool RemoveTransitions(SecuenceNode node)
        {
            List <SecuenceTransition> tempTransitions = new List <SecuenceTransition>();

            foreach (var item in _transitions)
            {
                if (item.DestNode == node)
                {
                    tempTransitions.Add(item);
                }
            }

            foreach (var item in tempTransitions)
            {
                _transitions.Remove(item);
            }

            return(tempTransitions.Count > 0);
        }
コード例 #4
0
        public void Update(float elapsedTime)
        {
            if (_nodes.Count == 0)
            {
                return;
            }

            if (_currentNode == null)
            {
                _currentNode = _nodes[0];
            }

            SecuenceNode next = null;

            while ((next = _currentNode.Update(elapsedTime)) != null)
            {
                _currentNode.OnDeactivating();
                next.OnActivating();

                _currentNode = next;
            }
        }
コード例 #5
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);
        }
コード例 #6
0
 public SecuenceTransition(SecuenceNode dest, float duration, Func <SecuenceTransition, bool> trigger = null)
     : this(null, dest, duration, trigger)
 {
 }
コード例 #7
0
 public SecuenceStateMachine WithState(SecuenceNode node)
 {
     _nodes.Add(node);
     node.Id = _nodes.Count - 1;
     return(this);
 }