public static AIRuntimeTreeData Parse(string json, string name) { // XDebug.Log(json); var obj = MiniJSON.Json.Deserialize(json) as Dictionary <string, object>; var root = obj as Dictionary <string, object>; AIRuntimeTreeData tree = new AIRuntimeTreeData(); //Variables if (root.ContainsKey("Variables")) { var list = root["Variables"] as List <object>; for (int i = 0, max = list.Count; i < max; i++) { if (tree.vars == null) { tree.vars = new List <AITreeVar>(); } AITreeVar v = ParseTreeVar(list[i] as Dictionary <string, object>); tree.vars.Add(v); } } //task var dic_task = root["RootTask"] as Dictionary <string, object>; AIRuntimeTaskData task = ParseTask(dic_task); tree.task = task; return(tree); }
public override void Init(AIRuntimeTaskData data) { if (data.children != null && data.children.Count > 0) { node = AIRuntimeFactory.MakeRuntime(data.children[0], _tree); } }
private static AIRuntimeTaskData ParseTask(Dictionary <string, object> task) { AIRuntimeTaskData t = new AIRuntimeTaskData(); foreach (var item in task) { if (item.Key == Type) { t.type = task[Type].ToString(); t.mode = Type2Mode(t.type); } else if (item.Key == Children) { List <object> list = task[Children] as List <object>; for (int i = 0, max = list.Count; i < max; i++) { Dictionary <string, object> child = list[i] as Dictionary <string, object>; if (t.children == null) { t.children = new List <AIRuntimeTaskData>(); } AIRuntimeTaskData tt = ParseTask(child); t.children.Add(tt); } } else if (item.Value is Dictionary <string, object> ) { AIVar v = ParseSharedVar(item.Key, item.Value as Dictionary <string, object>); if (t.vars == null) { t.vars = new List <AIVar>(); } t.vars.Add(v); } else { AIVar v = ParseCustomVar(item.Key, item.Value); if (v != null) { if (t.vars == null) { t.vars = new List <AIVar>(); } t.vars.Add(v); } } } return(t); }
public override void Init(AIRuntimeTaskData data) { if (data.children != null) { for (int i = 0, max = data.children.Count; i < max; i++) { if (list == null) { list = new List <AIRunTimeBase>(); } AIRunTimeBase run = AIRuntimeFactory.MakeRuntime(data.children[i], _tree); list.Add(run); } } }
public virtual void Init(AIRuntimeTaskData data) { }