public void RunMapPrototypeThing() { List <IEntity> ProtoActors = new P_DefaultEntityList().EntityList; P_TileArray ProtoMap = P_MapBuilder.GenerateRandomMap((P_Const.MapWidth), P_Const.MapHeight, Renderer); PrototypeBattleLogic.P_BattleMap ProtoBattle = new PrototypeBattleLogic.P_BattleMap(ProtoActors, ProtoMap, Updater, Renderer); this.Kill(); }
public P_TileArray DeepCopy() { P_TileArray ReturnValue = new P_TileArray(_Width, _MyTiles.Length / _Width); for (int i = 0; i < _MyTiles.Length; i++) { ReturnValue._MyTiles[i] = MyTiles[i].DeepCopy(); } return(ReturnValue); }
public static List <P_CubeCoords> GetPath(P_TileArray tilearray, P_CubeCoords start, P_CubeCoords end) { List <P_CubeCoords> ReturnValue = new List <P_CubeCoords>(); List <HexNode> closedset = new List <HexNode>(); List <HexNode> openset = new List <HexNode>(); HexNode thing = new HexNode(start, end, null); thing.H = P_CubeCoords.cube_distance(start, end); openset.Add(thing); while (openset.Count > 0) { HexNode current = openset[0]; for (int i = 1; i < openset.Count; i++) { if (openset[i].Score < current.Score) { current = openset[i]; } } if (current.Coords.X == end.X && current.Coords.Y == end.Y && current.Coords.Z == end.Z) { return(RebuildPath(current)); } openset.Remove(current); closedset.Add(current); List <P_CubeCoords> neighbors = tilearray.CubeCoordNeighbors(current.Coords); for (int i = 0; i < neighbors.Count; i++) { if (tilearray.MyTiles[tilearray.CubeToIndex(neighbors[i])].IsTilePassable() == false) { continue; } bool found = false; for (int j = 0; j < closedset.Count; j++) { if (closedset[j].Coords.X == neighbors[i].X && closedset[j].Coords.Y == neighbors[i].Y && closedset[j].Coords.Z == neighbors[i].Z) { found = true; break; } } if (found) { continue; } for (int j = 0; j < openset.Count; j++) { if (openset[j].Coords.X == neighbors[i].X && openset[j].Coords.Y == neighbors[i].Y && openset[j].Coords.Z == neighbors[i].Z) { found = true; break; } } if (found) { continue; } HexNode NewNode = new HexNode(neighbors[i], end, current); openset.Add(NewNode); } } return(ReturnValue); }