예제 #1
0
 private void Play(object sender, EventArgs e)
 {
     if (File.Exists(memoryTextBox5.Text))
     {
         try
         {
             if (mp.Source == null || mp.Source.LocalPath != memoryTextBox5.Text)
             {
                 mp.Open(new Uri(memoryTextBox5.Text));
             }
             mp.Play();
             mp.MediaEnded += delegate(object s, EventArgs args)
             {
                 mp.Stop();
             };
         }
         catch
         {
             MessageBox.Show("Ошибка воспроизведения!");
         }
     }
     else
     {
         MessageBox.Show("Файла не существует!");
     }
 }
예제 #2
0
        //start game engine
        public void GameInitialize()
        {
            this.BackgroundImage = Properties.Resources.planet_express_building;

            score          = 0;
            time           = 600;
            zoidbergBoxNum = 0;

            titleLabel.Visible    = false;
            subtitleLabel.Visible = false;
            titleZoidberg.Visible = false;
            adLabel.Visible       = false;
            adPictureBox.Visible  = false;

            gameTimer.Enabled = true;
            gameState         = "running";

            zoidbergBox.Visible = true;
            zoidbergX           = 350;
            objectXList.Clear();
            objectYList.Clear();
            objectSpeedList.Clear();
            objectTypeList.Clear();

            title.Stop();
            theme.MediaEnded += new EventHandler(Theme_Ended);
            theme.Open(new Uri(Application.StartupPath + "/Resources/Futurama theme song.wav"));
            theme.Play();
        }
예제 #3
0
 private void GameScreen_Load(object sender, EventArgs e)
 {
     player.y    = this.Height - pheight;
     player.hb.Y = this.Height - pheight;
     music.Stop();
     music.Play();
     music.MediaEnded += music_Loop;
 }
예제 #4
0
 public void Dispose()
 {
     if (me != null)
     {
         me.Stop();
         me.Close();
         me = null;
     }
 }
예제 #5
0
        //Methods

        //Crash Method
        private void Crash(int x, int y)
        {
            //Stop bike sound
            lightCycle.Stop();
            lightCycle2.Stop();

            //Play death sound
            death.Play();

            Graphics fg = this.CreateGraphics();

            for (int loop = 0; loop < 3; loop++)
            {
                fg.FillRectangle(heroBrush, p1X, p1Y, p1W, p1H);
                fg.FillRectangle(monsterBrush, p2X, p2Y, p2W, p2H);

                for (int i = 5; i < p1xBeen.Count; i++)
                {
                    fg.FillRectangle(tailBrush, p1xBeen[i], p1yBeen[i], p1W, p1H);
                }

                for (int i = 5; i < p2xBeen.Count; i++)
                {
                    fg.FillRectangle(tailBrush2, p2xBeen[i], p2yBeen[i], p2W, p2H);
                }
                //Blink player
                fg.FillRectangle(backColour, x, y, p1W, p1H);
                Thread.Sleep(250);
                fg.FillRectangle(heroBrush, x, y, p2W, p2H);
                Thread.Sleep(250);
            }
        }
예제 #6
0
        public void GameOver()
        {
            if (dist > maxDist)
            {
                maxDist = dist;                 // if you broke record, replace it
            }
            xmlSave();
            gameTimer.Stop(); // stop doing things

            if (coinScore >= 0)
            {
                revivePopup.dist = (int)(dist / 100);   //sets the dist you travelled
                revivePopup rp = new revivePopup();     //then opens a new popup
                rp.Location = this.FindForm().Location; // places in proper loc
                DialogResult result = rp.ShowDialog();  //show

                if (result == DialogResult.Yes)         // if revive button pushed,
                {
                    gameTimer.Enabled = true;           // renable timer
                    backgroundMoveSpd = spdStorage;     // restore spd
                    timeBtwnLasers    = 120;            // reset this
                    coinScore        -= 250;            // remove coins
                    endGame           = false;          // reset
                    lasers.Clear();                     //reset
                }
                else if (result == DialogResult.No)     // if shop button
                {
                    Form1.switchScreen(this, "shop");   //switch to shop
                    actualDist = 0;                     //reset dist
                    dist       = 0;
                }
                else if (result == DialogResult.OK) // obselete
                {
                    ShopScreen.switchS = true;
                    Form1.switchScreen(this, "shop");

                    dist       = 0;
                    actualDist = 0;
                }
                else if (result == DialogResult.Abort)
                {
                    FindForm().Close(); // close game
                }
                music.Stop();
            }
            else //obselete
            {
                Form1.switchScreen(this, "shop");
            }
        }
