当前位置: 首页>>代码示例>>C#>>正文


C# Sound类代码示例

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


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


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