private void MyThread() { BattleField Battle = BattleField.getBat(); Battle.DelR(); int i = Battle.DoMany(ArmyA, ArmyB); if (i == 1 || i == 2) { if (i == 1) { string s = Battle.WhoWin() + " выиграли!"; Battle.NotifyObserverF(s); MessageBox.Show(s, "Win!", MessageBoxButtons.OK); } else { MessageBox.Show("Ничья.", "GameOver!", MessageBoxButtons.OK); Battle.NotifyObserverF("Ничья."); } Restart.Invoke(new Action(() => Restart.Enabled = true)); UnDo.Invoke(new Action(() => UnDo.Enabled = false)); ReDo.Invoke(new Action(() => ReDo.Enabled = false)); OneStep.Invoke(new Action(() => OneStep.Enabled = false)); Start.Invoke(new Action(() => Start.Enabled = false)); Pause.Invoke(new Action(() => Pause.Enabled = false)); groupBox2.Invoke(new Action(() => groupBox2.Enabled = true)); groupBox1.Invoke(new Action(() => groupBox1.Enabled = true)); } }
private void OneStep_Click(object sender, EventArgs e) { UnDo.Enabled = true; button1.Enabled = false; Restart.Enabled = true; Pause.Enabled = false; Restart.Enabled = true; BattleField Battle = BattleField.getBat(); Battle.DelR(); ReDo.Enabled = false; int i = Battle.DoOne(ArmyA, ArmyB); if (i == 1 || i == 2) { if (i == 1) { string s = Battle.WhoWin() + " выиграли!"; Battle.NotifyObserverF(s); MessageBox.Show(s, "Win!", MessageBoxButtons.OK); } else { MessageBox.Show("Ничья.", "GameOver!", MessageBoxButtons.OK); Battle.NotifyObserverF("Ничья."); } Restart.Enabled = true; UnDo.Enabled = false; ReDo.Enabled = false; OneStep.Enabled = false; Start.Enabled = false; Pause.Enabled = false; } }