public void GenerateMaze() { if (indexBuffer != null) { indexBuffer.Dispose(); } if (vertexBuffer != null) { vertexBuffer.Dispose(); } Algorithm alg; int randomnumber = curMazeWidth < 2048 ? random.Next(3) : random.Next(2); if (randomnumber == 0) { alg = new AlgorithmBacktrack(); } else if (randomnumber == 1) { alg = new AlgorithmDivision(); } else { alg = new AlgorithmKruskal(); } lastAlgorithm = alg.GetType().Name; currentMaze = alg.Generate(curMazeWidth, curMazeHeight, InnerMapType.BitArreintjeFast, null); var walls = currentMaze.GenerateListOfMazeWalls(); currentPath = PathFinderDepthFirst.GoFind(currentMaze.InnerMap, null); determiner = new LineOfSightDeterminer(currentMaze.InnerMap, currentPath); curChaseCameraPoint = null; VertexPositionNormalTexture[] vertices = new VertexPositionNormalTexture[walls.Count * 8]; int[] indices = new int[walls.Count * 12]; int curVertice = 0; int curIndice = 0; foreach (var wall in walls) { //int factorHeight = 10; //int factorWidth = 10; WallModel model = new WallModel(wall); model.GoGenerateVertices(vertices, indices, ref curVertice, ref curIndice); } wallsCount = walls.Count; vertexBuffer = new VertexBuffer(GraphicsDevice, VertexPositionNormalTexture.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly); indexBuffer = new IndexBuffer(GraphicsDevice, IndexElementSize.ThirtyTwoBits, indices.Length, BufferUsage.WriteOnly); vertexBuffer.SetData(vertices); indexBuffer.SetData(indices); GeneratePath(currentPath); }
public void GenerateMaze() { if (indexBuffer != null) indexBuffer.Dispose(); if (vertexBuffer != null) vertexBuffer.Dispose(); Algorithm alg; int randomnumber = curMazeWidth < 2048 ? random.Next(3) : random.Next(2); if (randomnumber == 0) alg = new AlgorithmBacktrack(); else if (randomnumber == 1) alg = new AlgorithmDivision(); else alg = new AlgorithmKruskal(); lastAlgorithm = alg.GetType().Name; currentMaze = alg.Generate(curMazeWidth, curMazeHeight, InnerMapType.BitArreintjeFast, null); var walls = currentMaze.GenerateListOfMazeWalls(); currentPath = PathFinderDepthFirst.GoFind(currentMaze.InnerMap, null); determiner = new LineOfSightDeterminer(currentMaze.InnerMap, currentPath); curChaseCameraPoint = null; VertexPositionNormalTexture[] vertices = new VertexPositionNormalTexture[walls.Count * 8]; int[] indices = new int[walls.Count * 12]; int curVertice = 0; int curIndice = 0; foreach (var wall in walls) { //int factorHeight = 10; //int factorWidth = 10; WallModel model = new WallModel(wall); model.GoGenerateVertices(vertices, indices, ref curVertice, ref curIndice); } wallsCount = walls.Count; vertexBuffer = new VertexBuffer(GraphicsDevice, VertexPositionNormalTexture.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly); indexBuffer = new IndexBuffer(GraphicsDevice, IndexElementSize.ThirtyTwoBits, indices.Length, BufferUsage.WriteOnly); vertexBuffer.SetData(vertices); indexBuffer.SetData(indices); GeneratePath(currentPath); }