Esempio n. 1
49
 public void LaserSound()
 {
     System.Media.SoundPlayer player = new System.Media.SoundPlayer();
     player.SoundLocation = "peww1.wav";
     player.Load();
     player.Play();
     player.Play();
 }
Esempio n. 2
0
 private void playSound(string path)
 {
     System.Media.SoundPlayer player = new System.Media.SoundPlayer();
     player.SoundLocation = path;
     player.Load();
     player.Play();
 }
Esempio n. 3
0
        public void refreshControls()
        {
            lblTurno.Invoke((MethodInvoker)(() => lblTurno.Text = String.Format("{0}", turnosModel.TurnoActual.Turno.ToString())));
            lblVentanilla.Invoke((MethodInvoker)(() => lblVentanilla.Text = String.Format("{0}", turnosModel.TurnoActual.Ventanilla.ToString())));

            short iter = 0;
            if (turnosModel.TurnosAtendiendo.Count() != 0)
            {
                foreach (turno item in (turnosModel.TurnosAtendiendo.Count() == 1 ? turnosModel.TurnosAtendiendo : turnosModel.TurnosAtendiendo.GetRange(turnosModel.TurnosAtendiendo.Count() - 2, 2)))
                {
                    if (iter == 0)
                    {
                        lblTurno1Atiende.Invoke((MethodInvoker)(() => lblTurno1Atiende.Text = String.Format("{0}", item.Turno.ToString())));
                        lblVentanilla1Atiende.Invoke((MethodInvoker)(() => lblVentanilla1Atiende.Text = String.Format("{0}", item.Ventanilla.ToString())));
                        lblServicio1Atiende.Invoke((MethodInvoker)(() => lblServicio1Atiende.Text = String.Format("{0}", item.Tramite.ToString())));
                    }
                    else
                    {
                        lblTurno2Atiende.Invoke((MethodInvoker)(() => lblTurno2Atiende.Text = String.Format("{0}", item.Turno.ToString())));
                        lblVentanilla2Atiende.Invoke((MethodInvoker)(() => lblVentanilla2Atiende.Text = String.Format("{0}", item.Ventanilla.ToString())));
                        lblServicio2Atiende.Invoke((MethodInvoker)(() => lblServicio2Atiende.Text = String.Format("{0}", item.Tramite.ToString())));
                    }
                    iter++;
                }
            }

            System.Media.SoundPlayer player = new System.Media.SoundPlayer();
            player.SoundLocation = string.Format("{0}\\{1}{2}", System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), @"Assets\Sounds\", "defaultSound.wav");
            player.Play();
        }
Esempio n. 4
0
        public static void PlaySound(string soundpath)
        {
            System.Media.SoundPlayer player = new System.Media.SoundPlayer();

            try
            {
                player.SoundLocation = soundpath;
                player.Play();
            }
            catch
            {
                MessageBox.Show("Failed to play custom sound");
                player.SoundLocation = "Resources/alarm_beep.wav";
                player.Play();
            }
        }
Esempio n. 5
0
        private void Form1_Load(object sender, EventArgs e)
        {
            System.Media.SoundPlayer player = new System.Media.SoundPlayer();

            player.SoundLocation = "Sound.wav";
            player.Play();
        }
Esempio n. 6
0
        public int SearchandDestroy(bool reset)
        {
            System.Media.SoundPlayer player = new System.Media.SoundPlayer(Properties.Resources.kachu);
            System.Media.SoundPlayer playerInf = new System.Media.SoundPlayer(Properties.Resources.pikapika);

            TargetManager tm = TargetManager.GetInstance();
            Controller controller = Controller.GetInstance();

            int i = 0;
            foreach (Target target in tm.TMTargets)
            {
                i++;

                controller.MoveTo(target.x, target.y);

                player.Play();
                controller.Fire();
                controller.SetNum(controller.GetNum() - 1);

                playerInf.PlayLooping();

                if (i != tm.TMTargets.Count)
                {
                    if (reset == true)
                    {
                        controller.Launcher.Reset();
                    }
                }

                Thread.Sleep(250);
            }

            return i;
        }
Esempio n. 7
0
 static void Main(string[] args)
 {
     if (Convert.ToInt32(args[0]) == -1)
     {
         string soundsRoot = @"I:\ORT_Pendrive\Proyecto\TaskExecute\TaskExecute\bin\Debug\music";
         Random rand = new Random();
         var soundFiles = Directory.GetFiles(soundsRoot, "*.wav");
         var playSound = soundFiles[rand.Next(0, soundFiles.Length)];
         System.Media.SoundPlayer player = new System.Media.SoundPlayer(playSound);
         if (args[1] == "T")
         {
             player.Play();
         }
         else
         {
             player.Stop();
         }
         Console.Read();
     }
     else
     {
         int output = Convert.ToInt32(Math.Pow(2, Convert.ToInt32(args[0])));
         int total = PortControl.PortControl.Input(888);
         if (args[1] == "T")
         {
             if (((byte)PortControl.PortControl.Input(888) & (byte)output) == (byte)0)
                 PortControl.PortControl.Output(888, total + output);
         }
         else
             if (((byte)PortControl.PortControl.Input(888) & (byte)output) == output)
                 PortControl.PortControl.Output(888, total - output);
         Environment.Exit(0);
     }
 }
Esempio n. 8
0
        static void EndGame()
        {
            player = new System.Media.SoundPlayer("crash.wav");
            player.Play();

            for (int i = 0; i < 3; i++)
            {
                Console.BackgroundColor = ConsoleColor.Red;
                Console.Clear();
                System.Threading.Thread.Sleep(200);
                Console.BackgroundColor = ConsoleColor.Yellow;
                Console.Clear();
                System.Threading.Thread.Sleep(200);
            }

            Console.ForegroundColor = ConsoleColor.Red;
            Console.SetCursorPosition(35, 10);

            Console.WriteLine(@"

             _______  _______  __   __  _______    _______  __   __  _______  ______
            |       ||   _   ||  |_|  ||       |  |       ||  | |  ||       ||    _ |
            |    ___||  |_|  ||       ||    ___|  |   _   ||  |_|  ||    ___||   | ||
            |   | __ |       ||       ||   |___   |  | |  ||       ||   |___ |   |_||_
            |   ||  ||       ||       ||    ___|  |  |_|  ||       ||    ___||    __  |
            |   |_| ||   _   || ||_|| ||   |___   |       | |     | |   |___ |   |  | |
            |_______||__| |__||_|   |_||_______|  |_______|  |___|  |_______||___|  |_|     ");
        }
Esempio n. 9
0
        songbookEntities2 testcontext; //

        #endregion Fields

        #region Constructors

        public Controller(Panel[] panels, ListBox _lbSongs, ComboBox _cbShowCategory, ComboBox _cbAddSongCategory, ListBox _lbRemoveSong)
        {
            Panels = panels;
            lbSongs = _lbSongs;
            cbShowCategory = _cbShowCategory;
            cbAddSongCategory = _cbAddSongCategory;
            lbRemoveSong = _lbRemoveSong;
            currentCategory = -1;
            ShowPanel(0); // иницијално ги сокриваме сите панели
            Panels[1].Hide(); //како и панелот со мени
            Graph = Panels[0].CreateGraphics(); //платно за исцртување на интро панелот
            buffBmp = new Bitmap(Panels[0].Width, Panels[0].Height); //
            buffGraph = Graphics.FromImage(buffBmp); //платно кое го користиме како бафер
            numbSteps = 0;
            backgColor = Color.FromArgb(250, 250, 200); // позадинска боја на интрото
            //креирање на четки и фонтови
            brushBlue = new SolidBrush(Color.Blue);
            brushDodgerBlue = new SolidBrush(Color.DodgerBlue);
            brushRed = new SolidBrush(Color.Red);
            font1 = new Font("Arial", 30);
            font2 = new Font("Arial", 20);
            font3 = new Font("Arial", 16);

            testcontext = new songbookEntities2();

            loadIntro();
            // стартување тајмерот
            loadTimer = new Timer();
            loadTimer.Interval = 50;
            loadTimer.Tick += new EventHandler(timer_Tick);
            loadTimer.Start();
            // стартување на интро звукот
            System.Media.SoundPlayer player = new System.Media.SoundPlayer(Resources.intro);
            player.Play();
        }
Esempio n. 10
0
 private void TagVisualization_Initialized(object sender, EventArgs e)
 {
     String appdir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
     var path = System.IO.Path.Combine(appdir, "camera-shutter-click-01.wav");
     System.Media.SoundPlayer player = new System.Media.SoundPlayer(path);
     player.Play();
 }
Esempio n. 11
0
 private void btPlay_Click(object sender, EventArgs e)
 {
     int sel = Convert.ToInt32(listboxWavSlection.SelectedIndex);
     string location = CDCControls.WavLocation[sel];
     System.Media.SoundPlayer player = new System.Media.SoundPlayer(location);
     player.Play();
 }
Esempio n. 12
0
        public void PlayErrorSound()
        {
            if (App.Settings.PlayErrorSound)
            {
                try
                {
                    if (errorSound == null)
                    {
                        string soundFile = Path.Combine(App.AppDir, "Error.wav");
                        if (File.Exists(soundFile))
                        {
                            errorSound = new System.Media.SoundPlayer(soundFile);
                            errorSound.Load();
                        }
                    }
                    errorSound?.Play();
                }
                catch
                {
                }

                //Console.Beep(1000, 100);
                //Console.Beep(1000, 100);
                //Console.Beep(1000, 100);
            }
        }
Esempio n. 13
0
        static void Main(string[] args)
        {
            string dave = "\u0044\u0061\u0076\u0065";

            Console.WriteLine("Hello, " + dave + ".");
            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("\aAre You Trying To Turn ME Off ?");
            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("\aAre You Still Trying\a To Leave ME " + dave + " ?!\a");
            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("I'm sorry " + dave + ", I'm afraid I can't do that.");
            System.Media.SoundPlayer myPlayer = new System.Media.SoundPlayer();

            //Just change the first part of this to wherever the Hello_Wold folder is on your Drive
            myPlayer.SoundLocation = @"J:\Homework\CSC202\Hello_World\Hello_World\SorryDave.wav";
            myPlayer.Play();
            Console.WriteLine("Press any key to");
            Console.WriteLine("\t\tKiLL ");
            Console.Write("\t\t   HAL");
            Console.ReadKey(true);
        }
Esempio n. 14
0
 public override void controllerActivated(Dictionary<int, Target> targets)
 {
     System.Media.SoundPlayer myPlayer = new System.Media.SoundPlayer();
     myPlayer.SoundLocation = @"C:\Users\jon\AppData\Local\Temp\Temp2_P3StarterCode.zip\P3StarterCode\coin.wav";
     myPlayer.LoadAsync();
     myPlayer.Play();
 }
Esempio n. 15
0
        public void PlaySound(string soundLocation, int volume)
        {
            if (string.IsNullOrEmpty(soundLocation)) return;

            try
            {
                Log.DebugFormat("Playing sound '{0}' at volume", soundLocation, volume);

                try
                {
                    if (currentWaveOutVolume == null || currentWaveOutVolume.Value != volume)
                    {
                        int newVolume = ((ushort.MaxValue / 100) * volume);
                        uint newVolumeAllChannels = (((uint)newVolume & 0x0000ffff) | ((uint)newVolume << 16)); //Set the volume on left and right channels
                        PInvoke.waveOutSetVolume(IntPtr.Zero, newVolumeAllChannels);
                        currentWaveOutVolume = volume;
                    }
                }
                catch (Exception exception)
                {
                    var customException = new ApplicationException(
                        string.Format("There was a problem setting the wave out volume to '{0}'", volume), exception);

                    PublishError(this, customException);
                }

                var player = new System.Media.SoundPlayer(soundLocation);
                player.Play();
            }
            catch (Exception exception)
            {
                PublishError(this, exception);
            }
        }
Esempio n. 16
0
 public void ShowAwooga()
 {
     var player = new System.Media.SoundPlayer { SoundLocation = _config.Wav };
     player.Play();
     var awooga = new AwoogaForm(_config.Image);
     awooga.ShowDialog();
 }
Esempio n. 17
0
        // Handle the SpeakCompleted event.
        static void synth_SpeakCompleted(object sender, SpeakCompletedEventArgs e)
        {
            // Create a SoundPlayer instance to play the output audio file.
            var m_SoundPlayer = new System.Media.SoundPlayer(@"C:\MyWavFile.wav");

            //  Play the output file.
            m_SoundPlayer.Play();
        }
 public Winner2()
 {
     InitializeComponent();
     System.Media.SoundPlayer timeclap = new System.Media.SoundPlayer();
     timeclap.Stream = Properties.Resources.Clap;
     timeclap.Load();
     timeclap.Play();
 }
 /// <summary>
 /// plays a sound
 /// </summary>
 /// <param name="sound_filename"></param>
 private void PlaySound(string sound_filename)
 {
     usage.Update("Play Sound, SurveyorVisionStereoGtk, PlaySound");
     
     System.Media.SoundPlayer myPlayer = new System.Media.SoundPlayer();
     myPlayer.SoundLocation = sound_filename;
     myPlayer.Play();
 }
Esempio n. 20
0
        private static void PlayTest(Sound test)
        {
            using (var stream = new MemoryStream(test.SoundContent))
            using (var player = new System.Media.SoundPlayer(stream))
                player.Play();

            Console.WriteLine($"Played: {test}");
        }
Esempio n. 21
0
 private static void Play(string sound)
 {
     new Thread(() =>
     {
         player = new System.Media.SoundPlayer(sound);
         player?.Play();
     }).Start();
 }
Esempio n. 22
0
 private void listBox1_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     int index = listBox1.SelectedIndex;
     // MessageBox.Show("" + index + ": " + filepaths[index]);
     System.Media.SoundPlayer player = new System.Media.SoundPlayer(filepaths[index]);
     try
     {
         if (Control.ModifierKeys == Keys.Alt)
             player.Play();
         else
             player.Play();
     }
     catch (Exception exception)
     {
         filenames[index] += "(Broken?)";
         listBox1.DataSource = filenames;
     }
 }
 public void chequeo_estadistica_vacia()
 {
     if (dataGridView1.Rows.Count == 0)
     {
         System.Media.SoundPlayer sound = new System.Media.SoundPlayer(@"C:\Windows\Media\Windows Exclamation.wav");
         sound.Play();
         MessageBox.Show("Estadistica vacia");
     }
 }
 private void website_Click(object sender, RoutedEventArgs e)
 {
     if (website_Usr_Ctrl_Click != null)
     {
         website_Usr_Ctrl_Click(this, new EventArgs());
     }
     System.Media.SoundPlayer player = new System.Media.SoundPlayer("../../sound/tick.wav");
     player.Play();
 }
