private void RetrieveAnimationsFromCombatStateTree()
        {
            m_animationList.Clear();
            StateNode root = m_charViewData.StateTree.RootNode;

            PopulateAnimationSerializedObject(root);
        }
        private void CreateStartingNodeGraph()
        {
            StateNode startingState = m_charViewData.StateTree.RootNode;

            CharacterStateNode n = GenerateNode(startingState);

            GenerateChildrenNodes(n);
        }
        public CharacterStateNode(StateNode n)
        {
            NodeData = n;
            GUID     = Guid.NewGuid().ToString();
            OwningSerializedObject = n.OwnerStateObject;
            title = n.OwnerState.name;


            InitializeStyleSheet();
            CreateInputPort();
        }
Exemple #4
0
        public Vector2 GetNodePosition(StateNode _nodeData)
        {
            Vector2 position = new Vector2();

            if (!m_nodePositionLookup.TryGetValue(_nodeData.OwnerState.name, out position))
            {
                Vector2 pos = GetRawNodePosition(_nodeData);
                m_nodePositionLookup.Add(_nodeData.OwnerState.name, pos);
            }


            return(position);
        }
        private CharacterStateNode GenerateNode(StateNode _nodeData)
        {
            CharacterStateNode n = new CharacterStateNode(_nodeData);

            AddElement(n);

            Vector2 position = m_charViewData.CharacterStateGraph.GetNodePosition(_nodeData);

            AddStateNodeToStack(n);

            Rect parentPosition = new Rect(position.x, position.y, 150, 150);

            n.SetPosition(parentPosition);

            return(n);
        }
        private void PopulateAnimationSerializedObject(StateNode _node)
        {
            if (_node.CombatAnimation != null && !_node.IsRepeatNode)
            {
                m_animationList.Add(_node.CombatAnimation);
            }


            if (_node.StateTransitions.Count == 0)
            {
                return;
            }

            foreach (KeyValuePair <OTGCombatState, StateNodeTransition> pair in _node.StateTransitions)
            {
                PopulateAnimationSerializedObject(pair.Value.Transition);
            }
        }
Exemple #7
0
        private void FindTransitions(SerializedObject _ownerObj, Dictionary <OTGCombatState, int> _stateRecord, int _currentLevel)
        {
            int amountOfTransitions = _ownerObj.FindProperty("m_stateTransitions").arraySize;

            for (int i = 0; i < amountOfTransitions; i++)
            {
                Object nextStateObj = _ownerObj.FindProperty("m_stateTransitions").GetArrayElementAtIndex(i).FindPropertyRelative("m_nextState").objectReferenceValue;
                if (nextStateObj != null)
                {
                    OTGCombatState state             = (OTGCombatState)nextStateObj;
                    bool           transitionRepeats = (_stateRecord.ContainsKey(state)) ? true : false;



                    StateNode           n      = new StateNode(state, _currentLevel + 1, _stateRecord, i);
                    StateNodeTransition nTrans = new StateNodeTransition(transitionRepeats, n);
                    if (!StateTransitions.ContainsKey(state))
                    {
                        StateTransitions.Add(state, nTrans);
                    }
                }
            }
        }
Exemple #8
0
 public CharacterStateTree(OTGCombatState _startingState)
 {
     RecordOfStates = new Dictionary <OTGCombatState, int>();
     RootNode       = new StateNode(_startingState, 0, RecordOfStates, 0);
 }
Exemple #9
0
 public StateNodeTransition(bool _repeat, StateNode _n)
 {
     ShouldReturnToAnExistingState = _repeat;
     Transition = _n;
 }
Exemple #10
0
        private Vector2 GetRawNodePosition(StateNode _nodeData)
        {
            Vector2 position = new Vector2((_nodeData.Level * 200) + 150, (_nodeData.Order * 150));

            return(position);
        }