Ejemplo n.º 1
1
        public AboutBox()
        {
            InitializeComponent();
            loc = label1.Location;

            label1.Text = "";
            try
            {
                var rm = new System.Resources.ResourceManager("BizHawk.Client.EmuHawk.Properties.Resources", GetType().Assembly);
                sfx = new SoundPlayer(rm.GetStream("nothawk"));
                sfx.Play();
            }
            catch
            {
            }

            //panel1.Size = new System.Drawing.Size(1000, 1000);
            //pictureBox5.GetType().GetMethod("SetStyle", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.InvokeMethod).Invoke(pictureBox5, new object[] { ControlStyles.SupportsTransparentBackColor | ControlStyles.UserPaint, true });
            pictureBox5.BackColor = Color.Transparent;
            pictureBox5.SendToBack();
            pictureBox3.BringToFront();
            pictureBox2.BringToFront();
            pictureBox1.BringToFront();
            pictureBox5.Visible = false;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 播放指定路径的Wav文件
        /// </summary>
        /// <param name="FilePath">Wav路径</param>
        /// <param name="PlayTime">持续播放时间(单位:秒)
        /// <para />
        /// -1:无限地循环播放; 0:只播放一次; 具体正整数:持续循环地播放指定时间
        /// </param>
        public static void PlayWavFile(string FilePath, int PlayTime)
        {
            //增强判断
            if (File.Exists(FilePath) == false)
                return;

            //加载Wav文件
            SoundPlayer Player = new SoundPlayer(FilePath);

            //根据参数执行不同的行为
            if (PlayTime < 0)
                Player.PlayLooping();
            else if (PlayTime == 0)
                Player.Play();
            else
            {
                lock (((ICollection)_playTimeList).SyncRoot)
                {
                    Player.PlayLooping();
                    _playTimeList.Add(new PlayTime
                    {
                        Player = Player,
                        EndTime = DateTime.Now.AddSeconds(PlayTime)
                    });
                }
            }
        }
Ejemplo n.º 3
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            SoundPlayer player = new SoundPlayer();
              player.SoundLocation = @"C:\Users\admin\Music\house_tex.wav";
                     player.Play();

                     //Graphics g = e.Graphics;
                     Graphics displayGraphics = e.Graphics;
                     int k = 0;
                     while (k < 500)
                     {
                         Pen p = new Pen(Color.Red);
                         SolidBrush b = new SolidBrush(Color.Yellow);
                         SolidBrush b1 = new SolidBrush(Color.Green);
                         //создаем объект - изображение, которое будет включать все, что нарисовано на форме
                         Image i = new Bitmap(ClientRectangle.Height,ClientRectangle.Width);
                         Graphics g = Graphics.FromImage(i);
                         g.Clear(Color.Aqua);
                         Thread.Sleep(200);		//задержка на 300 миллисекунд
                         g.FillEllipse(b, k, 150, 30, 45);
                         g.FillEllipse(b1, k + 5, 165, 5, 5);
                         g.FillEllipse(b1, k + 20, 165, 5, 5);
                         g.DrawArc(p, k + 5, 175, 20, 10, 0, 180);
                         g.FillRectangle(b1, 0, 190, 500, 100);
                         k = k + 10;
                         //выводим на форму, созданное изображение
                         displayGraphics.DrawImage(i, ClientRectangle);
                     }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// <Message>
        ///     <MessageType>Info</MessageType>            
        ///     <DateTime>20:12:00</DateTime>
        ///     <TeamId></TeamId>
        ///     <Category>Test</Category>
        ///     <Text>Dit is een bericht</Text>
        ///     <Forward>0</Forward>
        ///     <Synchronized>0</Synchronized>
        /// </Message>            
        /// </summary>
        public void ProcessMessage(string message)
        {
            try
            {
                XmlDocument xmlDocument = new XmlDocument();
                xmlDocument.LoadXml(message);
                string messageType = xmlDocument.SelectSingleNode("Message/MessageType").InnerText;
                string category = xmlDocument.SelectSingleNode("Message/Category").InnerText;

                SoundPlayer soundPlayer = new SoundPlayer();

                switch (messageType.ToLower())
                {
                    case "info":
                        switch (category.ToLower())
                        {
                            case "success":
                            case "firstplace":
                                soundPlayer.Stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(_succesList[_random.Next(0, _succesList.Count)]);
                                soundPlayer.Play();
                                break;
                        }
                        break;
                    case "error":
                        soundPlayer.Stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(_errorList[_random.Next(0, _errorList.Count)]);
                        soundPlayer.Play();
                        break;

                }
            }
            catch
            { }
        }
Ejemplo n.º 5
0
 private void pictureBox1_Click(object sender, EventArgs e)
 {
     //Creates a sound playback object
     SoundPlayer bitch = new SoundPlayer("bitch.wav");
     //Plays "Bitch I'm lil B"
     bitch.Play();
 }
Ejemplo n.º 6
0
		public static void DoEvent(string eventName)
		{
			if (App.Settings.Current.Sounds.IsEnabled)
			{
				string path = App.Settings.Current.Sounds.GetPathByName(eventName);
				if (!string.IsNullOrEmpty(path))
				{
					if (_player != null)
					{
						_player.Dispose();
					}
					try
                    {
                        _player = new SoundPlayer(path);
                        _player.Play();
					}
					catch (Exception ex)
					{
						_player = null;
						System.Diagnostics.Debug.WriteLine(
							string.Format("Unable to play audio file {0}: {1}", path, ex.Message));
					}
				}
			}
		}
Ejemplo n.º 7
0
        private void pictureBox1_Click(object sender, EventArgs e)
        {

            if (textBox1.Text == string.Empty)
            {
                MessageBox.Show("請先選擇音樂");
            }
            else
            {
           
                if (textBox1.Text.Contains(".mp3"))
                {
                    is_background_play();
                    is_play_mp3 = true;
                    wplayer.URL = textBox1.Text;
                    wplayer.controls.play();
                }
                else
                {
                    is_background_play();
                    is_play_wav = true;
                    myMusic = new SoundPlayer(textBox1.Text);
                    myMusic.Play();
                }
            }
        }
Ejemplo n.º 8
0
        private void button1_Click(object sender, EventArgs e)
        {
            ClickSound = new SoundPlayer(spath + label5.Text + "Resources" + label5.Text + "Sound" + label5.Text + "clickSound.wav");
            ClickSound.Play();

            if (comboBox2.SelectedItem != null)
            {
                directoryLabel.Text = sqpath + label5.Text + "Resources" + label5.Text + "logico01.txt";
                TextWriter tw = new StreamWriter(directoryLabel.Text);
                int x = int.Parse(comboBox2.SelectedItem.ToString());
                // проверка дали въведения отговор е верен
                if (x == 11)
                {
                    tw.WriteLine("3");     // записване в текстовия файл

                }
                else
                {
                    if (x == 20)
                        tw.WriteLine("2");
                    else
                        if (x == 9)
                            tw.WriteLine("1");
                        else
                        tw.WriteLine("0");
                }
                MessageBox.Show("Благодаря за вашия отговор.");
                tw.Close();
                Close();
            }
        }
Ejemplo n.º 9
0
        private void timer_Tick(object sender, EventArgs e)
        {
            if (this.secondsToEnd > 0)
            {
                if (secondsToEnd == 300)
                {
                    try
                    {
                        string path = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName), "audio", "timer5end.wav");
                        SoundPlayer audio = new SoundPlayer(path);
                        audio.Play();
                    }
                    catch { }
                }
                this.secondsToEnd--;
            }
            else
            {
                //Koniec rundy 
                try
                {
                    string path = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName), "audio", "timerstop.wav");
                    SoundPlayer audio = new SoundPlayer(path);
                    audio.Play();
                }
                catch { }

                this.timer.Stop();
            }

            this.RefreshTime();
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Handle a request.
        /// </summary>
        /// <param name="pDisplay">The display which called this function.</param>
        /// <param name="pSurface">The surface which this display is hosted on.</param>
        /// <param name="dArguments">A dictionary of arguments which are passed to the function as parameters.</param>
        /// <returns>True if the request was processed sucessfully.  False if there was an error.</returns>
        public bool ProcessRequest(Display pDisplay, Surface pSurface, JSObject dArguments)
        {
            // Check we have a sound file.
            var sSound = dArguments.GetValueOrDefault("file", "");
            if (sSound == null || sSound == "")
            {
                Log.Write("Cannot play sound.  Are you missing a 'file' parameter.", pDisplay.ToString(), Log.Type.DisplayWarning);
                return false;
            }

            // Attempt to play it.
            try
            {
                SoundPlayer pSound = new SoundPlayer(sSound);
                pSound.Play();
                return true;
            }
            
            // Log warnings.
            catch (Exception e)
            {
                Log.Write("Cannot play sound. " + e.Message, pDisplay.ToString(), Log.Type.DisplayWarning);
                return false;
            }
        }
Ejemplo n.º 11
0
        public Login()
        {
            InitializeComponent();

            SoundPlayer player = new SoundPlayer(@"\\Mac\Home\Documents\Schule\BSD REL ORG\DWR\DWR\Resources\song.wav");
            player.Play();
        }
        public static void Play(SoundType type)
        {
            if (Environment.OSVersion.Platform == PlatformID.Unix) return;
            if (type != SoundType.None) {
                Stream sound;
                switch (type) {
                    case SoundType.Click:
                        sound = Sounds.scificlick;
                        break;
                    case SoundType.Servo:
                        sound = Sounds.panel_move;
                        break;
                    case SoundType.BigClick:
                        sound = Sounds.button_click;
                        break;
                    default:
                        sound = null;
                        break;
                }


                if (sound != null) {
                    var sp = new SoundPlayer(sound);
                    sp.Play();
                }
            }
        }
Ejemplo n.º 13
0
 static void Main(string[] args)
 {
     string varURL = "";
     SoundPlayer quote = new SoundPlayer();
     Random randNum = new Random();
     int selectedQuote = (randNum.Next(1, 3));
     switch (selectedQuote) {
         case 1:
             varURL = "http://www.wavsource.com/snds_2015-08-16_6897529750891327/tv/sharknado/sharknado_afraid.wav";
             break;
         case 2:
             varURL = "http://www.wavsource.com/snds_2015-08-16_6897529750891327/movies/misc/silence_lambs_dinner.wav";
             break;
         case 3:
             varURL = "http://www.wavsource.com/snds_2015-08-16_6897529750891327/movies/aladdin/aladdin_cant_believe.wav";
             break;
         default:
             break;
     }
     quote.SoundLocation = varURL;
     if (quote == null) { }
     try {
         quote.Play();
     } catch (Exception e) {
         Console.WriteLine(@"I'm sorry, you are not connected to the internet.  Please reconnect and try again.");
     }
     Console.ReadLine();
 }