Esempio n. 25
0
 /// <summary>
 /// plays a sound
 /// </summary>
 /// <param name="sound_filename"></param>
 private void PlaySound(string sound_filename)
 {
     System.Media.SoundPlayer myPlayer = new System.Media.SoundPlayer();
     myPlayer.SoundLocation = sound_filename;
     myPlayer.Play();
     
     //Gnome.Sound.Init("localhost");
     //Gnome.Sound.Play(sound_filename);
 }
Esempio n. 26
0
 public static void PlayError(bool force)
 {
     if (!File.Exists(config.fileError)) return;
     if (force || config.checkError.Checked)
     {
         System.Media.SoundPlayer player = new System.Media.SoundPlayer(config.fileError);
         player.Play();
     }
 }
Esempio n. 27
0
 public static void playSoundEffect(UnmanagedMemoryStream soundFile)
 {
     if (soundFlag == true)
     {
         Stream stream = soundFile;
         sp = new System.Media.SoundPlayer(stream);
         sp.Play();
     }
 }
Esempio n. 28
0
        private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
        {

            System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"F:\Personal\Study\Assingment\PSM\E-SiLK\E-SiLK\Sound\bg.wav");
            player.Play();
            this.sensorChooser = new KinectSensorChooser();
            this.sensorChooser.KinectChanged += SensorChooserOnKinectChanged;
            this.sensorChooserUi.KinectSensorChooser = this.sensorChooser;
            this.sensorChooser.Start();
        }
Esempio n. 29
0
 public void PlayWav(string path)
 {
     // NOT TESTED
     //TODO: figure this shit out
     using (System.Media.SoundPlayer player = new System.Media.SoundPlayer())
     {
         player.SoundLocation = path;
         player.Play();
     }
 }
Esempio n. 30
0
 void playmusic()
 {
     if(Properties.Settings.music_on)
     {
         System.Media.SoundPlayer player = new System.Media.SoundPlayer(new MemoryStream(Properties.Resources.frametraxx_Manga_Action));
         frm_options.music_playing = Properties.Settings.music_on;
         player.Load();
         player.Play();
     }
 }
        private static void PlayNotificationSound(string sound)
        {
            var soundsFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Sounds");
            var soundFile = Path.Combine(soundsFolder, sound + ".wav");

            using (var player = new System.Media.SoundPlayer(soundFile))
            {
                player.Play();
            }
        }
Esempio n. 32
0
        public WinScreen()
        {
            InitializeComponent();

            System.Media.SoundPlayer player = new System.Media.SoundPlayer();
            player.SoundLocation = Path.Combine(Environment.CurrentDirectory, "win.wav");
            player.Play();

            this.KeyDown += new KeyEventHandler(OnKeyDown);
        }
Esempio n. 33
0
        private void PlaySound(GSound s)
        {
            switch (s)
            {
            case GSound.Marked:
                sp_marked?.Play();
                break;

            case GSound.RoundBegin:
                sp_roundbegin?.Play();
                break;

            case GSound.RoundEnd:
                sp_roundend?.Play();
                break;
            }
        }
Esempio n. 34
0
 public void PlaySuccessSound()
 {
     if (App.Settings.PlaySuccessSound)
     {
         try
         {
             if (successSound == null)
             {
                 string soundFile = Path.Combine(App.AppDir, "Success.wav");
                 if (File.Exists(soundFile))
                 {
                     successSound = new System.Media.SoundPlayer(soundFile);
                     successSound.Load();
                 }
             }
             successSound?.Play();
         }
         catch
         {
         }
     }
 }
Esempio n. 35
0
 private void FormAbout_Activated(object sender, EventArgs e)
 {
     startMusic.Play();
 }
Esempio n. 36
0
 public static void PlayManea(string manelar)
 {
     player?.Stop();
     player = new System.Media.SoundPlayer($"../../{manelar}.wav");
     player?.Play();
 }
Esempio n. 37
0
 private void c_ding_SelectedIndexChanged(object sender, EventArgs e)
 {
     System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"Counter/" + c_ding.Text + ".wav");
     player.Play();
 }
Esempio n. 38
0
        private void btnGissa(object sender, EventArgs e)
        {
            Button val = sender as Button;

            val.Enabled = false;
            if (nuvarandeOrd.Contains(val.Text))
            {
                char[] temp         = kopiaOrd.ToCharArray();
                char[] hitta        = nuvarandeOrd.ToCharArray();
                char   gissaBokstav = val.Text.ElementAt(0);
                for (int i = 0; i < hitta.Length; i++)
                {
                    if (hitta[i] == gissaBokstav)
                    {
                        temp[i] = gissaBokstav;
                    }
                }
                kopiaOrd = new string(temp);
                visaKopia();
            }
            else
            {
                felGissningar++;
                gissningar--;
                lblGissningar.Text = gissningar.ToString();
            }

            if (felGissningar < 8)
            {
                if (standardSkin)
                {
                    pbHänga.Image = liv[felGissningar];
                }
                else if (standardSkin == false)
                {
                    pbHänga.Image = liv_skin_andjen[felGissningar];
                }
            }
            else
            {
                lblOrdet.Text = "Gubben är hängd!";
                tbxTidigare.AppendText(nuvarandeOrd.ToString() + " " + "- Förlust" + "\n");
                gbxKnappar.Enabled = false;
                btnOmstart.Enabled = true;
                antalSpel++;
                btnExtraLiv.Enabled = true;
                btnLedtråd.Enabled  = false;
                if (winningStreak >= 2)
                {
                    System.Media.SoundPlayer comboBreaker = new System.Media.SoundPlayer(Properties.Resources.Combo_breaker);
                    comboBreaker.Play();
                    winningStreak = 0;
                }
                else
                {
                    winningStreak = 0;
                }
            }
            if (kopiaOrd.Equals(nuvarandeOrd))
            {
                lblOrdet.Text      = "Du gissade rätt!";
                gbxKnappar.Enabled = false;
                tbxTidigare.AppendText(nuvarandeOrd.ToString() + " " + "- Vinst" + "\n");
                btnOmstart.Enabled = true;
                btnLedtråd.Enabled = false;
                antalSpel++;
                vinster++;
                if (winningStreak == 2)
                {
                    System.Media.SoundPlayer hattrickSound = new System.Media.SoundPlayer(Properties.Resources.Hattrick);
                    hattrickSound.Play();
                }
                else
                {
                    winningStreak++;
                }
                if (lvl1)
                {
                    credits++;
                    lblCredits.Text = credits.ToString();
                }
                else if (lvl2)
                {
                    credits         = credits + 2;
                    lblCredits.Text = credits.ToString();
                }
                else if (lvl3)
                {
                    credits         = credits + 3;
                    lblCredits.Text = credits.ToString();
                }
            }
        }
