示例#1
0
        private Sprite GetSprite(Map map, Vec2I pos, Vec2I subTile, int frame)
        {
            BB.Assert(frame < def.spriteFrames.Length);

            TerrainDef lambdaDef = def; // C# is dumb

            Tiling.TileType ttype = Tiling.GetTileType(pos, subTile, p => IsSame(map, p, lambdaDef));

            // TODO: Kludge for water arrangement in atlas
            if (def == K_waterDef)
            {
                switch (ttype)
                {
                case Tiling.TileType.ConcaveBL: ttype = Tiling.TileType.ConcaveTR; break;

                case Tiling.TileType.ConcaveTR: ttype = Tiling.TileType.ConcaveBL; break;

                case Tiling.TileType.ConcaveBR: ttype = Tiling.TileType.ConcaveTL; break;

                case Tiling.TileType.ConcaveTL: ttype = Tiling.TileType.ConcaveBR; break;
                }
            }

            var spritePos = def.spriteFrames[frame] + Tiling.SpriteOffset(ttype);

            return(atlas.GetSprite(spritePos, Vec2I.one));
        }
示例#2
0
        protected override TileSprite GetSprite(Map.BBTile tile, Vec2I pos, Vec2I subTile)
        {
            if (grassSprite == null)
            {
                var   atlas     = map.game.assets.atlases.Get(Terrain.K_grassDef.atlas);
                Vec2I spritePos = Terrain.K_grassDef.spriteFrames[0] + Tiling.SpriteOffset(Tiling.TileType.Base);
                grassSprite = atlas.GetSprite(spritePos, Vec2I.one);
            }

            return(grassSprite);
        }