예제 #7
0
파일: Form1.cs 프로젝트: Colb98/UI_Media
        private void MediaPlayer_MediaEnded(object sender, EventArgs e)
        {
            if (repeat_mode == 0)
            {
                if (i == FilePath.Count - 1)
                {
                    playing = false;
                    mediaPlayer.Stop();

                    CircularButton btn = (CircularButton)playingUC2.Controls.Find("play", true)[0];
                    btn.BackgroundImage = UI_Media.Properties.Resources.play_button;
                }
                else
                {
                    i++;
                    mediaPlayer.Open(new Uri(FilePath[i], UriKind.Absolute));
                    mediaPlayer.Play();
                }
            }
            else if (repeat_mode == 1)
            {
                mediaPlayer.Position = new TimeSpan(0);
            }
            else
            {
                i = (++i) % FilePath.Count;
                mediaPlayer.Open(new Uri(FilePath[i], UriKind.Absolute));
                mediaPlayer.Play();

                string FileName = System.IO.Path.GetFileName(FilePath[i]);
                this.Text = label1.Text = FileName + " - Media Player";
                System.Windows.Forms.Label lb = (System.Windows.Forms.Label) this.playingUC2.Controls.Find("label3", true)[0];
                lb.Text = FileName;
            }
        }
예제 #8
0
        public tutorialScreen()
        {
            InitializeComponent();

            BMPlayer = new System.Windows.Media.MediaPlayer();
            BMPlayer.Open(new Uri(Application.StartupPath + "/Resources/battle_music.mp3"));
            BMPlayer.Stop();
            BMPlayer.Play();

            // set up background music ^
            // inititalize graphics \/

            xStart = -100;
            xStop  = 50;
            Efire.RotateFlip(RotateFlipType.Rotate180FlipY);
            bm        = new Bitmap(this.Width, this.Height);
            offScreen = Graphics.FromImage(bm);
            gGraphics = this.CreateGraphics();
            Bazooka   = new Bitmap(Properties.Resources.BazookaIcon, Properties.Resources.ATIcon.Width / 2, fire.Height);
            Hvy       = new Bitmap(Properties.Resources.HvyIcon, Properties.Resources.ATIcon.Size);
            Lt        = new Bitmap(Properties.Resources.LtIcon, Properties.Resources.ATIcon.Width / 2, Properties.Resources.ATIcon.Height);
            Md        = new Bitmap(Properties.Resources.MdIcon, Properties.Resources.ATIcon.Width / 2, Properties.Resources.ATIcon.Height);
            Soldier   = new Bitmap(Properties.Resources.SoldierIcon, Properties.Resources.ATIcon.Width / 2, Properties.Resources.ATIcon.Height);
            Sniper    = new Bitmap(Properties.Resources.SniperIcon, Properties.Resources.ATIcon.Width / 2, Properties.Resources.ATIcon.Height);
        }
예제 #9
0
 private void остановитьСигналToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         mp.Stop();
     }
     catch { }
 }
예제 #10
0
        private void drawPickleRick_Click(object sender, EventArgs e) //i made it so when u click starting label it loads this
        {
            //players
            System.Windows.Media.MediaPlayer beepPlayer;
            System.Windows.Media.MediaPlayer themePlayer;

            //sounds
            beepPlayer = new System.Windows.Media.MediaPlayer();
            beepPlayer.Open(new Uri(Application.StartupPath + "/Resources/beep_02.wav"));
            themePlayer = new System.Windows.Media.MediaPlayer();                                 //theme
            themePlayer.Open(new Uri(Application.StartupPath + "/Resources/Im_Pickle_Rick.wav")); //theme

            //hide label
            musicPlayer.Visible = false;
            beepPlayer.Play();
            Thread.Sleep(1000);
            beepPlayer.Stop();

            //graphics
            Graphics   graphics          = this.CreateGraphics();
            Pen        drawPen           = new Pen(Color.Red, 10);
            SolidBrush labelBrushA       = new SolidBrush(Color.Navy);
            Font       loadingFont       = new Font("Impact", 40, FontStyle.Bold);
            SolidBrush loadingBrush      = new SolidBrush(Color.DarkGray);
            Font       loadingFontCover  = new Font("Impact", 40, FontStyle.Bold);
            SolidBrush loadingBrushCover = new SolidBrush(Color.Blue);
            Font       welcomeFont       = new Font("Comic Sans", 30, FontStyle.Bold);
            SolidBrush welcomeBrush      = new SolidBrush(Color.Red);

            //loadscreen (waste time counting down)
            graphics.DrawString("Loading", loadingFont, loadingBrush, 120, 140);
            Thread.Sleep(1200);
            graphics.DrawString(".", loadingFont, loadingBrush, 305, 140);
            Thread.Sleep(1200);
            graphics.DrawString(".", loadingFont, loadingBrush, 320, 140);
            Thread.Sleep(1200);
            graphics.DrawString(".", loadingFont, loadingBrush, 335, 140);
            Thread.Sleep(1200);
            //blue
            graphics.DrawString(".", loadingFontCover, loadingBrushCover, 305, 140);
            Thread.Sleep(1200);
            graphics.DrawString(".", loadingFontCover, loadingBrushCover, 320, 140);
            Thread.Sleep(1200);
            graphics.DrawString(".", loadingFontCover, loadingBrushCover, 335, 140);
            Thread.Sleep(1200);
            //gray
            graphics.DrawString(".", loadingFont, loadingBrush, 305, 140);
            Thread.Sleep(1200);
            graphics.DrawString(".", loadingFont, loadingBrush, 320, 140);
            Thread.Sleep(1200);
            graphics.DrawString(".", loadingFont, loadingBrush, 335, 140);
            Thread.Sleep(1200);

            Thread.Sleep(1000); //make longer after testing
            graphics.FillRectangle(labelBrushA, 110, 140, 270, 70);
            graphics.DrawString("Welcome!", welcomeFont, welcomeBrush, 140, 150);
            themePlayer.Play();
        }