Esempio n. 39
0
        static void Main(string[] args)
        {
            System.Media.SoundPlayer move     = new System.Media.SoundPlayer(@"C:\Users\User\Desktop\Snake\Snake\sound\move.wav");
            System.Media.SoundPlayer eat      = new System.Media.SoundPlayer(@"C:\Users\User\Desktop\Snake\Snake\sound\eat.wav");
            System.Media.SoundPlayer gameover = new System.Media.SoundPlayer(@"C:\Users\User\Desktop\Snake\Snake\sound\gameover.wav");
            System.Media.SoundPlayer crash    = new System.Media.SoundPlayer(@"C:\Users\User\Desktop\Snake\Snake\sound\crash.wav");
            byte   right             = 0;
            byte   left              = 1;
            byte   down              = 2;
            byte   up                = 3;
            int    lastFoodTime      = 0;
            int    foodDissapearTime = 12000;
            int    negativePoints    = 0;
            double sleepTime         = 100;
            int    direction         = right; // To make the snake go to the right when the program starts

            Random randomNumbersGenerator = new Random();

            Console.BufferHeight = Console.WindowHeight;
            lastFoodTime         = Environment.TickCount;

            // Make sure the snake spawn with just 3 "*"s and spawn it on the top left of the screen

            Queue <Position> snakeElements = new Queue <Position>();

            for (int i = 0; i <= 3; i++) //spawn snake body
            {
                snakeElements.Enqueue(new Position(0, i));
            }

            // Spawn the first 5 obstacles in the game

            List <Position> obstacles = new List <Position>() //spawn the first obstacles
            {
                new Position(randomNumbersGenerator.Next(0, Console.WindowHeight),
                             randomNumbersGenerator.Next(0, Console.WindowWidth)),
                new Position(randomNumbersGenerator.Next(0, Console.WindowHeight),
                             randomNumbersGenerator.Next(0, Console.WindowWidth)),
                new Position(randomNumbersGenerator.Next(0, Console.WindowHeight),
                             randomNumbersGenerator.Next(0, Console.WindowWidth)),
                new Position(randomNumbersGenerator.Next(0, Console.WindowHeight),
                             randomNumbersGenerator.Next(0, Console.WindowWidth)),
                new Position(randomNumbersGenerator.Next(0, Console.WindowHeight),
                             randomNumbersGenerator.Next(0, Console.WindowWidth)),
            };

            foreach (Position obstacle in obstacles) //write obstacle as "=" on declared position
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.SetCursorPosition(obstacle.y, obstacle.x);
                Console.Write("=");
            }

            //Food Creation

            Position food;

            do //randomize where the food spawns
            {
                food = new Position(randomNumbersGenerator.Next(0, Console.WindowHeight),
                                    randomNumbersGenerator.Next(0, Console.WindowWidth));
            }while (snakeElements.Contains(food) || obstacles.Contains(food)); //to make sure that food doesnt spawn on both snake and obstacles


            //Movement implementation

            Position[] directions = new Position[]
            {
                new Position(0, 1),  // right
                new Position(0, -1), // left
                new Position(1, 0),  // down
                new Position(-1, 0), // up
            };

            while (true) //read the direction of arrow key which user inputted
            {
                negativePoints++;

                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo userInput = Console.ReadKey();
                    if (userInput.Key == ConsoleKey.LeftArrow)
                    {
                        if (direction != right)
                        {
                            direction = left;
                        }
                        move.Play();
                    }
                    if (userInput.Key == ConsoleKey.RightArrow)
                    {
                        if (direction != left)
                        {
                            direction = right;
                        }
                        move.Play();
                    }
                    if (userInput.Key == ConsoleKey.UpArrow)
                    {
                        if (direction != down)
                        {
                            direction = up;
                        }
                        move.Play();
                    }
                    if (userInput.Key == ConsoleKey.DownArrow)
                    {
                        if (direction != up)
                        {
                            direction = down;
                        }
                        move.Play();
                    }
                }


                //Creating the snake:

                Position snakeHead     = snakeElements.Last();  //make sure the head of the snake is spawned at the end of the "*" position
                Position nextDirection = directions[direction]; //initialize which direction is inputted

                Position snakeNewHead = new Position(snakeHead.x + nextDirection.x,
                                                     snakeHead.y + nextDirection.y); //snakehead will move to the same direction to which the user inputted

                // make sure the snake wont be able to go outside the screen
                if (snakeNewHead.y < 0)
                {
                    snakeNewHead.y = Console.WindowWidth - 1;
                }
                if (snakeNewHead.x < 0)
                {
                    snakeNewHead.x = Console.WindowHeight - 1;
                }
                if (snakeNewHead.x >= Console.WindowHeight)
                {
                    snakeNewHead.x = 0;
                }
                if (snakeNewHead.y >= Console.WindowWidth)
                {
                    snakeNewHead.y = 0;
                }

                foreach (Position position in snakeElements) //writes the body of the snake as "*" on declared position
                {
                    Console.SetCursorPosition(position.y, position.x);
                    Console.ForegroundColor = ConsoleColor.DarkGray;
                    Console.Write("*");
                }

                int userPoints = (snakeElements.Count - 4) * 100;

                // Show and update the score of the player

                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.SetCursorPosition(110, 0);
                Console.Write("Score: {0}", userPoints);

                // the game will be over when the snake hits it body or the obstacles

                if (snakeElements.Contains(snakeNewHead) || obstacles.Contains(snakeNewHead))
                {
                    gameover.Play();

                    Console.SetCursorPosition(50, 6);

                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Game over!");
                    //if (userPoints < 0) userPoints = 0;

                    Console.SetCursorPosition(45, 7);
                    Console.WriteLine("Your points are: {0}", userPoints);

                    Console.SetCursorPosition(35, 8);
                    Console.WriteLine("Please press the ENTER key to exit the game.");

                    string nametext = Console.ReadLine();

                    using (System.IO.StreamWriter file =
                               new System.IO.StreamWriter(@"C:\Users\joe_y\Desktop\Snaketest\score.txt", true))
                    {
                        file.WriteLine(nametext + " - " + userPoints.ToString());
                    }
                    Console.WriteLine("Please press the ENTER key to exit the game."); //true here mean we won't output the key to the console, just cleaner in my opinion.

                    ConsoleKeyInfo keyInfo = Console.ReadKey(true);
                    if (keyInfo.Key == ConsoleKey.Enter)
                    {
                        return;
                    }
                }


                // The game will be over and user will win if they reached 1000 points

                if (userPoints == 1000)
                {
                    Console.SetCursorPosition(0, 0);
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("Congrats! You've won the game!");
                    Console.WriteLine("Your points are: {0}", userPoints);
                    int loopcount = 0;
                    while (Console.ReadKey().Key != ConsoleKey.Enter)
                    {
                        if (Console.ReadKey().Key == ConsoleKey.Enter)
                        {
                            return;
                        }
                        loopcount = +1;
                    }
                }

                // writes the head of the snake as ">","<","^","v" to the position it is declared
                snakeElements.Enqueue(snakeNewHead);
                Console.SetCursorPosition(snakeNewHead.y, snakeNewHead.x);
                Console.ForegroundColor = ConsoleColor.Gray;
                if (direction == right)
                {
                    Console.Write(">");
                }
                if (direction == left)
                {
                    Console.Write("<");
                }
                if (direction == up)
                {
                    Console.Write("^");
                }
                if (direction == down)
                {
                    Console.Write("v");
                }


                //What will happened if the snake got fed:
                if (snakeNewHead.y == food.y && snakeNewHead.x == food.x)
                {
                    // Things that will be happening with the FOOD once it got ate by the snake
                    do
                    {
                        food = new Position(randomNumbersGenerator.Next(0, Console.WindowHeight), //randomize the new position of the food
                                            randomNumbersGenerator.Next(0, Console.WindowWidth));
                    }while (snakeElements.Contains(food) || obstacles.Contains(food));            //writes "@" to indicate food to the designated position it randomized
                    eat.Play();
                    lastFoodTime = Environment.TickCount;
                    sleepTime--;

                    // Things that will be happening with the OBSTACLE once the FOOD got ate by the snake

                    Position obstacle = new Position(); // randomize the position of the obstacles
                    do
                    {
                        obstacle = new Position(randomNumbersGenerator.Next(0, Console.WindowHeight),
                                                randomNumbersGenerator.Next(0, Console.WindowWidth));
                    }while (snakeElements.Contains(obstacle) ||
                            obstacles.Contains(obstacle) ||
                            (food.x != obstacle.x && food.y != obstacle.y));
                    obstacles.Add(obstacle);
                    Console.SetCursorPosition(obstacle.y, obstacle.x);
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.Write("=");
                }
                else
                {
                    // moving...
                    Position last = snakeElements.Dequeue(); // basically moving the snake and delete the last "body part" of the snake to maintain the length of the snake
                    Console.SetCursorPosition(last.y, last.x);
                    Console.Write(" ");
                }


                // Initialize the time taken for the food to spawn if the snake doesn't eat it

                if (Environment.TickCount - lastFoodTime >= foodDissapearTime)
                {
                    negativePoints = negativePoints + 50;
                    Console.SetCursorPosition(food.y, food.x);
                    Console.Write(" ");
                    do
                    {
                        food = new Position(randomNumbersGenerator.Next(0, Console.WindowHeight),
                                            randomNumbersGenerator.Next(0, Console.WindowWidth));
                    }while (snakeElements.Contains(food) || obstacles.Contains(food));
                    lastFoodTime = Environment.TickCount;
                }

                Console.SetCursorPosition(food.y, food.x);
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.Write("@");

                sleepTime -= 0.01;

                Thread.Sleep((int)sleepTime);
            }
        }
Esempio n. 40
0
        private void timer_Tick(object sender, EventArgs e)
        {
            PowerStatus powerStatus = SystemInformation.PowerStatus;

            batteryPercentage   = (powerStatus.BatteryLifePercent * 100).ToString();
            batteryChargeStatus = (powerStatus.BatteryChargeStatus).ToString();
            powerLineStatus     = (powerStatus.PowerLineStatus).ToString();

            Color whiteColor = Color.White;
            Color greenColor = System.Drawing.ColorTranslator.FromHtml("#7CFC00");
            Color redColor   = Color.Red;

            Color color = whiteColor;

            if (powerLineStatus.ToLower() == "online")
            {
                if (Int32.Parse(batteryPercentage) >= 80)
                {
                    TimeSpan duration = DateTime.Now - lastExecutedTime;

                    if (duration.TotalMinutes >= 5)
                    {
                        System.Media.SoundPlayer player = new System.Media.SoundPlayer(ConfigurationManager.AppSettings["HighBatterySound"]);
                        player.Play();
                        lastExecutedTime = DateTime.Now;
                    }
                }
                color = greenColor;
            }
            else if (batteryChargeStatus.ToString().ToLower().Contains("not charging"))
            {
                //Should use relative path or through resources.
                System.Media.SoundPlayer player = new System.Media.SoundPlayer(ConfigurationManager.AppSettings["LowBatterySound"]);
                player.Play();
            }
            else
            {
                if (Int32.Parse(batteryPercentage) <= 30)
                {
                    TimeSpan duration = DateTime.Now - lastExecutedTime;

                    if (duration.TotalMinutes >= 5)
                    {
                        //Should use relative path or through resources.
                        System.Media.SoundPlayer player = new System.Media.SoundPlayer(ConfigurationManager.AppSettings["LowBatterySound"]);
                        player.Play();
                        lastExecutedTime = DateTime.Now;
                    }
                    color = redColor;
                }
                else
                {
                    color = whiteColor;
                }
            }

            using (Bitmap bitmap = new Bitmap(DrawText(batteryPercentage, new Font(iconFont, iconFontSize, FontStyle.Bold), color, Color.Transparent)))
            {
                System.IntPtr intPtr = bitmap.GetHicon();
                try
                {
                    using (Icon icon = Icon.FromHandle(intPtr))
                    {
                        notifyIcon.Icon = icon;
                        notifyIcon.Text = batteryPercentage + "%";
                    }
                }
                finally
                {
                    DestroyIcon(intPtr);
                }
            }
        }
