Beispiel #1
0
        /// <summary>
        /// Funkcja obsługująca przycisk odpowiedzialny za pójście do domu
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonGoHome_Click(object sender, EventArgs e)
        {
            FormHome fH = new FormHome(people, dayCounter, cash, amountOfPills);

            this.Close();
            fH.Show();
        }
Beispiel #2
0
        /// <summary>
        /// Funkcja obsługująca tick zegara odpowiedzialnego za awarie/choroby
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void timerAccident_Tick(object sender, EventArgs e)
        {
            Random random = new Random();
            int    tmp    = random.Next(0, 2);

            if (dayCounter > 2)
            {
                if (tmp == 0)
                {
                    accident = new PowerFailure();
                    random   = new Random();
                    if (random.Next(1, 101) <= accident.GetPossibility())
                    {
                        timerInGame.Stop();
                        timerPersonTime.Stop();
                        timerAccident.Stop();
                        MessageBox.Show(accident.Description());
                        PowerFailure powerFailure = (PowerFailure)accident;
                        labelNumber1.Visible = labelNumber1.Enabled = true;
                        labelNumber1.Text    = powerFailure.GetNumber1().ToString();
                        numberFirst          = powerFailure.GetNumber1();

                        labelNumber2.Visible = labelNumber2.Enabled = true;
                        labelNumber2.Text    = powerFailure.GetNumber2().ToString();
                        numberSecond         = powerFailure.GetNumber2();

                        solutionNumber = powerFailure.GetSolution();

                        labelOperand.Visible = labelOperand.Enabled = true;

                        textBoxAnswer.Enabled       = textBoxAnswer.Visible = true;
                        progressBarMath.Enabled     = progressBarMath.Visible = true;
                        buttonConfirmAnswer.Enabled = buttonConfirmAnswer.Visible = true;

                        timerMath.Start();
                    }
                }
                else
                {
                    accident = new Illness();
                    random   = new Random();
                    if (random.Next(1, 101) <= accident.GetPossibility())
                    {
                        timerInGame.Stop();
                        timerPersonTime.Stop();
                        timerAccident.Stop();
                        MessageBox.Show(accident.Description());
                        if (amountOfPills >= 1)
                        {
                            amountOfPills--;
                            MessageBox.Show("Bierzesz tabletkę! Możesz wracać do pracy");
                        }
                        if (amountOfPills == 0)
                        {
                            cash -= accident.GetPenalty();
                            MessageBox.Show("Musisz wcześniej wyjść z pracy z powodu choroby! Dostajesz karę pieniężną.");
                            FormHome fH = new FormHome(people, dayCounter, cash, amountOfPills);
                            this.Close();
                            fH.Show();
                        }
                    }
                }
            }
        }