예제 #11
0
 private void timer4_Tick(object sender, EventArgs e)
 {
     if (alive == true)
     {
         gr.DrawImage(drone.droneimg, drone.position);
         time4 += timer4.Interval;
         if (time4 >= 10)
         {
             time4 = 0;
             if (drone.position.Y < 300 && posit == false)
             {
                 drone.position.Y += 3;
                 if (drone.position.Y > 270)
                 {
                     posit = true;
                 }
             }
             if (drone.position.Y > 100 && posit == true)
             {
                 drone.position.Y -= 3;
                 if (drone.position.Y < 130)
                 {
                     posit = false;
                 }
             }
         }
         if (pictureBox2.Width == 0)
         {
             alive = false;
         }
     }
     if (alive == false && message == false)
     {
         time4 += timer4.Interval;
         gr.DrawImage(drone.deaddrone[drone.currentimage], drone.position);
         if (time4 >= 50)
         {
             drone.currentimage++;
             if (drone.currentimage == 6)
             {
                 System.Windows.Media.MediaPlayer backgroundMusic;
                 backgroundMusic = new System.Windows.Media.MediaPlayer();
                 backgroundMusic.Open(new Uri(Directory.GetCurrentDirectory() + "\\guchimuchi.wav"));
                 backgroundMusic.Play();
                 message         = true;
                 backgroundMusic = new System.Windows.Media.MediaPlayer();
                 backgroundMusic.Open(new Uri(Directory.GetCurrentDirectory() + "\\golos.wav"));
                 backgroundMusic.Play();
                 MessageBox.Show("Вы пабидили)))");
                 backgroundMusic.Stop();
                 backgroundMusic.Close();
                 this.Close();
             }
         }
     }
 }
예제 #12
0
 public static void SoundStop()
 {
     if (!stop)
     {
         soundMove.Stop();
         soundStop.Play();
         stop = true;
         move = false;
     }
 }
예제 #13
0
 /// <summary>
 ///		Detiene la reproducción de un archivo
 /// </summary>
 private void StopPlay()
 {
     // Detiene la reproducción
     _mediaPlayer.Stop();
     // Indica que se ha detenido
     ViewModel.IsPlaying = false;
     // y oculta la barra de progreso y detiene el temporizador
     prgMedia.Visibility = System.Windows.Visibility.Collapsed;
     _tmrTimer.Stop();
 }
 public static void stopOvenSound()
 {
     try
     {
         player.Stop();
     }
     catch (Exception e)
     {
         // Handled, ignore issue.
     }
 }
예제 #15
0
 private void MusicOnToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (musicOnToolStripMenuItem.Checked)
     {
         musicPlayer.Play();
     }
     else
     {
         musicPlayer.Stop();
     }
 }
예제 #16
0
 private void PlayMusic(int a)
 {
     System.Windows.Media.MediaPlayer backgroundMusic;
     backgroundMusic = new System.Windows.Media.MediaPlayer();
     backgroundMusic.Open(new Uri(Directory.GetCurrentDirectory() + "\\Harppen.wav"));
     backgroundMusic.Play();
     if (a == 0)
     {
         backgroundMusic.Stop();
         backgroundMusic.Close();
     }
 }
예제 #17
0
 private void countDown_Tick(object sender, EventArgs e)
 {
     //start countdown timer
     counter++;
     if (counter < 5)
     {
         raceStart.Stop();
         raceStart.Play();
         if (counter == 4)
         {
             engine.Stop();
             engine.Play();
         }
     }
 }
예제 #18
0
        public Form1()
        {
            InitializeComponent();

            this.boardColumns = new Rectangle[7];

            this.board = new int[6, 7];

            this.turn = 1;

            eightBitPlayer = new System.Windows.Media.MediaPlayer();
            eightBitPlayer.Open(new Uri(Application.StartupPath + "/Resources/08_Ascending.wav"));

            eightBitPlayer.Stop();
            eightBitPlayer.Play();
        }