Esempio n. 41
0
        public bool CheckObject(Object selObject)
        {
            if (DebugCheck(3))
            {
                System.Media.SoundPlayer player = new System.Media.SoundPlayer(resmgr.GetStream("fgth_welcome", ci));
                player.Play();
            }

            // selObject=AppointmentItem => Kalenderliste + Doppel-klick auf Kalendereinträge
            // selObject=MeetingItem => Meetings in Mailliste + Doppel-klick auf Mails

            /*
             * The AppointmentItem object represents a meeting, a one-time appointment, or a recurring appointment or meeting in the Calendar folder.
             * The AppointmentItem object includes methods that perform actions such as responding to or forwarding meeting requests,
             * and properties that specify meeting details such as the location and time.
             * */

            if (selObject is MeetingItem)
            {
                DPrint(I18n("RECOGNIZED") + " - MeetingItem", 2);
                selObject = (selObject as MeetingItem).GetAssociatedAppointment(false);
            }

            if (!(selObject is AppointmentItem) || (selObject as AppointmentItem) == null || (selObject as AppointmentItem).EntryID == null)
            {
                if (selObject == null)
                {
                    DPrint("selObject " + I18n("IS_NULL"), 0);
                }
                return(false);
            }
            // https://docs.microsoft.com/de-de/office/vba/api/outlook.appointmentItem#properties
            AppointmentItem apptItem = (selObject as AppointmentItem);
            // https://docs.microsoft.com/de-de/office/vba/api/outlook.appointmentitem.meetingstatus
            bool isMeeting = (MeetingStatusToInt(apptItem.MeetingStatus) != 0);

            DPrint(I18n("RECOGNIZED") + " - AppointmentItem: isMeeting=" + isMeeting.ToString(), 2);

            // https://docs.microsoft.com/de-de/office/vba/api/outlook.appointmentitem.organizer
            string Organizer_Name;
            string Organizer_Full = null;

            if (apptItem.Organizer == null && MeetingStatusToInt(apptItem.MeetingStatus) == 1)  // my own non-sended meeting, in this case GetOrganizer() is obsolete.
            {
                Organizer_Name = apptItem.SendUsingAccount.UserName;
                DPrint("apptItem.SendUsingAccount.DisplayName=\"" + apptItem.SendUsingAccount.DisplayName + "\"", 2);
            }
            else
            {
                // https://docs.microsoft.com/de-de/office/vba/api/outlook.appointmentitem.getorganizer
                string[] result = AdressEntryNameExtract(apptItem.GetOrganizer());
                if (result != null)
                {
                    Organizer_Name = result[0];
                    Organizer_Full = result[1];
                }
                else
                {
                    Organizer_Name = apptItem.Organizer;
                }
            }
            DPrint("apptItem.MeetingStatus=\"" + apptItem.MeetingStatus + "\"", 2);
            if (apptItem.GetOrganizer().Name != apptItem.Organizer)
            {
                DPrint("DIFF: apptItem.GetOrganizer().Name=\"" + apptItem.GetOrganizer().Name + "\" / apptItem.Organizer=\"" + apptItem.Organizer + "\"", 0);
            }
            Organizer_Name = Organizer_Name ?? "[" + I18n("ORGANIZER") + " " + I18n("IS_EMPTY") + "]";
            Organizer_Full = Organizer_Full ?? Organizer_Name;

            // https://docs.microsoft.com/de-de/office/vba/api/outlook.appointmentitem.subject
            string Subject = apptItem.Subject;

            // https://docs.microsoft.com/de-de/office/vba/api/outlook.appointmentItem.recipients
            string[] output = Recipients(apptItem.Recipients, (apptItem.GetOrganizer() != null ? apptItem.GetOrganizer().ID : ""));
            //string[] output = Recipients(apptItem.Recipients, "");
            // TODO testing is this without organizer?? testing with somebody
            string RequiredAttendees_Names = output[0];
            string OptionalAttendees_Names = output[1];
            string RequiredAttendees_Full  = output[2];
            string OptionalAttendees_Full  = output[3];
            bool   Acceptable = MeetingStatusToInt(apptItem.MeetingStatus) == 3;
            int    Importance = MessgageImportanceToInt(apptItem.Importance);

            Subject = Subject ?? "[" + I18n("SUBJECT") + " " + I18n("IS_EMPTY") + "]";

            SetElements(new string[] { Subject, Organizer_Name, RequiredAttendees_Names, OptionalAttendees_Names }, 0);
            SetElements(new string[] { I18n("SUBJECT"), I18n("ORGANIZER"), I18n("REQUIRED_ATTENDEES"), I18n("OPTIONAL_ATTENDEES") }, 1);
            SetElements(new string[] { Subject, Organizer_Full, RequiredAttendees_Full, OptionalAttendees_Full }, 2);
            // https://docs.microsoft.com/de-de/office/vba/api/outlook.meetingitem.importance
            CheckImage((System.Drawing.Bitmap)resmgr.GetObject("important", ci), 0, Importance == 2);
            SetElement(Acceptable && setting.AcceptButton ? I18n("ACCEPT") : null, 4, 0);
            SetElement(Acceptable && setting.AcceptButton ? I18n("ACCEPT") : null, 4, 1);
            SetElement(Acceptable && setting.AcceptButton ? I18n("ACCEPT") : null, 4, 2);
            SetElement(Acceptable && setting.AcceptButton ? apptItem : null, 4);
            return(true);
        }
Esempio n. 42
0
 private void FinishLabel_MouseEnter(object sender, EventArgs e)
 {
     finishSoundPlayer.Play();
     MessageBox.Show("Congratualations!"); // once teh mouse enters the finish label the message box will pop up
     Close();
 }
Esempio n. 43
0
 private void playSound(string path)
 {
     System.Media.SoundPlayer player = new System.Media.SoundPlayer(@path);
     player.Play();
 }
