Ejemplo n.º 1
0
        private void LoadData()
        {
            Debug.Log($"Loading AI data from '{TestAssetPath}'...");

            AIData data = AssetDatabase.LoadAssetAtPath <AIData>(TestAssetPath);

            if (null == data)
            {
                Debug.LogError("Could not load AI data!");
                return;
            }

            foreach (AIState state in data.States)
            {
                AIEditorNode stateNode = new AIEditorNode(state.EditorPosition, state.Name, this);
                AddNode(stateNode);

                // TODO: check for overwrites
                _states[state.Id] = stateNode;
            }

            foreach (AIStateTransition stateTransition in data.StateTransitions)
            {
                AIEditorNode startNode = _states.GetOrDefault(stateTransition.StartState);
                if (null == startNode)
                {
                    Debug.Log($"No such start state {stateTransition.StartState}!");
                    continue;
                }

                AIEditorNode endNode = _states.GetOrDefault(stateTransition.EndState);
                if (null == endNode)
                {
                    Debug.Log($"No such end state {stateTransition.EndState}!");
                    continue;
                }

                AIEditorEdge stateEdge = new AIEditorEdge(this)
                {
                    StartNode = startNode,
                    EndNode   = endNode
                };
                AddEdge(stateEdge);
            }
        }
Ejemplo n.º 2
0
        private void LoadData()
        {
            Debug.Log($"Loading AI data from '{TestAssetPath}'...");

            AIData data = AssetDatabase.LoadAssetAtPath<AIData>(TestAssetPath);
            if(null == data) {
                Debug.LogError("Could not load AI data!");
                return;
            }

            foreach(AIState state in data.States) {
                AIEditorNode stateNode = new AIEditorNode(state.EditorPosition, state.Name, this);
                AddNode(stateNode);

                // TODO: check for overwrites
                _states[state.Id] = stateNode;
            }

            foreach(AIStateTransition stateTransition in data.StateTransitions) {
                AIEditorNode startNode = _states.GetOrDefault(stateTransition.StartState);
                if(null == startNode) {
                    Debug.Log($"No such start state {stateTransition.StartState}!");
                    continue;
                }

                AIEditorNode endNode = _states.GetOrDefault(stateTransition.EndState);
                if(null == endNode) {
                    Debug.Log($"No such end state {stateTransition.EndState}!");
                    continue;
                }

                AIEditorEdge stateEdge = new AIEditorEdge(this)
                {
                    StartNode = startNode,
                    EndNode = endNode
                };
                AddEdge(stateEdge);
            }
        }