private void newGamebtn_Click(object sender, EventArgs e)
        {
            MainScene ms = new MainScene();

            ms.Show();
            this.Close();
        }
Exemple #2
0
 //Тајмер кој ни овозможува после 5 секунди замена од форма2 на Мејн син.
 private void Timer3_Tick(object sender, EventArgs e)
 {
     count++;
     if (count == 5)
     {
         MainScene mn = new MainScene();
         this.Hide();
         mn.ShowDialog();
         timer3.Stop();
         this.Close();
     }
 }
Exemple #3
0
        //Loading scene and changing from form2 to the MainScene
        //
        private void LoadingForm_Load(object sender, EventArgs e)
        {
            MainScene mainScene = new MainScene();

            timer1.Tick    += new EventHandler(move);
            timer1.Interval = 10;
            timer1.Start();
            //Duhet Diskutim
            if (timer1.Interval >= 100)
            {
                MainScene mn = new MainScene();
                if (mn.ShowDialog() == DialogResult.OK)
                {
                    mn.AddOwnedForm(mainscene);
                    timer1.Stop();
                }
                this.Close();
            }
        }
Exemple #4
0
        private void SceneForm_Paint(object sender, PaintEventArgs e)
        {
            Graphics g     = e.Graphics;
            Color    color = NewGame.ActualScene.BackgroundColor;

            g.Clear(color);
            Pen pen = new Pen(color, 1);

            if (gameOver)
            {
                Clock.Stop();
                //string message = NewGame.Player1.Name + "\t" + NewGame.Player2.Name + "\n" +
                //    "Score: " + NewGame.Player1.Points + "\tScore: " + NewGame.Player2.Points + "\n\n\n" +
                //    "Winner is: " + (NewGame.Player1.Points > NewGame.Player2.Points ? NewGame.Player1.Name : NewGame.Player2.Name);



                //MessageBox.Show(message);

                //this.Hide();
                //ResultsScene rs = new ResultsScene();

                //rs.ShowDialog();
                //this.Close();



                //BACKGROUND

                background.Size = new Size(backgroundWidth, backgroundHeight);

                background.Location = new Point(locationX, locationY);
                //background.Image = Resources.BrownTankWinner;
                background.SizeMode    = PictureBoxSizeMode.StretchImage;
                background.BorderStyle = BorderStyle.Fixed3D;


                int newExitGameWidth  = 130;
                int newExitGameHeight = 60;

                // NEW GAME
                int left = 180;
                int top  = 393;

                newGamebtn.Size     = new Size(newExitGameWidth, newExitGameHeight);
                newGamebtn.Location = new Point(left, top + 3);
                newGamebtn.Image    = Resources.newGameBtn;
                newGamebtn.SizeMode = PictureBoxSizeMode.StretchImage;
                background.Controls.Add(newGamebtn);
                newGamebtn.BackColor   = Color.Transparent;
                newGamebtn.Click      += new EventHandler(newGamebtn_Click);
                newGamebtn.MouseEnter += new EventHandler(newGamebtn_MouseEnter);
                newGamebtn.MouseLeave += new EventHandler(newGamebtn_MouseLeave);

                //EXIT GAME

                exitGamebtn.Size     = new Size(newExitGameWidth, newExitGameHeight - 3);
                exitGamebtn.Location = new Point(left + 200, top);
                exitGamebtn.Image    = Resources.ExitBtn;
                exitGamebtn.SizeMode = PictureBoxSizeMode.StretchImage;
                background.Controls.Add(exitGamebtn);
                exitGamebtn.BackColor   = Color.Transparent;
                exitGamebtn.Click      += new EventHandler(exitGamebtn_Click);
                exitGamebtn.MouseEnter += new EventHandler(exitGamebtn_MouseEnter);
                exitGamebtn.MouseLeave += new EventHandler(exitGamebtn_MouseLeave);



                int ScoreX = left + 60;
                int ScoreY = top - 60;
                // LABEL SCORE

                score1.Text      = "SCORE:";
                score1.BackColor = Color.Transparent;
                score1.Font      = new Font("Microsoft Sans Serif", 12);
                score1.ForeColor = Color.White;
                score1.Location  = new Point(ScoreX, ScoreY);
                score1.Size      = new Size(70, 20);
                background.Controls.Add(score1);



                score2.Text      = "SCORE:";
                score2.BackColor = Color.Transparent;
                score2.Font      = new Font("Microsoft Sans Serif", 12);
                score2.ForeColor = Color.White;
                score2.Location  = new Point(ScoreX + 110, ScoreY);
                score2.Size      = new Size(70, 20);
                background.Controls.Add(score2);



                scoreFirstPlayer.Text      = NewGame.Player1.Points.ToString();
                scoreFirstPlayer.BackColor = Color.Transparent;
                scoreFirstPlayer.Font      = new Font("Microsoft Sans Serif", 12);
                scoreFirstPlayer.ForeColor = Color.White;
                background.Controls.Add(scoreFirstPlayer);
                scoreFirstPlayer.Location = new Point(ScoreX + 70, ScoreY);


                scoreSecondPlayer.Text      = "Pts";
                scoreSecondPlayer.BackColor = Color.Transparent;
                scoreSecondPlayer.Font      = new Font("Microsoft Sans Serif", 12);
                scoreSecondPlayer.ForeColor = Color.White;
                background.Controls.Add(scoreSecondPlayer);
                scoreSecondPlayer.Location = new Point(ScoreX + 110 + 70, ScoreY);

                if (NewGame.Player1.Points > NewGame.Player2.Points)
                {
                    //this.BackgroundImage = Resources.GreenTankWinner;
                    background.Image       = Resources.GreenTankWinner;
                    scoreFirstPlayer.Text  = NewGame.Player2.Points.ToString();
                    scoreSecondPlayer.Text = NewGame.Player1.Points.ToString();
                }
                else
                {
                    //this.BackgroundImage = Resources.BrownTankWinner;
                    background.Image       = Resources.BrownTankWinner;
                    scoreSecondPlayer.Text = NewGame.Player2.Points.ToString();
                    scoreFirstPlayer.Text  = NewGame.Player1.Points.ToString();
                }

                Controls.Add(background);
                MainScene.updateScores(NewGame.Player1.Name, NewGame.Player2.Name, NewGame.Player1.Points, NewGame.Player2.Points);
            }
            else
            {
                //g.DrawEllipse(pen, new Rectangle(new Point(100, 100), new Size(200, 300)));
                NewGame.DrawScene(pen, g, this);

                foreach (Bullet bullet in Bullets)
                {
                    bullet.Draw(g);
                }

                for (int i = Bullets.Count - 1; i >= 0; --i)
                {
                    if (Bullets[i].BulletTime > 5000)
                    {
                        Bullets.RemoveAt(i);
                    }
                }
            }
            pen.Dispose();
        }