private void GenerateMap() { string fileName = "./Assets/Maps/map1.txt"; MapTiles mapTiles = MapReader <MapTiles, TileType> .ReadMapFile(fileName, ListToMapTiles, tileDictionary); LevelMaps.Add(mapTiles); }
void removeFromArray(List <MapTiles> inTiles, MapTiles inCurrent) { for (int i = inTiles.Count - 1; i >= 0; i--) { if (inTiles[i] == inCurrent) { inTiles.RemoveAt(i); } } }
public static string GetTileRoot(this MapTiles part) { var mediaField = part.Get<MediaField>(Constants.TilesMediaFileFieldName); if (mediaField == null || !mediaField.Paths.Any()) { return null; } return Path.Combine(Path.GetDirectoryName(mediaField.Paths[0]), part.ContentItem.ContentItemId); }
private void ReadjustWalkability() { for (int x = 0; x < _grid_size.x; x++) { for (int y = 0; y < _grid_size.y; y++) { MapTiles tile = (MapTiles)Array.IndexOf(Tiles, _tilemap.GetTile(new Vector3Int(x - _grid_size.x / 2, y - _grid_size.y / 2, 0))); _grid[x, y].Tile = tile; _grid[x, y].SetTileWalkable(!Collidability[(int)tile]); } } }
private static Vector2 GetRandomValidPosition() { int x = random.Next(MapTiles.GetLength(0)); int y = random.Next(MapTiles.GetLength(1)); while (MapTiles[x, y] == 0 || !(EntityManager.OccupiedTiles[x, y] == null)) { x = random.Next(MapTiles.GetLength(0)); y = random.Next(MapTiles.GetLength(1)); } return(new Vector2(x, y)); }
private MapTiles[,] ConvertSampleToMap(float [,] sample, float amplitude) { MapTiles[,] map = new MapTiles[sample.GetLength(0), sample.GetLength(1)]; for (int x = 0; x < sample.GetLength(0); x++) { for (int y = 0; y < sample.GetLength(1); y++) { map[x, y] = ActivationFuction(sample[x, y], amplitude); } } return(map); }
public static MapTiles GenerateMap(Tile.topology topology, int width, int height) { MapTiles mt = new MapTiles(topology, width, height); ProvinceTile P = new ProvinceTile(mt, 1); P = new ProvinceTile(mt, 2); P = new ProvinceTile(mt, 3); P = new ProvinceTile(mt, 4); P = new ProvinceTile(mt, 5); P = new ProvinceTile(mt, 6); P = new ProvinceTile(mt, 7); P = new ProvinceTile(mt, 8); P = new ProvinceTile(mt, 9); return(mt); }
public void BuildMap(MapTiles mapTiles) { int height = mapTiles.Tiles.Length; int width = mapTiles.Tiles[0].Row.Length; tiles = new Tile[width, height]; for (int i = 0; i < height; i++) { TileType[] row = mapTiles.Tiles[i].Row; for (int j = 0; j < width; j++) { BuildTile(row[j], j, i); } } CreateBattleGroups(2, 2); }
public void LoadMapTiles(string mapName, Graphics device) { MapTiles.Clear(); Reader = new StreamReader(@"..\..\Assets\Maps\" + mapName + ".map"); Bitmap walkableAreas = new Bitmap(@"..\..\Assets\Maps\" + mapName + ".walkable"); int y = 0; while (!Reader.EndOfStream) { string line = Reader.ReadLine(); for (int x = 0; x < line.Length; x++) { Tile t = new Tile(); t.loc = new Point(x * 10, y * 10); PixelColor = walkableAreas.GetPixel(x * 10, y * 10); if (PixelColor == WalkableColor) //if (line[x].ToString() == "1") { t.color = Color.Green; t.walkable = true; } if (PixelColor == NonWalkableColor) //if (line[x].ToString() == "0") { t.color = Color.Cyan; t.walkable = false; } MapTiles.Add(t); } y++; } // Once the tilelist is full, preform an initial drawing of the grid GridCalculatedImage = new Bitmap(this.MapImageWidth, this.MapImageHeight); GridGraphicsDevice = Graphics.FromImage(this.GridCalculatedImage); foreach (Tile tile in MapTiles) { pen.Color = tile.color; GridGraphicsDevice.DrawRectangle(pen, 0 + tile.loc.X, 0 + tile.loc.Y, 10, 10); } }
public void Close() { if (!ProjectLoaded) { return; } Rooms.Clear(); DoorSets.Clear(); Doors.Clear(); ScrollSets.Clear(); PlmSets.Clear(); ScrollPlmDatas.Clear(); Backgrounds.Clear(); Fxs.Clear(); SaveStations.Clear(); LevelDatas.Clear(); EnemySets.Clear(); EnemyGfxs.Clear(); ScrollAsms.Clear(); DoorAsms.Clear(); SetupAsms.Clear(); MainAsms.Clear(); TileSets.Clear(); TileTables.Clear(); TileSheets.Clear(); Palettes.Clear(); AreaMaps.Clear(); PlmTypes.Clear(); EnemyTypes.Clear(); CurrentRom = null; ProjectPath = String.Empty; RomFileName = String.Empty; ProjectFileName = String.Empty; RoomTiles.Clear(); MapTiles.Clear(); BackgroundImage = null; ChangesMade = false; ProjectLoaded = false; ProjectClosed?.Invoke(this, null); }
public void FindAllSolutions() { map = FindObjectOfType <MapTiles>(); mapSizeX = map.mapSizeX; mapSizeY = map.mapSizeY; tiles = map.tiles; graph = map.graph; int availebleShapes = 3; List <BoardManager.ShapeToComplete> winConditionShapes = new List <BoardManager.ShapeToComplete>(); //winConditionShapes.Add(new BoardManager.ShapeToComplete(new Shape.Rectangle(true))); //winConditionShapes.Add(new BoardManager.ShapeToComplete(new Shape.Rectangle(false))); //winConditionShapes.Add(new BoardManager.ShapeToComplete(new Shape.Rectangle(true))); //GenerateSquare(new Vector2(0,0),1); Solution sol = new Solution();; for (int i = 0; i < mapSizeX; i++) { for (int j = 0; j < mapSizeY; j++) { int tile = tiles[i, j]; if (tile != 0) { //Debug.Log("---------POSIBLE CANDIDATES FOR: " + new Vector2(i, j)); //sol.Add(); // shapes of valid solution } } } FindAllPosiibleRectangleTopVertices(new Vector2(0, 0)); solutions.Add(sol); }
public Unity_Tile GetMapTile(int x, int y) => MapTiles.ElementAtOrDefault((Width * y) + x);
void Start() { map = FindObjectOfType <MapTiles>(); ui = FindObjectOfType <UiShapeManager>(); }
private void SetMapTiles(int mapIndex) { currentMapTiles = levelMaps[mapIndex]; }
public List <MapTiles> Pathfind(Vector2 startPos, Vector2 endPos) { try { start = startPos; end = endPos; openSet.Add(tiles[(int)start.x, (int)start.y]); while (openSet.Count > 0) { if (openSet.Count > 0) { int lowestIndex = 0; for (int i = 0; i < openSet.Count; i++) { if (openSet[i].f < openSet[lowestIndex].f) { lowestIndex = i; } } MapTiles current = openSet[lowestIndex]; if (current.position == end) { if (!noSolution) { path = new List <MapTiles>(); MapTiles temp = current; path.Add(temp); while (temp.previous && temp.previous != null) { path.Add(temp.previous); temp = temp.previous; } return(path); } } removeFromArray(openSet, current); closedSet.Add(current); List <MapTiles> neighbours = current.neighbours; for (int i = 0; i < neighbours.Count; i++) { MapTiles neighbour = neighbours[i]; if (!closedSet.Contains(neighbour) && neighbour.walkable) { int tempG = current.g + 1; bool newPath = false; if (openSet.Contains(neighbour)) { if (tempG < neighbour.g) { neighbour.g = tempG; newPath = true; } } else { neighbour.g = tempG; newPath = true; openSet.Add(neighbour); } if (newPath) { neighbour.h = heuristic(neighbour, tiles[(int)end.x, (int)end.y]); neighbour.f = neighbour.g + neighbour.h; neighbour.previous = current; } } } } else { noSolution = true; break; } } } catch (ArgumentException e) { Console.WriteLine(e); return(path); } return(path); }
float heuristic(MapTiles a, MapTiles b) { float dist = System.Math.Abs(a.position.x - b.position.x) + System.Math.Abs(a.position.y - b.position.y); return(dist); }
void Start() { map = FindObjectOfType <MapTiles>(); }
public Tile GetTileAtPosition(int x, int y) { return(MapTiles.Find(tile => tile.X == x && tile.Y == y)); }