コード例 #1
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();
                }
            }
        }
コード例 #2
0
 void CheckForMoleHit()
 {
     if (Input.GetMouseButtonDown(0))
     {
         Mole mole = MoleUnderMouse();
         if (mole != null)
         {
             Debug.Log("Hit!");
             roundActive = false;
             if (mole.Letter == currentLetter)
             {
                 mole.Hit();
             }
             else
             {
                 mole.Miss();
             }
         }
     }
 }
コード例 #3
0
 /*--------------------------------------------------------------------------------
 *   Hammer_OnHitMole
 *  --------------------------------------------------------------------------------*/
 private void Hammer_OnHitMole(Mole mole)
 {
     mole.Hit();
     audioManager.PlayFx(AudioManager.AudioType.Hit, 0.15f);
     audioManager.PlayFx(AudioManager.AudioType.Point, 0.4f);
 }