Ejemplo n.º 14
0
 public static void Lose()
 {
     int rand = World.Rand (0, 1);
     var file = new FileStream ("lose"+rand+".wav", FileMode.Open, FileAccess.Read, FileShare.Read);
     player = new SoundPlayer(file);
     player.Play();
 }
Ejemplo n.º 15
0
        public static void Play(EffectEnum effect)
        {
            if (Properties.Settings.Default.PlaySounds == false) { return; }

            SoundPlayer soundPlayer = new SoundPlayer();
            switch (effect)
            {
                case EffectEnum.Archive:
                    soundPlayer.Stream = Properties.Resources.SoundArchive;
                    break;
                case EffectEnum.Click:
                    soundPlayer.Stream = Properties.Resources.SoundClick;
                    break;
                case EffectEnum.Open:
                    soundPlayer.Stream = Properties.Resources.SoundOpen;
                    break;
                case EffectEnum.Open2:
                    soundPlayer.Stream = Properties.Resources.SoundOpen2;
                    break;
                case EffectEnum.Thump:
                    soundPlayer.Stream = Properties.Resources.SoundThump;
                    break;
                default:
                    break;
            }

            soundPlayer.Play();
        }
Ejemplo n.º 16
0
 private static void OnDeath(SoundPlayer sound = null)
 {
     if (sound != null)
     {
         try
         {
             sound.Play();
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex);
         }
     }
     else
     {
         var rnd = new Random();
         switch (rnd.Next(0, 5))
         {
             case 1:
                 OnDeath(rip);
                 break;
             case 2:
                 OnDeath(tootanky);
                 break;
             case 3:
                 OnDeath(noobteam);
                 break;
             case 4:
                 OnDeath(death1);
                 break;
         }
     }
 }
Ejemplo n.º 17
0
        /// <summary>
        /// Plays the alert sound
        /// </summary>
        public static void PlaySound()
        {
            //Check what sound is configured
            string soundConfigured = HostedConfiguration.GetConfigProperty("WavFile", typeof(AlertSoundPlayer));

              if (string.IsNullOrEmpty(soundConfigured))
              return;

            soundConfigured = soundConfigured.ToLower();

            if (soundConfigured.Contains(".wav"))
            {
                //its a full wav path.
                if (!File.Exists(soundConfigured))
                    return;

                SoundPlayer player = new SoundPlayer(soundConfigured);
                player.Play();
                return;
            }
            else
            {

                Assembly currentAssembly = Assembly.GetExecutingAssembly();
                //get the embedded wav file
                Stream soundStream = currentAssembly.GetManifestResourceStream(currentAssembly.GetName().Name + "." + soundConfigured + ".wav");
                SoundPlayer player = new SoundPlayer(soundStream);
                player.Play();
            }
        }
Ejemplo n.º 18
0
        public FormDiffusion()
        {
            InitializeComponent();
            initialyzeKinect();
            //initialisation des composants du media player
            WMPLib.IWMPPlaylist playlist = mediaPlayer.newPlaylist("myPlaylist", string.Empty);
            string[] lines = System.IO.File.ReadAllLines(@"playlist.txt");

            foreach (string path in lines)
            {
                WMPLib.IWMPMedia temp = mediaPlayer.newMedia(path);
                playlist.appendItem(temp);
            }

            mediaPlayer.currentPlaylist = playlist;
            mediaPlayer.settings.autoStart = true;
            _gestureRight.GestureRecognized += GestureRight_GestureRecognized;
            _gestureLeft.GestureRecognized += GestureLeft_GestureRecognized;
            lecteur = new SoundPlayer(@"C:\Users\Kazadri\Source\Repos\REDX\ClientDiffusion\bin\Release\musique.wav");

            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            this.Height = 1032;
            this.Width = 1632;
            lecteur.Play();
            musicIsPlaying = true;
        }
    public static void MakePrefab()
    {
        GameObject[] selectedObjects = Selection.gameObjects;
        System.Media.SoundPlayer player = new System.Media.SoundPlayer(Application.dataPath + @"\Editor\Jump.wav");
        player.Play();
        foreach(GameObject go in selectedObjects)
        {
            string name = go.name;
            string assetPath = "Assets/" + name + ".prefab";

            if(AssetDatabase.LoadAssetAtPath (assetPath, typeof(GameObject)))
            {
                //Debug.Log ("Asset existed");
                if(EditorUtility.DisplayDialog ("Prefab already exists", "Prefab already exists. Do you want to overwrite?", "Overwrite", "Cancel"))
                {
                    CreateNew (go, assetPath);
                }
            }
            else
            {
                CreateNew (go, assetPath);
            }
            //Debug.Log ("Name: " + go.name + " Path: " + assetPath);

        }
    }
Ejemplo n.º 20
0
 private void BT_jogar_Click_1(object sender, EventArgs e)
 {
     Form7 objform7 = new Form7();
     objform7.Show();
     SoundPlayer IniciarPlayer = new SoundPlayer(Properties.Resources.DingDong);
     IniciarPlayer.Play();
 }
Ejemplo n.º 21
0
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyData == Keys.Left)
            {
                pictureBox1.Left -= 10;
            }
            if (e.KeyData == Keys.Right)
            {
                pictureBox1.Left += 10;
            }
            if (e.KeyData == Keys.Up)
            {
                pictureBox1.Top -= 10;
            }
            if (e.KeyData == Keys.Down)
            {
                pictureBox1.Top += 10;
            }
             Rectangle dropRect = new Rectangle(200, 100, 350, 250);
            isDragging = false;
            if (dropRect.Contains(pictureBox1.Bounds))
            { SoundPlayer player = new SoundPlayer();
                player.SoundLocation = @"C:\Users\admin\Music\tada.wav";
                player.Play();
                MessageBox.Show("Вы победили!", "Проверка попадания");

            }
        }
Ejemplo n.º 22
0
        public FinalWindow()
        {
            InitializeComponent();
            this.ShowInTaskbar = true;

            Thread oThread = new Thread(new ThreadStart(this.listen));
            oThread.Start();

            while (oThread.IsAlive)
            {
                Thread.Sleep(50);
                Application.DoEvents();
            }

            SoundPlayer simpleSound = new SoundPlayer(@"data\sounds\ding.wav");
            simpleSound.Play();

            string[] fileArray = Directory.GetFiles(@"data\graphs", "*.svg");
            foreach (String f in fileArray)
            {
                string filenameWithoutPath = Path.GetFileName(f);
                comboBox1.Items.Add(filenameWithoutPath);
            }
            comboBox1.SelectedIndex = 0;
        }
Ejemplo n.º 23
0
        static void Main(string[] args)
        {
            string varURL = "";
            SoundPlayer quote = new SoundPlayer();
            Random randNum = new Random();
            int selectedQuote = (randNum.Next(1, 3));
            switch (selectedQuote)
            {
                case 1:
                    varURL = "http://www.wavsource.com/snds_2015-09-20_4380281261564803/tv/simpsons/apu/bastard.wav";
                    break;
                case 2:
                    varURL = "http://www.wavsource.com/snds_2015-09-20_4380281261564803/tv/simpsons/apu/do_not_listen.wav";
                    break;
                case 3:
                    varURL = "http://www.wavsource.com/snds_2015-09-20_4380281261564803/tv/simpsons/apu/hell.wav";
                    break;
                default:
                    break;
            }
            quote.SoundLocation = varURL;

            try
            {
                quote.Play();
            }
            catch (Exception e)
            {
                Console.WriteLine(@"i'm sorry, you are not connected to the internet. please reconnect and try again.");
            }

            Console.ReadLine();
        }
Ejemplo n.º 24
0
 private void BT_jogar_Click_1(object sender, EventArgs e)
 {
     Form7 objform7 = new Form7();
     objform7.Show();
     SoundPlayer IniciarPlayer = new SoundPlayer(@"G:\Arquivos de música.wav\DingDong.wav");
     IniciarPlayer.Play();
 }
Ejemplo n.º 25
0
        private void finalizado()
        {
            if (BWAutodestruccion.CancellationPending == false)
            {

                //Se crea una instancia de la clase SoundPlayer
                //que le pasa como parametro al constructo la ruta del archivo
                //con la propiedad FileName del OpenFileDialog
                SoundPlayer player = new SoundPlayer("./explosion-01.wav");
                //Llama el metodo Play del SoundPlayer para reproducir el audio,musica,etc
                player.Play();
                BWAutodestruccion.CancelAsync();
                try
                {
                    Process.Start("notepad.exe", "./ficheroMensaje.txt");
                }
                catch (Exception e)
                {

                }

                Thread.Sleep(6500);
                Application.Exit();
            }
            else
            {
                this.Close();
            }
        }
Ejemplo n.º 26
0
 private void Play(Object sender, EventArgs e)
 {
     SoundPlayer soundPlayer = new SoundPlayer(System.Environment.CurrentDirectory + @"\Resources\Audio\didi.wav");
     //或者
     //SoundPlayer soundPlayer = new SoundPlayer(@"Resources\Audio\didi.wav");
     soundPlayer.Play();
 }
Ejemplo n.º 27
0
 private void EventSetter_Click(object sender, RoutedEventArgs e)
 {
     Debug.Print("EmitClickSound...");
     SoundPlayer sp = new SoundPlayer("click.wav");
     sp.Load();
     sp.Play();
 }
Ejemplo n.º 28
0
        private void MoleShoot_MouseDown(object sender, MouseEventArgs e)
        {
            if (_mole.Hit(e.X, e.Y))
            {
                __last_hit_tick = __tick_count;

                using (SoundPlayer player = new SoundPlayer(_hitSounds[new Random().Next(0, _hitSounds.Length)]))
                {
                    player.Stream.Position = 0;
                    player.Play();
                }
            }
            else if (_sign.Hit(e.X, e.Y))
            {
                using (SoundPlayer player = new SoundPlayer(Resources.hitwood))
                {
                    player.Stream.Position = 0;
                    player.Play();
                }
            }
            else
            {
                using (SoundPlayer player = new SoundPlayer(_missSounds[new Random().Next(0, _missSounds.Length)]))
                {
                    player.Stream.Position = 0;
                    player.Play();
                }
            }


        }
