public static TreeConfig ReadBinary(byte[] bytes) { using (MemoryStream ms = new MemoryStream(bytes)) { BinaryFormatter binaryFormatter = new BinaryFormatter(); TreeConfig bTree = binaryFormatter.Deserialize(ms) as TreeConfig; ms.Close(); ms.Dispose(); return(bTree); } }
public static TreeConfig CreateConfigFromBTreeRoot(BTNode _root) { TreeConfig _tree = new TreeConfig(); _tree.mName = _root.name; int _nodeCount = GetBTreeChildNodeNum(_root) + 1; _tree.mNodes = new TreeNodeConfig[_nodeCount]; int index = 0; GetTreeNodeConfigFromBTreeRoot(_root, ref _tree.mNodes, ref index, -1); return(_tree); }
public static TreeConfig ReadXML(byte[] bytes) { using (MemoryStream ms = new MemoryStream(bytes)) { XmlSerializer reader = new XmlSerializer(typeof(TreeConfig)); StreamReader file = new StreamReader(ms); TreeConfig btree = reader.Deserialize(file) as TreeConfig; file.Close(); ms.Close(); ms.Dispose(); return(btree); } }
public static BTNode[] CreateBTreeFromConfig(TreeConfig _config) { BTNode[] _nodes = new BTNode[_config.mNodes.Length]; for (int i = 0; i < _nodes.Length; i++) { _nodes[i] = null; } for (int i = 0; i < _config.mNodes.Length; i++) { if (_nodes[i] == null) { _nodes[i] = CreateTreeNode(ref _nodes, _config.mNodes, i); } if (_config.mNodes[i].mPreconditions != null) { var precondition = CreatePreconditionFromConfig(_config.mNodes[i]); //Debugger.Log(precondition); _nodes[i].SetPrecondition(precondition); } } return(_nodes); }
public static BTNode CreateBTreeRootFromConfig(TreeConfig _config) { BTNode[] _nodes = CreateBTreeFromConfig(_config); return(_nodes[0]); }