Esempio n. 1
0
        public Game()
        {
            InitializeComponent();
            currentView = new MainMenuView();
            this.playerId = PLAYERID.player1;
            this.enableAllMainMenuControls();

            //fixing the form
            DoubleBuffered = true;
            this.Width = 700 + 15;
            this.Height = 520;

            //labeli za score
            lblScore.BackColor = Color.Transparent;
            finScore.BackColor = Color.Transparent;
            lblScore.Size = new Size(21, 21);
            finScore.Size = new Size(21, 21);

            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.timer1 = new Timer();

            this.timer1.Tick += new EventHandler(timer1_Tick);
            ticksCounter = 0;

            this.level = 1;
            this.scores = 0;
            this.numLives = 5;
        }
Esempio n. 2
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            g.Clear(Color.White);

            if (currentView.GetType() == typeof(MainMenuView) ||
                currentView.GetType() == typeof(ChoosePlayerView) ||
                currentView.GetType() == typeof(InstructionsView) ||
                currentView.GetType() == typeof(ScoreView))
            {
                currentView.drawView(g, this.ClientRectangle);
                if (currentView.GetType() == typeof(ScoreView))
                {
                    this.enableAllScoreViewControls();
                    lblScore.Visible = false;
                    this.finScore.Visible = true;
                    finScore.Text = lblScore.Text;
                }
            }

            else
            {
                //iscrtuvanje na scenata
                currentView.drawView(g, this.ClientRectangle);
                //iscrtuvanje na igracot
                player.DrawPlayer(g, this.ClientRectangle);

                if (Balls.Count() == 0)
                {

                    if (currentView.GetType() != typeof(ThirdLevelView))
                    {
                        this.Update();
                        if (ticksCounter >= 65)
                        {
                            ticksCounter = 0;
                            player.isKilled = false;
                            this.nextLevel();
                            this.startGame();
                            Invalidate();
                        }
                        else
                        {
                            ticksCounter++;
                            //za congrats Level 1 completed etc...
                            lblScore.Visible = false;
                             g.DrawImage(Resources.start,0,0,this.Width,this.Height);

                        }
                    }
                    else
                    {
                        if (ticksCounter >= 65)
                        {
                            currentView = new ScoreView();
                            this.enableAllScoreViewControls();
                            ticksCounter = 0;
                            this.lblScore.Visible = false;
                            Invalidate();
                        }
                        else
                        {
                            ticksCounter++;

                        }

                    }

                }
               else
               {
                    //iscrtuvanje na topkite
                    foreach (Ball ball in Balls)
                    {
                        ball.DrawBall(g);
                    }

                    //  ako igracot e pogoden od topka igrata zavrsuva ili istece vremeto
                    if (player.isHit(Balls) || pbTime.timeUp())
                    {
                        timer1.Stop();
                        //  if it's the last round draw the circle around the player and allow score View
                        if (numLives == 1)
                        {

                            player.isKilled = true;
                            this.Update();

                            //otkako ke gi izgubi site zivoti
                            //broi 15 ticks
                            //za vreme na broenjeto se zatemnuva
                            //i posle ide na gameOver(showScore)
                            if (ticksCounter >= 35)
                            {
                                currentView = new ScoreView();
                                currentView.drawView(g, this.ClientRectangle);
                                ticksCounter = 0;

                            }
                            else
                            {
                                ticksCounter++;
                                if (pbTime.timeUp())
                                {
                                    Brush brush = new SolidBrush(Color.FromArgb(30, Color.Black));
                                    g.FillRectangle(brush, 0, 0, currentView.backgroundImg.Width, currentView.backgroundImg.Height);
                                }
                                else this.roundOver(this.player.X - 25, this.player.Y - 10, 100, g, this.ClientRectangle);
                            }
                            Invalidate();
                        }
                        //if it's not the last round when the player is killed wait for 10 ticks and replay the round
                        else
                        {
                            if (ticksCounter >= 30)
                            {
                                ticksCounter = 0;
                                player.isKilled = false;
                                replayLevel();
                            }
                            else
                            {
                                player.isKilled = true;
                                ticksCounter++;
                                if (pbTime.timeUp())
                                {
                                    Brush brush = new SolidBrush(Color.FromArgb(30, Color.Black));
                                    g.FillRectangle(brush, 0, 0, currentView.backgroundImg.Width, currentView.backgroundImg.Height);
                                }
                                else this.roundOver(this.player.X - 25, this.player.Y - 10, 100, g, this.ClientRectangle);
                            }
                        }
                        Invalidate();

                    }
                    //iscrtuvanje na progres barot
                    pbTime.DrawPB(g);
                }

               //iscrtuvanje na linijata za pukanje
               if (player.isShooting && Shot.numTicks < 150)
               {  Shot.Draw(g, player);
               }
            }
        }
Esempio n. 3
0
        private void button_player3_Click(object sender, EventArgs e)
        {
            if (currentView.GetType() == typeof(ChoosePlayerView))
            {
                disableAllChoosePlayerMenuControls();
            }

            this.playerId = PLAYERID.player3;
            currentView = new MainMenuView();
            enableAllMainMenuControls();
            Invalidate();
        }
Esempio n. 4
0
 private void button_NewGAME_Click(object sender, EventArgs e)
 {
     this.disableAllMainMenuControls();
     currentView = new FirstLevelView(numLives, scores);
     this.startGame();
     this.lblScore.Visible = true;
     scores = 0;
     lblScore.Text = scores.ToString();
     Invalidate();
 }
Esempio n. 5
0
 //button which brings you to the View with instructions
 private void button_INSTRCTIONS_Click(object sender, EventArgs e)
 {
     this.disableAllMainMenuControls();
     currentView = new InstructionsView();
     this.enableAllInstructionsViewControls();
     Invalidate();
 }
Esempio n. 6
0
 private void button_choosePLAYER_Click(object sender, EventArgs e)
 {
     this.disableAllMainMenuControls();
     currentView = new ChoosePlayerView();
     this.enableAllChoosePlayerMenuControls();
     Invalidate();
 }
Esempio n. 7
0
        private void button_BACK_Click(object sender, EventArgs e)
        {
            if (currentView.GetType() == typeof(ScoreView))
            {
                this.disableAllScoreViewControls();
            }

            else if (currentView.GetType() == typeof(ChoosePlayerView))
            {
                this.disableAllChoosePlayerMenuControls();
            }
            else if (currentView.GetType() == typeof(InstructionsView))
            {
                this.disableAllInstructionsViewControls();
            }

            currentView = new MainMenuView();
            enableAllMainMenuControls();

            Invalidate();
        }
Esempio n. 8
0
 public void nextLevel()
 {
     lblScore.Visible = true;
     if(currentView.GetType() == typeof(FirstLevelView))
     {
         currentView = new SecondLevelView(this.numLives, this.scores);
        }
     else if (currentView.GetType() == typeof(SecondLevelView))
     {
         currentView = new ThirdLevelView(this.numLives, this.scores);
     }
 }