Пример #1
0
        public void loadScores()
        {
            //creating Xml reader file
            XmlReader reader = XmlReader.Create("HighScores.xml", null);
            string    e;

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Text)
                {
                    e = reader.ReadString();

                    HighScores s = new HighScores(e);

                    topearnings.Add(s);
                }
            }

            reader.Close();
        }
Пример #2
0
        public void TimerOff()
        {
            //mood.levelHeight/mood.height times 20
            double sandwichMoney = ((double)mood.levelHeight / (double)mood.height) * 20;


            if (((double)mood.levelHeight / (double)mood.height) * 20 < 0)
            {
                //should fix the issue of keeping track of money
                sandwichMoney = 0;
            }

            //if customer number is smaller than the amount of customers in each level, proceed with the level
            if (customerNumber < numbers)
            {
                earnings        += sandwichMoney;
                moneyEarned.Text = "$ " + earnings;
                customers.RemoveAt(0);
                OnStart();
                gameTimer.Enabled = true;
                if (earnings <= 0) //if earnings is less than or equal to zero,
                {
                    Form f = this.FindForm();
                    f.Controls.Remove(value: this);
                    GameOverScreen gos = new GameOverScreen();
                    f.Controls.Add(gos);

                    gos.Location = new Point((f.Width - gos.Width) / 2, (f.Height - gos.Height) / 2);
                    gos.Focus();
                }
            }

            //if the amount of customers in the game is equal to the amount of customers in each level, display the code
            else if (customerNumber == numbers)
            {
                if (earnings >= quotas)
                {
                    //Moving on the level
                    levelNumber++;
                    //if level number is larger than 3, display the following code
                    if (levelNumber > 3)
                    {
                        HighScores s = new HighScores(Convert.ToString(earnings));
                        Form1.topearnings.Add(s);
                        save();
                        //move screen to win screen

                        Form f = this.FindForm();
                        f.Controls.Remove(value: this);
                        WinGameScreen wgs = new WinGameScreen();
                        f.Controls.Add(wgs);

                        wgs.Location = new Point((f.Width - wgs.Width) / 2, (f.Height - wgs.Height) / 2);
                        wgs.Focus();
                    }
                    customers.RemoveAt(0);
                    OnStart();
                    gameTimer.Enabled = true;
                }
                else //go to lose screen
                {
                    //adding the earnings to the list and saving the list
                    HighScores s = new HighScores(Convert.ToString(earnings));
                    Form1.topearnings.Add(s);
                    save();

                    Form f = this.FindForm();
                    f.Controls.Remove(value: this);
                    GameOverScreen gos = new GameOverScreen();
                    f.Controls.Add(gos);

                    gos.Location = new Point((f.Width - gos.Width) / 2, (f.Height - gos.Height) / 2);
                    gos.Focus();
                }
            }
        }