Esempio n. 44
0
        static int playGame()
        {
            int callCounter        = 1;
            int askAudienceCounter = 1;
            int halfHalfCounter    = 1;

            System.Media.SoundPlayer playerBackground = play_background_sound();
            List <Question>          questions        = loadQuestions();

            Console.Clear();
            Random rnd              = new Random();
            int    amountWon        = 0;
            bool   gameOn           = true;
            int    counterQuestions = 0;
            string dateToday        = DateTime.Today.ToString("dd-MM-yyyy");

            Console.WriteLine("Type in your name:");
            string playerName = Console.ReadLine();

            Console.WriteLine("Type in your surname:");
            string playerSurname  = Console.ReadLine();
            int    questionNumber = 0;

            int[] questionNumberCheck = new int[16];
            bool  questionOK;

            Console.Clear();
            for (int i = 1; i < 16; i++)
            {
                if (gameOn == true)
                {
                    do
                    {
                        questionOK = true;
                        if (i < 5)
                        {
                            questionNumber = rnd.Next(1, 9);
                        }
                        if (i < 7 && i > 4)
                        {
                            questionNumber = rnd.Next(9, 13);
                        }
                        if (i < 9 && i > 6)
                        {
                            questionNumber = rnd.Next(13, 17);
                        }
                        if (i < 11 && i > 8)
                        {
                            questionNumber = rnd.Next(17, 21);
                        }
                        if (i < 13 && i > 10)
                        {
                            questionNumber = rnd.Next(21, 24);
                        }
                        if (i < 15 && i > 12)
                        {
                            questionNumber = rnd.Next(24, 29);
                        }
                        if (i == 15)
                        {
                            questionNumber = rnd.Next(29, 31);
                        }
                        for (int q = 0; q < 15; q++)
                        {
                            if (questionNumberCheck[q] == questionNumber)
                            {
                                questionOK = false;
                            }
                        }
                    } while (questionOK == false);
                    stop_background_sound(playerBackground);
                    System.Media.SoundPlayer player1 = new System.Media.SoundPlayer();
                    player1.SoundLocation = ("C:\\Users\\Mario\\Documents\\Visual Studio 2017\\Projects\\Millionaire\\Sounds\\questions.wav");
                    player1.Play();
                    questionNumberCheck[i] = questionNumber;
                    Console.Write("{0}. question: ", i);
                    Console.WriteLine(questions[questionNumber - 1].name);
                    Console.WriteLine();
                    Console.WriteLine();
                    Console.WriteLine("a: {0}", questions[questionNumber - 1].a);
                    Console.WriteLine();
                    Console.WriteLine("b: {0}", questions[questionNumber - 1].b);
                    Console.WriteLine();
                    Console.WriteLine("c: {0}", questions[questionNumber - 1].c);
                    Console.WriteLine();
                    Console.WriteLine("d: {0}", questions[questionNumber - 1].d);
                    Console.WriteLine();
                    Console.WriteLine();
                    Console.WriteLine("Avaliable jokers are:");
                    if (callCounter == 1)
                    {
                        Console.WriteLine("press i for Call joker");
                    }
                    if (askAudienceCounter == 1)
                    {
                        Console.WriteLine("press o for Ask audience joker");
                    }
                    if (halfHalfCounter == 1)
                    {
                        Console.WriteLine("press p for 50/50 joker");
                    }
                    Console.WriteLine();
                    Console.WriteLine("***** to quit the game press q");
                    Console.WriteLine();
                    Console.WriteLine("Your answer: ");
                    string yourAnswer = Console.ReadLine();


                    while (yourAnswer != "a" && yourAnswer != "b" && yourAnswer != "c" && yourAnswer != "d" &&
                           yourAnswer != "i" && yourAnswer != "o" && yourAnswer != "p" && yourAnswer != "q")
                    {
                        Console.Clear();
                        Console.WriteLine("Incorrect answer format. Please try again!");
                        Console.Write("{0}. question: ", i);
                        Console.WriteLine(questions[questionNumber - 1].name);
                        Console.WriteLine();
                        Console.WriteLine();
                        Console.WriteLine("a: {0}", questions[questionNumber - 1].a);
                        Console.WriteLine();
                        Console.WriteLine("b: {0}", questions[questionNumber - 1].b);
                        Console.WriteLine();
                        Console.WriteLine("c: {0}", questions[questionNumber - 1].c);
                        Console.WriteLine();
                        Console.WriteLine("d: {0}", questions[questionNumber - 1].d);
                        Console.WriteLine();
                        Console.WriteLine("Avaliable jokers are:");
                        if (callCounter == 1)
                        {
                            Console.WriteLine("press i for Call joker");
                        }
                        if (askAudienceCounter == 1)
                        {
                            Console.WriteLine("press o for Ask audience joker");
                        }
                        if (halfHalfCounter == 1)
                        {
                            Console.WriteLine("press p for 50/50 joker");
                        }
                        Console.WriteLine();
                        Console.WriteLine("***** to quit the game press q");
                        Console.WriteLine();
                        Console.WriteLine("Your answer: ");
                        yourAnswer = Console.ReadLine();
                    }

                    while (yourAnswer == "i" || yourAnswer == "o" || yourAnswer == "p")
                    {
                        if (yourAnswer == "i" && callCounter == 1)
                        {
                            string friend = getFriend();
                            callCounter++;
                            int chance = rnd.Next(1, 101);
                            if (counterQuestions < 5)
                            {
                                chance = rnd.Next(1, 55);
                            }
                            if (counterQuestions >= 5 && counterQuestions < 7)
                            {
                                chance = rnd.Next(1, 60);
                            }
                            if (counterQuestions >= 7 && counterQuestions < 9)
                            {
                                chance = rnd.Next(1, 65);
                            }
                            if (counterQuestions >= 9 && counterQuestions < 11)
                            {
                                chance = rnd.Next(1, 70);
                            }
                            if (counterQuestions >= 11 && counterQuestions < 13)
                            {
                                chance = rnd.Next(1, 75);
                            }
                            if (counterQuestions >= 13 && counterQuestions < 15)
                            {
                                chance = rnd.Next(1, 80);
                            }
                            if (counterQuestions == 15)
                            {
                                chance = rnd.Next(1, 85);
                            }

                            if (chance < 50)
                            {
                                Console.WriteLine();
                                Console.WriteLine("**CALL** {0} says the answer is: {1}", friend, questions[questionNumber - 1].correct);
                                Console.WriteLine();
                            }
                            else
                            {
                                int luck = rnd.Next(1, 4);
                                if (luck == 1)
                                {
                                    Console.WriteLine();
                                    Console.WriteLine("**CALL** {0} says the answer is: a", friend);
                                    Console.WriteLine();
                                }
                                if (luck == 2)
                                {
                                    Console.WriteLine();
                                    Console.WriteLine("**CALL** {0} says the answer is: b", friend);
                                    Console.WriteLine();
                                }
                                if (luck == 3)
                                {
                                    Console.WriteLine();
                                    Console.WriteLine("**CALL** {0} says the answer is: c", friend);
                                    Console.WriteLine();
                                }
                                if (luck == 4)
                                {
                                    Console.WriteLine();
                                    Console.WriteLine("**CALL** {0}  says the answer is: d", friend);
                                    Console.WriteLine();
                                }
                            }

                            Console.WriteLine("Your answer: ");
                            yourAnswer = Console.ReadLine();
                            while (yourAnswer != "a" && yourAnswer != "b" && yourAnswer != "c" && yourAnswer != "d" &&
                                   yourAnswer != "i" && yourAnswer != "o" && yourAnswer != "p" && yourAnswer != "q")
                            {
                                Console.WriteLine("Incorrect answer format. Please try again!");
                                Console.WriteLine("Your answer: ");
                                yourAnswer = Console.ReadLine();
                            }
                        }
                        if (yourAnswer == "o" && askAudienceCounter == 1)
                        {
                            askAudienceCounter++;
                            int chance = rnd.Next(1, 101);

                            if (counterQuestions < 5)
                            {
                                chance = rnd.Next(1, 55);
                            }
                            if (counterQuestions >= 5 && counterQuestions < 7)
                            {
                                chance = rnd.Next(1, 60);
                            }
                            if (counterQuestions >= 7 && counterQuestions < 9)
                            {
                                chance = rnd.Next(1, 65);
                            }
                            if (counterQuestions >= 9 && counterQuestions < 11)
                            {
                                chance = rnd.Next(1, 70);
                            }
                            if (counterQuestions >= 11 && counterQuestions < 13)
                            {
                                chance = rnd.Next(1, 75);
                            }
                            if (counterQuestions >= 13 && counterQuestions < 15)
                            {
                                chance = rnd.Next(1, 80);
                            }
                            if (counterQuestions == 15)
                            {
                                chance = rnd.Next(1, 85);
                            }

                            if (chance < 50)
                            {
                                Console.WriteLine();
                                Console.WriteLine("Audience says the answer is: {0}", questions[questionNumber - 1].correct);
                                Console.WriteLine();
                            }
                            else
                            {
                                int luck = rnd.Next(1, 4);
                                if (luck == 1)
                                {
                                    Console.WriteLine();
                                    Console.WriteLine("Audience says the answer is: a");
                                    Console.WriteLine();
                                }
                                if (luck == 2)
                                {
                                    Console.WriteLine();
                                    Console.WriteLine("Audience says the answer is: b");
                                    Console.WriteLine();
                                }
                                if (luck == 3)
                                {
                                    Console.WriteLine();
                                    Console.WriteLine("Audience says the answer is: c");
                                    Console.WriteLine();
                                }
                                if (luck == 4)
                                {
                                    Console.WriteLine();
                                    Console.WriteLine("Audience says the answer is: d");
                                    Console.WriteLine();
                                }
                            }

                            Console.WriteLine("Your answer: ");
                            yourAnswer = Console.ReadLine();
                            while (yourAnswer != "a" && yourAnswer != "b" && yourAnswer != "c" && yourAnswer != "d" &&
                                   yourAnswer != "i" && yourAnswer != "o" && yourAnswer != "p" && yourAnswer != "q")
                            {
                                Console.WriteLine("Incorrect answer format. Please try again!");
                                Console.WriteLine("Your answer: ");
                                yourAnswer = Console.ReadLine();
                            }
                        }
                        if (yourAnswer == "p" && halfHalfCounter == 1)
                        {
                            string firstCase  = "";
                            string secondCase = questions[questionNumber - 1].correct;
                            halfHalfCounter++;

                            int firstRand = rnd.Next(1, 3);
                            if (firstRand == 1)
                            {
                                firstCase = questions[questionNumber - 1].correct;
                                do
                                {
                                    int secondRand = rnd.Next(1, 4);
                                    if (secondRand == 1)
                                    {
                                        secondCase = ("a");
                                    }
                                    if (secondRand == 2)
                                    {
                                        secondCase = ("b");
                                    }
                                    if (secondRand == 3)
                                    {
                                        secondCase = ("c");
                                    }
                                    if (secondRand == 4)
                                    {
                                        secondCase = ("d");
                                    }
                                } while (secondCase == questions[questionNumber - 1].correct);
                            }
                            if (firstRand == 2)
                            {
                                do
                                {
                                    int secondRand = rnd.Next(1, 4);
                                    if (secondRand == 1)
                                    {
                                        firstCase = ("a");
                                    }
                                    if (secondRand == 2)
                                    {
                                        firstCase = ("b");
                                    }
                                    if (secondRand == 3)
                                    {
                                        firstCase = ("c");
                                    }
                                    if (secondRand == 4)
                                    {
                                        firstCase = ("d");
                                    }
                                } while (firstCase == questions[questionNumber - 1].correct);
                            }

                            Console.WriteLine();
                            Console.WriteLine("Correct answer is: {0} or {1}", firstCase, secondCase);
                            Console.WriteLine();
                            Console.WriteLine("Your answer: ");
                            yourAnswer = Console.ReadLine();
                            while (yourAnswer != firstCase && yourAnswer != secondCase && yourAnswer != "i" && yourAnswer != "o" && yourAnswer != "p" && yourAnswer != "q")
                            {
                                Console.WriteLine("Incorrect answer format. Please try again!");
                                Console.WriteLine("Your answer: ");
                                yourAnswer = Console.ReadLine();
                            }
                        }
                        if (yourAnswer == "p" && halfHalfCounter == 2 || yourAnswer == "o" && askAudienceCounter == 2 || yourAnswer == "i" && callCounter == 2)
                        {
                            Console.WriteLine("Incorrect answer format. Please try again!");
                            Console.WriteLine("Your answer: ");
                            yourAnswer = Console.ReadLine();
                            while (yourAnswer != "a" && yourAnswer != "b" && yourAnswer != "c" && yourAnswer != "d" &&
                                   yourAnswer != "i" && yourAnswer != "o" && yourAnswer != "p" && yourAnswer != "q")
                            {
                                Console.WriteLine("Incorrect answer format. Please try again!");
                                Console.WriteLine("Your answer: ");
                                yourAnswer = Console.ReadLine();
                            }
                        }
                    }
                    if (yourAnswer == questions[questionNumber - 1].correct)
                    {
                        System.Media.SoundPlayer playerCorrect = new System.Media.SoundPlayer();
                        playerCorrect.SoundLocation = ("C:\\Users\\Mario\\Documents\\Visual Studio 2017\\Projects\\Millionaire\\Sounds\\correct1.wav");
                        System.Media.SoundPlayer playerCorrectBig = new System.Media.SoundPlayer();
                        playerCorrectBig.SoundLocation = ("C:\\Users\\Mario\\Documents\\Visual Studio 2017\\Projects\\Millionaire\\Sounds\\correct2.wav");
                        Console.Clear();
                        player1.Stop();
                        counterQuestions += 1;
                        Console.WriteLine("CORRECT");
                        if (counterQuestions == 1)
                        {
                            playerCorrect.Play();
                            Console.WriteLine();
                            Console.WriteLine("You have won 100KN!");
                            amountWon = 100;
                            Console.WriteLine();
                            System.Threading.Thread.Sleep(5000);
                            Console.Clear();
                        }
                        if (counterQuestions == 2)
                        {
                            playerCorrect.Play();
                            Console.WriteLine();
                            Console.WriteLine("You have won 200KN!");
                            amountWon = 200;
                            Console.WriteLine();
                            System.Threading.Thread.Sleep(5000);
                            Console.Clear();
                        }
                        if (counterQuestions == 3)
                        {
                            playerCorrect.Play();
                            Console.WriteLine();
                            Console.WriteLine("You have won 300KN!");
                            amountWon = 300;
                            Console.WriteLine();
                            System.Threading.Thread.Sleep(5000);
                            Console.Clear();
                        }
                        if (counterQuestions == 4)
                        {
                            playerCorrect.Play();
                            Console.WriteLine();
                            Console.WriteLine("You have won 500KN!");
                            amountWon = 500;
                            Console.WriteLine();
                            System.Threading.Thread.Sleep(5000);
                            Console.Clear();
                        }
                        if (counterQuestions == 5)
                        {
                            playerCorrectBig.Play();
                            Console.WriteLine();
                            Console.WriteLine("YOU HAVE WON 1000KN!!!!!!!!!!!!!!!!!!!!!!!!!");
                            amountWon = 1000;
                            Console.WriteLine();
                            System.Threading.Thread.Sleep(8000);
                            Console.Clear();
                        }
                        if (counterQuestions == 6)
                        {
                            playerCorrect.Play();
                            Console.WriteLine();
                            Console.WriteLine("You have won 2000KN!");
                            amountWon = 2000;
                            Console.WriteLine();
                            System.Threading.Thread.Sleep(5000);
                            Console.Clear();
                        }
                        if (counterQuestions == 7)
                        {
                            playerCorrect.Play();
                            Console.WriteLine();
                            Console.WriteLine("You have won 4000KN!");
                            amountWon = 4000;
                            Console.WriteLine();
                            System.Threading.Thread.Sleep(5000);
                            Console.Clear();
                        }
                        if (counterQuestions == 8)
                        {
                            playerCorrect.Play();
                            Console.WriteLine();
                            Console.WriteLine("You have won 8000KN!");
                            amountWon = 8000;
                            Console.WriteLine();
                            System.Threading.Thread.Sleep(5000);
                            Console.Clear();
                        }
                        if (counterQuestions == 9)
                        {
                            playerCorrect.Play();
                            Console.WriteLine();
                            Console.WriteLine("You have won 1600KN!");
                            amountWon = 16000;
                            Console.WriteLine();
                            System.Threading.Thread.Sleep(5000);
                            Console.Clear();
                        }
                        if (counterQuestions == 10)
                        {
                            playerCorrectBig.Play();
                            Console.WriteLine();
                            Console.WriteLine("YOU HAVE WON 32000KN!!!!!!!!!!!!!!!!!!!!!!!!!");
                            amountWon = 32000;
                            Console.WriteLine();
                            System.Threading.Thread.Sleep(8000);
                            Console.Clear();
                        }
                        if (counterQuestions == 11)
                        {
                            playerCorrect.Play();
                            Console.WriteLine();
                            Console.WriteLine("You have won 64000KN!");
                            amountWon = 64000;
                            Console.WriteLine();
                            System.Threading.Thread.Sleep(5000);
                            Console.Clear();
                        }
                        if (counterQuestions == 12)
                        {
                            playerCorrect.Play();
                            Console.WriteLine();
                            Console.WriteLine("You have won 125000KN!");
                            amountWon = 125000;
                            Console.WriteLine();
                            System.Threading.Thread.Sleep(5000);
                            Console.Clear();
                        }
                        if (counterQuestions == 13)
                        {
                            playerCorrect.Play();
                            Console.WriteLine();
                            Console.WriteLine("You have won 250000KN!");
                            amountWon = 250000;
                            Console.WriteLine();
                            System.Threading.Thread.Sleep(5000);
                            Console.Clear();
                        }
                        if (counterQuestions == 14)
                        {
                            playerCorrect.Play();
                            Console.WriteLine();
                            Console.WriteLine("You have won 500000KN!");
                            amountWon = 500000;
                            Console.WriteLine();
                            System.Threading.Thread.Sleep(5000);
                            Console.Clear();
                        }
                        if (counterQuestions == 15)
                        {
                            Console.WriteLine();
                            Console.WriteLine("YOU HAVE WON 1000000KN!!!!!!!!!!!!!!!!!!!!!!!!!");
                            amountWon = 1000000;
                            Console.WriteLine();
                            playerCorrectBig.Play();
                            System.Threading.Thread.Sleep(8000);
                            Console.Clear();
                        }
                    }
                    if (yourAnswer == "q")
                    {
                        gameOn = false;
                        Console.Clear();
                        Console.WriteLine("You have quit!");
                        player1.Stop();
                        System.Media.SoundPlayer playerQuit = new System.Media.SoundPlayer();
                        playerQuit.SoundLocation = ("C:\\Users\\Mario\\Documents\\Visual Studio 2017\\Projects\\Millionaire\\Sounds\\fail.wav");
                        playerQuit.Play();
                        System.Threading.Thread.Sleep(5000);
                    }
                    if (yourAnswer != questions[questionNumber - 1].correct && yourAnswer != "q")
                    {
                        if (counterQuestions < 5)
                        {
                            amountWon = 0;
                        }
                        if (counterQuestions >= 5)
                        {
                            amountWon = 1000;
                        }
                        if (counterQuestions >= 10)
                        {
                            amountWon = 32000;
                        }
                        if (counterQuestions == 15)
                        {
                            amountWon = 1000000;
                        }
                        Console.Clear();
                        player1.Stop();
                        gameOn = false;
                        Console.WriteLine("INCORRECT");
                        System.Media.SoundPlayer playerIncorrect = new System.Media.SoundPlayer();
                        playerIncorrect.SoundLocation = ("C:\\Users\\Mario\\Documents\\Visual Studio 2017\\Projects\\Millionaire\\Sounds\\fail.wav");
                        playerIncorrect.Play();
                        System.Threading.Thread.Sleep(5000);
                    }
                }
            }

            string usedJokers = "";

            if (callCounter != 1)
            {
                usedJokers = usedJokers + " " + "Call";
            }
            if (askAudienceCounter != 1)
            {
                usedJokers = usedJokers + " " + "Ask audience";
            }
            if (halfHalfCounter != 1)
            {
                usedJokers = usedJokers + " " + "50/50";
            }

            Console.WriteLine("You have won {0} kn", amountWon);

            XmlDocument doc = new XmlDocument();

            doc.Load("C:\\Users\\Mario\\Documents\\Visual Studio 2017\\Projects\\Millionaire\\results.xml");
            XmlNode Player = doc.CreateElement("Player");
            XmlNode name   = doc.CreateElement("name");

            name.InnerText = playerName;
            Player.AppendChild(name);
            XmlNode surname = doc.CreateElement("surname");

            surname.InnerText = playerSurname;
            Player.AppendChild(surname);
            XmlNode date = doc.CreateElement("date");

            date.InnerText = dateToday;
            Player.AppendChild(date);
            XmlNode moneyWon = doc.CreateElement("moneyWon");

            moneyWon.InnerText = Convert.ToString(amountWon);
            Player.AppendChild(moneyWon);
            XmlNode jokers = doc.CreateElement("jokers");

            jokers.InnerText = usedJokers;
            Player.AppendChild(jokers);
            doc.DocumentElement.AppendChild(Player);
            doc.Save("C:\\Users\\Mario\\Documents\\Visual Studio 2017\\Projects\\Millionaire\\results.xml");


            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            System.Media.SoundPlayer background_sound = play_background_sound();
            showMenu();
            int choice = your_option();

            return(choice);
        }