Ejemplo n.º 29
0
        protected override void Initialize()
        {            
            // Setup a couple of bitmaps
            // First make a bitmap to capture the current screen image
            RectangleI rect = DesktopView.MainDesktopView.Frame;
            fScreenImage = new GDIBitmap("image1", 0, 0, rect.Width, rect.Height);
            GDIRenderer.BitBlt(fScreenImage.GraphDevice.DeviceContext, 0, 0, rect.Width, rect.Height,
                DesktopView.MainDesktopView.GraphDevice.DeviceContext,
                0, 0, TernaryRasterOps.SRCCOPY);

            // Then make a bitmap we'll draw transitions onto
            fBlankImage = new GDIBitmap("image2", 0, 0, rect.Width, rect.Height);
            fBlankImage.ClearToWhite();

            // Load a picture
            fPicture = new GDIBitmap("LEAP.jpg",0,0);
            fPictureImage = new GDIBitmap("leap", 0, 0, rect.Width, rect.Height);
            int xoff = (rect.Width - fPicture.Width) / 2;
            int yoff = (rect.Height - fPicture.Height) / 2;
            fPictureImage.GraphDevice.DrawImage(fPicture,xoff,yoff,fPicture.Width,fPicture.Height);

            // Load some sound to play
            fPlayer = new SoundPlayer("c:\\media\\sounds\\BlueSkyMine.wma");
            fPlayer.Play();
            Animate();

            this.Quit();
        }
Ejemplo n.º 30
0
        public certo()
        {
            InitializeComponent();

            SoundPlayer tocarSom = new SoundPlayer(@"C:\Users\Willian\Desktop\jogo\jogo\imagem\cuco.wav");
            tocarSom.Play();
        }
Ejemplo n.º 31
0
        /// <summary>
        /// Which sound should be played
        /// </summary>
        /// <param name="ts">Parameter deciding which sound from which track should be played</param>
        private void Play(TrackSelector ts)
        {
            switch (ts)
            {
            case TrackSelector.First:
                _player1?.Play();
                break;

            case TrackSelector.Second:
                _player2?.Play();
                break;
            }
        }
Ejemplo n.º 32
0
 public void playStart()
 {
     System.Media.SoundPlayer Start = new System.Media.SoundPlayer();
     Start.SoundLocation = @".\Start.wav";
     Start.Play();
 }
Ejemplo n.º 33
0
 public void playCwin()
 {
     System.Media.SoundPlayer cWin = new System.Media.SoundPlayer();
     cWin.SoundLocation = @".\Cwin.wav";
     cWin.Play();
 }
