コード例 #1
0
    public static bool needSave(string matName, ArrayList propNames, ArrayList texNames, ArrayList texPaths)
    {
        if (propNames == null || propNames.Count <= 0)
        {
            Debug.Log("There is no textures");
            return(false);
        }
        //Debug.Log("matName===" + matName);
        Hashtable map = MapEx.getMap(CLMaterialPool.materialTexRefCfg, matName);

        if (map == null)
        {
            return(true);
        }
        ArrayList _propNames = MapEx.getList(map, "pp");
        ArrayList _texNames  = MapEx.getList(map, "tn");
        ArrayList _texPaths  = MapEx.getList(map, "tp");

        if (!arrayList2Str(_propNames).Equals(arrayList2Str(propNames)) ||
            !arrayList2Str(_texNames).Equals(arrayList2Str(texNames)) ||
            !arrayList2Str(_texPaths).Equals(arrayList2Str(texPaths)))
        {
            return(true);
        }
        return(false);
    }
コード例 #2
0
ファイル: Node.cs プロジェクト: coolape/mibao
        public virtual void DeserializeChildren(Hashtable map)
        {
            ArrayList list = MapEx.getList(map, "Children");
            Node      node = null;

            for (int i = 0; i < list.Count; i++)
            {
                int id = int.Parse(list [i].ToString());
                node = behaviorTree.getNodeByID(id);
                ConnectChild(node);
            }

            list = MapEx.getList(map, "KillNodes");
            node = null;
            for (int i = 0; i < list.Count; i++)
            {
                int id = int.Parse(list [i].ToString());
                node = behaviorTree.getNodeByID(id);
                ConnectKillChild(node);
            }
        }
コード例 #3
0
        public override void DeserializeChildren(Hashtable map)
        {
            ArrayList children = MapEx.getList(map, "ChildrenLeft");
            Node      node     = null;

            for (int i = 0; i < children.Count; i++)
            {
                int id = int.Parse(children [i].ToString());
                node = behaviorTree.getNodeByID(id);
                ConnectLeftChild(node);
            }

            children = MapEx.getList(map, "ChildrenRight");
            for (int i = 0; i < children.Count; i++)
            {
                int id = int.Parse(children [i].ToString());
                node = behaviorTree.getNodeByID(id);
                ConnectRightChild(node);
            }

            children = MapEx.getList(map, "KillLeftNodes");
            for (int i = 0; i < children.Count; i++)
            {
                int id = int.Parse(children [i].ToString());
                node = behaviorTree.getNodeByID(id);
                ConnectKillLeftChild(node);
            }

            children = MapEx.getList(map, "KillRightNodes");
            for (int i = 0; i < children.Count; i++)
            {
                int id = int.Parse(children [i].ToString());
                node = behaviorTree.getNodeByID(id);
                ConnectKillRightChild(node);
            }
        }
コード例 #4
0
ファイル: BTAsset.cs プロジェクト: coolape/mibao
        public BehaviorTree Deserialize()
        {
            Hashtable map = JSON.DecodeMap(serializedBehaviorTree);
            // Behavior Tree
            BehaviorTree bt    = ScriptableObject.CreateInstance <BehaviorTree> ();
            ArrayList    nodes = MapEx.getList(map, "nodes");
            string       type  = "";
            Node         node  = null;

            //先把所有的node创建好
            for (int i = 0; i < nodes.Count; i++)
            {
                type = MapEx.getString(nodes [i], "type");
                switch (type)
                {
                case "Hivemind.Root":
                    node = bt.CreateNode <Root> ();
                    ((Root)node).Deserialize(ListEx.getMap(nodes, i));
                    bt.SetRoot((Root)node);
                    break;

                case "Hivemind.NodeAction":
                    node = bt.CreateNode <NodeAction> ();
                    node.Deserialize(ListEx.getMap(nodes, i));
                    bt.nodes.Add(node);
                    break;

                case "Hivemind.NodeBranch":
                    node = bt.CreateNode <NodeBranch> ();
                    node.Deserialize(ListEx.getMap(nodes, i));
                    bt.nodes.Add(node);
                    break;

                case "Hivemind.NodeTogether":
                    node = bt.CreateNode <NodeTogether> ();
                    node.Deserialize(ListEx.getMap(nodes, i));
                    bt.nodes.Add(node);
                    break;

                default:
                    node = bt.CreateNode <Node> ();
                    node.Deserialize(ListEx.getMap(nodes, i));
                    bt.nodes.Add(node);
                    break;
                }
            }

            // 处理子节点的的关系
            for (int i = 0; i < nodes.Count; i++)
            {
                node = bt.getNodeByID(MapEx.getInt(nodes [i], "id"));
                node.DeserializeChildren(ListEx.getMap(nodes, i));
            }

            behaviorTree = bt;
            return(bt);
            //=============================
//			XmlDocument doc = new XmlDocument();
//			doc.LoadXml(serializedBehaviorTree);

            // Behavior Tree
//			BehaviorTree bt = ScriptableObject.CreateInstance<BehaviorTree>();

            // Root
//			XmlElement rootEl = (XmlElement)doc.GetElementsByTagName ("root").Item (0);
//			Root root = (Root)DeserializeSubTree (rootEl, bt);
//			bt.SetRoot (root);
//
//			// Unparented nodes
//			XmlElement unparentedRoot = (XmlElement)doc.GetElementsByTagName ("unparented").Item (0);
//			foreach (XmlNode xmlNode in unparentedRoot.ChildNodes) {
//				XmlElement el = xmlNode as XmlElement;
//				if (el != null)
//					DeserializeSubTree (el, bt);
//			}
//
//			behaviorTree = bt;
//			return bt;
        }