Example #1
0
 public int Hit(BulletsDoc bDoc)
 {
     int ret = 0;
     this.Kids.Sort();
     bDoc.Bullets.Sort();
     for (int i = this.Kids.Count - 1; i >= 0; --i)
     {
         bool flag = false;
         for (int j = bDoc.Bullets.Count - 1; j >= 0; --j)
             if (this.Kids[i].Hit(bDoc.Bullets[j]))
             {
                 bDoc.Bullets.RemoveAt(j);
                 flag = true;
                 Kids[i].X -= 20; //Pushback
                 break;
             }
         if (flag)
         {
             if (this.Kids[i].isDead())
             {
                 this.Kids.RemoveAt(i);
                 ret++;
             }
         }
     }
     return ret;
 }
Example #2
0
        public Form1()
        {
            InitializeComponent();
            StartWindow();
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
            this.DoubleBuffered = true;
            this.gameStarted = false;

            Bullets = new BulletsDoc();
            Houses = new HousesDoc(this.Width);
            Kids = new KidsDoc();
            Clouds = new CloudsDoc(this.Width, this.Height);
            Music = new Sounds();
            Levels = new LevelsDoc();
            CurrentLevel = new List<Kid>();
            CarItems = new CarDoc();
            Players = new PlayersDoc();
            KidsKilled = 0;
        }
Example #3
0
 private void levelFinished()
 {
     if (Kids.Kids.Count == 0 && CurrentLevel.Count == 0)
     {
         //nextlevel
         timerNewHouse.Stop();
         timerNewCloud.Stop();
         timerDrawing.Stop();
         NextLevelWindow nextLevel = new NextLevelWindow();
         if (nextLevel.ShowDialog() == DialogResult.OK)
         {
             Kids = new KidsDoc();
             Bullets = new BulletsDoc();
             Houses = new HousesDoc(this.Width);
             CurrentLevel = Levels.getNextLevel();
             gameStarted = true;
             Houses.startMoving();
             StartWindow();
         }
         else
         {
             nextLevel = null;
             gameOver();
         }
     }
 }
Example #4
0
 private void showMainMenu()
 {
     timerNewHouse.Stop();
     Kids = new KidsDoc();
     Houses = new HousesDoc(this.Width);
     Levels = new LevelsDoc();
     Clouds = new CloudsDoc(this.Width, this.Height);
     Bullets = new BulletsDoc();
     showButtons();
     CarItems.MoveToStart();
     gameStarted = false;
     StartWindow();
 }
Example #5
0
 private void gameOver()
 {
     timerNewHouse.Stop();
     timerDrawing.Stop();
     GameOverWindow gameOver = new GameOverWindow();
     writeToFile(gameOver.PlayerName, this.KidsKilled);
     this.KidsKilled = 0;
     DialogResult res=gameOver.ShowDialog();
     if ( res== DialogResult.OK)
     {
         Kids = new KidsDoc();
         Bullets = new BulletsDoc();
         Levels = new LevelsDoc();
         Houses = new HousesDoc(this.Width);
         CurrentLevel = Levels.getNextLevel();
         gameStarted = true;
         Houses.startMoving();
         StartWindow();
     }
     else if(res == DialogResult.No)
     {
         Application.Exit();
     }
     else
     {
         gameOver = null;
         showMainMenu();
     }
 }