• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Sound类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Sound的典型用法代码示例。如果您正苦于以下问题:C# Sound类的具体用法?C# Sound怎么用?C# Sound使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Sound类属于命名空间,在下文中一共展示了Sound类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Play

 public void Play(Sound sound)
 {
     if (AudioIsEnabled)
     {
         sound.SoundEffect.Play(standardVolume, 0.0f, 0.0f);
     }
 }
开发者ID:rubna,项目名称:MetroidClone,代码行数:7,代码来源:AudioWrapper.cs


示例2: Play

        public void Play(Sound sound, float fadeTime = 0f)
        {
            StopAllCoroutines();
            CachedAudioSource.Stop();

            CurrentSound = sound;
            Volume = fadeTime == 0f ? VolumeFromSettings : 0f;

            CachedAudioSource.clip = sound.audioClip;
            CachedAudioSource.loop = sound.loop;
            CachedAudioSource.pitch = Random.Range(sound.minPitch, sound.maxPitch);
            CachedAudioSource.spatialBlend = sound.spatialBlend;
            CachedAudioSource.volume = sound.volume;
            CachedAudioSource.loop = sound.loop;

            CachedAudioSource.Play();

            //TODO dont relly on this
            CachedAudioSource.spatialBlend = 0;

            if (fadeTime > 0f) SetVolumeTo(VolumeFromSettings, fadeTime);

            isPlaying = true;
            PlayEvent(this);
        }
开发者ID:Stumpstump,项目名称:RoverGame,代码行数:25,代码来源:SoundSource.cs


示例3: SoundRecord

 public SoundRecord(Sound.Type soundType, float effectiveSoundLevel, Vector3 location)
 {
     this.soundType = soundType;
     this.effectiveSoundLevel = effectiveSoundLevel;
     this.location = location;
     this.timeHeard = Time.time;
 }
开发者ID:peterwerner,项目名称:unity_fps_rpg,代码行数:7,代码来源:SoundListener.cs


示例4: initSoundConfig

 public void initSoundConfig(ContentManager content, String soundConfigFile, String musicConfigFile)
 {
     soundPrototypes = new Dictionary<String, Sound>();
     songPrototypes = new Dictionary<String, Song>();
     XDocument soundDoc = XDocument.Load(soundConfigFile);
     List<XElement> sounds = soundDoc.Element("Sounds").Elements("Sound").ToList();
     XDocument musicDoc = XDocument.Load(musicConfigFile);
     List<XElement> songs = musicDoc.Element("Songs").Elements("Song").ToList();
     String soundClass;
  
     SoundEffect effect;
     String songName;
     String songPath;
     Song actualSong;
     foreach (XElement sound in sounds)
     {
         soundClass = sound.Attribute("className").Value;
         effect = content.Load<SoundEffect>(sound.Attribute("filePath").Value);
         soundPrototypes[soundClass] = new Sound(effect);
     }
     foreach (XElement song in songs)
     {
         songName = song.Attribute("name").Value;
         songPath = song.Attribute("filePath").Value;
         actualSong = content.Load<Song>("StainedGlassAndSpookySkeletons");
         //actualSong = content.Load<Song>(song.Attribute("filepath").Value);
         songPrototypes[songName] = actualSong;
     }
 }
开发者ID:jpfeltracco,项目名称:DreamStateMachine,代码行数:29,代码来源:SoundManager.cs


示例5: Start

	void Start () {
		enabled = true;
        //find the camera object and obtain its script
        cameraObject = GameObject.Find("Main Camera");
		CameraScript = cameraObject.GetComponent<CameraFollow>();
		//initialize the object in control to be the head at first
		inControl = GameObject.Find("Player");
		ClosestLimb = FindClosestLimb();
		//collect all the objects with tags "leg" and "arm" in 
		//data structures
		Legs = GameObject.FindGameObjectsWithTag("leg");
		Arms = GameObject.FindGameObjectsWithTag("arm");
		//merge the two arrays into one

		player = GameObject.FindGameObjectWithTag("Player");
        sounds = player.GetComponent<Sound>();
        for (int i = 0; i < Legs.Length; i++) 
		{
			Limbs.Add(Legs[i]);
		}

		for (int i = 0; i < Arms.Length; i++) 
		{
			Limbs.Add(Arms[i]);
		}
	}
