Esempio n. 1
0
        public IteratableTile GeTileByNeighbour(IteratableTile parent, MapTile.MapTileExits direction)
        {
            MapTile tile     = parent.tile;
            MapTile nextTile = null;

            for (int j = 0; j < tiles.GetLength(0); j++)     //Vertical
            {
                for (int k = 0; k < tiles.GetLength(1); k++) //Horizontal
                {
                    if (tiles[j, k] == tile)
                    {
                        MapTile north = (j == 0) ? tiles[tiles.GetLength(0) - 1, k] : tiles[j - 1, k];
                        MapTile east  = (k == tiles.GetLength(1) - 1) ? tiles[j, 0] : tiles[j, k + 1];
                        MapTile west  = (k == 0) ? tiles[j, tiles.GetLength(1) - 1] : tiles[j, k - 1];
                        MapTile south = (j == tiles.GetLength(0) - 1) ? tiles[0, k] : tiles[j + 1, k];

                        switch (direction)
                        {
                        case MapTile.MapTileExits.East:
                            nextTile = east;
                            break;

                        case MapTile.MapTileExits.North:
                            nextTile = north;
                            break;

                        case MapTile.MapTileExits.South:
                            nextTile = south;
                            break;

                        default:         //West
                            nextTile = west;
                            break;
                        }
                    }
                }
            }
            return(new IteratableTile(nextTile, this, tile));
        }
Esempio n. 2
0
        private static MapTile.MapTileExits EntranceToExit(MapTile.MapTileExits exit)
        {
            MapTile.MapTileExits entrance;
            switch (exit)
            {
            case MapTile.MapTileExits.East:
                entrance = MapTile.MapTileExits.West;
                break;

            case MapTile.MapTileExits.South:
                entrance = MapTile.MapTileExits.North;
                break;

            case MapTile.MapTileExits.West:
                entrance = MapTile.MapTileExits.East;
                break;

            default:     //MapTile.MapTileExits.North
                entrance = MapTile.MapTileExits.South;
                break;
            }

            return(entrance);
        }