Exemplo n.º 1
0
        public static PillarData LoadData(string path, string dataName)
        {
            FileStream stream = File.Open(path, FileMode.Open);
            PillarData data   = new PillarData();

            data.DataName = dataName;
            int readOffset = 0;
            //read setting
            int settingSize = data.setting.byteSize();

            if (stream.Length - readOffset >= settingSize)
            {
                byte[] buff = new byte[settingSize];
                int    len  = stream.Read(buff, readOffset, settingSize);
                data.setting.Reset(buff);
                readOffset += len;
            }
            else
            {
                MPLog.LogError("load setting failed");
                return(null);
            }
            //read header
            int headerSize = data.setting.maxX * data.setting.maxZ;

            if (stream.Length - readOffset < headerSize * sizeof(uint))
            {
                MPLog.LogError("load header failed");
                return(null);
            }
            data.tree = new QuadTreeBase[headerSize];
            byte[] bBuff = new byte[1] {
                0
            };
            byte bRootLeafBuff = 1 << 4;

            for (int i = 0; i < headerSize; ++i)
            {
                //root mask
                stream.Read(bBuff, 0, 1);
                //
                if ((bBuff[0] & bRootLeafBuff) > 0)
                {
                    data.tree[i] = new QuadTreeLeafSerializable(stream);
                }
                else
                {
                    data.tree[i] = new QuadTreeNodeSerializable(bBuff[0], stream);
                }
            }
            MPLog.Log("load successed !");
            stream.Close();
            return(data);
        }
Exemplo n.º 2
0
 //
 public MPAStarPath(PillarData data)
 {
     mData        = data;
     mDetail      = 1 << data.setting.subdivision;
     mMaxDeatailX = data.setting.maxX * mDetail;
     mMaxDeatailZ = data.setting.maxZ * mDetail;
     mVolumeSizeX = data.setting.maxX * GridX;
     mVolumeSizeZ = data.setting.maxZ * GridZ;
     mDetailGridX = GridX / mDetail;
     mDetailGridZ = GridZ / mDetail;
     //each pillar height slice max to 64
     mNeighbourCache = new MPNeigbours((mDetail + 1) * 4 * SliceAccessor.MaxHeightSliceCount);
     MPPathNodePool.AllocatePool(128);
 }
Exemplo n.º 3
0
 //
 public MPUnityAStar(PillarData data) : base(data)
 {
 }