开发者ID:Rebind,项目名称:Master,代码行数:26,代码来源:SwitchControl.cs


示例6: SoundTrack

    private float _volumeRatio = 1; // sound volume ratio

    #endregion Fields

    #region Constructors

    /**
     * INIT soundTrack, hook up controls
     *  @param soundObject: Sound
     *  @param gameObject: GameObject
     * 	@param onCompleteHandler: Delegate
     **/
    public SoundTrack(Sound soundObject, GameObject gameObject, Delegate onCompleteHandler=null)
    {
        _soundObj = soundObject;
        _channel = gameObject.AddComponent("AudioSource") as AudioSource;
        _channel.clip = _soundObj.clip;
        _complete = onCompleteHandler;
    }
开发者ID:crl,项目名称:UniStarling,代码行数:19,代码来源:SoundTrack.cs


示例7: GetResourceName

        public static string GetResourceName(Sound sound)
        {
            if (sound == Sound.IncomingMessage)
                return "VDesktope.Content.Sounds.incoming-message.mp3";

            return "";
        }
开发者ID:ukionik,项目名称:VDesktopeNew,代码行数:7,代码来源:SoundUtil.cs


示例8: Kill

    public void Kill(bool gainExperience, bool playSound = true)
	{   
        stunTimer = 0;
		int rand = (int)UnityEngine.Random.Range(1, 40);
        if(playSound){
            if (rand == 36) {
                Sound sound = new Sound (transform.root.gameObject.GetComponent<AudioSource> (), "SFX/" + "WilhelmScream", 1f);
            } else {
                Sound sound = new Sound (transform.root.gameObject.GetComponent<AudioSource> (), "SFX/" + "Kill", 1f);
            }
        }
		
        if(gainExperience){
            PlayerManager.instance.AddExperience();
            GameObject soul = GameObject.Instantiate(SoulPrefab);
            soul.transform.position = transform.position;
        }

        Tile tile = enemyManager.GetTileOfEnemy(this);
        if(tile != null){
            tile.enemy = null;
        }

        StopAllCoroutines();
        LeanTween.cancel(gameObject);


        FallApart();
    }
开发者ID:stevengunneweg,项目名称:GGJ2016,代码行数:29,代码来源:Enemy.cs


示例9: InitializeButtonEvents

        private void InitializeButtonEvents()
        {
            DialogShowButton.ButtonAction += (sender, e) =>
            {
                CustomDialog dialog = new CustomDialog();
                dialog.Show();
            };

            PopupListShowButton.ButtonAction += (sender, e) =>
            {
                Sound se = new Sound("/Application/assets/GAME_SE_01.wav");
                sp = se.CreatePlayer();
                sp.Play();
            };

            bgmButton.ButtonAction += (sender, e) =>
            {
                if (!bgm_play)
                {
                    bp.Play();
                    bgmButton.Text = "BGMStop";
                }
                else
                {
                    bp.Pause();
                    bgmButton.Text = "BGMPlay";
                }
                bgm_play = !bgm_play;
            };
        }
开发者ID:yutanaka,项目名称:PSSuite_RD,代码行数:30,代码来源:MainScene.cs


示例10: Pause

        public Pause(TimeGuardianGame game, LevelBase level)
        {
            _level = level;
            _game = game;

            x = -500;

            Sprite background = new Sprite(UtilStrings.SpritesPause + "background_pause.png");
            background.SetOrigin(0,background.height/2);
            background.y = game.height/2;

            Sprite header = new Sprite(UtilStrings.SpritesPause + "header_pause.png");
            header.SetOrigin(header.width/2, header.height/2);
            header.SetXY(background.width/2, 200);

            _buttons = new[]
            {
            new Button(UtilStrings.SpritesPause + "button_resume.png", 2, background.width/2, 350, "Resume"),
            new Button(UtilStrings.SpritesPause + "button_restart.png", 2, background.width/2, 450, _level.GetLevelName()),
            new Button(UtilStrings.SpritesPause + "button_exit.png", 2, background.width/2, 550, "MainMenu")
            };

            AddChild(background);
            AddChild(header);
            foreach (Button button in _buttons)
            {
                AddChild(button);
            }

            _selectedSound = new Sound(UtilStrings.SoundsMenu + "sound_selected.wav");
            _openSound = new Sound(UtilStrings.SoundsMenu + "sound_pause.wav");
        }