예제 #19
0
 private void timer3_Tick(object sender, EventArgs e)
 {
     gr.DrawImage(vehicle.imagesvehicles[vehicle.currentimage], vehicle.position);
     time3 += timer3.Interval;
     if (time3 >= 10 && viselzagran == false)
     {
         vehicle.position.X -= 10;
         time3 = 0;
         if (vehicle.position.X < -500)
         {
             viselzagran = true;
         }
     }
     if (viselzagran == true)
     {
         vehicle.currentimage++;
         if (vehicle.currentimage == 4)
         {
             vehicle.currentimage = 0;
         }
         vehicle.position.X = 1500;
         viselzagran        = false;
         udar = false;
     }
     if (vehicle.position.Y + 20 > player.position.Y && vehicle.position.Y - 10 < player.position.Y && vehicle.position.X + 50 > player.position.X && vehicle.position.X - 40 < player.position.X && udar == false)
     {
         System.Windows.Media.MediaPlayer backgroundMusic;
         backgroundMusic = new System.Windows.Media.MediaPlayer();
         backgroundMusic.Open(new Uri(Directory.GetCurrentDirectory() + "\\uron.wav"));
         backgroundMusic.Play();
         udar      = true;
         HP.Width -= 100;
     }
     if (HP.Width == 0 && message == false)
     {
         System.Windows.Media.MediaPlayer backgroundMusic;
         backgroundMusic = new System.Windows.Media.MediaPlayer();
         backgroundMusic.Open(new Uri(Directory.GetCurrentDirectory() + "\\golos.wav"));
         backgroundMusic.Play();
         message = true;
         MessageBox.Show("Вы погибли(((");
         backgroundMusic.Stop();
         backgroundMusic.Close();
         this.Close();
     }
 }
예제 #20
0
        private void Form1_Load(object sender, EventArgs e)
        {
            titleMusic.Open(new Uri(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "BONGO.mp3")));
            mainGameMusic.Open(new Uri(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "funky beat.mp3")));

            // Create an instance of the MainScreen
            MainScreen ms = new MainScreen();

            titleMusic.Stop();
            titleMusic.Play();

            // Add the User Control to the Form
            this.Controls.Add(ms);

            ms.Location = new Point((this.Width - ms.Width) / 2, (this.Height - ms.Height) / 2);
            loadHighscores();
        }
예제 #21
0
        private void playButton_Click(object sender, EventArgs e)
        {
            gamesoundPlayer.Stop();
            playButton.Visible       = false;
            exitButton.Visible       = false;
            toptitleLabel.Visible    = false;
            middletitleLabel.Visible = false;
            bottemtitleLabel.Visible = false;

            failLabel.Visible        = true;
            loadingtextLabel.Visible = true;
            MadebyLabel.Text         = "Level: 1";

            Refresh();
            Thread.Sleep(3000);

            MainForm.ChangeScreen(this, "GameScreen");
        }
예제 #22
0
        /// <summary>
        /// 停止播放声音
        /// </summary>
        public void StopAudio()
        {
            System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                try
                {
                    if (_player != null)
                    {
                        _player.Stop();
                    }

                    _player = null;
                }
                catch (Exception ex)
                {
                    Log.SaveLog("Core Common_StopAudio", ex.ToString());
                }
            }));
        }
예제 #23
0
 public static void MediaEnded(Action <bool> StartStopTimer, bool forceStop = false)
 {
     if (remainingNotifications > 0 && forceStop == false)
     {
         remainingNotifications--;
         player.Stop();
         Thread.Sleep(300);
         player.Play();
     }
     else
     {
         player.Close();
         soundIsPlaying = false;
         player         = new System.Windows.Media.MediaPlayer(); // doesn't work otherwise?
         if (StartStopTimer != null)
         {
             StartStopTimer(false);
         }
     }
 }