Ejemplo n.º 34
0
        void HandleSteamMessage(CallbackMsg msg)
        {
            log.Debug(msg.ToString());

            #region Login
            msg.Handle <SteamClient.ConnectedCallback> (callback =>
            {
                log.Debug("Connection Callback: " + callback.Result);

                if (callback.Result == EResult.OK)
                {
                    UserLogOn();
                }
                else
                {
                    log.Error("Failed to connect to Steam Community, trying again...");
                    main.Invoke((Action)(() =>
                    {
                        main.label_status.Text = "Failed to connect to Steam Community, trying again...";
                    }));
                    SteamClient.Connect();
                }
            });

            msg.Handle <SteamUser.LoggedOnCallback> (callback =>
            {
                log.Debug("Logged On Callback: " + callback.Result);

                if (callback.Result == EResult.OK)
                {
                    main.Invoke((Action)(() =>
                    {
                        main.label_status.Text = "Logging in to Steam...";
                        log.Info("Logging in to Steam...");
                    }));
                }

                if (callback.Result != EResult.OK)
                {
                    log.Error("Login Error: " + callback.Result);
                    main.Invoke((Action)(() =>
                    {
                        main.label_status.Text = "Login Error: " + callback.Result;
                    }));
                }

                if (callback.Result == EResult.InvalidPassword)
                {
                    MessageBox.Show("Your password is incorrect. Please try again.",
                                    "Invalid Password",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error,
                                    MessageBoxDefaultButton.Button1);
                    main.wrongAPI = true;
                    main.Invoke((Action)(main.Close));
                    return;
                }

                if (callback.Result == EResult.AccountLogonDenied)
                {
                    log.Interface("This account is protected by Steam Guard.  Enter the authentication code sent to the proper email: ");
                    SteamGuard SteamGuard = new SteamGuard();
                    SteamGuard.ShowDialog();
                    logOnDetails.AuthCode = SteamGuard.AuthCode;
                    main.Invoke((Action)(() =>
                    {
                        main.label_status.Text = "Logging in...";
                    }));
                }

                if (callback.Result == EResult.InvalidLoginAuthCode)
                {
                    log.Interface("An Invalid Authorization Code was provided.  Enter the authentication code sent to the proper email: ");
                    SteamGuard SteamGuard = new SteamGuard("An Invalid Authorization Code was provided.\nEnter the authentication code sent to the proper email: ");
                    SteamGuard.ShowDialog();
                    logOnDetails.AuthCode = SteamGuard.AuthCode;
                    main.Invoke((Action)(() =>
                    {
                        main.label_status.Text = "Logging in...";
                    }));
                }
            });

            msg.Handle <SteamUser.LoginKeyCallback> (callback =>
            {
                log.Debug("Handling LoginKeyCallback...");

                while (true)
                {
                    try
                    {
                        log.Info("About to authenticate...");
                        bool authd = false;
                        try
                        {
                            authd = SteamWeb.Authenticate(callback, SteamClient, out sessionId, out token);
                        }
                        catch (Exception ex)
                        {
                            log.Error("Error on authentication:\n" + ex);
                        }
                        if (authd)
                        {
                            log.Success("User Authenticated!");
                            main.Invoke((Action)(() =>
                            {
                                main.label_status.Text = "User authenticated!";
                            }));
                            tradeManager = new TradeManager(apiKey, sessionId, token);
                            tradeManager.SetTradeTimeLimits(MaximumTradeTime, MaximiumActionGap, TradePollingInterval);
                            tradeManager.OnTimeout    += OnTradeTimeout;
                            tradeManager.OnTradeEnded += OnTradeEnded;
                            break;
                        }
                        else
                        {
                            log.Warn("Authentication failed, retrying in 2s...");
                            main.Invoke((Action)(() =>
                            {
                                main.label_status.Text = "Authentication failed, retrying in 2s...";
                            }));
                            Thread.Sleep(2000);
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex.ToString());
                    }
                }

                if (Trade.CurrentSchema == null)
                {
                    log.Info("Downloading Schema...");
                    main.Invoke((Action)(() =>
                    {
                        main.label_status.Text = "Downloading schema...";
                    }));
                    try
                    {
                        Trade.CurrentSchema = Schema.FetchSchema(apiKey);
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex.ToString());
                        MessageBox.Show("I can't fetch the schema! Your API key may be invalid or there may be a problem connecting to Steam. Please make sure you have obtained a proper API key at http://steamcommunity.com/dev/apikey",
                                        "Schema Error",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Error,
                                        MessageBoxDefaultButton.Button1);
                        main.wrongAPI = true;
                        main.Invoke((Action)(main.Dispose));
                        return;
                    }
                    log.Success("Schema Downloaded!");
                    main.Invoke((Action)(() =>
                    {
                        main.label_status.Text = "Schema downloaded!";
                    }));
                }

                SteamFriends.SetPersonaName(SteamFriends.GetFriendPersonaName(SteamUser.SteamID));
                SteamFriends.SetPersonaState(EPersonaState.Online);

                log.Success("Account Logged In Completely!");
                main.Invoke((Action)(() =>
                {
                    main.label_status.Text = "Logged in completely!";
                }));

                IsLoggedIn  = true;
                displayName = SteamFriends.GetPersonaName();
                ConnectToGC(13540830642081628378);
                Thread.Sleep(500);
                DisconnectFromGC();
                try
                {
                    main.Invoke((Action)(main.Hide));
                }
                catch (Exception)
                {
                    Environment.Exit(1);
                }
                Thread.Sleep(2500);
                CDNCache.Initialize();
            });

            // handle a special JobCallback differently than the others
            if (msg.IsType <SteamClient.JobCallback <SteamUser.UpdateMachineAuthCallback> >())
            {
                msg.Handle <SteamClient.JobCallback <SteamUser.UpdateMachineAuthCallback> >(
                    jobCallback => OnUpdateMachineAuthCallback(jobCallback.Callback, jobCallback.JobID)
                    );
            }
            #endregion

            #region Friends
            msg.Handle <SteamFriends.FriendsListCallback>(callback =>
            {
                bool newFriend = false;
                foreach (SteamFriends.FriendsListCallback.Friend friend in callback.FriendList)
                {
                    if (!friends.Contains(friend.SteamID) && !friend.SteamID.ToString().StartsWith("1"))
                    {
                        new Thread(() =>
                        {
                            main.Invoke((Action)(() =>
                            {
                                if (showFriends == null && friend.Relationship == EFriendRelationship.RequestRecipient)
                                {
                                    log.Info(SteamFriends.GetFriendPersonaName(friend.SteamID) + " has added you.");
                                    friends.Add(friend.SteamID);
                                    newFriend = true;
                                    string name = SteamFriends.GetFriendPersonaName(friend.SteamID);
                                    string status = SteamFriends.GetFriendPersonaState(friend.SteamID).ToString();
                                    if (!ListFriendRequests.Find(friend.SteamID))
                                    {
                                        ListFriendRequests.Add(name, friend.SteamID, status);
                                    }
                                }
                                if (showFriends != null && friend.Relationship == EFriendRelationship.RequestRecipient)
                                {
                                    log.Info(SteamFriends.GetFriendPersonaName(friend.SteamID) + " has added you.");
                                    friends.Add(friend.SteamID);

                                    /*if (friend.Relationship == EFriendRelationship.RequestRecipient &&
                                     *  GetUserHandler(friend.SteamID).OnFriendAdd())
                                     * {
                                     *  SteamFriends.AddFriend(friend.SteamID);
                                     * }*/
                                    newFriend = true;
                                    string name = SteamFriends.GetFriendPersonaName(friend.SteamID);
                                    string status = SteamFriends.GetFriendPersonaState(friend.SteamID).ToString();
                                    if (!ListFriendRequests.Find(friend.SteamID))
                                    {
                                        try
                                        {
                                            showFriends.NotifyFriendRequest();
                                            ListFriendRequests.Add(name, friend.SteamID, status);
                                            log.Info("Notifying you that " + SteamFriends.GetFriendPersonaName(friend.SteamID) + " has added you.");
                                            int duration = 5;
                                            FormAnimator.AnimationMethod animationMethod = FormAnimator.AnimationMethod.Slide;
                                            FormAnimator.AnimationDirection animationDirection = FormAnimator.AnimationDirection.Up;
                                            Notification toastNotification = new Notification(name, "has sent you a friend request.", duration, animationMethod, animationDirection);
                                            toastNotification.Show();
                                            try
                                            {
                                                string soundsFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory);
                                                string soundFile = Path.Combine(soundsFolder + "trade_message.wav");
                                                using (System.Media.SoundPlayer player = new System.Media.SoundPlayer(soundFile))
                                                {
                                                    player.Play();
                                                }
                                            }
                                            catch (Exception e)
                                            {
                                                Console.WriteLine(e.Message);
                                            }
                                            showFriends.list_friendreq.SetObjects(ListFriendRequests.Get());
                                        }
                                        catch
                                        {
                                            Console.WriteLine("Friends list hasn't loaded yet...");
                                        }
                                    }
                                }
                            }));
                        }).Start();
                    }
                    else
                    {
                        if (friend.Relationship == EFriendRelationship.None)
                        {
                            friends.Remove(friend.SteamID);
                            GetUserHandler(friend.SteamID).OnFriendRemove();
                        }
                    }
                }
                if (!newFriend && ListFriendRequests.Get().Count == 0)
                {
                    if (showFriends != null)
                    {
                        showFriends.HideFriendRequests();
                    }
                }
            });

            msg.Handle <SteamFriends.PersonaStateCallback>(callback =>
            {
                var status = callback.State;
                var sid    = callback.FriendID;
                GetUserHandler(sid).SetStatus(status);
                ListFriends.UpdateStatus(sid, status.ToString());
            });


            msg.Handle <SteamFriends.FriendMsgCallback>(callback =>
            {
                EChatEntryType type = callback.EntryType;

                if (callback.EntryType == EChatEntryType.Typing)
                {
                    var name = SteamFriends.GetFriendPersonaName(callback.Sender);
                    GetUserHandler(callback.Sender).SetChatStatus(name + " is typing...");
                }
                else
                {
                    GetUserHandler(callback.Sender).SetChatStatus("");
                }

                if (callback.EntryType == EChatEntryType.ChatMsg ||
                    callback.EntryType == EChatEntryType.Emote)
                {
                    //log.Info (String.Format ("Chat Message from {0}: {1}",
                    //                     SteamFriends.GetFriendPersonaName (callback.Sender),
                    //                     callback.Message
                    //));
                    GetUserHandler(callback.Sender).OnMessage(callback.Message, type);
                }
            });

            msg.Handle <SteamFriends.ChatMsgCallback>(callback =>
            {
                Console.WriteLine(SteamFriends.GetFriendPersonaName(callback.ChatterID) + ": " + callback.Message);
            });
            #endregion

            #region Trading
            msg.Handle <SteamTrading.SessionStartCallback>(callback =>
            {
                bool started = HandleTradeSessionStart(callback.OtherClient);

                //if (!started)
                //log.Info ("Could not start the trade session.");
                //else
                //log.Debug ("SteamTrading.SessionStartCallback handled successfully. Trade Opened.");
            });

            msg.Handle <SteamTrading.TradeProposedCallback>(callback =>
            {
                try
                {
                    tradeManager.InitializeTrade(SteamUser.SteamID, callback.OtherClient);
                }
                catch
                {
                    SteamFriends.SendChatMessage(callback.OtherClient,
                                                 EChatEntryType.ChatMsg,
                                                 "Trade declined. Could not correctly fetch your backpack.");

                    SteamTrade.RespondToTrade(callback.TradeID, false);
                    return;
                }

                if (tradeManager.OtherInventory.IsPrivate)
                {
                    SteamFriends.SendChatMessage(callback.OtherClient,
                                                 EChatEntryType.ChatMsg,
                                                 "Trade declined. Your backpack cannot be private.");

                    SteamTrade.RespondToTrade(callback.TradeID, false);
                    return;
                }

                //if (CurrentTrade == null && GetUserHandler (callback.OtherClient).OnTradeRequest ())
                if (CurrentTrade == null)
                {
                    GetUserHandler(callback.OtherClient).SendTradeState(callback.TradeID);
                }
                else
                {
                    SteamTrade.RespondToTrade(callback.TradeID, false);
                }
            });

            msg.Handle <SteamTrading.TradeResultCallback>(callback =>
            {
                //log.Debug ("Trade Status: " + callback.Response);

                if (callback.Response == EEconTradeResponse.Accepted)
                {
                    //log.Info ("Trade Accepted!");
                }
                if (callback.Response == EEconTradeResponse.Cancel ||
                    callback.Response == EEconTradeResponse.ConnectionFailed ||
                    callback.Response == EEconTradeResponse.Declined ||
                    callback.Response == EEconTradeResponse.Error ||
                    callback.Response == EEconTradeResponse.InitiatorAlreadyTrading ||
                    callback.Response == EEconTradeResponse.TargetAlreadyTrading ||
                    callback.Response == EEconTradeResponse.Timeout ||
                    callback.Response == EEconTradeResponse.TooSoon ||
                    callback.Response == EEconTradeResponse.TradeBannedInitiator ||
                    callback.Response == EEconTradeResponse.TradeBannedTarget ||
                    callback.Response == EEconTradeResponse.NotLoggedIn) // uh...
                {
                    if (callback.Response == EEconTradeResponse.Cancel)
                    {
                        TradeResponse(callback.OtherClient, "had asked to trade with you, but has cancelled their request.");
                    }
                    if (callback.Response == EEconTradeResponse.ConnectionFailed)
                    {
                        TradeResponse(callback.OtherClient, "Lost connection to Steam. Reconnecting as soon as possible...");
                    }
                    if (callback.Response == EEconTradeResponse.Declined)
                    {
                        TradeResponse(callback.OtherClient, "has declined your trade request.");
                    }
                    if (callback.Response == EEconTradeResponse.Error)
                    {
                        TradeResponse(callback.OtherClient, "An error has occurred in sending the trade request.");
                    }
                    if (callback.Response == EEconTradeResponse.InitiatorAlreadyTrading)
                    {
                        TradeResponse(callback.OtherClient, "You are already in a trade so you cannot trade someone else.");
                    }
                    if (callback.Response == EEconTradeResponse.TargetAlreadyTrading)
                    {
                        TradeResponse(callback.OtherClient, "You cannot trade the other user because they are already in trade with someone else.");
                    }
                    if (callback.Response == EEconTradeResponse.Timeout)
                    {
                        TradeResponse(callback.OtherClient, "did not respond to the trade request.");
                    }
                    if (callback.Response == EEconTradeResponse.TooSoon)
                    {
                        TradeResponse(callback.OtherClient, "It is too soon to send a new trade request. Try again later.");
                    }
                    if (callback.Response == EEconTradeResponse.TradeBannedInitiator)
                    {
                        TradeResponse(callback.OtherClient, "You are trade-banned and cannot trade.");
                    }
                    if (callback.Response == EEconTradeResponse.TradeBannedTarget)
                    {
                        TradeResponse(callback.OtherClient, "You cannot trade with this person because they are trade-banned.");
                    }
                    if (callback.Response == EEconTradeResponse.NotLoggedIn)
                    {
                        TradeResponse(callback.OtherClient, "Trade failed to initialize because you are not logged in.");
                    }
                    CloseTrade();
                }
            });
            #endregion

            #region Disconnect
            msg.Handle <SteamUser.LoggedOffCallback> (callback =>
            {
                IsLoggedIn = false;
                log.Warn("Logged Off: " + callback.Result);
            });

            msg.Handle <SteamClient.DisconnectedCallback> (callback =>
            {
                IsLoggedIn = false;
                CloseTrade();
                log.Warn("Disconnected from Steam Network!");
                main.Invoke((Action)(() =>
                {
                    main.label_status.Text = "Disconnected from Steam Network! Retrying...";
                }));
                SteamClient.Connect();
                main.Invoke((Action)(() =>
                {
                    main.label_status.Text = "Connecting to Steam...";
                }));
            });
            #endregion

            if (!hasrun && IsLoggedIn)
            {
                Thread main = new Thread(GUI);
                main.Start();
                hasrun = true;
            }
        }
Ejemplo n.º 35
0
 public void TestMethod1()
 {
     System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"C:\Users\user\Downloads\shot.wav");
     player.Play();
     Assert.IsTrue(player != null);
 }
Ejemplo n.º 36
0
        public void gameTime_Tick(object sender, EventArgs e)
        {
            if (playTime > 0)
            {
                playTime--;
                gameCountDownBeforeStart.Text = playTime.ToString();

                if (btnImage1.IsEnabled == false && btnImage2.IsEnabled == false && btnImage3.IsEnabled == false && btnImage4.IsEnabled == false &&
                    btnImage5.IsEnabled == false && btnImage6.IsEnabled == false && btnImage7.IsEnabled == false && btnImage8.IsEnabled == false &&
                    btnImage9.IsEnabled == false && btnImage10.IsEnabled == false && btnImage11.IsEnabled == false && btnImage12.IsEnabled == false &&
                    btnImage13.IsEnabled == false && btnImage14.IsEnabled == false && btnImage15.IsEnabled == false && btnImage16.IsEnabled == false &&
                    btnImage17.IsEnabled == false && btnImage18.IsEnabled == false && btnImage19.IsEnabled == false && btnImage20.IsEnabled == false &&
                    btnImage21.IsEnabled == false && btnImage22.IsEnabled == false && btnImage23.IsEnabled == false && btnImage24.IsEnabled == false)
                {
                    gameTime.Stop();

                    System.IO.Stream         gameWinStream = Properties.Resources.gameWin;
                    System.Media.SoundPlayer gameWinPlayer = new System.Media.SoundPlayer(gameWinStream);
                    gameWinPlayer.Play();
                    GameWin main = new GameWin();
                    App.Current.MainWindow = main;
                    main.Show();
                }
                else if (playTime == 0)
                {
                    btnImage1.IsEnabled             = false;
                    btnImage2.IsEnabled             = false;
                    btnImage3.IsEnabled             = false;
                    btnImage4.IsEnabled             = false;
                    btnImage5.IsEnabled             = false;
                    btnImage6.IsEnabled             = false;
                    btnImage8.IsEnabled             = false;
                    btnImage9.IsEnabled             = false;
                    btnImage10.IsEnabled            = false;
                    btnImage11.IsEnabled            = false;
                    btnImage12.IsEnabled            = false;
                    btnImage13.IsEnabled            = false;
                    btnImage14.IsEnabled            = false;
                    btnImage15.IsEnabled            = false;
                    btnImage16.IsEnabled            = false;
                    btnImage17.IsEnabled            = false;
                    btnImage18.IsEnabled            = false;
                    btnImage19.IsEnabled            = false;
                    btnImage20.IsEnabled            = false;
                    btnImage21.IsEnabled            = false;
                    btnImage22.IsEnabled            = false;
                    btnImage23.IsEnabled            = false;
                    btnImage24.IsEnabled            = false;
                    gameCountDownBeforeStart.Text   = "";
                    gameCountDownPlay.TextAlignment = TextAlignment.Center;
                    gameCountDownPlay.Foreground    = new SolidColorBrush(Colors.Red);
                    gameCountDownPlay.Text          = "Joc terminat";

                    GameOver main = new GameOver();
                    App.Current.MainWindow = main;
                    main.Show();

                    System.IO.Stream         gameOverStream = Properties.Resources.gameOver;
                    System.Media.SoundPlayer gameOverPlayer = new System.Media.SoundPlayer(gameOverStream);
                    gameOverPlayer.Play();
                }
            }
        }
