예제 #1
0
        public static MemoryStream WriteTileData(this MemoryStream stream, ITileData tileData)
        {
            switch (tileData)
            {
            case TileBasic _:
                return(stream.WriteInt(0));

            case TileRail rail:
                return(stream.WriteInt(1)
                       .WriteList(rail.Trains, WriteTrain));

            case TileRailFork fork:
                return(stream
                       .WriteInt(2)
                       .WriteList(fork.Trains, WriteTrain)
                       .WriteBool(fork.IsOn));

            case TileDepot depot:
                return(stream
                       .WriteInt(3)
                       .WriteList(depot.Trains, WriteTrain)
                       .WriteBool(depot.Occupied));

            default:
                throw new NotImplementedException();
            }
        }
예제 #2
0
    public static String[,] miniGridFromTile(ITileData tile)
    {
        String[,] grid = new String[3, 3];
        for (var y = grid.GetLowerBound(0); y <= grid.GetUpperBound(0); y++)
        {
            for (var x = grid.GetLowerBound(1); x <= grid.GetUpperBound(1); x++)
            {
                grid[y, x] = "NOT VISITED";
            }
        }

        spread(tile, 1, 1, grid);

        for (var y = grid.GetLowerBound(0); y <= grid.GetUpperBound(0); y++)
        {
            for (var x = grid.GetLowerBound(1); x <= grid.GetUpperBound(1); x++)
            {
                if (grid[y, x] == "NOT VISITED")
                {
                    grid[y, x] = null;
                }
            }
        }

        return grid;
    }
예제 #3
0
 internal EntryTile(uint id, IDataFactory factory, ITileData tiledata, bool valid)
 {
     _EntryId    = id;
     dataFactory = factory;
     _TileData   = tiledata;
     _IsValid    = valid;
 }
예제 #4
0
 public Tile(TileBaseData baseData, ITileData data)
 {
     DebugEx.Assert(baseData != null);
     DebugEx.Assert(data != null);
     BaseData = baseData;
     Data     = data;
 }
예제 #5
0
        public void Place(int destinationX, int destinationY, ITileData world)
        {
            ErrorLogging.TelemetryClient?.TrackEvent("PlaceSprite", new Dictionary <string, string> {
                ["Tile"] = Tile.ToString(), ["UV"] = UV.ToString()
            });

            if (Tile == (ushort)TileType.ChristmasTree)
            {
                for (int x = 0; x < SizeTiles.X; x++)
                {
                    int tilex = x + destinationX;
                    for (int y = 0; y < SizeTiles.Y; y++)
                    {
                        int  tiley   = y + destinationY;
                        Tile curtile = world.Tiles[tilex, tiley];
                        curtile.IsActive = true;
                        curtile.Type     = Tile;
                        if (x == 0 && y == 0)
                        {
                            curtile.U = 10;
                        }
                        else
                        {
                            curtile.U = (short)x;
                        }
                        curtile.V = (short)y;
                    }
                }
            }
            else
            {
                for (int x = 0; x < SizeTiles.X; x++)
                {
                    Vector2Short[,] tiles = GetTiles();
                    int tilex = x + destinationX;
                    for (int y = 0; y < SizeTiles.Y; y++)
                    {
                        int  tiley   = y + destinationY;
                        Tile curtile = world.Tiles[tilex, tiley];
                        curtile.IsActive = true;
                        curtile.Type     = Tile;
                        curtile.U        = tiles[x, y].X;
                        curtile.V        = tiles[x, y].Y;
                    }
                }
            }
        }
 public void Place(int destinationX, int destinationY, ITileData world)
 {
     if (Tile == (ushort)TileType.ChristmasTree)
     {
         for (int x = 0; x < SizeTiles.X; x++)
         {
             int tilex = x + destinationX;
             for (int y = 0; y < SizeTiles.Y; y++)
             {
                 int  tiley   = y + destinationY;
                 Tile curtile = world.Tiles[tilex, tiley];
                 curtile.IsActive = true;
                 curtile.Type     = Tile;
                 if (x == 0 && y == 0)
                 {
                     curtile.U = 10;
                 }
                 else
                 {
                     curtile.U = (short)x;
                 }
                 curtile.V = (short)y;
             }
         }
     }
     else
     {
         for (int x = 0; x < SizeTiles.X; x++)
         {
             Vector2Short[,] tiles = GetTiles();
             int tilex = x + destinationX;
             for (int y = 0; y < SizeTiles.Y; y++)
             {
                 int  tiley   = y + destinationY;
                 Tile curtile = world.Tiles[tilex, tiley];
                 curtile.IsActive = true;
                 curtile.Type     = Tile;
                 curtile.U        = tiles[x, y].X;
                 curtile.V        = tiles[x, y].Y;
             }
         }
     }
 }
예제 #7
0
 private static void spread(ITileData tile, int x, int y, String[,] grid)
 {
     if (tile == null)
     {
         return;
     }
     if (x < grid.GetLowerBound(1) || x > grid.GetUpperBound(1))
     {
         return;
     }
     if (y < grid.GetLowerBound(0) || y > grid.GetUpperBound(0))
     {
         return;
     }
     if (grid[y, x] != "NOT VISITED")
     {
         return;
     }
     grid[y, x] = tile.getId();
     spread(tile.getLeft(), x - 1, y, grid);
     spread(tile.getRight(), x + 1, y, grid);
     spread(tile.getUp(), x, y - 1, grid);
     spread(tile.getDown(), x, y + 1, grid);
 }
예제 #8
0
 public HomeController(ITileData tileData)
 {
 }
예제 #9
0
 public static Boolean validateTile(ITileData tile)
 {
     return gridValid(miniGridFromTile(tile), 3, 3);
 }
예제 #10
0
 internal  EntryTile(uint id, IDataFactory factory, ITileData tiledata, bool valid)
 {
     _EntryId    = id;
     dataFactory = factory;
     _TileData   = tiledata;
     _IsValid    = valid;
 }
예제 #11
0
 public Tile With(TileBaseData baseData = null, ITileData data = null) =>
 new Tile(baseData ?? BaseData, data ?? Data);
예제 #12
0
 public void swap(ITileData select, ITileData neighbour)
 {
     ruby.swap_fields(select.y, select.x, neighbour.y, neighbour.x);
 }