Пример #1
0
        private void InitLiquidTile(CTile tile, Transform tileHolder)
        {
            var script = tile.Handle.AddComponent <STile>();

            script.InitTile(tile);
            var sprites = this._spriteDict[tile.Model.Type];
            var roll    = RNG.Instance.Next(0, sprites.Count - 1);
            var sprite  = sprites[roll];
            var render  = tile.Handle.AddComponent <SpriteRenderer>();

            render.sprite           = sprite;
            render.sortingLayerName = SortingLayers.TILE_LAYER;
            tile.Handle.transform.SetParent(tileHolder);
            tile.Handle.name = SortingLayers.TILE + "( " + tile.Model.GetCol() + " / " + tile.Model.GetRow() + " )";

            tile.InitLiquidTile();
            tile.LiquidHandle.transform.position = tile.Model.Center;
            var liquidRenderer = tile.LiquidHandle.AddComponent <SpriteRenderer>();
            var liquidSprites  = MapBridge.Instance.GetTileSprites(ETile.Water);

            liquidRenderer.sprite           = liquidSprites[roll + 8];
            liquidRenderer.sortingLayerName = SortingLayers.TILE_LAYER;
            tile.LiquidHandle.transform.SetParent(tileHolder);
            tile.LiquidHandle.name = SortingLayers.TILE + "( " + tile.Model.GetCol() + " / " + tile.Model.GetRow() + " )";
        }