public Form1() { InitializeComponent(); world = new World(new BeeMessage(SendMessage)); timer1.Interval = 50; timer1.Tick += new EventHandler(RunFrame); timer1.Enabled = false; UpdateStats(new TimeSpan()); }
private void openToolStripButton_Click(object sender, EventArgs e) { World currentWorld = world; int currentFrameRun = frameRun; bool enabled = timer1.Enabled; if (enabled) { timer1.Stop(); } OpenFileDialog openDialog = new OpenFileDialog(); openDialog.Filter = "|*.bees"; openDialog.CheckFileExists = true; openDialog.CheckPathExists = true; openDialog.Title = "Abrir"; if (openDialog.ShowDialog() == DialogResult.OK) { try { BinaryFormatter bf = new BinaryFormatter(); using (Stream input = File.Open(openDialog.FileName, FileMode.Open)) { //World w = (World)bf.Deserialize(input); //int f = (int)bf.Deserialize(input); //world = w; //frameRun = f; world = (World)bf.Deserialize(input); frameRun = (int)bf.Deserialize(input); } } catch (Exception ex) { MessageBox.Show(ex.Message); world = currentWorld; frameRun = currentFrameRun; } } world.hive.MessageSender = new BeeMessage(SendMessage); foreach (Bee bee in world.bees) { bee.MessageSender = new BeeMessage(SendMessage); } if (enabled) { timer1.Start(); } }
public Hive(World world, BeeMessage messageSender) { MessageSender = messageSender; this.world = world; Honey = HoneyInitial; InitializeLocations(); Random random = new Random(); for (int i = 0; i < QtdeInicialDeAbelhas; i++) { AddBee(random); } }
public Bee(int id, Point location, Hive hive, World world) { ID = id; this.location = location; InsideHive = true; destinationFlower = null; NectarCollected = 0; CurrentState = BeeState.Idle; this.world = world; this.hive = hive; MessageSender = hive.MessageSender; }
public Form1() { InitializeComponent(); MoveChildForms(); frmHive.Show(this); frmField.Show(this); ResetSimulator(); world = new World(new BeeMessage(SendMessage)); timer1.Interval = 50; timer1.Tick += new EventHandler(RunFrame); timer1.Enabled = false; UpdateStats(new TimeSpan()); //new TesteResizeImage().Show(this); }
private void ResetSimulator() { frameRun = 0; world = new World(new BeeMessage(SendMessage)); renderer = new Renderer(world, frmHive, frmField); }
private void toolStripLabel2_Click(object sender, EventArgs e) { frameRun = 0; world = new World(new BeeMessage(SendMessage)); if (!timer1.Enabled) { toolStrip1.Items[0].Text = "Start simulation"; } }