开发者ID:mtesseracttech,项目名称:ArcadeGame,代码行数:32,代码来源:Pause.cs


示例11: SuperXbloxGame

        public SuperXbloxGame()
        {
            Content.RootDirectory = "Content";
            graphics = new GraphicsDeviceManager(this);
            graphics.PreparingDeviceSettings += new EventHandler<PreparingDeviceSettingsEventArgs>(graphics_PreparingDeviceSettings);

            mSound = new Sound(this);
            particleManager = new ParticleManager(this);
            screenManager = new ScreenManager(this);
            reticule = new Reticule(this);
            reticule2 = new Reticule(this);

            Components.Add(mSound);//0
            Components.Add(screenManager);//1
            Components.Add(particleManager);//2
            //Components.Add(reticule); //3
            //Components.Add(reticule2); //4

            //Storage.LoadSettings();
            //Components.Add(smokePlume);

            //BEGIN Xbox Live Test
            Components.Add(new GamerServicesComponent(this));//5
            //END Xbox Live TEST
        }
开发者ID:hillgr,项目名称:SuperXblox360,代码行数:25,代码来源:SuperXbloxGame.cs


示例12: LoadSound

 private static Sound LoadSound(System.IO.UnmanagedMemoryStream memoryStream)
 {
     Sound sound = new Sound();
     sound.player = new System.Media.SoundPlayer() { Stream = memoryStream };
     sound.player.Load();
     return sound;
 }
开发者ID:rlods,项目名称:PocDotNet,代码行数:7,代码来源:Sound.cs


示例13: PlaySound

 /// <summary>
 /// Plays a sound by name.
 /// </summary>
 /// <param name="soundName">The sound to play</param>
 public void PlaySound(Sound sound, bool isSoundOff, bool isPauseMusicZune)
 {
     if (isSoundOff || !isPauseMusicZune)
         return;
     // If the sound exists, start it
     sound.Play();
 }
开发者ID:doanhtdpl,项目名称:plants-vs-zombies-gameonmobile-uit-term7,代码行数:11,代码来源:AudioManager.cs


示例14: InitSound

        public static void InitSound()
        {
            stage1 = new Bgm("/Application/resourses/stage1.mp3");
            stage1boss = new Bgm("/Application/resourses/stage1boss.mp3");
            title = new Bgm("/Application/resourses/title.mp3");
            gameover = new Bgm("/Application/resourses/gameover.mp3");

            bgmPlayer = stage1.CreatePlayer();

            sound = new Sound("/Application/resourses/shot.wav");
            shot = sound.CreatePlayer();
            sound = new Sound("/Application/resourses/hidan.wav");
            hidan = sound.CreatePlayer();
            sound = new Sound("/Application/resourses/siren.wav");
            siren = sound.CreatePlayer();
            sound = new Sound("/Application/resourses/stageClear.wav");
            stageClear = sound.CreatePlayer();
            sound = new Sound("/Application/resourses/system1.wav");
            ok = sound.CreatePlayer();
            sound = new Sound("/Application/resourses/system2.wav");
            cancel = sound.CreatePlayer();
            sound = new Sound("/Application/resourses/damage.wav");
            tekihidan = sound.CreatePlayer();
            sound = new Sound("/Application/resourses/skillSE1.wav");
            skill1 = sound.CreatePlayer();
            sound = new Sound("/Application/resourses/skillSE2.wav");
            skill2 = sound.CreatePlayer();
            sound = new Sound("/Application/resourses/stageClear.wav");
            stageClear = sound.CreatePlayer();
            sound = new Sound("/Application/resourses/tick.wav");
            ticktuck = sound.CreatePlayer();
        }
开发者ID:noradium,项目名称:Black-Rins-ambition,代码行数:32,代码来源:Sound.cs


