Exemplo n.º 1
0
        private void RestartGame()
        {
            // This if-else statements are for to display the character based on the chosen character by the user
            // The default value of choseCharacter variable is man character
            if (ChooseCharacter.chosenCharacter == "woman")
            {
                player.Image = Properties.Resources.p2_up; // set player faces up
            }
            else
            {
                player.Image = Properties.Resources.up; // set player faces up
            }

            foreach (PictureBox i in zombiesList)
            {
                this.Controls.Remove(i); // remove all the zombies on the screen
            }
            zombiesList.Clear();         // clear the zombieList

            foreach (PictureBox i in medicList)
            {
                this.Controls.Remove(i); // remove all the medics on the screen
            }
            medicList.Clear();           // clear the medicList

            foreach (PictureBox i in gunList)
            {
                this.Controls.Remove(i); // remove all the guns on the screen
            }
            gunList.Clear();

            foreach (PictureBox i in shieldList)
            {
                this.Controls.Remove(i); // Remove all the shields on the screen
            }
            shieldList.Clear();

            foreach (PictureBox i in grenadeList)
            {
                this.Controls.Remove(i); // remove all the grenade on the screen
            }
            grenadeList.Clear();         // clear the grenadeList

            for (int i = 0; i < 3; i++)
            {
                MakeZombies(); // create 3 zombies on the screen
            }

            goup         = false;
            godown       = false;
            goleft       = false;
            goright      = false;
            gameOver     = false;
            playerHealth = 100;
            score        = 0;
            ammo         = 10;
            level        = 1;
            tempScore    = 0;

            superGun.Image = null;
            laserGun.Image = null;

            Array.Clear(inventory.bag, 0, inventory.bag.Length);
            inventory.numberOfItem = 0;

            GameTimer.Start();
            MedicTimer.Start();
            SuperGunTimer.Start();
            shieldTimer.Start();
            GrenadeTimer.Start();
        }