-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainForm.cs
82 lines (70 loc) · 1.59 KB
/
mainForm.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ZFind.MapModule;
using ZFind.ZeebotModule;
namespace ZFind
{
public partial class mainForm : Form
{
MapContext mapContext;
ZeebotSystem zeebotSystem;
public mainForm()
{
InitializeComponent();
mapContext = new MapContext(MapBuilder.Build("Fixtures/map.in"));
zeebotSystem = new ZeebotSystem(mapContext, 6);
realMap.ToPaint = mapContext;
calculatedMap.ToPaint = zeebotSystem;
timer.Interval = 250;
timer.Start();
}
private void timer_Tick(object sender, EventArgs e)
{
if (!playing) return;
zeebotSystem.Run();
realMap.Refresh();
realMap.Invalidate();
calculatedMap.Refresh();
calculatedMap.Invalidate();
}
bool playing = false;
int speed = 3;
int[] speedToInterval = new int[] { 750, 500, 300, 200, 100 };
private void toolStripButton1_Click(object sender, EventArgs e)
{
if (playing)
{
playing = false;
playButton.Text = "Play";
}
else
{
playing = true;
playButton.Text = "Pause";
}
}
void AlterSpeed(bool faster)
{
if (faster) speed++;
else speed--;
if (speed < 1) speed = 1;
if (speed > 5) speed = 5;
speedLabel.Text = string.Format("Speed: {0}", speed);
timer.Interval = speedToInterval[speed - 1];
}
private void slowerButton_Click(object sender, EventArgs e)
{
AlterSpeed(false);
}
private void fasterButton_Click(object sender, EventArgs e)
{
AlterSpeed(true);
}
}
}