示例15: PlayEffect

    /// <summary>
    /// 指定されたエフェクト音を再生します
    /// ループするかどうかも一応指定できます
    /// </summary>
    /// <param name="effect"></param>
    public static void PlayEffect(Sound.Effect effect, bool loop = false)
    {
        if (manager == null) return;

        AudioClip clip = Sound.GetEffect(effect);
        if (clip == null) return;

        bool result = false;

        for(var i = 0;i < effectSources.Count;i++)
        {
            if (effectSources[i].isPlaying) continue;
            else
            {
                effectSources[i].clip = clip;
                effectSources[i].loop = loop;
                effectSources[i].Play();
                result = true;
                break;
            }
        }

        if(!result)
        {
            var source = manager.gameObject.AddComponent<AudioSource>();
            effectSources.Add(source);
            source.clip = clip;
            source.loop = loop;
            source.Play();
        }
    }
开发者ID:taiseiKMC,项目名称:minge-,代码行数:36,代码来源:SoundManager.cs


示例16: Add

 /// <summary>
 /// Add new empty sound to list of cached sounds
 /// </summary>
 public void Add()
 {
     Sound newSound = new Sound();
     newSound.type = soundType;
     newSound.show = true;
     sounds.Add(newSound);
 }
开发者ID:Stumpstump,项目名称:RoverGame,代码行数:10,代码来源:SoundCollection.cs


示例17: btnPlay_Click

 private void btnPlay_Click(object sender, EventArgs e)
 {
     if (channel != null && channel.IsPlaying)
         return;
     sound = fmod.CreateSound(MP3_PATH);
     channel = fmod.PlaySound(sound);
 }
开发者ID:nathanchere,项目名称:nFMOD,代码行数:7,代码来源:frmMain.cs


示例18: Update

 //UPDATE & DRAW
 public void Update(List<Player> liste_joueurs, List<IA> liste_ias, List<Projectile> liste_projectiles, Sound sons)
 {
     foreach (IA ia in liste_ias)
     {
         if (reffroidissement == 0 && munition > 0)
         {
             if (ia.IATexture.Contains((int)centre().X, (int)ia.IATexture.Y))
             {
                 if (ia.IATexture.Y < turretTexture.Y)
                     liste_projectiles.Add(new Projectile(Ressources.Projectile, (int)centre().X - 5, (int)centre().Y - 5, 10, Direction.Up, 50));
                 else
                     liste_projectiles.Add(new Projectile(Ressources.Projectile, (int)centre().X - 5, (int)centre().Y - 5, 10, Direction.Down, 50));
                 reffroidissement = 10;
                 munition--;
                 sons.PlaySentryShoot();
             }
             else if (ia.IATexture.Contains((int)ia.IATexture.X, (int)centre().Y))
             {
                 if (ia.IATexture.X < turretTexture.X)
                     liste_projectiles.Add(new Projectile(Ressources.Projectile, (int)centre().X - 5, (int)centre().Y - 5, 10, Direction.Left, 50));
                 else
                     liste_projectiles.Add(new Projectile(Ressources.Projectile, (int)centre().X - 5, (int)centre().Y - 5, 10, Direction.Right, 50));
                 reffroidissement = 10;
                 munition--;
                 sons.PlaySentryShoot();
             }
         }
     }
     if (reffroidissement > 0)
     {
         reffroidissement--;
     }
 }
开发者ID:Bm0c,项目名称:projet_SBS,代码行数:34,代码来源:Turret.cs


示例19: NewSound

 /// Creates a new sound, registers it, and gives it the properties specified
 public Sound NewSound(string soundName, bool loop=false, bool interrupts=false, Action<Sound> callback=null) {
     Sound sound = new Sound(soundName);
     RegisterSound(sound);
     sound.loop = loop;
     sound.interrupts = interrupts;
     sound.callback = callback;
     return sound;
 }
开发者ID:xiatianjin,项目名称:Tank,代码行数:9,代码来源:AudioManager.cs


示例20: Main

		static void Main() {
			Timers timers = new Timers();
			Screen screen = new Screen();
			Keyboard keyboard = new Keyboard();
			Sound sound = new Sound();
			Chip8Emulator chip8 = new Chip8Emulator(timers, screen, keyboard, sound);
			Application.Run(new MainForm(chip8));
		}
开发者ID:Q-Smith,项目名称:.NET-Chip-8,代码行数:8,代码来源:Program.cs



注:本文中的Sound类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SoundManager类代码示例发布时间:2022-05-24
下一篇:
C# SortedSet类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap