Beispiel #1
0
    public static IEnumerator Load()
    {
        ResourceLoadTask task = new ResourceLoadTask();

        task.path = "cfg";
        task.name = "tile.csv";
        yield return(ResourceLoader.LoadAssetAsync(task));

        TileCfg.load((task.asset as TextAsset).bytes);

        task.name = "resources.csv";
        yield return(ResourceLoader.LoadAssetAsync(task));

        ResourcesCfg.load((task.asset as TextAsset).bytes);

        task.name = "prefab.csv";
        yield return(ResourceLoader.LoadAssetAsync(task));

        PrefabCfg.load((task.asset as TextAsset).bytes);

        task.name = "prefabType.csv";
        yield return(ResourceLoader.LoadAssetAsync(task));

        PrefabTypeCfg.load((task.asset as TextAsset).bytes);

        task.name = "audio.csv";
        yield return(ResourceLoader.LoadAssetAsync(task));

        AudioCfg.load((task.asset as TextAsset).bytes);

        task.name = "frameAnimation.csv";
        yield return(ResourceLoader.LoadAssetAsync(task));

        FrameAnimationCfg.load((task.asset as TextAsset).bytes);
        task.name = "characterSprite.csv";
        yield return(ResourceLoader.LoadAssetAsync(task));

        CharacterSpriteCfg.load((task.asset as TextAsset).bytes);
        task.name = "unitType.csv";
        yield return(ResourceLoader.LoadAssetAsync(task));

        UnitTypeCfg.load((task.asset as TextAsset).bytes);
    }
Beispiel #2
0
    public void refreshTileSprite(int x, int y)
    {
        //Dictionary<int ,int > tileId2num=new Dictionary<int, int>();
        Dictionary <int, int> tileId2flag = new Dictionary <int, int>();

        for (int i = 0; i < 4; i++)
        {
            int      mapFieldX     = x * 2 + Tile2MapFieldX[i];
            int      mapFieldY     = y * 2 + Tile2MapFieldY[i];
            int      mapFieldIndex = mapFieldY * width + mapFieldX;
            MapField field         = fields[mapFieldIndex];
            //if (!tileId2num.ContainsKey(field.tileCfgId))
            //{
            //    tileId2num[field.tileCfgId] = 1;
            //}
            //else
            //{
            //    tileId2num[field.tileCfgId] += 1;
            //}
            if (!tileId2flag.ContainsKey(field.tileCfgId))
            {
                tileId2flag[field.tileCfgId] = TileFlags[i];
            }
            else
            {
                tileId2flag[field.tileCfgId] = tileId2flag[field.tileCfgId] + TileFlags[i];
            }
        }
        List <int> tileIdList = new List <int>();

        foreach (int key in tileId2flag.Keys)
        {
            TileCfg tileCfg     = TileCfg.get(key);
            int     insertIndex = 0;
            for (int i = 0; i < tileIdList.Count; i++)
            {
                float height = TileCfg.get(tileIdList[i]).height;
                insertIndex = i;
                if (tileCfg.height <= height)
                {
                    break;
                }
                if (i == tileIdList.Count - 1)
                {
                    insertIndex++;
                }
            }
            tileIdList.Insert(insertIndex, key);
        }

        int tileIndex = y * widthInTiles + x;

        mapTiles[tileIndex].removeSprit();
        for (int i = 0; i < tileIdList.Count; i++)
        {
            int tileCfgId = tileIdList[i];
            if (i == 0)/// 最下层的贴图使用全图
            {
                mapTiles[tileIndex].spriteRenderers[i].sprite = tilesets[tileCfgId].getSprit(15);
            }
            else
            {
                int flag = tileId2flag[tileCfgId];
                mapTiles[tileIndex].spriteRenderers[i].sprite = tilesets[tileCfgId].getSprit(flag);
            }
        }
    }