Esempio n. 45
0
 public static void playTone(String toneFile)
 {
     player.SoundLocation = toneFile;
     player.Play();
 }
Esempio n. 46
0
 private void btn_sair_MouseEnter(object sender, EventArgs e)
 {
     btn_sair.BackgroundImage = sair_high;
     System.Media.SoundPlayer player = new System.Media.SoundPlayer("sys_sounds/hover.wav");
     player.Play();
 }
Esempio n. 47
0
 private void C_Sharp_1(object sender, RoutedEventArgs e)
 {
     player = new System.Media.SoundPlayer(Properties.Resources.Piano_pp_Db3);
     player.Play();
 }
Esempio n. 48
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Sound sys
            System.Media.SoundPlayer s = new System.Media.SoundPlayer();
            s.SoundLocation = "C:\\Users\\Acer\\Desktop\\New\\slow.wav";
            s.Play();

            //priceChecking

            int cocaPrice    = int.Parse(cocaprice.Text);
            int pepsiPrice   = int.Parse(pepsiprice.Text);
            int monsterPrice = int.Parse(monsterprice.Text);

            int textBox = int.Parse(textBox1.Text);

            string price = textBox1.Text;

            //cocaPrice check and output

            if (cocaButtonWasClicked == true)
            {
                if (textBox >= cocaPrice)
                {
                    int aa = textBox - cocaPrice;
                    textBox1.Text        = aa.ToString();
                    count                = aa;
                    cocaSlide.Visible    = true;
                    pepsiSlide.Visible   = false;
                    monsterSlide.Visible = false;
                }
            }

            //pepsiPrice Check and output

            if (pepsiButtonWasClicked == true)
            {
                if (textBox >= pepsiPrice)
                {
                    int aa = textBox - pepsiPrice;
                    textBox1.Text        = aa.ToString();
                    count                = aa;
                    pepsiSlide.Visible   = true;
                    monsterSlide.Visible = false;
                    cocaSlide.Visible    = false;
                }
            }

            //monsterPriceCheck&Output
            if (monsterButtonWasClicked == true)
            {
                if (textBox >= monsterPrice)
                {
                    int aa = textBox - monsterPrice;
                    textBox1.Text        = aa.ToString();
                    count                = aa;
                    monsterSlide.Visible = true;
                    pepsiSlide.Visible   = false;
                    cocaSlide.Visible    = false;
                }
            }
        }
        // Game timer that determines player and enemy movement and collisions
        private void Timer_Tick(object sender, System.EventArgs e)
        {
            // If player is not on a platform, apply jumpspeed
            if (!onPlatform)
            {
                player.Top += jumpSpeed;
            }

            // Prevents infinite jump
            if (jumping && force < 0)
            {
                jumping = false;
            }

            // Left and right movements
            if (goLeft)
            {
                player.Left -= 6;
            }
            else if (goRight)
            {
                player.Left += 6;
            }

            // When jumping, apply negative jumpspeed and force
            if (jumping)
            {
                jumpSpeed = -1 * JS;
                force    -= 1;
            }
            // Else, apply positive jumpspeed
            else
            {
                jumpSpeed = JS;
            }

            // Collision Checks
            foreach (Control x in this.Controls)
            {
                // Intersection Checks
                if (player.Bounds.IntersectsWith(x.Bounds))
                {
                    // Player cannot go through floor
                    if (x.Tag.Equals("floor") && !jumping)
                    {
                        force           = 8;
                        player.Top      = x.Top - player.Height;
                        onPlatform      = true;
                        currentPlatform = (Platform)x;

                        // When player lands on floor, switch sprite from jumping to
                        // appropriate image
                        if (goLeft)
                        {
                            player.Image = Image.FromFile("run_left.gif");
                        }
                        else if (goRight)
                        {
                            player.Image = Image.FromFile("run_right.gif");
                        }
                        else
                        {
                            if (lookLeft)
                            {
                                player.Image = Image.FromFile("stand_left.png");
                            }
                            else
                            {
                                player.Image = Image.FromFile("stand_right.png");
                            }
                        }
                    }
                    // Player cannot go through edges
                    if (x.Tag.Equals("edge"))
                    {
                        if (goLeft)
                        {
                            player.Left = x.Left + player.Width;
                        }
                        if (goRight)
                        {
                            player.Left = x.Left - player.Width;
                        }
                    }

                    // Player collects a coin
                    if (x.Tag.Equals("coin"))
                    {
                        UpdateScore(10);
                        x.Dispose();
                        sfxPlayer = new System.Media.SoundPlayer("Coin.wav");
                        sfxPlayer.Play();
                    }
                    // Player collects a heart
                    if (x.Tag.Equals("heart"))
                    {
                        UpdateLives(1);
                        x.Dispose();
                        sfxPlayer = new System.Media.SoundPlayer("getItem.wav");
                        sfxPlayer.Play();
                    }
                    // Player reaches the exit
                    if (x.Tag.Equals("exit"))
                    {
                        UpdateScore(50);
                        timer.Stop();
                        Next();
                    }
                } // End of Intersection Checks

                // Player landing on platform check
                if (x.Tag.Equals("platform") && player.Right > x.Left && player.Left < x.Right &&
                    (player.Bottom <= x.Top && player.Bottom >= x.Top - 20) && !jumping)
                {
                    force           = 8;
                    player.Top      = x.Top - player.Height;
                    onPlatform      = true;
                    currentPlatform = (Platform)x;

                    // When player lands on platform, switch sprite from jumping to
                    // appropriate image
                    if (goLeft)
                    {
                        player.Image = Image.FromFile("run_left.gif");
                    }
                    else if (goRight)
                    {
                        player.Image = Image.FromFile("run_right.gif");
                    }
                    else
                    {
                        if (lookLeft)
                        {
                            player.Image = Image.FromFile("stand_left.png");
                        }
                        else
                        {
                            player.Image = Image.FromFile("stand_right.png");
                        }
                    }
                }

                // Player landing on a turtle of barrel, or getting hit by them
                if ((x.Tag.Equals("turtle") || x.Tag.Equals("barrel")))
                {
                    // If player land on a turtle or barrel, kill it and add to score
                    if (player.Right > x.Left && player.Left < x.Right &&
                        (player.Bottom < x.Top && player.Bottom >= x.Top - 20) && !jumping)
                    {
                        if (x.Tag.Equals("turtle"))
                        {
                            UpdateScore(15);
                            sfxPlayer = new System.Media.SoundPlayer("turtledie.wav");
                            sfxPlayer.Play();
                        }
                        else
                        {
                            UpdateScore(20);
                        }
                        x.Dispose();
                    }

                    // Else player is attacked by turtle or barrel, reset to start and lose a life
                    else if (player.Bounds.IntersectsWith(x.Bounds))
                    {
                        player.Left  = 60;
                        player.Top   = 600;
                        player.Image = Image.FromFile("death.png");
                        onPlatform   = false;
                        UpdateScore(-10);
                        UpdateLives(-1);
                        if (GetLives() == 0)
                        {
                            End();
                        }
                    }
                }

                // Player is attacked by a ghost
                if (x.Tag.Equals("ghost") && player.Bounds.IntersectsWith(x.Bounds))
                {
                    player.Left  = 60;
                    player.Top   = 600;
                    player.Image = Image.FromFile("death.png");
                    onPlatform   = false;
                    UpdateScore(-10);
                    UpdateLives(-1);
                    if (GetLives() == 0)
                    {
                        End();
                    }
                }

                // Update Enemy movements
                if (x is Enemy)
                {
                    Enemy temp = (Enemy)x;
                    temp.Movement();
                }

                // Barrel Gravity
                if (x.Tag.Equals("barrel"))
                {
                    Barrel temp = (Barrel)x;
                    foreach (Control y in this.Controls)
                    {
                        // If barrel is not on a platform or another barrel
                        if (!temp.OnPlatform && !(y is Barrel))
                        {
                            // If barrel intersects with a platform or floo,
                            // set it as the platform that it is on.
                            if ((y.Tag.Equals("platform") || y.Tag.Equals("floor")) &&
                                temp.Bounds.IntersectsWith(y.Bounds))
                            {
                                Platform temp2 = (Platform)y;
                                temp.Platform = temp2;
                            }
                        }

                        // Reverse the barrel direction if it hits an edge
                        if (y.Tag.Equals("edge") && temp.Bounds.IntersectsWith(y.Bounds))
                        {
                            if (temp.GoingLeft)
                            {
                                temp.GoingLeft = false;
                            }
                            else
                            {
                                temp.GoingLeft = true;
                            }
                        }
                    }
                } // End of Barrel Gravity
            }     // End of Collision Checks

            // If a player is on a platform and moves off of the platform, they begin to fall
            if (currentPlatform != null)
            {
                // Leave from the left
                if (goLeft && player.Right < currentPlatform.Left)
                {
                    onPlatform      = false;
                    currentPlatform = null;
                }

                // Leave from the right
                if (goRight && player.Left > currentPlatform.Right)
                {
                    onPlatform      = false;
                    currentPlatform = null;
                }
            }
        }
Esempio n. 50
0
 /// <summary>
 /// 播放录音
 /// </summary>
 /// <param name="recordURL">音频地址</param>
 public void RecorPlay(System.Media.SoundPlayer sp)
 {
     sp.Play();
     //sp.sto
 }