Ejemplo n.º 37
0
 // Player Matt radio button
 private void RBmatt_CheckedChanged(object sender, EventArgs e)
 {
     click.Play();
     maximumbetlbl(punters[0].money); // maximum bet
 }
Ejemplo n.º 38
0
 public void playListen()
 {
     System.Media.SoundPlayer wavListen = new System.Media.SoundPlayer();
     wavListen.SoundLocation = @".\Listen.wav";
     wavListen.Play();
 }
Ejemplo n.º 39
0
 public void playPRoll()
 {
     System.Media.SoundPlayer pRoll = new System.Media.SoundPlayer();
     pRoll.SoundLocation = @".\PRoll.wav";
     pRoll.Play();
 }
Ejemplo n.º 40
0
 private void btnAudio_Click(object sender, EventArgs e)
 {
     System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"C:\LEA by DELAN\LEA by DELAN\Resources\AUD6.wav");
     player.Play();
 }
Ejemplo n.º 41
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            rack.Left = Cursor.Position.X;

            boll.Left += fart_horisontell;                                                                                   //Gör så att "bollen" rör sig från början.
            boll.Top  += fart_upp;                                                                                           // -II-

            if (boll.Bottom >= rack.Top && boll.Bottom <= rack.Bottom && boll.Left >= rack.Left && boll.Right <= rack.Right) //Gör så att bollen får mer fart per studs,                                                                                                                            //samt att den fastnar i botten då man förlorar (så att den inte bara fortsätter att åka i "oändlighet".
            {
                fart_upp         += 2;
                fart_horisontell += 2;
                poäng            += 1;
                lblPoäng.Text     = "Oliverskrik: " + poäng;
                fart_upp          = -fart_upp; //Ändrar riktningen på "bollen" så att den studsar uppåt istället för att fortsätta nedåt.
                if (mute == false)
                {
                    System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"c:\Pong\oliverhoppG.wav");
                    player.Play();
                }
                else
                {
                    System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"c:\Pong\oliverhoppG.wav");
                    player.Stop();
                }
            }
            if (boll.Left <= spelplan.Left)
            {
                fart_horisontell = -fart_horisontell; //Vid varje studs mot en vägg måste riktningen ändras.
            }
            if (boll.Right >= spelplan.Right)
            {
                fart_horisontell = -fart_horisontell; //Vid varje studs mot en vägg måste riktningen ändras.
            }
            if (boll.Top <= spelplan.Top)
            {
                fart_upp = -fart_upp;           //Vid varje studs mot en vägg måste riktningen ändras.
            }
            if (boll.Bottom >= spelplan.Bottom) //Då bollen rör golvet är spelet över.
            {
                liv--;
                boll.Left        = slump.Next(10, 1001);
                boll.Top         = 60;
                fart_horisontell = slump.Next(-5, 11);
                fart_upp         = slump.Next(-5, 11);
                timer1.Enabled   = true;
                lblMeny.Visible  = false;
                lblPoäng.Text    = "Oliverskrik: " + poäng;
                if (mute == false)
                {
                    System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"c:\Pong\Roblox.wav");
                    player.Play();
                }
            }
            if (liv == 3)
            {
                liv1PCB.Visible = true;
                liv2PCB.Visible = true;
                liv3PCB.Visible = true;
            }
            else if (liv == 2)
            {
                liv1PCB.Visible = true;
                liv2PCB.Visible = true;
                liv3PCB.Visible = false;
            }
            else if (liv == 1)
            {
                liv1PCB.Visible = true;
                liv2PCB.Visible = false;
                liv3PCB.Visible = false;
            }
            else if (liv == 0)
            {
                liv1PCB.Visible = false;
                liv2PCB.Visible = false;
                liv3PCB.Visible = false;
                timer1.Enabled  = false;

                lblMeny.Visible  = true; //Visa "menyn" då spelet är över.
                lblMeny.Text     = "ESC - Stäng av " + "\n" + " R - Starta om" + "\n" + " Z - Lycka till " + "\n" + " M - Stäng av ljud ";
                lblPoäng.Visible = false;
                rack.Visible     = false;
                boll.Visible     = false;
                if (mute == false)
                {
                    System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"c:\Pong\TadaOliver123.wav");
                    player.Play();
                    spelplan.BackgroundImage = Pong.Properties.Resources.oliverxd;
                }
                else if (mute == true)
                {
                    spelplan.BackgroundImage = Pong.Properties.Resources.OliverChill;
                }
            }
            if (poäng % 2 == 0) //Då poängen är jämn så visas bollen som "oliverjackshitmannen.jpg" och när poängen är udda visas bollen som "oliver3.jpg".
            {
                boll.Image = Pong.Properties.Resources.oliverjackshitmannen;
            }
            else
            {
                boll.Image = Pong.Properties.Resources.oliver3;
            }
        }
Ejemplo n.º 42
0
 public MainForm()
 {
     InitializeComponent(); //  form initilize
     RaceTrack();           // race track function
     sound.Play();          // sound play
 }
Ejemplo n.º 43
0
        private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN)
            {
                int vkCode = Marshal.ReadInt32(lParam);
                Console.WriteLine((Keys)vkCode + "   " + vkCode + "    " + lParam);
                System.Media.SoundPlayer myPlayer = new System.Media.SoundPlayer();
                switch (vkCode)
                {
                case 65:      // A Yaw left
                    myPlayer.SoundLocation = @"C:\Users\jsquared\Desktop\KSP\ConsoleApp1\SoundMedia\YawUp.wav";
                    myPlayer.Play();
                    break;

                case 68:     // D Yaw right
                    myPlayer.SoundLocation = @"C:\Users\jsquared\Desktop\KSP\ConsoleApp1\SoundMedia\YawRight.wav";
                    myPlayer.Play();
                    break;

                case 83:     // S PitchUp
                    myPlayer.SoundLocation = @"C:\Users\jsquared\Desktop\KSP\ConsoleApp1\SoundMedia\pitchUp.wav";
                    myPlayer.Play();
                    break;

                case 87:     // W PitchDown
                    myPlayer.SoundLocation = @"C:\Users\jsquared\Desktop\KSP\ConsoleApp1\SoundMedia\pitchDown.wav";
                    myPlayer.Play();
                    break;

                case 160:     // LeftShift Throddle up
                    myPlayer.SoundLocation = @"C:\Users\jsquared\Desktop\KSP\ConsoleApp1\SoundMedia\throttleUp.wav";
                    myPlayer.Play();
                    break;

                case 162:     // Leftcontrol Throddle down
                    myPlayer.SoundLocation = @"C:\Users\jsquared\Desktop\KSP\ConsoleApp1\SoundMedia\throttleDown.wav";
                    myPlayer.Play();
                    break;

                case 77:     // Map
                    myPlayer.SoundLocation = @"C:\Users\jsquared\Desktop\KSP\ConsoleApp1\SoundMedia\map.wav";
                    myPlayer.Play();
                    break;

                case 20:     // Precise Controls
                    myPlayer.SoundLocation = @"C:\Users\jsquared\Desktop\KSP\ConsoleApp1\SoundMedia\Pcontrol.wav";
                    myPlayer.Play();
                    break;

                case 46:     // Delete Part
                    myPlayer.SoundLocation = @"C:\Users\jsquared\Desktop\KSP\ConsoleApp1\SoundMedia\RemovePart.wav";
                    myPlayer.Play();
                    break;

                case 88:     // cut throt
                    myPlayer.SoundLocation = @"C:\Users\jsquared\Desktop\KSP\ConsoleApp1\SoundMedia\cutThrottle.wav";
                    myPlayer.Play();
                    break;
                }
            }
            return(CallNextHookEx(hookId, nCode, wParam, lParam));
        }
Ejemplo n.º 44
0
 public void playNewTitanic()
 {
     System.Media.SoundPlayer newTitanic = new System.Media.SoundPlayer("../../sounds/titanic.wav");
     newTitanic.Play();
     newTitanic.Dispose();
 }
Ejemplo n.º 45
0
 public void playPwin()
 {
     System.Media.SoundPlayer pWin = new System.Media.SoundPlayer();
     pWin.SoundLocation = @".\Pwin.wav";
     pWin.Play();
 }
Ejemplo n.º 46
0
 public void playSecret()
 {
     System.Media.SoundPlayer wavSecret = new System.Media.SoundPlayer();
     wavSecret.SoundLocation = @".\Secret.wav";
     wavSecret.Play();
 }
Ejemplo n.º 47
0
 public void playCRoll()
 {
     System.Media.SoundPlayer cRoll = new System.Media.SoundPlayer();
     cRoll.SoundLocation = @".\CRoll.wav";
     cRoll.Play();
 }
Ejemplo n.º 48
0
 public void playUp()
 {
     System.Media.SoundPlayer wavUp = new System.Media.SoundPlayer();
     wavUp.SoundLocation = @".\Up.wav";
     wavUp.Play();
 }