예제 #24
0
        private void Timer1_Tick(object sender, EventArgs e)
        {
            if (music == false)
            {
                //background music
                backMedia.Play();
                music = true;
            }

            #region Move dashes and lamp post
            if (dashes)
            {
                //lamp posts
                if (lampPostX.Count == 0 || lampPostSpace == 40)
                {
                    lampPostX.Add(225);
                    lampPostY.Add(100);
                    lampPostHeight.Add(100);
                    lampPostWidth.Add(25);
                    lampPostSpace = 0;
                }

                for (int i = 0; i < lampPostX.Count; i++)
                {
                    lampPostX[i]      -= 3;
                    lampPostY[i]      += 3;
                    lampPostWidth[i]  += 1;
                    lampPostHeight[i] += 3;

                    if (lampPostHeight[i] > this.Height)
                    {
                        lampPostX.RemoveAt(i);
                        lampPostY.RemoveAt(i);
                        lampPostWidth.RemoveAt(i);
                        lampPostHeight.RemoveAt(i);
                    }
                }

                //dashes
                if (rightDashesY.Count == 0 || dashSpace == 8)
                {
                    rightDashesY.Add(150);
                    leftDashesY.Add(0);
                    dashSpace = 0;
                }

                for (int i = 0; i < rightDashesY.Count; i++)
                {
                    rightDashesY[i] += 20;
                    if (rightDashesY[i] > this.Height + 100)
                    {
                        rightDashesY.RemoveAt(i);
                    }
                }

                for (int i = 0; i < leftDashesY.Count; i++)
                {
                    leftDashesY[i] += 20;
                    if (leftDashesY[i] > this.Height + 100)
                    {
                        leftDashesY.RemoveAt(i);
                    }
                }
            }
            #endregion

            #region Clouds
            if (cloudX.Count == 0 || cloudSpace == 100)
            {
                cloudY.Add(randGen.Next(10, 100));
                cloudX.Add(-200);
                cloudSpace = 0;
            }
            for (int i = 0; i < cloudX.Count; i++)
            {
                cloudX[i] += 5;
                if (cloudX[i] > this.Width)
                {
                    cloudX.RemoveAt(i);
                    cloudY.RemoveAt(i);
                }
            }
            #endregion

            if (running)
            {
                #region Move player
                if (rightDown)
                {
                    carX += carSpeed;
                    if (carX >= closestLane)
                    {
                        rightDown = false;
                    }
                }

                if (leftDown)
                {
                    carX -= carSpeed;
                    if (carX <= closestLane)
                    {
                        leftDown = false;
                    }
                }
                #endregion

                #region Deicde lane and frenquency
                if (obstacleCounter >= obstacleFrenq)
                {
                    int i = randGen.Next(1, 4);
                    if (i == 1)
                    {
                        leftObstacle    = true;
                        obstacleCounter = 0;
                    }
                    if (i == 2)
                    {
                        rightObstacle   = true;
                        obstacleCounter = 0;
                    }
                    if (i == 3)
                    {
                        centerObstacle  = true;
                        obstacleCounter = 0;
                    }
                }
                else
                {
                    obstacleCounter++;
                }
                #endregion

                #region Obstacle movement
                if (leftObstacle)
                {
                    leftObstacleX        -= 2;
                    leftObstacleY        += 5;
                    obstacleHeight[left] += 1;
                    obstacleWidth[left]  += 1;
                }

                if (centerObstacle)
                {
                    centerObstacleY          += 6;
                    centerObstacleX          -= 1;
                    obstacleHeight[centerOb] += 1;
                    obstacleWidth[centerOb]  += 2;
                }

                if (rightObstacle)
                {
                    rightObstacleX        += 2;
                    rightObstacleY        += 5;
                    obstacleHeight[right] += 1;
                    obstacleWidth[right]  += 1;
                }

                //reset after they leave screen
                if (leftObstacle && leftObstacleY > this.Height)
                {
                    leftObstacle         = false;
                    leftObstacleX        = 260;
                    leftObstacleY        = 150;
                    obstacleHeight[left] = 50;
                    obstacleWidth[left]  = 100;
                }

                if (centerObstacle && centerObstacleY > this.Height)
                {
                    centerObstacle           = false;
                    centerObstacleX          = 395;
                    centerObstacleY          = 150;
                    obstacleHeight[centerOb] = 50;
                    obstacleWidth[centerOb]  = 70;
                }

                if (rightObstacle && rightObstacleY > this.Height)
                {
                    rightObstacle         = false;
                    rightObstacleX        = 485;
                    rightObstacleY        = 150;
                    obstacleHeight[right] = 50;
                    obstacleWidth[right]  = 100;
                }


                #endregion

                #region Intersections and clear for end screen
                Rectangle playerRec = new Rectangle(carX, 460 + 30, 150, 40);
                Rectangle leftRec   = new Rectangle(leftObstacleX, leftObstacleY + 50, obstacleWidth[left], 40);
                Rectangle centerRec = new Rectangle(centerObstacleX, centerObstacleY + 50, obstacleWidth[centerOb], 40);
                Rectangle rightRec  = new Rectangle(rightObstacleX, rightObstacleY + 50, obstacleWidth[right], 40);

                if (playerRec.IntersectsWith(leftRec) || playerRec.IntersectsWith(centerRec) || playerRec.IntersectsWith(rightRec))
                {
                    skid.Stop();
                    skid.Play();

                    crash.Stop();
                    crash.Play();

                    running            = false;
                    endScreen          = true;
                    scoreTimer.Enabled = false;
                    dashes             = false;

                    leftObstacle         = false;
                    leftObstacleX        = 260;
                    leftObstacleY        = 150;
                    obstacleHeight[left] = 50;
                    obstacleWidth[left]  = 100;

                    centerObstacle           = false;
                    centerObstacleX          = 395;
                    centerObstacleY          = 150;
                    obstacleHeight[centerOb] = 50;
                    obstacleWidth[centerOb]  = 70;

                    rightObstacle         = false;
                    rightObstacleX        = 485;
                    rightObstacleY        = 150;
                    obstacleHeight[right] = 50;
                    obstacleWidth[right]  = 100;
                    lastScore             = 0;
                    obstacleFrenq         = 50;
                }
                #endregion

                //increase car frequncy
                if (score > lastScore + 0.2)
                {
                    obstacleFrenq -= 5;
                    speed          = speed + 5;
                    lastScore      = score;
                }
            }
            dashSpace++;
            cloudSpace++;
            lampPostSpace++;
            Refresh();
        }
