private void button_set_Click(object sender, EventArgs e) { lock (flags) { SetWindow st = new SetWindow(ref flags, ref game, this); st.Show(); } }
private void Flush() { if (!alreadySet) { lock (flags) { SetWindow st = new SetWindow(ref flags, ref game, this); st.Show(); } alreadySet = true; } CameraReading(); lock (flags) { game.BallsDot.Clear(); foreach (Point2i posBall in flags.posBalls) { game.BallsDot.Add(new Dot(posBall.X, posBall.Y)); } game.CarA.Pos.x = flags.posCarA.X; game.CarA.Pos.y = flags.posCarA.Y; game.CarB.Pos.x = flags.posCarB.X; game.CarB.Pos.y = flags.posCarB.Y; } game.Update(); lock (flags) { flags.currPersonNum = game.CurrPersonNumber; for (int i = 0; i != Game.MaxPersonNum; ++i) { flags.posPersonStart[i].X = game.People[i].StartPos.x; flags.posPersonStart[i].Y = game.People[i].StartPos.y; flags.gameState = game.State; } } byte[] Message = game.PackMessage(); label_CountDown.Text = Convert.ToString(game.Round); if (serial1 != null && serial1.IsOpen) { serial1.Write(Message, 0, 32); } if (serial2 != null && serial2.IsOpen) { serial2.Write(Message, 0, 32); } ShowMessage(Message); validPorts = SerialPort.GetPortNames(); }