/// <summary> /// Generates a TileMap with the given UnitMap and Unit (and Tilemap and Organization) /// </summary> /// <param name="umap">The UnitMap to use</param> /// <param name="unit">The Unit to be based on</param> /// <param name="tm">Tilemap (not the pathfind one)</param> /// <param name="org">Organization to base the map from (determins who is ally and who is enemy)</param> /// <returns>a PathFind.TileMap</returns> public static TileMap gen(UnitMap umap, Tilemap tm, Unit unit) { TileMap ptm = new TileMap(tm.NumX, tm.NumY); for(int i=0; i<tm.NumX; i++) for(int e=0; e<tm.NumY; e++) if(!unit.canMove(tm.get(i, e).Type)) ptm.set(i, e, Tile_Type.BLOCK_TERRAIN); else if(!umap.canMove(i, e, unit.Organization)) ptm.set(i, e, Tile_Type.BLOCK_UNIT); else ptm.set(i, e, Tile_Type.NOTHING); return ptm; }
private static bool canMove(UnitMap umap, Tilemap tm, Point dest, String org) { if (tm.get(dest.X, dest.Y).Type == Tile.TileType.MOUNTAIN || tm.get(dest.X, dest.Y).Type == Tile.TileType.WATER) return false; return umap.canMove(dest.X, dest.Y, org); }