예제 #25
0
        //SoundPlayer startRace = new SoundPlayer(Properties.Resources.raceStart);
        //SoundPlayer engine = new SoundPlayer(Properties.Resources.engine);

        #endregion

        private void backMedia_MediaEnded(object sender, EventArgs e)
        {
            backMedia.Stop();
            backMedia.Play();
        }
예제 #26
0
 private void Radio_FormClosed(object sender, FormClosedEventArgs e)
 {
     player.Stop();
 }
예제 #27
0
        private void GameScreen_Paint(object sender, PaintEventArgs e)
        {
            SolidBrush g = new SolidBrush(Color.Green);
            SolidBrush b = new SolidBrush(Color.SkyBlue);

            e.Graphics.FillRectangle(g, 0, this.Height - 100, this.Width, 100);
            e.Graphics.FillRectangle(b, 0, 0, this.Width, this.Height - 100);

            e.Graphics.DrawRectangle(new Pen(Color.Black), cloudX, 50, 100, 50);
            if (!started)
            {
                Font s = new Font(Font.FontFamily, 20);

                e.Graphics.DrawString("Press Space to Play!", s, new SolidBrush(Color.Black), (this.Width - 300) / 2, 100);
            }
            if (!up && !grounded)
            {
                frame = 9;
            }
            if (up && curntMech != "superJump")
            {
                frame = 8;
            }
            if (grounded && !up && tick % 4 == 0)
            {
                frame++;
            }
            if (curntMech == "superJump" && tick % 4 == 0)
            {
                frame++;
            }
            if (endGame)
            {
                frame = 10;
            }
            switch (curntMech)
            {
            case "none":
                frameCount = gifImage.GetFrameCount(dimension);
                if (frame >= 8 && grounded && !up && !endGame)
                {
                    frame = 0;
                }
                e.Graphics.DrawImage(gifImage, player.hb);
                gifImage.SelectActiveFrame(dimension, frame);

                break;

            case "teleporter":
                e.Graphics.DrawImage(Properties.Resources.teleporter, player.hb.X, player.hb.Y);
                break;

            case "superJump":
                frameCount = spImage.GetFrameCount(dimension);
                if (frame >= 8 && !endGame)
                {
                    frame = 0;
                }
                e.Graphics.DrawImage(spImage, player.x, player.y);
                spImage.SelectActiveFrame(spdimension, frame);

                break;

            case "gravity":
                frameCount = gImage.GetFrameCount(dimension);
                if (frame >= 8 && grounded && !up && !endGame)
                {
                    frame = 0;
                }
                e.Graphics.DrawImage(gImage, player.x, player.y);
                gImage.SelectActiveFrame(gdimension, frame);

                break;
            }



            if (curntMech == "teleporter")
            {
                teleporterDraw(e.Graphics, teleporterMarkerY);
            }
            foreach (Classes.rocket l in rockets)
            {
                if (l.launchingRocket && l.launchingTicks < 180)
                {
                    l.launchingTicks++;
                    l.hb.Y = player.y + 25;
                    l.y    = player.y + 25;
                    e.Graphics.DrawImage(l.i, l.hb);
                }
                if (l.launchingTicks == 180 && l.launchingRocket)
                {
                    l.hb.Y            = player.y + 25;
                    l.y               = player.y + 25;
                    l.launchingRocket = false;
                }
                if (!l.launchingRocket)
                {
                    l.move();
                    e.Graphics.DrawImage(l.i, l.hb);
                    if (l.hb.Right <= 0)
                    {
                        rocketToRemove = l;
                    }
                    if (player.hb.IntersectsWith(l.hb))
                    {
                        //GameOver();
                        if (!endGame && curntMech == "none")
                        {
                            endGame = true;
                            death.Stop();
                            death.Play();
                            spdStorage = backgroundMoveSpd;
                            bounce     = (this.Height - player.y) / 2;
                        }
                        else if (curntMech != "none")
                        {
                            broken.Stop();
                            broken.Play();
                            toClearLsers = true;
                            grounded     = false;
                            curntMech    = "none";
                        }
                    }
                }
            }

            foreach (Classes.laser l in lasers)
            {
                l.move();
                e.Graphics.DrawImage(l.i, l.hb);
                if (l.hb.Right <= 0)
                {
                    laserToRemove = l;
                }
                if (player.hb.IntersectsWith(l.hb))
                {
                    //GameOver();
                    if (!endGame && curntMech == "none")
                    {
                        death.Stop();
                        death.Play();
                        spdStorage = backgroundMoveSpd;
                        endGame    = true;
                        bounce     = (this.Height - player.y) / 2;
                    }
                    else if (curntMech != "none")
                    {
                        broken.Stop();
                        broken.Play();
                        toClearLsers = true;
                        grounded     = false;
                        curntMech    = "none";
                    }
                }
            }
            if (toClearLsers)
            {
                lasers.Clear();
                rockets.Clear();
                toClearLsers = false;
            }
            List <Classes.coin> delete = new List <Classes.coin>();

            foreach (Classes.coin c in coins)
            {
                if (c.hb.IntersectsWith(player.hb))
                {
                    coinScore++;
                    //coinToRemove = c;
                    delete.Add(c);
                }
                else
                {
                    c.move();
                    e.Graphics.FillEllipse(coinBrush, c.hb);
                    if (c.hb.Right <= 0)
                    {
                        //coinToRemove = c;
                        delete.Add(c);
                    }
                }
            }
            foreach (Classes.mechToken m in MTokens)
            {
                if (m.hb.IntersectsWith(player.hb))
                {
                    MTokenToRemove = m;
                    curntMech      = m.type;
                    lasers.Clear();
                    rockets.Clear();
                    broken.Play();
                }
                else
                {
                    m.move();
                    e.Graphics.FillRectangle(coinBrush, m.hb);
                    if (m.hb.Right <= 0)
                    {
                        MTokenToRemove = m;
                    }
                }
                if (upgrades["xray"])
                {
                    string s = "";
                    Font   f = new Font(Font.FontFamily, 20);
                    if (m.type == "teleporter")
                    {
                        s = "T";
                    }
                    else if (m.type == "superJump")
                    {
                        s = "S";
                    }
                    else if (m.type == "gravity")
                    {
                        s = "G";
                    }
                    e.Graphics.DrawString(s, f, new SolidBrush(Color.Black), m.hb.X + 10, m.hb.Y + 10);
                }
            }
            Font fr = new Font("Arial", 16);

            e.Graphics.DrawString("Coins " + coinScore, fr, new SolidBrush(Color.Black), 0, 10);
            e.Graphics.DrawString("Distance " + actualDist + "m", fr, new SolidBrush(Color.Black), 0, 30);
            RemoveLaser(laserToRemove);
            RemoveCoin(delete);
            RemoveMToken(MTokenToRemove);
            MTokenToRemove = null;
            coinToRemove   = null;
            laserToRemove  = null;
        }
