Esempio n. 1
0
                /// <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;
                }
Esempio n. 2
0
        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);
        }