Esempio n. 1
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. 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);
               }
            }
        }