TreeNode BuildTree(FB.FFSM.TreeStateConfig config) { TreeNode tree = null; Dictionary <string, TreeNode> nodes = new Dictionary <string, TreeNode>(); if (config.states != null) { foreach (var a in config.states) { if (!nodes.ContainsKey(a.name)) { nodes.Add(a.name, new TreeNode() { aniname = a.name }); } } } foreach (var a in config.states) { if (string.IsNullOrEmpty(a.parent)) { tree = nodes[a.name]; } else { if (nodes.ContainsKey(a.parent)) { nodes[a.parent].Add(nodes[a.name]); } } } return(tree); }
static void CreateTreeStateConfig() { string outpath = GetCreatePath(); //Debug.Log("setpath=" + path); FB.FFSM.TreeStateConfig config = ScriptableObject.CreateInstance <FB.FFSM.TreeStateConfig>(); AssetDatabase.CreateAsset(config, outpath); }
public override void OnInspectorGUI() { if (Application.isPlaying || target == null) { base.OnInspectorGUI(); return; } bShowTree = GUILayout.Toggle(bShowTree, "编辑树/修改值"); if (bShowTree) { EditorGUILayout.HelpBox("这是一个AnimConfig树查看工具", MessageType.Info); statetree = target as FB.FFSM.TreeStateConfig; TreeNode t = BuildTree(statetree); if (t != null) { FillTree(t); } } else { base.OnInspectorGUI(); } }
public FightFSM(IGraphChar player, ILogicCharDriver charLogic, StateTable table, AI_StateTable aiStateTable, TreeStateConfig stateTree, IJoyInput joy) { this.aniPlayer = player; this.charLogic = charLogic; this.stateTable = table; this.aiStateTable = aiStateTable; InitBlockParserMap(); //StateItem 存储指令 mapState = new Dictionary <string, StateItem>(); foreach (var s in stateTable.allStates) { mapState[s.name] = s; } this.joy = joy; this.fps = aniPlayer.fps; ChangeBlock("stand", 0); mapBackState = new Dictionary <string, string>(); if (stateTree == null) { return; } foreach (var state in stateTree.states) { if (mapState.ContainsKey(state.name)) { mapBackState[state.name] = state.name;//自己就有 continue; } else { var node = stateTree.GetNode(state.name); while (node != null) { if (mapState.ContainsKey(node.name)) { break; } node = node.parent; } if (node == null) { throw new Exception("无效状态:" + state.name); } mapBackState[state.name] = node.name;//找到上层 } } //player.set }