//Basically the same. public void RefreshMap(Map map) { #region Create set of tiles for (int i = 0; i < map.tLList.Count; i++) { for (int j = 0; j < map.tLList[0].Count; j++) { if (map.tLList[i][j].isWall) { tileImSet[i][j] = new Tile_Image("wall"); } else tileImSet[i][j] = new Tile_Image("floor"); } } #endregion #region Draw Tiles foreach (Party p in GlobalVars.PartyList) { tileImSet[p.location.x][p.location.y].currentImage = tileImSet[p.location.x][p.location.y].AddObject("party"); } for (int i = 0; i < map.tLList.Count; i++) { for (int j = 0; j < map.tLList[0].Count; j++) { for (int k = 0; k < tilesize; k++) { for (int l = 0; l < tilesize; l++) { visMap.SetPixel(i * tilesize + k, j * tilesize + l, tileImSet[i][j].currentImage.GetPixel(k, l)); } } } } #endregion }
public DMMap(Map map) { int xmax = map.tLList.Count; int ymax = map.tLList[0].Count; visMap = new Bitmap(xmax * tilesize, ymax * tilesize); #region Create Set of tiles for (int i = 0; i < xmax; i++) { for (int j = 0; j < ymax; j++) { tileImSet.Add(new List<Tile_Image>()); if (map.tLList[i][j].isWall) { tileImSet[i].Add(new Tile_Image("wall")); } else tileImSet[i].Add(new Tile_Image("floor")); } } foreach (Party p in GlobalVars.PartyList) { tileImSet[p.location.x][p.location.y].currentImage = tileImSet[p.location.x][p.location.y].AddObject("party"); } #endregion #region Create Image of map for (int i = 0; i < xmax; i++) { for (int j = 0; j < ymax; j++) { for (int k = 0; k < tilesize; k++) { for (int l = 0; l < tilesize; l++) { visMap.SetPixel(i * tilesize + k, j * tilesize + l, tileImSet[i][j].currentImage.GetPixel(k, l)); } } } } #endregion }
//For party initialization at random location public Party(Map map, List<PlayerChar> chars) { foreach (PlayerChar p in chars) { PartyMembers.Add(p); } location = new Coordinates(map.openSpace[pRand.Next(0, map.openSpace.Count)].coord.str_xy); }
public void RefreshMap(Map map) { int xmax = map.tLList.Count; int ymax = map.tLList[0].Count; playerMap = new Bitmap(xmax * tilesize, ymax * tilesize); CheckVisibleTiles(GlobalVars.GMap, GlobalVars.PartyList); tileImSet.Clear(); #region Create set of tiles for (int i = 0; i < xmax; i++) { for (int j = 0; j < ymax; j++) { tileImSet.Add(new List<Tile_Image>()); if (map.tLList[i][j].isWall && map.tLList[i][j].isVisible) { tileImSet[i].Add(new Tile_Image("wall")); } else if (map.tLList[i][j].isWall && !map.tLList[i][j].isVisible && map.tLList[i][j].isViewed) { tileImSet[i].Add(new Tile_Image("wall_invis")); } else if (!map.tLList[i][j].isWall && map.tLList[i][j].isVisible) { tileImSet[i].Add(new Tile_Image("floor")); } else if (!map.tLList[i][j].isWall && !map.tLList[i][j].isVisible && map.tLList[i][j].isViewed) { tileImSet[i].Add(new Tile_Image("floor_invis")); } else { tileImSet[i].Add(new Tile_Image("unknown")); } } } foreach (Party p in GlobalVars.PartyList) { tileImSet[p.location.x][p.location.y].currentImage = tileImSet[p.location.x][p.location.y].AddObject("party"); } //tileImSet[1][1].currentImage = tileImSet[1][1].AddObject("debug"); #endregion #region Create image for (int i = 0; i < xmax; i++) { for (int j = 0; j < ymax; j++) { for (int k = 0; k < tilesize; k++) { for (int l = 0; l < tilesize; l++) { playerMap.SetPixel(i * tilesize + k, j * tilesize + l, tileImSet[i][j].currentImage.GetPixel(k, l)); } } } } #endregion }
//Checks what tiles the party can see, and tracks which ones have been seen. public void CheckVisibleTiles(Map map, List<Party> parties) { double incR = .2; double incTh = .05; //Mark all tiles as not visible foreach(List<Tile> tList in map.tLList) { foreach (Tile t in tList) { t.isVisible = false; } } //Find all currently visible tiles and record that they have been viewed. foreach(Party p in parties) { double th = 0; for (int i = 0; i < 720; i++) { double r = 0; for (int j = 0; j < map.tLList.Count * 5; j++) { int viewX = Convert.ToInt16(Math.Round(Convert.ToDouble(p.location.x) + r * Math.Cos(th))); int viewY = Convert.ToInt16(Math.Round(Convert.ToDouble(p.location.y) + r * Math.Sin(th))); map.tLList[viewX][viewY].isVisible = true; map.tLList[viewX][viewY].isViewed = true; if (map.tLList[viewX][viewY].isWall){ break; } r += incR; } th += incTh; } } int debugstep = 0; }