Exemplo n.º 1
0
    public void OnLoadWayPointPaths()
    {
        CTimeCheck.Start();

        FileStream   fileStream   = null;
        BinaryReader binaryReader = null;

        if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer)
        {
            CTextAssetMgr TextAssetMgr = GameObject.FindGameObjectWithTag("TextAssetMgr").GetComponent <CTextAssetMgr>();
            binaryReader = TextAssetMgr.LoadTextAsset(CTextAssetMgr.EFileType.MapWPP, FileName);
            if (binaryReader == null)
            {
                return;
            }
        }
        else
        {
            string FileFullPath = FileName + "_WPP";
            string Path         = GetPath(ref FileFullPath);
            if (false == File.Exists(Path))
            {
                return;
            }
            fileStream   = new FileStream(Path, FileMode.Open);
            binaryReader = new BinaryReader(fileStream);
        }
        WayPointPaths.Clear();
        int Count = binaryReader.ReadInt32();

        for (int i = 0; i < Count; ++i)
        {
            int       Key        = binaryReader.ReadInt32();
            int       ValueCount = binaryReader.ReadInt32();
            ArrayList paths      = new ArrayList();
            for (int j = 0; j < ValueCount; ++j)
            {
                paths.Add(binaryReader.ReadInt32());
            }
            WayPointPaths.Add(Key, paths);
        }
        binaryReader.Close();
        if (fileStream != null)
        {
            fileStream.Close();
        }
        CTimeCheck.End(ELogType.MapGenerator, "OnLoadWayPointPaths");
    }
Exemplo n.º 2
0
    public void OnLoad()
    {
        CTimeCheck.Start();

        BinaryReader binaryReader = null;
        FileStream   fileStream   = null;

        if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer)
        {
            CTextAssetMgr TextAssetMgr = GameObject.FindGameObjectWithTag("TextAssetMgr").GetComponent <CTextAssetMgr>();
            binaryReader = TextAssetMgr.LoadTextAsset(CTextAssetMgr.EFileType.Map, FileName);
            if (binaryReader == null)
            {
                return;
            }
        }
        else
        {
            string Path = GetPath(ref FileName);
            fileStream   = new FileStream(Path, FileMode.Open);
            binaryReader = new BinaryReader(fileStream);
        }

        int Count     = (int)binaryReader.ReadUInt16();
        int Remainder = (int)binaryReader.ReadUInt16();

        UInt64[] SaveData = new UInt64[Count];
        for (int i = 0; i < Count; ++i)
        {
            SaveData[i] = binaryReader.ReadUInt64();
        }

        TileFullSize = 0 < Remainder ? (Count - 1) * 64 + Remainder : Count * 64;
        Size         = (int)Math.Sqrt(TileFullSize);
        Tiles        = new bool[TileFullSize];

        for (int i = 0; i < Count; ++i)
        {
            for (int j = 0; j < 64; ++j)
            {
                if (0 < Remainder && i == Count - 1 && Remainder == j)
                {
                    break;
                }

                if ((UInt64)0 < (SaveData[i] & 0x8000000000000000))
                {
                    Tiles[i * 64 + j] = true;
                }

                SaveData[i] = SaveData[i] << 1;
            }
        }

        LoadMapObjects(ref binaryReader);

        BlockImage = binaryReader.ReadString();
        TileImage  = binaryReader.ReadString();

        binaryReader.Close();
        if (fileStream != null)
        {
            fileStream.Close();
        }

        if (bShowAllTile)
        {
            ShowTile();
        }
        else
        {
            CreateTileObject();
        }

        CTimeCheck.End(ELogType.MapGenerator, "OnLoad");
    }