Esempio n. 51
0
        private void tmrCar_Tick(object sender, EventArgs e)
        {
            Image  carImage;
            int    i, c, r;
            String s;

            deliveryGrid[carC, carR].Image = null;
            // move horizontally first
            if (deltaC != 0)
            {
                mileage++;
                carImage = picHCar.Image;
                carC    += Math.Sign(deltaC);
                deltaC   = deliveryC - carC;
            }
            else
            {
                mileage++;
                carImage = picVCar.Image;
                carR    += Math.Sign(deltaR);
                deltaR   = deliveryR - carR;
            }
            deliveryGrid[carC, carR].Image = carImage;
            if (carC == deliveryC && carR == deliveryR)
            {
                beepSound.Play();
                tmrCar.Enabled = false;
                if (carC == pizzaC && carR == pizzaR)
                {
                    lblMessage.Text = "Car at Pizza Parlor:\r\n" +
                                      Display(carC, carR);
                    deliveryGrid[carC, carR].Image = null;

                    pizzasInCar        = 0;
                    lblInCar.Text      = "0";
                    btnLoadCar.Enabled = true;
                }
                else
                {
                    lblMessage.Text = "Car at " + Display(carC,
                                                          carR);
                    // check delivery status
                    if (pizzas[deliveryC, deliveryR] == 0)
                    {
                        lblMessage.Text += "\r\nNo Pizza Wanted";
                    }
                    else
                    {
                        if (pizzas[deliveryC, deliveryR] >
                            pizzasInCar)
                        {
                            lblMessage.Text += "\r\nNot Enough Pizzas";
                        }
                        else
                        {
                            lblMessage.Text += "\r\nDelivered " +
                                               pizzas[deliveryC, deliveryR].ToString() + " Pizza";
                            if (pizzas[deliveryC, deliveryR] > 1)
                            {
                                lblMessage.Text += "s";
                            }
                            // see if on-time
                            if ((clockMinute + 60 * clockHour) -
                                pizzaTime[deliveryC, deliveryR] <= orderLateTime)
                            {
                                lblMessage.Text += ": On-Time";
                                totalSales      += pizzas[deliveryC, deliveryR] * netSoldPizza;
                                pizzasOnTime    += pizzas[deliveryC, deliveryR];
                            }
                            else
                            {
                                lblMessage.Text += ": Late!";
                                totalSales      += pizzas[deliveryC, deliveryR] * netLatePizza;
                                pizzasLate      += pizzas[deliveryC, deliveryR];
                            }
                            lblSales.Text = "$" +
                                            totalSales.ToString();
                            pizzasInCar  -= pizzas[deliveryC, deliveryR];
                            lblInCar.Text =
                                pizzasInCar.ToString();
                            pizzas[deliveryC, deliveryR] = 0;
                            deliveryGrid[deliveryC, deliveryR].BackColor = Color.White;
                            deliveryGrid[deliveryC, deliveryR].Text      = "";
                            // remove from list
                            for (i = 0; i < lstOrders.Items.Count;
                                 i++)
                            {
                                s = lstOrders.Items[i].ToString();
                                c = ((int)s[6]) - 64;
                                r =
                                    Convert.ToInt32(s.Substring(8, 2));
                                if (c == deliveryC && r ==
                                    deliveryR)
                                {
                                    break;
                                }
                            }
                            lstOrders.Items.RemoveAt(i);
                        }
                    }
                }
            }
        }
        private void case4_Tick(object sender, EventArgs e)
        {
            countC4++;

            //airplane 1 lands on runway
            if (airplane1.Location.Y == 150 && !flippedA1C4)
            {
                airplane1.Image.RotateFlip(RotateFlipType.Rotate270FlipNone);
                flippedA1C4     = true;
                airplane1.Left -= 1;
                labelair1.Left -= 1;
            }
            else if (airplane1.Location.Y > 150)
            {
                airplane1.Top -= 1;
                labelair1.Top -= 1;
            }
            else if (airplane1.Visible)
            {
                airplane1.Left -= 1;
                labelair1.Left -= 1;
                if (airplane1.Location.X == 225)
                {
                    airplane1.Visible = false;
                    airplane2.Visible = false;
                    airplane3.Visible = false;
                    labelair1.Visible = false;
                    labelair2.Visible = false;
                    labelair3.Visible = false;

                    if (!changedCountA1C4)
                    {
                        int currentAirplanes = Convert.ToInt32(aircraftCount.Text);
                        aircraftCount.Text = Convert.ToString(currentAirplanes - 1);
                        changedCountA1C4   = true;
                    }

                    //reset planes to starting directions (a1-up, a2-up, a3-up)
                    if (flippedA1C4)
                    {
                        airplane1.Image.RotateFlip(RotateFlipType.Rotate90FlipNone);
                        flippedA1C4 = false;
                    }

                    if (flippedA2C4)
                    {
                        airplane2.Image.RotateFlip(RotateFlipType.Rotate90FlipNone);
                        flippedA2C4 = false;
                    }

                    if (flippedA3C4)
                    {
                        airplane3.Image.RotateFlip(RotateFlipType.Rotate270FlipNone);
                        flippedA3C4 = false;
                    }
                    warning = false;
                    warningLabel.Visible   = false;
                    emergency              = false;
                    emergencyLabel.Visible = false;

                    t_case4.Dispose(); //stop timer 4
                }
            }
            //airplane 2 collides with airplane 3
            if (airplane2.Location.X == 260)
            {
                warning         = true;
                airplane3.Image = Properties.Resources.airplaneRed;
                airplane3.Image.RotateFlip(RotateFlipType.Rotate90FlipNone);
                warningLabel.Visible = true;
                System.IO.Stream         warningSound2 = Properties.Resources.warning;
                System.Media.SoundPlayer player        = new System.Media.SoundPlayer(warningSound2);
                player.Play();

                airplane2.Left -= 1;
                labelair2.Left -= 1;

                if (countC4 % 15 == 0)
                {
                    int altitude = Convert.ToInt32(infoAltitude.Text);
                    infoAltitude.Text = Convert.ToString(altitude + 5);
                    int speed = Convert.ToInt32(infoSpeed.Text);
                    labelair2.Text = "DL305 MCO D \n" + " " + (altitude + 5) + " " + (speed) + " " + "270";
                    if (speed <= 247)
                    {
                        infoSpeed.Text = Convert.ToString(speed + 3);
                        labelair2.Text = "DL305 MCO D \n" + " " + (altitude) + " " + (speed + 3) + " " + "270";
                    }
                    else
                    {
                        infoSpeed.Text = "250";
                        labelair2.Text = "DL305 MCO D \n" + " " + (altitude) + "250 270";
                    }
                }
            }
            else if (airplane2.Location.X == 240)
            {
                airplane2.Left -= 1;
                labelair2.Left -= 1;

                warning = false;
                warningLabel.Visible   = false;
                emergency              = true;
                emergencyLabel.Visible = true;
                System.IO.Stream         emergeSound = Properties.Resources.emerg;
                System.Media.SoundPlayer player      = new System.Media.SoundPlayer(emergeSound);
                player.Play();
            }
            else if (airplane2.Location.X > 220)
            {
                airplane2.Left -= 1;
                labelair2.Left -= 1;

                if (countC4 % 15 == 0)
                {
                    int altitude = Convert.ToInt32(infoAltitude.Text);
                    infoAltitude.Text = Convert.ToString(altitude + 5);
                    int speed = Convert.ToInt32(infoSpeed.Text);
                    labelair2.Text = "DL305 MCO D \n" + " " + (altitude + 5) + " " + (speed) + " " + "270";
                    if (speed <= 247)
                    {
                        infoSpeed.Text = Convert.ToString(speed + 3);
                        labelair2.Text = "DL305 MCO D \n" + " " + (altitude) + " " + (speed + 3) + " " + "270";
                    }
                    else
                    {
                        infoSpeed.Text = "250";
                        labelair2.Text = "DL305 MCO D \n" + " " + (altitude) + "250 270";
                    }
                }

                if (emergency)
                {
                    if (countC4 % 2 == 0)
                    {
                        emergencyLabel.Visible = true;
                    }
                    else
                    {
                        emergencyLabel.Visible = false;
                    }
                }
            }

            //airplane 3 collides with airplane 2
            if (airplane3.Location.X < 200)
            {
                airplane3.Left += 1;
                labelair3.Left += 1;
            }
            else if (airplane3.Location.X == 200)
            {
                emergencyLabel.Visible = true;
                airplane2.Visible      = false;
                labelair2.Visible      = false;
                airplane3.Image        = Properties.Resources.collision;
                airplane3.Location     = new Point(210, 30);
                labelair3.Location     = new Point(220, 68);
            }
        }
Esempio n. 53
0
        //Collision Detection
        protected void collisionDetection(Object source, ElapsedEventArgs e)
        {
            this.Dispatcher.Invoke((Action)(() =>
            {
                for (int i = 0; i < aisquares.Length; i++)
                {
                    //get player current dimensions and position
                    double playerRight = rectPlayer.Margin.Left + (playerSize);
                    double playerBottom = rectPlayer.Margin.Top + (playerSize);
                    double playerLeft = rectPlayer.Margin.Left - (playerSize);
                    double playerTop = rectPlayer.Margin.Top - (playerSize);

                    //get target square dimensions and position
                    double badTop = aisquares[i].Margin.Top - aisquares[i].ActualHeight;
                    double badBottom = aisquares[i].Margin.Top + aisquares[i].ActualHeight;
                    double badLeft = aisquares[i].Margin.Left - aisquares[i].ActualWidth;
                    double badRight = aisquares[i].Margin.Left + aisquares[i].ActualWidth;



                    //Test for collsion using above dimensions
                    if (badRight >= playerLeft &&
                        badLeft <= playerRight &&
                        badBottom >= playerTop &&
                        badTop <= playerBottom)
                    {               //successful collision
                        if (i < 24) //Green square locations in array
                        {
                            //play good sound
                            System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"c:\Windows\Media\chimes.wav");
                            player.Play();
                            //update score, size and speed
                            playerScore += 1;
                            playerSize += 1;
                            speed += 0.5;
                        }
                        else//A red sqaure has been hit
                        {
                            //Show game over, play bad sound and record new high score if achieved
                            gridGameOver.Visibility = Visibility.Visible;
                            System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"c:\Windows\Media\Windows Critical Stop.wav");
                            player.Play();

                            //save new high score to file depending on what difficultty was used
                            //Easy
                            if (numberOfOpponents == 30 && playerScore > highScoreEasy)
                            {
                                gridGameOver.Visibility = Visibility.Collapsed;
                                gridHighScore.Visibility = Visibility.Visible;
                                highScoreEasy = playerScore;

                                TextWriter tw = new StreamWriter(path);
                                tw.WriteLine(highScoreEasy + "");
                                tw.WriteLine(highScoreMedium + "");
                                tw.WriteLine(highScoreHard + "");
                                tw.Close();
                            }
                            //Medium
                            if (numberOfOpponents == 75 && playerScore > highScoreMedium)
                            {
                                gridGameOver.Visibility = Visibility.Collapsed;
                                gridHighScore.Visibility = Visibility.Visible;
                                highScoreMedium = playerScore;

                                TextWriter tw = new StreamWriter(path);
                                tw.WriteLine(highScoreEasy + "");
                                tw.WriteLine(highScoreMedium + "");
                                tw.WriteLine(highScoreHard + "");
                                tw.Close();
                            }
                            //Hard
                            if (numberOfOpponents == 100 && playerScore > highScoreHard)
                            {
                                gridGameOver.Visibility = Visibility.Collapsed;
                                gridHighScore.Visibility = Visibility.Visible;
                                highScoreHard = playerScore;

                                TextWriter tw = new StreamWriter(path);
                                tw.WriteLine(highScoreEasy + "");
                                tw.WriteLine(highScoreMedium + "");
                                tw.WriteLine(highScoreHard + "");
                                tw.Close();
                            }


                            lblEasy.Content = highScoreEasy + "";
                            lblMedium.Content = highScoreMedium + "";
                            lblHard.Content = highScoreHard + "";

                            lose = true;
                        }


                        //respawn the square that was hit
                        int rndX = 0;
                        int rndY = 0;
                        //While used to make sure respawned sqaures are away from current player position to avoid instant collision
                        while (rndX < rectPlayer.Margin.Left + 50 + playerSize && rndX > rectPlayer.Margin.Left - 50 - playerSize)
                        {
                            rndX = globalSeed.Next(-475, 475);
                        }
                        while (rndY < rectPlayer.Margin.Top + 50 + playerSize && rndY > rectPlayer.Margin.Top - 50 - playerSize)
                        {
                            rndY = globalSeed.Next(-450, 450);
                        }
                        aisquares[i].Margin = new Thickness(rndX, rndY, 0, 0);
                    }
                }
            }));
        }
