Beispiel #1
0
        public BehaviorTreeData ReadJson(string filePath)
        {
            Debug.Log("Read:" + filePath);
            BehaviorTreeData behaviorData = new BehaviorTreeData();

            string content = FileReadWrite.Read(filePath);

            if (string.IsNullOrEmpty(content))
            {
                return(behaviorData);
            }

            JsonData jsonData = JsonMapper.ToObject(content);

            behaviorData.fileName = jsonData["fileName"].ToString();

            behaviorData.rootNodeId = int.Parse(jsonData["rootNodeId"].ToString());

            if (((IDictionary)jsonData).Contains("nodeList"))
            {
                JsonData nodeList = jsonData["nodeList"];
                behaviorData.nodeList = GetNodeList(nodeList);
            }

            if (((IDictionary)jsonData).Contains("parameterList"))
            {
                JsonData parameterList = jsonData["parameterList"];
                behaviorData.parameterList = GetParameterList(parameterList);
            }

            if (((IDictionary)jsonData).Contains("descript"))
            {
                behaviorData.descript = jsonData["descript"].ToString();
            }

            return(behaviorData);
        }