Ejemplo n.º 1
0
        public override void Added()
        {
            base.Added();
            GameLevel.PlatformerLevel Level = (GameLevel.PlatformerLevel)Scene;
            image = new Tilemap(Level.Width, Level.Height);

            image.SetTileset(texture,16,16);

            image.BeginTiling();
            image.LoadCSV(csv);
            image.EndTiling();
            Add(image);
        }
Ejemplo n.º 2
0
        public static void Tile(bool[,] bits, Func<int> tileHandler, Tilemap tilemap, int tileWidth, int tileHeight, bool edges = true)
        {
            for (TileX = 0; TileX < bits.GetLength(0); TileX++)
            {
                for (TileY = 0; TileY < bits.GetLength(1); TileY++)
                {
                    if (bits[TileX, TileY])
                    {
                        Left = TileX == 0 ? edges : bits[TileX - 1, TileY];
                        Right = TileX == 31 ? edges : bits[TileX + 1, TileY];
                        Up = TileY == 0 ? edges : bits[TileX, TileY - 1];
                        Down = TileY == 23 ? edges : bits[TileX, TileY + 1];

                        UpLeft = (TileX == 0 || TileY == 0) ? edges : bits[TileX - 1, TileY - 1];
                        UpRight = (TileX == 31 || TileY == 0) ? edges : bits[TileX + 1, TileY - 1];
                        DownLeft = (TileX == 0 || TileY == 23) ? edges : bits[TileX - 1, TileY + 1];
                        DownRight = (TileX == 31 || TileY == 23) ? edges : bits[TileX + 1, TileY + 1];

                        tilemap.DrawTile(tileHandler(), TileX * tileWidth, TileY * tileHeight);
                    }
                }
            }
        }
Ejemplo n.º 3
0
 public static int[,] Tile(bool[,] bits, bool[,] also, AutotileData autotileData, Tilemap tilemap, int tileWidth, int tileHeight, EdgeBehavior edges)
 {
     return Tile(bits, also, autotileData.TileHandler, tilemap, tileWidth, tileHeight, edges);
 }
Ejemplo n.º 4
0
        public static int[,] Tile(bool[,] bits, bool[,] also, Func<int> tileHandler, Tilemap tilemap, int tileWidth, int tileHeight, EdgeBehavior edges)
        {
            int boundsX = bits.GetLength(0);
            int boundsY = bits.GetLength(1);
            int[,] tiles = new int[boundsX, boundsY];

            for (TileX = 0; TileX < boundsX; TileX++)
            {
                for (TileY = 0; TileY < boundsY; TileY++)
                {
                    if (bits[TileX, TileY])
                    {
                        switch (edges)
                        {
                            case EdgeBehavior.True:
                                Left = TileX == 0 ? true : bits[TileX - 1, TileY] || also[TileX - 1, TileY];
                                Right = TileX == boundsX - 1 ? true : bits[TileX + 1, TileY] || also[TileX + 1, TileY];
                                Up = TileY == 0 ? true : bits[TileX, TileY - 1] || also[TileX, TileY - 1];
                                Down = TileY == boundsY - 1 ? true : bits[TileX, TileY + 1] || also[TileX, TileY + 1];

                                UpLeft = (TileX == 0 || TileY == 0) ? true : bits[TileX - 1, TileY - 1] || also[TileX - 1, TileY - 1];
                                UpRight = (TileX == boundsX - 1 || TileY == 0) ? true : bits[TileX + 1, TileY - 1] || also[TileX + 1, TileY - 1];
                                DownLeft = (TileX == 0 || TileY == boundsY - 1) ? true : bits[TileX - 1, TileY + 1] || also[TileX - 1, TileY + 1];
                                DownRight = (TileX == boundsX - 1 || TileY == boundsY - 1) ? true : bits[TileX + 1, TileY + 1] || also[TileX + 1, TileY + 1];
                                break;

                            case EdgeBehavior.False:
                                Left = TileX == 0 ? false : bits[TileX - 1, TileY] || also[TileX - 1, TileY];
                                Right = TileX == boundsX - 1 ? false : bits[TileX + 1, TileY] || also[TileX + 1, TileY];
                                Up = TileY == 0 ? false : bits[TileX, TileY - 1] || also[TileX, TileY - 1];
                                Down = TileY == boundsY - 1 ? false : bits[TileX, TileY + 1] || also[TileX, TileY + 1];

                                UpLeft = (TileX == 0 || TileY == 0) ? false : bits[TileX - 1, TileY - 1] || also[TileX - 1, TileY - 1];
                                UpRight = (TileX == boundsX - 1 || TileY == 0) ? false : bits[TileX + 1, TileY - 1] || also[TileX + 1, TileY - 1];
                                DownLeft = (TileX == 0 || TileY == boundsY - 1) ? false : bits[TileX - 1, TileY + 1] || also[TileX - 1, TileY + 1];
                                DownRight = (TileX == boundsX - 1 || TileY == boundsY - 1) ? false : bits[TileX + 1, TileY + 1] || also[TileX + 1, TileY + 1];
                                break;

                            case EdgeBehavior.Wrap:
                                Left = bits[(TileX + boundsX - 1) % boundsX, TileY] || also[(TileX + boundsX - 1) % boundsX, TileY];
                                Right = bits[(TileX + 1) % boundsX, TileY] || also[(TileX + 1) % boundsX, TileY];
                                Up = bits[TileX, (TileY + boundsY - 1) % boundsY] || also[TileX, (TileY + boundsY - 1) % boundsY];
                                Down = bits[TileX, (TileY + 1) % boundsY] || also[TileX, (TileY + 1) % boundsY];

                                UpLeft = bits[(TileX + boundsX - 1) % boundsX, (TileY + boundsY - 1) % boundsY] || also[(TileX + boundsX - 1) % boundsX, (TileY + boundsY - 1) % boundsY];
                                UpRight = bits[(TileX + 1) % boundsX, (TileY + boundsY - 1) % boundsY] || also[(TileX + 1) % boundsX, (TileY + boundsY - 1) % boundsY];
                                DownLeft = bits[(TileX + boundsX - 1) % boundsX, (TileY + 1) % boundsY] || also[(TileX + boundsX - 1) % boundsX, (TileY + 1) % boundsY];
                                DownRight = bits[(TileX + 1) % boundsX, (TileY + 1) % boundsY] || also[(TileX + 1) % boundsX, (TileY + 1) % boundsY];
                                break;
                        }

                        int tile = tileHandler();
                        if (tile != -1)
                            tilemap.DrawTile(tile, TileX * tileWidth, TileY * tileHeight);
                        tiles[TileX, TileY] = tile;
                    }
                }
            }

            return tiles;
        }