예제 #28
0
        private void GameTimer_Tick(object sender, EventArgs e)
        {
            tick++;                         // tick
            cloudX    -= backgroundMoveSpd; // move cloud
            dist      += backgroundMoveSpd; // add to dist
            actualDist = dist / 100;        // actual distance travelled
            if (endGame && tick % 15 == 0)
            {
                if (backgroundMoveSpd > 0)
                {
                    backgroundMoveSpd--;
                }
                else if (bounce < 10 && backgroundMoveSpd == 0)
                {
                    GameOver();
                }
            }
            if (endGame && player.hb.Bottom >= this.Height && !bounceUp)
            {
                bounceUp = true;
                bounce  /= 2;
                if (bounce < 15)
                {
                    bounce = 0;
                }
            }
            if (player.hb.Bottom > this.Height - bounce && bounceUp && endGame)
            {
                player.move(-10);
                airDownFrames = 0;
            }
            else
            {
                bounceUp = false;
            }

            if (r.Next(0, 101) < coinChance && tick % 120 == 0 && !endGame)
            {
                generateCoin(r.Next(0, 3), r.Next(100, this.Height - 100));
            }
            if (r.Next(0, 2) == 0 && tick % 1200 == 0 && !endGame && curntMech == "none")
            {
                Classes.mechToken m = new Classes.mechToken(this.Width, r.Next(0, this.Height - 50));
                if (!abort)
                {
                    MTokens.Add(m);
                }
                else
                {
                    abort = false;
                }
            }
            if (tick == 180)
            {
                lasers.Add(new Classes.laser(this.Width, 10, midLaser, laserWidth, Properties.Resources.laserV));
            }
            else if (tick % timeBtwnLasers == 0 && !endGame)
            {
                generateLaser(player.y);
            }
            if (tick % 1200 == 0 && coinChance < 35 && !endGame)
            {
                coinChance += 5;
            }

            if (tick % 240 == 0)
            {
                cloudX = this.Width;
            }
            if (tick % 550 == 0 && !endGame)
            {
                if (backgroundMoveSpd < 20)
                {
                    backgroundMoveSpd += 2;
                }

                //if (timeBtwnLasers > 15) timeBtwnLasers -= 15;
            }
            if (tick % 240 == 0)
            {
                if (timeBtwnLasers > 20)
                {
                    timeBtwnLasers -= 15;
                }
                else
                {
                    //timeBtwnLasers = 5;
                }
            }
            if (tick % 600 == 0 && r.Next(0, 3) == 0 && !upgrades["jammer"])
            {
                if (r.Next(0, 5) == 0)
                {
                    spawnBarrage  = true;
                    barrageSpawns = 0;
                }

                Classes.rocket rc = new Classes.rocket(this.Width - 80, player.y + 25);
                alert.Stop();
                alert.Play();
                rockets.Add(rc);
            }
            if (spawnBarrage && tick % 30 == 0 && barrageSpawns < 5)
            {
                Classes.rocket rc = new Classes.rocket(this.Width - 80, player.y + 25);
                rockets.Add(rc);
                barrageSpawns++;
            }



            switch (curntMech)
            {
            case "none":
                standardGrounded();
                standardUp();
                standardGav();
                standardJump();
                break;

            case "teleporter":
                grounded = true;
                break;

            case "superJump":
                superJumpUp();
                superJumpGav();
                break;

            case "gravity":
                GsuitGav();
                break;
            }



            if (endGame)
            {
                up = false;
            }
            Refresh();
        }
