Пример #1
0
        //GameOver wird nach dem drücken einer belibigen Taste, nach dem Ende des Spiels ausgeführt
        private void GameOver()
        {
            Score           = 0;
            Hits            = 0;
            Stage           = 1;
            LabelScore.Text = Score.ToString();
            LabelStage.Text = Stage.ToString();
            Lives           = 3;
            Label2.Hide();
            Label5.Hide();

            Over = false;

            Live1.Show();
            Live2.Show();
            Live3.Show();

            MonstersDelete();
            MonstersNew();

            Random.Start();
            MonstersMove.Start();
            Bullets.Start();
            MonstersAttack.Start();
        }
Пример #2
0
        //Main Aktion, Key_Down alles starten
        private void Game_KeyDown(object sender, KeyEventArgs e)
        {
            Random.Start();
            MonstersMove.Start();
            Label7.Hide();

            string Geschwindgkeit = "15";
            int    PositionX      = Tank.Location.X;
            int    PositionY      = Tank.Location.Y;
            int    PositionLabelX = Bullet1.Location.X;
            int    PositionLabelY = Bullet1.Location.Y;

            if (e.KeyCode == Keys.Right && PositionX + Tank.Width < this.Width - 20)
            {
                Tank.Location = new Point(PositionX += Convert.ToInt32(Geschwindgkeit), Tank.Location.Y);
                if (PositionLabelY == 525)
                {
                    Bullet1.Location = new Point(PositionLabelX += Convert.ToInt32(Geschwindgkeit), Bullet1.Location.Y);
                }
            }

            if (e.KeyCode == Keys.Left && PositionX > 15)
            {
                Tank.Location = new Point(PositionX -= Convert.ToInt32(Geschwindgkeit), Tank.Location.Y);
                if (PositionLabelY == 525)
                {
                    Bullet1.Location = new Point(PositionLabelX -= Convert.ToInt32(Geschwindgkeit), Bullet1.Location.Y);
                }
            }
            PositionLabelY = Bullet1.Location.Y;

            if (e.KeyCode == Keys.Space &&
                tankBullet == null)
            {
                bool ID = false;

                tankBullet = new Bullet(new Point(PositionX += 24, PositionY), ID);
                Controls.Add(tankBullet.Label);
                panel2.BringToFront();
            }
            if (Over && e.KeyCode == Keys.Space)
            {
                GameOver();
            }
        }
Пример #3
0
        //Ende, führt wiederholt die Aktionen der GameOver-Funktin aus, zudem öffnet sie die HighScore-Liste
        private void End()
        {
            MonstersDelete();
            if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
            {
                Connections c = new Connections();

                c.InsertData(Score, Stage, Hits);
            }
            else
            {
                new NetworkFail().Show(this);
            }
            Over = true;
            Live3.Hide();
            Live2.Hide();
            Live1.Hide();
            Label5.Show();
            Bullets.Stop();
            MonstersMove.Stop();
            Random.Stop();
            MonstersAttack.Stop();
            GameOver();
        }