//重置数据 private void Reset() { EditorUtility.NodeClassDic.Clear(); treeView1.Nodes.Clear(); NodeClasses = new NodeClasses(); NodeClasses.ResetEnums(); NodeClasses.ResetNodes(); TreeData = new TreeData(); SetSelectedAgent(null); }
public static BehaviorTreeData.TreeData CreateTreeData(TreeData treeData) { BehaviorTreeData.TreeData data = new BehaviorTreeData.TreeData(); for (int i = 0; i < treeData.Agents.Count; i++) { AgentDesigner agent = treeData.Agents[i]; if (agent == null) { continue; } data.Agents.Add(CreateAgentData(agent)); } return(data); }
public void LoadBehaviorTreeData() { //读取行为树数据 TreeData = XmlUtility.Read <TreeData>(GetBehaviorTreeDataPath()); if (TreeData == null) { TreeData = new TreeData(); XmlUtility.Save(GetBehaviorTreeDataPath(), TreeData); } BehaviorTreeDataStringContent = XmlUtility.ObjectToString(TreeData); if (TreeData.Agents.Count > 0) { for (int i = 0; i < TreeData.Agents.Count; i++) { AgentDesigner agent = TreeData.Agents[i]; if (agent != null) { if (agent.Nodes.Count > 0) { for (int ii = 0; ii < agent.Nodes.Count; ii++) { NodeDesigner node = agent.Nodes[ii]; if (node.Transitions.Count > 0) { for (int iii = 0; iii < node.Transitions.Count; iii++) { Transition transition = node.Transitions[iii]; NodeDesigner fromNode = agent.FindNodeByID(transition.FromNodeID); NodeDesigner toNode = agent.FindNodeByID(transition.ToNodeID); transition.Set(toNode, fromNode); } } } } } } } }