Ejemplo n.º 49
0
        private void tf()
        {
            //時報判定用時刻(Hourのみ)を取得

            //必要な関数を宣言
            DateTime dt = DateTime.Now;

            //int型のh変数へ時刻(Hourのみを挿入)
            h = dt.Hour;


            if (h != checkTime)
            {
                //時報時にエラーが起きたら下記のコードを有効化
                //timer1の一時停止
                timer1.Enabled = false;

                if (MuteCHK == true)
                {
                    switch (h)
                    {
                    case 1:
                        //1時のときのボイスを指定
                        System.IO.Stream         strm1   = Properties.Resources._1;
                        System.Media.SoundPlayer player1 = new System.Media.SoundPlayer(strm1);

                        player1.Play();
                        player1.Dispose();

                        break;

                    case 2:
                        //2時のときのボイスを指定
                        System.IO.Stream         strm2   = Properties.Resources._2;
                        System.Media.SoundPlayer player2 = new SoundPlayer(strm2);

                        player2.Play();

                        player2.Dispose();

                        break;

                    case 3:
                        //3時のときのボイスを指定
                        System.IO.Stream         strm3   = Properties.Resources._3;
                        System.Media.SoundPlayer player3 = new SoundPlayer(strm3);
                        player3.Play();
                        player3.Dispose();

                        break;

                    case 4:
                        //4時のときのボイスを指定
                        System.IO.Stream         strm4   = Properties.Resources._4;
                        System.Media.SoundPlayer player4 = new SoundPlayer(strm4);
                        player4.Play();

                        player4.Dispose();

                        break;


                    case 5:
                        //5時のときのボイスを指定
                        System.IO.Stream         strm5   = Properties.Resources._5;
                        System.Media.SoundPlayer player5 = new SoundPlayer(strm5);
                        player5.Play();
                        player5.Dispose();

                        break;

                    case 6:
                        //6時のときのボイスを指定
                        System.IO.Stream         strm6   = Properties.Resources._6;
                        System.Media.SoundPlayer player6 = new SoundPlayer(strm6);
                        player6.Play();
                        player6.Dispose();

                        break;

                    case 7:
                        //7時のときのボイスを指定
                        System.IO.Stream         strm7   = Properties.Resources._7;
                        System.Media.SoundPlayer player7 = new SoundPlayer(strm7);
                        player7.Play();
                        player7.Dispose();

                        break;

                    case 8:
                        //8時のときのボイスを指定
                        System.IO.Stream         strm8   = Properties.Resources._8;
                        System.Media.SoundPlayer player8 = new SoundPlayer(strm8);
                        player8.Play();
                        player8.Dispose();

                        break;

                    case 9:
                        //9時のときのボイスを指定
                        System.IO.Stream         strm9   = Properties.Resources._9;
                        System.Media.SoundPlayer player9 = new SoundPlayer(strm9);
                        player9.Play();
                        player9.Dispose();

                        break;

                    case 10:
                        //10時のときのボイスを指定
                        System.IO.Stream         strm10   = Properties.Resources._10;
                        System.Media.SoundPlayer player10 = new SoundPlayer(strm10);
                        player10.Play();
                        player10.Dispose();

                        break;

                    case 11:
                        //11時のときのボイスを指定
                        System.IO.Stream         strm11   = Properties.Resources._11;
                        System.Media.SoundPlayer player11 = new SoundPlayer(strm11);
                        player11.Play();
                        player11.Dispose();

                        break;

                    case 12:
                        //12時のときのボイスを指定
                        System.IO.Stream         strm12   = Properties.Resources._12;
                        System.Media.SoundPlayer player12 = new SoundPlayer(strm12);
                        player12.Play();
                        player12.Dispose();

                        break;

                    case 13:
                        //13時のときのボイスを指定
                        System.IO.Stream         strm13   = Properties.Resources._13;
                        System.Media.SoundPlayer player13 = new SoundPlayer(strm13);
                        player13.Play();
                        player13.Dispose();

                        break;

                    case 14:
                        //14時のときのボイスを指定
                        System.IO.Stream         strm14   = Properties.Resources._14;
                        System.Media.SoundPlayer player14 = new SoundPlayer(strm14);
                        player14.Play();
                        player14.Dispose();

                        break;

                    case 15:
                        //15時のときのボイスを指定
                        System.IO.Stream         strm15   = Properties.Resources._15;
                        System.Media.SoundPlayer player15 = new SoundPlayer(strm15);
                        player15.Play();
                        player15.Dispose();

                        break;

                    case 16:
                        //16時のときのボイスを指定
                        System.IO.Stream         strm16   = Properties.Resources._16;
                        System.Media.SoundPlayer player16 = new SoundPlayer(strm16);
                        player16.Play();
                        player16.Dispose();

                        break;

                    case 17:
                        //17時のときのボイスを指定
                        System.IO.Stream         strm17   = Properties.Resources._17;
                        System.Media.SoundPlayer player17 = new SoundPlayer(strm17);
                        player17.Play();
                        player17.Dispose();

                        break;

                    case 18:
                        //18時のときのボイスを指定
                        System.IO.Stream         strm18   = Properties.Resources._18;
                        System.Media.SoundPlayer player18 = new SoundPlayer(strm18);
                        player18.Play();
                        player18.Dispose();

                        break;

                    case 19:
                        //19時のときのボイスを指定
                        System.IO.Stream         strm19   = Properties.Resources._19;
                        System.Media.SoundPlayer player19 = new SoundPlayer(strm19);
                        player19.Play();
                        player19.Dispose();

                        break;

                    case 20:
                        //20時のときのボイスを指定
                        System.IO.Stream         strm20   = Properties.Resources._20;
                        System.Media.SoundPlayer player20 = new SoundPlayer(strm20);
                        player20.Play();
                        player20.Dispose();

                        break;

                    case 21:
                        //21時のときのボイスを指定
                        System.IO.Stream         strm21   = Properties.Resources._21;
                        System.Media.SoundPlayer player21 = new SoundPlayer(strm21);
                        player21.Play();
                        player21.Dispose();

                        break;

                    case 22:
                        //22時のときのボイスを指定
                        System.IO.Stream         strm22   = Properties.Resources._22;
                        System.Media.SoundPlayer player22 = new SoundPlayer(strm22);
                        player22.Play();
                        player22.Dispose();

                        break;

                    case 23:
                        //23時のときのボイスを指定
                        System.IO.Stream         strm23   = Properties.Resources._23;
                        System.Media.SoundPlayer player23 = new SoundPlayer(strm23);
                        player23.Play();
                        player23.Dispose();

                        break;

                    case 0:
                        //24時のときのボイスを指定
                        System.IO.Stream         strm24   = Properties.Resources._0;
                        System.Media.SoundPlayer player24 = new SoundPlayer(strm24);
                        player24.Play();
                        player24.Dispose();

                        break;
                        //お疲れ様でした(;´∀`)
                    }//switchの終わり
                }
                //ifでfalseだった場合、switch処理後にhを同期
                checkTime = h;
                //再開用
                timer1.Enabled = true;
            } //ifの終わり
        }     //tfの終わり
 private void giris_btn_Click(object sender, EventArgs e)
 {
     sound.Play();
 }
Ejemplo n.º 51
0
 public void playNewSkiff()
 {
     System.Media.SoundPlayer newSkiff = new System.Media.SoundPlayer("../../sounds/cartmanrespect.wav");
     newSkiff.Play();
     newSkiff.Dispose();
 }
Ejemplo n.º 52
0
        private void timer2_Tick(object sender, EventArgs e)
        {
            //This code for Connet with realtime

            /*bsys.Text = RealTime.passingtext1;
             * bdia.Text = RealTime.passingtext2;
             * bpul.Text = RealTime.passingtext3;
             * bbre.Text = RealTime.passingtext4;
             * btem.Text = RealTime.passingtext5;
             * pid.Text = RealTime.passingtext6;*/

            bsrandomnum = random.Next(85, 145);
            bdrandomnum = random.Next(65, 100);
            prandomnum  = random.Next(65, 75);
            brandomnum  = random.Next(12, 20);
            trandomnum  = random.Next(36, 37);
            bsys.Text   = bsrandomnum.ToString();
            bdia.Text   = bdrandomnum.ToString();
            bpul.Text   = prandomnum.ToString();
            bbre.Text   = brandomnum.ToString();
            btem.Text   = trandomnum.ToString();

            int bsyst = int.Parse(bsys.Text);
            int bdiat = int.Parse(bdia.Text);
            int bpult = int.Parse(bpul.Text);
            int bbret = int.Parse(bbre.Text);
            int btemt = int.Parse(btem.Text);

            int sysmin = int.Parse(sysMin.Text);
            int sysmax = int.Parse(sysMax.Text);
            int diamin = int.Parse(diaMin.Text);
            int diamax = int.Parse(diaMax.Text);
            int pulmin = int.Parse(pulMin.Text);
            int pulmax = int.Parse(pulMax.Text);
            int bremin = int.Parse(breMin.Text);
            int bremax = int.Parse(breMax.Text);
            int temmin = int.Parse(temMin.Text);
            int temmax = int.Parse(temMax.Text);

            if (bsyst <= sysmin || bsyst >= sysmax)
            {
                bcolor.BackColor = Color.Red;
                SoundPlayer player1 = new System.Media.SoundPlayer(Properties.Resources.Alarm);
                player1.Play();

                DatabaseConnertor databaseConnertor = new DatabaseConnertor();
                databaseConnertor.connect();

                active active = new active();
                active.Bed_number         = int.Parse(bedNo.Text);
                active.Emergency_datetime = DateTime.Parse(lbDateTime.Text);
                active.Systolic           = int.Parse(bsys.Text);

                activeHandler activeHandler = new activeHandler();
                int           recordCnt1    = activeHandler.addActive(databaseConnertor.getconn(), active);
            }
            else if (bdiat <= diamin || bdiat >= diamax)
            {
                bcolor.BackColor = Color.Red;
                SoundPlayer player1 = new System.Media.SoundPlayer(Properties.Resources.Alarm);
                player1.Play();

                DatabaseConnertor databaseConnertor = new DatabaseConnertor();
                databaseConnertor.connect();

                active active = new active();
                active.Bed_number         = int.Parse(bedNo.Text);
                active.Emergency_datetime = DateTime.Parse(lbDateTime.Text);
                active.Diastolic          = int.Parse(bdia.Text);

                activeHandler activeHandler = new activeHandler();
                int           recordCnt1    = activeHandler.addActive(databaseConnertor.getconn(), active);
            }
            else if (bpult <= pulmin || bpult >= pulmax)
            {
                bcolor.BackColor = Color.Red;
                SoundPlayer player1 = new System.Media.SoundPlayer(Properties.Resources.Alarm);
                player1.Play();

                DatabaseConnertor databaseConnertor = new DatabaseConnertor();
                databaseConnertor.connect();

                active active = new active();
                active.Bed_number         = int.Parse(bedNo.Text);
                active.Emergency_datetime = DateTime.Parse(lbDateTime.Text);
                active.Pulse = int.Parse(bpul.Text);

                activeHandler activeHandler = new activeHandler();
                int           recordCnt1    = activeHandler.addActive(databaseConnertor.getconn(), active);
            }
            else if (bbret <= bremin || bbret >= bremax)
            {
                bcolor.BackColor = Color.Red;
                SoundPlayer player1 = new System.Media.SoundPlayer(Properties.Resources.Alarm);
                player1.Play();

                DatabaseConnertor databaseConnertor = new DatabaseConnertor();
                databaseConnertor.connect();

                active active = new active();
                active.Bed_number         = int.Parse(bedNo.Text);
                active.Emergency_datetime = DateTime.Parse(lbDateTime.Text);
                active.Breathing          = int.Parse(bbre.Text);

                activeHandler activeHandler = new activeHandler();
                int           recordCnt1    = activeHandler.addActive(databaseConnertor.getconn(), active);
            }
            else if (btemt <= temmin || btemt >= temmax)
            {
                bcolor.BackColor = Color.Red;
                SoundPlayer player1 = new System.Media.SoundPlayer(Properties.Resources.Alarm);
                player1.Play();

                DatabaseConnertor databaseConnertor = new DatabaseConnertor();
                databaseConnertor.connect();

                active active = new active();
                active.Bed_number         = int.Parse(bedNo.Text);
                active.Emergency_datetime = DateTime.Parse(lbDateTime.Text);
                active.Temperature        = int.Parse(btem.Text);

                activeHandler activeHandler = new activeHandler();
                int           recordCnt1    = activeHandler.addActive(databaseConnertor.getconn(), active);
            }
            else
            {
                bcolor.BackColor = Color.Green;
            }
        }
