Example #1
0
    async void RenderMap()
    {
        DatabaseMergedData systemDB = await ReadSystemDB();

        var mapDataList = systemDB.GetDataDescList(0);

        if (mapNo >= mapDataList.Count)
        {
            return;
        }

        string  mapPath   = dataPath + mapDataList[mapNo].ItemValueList[0].StringValue.ToString();
        var     mpsReader = new MpsFileReader();
        MapData mapData   = await mpsReader.ReadFileAsync(mapPath);

        string      tileSetPath = dataPath + "BasicData/TileSetData.dat";
        var         reader      = new TileSetDataFileReader();
        TileSetData setData     = await reader.ReadFileAsync(tileSetPath);

        TileSetSetting tileSetting = setData.TileSetSettingList[mapData.TileSetId];

        ReadBaseTileTexture(tileSetting.BaseTileSetFileName);

        ReadAutoTileTextures(tileSetting.AutoTileFileNameList.ToArray());

        Texture2D mapTexture
            = new Texture2D(mapData.MapSizeWidth * chipSize, mapData.MapSizeHeight * chipSize);

        for (int i = 0; i < mapData.MapSizeHeight; i++)
        {
            for (int j = 0; j < mapData.MapSizeWidth; j++)
            {
                for (int k = 0; k < 3; k++)
                {
                    int id = mapData.GetLayer(k).Chips[j][i];
                    if (mapData.GetLayer(k).Chips[j][i].IsAutoTile)
                    {
                        RenderAutoTile(mapTexture, j, i, id);
                    }
                    else
                    {
                        RenderNormalTile(mapTexture, j, i, id);
                    }
                }
            }
        }

        for (int i = 0; i < mapData.MapEvents.Count; i++)
        {
            int          x            = mapData.MapEvents[i].Position.X;
            int          y            = mapData.MapEvents[i].Position.Y;
            MapEventPage mapEventPage = mapData.MapEvents[i].MapEventPageList[0];
            if (mapEventPage.GraphicInfo.IsGraphicTileChip)
            {
                int tileId = mapEventPage.GraphicInfo.GraphicTileId;
                RenderNormalTile(mapTexture, x, y, tileId);
            }
            else if (!string.IsNullOrEmpty(mapEventPage.GraphicInfo.CharaChipFilePath))
            {
                string graphicPath = dataPath + mapEventPage.GraphicInfo.CharaChipFilePath;
                Debug.Log(graphicPath);
                CharaChipDirection charaChipDirection = mapEventPage.GraphicInfo.InitDirection;
                Texture2D          charaChipTexture   = new Texture2D(1, 1);
                byte[]             bytes = System.IO.File.ReadAllBytes(graphicPath);
                charaChipTexture.LoadImage(bytes);
                charaChipTexture.filterMode = FilterMode.Point;
                RenderCharaChip(mapTexture, x, y, charaChipTexture, charaChipDirection);
            }
        }

        mapTexture.Apply();
        mapTexture.filterMode = FilterMode.Point;

        Sprite sprite = Sprite.Create(mapTexture,
                                      new Rect(0.0f, 0.0f, mapTexture.width, mapTexture.height), new Vector2(0.5f, 0.5f), 1.0f);

        mapSprite.sprite = sprite;
    }
Example #2
0
        public void SetUserDB(int typeID, int dataID, int itemID, int value)
        {
            DatabaseMergedData db = CoreData.Instance.userDB;

            db.GetDataDescList(typeID)[dataID].ItemValueList[itemID] = new DBItemValue(value);
        }
Example #3
0
        public int GetSystemDBInteger(int typeID, int dataID, int itemID)
        {
            DatabaseMergedData db = CoreData.Instance.systemDB;

            return(db.GetDataDescList(typeID)[dataID].ItemValueList[itemID].IntValue);
        }
Example #4
0
        public string GetUserDBString(int typeID, int dataID, int itemID)
        {
            DatabaseMergedData db = CoreData.Instance.userDB;

            return(db.GetDataDescList(typeID)[dataID].ItemValueList[itemID].StringValue);
        }