Example #1
0
                /// <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;
                }
Example #2
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;
                }
Example #3
0
 /// <summary>
 /// Put the source and destination free (for the algorithm to work properly)
 /// </summary>
 /// <param name="tm"></param>
 /// <param name="src"></param>
 /// <param name="dest"></param>
 public static void free(ref TileMap tm, Point src, Point dest)
 {
     tm.set(src.X, src.Y, Tile_Type.NOTHING);
     tm.set(dest.X, dest.Y, Tile_Type.NOTHING);
 }