Ejemplo n.º 53
0
 public void playTorpedoFire()
 {
     System.Media.SoundPlayer torpedo = new System.Media.SoundPlayer("../../sounds/torpedoKort.wav");
     torpedo.Play();
     torpedo.Dispose();
 }
Ejemplo n.º 54
0
 public void playNewFerry()
 {
     System.Media.SoundPlayer newFerry = new System.Media.SoundPlayer("../../sounds/ferry.wav");
     newFerry.Play();
     newFerry.Dispose();
 }
Ejemplo n.º 55
0
        public BattleBot PromptUserForBot(int highScore)
        {
            OpenSFX.Play();
            // Plays Sound
            Console.WriteLine("\n Version 42.069");
            Console.WriteLine("\n Copyright (©) The Pokemon Company 2019");
            Console.WriteLine("\n Copyright (©) Nintendo 2019");
            Console.WriteLine("\n Copyright (©) MrLettsGiveUseAnA.Inc 2019\n");

            Console.WriteLine("Do you want to enable the reading out of all the text?");
            if (Console.ReadLine().Trim().ToLower()[0] != 'y')
            {
                SpeakingConsole.EnableSpeaking = false;
            }
            OpenSFX.Stop();
            MeetOakSFX.PlayLooping();
            Console.ForegroundColor = ConsoleColor.DarkYellow;
            SpeakingConsole.WriteLine("Welcome to Rock Paper Scissors Lizard Spock");
            Console.WriteLine("\n Press Enter...");
            Console.ReadLine();

            Console.WriteLine("\n ...");
            Console.ReadLine();
            SpeakingConsole.WriteLine("\n  Opps, Wrong Program..");
            Console.ReadLine();
            SpeakingConsole.WriteLine("\n Welcome to Battle Bots");
            Console.ReadLine();
            SpeakingConsole.WriteLine("\n This is a Battle to the Dea... err of the Pokemon ");
            Console.ReadLine();
            SpeakingConsole.WriteLine("\n My name is Professor Oak, Welcome to the World of Pokemon");
            Console.ReadLine();
            Console.WriteLine("\n This world is inhabited by creatures called pokémon!");
            Console.WriteLine("\n For some people, pokémon are pets. Others use them for fights.");
            Console.WriteLine("\n Myself...I study pokémon as a profession.");
            Console.ReadLine();
            Console.ForegroundColor = ConsoleColor.White;
            SpeakingConsole.WriteLine("\n Professor Oak: what is your Name?");

            string strName = SpeakingConsole.ReadLine();



            SpeakingConsole.WriteLine("\n Please choose a Pokemon:");

            //foreach (string weapon in WEAPONS)
            //{
            //string[] beatableWeapons = Array.FindAll(WEAPONS, w => CanBeat(weapon, w));
            //SpeakingConsole.WriteLine("\n" + weapon + " Beats " + String.Join(" And ", beatableWeapons));
            //}

            ///////////////////////////////////////////////////////////////////////
            //Console.WriteLine("\n Please type your Choice of Pokemon:");
            //Console.ForegroundColor = ConsoleColor.Yellow;
            //Console.WriteLine("\n Pikachu: Electric");
            //Console.WriteLine("\n     Strengths: Squirtle and Pidgey");
            //Console.WriteLine("\n     Weekness: Geodude and Swadloon");

            //Console.ForegroundColor = ConsoleColor.Blue;
            //Console.WriteLine("\n Squirtle: Water");
            //Console.WriteLine("\n     Strengths: Swadloon and Geodude");
            //Console.WriteLine("\n     Weekness: Pickachu and Pidgey");

            //Console.ForegroundColor = ConsoleColor.DarkRed;
            //Console.WriteLine("\n Charmander: Fire");
            //Console.WriteLine("\n     Strengths: Squirtle and Swadloon");
            //Console.WriteLine("\n     Weekness: Pickachu and Geodude");

            //Console.ForegroundColor = ConsoleColor.Gray;
            //Console.WriteLine("\n Geodude: Rock/Ground");
            //Console.WriteLine("\n     Strengths: Pikachu and Pidgey");
            //Console.WriteLine("\n     Weekness: Swadloon and Squirtle");

            //Console.ForegroundColor = ConsoleColor.Green;
            //Console.WriteLine("\n Bulbasaur: Grass");
            //Console.WriteLine("\n     Strengths: Geodude and Pikachu");
            //Console.WriteLine("\n     Weekness: Squirtle and Pidgey");

            SpeakingConsole.WriteLine("\nPlease choose a Pokemon from the following:");

            foreach (string weapon in WEAPONS)
            {
                string[] beatableWeapons   = Array.FindAll(WEAPONS, w => CanBeat(weapon, w));
                string[] unbeatableWeapons = Array.FindAll(WEAPONS, w => (!CanBeat(weapon, w)) && w != weapon);

                Console.ForegroundColor = GetColorForWeapon(weapon);
                SpeakingConsole.WriteLine("\n " + weapon + ": " + GetTypeForWeapon(weapon));
                SpeakingConsole.WriteLine("\n     Strengths: " + string.Join(" And ", beatableWeapons));
                SpeakingConsole.WriteLine("\n     Weekness: " + string.Join(" And ", unbeatableWeapons));
            }
            Console.ForegroundColor = ConsoleColor.White;


            //////////////////////////////////////////////////////////////////

            string strWeapon;

            while (((strWeapon = SpeakingConsole.ReadLine()) == "" || !IsValidWeapon(strWeapon)) && strName != "")
            {
                SpeakingConsole.WriteLine("Please enter a valid weapon from above");
            }
            MeetOakSFX.Stop();

            timer.Start();
            intTimeSinceGameStart = 0;
            BattleBot result;

            if (IsValidWeapon(strWeapon))
            {
                if (strName != "")
                {
                    result = new BattleBot(strName, GetValidWeaponName(strWeapon));
                }
                else
                {
                    result = new BattleBot(GetValidWeaponName(strWeapon));
                }
            }
            else
            {
                result = new BattleBot();
            }
            result.UpdateHighScore(highScore);
            return(result);
        }
Ejemplo n.º 56
0
 public void playReloading()
 {
     System.Media.SoundPlayer reloading = new System.Media.SoundPlayer("../../sounds/reloading.wav");
     reloading.Play();
     reloading.Dispose();
 }
Ejemplo n.º 57
0
 // L'evenement se déclenche au chargement de la page
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     GameMusic.Play();
 }
Ejemplo n.º 58
0
 public void playExplosionSound()
 {
     System.Media.SoundPlayer explosion = new System.Media.SoundPlayer("../../sounds/explosion.wav");
     explosion.Play();
     explosion.Dispose();
 }
Ejemplo n.º 59
0
        private void alientimer_Tick(object sender, EventArgs e)
        {
            foreach (PictureBox bullet in bullets)
            {
                bullet.Location = new Point(bullet.Location.X, bullet.Location.Y - int.Parse((string)bullet.Tag));
                if (level == 1)
                {
                    foreach (PictureBox enemy in listghost)
                    {
                        if (enemy.Visible)
                        {
                            if (doesHit(bullet, enemy))
                            {
                                soundplayer.Play();
                                score          += 50;
                                scorelabel.Text = score.ToString();
                                enemycount--;
                                totalkills++;
                                enemy.Visible    = false;
                                coins           += 25;
                                balancegame.Text = coins.ToString();

                                if (enemycount == 0)
                                {
                                    acceptinput = false;
                                    actions.Add(dir + " " + rep);
                                    dir             = "none";
                                    rep             = 0;
                                    timer.Enabled   = false;
                                    winmessage.Text = "Level up: 2";
                                    panel77.Visible = true;
                                }
                            }
                        }
                    }
                }
                else if (level == 2)
                {
                    foreach (PictureBox enemy in listhuman)
                    {
                        if (enemy.Visible)
                        {
                            if (doesHit(bullet, enemy))
                            {
                                soundplayer.Play();
                                score          += 50;
                                scorelabel.Text = score.ToString();
                                enemycount--;
                                totalkills++;
                                enemy.Visible    = false;
                                coins           += 25;
                                balancegame.Text = coins.ToString();

                                if (enemycount == 0)
                                {
                                    acceptinput     = false;
                                    timer.Enabled   = false;
                                    winmessage.Text = "Level up: 3";
                                    panel77.Visible = true;
                                }
                            }
                        }
                    }
                }
                else if (level == 3)
                {
                    foreach (PictureBox enemy in listhuman)
                    {
                        if (enemy.Visible)
                        {
                            if (doesHit(bullet, enemy))
                            {
                                soundplayer.Play();
                                score          += 50;
                                scorelabel.Text = score.ToString();
                                enemycount--;
                                totalkills++;
                                enemy.Visible    = false;
                                coins           += 25;
                                balancegame.Text = coins.ToString();

                                if (enemycount == 0)
                                {
                                    acceptinput     = false;
                                    timer.Enabled   = false;
                                    winmessage.Text = "YOU WIN!";
                                    panel77.Visible = true;
                                    foreach (PictureBox b in bulletshuman)
                                    {
                                        b.Dispose();
                                    }
                                    bulletshuman.Clear();
                                }
                            }
                        }
                    }
                }
            }
            if (totalkills == 3)
            {
                alien2.Visible = true;
                label6.Visible = true;
            }
            else if (totalkills == 6)
            {
                alien3.Visible = true;
                label7.Visible = true;
            }
            else if (totalkills == 9)
            {
                alien4.Visible = true;
                label8.Visible = true;
            }
            else if (totalkills == 12)
            {
                alien5.Visible = true;
                label9.Visible = true;
            }
            else if (totalkills == 15)
            {
                alien6.Visible  = true;
                label10.Visible = true;
            }
        }