Esempio n. 54
0
        private void playPlastic(int numDice)
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DiceRollForm));
            if (numDice > 2)
            {
                numDice = 3;
            }

            var a       = global::dnd.Properties.Resources._3_Plastic_1;
            int choices = getRandom(8);

            switch (numDice)
            {
            case 3:
                if (choices == 8)
                {
                    a = global::dnd.Properties.Resources._3_Plastic_1;
                }
                else if (choices == 7)
                {
                    a = global::dnd.Properties.Resources._3_Plastic_2;
                }
                else if (choices == 6)
                {
                    a = global::dnd.Properties.Resources._3_Plastic_3;
                }
                else if (choices == 5)
                {
                    a = global::dnd.Properties.Resources._3_Plastic_4;
                }
                else if (choices == 4)
                {
                    a = global::dnd.Properties.Resources.Many_Plastic_1;
                }
                else if (choices == 3)
                {
                    a = global::dnd.Properties.Resources.Many_Plastic_2;
                }
                else if (choices == 2)
                {
                    a = global::dnd.Properties.Resources.Many_Plastic_3;
                }
                else
                {
                    a = global::dnd.Properties.Resources.Many_Plastic_4;
                }
                break;

            case 2:
                choices = getRandom(4);
                if (choices == 4)
                {
                    a = global::dnd.Properties.Resources._2_Plastic_1;
                }
                else if (choices == 3)
                {
                    a = global::dnd.Properties.Resources._2_Plastic_2;
                }
                else if (choices == 2)
                {
                    a = global::dnd.Properties.Resources._2_Plastic_3;
                }
                else
                {
                    a = global::dnd.Properties.Resources._2_Plastic_4;
                }
                break;

            default:
                choices = getRandom(4);
                if (choices == 4)
                {
                    a = global::dnd.Properties.Resources._1_Plastic_1;
                }
                else if (choices == 3)
                {
                    a = global::dnd.Properties.Resources._1_Plastic_2;
                }
                else if (choices == 2)
                {
                    a = global::dnd.Properties.Resources._1_Plastic_3;
                }
                else
                {
                    a = global::dnd.Properties.Resources._1_Plastic_4;
                }
                break;
            }
            System.Media.SoundPlayer player = new System.Media.SoundPlayer(a);
            player.Play();
        }
        private void case3_Tick(object sender, EventArgs e)
        {
            countC3++;

            //airplane 1 lands on runway
            if (airplane1.Location.Y == 150 && !flippedA1C3)
            {
                airplane1.Image.RotateFlip(RotateFlipType.Rotate270FlipNone);
                flippedA1C3     = true;
                airplane1.Left -= 1;
                labelair1.Left -= 1;
            }
            else if (airplane1.Location.Y > 150)
            {
                airplane1.Top -= 1;
                labelair1.Top -= 1;
            }
            else if (airplane1.Visible)
            {
                airplane1.Left -= 1;
                labelair1.Left -= 1;
                if (airplane1.Location.X == 225)
                {
                    airplane1.Visible = false;
                    labelair1.Visible = false;

                    if (!changedCountA1C3)
                    {
                        int currentAirplanes = Convert.ToInt32(aircraftCount.Text);
                        aircraftCount.Text = Convert.ToString(currentAirplanes - 1);
                        changedCountA1C3   = true;
                    }
                }
            }

            //airplane 2 almost hits airplane 3 and then exits on bottom left airspace exit point
            if (airplane2.Location.Y < 80)
            {
                airplane2.Top += 1;
                labelair2.Top += 1;
                if (countC3 % 15 == 0)
                {
                    int altitude = Convert.ToInt32(infoAltitude.Text);
                    infoAltitude.Text = Convert.ToString(altitude + 11);
                    int speed = Convert.ToInt32(infoSpeed.Text);
                    labelair2.Text = "DL308 MSP D \n" + " " + (altitude + 11) + " " + (speed) + " " + "180";
                    if (speed <= 234)
                    {
                        infoSpeed.Text = Convert.ToString(speed + 2);
                        labelair2.Text = "DL308 MSP D \n" + " " + (altitude) + " " + (speed + 2) + " " + "180";
                    }
                    else
                    {
                        infoSpeed.Text = "250";
                        labelair2.Text = "DL308 MSP D \n" + " " + (altitude) + "250 180";
                    }
                }

                if (airplane2.Location.Y == 70)
                {
                    warningLabel.Visible = true;
                    airplane3.Image      = Properties.Resources.airplaneRed;
                    warning = true;
                    System.IO.Stream         warningSound = Properties.Resources.warning;
                    System.Media.SoundPlayer player       = new System.Media.SoundPlayer(warningSound);
                    player.Play();
                }
            }
            else if (airplane2.Location.Y == 80 && !flippedA2C3_1)
            {
                System.Threading.Thread.Sleep(2000); //wait to simulate input from user
                airplane2.Image.RotateFlip(RotateFlipType.Rotate90FlipNone);
                infoHeading.Text = "270";
                flippedA2C3_1    = true;
            }
            else if (airplane2.Location.X > 70)
            {
                airplane2.Left -= 2;
                labelair2.Left -= 2;

                if (countC3 % 15 == 0)
                {
                    int altitude = Convert.ToInt32(infoAltitude.Text);
                    infoAltitude.Text = Convert.ToString(altitude + 13);
                    int speed = Convert.ToInt32(infoSpeed.Text);
                    labelair2.Text = "DL308 MSP D \n" + " " + (altitude - 216) + " " + (speed - 19) + " " + "180";
                    if (speed <= 234)
                    {
                        infoSpeed.Text = Convert.ToString(speed + 6);
                        labelair2.Text = "DL308 MSP D \n" + " " + (altitude) + " " + (speed + 6) + " " + "180";
                    }
                    else
                    {
                        infoSpeed.Text = "250";
                        labelair2.Text = "DL308 MSP D \n" + " " + (altitude) + "250 180";
                    }
                }

                if (airplane2.Location.X == 80)
                {
                    warningLabel.Visible = false;
                    airplane3.Image      = Properties.Resources.airplaneGreen;
                    warning = false;
                }
            }
            else if (airplane2.Location.X == 70 && !flippedA2C3_2)
            {
                airplane2.Image.RotateFlip(RotateFlipType.Rotate270FlipNone);
                infoHeading.Text = "180";
                flippedA2C3_2    = true;
            }
            else if (airplane2.Location.Y < 330)
            {
                airplane2.Top += 2;
                labelair2.Top += 2;

                if (airplane2.Location.Y == 280)
                {
                    infoStatus.Text = "";
                }

                if (countC3 % 15 == 0)
                {
                    int altitude = Convert.ToInt32(infoAltitude.Text);
                    infoAltitude.Text = Convert.ToString(altitude + 213);
                    int speed = Convert.ToInt32(infoSpeed.Text);
                    labelair2.Text = "DL308 MSP D \n" + " " + (altitude + 213) + " " + (speed) + " " + "180";
                    if (speed <= 234)
                    {
                        infoSpeed.Text = Convert.ToString(speed + 6);
                        labelair2.Text = "DL308 MSP D \n" + " " + (altitude) + " " + (speed + 19) + " " + "180";
                    }
                    else
                    {
                        infoSpeed.Text = "250";
                        labelair2.Text = "DL308 MSP D \n" + " " + (altitude) + "250 180";
                    }
                }
            }
            else if (airplane2.Location.Y == 330)
            {
                airplane2.Visible = false;
                labelair2.Visible = false;

                infoFlight.Text      = "";
                infoDestination.Text = "";
                infoAltitude.Text    = "0";
                infoSpeed.Text       = "0";
                infoHeading.Text     = "0";
                needsUpdatingC3      = false;

                if (!changedCountA2C3)
                {
                    int currentAirplanes = Convert.ToInt32(aircraftCount.Text);
                    aircraftCount.Text = Convert.ToString(currentAirplanes - 1);
                    changedCountA2C3   = true;
                }
            }

            //airplane 3 almost hits airplane 2 and then exits on top right airspace exit point
            if (airplane3.Location.Y > 30)
            {
                airplane3.Top -= 1;
                labelair3.Top -= 1;
            }
            else if (airplane3.Location.Y == 30 && !flippedA3C3)
            {
                airplane3.Image.RotateFlip(RotateFlipType.Rotate90FlipNone);
                flippedA3C3 = true;
            }
            else if (airplane3.Location.X < 380)
            {
                airplane3.Left += 2;
                labelair3.Left += 2;
            }
            else if (airplane3.Location.X == 380)
            {
                airplane3.Visible = false;
                labelair3.Visible = false;

                if (!changedCountA3C3)
                {
                    int currentAirplanes = Convert.ToInt32(aircraftCount.Text);
                    aircraftCount.Text = Convert.ToString(currentAirplanes - 1);
                    changedCountA3C3   = true;
                }

                //reset planes to starting directions (a1-up, a2-up, a3-up)
                if (flippedA1C3)
                {
                    airplane1.Image.RotateFlip(RotateFlipType.Rotate90FlipNone);
                    flippedA1C3 = false;
                }

                if (flippedA2C3_1 || flippedA2C3_2)
                {
                    airplane2.Image.RotateFlip(RotateFlipType.Rotate180FlipNone);
                    flippedA2C3_1 = false;
                    flippedA2C3_2 = false;
                }

                if (flippedA3C3)
                {
                    airplane3.Image.RotateFlip(RotateFlipType.Rotate270FlipNone);
                    flippedA3C3 = false;
                }

                t_case3.Dispose();
            }
        }
Esempio n. 56
0
 private void pictureBox1_MouseHover(object sender, EventArgs e)
 {
     SoundButton.Play();
     pictureBox5.Visible = true;
     pictureBox5.Image   = Image.FromFile(Application.StartupPath + "\\Map\\no.png");
 }
Esempio n. 57
0
 private void C2_Click(object sender, RoutedEventArgs e)
 {
     player = new System.Media.SoundPlayer(Properties.Resources.Piano_pp_C5);
     player.Play();
 }
Esempio n. 58
0
 private void button10_Click(object sender, EventArgs e)
 {
     System.IO.Stream         str = Properties.Resources.tones;
     System.Media.SoundPlayer snd = new System.Media.SoundPlayer(str);
     snd.Play();
 }
 private void PlayMusic(String audioFile)
 {
     _player.Stop();
     _player.SoundLocation = audioFile;
     _player.Play();
 }
Esempio n. 60
0
 private void btn_sair_Click(object sender, EventArgs e)
 {
     System.Media.SoundPlayer player = new System.Media.SoundPlayer("sys_sounds/sair.wav");
     player.Play();
     this.Close();
 }