예제 #1
0
        private void clone_CheckedChanged(object sender, EventArgs e)
        {
            BattleField Battle = BattleField.getBat();

            if (clone.Checked)
            {
                OC = new ObserverClone();
                Battle.AddObserverC(OC);
            }
            else
            {
                Battle.RemoveObserverC(OC);
            }
        }
예제 #2
0
        private void Death_CheckedChanged(object sender, EventArgs e)
        {
            BattleField Battle = BattleField.getBat();

            if (Death.Checked)
            {
                OD = new ObserverDeath(ArmyA, ArmyB);
                Battle.AddObserverD(OD);
            }
            else
            {
                Battle.RemoveObserverD(OD);
            }
        }
예제 #3
0
        private void Pause_Click(object sender, EventArgs e)
        {
            groupBox1.Invoke(new Action(() => groupBox1.Enabled = false));

            BattleField Battle = BattleField.getBat();

            Pause.Enabled     = false;
            UnDo.Enabled      = true;
            OneStep.Enabled   = true;
            Start.Enabled     = true;
            Restart.Enabled   = true;
            groupBox2.Enabled = true;
            groupBox1.Enabled = true;
            Battle.Pause();
        }
예제 #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show("Введите стоимость армий.", "Error.", MessageBoxButtons.OK);
                return;
            }

            BattleField Battle = BattleField.getBat();

            groupBox2.Enabled = true;

            Battle.CreateArmy(Convert.ToInt16(textBox1.Text));
            Battle.AddObserverF(OF);

            Battle.CreateCom(UnDo, ReDo);
            Battle.ShowArmy(ArmyA, ArmyB);
            Start.Enabled   = true;
            OneStep.Enabled = true;
        }
예제 #5
0
        private void Restart_Click(object sender, EventArgs e)
        {
            BattleField Battle = BattleField.getBat();

            Death.Checked = false;
            clone.Checked = false;
            clone_CheckedChanged(sender, e);
            Death_CheckedChanged(sender, e);
            groupBox2.Enabled = false;
            Battle.DelR();
            Battle.DelU();
            Battle.DelB();
            Battle.NotifyObserverF("Начата новая игра");
            button1.Enabled = true;
            Restart.Enabled = false;
            UnDo.Enabled    = false;
            ReDo.Enabled    = false;
            OneStep.Enabled = false;
            Start.Enabled   = false;
            Pause.Enabled   = false;
            ArmyA.Rows.Clear();
            ArmyB.Rows.Clear();
        }
예제 #6
0
        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;
            }
        }
예제 #7
0
        private void many_CheckedChanged(object sender, EventArgs e)
        {
            BattleField Battle = BattleField.getBat();

            Battle.ChangeStrategy(3);
        }