public Tilemap(int w, int h, Tilemap ft) { cmap = new CityMap(w, h); map = new Tile[w, h]; fog = new Fog(w, h); name = ft.name; startpos = new Point(ft.startpos.X, ft.startpos.Y); for (int i = 0; i < w; i++) for (int e = 0; e < h; e++) { if (i < ft.NumX && e < ft.NumY) { map[i, e] = ft.get(i, e); fog.set(i, e, ft.Fog.get(i, e)); cmap.set(i, e, ft.CityMap.get(i, e)); } else if (i < w && e < h) { map[i, e] = new Tile(); fog.set(i, e, false); } } }
/// <summary> /// Generates a TileMap with the given CharMap and Character (and Tilemap and Organization) /// </summary> /// <param name="cmap">The CharMap to use</param> /// <param name="c">The Character to base the map 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(CharMap cmap, Tilemap tm, String org, Character c) { 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 (!c.canMove(tm.get(i, e).Type)) ptm.set(i, e, Tile_Type.BLOCK_TERRAIN); else if (!cmap.canMove(i, e)) ptm.set(i, e, Tile_Type.BLOCK_UNIT); else ptm.set(i, e, Tile_Type.NOTHING); return ptm; }
/// <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(CharMap cmap, Tilemap tm, Point dest) { if (tm.get(dest.X, dest.Y).Type == Tile.TileType.MOUNTAIN || tm.get(dest.X, dest.Y).Type == Tile.TileType.WATER) return false; return cmap.canMove(dest.X, dest.Y); }
private static bool canMove(Tilemap tm, Point dest, String org) { return !(tm.get(dest.X, dest.Y).Type == Tile.TileType.MOUNTAIN || tm.get(dest.X, dest.Y).Type == Tile.TileType.WATER); }
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); }