Ejemplo n.º 60
0
        public void Battle(ref BattleBot battleBot)
        {
            if (!blnIsBattleSoundPlaying)
            {
                BattleSFX.PlayLooping();
                blnIsBattleSoundPlaying = true;
            }

            if (battleBot.FuelLevel > 0 && battleBot.ConditionLevel > 0)
            {
                intBattleStartTime = intTimeSinceGameStart;
                string computerWeapon = WEAPONS[rGen.Next(WEAPONS.Length)];
                //////////////////////////////////
                Console.ForegroundColor = GetColorForWeapon(battleBot.Weapon);
                Console.WriteLine("███████████████████████████");
                SpeakingConsole.WriteLine("\n\t\t" + battleBot.Weapon + "           ");

                Console.ForegroundColor = ConsoleColor.White;
                SpeakingConsole.WriteLine("\n\t\t----- VS -----   ");

                Console.ForegroundColor = GetColorForWeapon(computerWeapon);
                SpeakingConsole.WriteLine("\n\t\t" + computerWeapon);    // Pokemon
                Console.WriteLine("███████████████████████████");

                Console.ForegroundColor = ConsoleColor.White;
                //////////////////////////////////
                //SpeakingConsole.WriteLine("\nYou are being attacked by a " + computerWeapon + ". What do you do?");
                bool blnValidAction = false;
                char charReadKey    = '\0';
                while (!blnValidAction)
                {
                    bool blnCheatCodeWorked = false;
                    SpeakingConsole.WriteLine("\nAttack, Defend, or Retreat");
                    for (int i = 0; i < KONAMI_CODE.Length; i++)
                    {
                        ConsoleKeyInfo key = Console.ReadKey();
                        charReadKey = key.KeyChar;
                        if (key.Key != KONAMI_CODE[i])
                        {
                            break;
                        }
                        if (i == KONAMI_CODE.Length - 1)
                        {
                            battleBot.GainPoints(20);
                            SpeakingConsole.WriteLine("\nYou have cheated, trainer!! But you will get 20 extra points because that's just how the world is (unfair)");
                            PokeBallOpenSFX.PlaySync();

                            blnCheatCodeWorked = true;
                            BattleSFX.PlayLooping();
                        }
                    }
                    if (blnCheatCodeWorked)
                    {
                        continue;
                    }

                    string strAction = SpeakingConsole.SpeakAndReturn(charReadKey + Console.ReadLine());
                    switch (strAction.Trim().ToLower())
                    {
                    case "attack":
                        blnValidAction = true;
                        if (CanBeat(battleBot.Weapon, computerWeapon))
                        {
                            if (IsCriticalTo(battleBot.Weapon, computerWeapon))
                            {
                                battleBot.GainPoints(rGen.Next(6, 11));
                                SpeakingConsole.WriteLine("Professor Oak: You have critically destroyed your opponent!!");

                                //////////////////////////////////
                                ///////////////////////////////////
                                /////////////////////////////////
                            }
                            else
                            {
                                battleBot.GainPoints(5);
                                SpeakingConsole.WriteLine("Professor Oak: You have destroyed your opponent!!");
                            }
                        }
                        else
                        {
                            if (IsCriticalTo(battleBot.Weapon, computerWeapon))
                            {
                                battleBot.HandleDamage(rGen.Next(6, 11));
                                SpeakingConsole.WriteLine("Professor Oak: You have tragically lost!!");
                            }
                            else
                            {
                                battleBot.HandleDamage(5);
                                SpeakingConsole.WriteLine("Professor Oak: You have lost!!");
                            }
                        }
                        battleBot.ConsumeFuel(2 * intTimeElapsed);
                        break;

                    case "defend":
                        blnValidAction = true;
                        if (CanBeat(battleBot.Weapon, computerWeapon))
                        {
                            battleBot.GainPoints(2);
                            SpeakingConsole.WriteLine("Professor Oak: You have defended yourself like a noble man!!");
                        }
                        else
                        {
                            if (IsCriticalTo(battleBot.Weapon, computerWeapon))
                            {
                                battleBot.HandleDamage(rGen.Next(3, 5));
                                SpeakingConsole.WriteLine("Professor Oak: Whoops, your shield has completely failed!!");
                            }
                            else
                            {
                                battleBot.HandleDamage(2);
                                SpeakingConsole.WriteLine("Professor Oak: Whoops, your shield has failed!!");
                            }
                        }
                        battleBot.ConsumeFuel(intTimeElapsed);
                        break;

                    case "retreat":
                        blnValidAction = true;
                        if (rGen.Next(0, 4) == 0)
                        {
                            SpeakingConsole.WriteLine("Professor Oak: Unfortunately, you couldn't escape in time!!");
                            battleBot.HandleDamage(7);
                        }
                        else
                        {
                            SpeakingConsole.WriteLine("Professor Oak: You have succesfully escaped from the battle like a coward!! No points for you!!");
                        }
                        battleBot.ConsumeFuel(3 * intTimeElapsed);
                        break;

                    case "absorb":
                        if (battleBot.Weapon == computerWeapon)
                        {
                            blnValidAction = true;
                            SpeakingConsole.WriteLine("You have succesfully absorbed the opponent's power!! This tastes yummy OwO");
                            SpeakingConsole.WriteLine("Professor Oak: Mmmmm... Fried " + computerWeapon);
                            battleBot.Refuel(10);
                            battleBot.Heal(10);
                        }
                        break;
                    }

                    if (blnValidAction)
                    {
                        GetSoundForWeapon(battleBot.Weapon).PlaySync();
                        BattleSFX.Play();
                    }
                }
                Thread.Sleep(1000);
                SpeakingConsole.WriteLine("\nBot stats:");

                if (battleBot.Name == "PokeBall")
                {
                    Console.WriteLine("────────▄███████████▄────────");
                    Console.WriteLine("─────▄███▓▓▓▓▓▓▓▓▓▓▓███▄─────");
                    Console.WriteLine("────███▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓███────");
                    Console.WriteLine("───██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██───");
                    Console.WriteLine("──██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██──");
                    Console.WriteLine("─██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██─");
                    Console.WriteLine("██▓▓▓▓▓▓▓▓▓███████▓▓▓▓▓▓▓▓▓██");
                    Console.WriteLine("██▓▓▓▓▓▓▓▓██░░░░░██▓▓▓▓▓▓▓▓██");
                    Console.WriteLine("██▓▓▓▓▓▓▓██░░███░░██▓▓▓▓▓▓▓██");
                    Console.WriteLine("███████████░░███░░███████████");
                    Console.WriteLine("██░░░░░░░██░░███░░██░░░░░░░██");
                    Console.WriteLine("██░░░░░░░░██░░░░░██░░░░░░░░██");
                    Console.WriteLine("██░░░░░░░░░███████░░░░░░░░░██");
                    Console.WriteLine("─██░░░░░░░░░░░░░░░░░░░░░░░██─");
                    Console.WriteLine("──██░░░░░░░░░░░░░░░░░░░░░██──");
                    Console.WriteLine("───██░░░░░░░░░░░░░░░░░░░██───");
                    Console.WriteLine("────███░░░░░░░░░░░░░░░███────");
                    Console.WriteLine("─────▀███░░░░░░░░░░░███▀─────");
                    Console.WriteLine("────────▀███████████▀────────");
                }

                SpeakingConsole.WriteLine("Trainers Name: " + battleBot.Name + ",");

                // Color Desiders
                if (battleBot.Weapon == "Pickachu")
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                }
                else if (battleBot.Weapon == "Geodude")
                {
                    Console.ForegroundColor = ConsoleColor.Gray;
                }
                else if (battleBot.Weapon == "Squirtle")
                {
                    Console.ForegroundColor = ConsoleColor.Blue;
                }
                else if (battleBot.Weapon == "Swadloon")
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                }
                else if (battleBot.Weapon == "Charmander")
                {
                    Console.ForegroundColor = ConsoleColor.DarkRed;
                }



                SpeakingConsole.WriteLine("Pokemon: " + battleBot.Weapon + ",");
                Console.ForegroundColor = ConsoleColor.White;
                SpeakingConsole.WriteLine("Condition Level: " + battleBot.ConditionLevel + ",");
                SpeakingConsole.WriteLine("Power Points:" + battleBot.FuelLevel + ",\nTurn Time: " + intTimeElapsed + ",\nTotal Battle Time: " + intTimeSinceGameStart + ",\nPoints: " + battleBot.Score + ",\nHighest Score: " + battleBot.HighScore);

                SpeakingConsole.WriteLine("\n Health Left: ##");
                SpeakingConsole.WriteLine("\n Power Left: ");
                //Console.WriteLine("\n Next Move: ");

                Thread.Sleep(1000);
                Battle(ref battleBot);
            }
            else
            {
                battleBot.UpdateHighScore(battleBot.Score);
                SpeakingConsole.WriteLine("Your pokemon has lost. Do you want to play again?");
                if (SpeakingConsole.ReadLine().Trim().ToLower()[0] == 'y')
                {
                    battleBot = PromptUserForBot(battleBot.HighScore);
                    Battle(ref battleBot);
                }
            }
        }