예제 #29
0
        private void gameTimer_Tick(object sender, EventArgs e)
        {
            #region move
            waterGirlY += jumpSpeed;
            fireBoyY   += jump2Speed;

            //watergirl moving
            if (jumpingGirl && force < 0)
            {
                jumpingGirl = false;
            }

            if (aDown)
            {
                waterGirlX -= playerSpeed;
            }

            if (dDown)
            {
                waterGirlX += playerSpeed;
            }

            if (jumpingGirl)
            {
                jumpSpeed = -12;
                force    -= 1;
            }
            else
            {
                jumpSpeed = 12;
            }

            //fireboy moving
            if (jumpingBoy && force2 < 0)
            {
                jumpingBoy = false;
            }

            if (leftArrow)
            {
                fireBoyX -= player2Speed;
            }

            if (rightArrow)
            {
                fireBoyX += player2Speed;
            }

            if (jumpingBoy)
            {
                jump2Speed = -12;
                force2    -= 1;
            }
            else
            {
                jump2Speed = 12;
            }
            #endregion

            Rectangle waterGirlRec = new Rectangle(waterGirlX, waterGirlY + 20, playerLength, playerHeight - 20);
            Rectangle fireBoyRec   = new Rectangle(fireBoyX, fireBoyY + 20, playerLength, playerHeight - 20);

            for (int i = 0; i < landingXList.Count(); i++)
            {
                Rectangle landRec      = new Rectangle(landingXList[i], landingYList[i], landingLList[i], 1);
                Rectangle bottomLand   = new Rectangle(landingXList[i], landingYList[i] + wallThick, landingLList[i], 2);
                Rectangle leftWallRec  = new Rectangle(0, landingYList[i], wallThick, landingHList[i]);
                Rectangle rightWallRec = new Rectangle(572, 0, wallThick, 600);

                #region watergirl intersections
                if (waterGirlRec.IntersectsWith(landRec) && !jumpingGirl)
                {
                    force      = 7;
                    waterGirlY = landingYList[i] - playerHeight;
                }

                if (waterGirlRec.IntersectsWith(bottomLand))
                {
                    waterGirlY = waterGirlY + 10;
                }

                if (waterGirlRec.IntersectsWith(leftWallRec))
                {
                    waterGirlX = waterGirlX + playerSpeed;
                }

                if (waterGirlRec.IntersectsWith(rightWallRec))
                {
                    waterGirlX = waterGirlX - 1;
                }
                #endregion

                #region fireboy intersections
                if (fireBoyRec.IntersectsWith(landRec) && !jumpingBoy)
                {
                    force2   = 7;
                    fireBoyY = landingYList[i] - playerHeight;
                }

                if (fireBoyRec.IntersectsWith(bottomLand))
                {
                    fireBoyY = fireBoyY + 10;
                }

                if (fireBoyRec.IntersectsWith(leftWallRec))
                {
                    fireBoyX = fireBoyX + player2Speed;
                }

                if (fireBoyRec.IntersectsWith(rightWallRec))
                {
                    fireBoyX = fireBoyX - 1;
                }
                #endregion
            }

            //if you run into the 'puddles'
            Rectangle waterPuddle = new Rectangle(285, 230, 10, 3);
            Rectangle firePuddle  = new Rectangle(350, 415, 10, 3);
            if (fireBoyRec.IntersectsWith(waterPuddle) || waterGirlRec.IntersectsWith(firePuddle))
            {
                gameState = "gameLost";
            }

            //how to win the game, both players are touching their door
            Rectangle waterDoorRec = new Rectangle(464, 40, 10, 35);
            Rectangle fireDoorRec  = new Rectangle(490, 40, 10, 35);

            if (waterGirlRec.IntersectsWith(waterDoorRec) && fireBoyRec.IntersectsWith(fireDoorRec))
            {
                Thread.Sleep(500);
                backMedia.Stop();
                gameState = "gameWon";
            }

            Refresh();
        }
 public void Stop()
 {
     player.Stop();
     currState = AudioState.STOPPED;
 }