Example #1
0
 private void ResumeButton_Click(object sender, EventArgs e)
 {
     Game.Hero.ShowHeroShip = true;
     HeroBulletTimer.Start();
     timer1.Start();
     HidePauseMenu();
     HeroHealth.Visible = true;
     HeroHealth.Enabled = true;
     BossHealth.Visible = true;
     BossHealth.Enabled = true;
 }
Example #2
0
 private void NewGame_Click(object sender, EventArgs e)
 {
     HeroHealth.Visible = true;
     HeroHealth.Enabled = true;
     enemyTimerCounter  = 0;
     Game = new Game(this.Width, this.Height);
     timer1.Start();
     HeroBulletTimer.Start();
     Game.Hero.ShowHeroShip = true;
     HidePauseMenu();
 }
Example #3
0
 private void PickHero4_MouseClick(object sender, MouseEventArgs e)
 {
     HidePickHeroUI();
     Game.Hero.HeroShipImg  = VP_Project.Properties.Resources.HeroShip4;
     Game.Hero.ShowHeroShip = true;
     HeroHealth.Enabled     = true;
     HeroHealth.Visible     = true;
     PickedHeroFlag         = true;
     HeroBulletTimer.Start();
     timer1.Start();
     HeroHealth.Value = Game.Hero.Health;
 }
Example #4
0
        private void LoadGame_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "SpaceOdyssey(*.so)|*.so";
            ofd.Title  = "Load a SpaceOdyssey Game";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                FileName = ofd.FileName;
                BinaryFormatter binaryFormatter = new BinaryFormatter();
                FileStream      stream          = new FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.None);
                Game = (Game)binaryFormatter.Deserialize(stream);
                stream.Close();
                PickedHeroFlag     = true;
                HeroHealth.Enabled = true;
                HeroHealth.Visible = true;
                timer1.Start();
                HeroBulletTimer.Start();
                buttonclicked();
                Game.Hero.ShowHeroShip = true;
            }
            //this.Text = FileName;
        }
Example #5
0
        private void SpaceOdyssey_KeyDown(object sender, KeyEventArgs e)
        {
            e.SuppressKeyPress = true;
            if (e.KeyCode == Keys.Escape && PickedHeroFlag)
            {
                timer1.Stop();
                HeroBulletTimer.Stop();
                Game.Hero.ShowHeroShip = false;

                NewGame.Visible = true;
                NewGame.Enabled = true;

                ResumeButton.Visible = true;
                ResumeButton.Enabled = true;

                QtMainMenu.Visible = true;
                QtMainMenu.Enabled = true;

                SaveGame.Visible = true;
                SaveGame.Enabled = true;

                HeroHealth.Visible = false;
                HeroHealth.Enabled = false;

                BossHealth.Visible = false;
                BossHealth.Enabled = false;
            }

            else if (e.KeyCode == Keys.A)
            {
                Game.Hero.Move(Keys.Left, this.Width);
                foreach (HeroBullet bullet in Game.Hero.bullets)
                {
                    bullet.UpdatePosition();
                }
            }

            else if (e.KeyCode == Keys.D)
            {
                Game.Hero.Move(Keys.Right, this.Width);
                foreach (HeroBullet bullet in Game.Hero.bullets)
                {
                    bullet.UpdatePosition();
                }
            }

            else if (e.KeyCode == Keys.G)
            {
                Game.Boss.Health -= 25;
            }

            Game.CheckBulletsImpact();
            Game.CheckMeteorImpact();
            Game.MoveEnemies();
            Game.MoveMeteors();
            Game.MoveBoss();

            if (Game.Hero.Health >= 0)
            {
                HeroHealth.Value = Game.Hero.Health;
            }
            else
            {
                GameOverTimer_Tick(sender, e);
            }

            Invalidate(true);
        }