本文整理汇总了C#中Generator.Start方法的典型用法代码示例。如果您正苦于以下问题:C# Generator.Start方法的具体用法?C# Generator.Start怎么用?C# Generator.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Generator
的用法示例。
在下文中一共展示了Generator.Start方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: buttonGenerate_Click
// --------------------------------------------------------------------------------
// Event Handlers
private void buttonGenerate_Click(object sender, EventArgs e)
{
this.buttonGenerate.Enabled = false;
this.checkBoxRealTime.Enabled = false;
this.buttonViewFloorDown.Enabled = false;
this.buttonViewFloorUp.Enabled = false;
// initialize a new maze using sizes specified
this.maze = new Maze3D((int)this.numericUpDownWidth.Value, (int)this.numericUpDownHeight.Value, (int)this.numericUpDownLevels.Value);
// create the bitmaps for rendering each level of the maze
this.floorLevelBitmap = new Bitmap[this.maze.Levels];
for (int floorIndex = 0; floorIndex < this.maze.Levels; floorIndex++)
{
this.floorLevelBitmap[floorIndex] = new Bitmap(this.maze.Width * cellSize + 2 * offsetX, this.maze.Height * cellSize + 2 * offsetY);
}
// create the ungenerated floors of the maze
InitializeMazeLevelBitmaps();
this.viewLevel = 1;
this.pictureBoxCanvas.Image = this.floorLevelBitmap[this.viewLevel - 1];
if (this.checkBoxRealTime.Checked)
{
this.labelViewingFloor.Enabled = true;
this.pictureBoxCanvas.Visible = true;
this.setLevelViewButtons();
}
else
{
this.labelViewingFloor.Enabled = false;
this.pictureBoxCanvas.Visible = false;
this.labelViewingFloor.Text = "Viewing Floor: none";
}
// set up the tool strip lable and progress bar
int generatorSteps = this.maze.Width * this.maze.Height * this.maze.Levels;
this.toolStripProgressBar1.Maximum = generatorSteps;
this.toolStripProgressBar1.Value = 0;
this.toolStripProgressBar1.Visible = true;
int generatorStepCount = 1;
this.toolStripStatusLabel2.Visible = true;
this.toolStripStatusLabel2.Text = "Generating maze...0%";
// create the maze generator and provide it a reference to the maze it will operate upon
Generator generator = new Generator(this.maze);
// start the maze generator in manual step mode
bool generating = generator.Start();
while (generating)
{
var stepResult = generator.Step();
Cell changedCell = stepResult.Item1;
string changedWall = stepResult.Item2;
if (changedCell != null)
this.toolStripStatusLabel1.Text = String.Format("Cell: ({0}, {1}, {2})", changedCell.X, changedCell.Y, changedCell.Z);
switch (changedWall)
{
case "Floor":
using (Graphics bitmapGraphics = Graphics.FromImage(this.floorLevelBitmap[changedCell.Z]))
{
bitmapGraphics.DrawLine(Pens.Red, this.offsetX + cellSize * changedCell.X + cellSize / 2,
this.offsetY + cellSize * changedCell.Y + cellSize / 4,
this.offsetX + cellSize * changedCell.X + cellSize / 2,
this.offsetY + cellSize * changedCell.Y + 3 * cellSize / 4);
bitmapGraphics.DrawLine(Pens.Red, this.offsetX + cellSize * changedCell.X + cellSize / 2,
this.offsetY + cellSize * changedCell.Y + 3 * cellSize / 4,
this.offsetX + cellSize * changedCell.X + cellSize / 2 - 3,
this.offsetY + cellSize * changedCell.Y + 3 * cellSize / 4 - 3);
bitmapGraphics.DrawLine(Pens.Red, this.offsetX + cellSize * changedCell.X + cellSize / 2,
this.offsetY + cellSize * changedCell.Y + 3 * cellSize / 4,
this.offsetX + cellSize * changedCell.X + cellSize / 2 + 3,
this.offsetY + cellSize * changedCell.Y + 3 * cellSize / 4 - 3);
}
using (Graphics bitmapGraphics = Graphics.FromImage(this.floorLevelBitmap[changedCell.Z - 1]))
{
bitmapGraphics.DrawLine(Pens.Blue, this.offsetX + cellSize * changedCell.X + cellSize / 2,
this.offsetY + cellSize * changedCell.Y + cellSize / 4,
this.offsetX + cellSize * changedCell.X + cellSize / 2,
this.offsetY + cellSize * changedCell.Y + 3 * cellSize / 4);
bitmapGraphics.DrawLine(Pens.Blue, this.offsetX + cellSize * changedCell.X + cellSize / 2,
this.offsetY + cellSize * changedCell.Y + cellSize / 4,
this.offsetX + cellSize * changedCell.X + cellSize / 2 - 3,
this.offsetY + cellSize * changedCell.Y + cellSize / 4 + 3);
bitmapGraphics.DrawLine(Pens.Blue, this.offsetX + cellSize * changedCell.X + cellSize / 2,
this.offsetY + cellSize * changedCell.Y + cellSize / 4,
this.offsetX + cellSize * changedCell.X + cellSize / 2 + 3,
this.offsetY + cellSize * changedCell.Y + cellSize / 4 + 3);
}
break;
case "North":
using (Graphics bitmapGraphics = Graphics.FromImage(this.floorLevelBitmap[changedCell.Z]))
{
bitmapGraphics.DrawLine(Pens.LightGray, this.offsetX + (cellSize * changedCell.X) + 1,
this.offsetY + (cellSize * changedCell.Y),
this.offsetX + (cellSize * changedCell.X) + cellSize - 1,
this.offsetY + (cellSize * changedCell.Y));
//.........这里部分代码省略.........