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


C# GameRules.MusicInfo类代码示例

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


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

示例1: BuildMusicTable

        public void BuildMusicTable()
        {
            music = modRules.InstalledMusic.Select(a => a.Value).ToArray();
            random = music.Shuffle(Game.CosmeticRandom).ToArray();
            currentSong = Sound.CurrentMusic;
            if (currentSong == null && music.Any())
                currentSong = Game.Settings.Sound.Shuffle ? random.First() : music.First();

            musicList.RemoveChildren();
            foreach (var s in music)
            {
                var song = s;
                if (currentSong == null)
                    currentSong = song;

                // TODO: We leak the currentSong MusicInfo across map load, so compare the Filename instead.
                var item = ScrollItemWidget.Setup(song.Filename, itemTemplate, () => currentSong.Filename == song.Filename, () => { currentSong = song; Play(); }, () => {});
                item.Get<LabelWidget>("TITLE").GetText = () => song.Title;
                item.Get<LabelWidget>("LENGTH").GetText = () => SongLengthLabel(song);
                musicList.AddChild(item);
            }

            if (currentSong != null)
                musicList.ScrollToItem(currentSong.Filename);

            installed = modRules.InstalledMusic.Any();
        }
开发者ID:RunCraze,项目名称:OpenRA,代码行数:27,代码来源:MusicPlayerLogic.cs

示例2: PlayMusicThen

        public static void PlayMusicThen(MusicInfo m, Action then)
        {
            if (m == null || !m.Exists)
                return;

            OnMusicComplete = then;

            if (m == currentMusic && music != null)
            {
                soundEngine.PauseSound(music, false);
                MusicPlaying = true;
                return;
            }
            StopMusic();

            var sound = sounds[m.Filename];
            if (sound == null)
                return;

            music = soundEngine.Play2D(sound, false, true, WPos.Zero, MusicVolume, false);
            currentMusic = m;
            MusicPlaying = true;
        }
开发者ID:Generalcamo,项目名称:OpenRA,代码行数:23,代码来源:Sound.cs

示例3: SongExists

 bool SongExists(MusicInfo song)
 {
     return song != null && song.Exists;
 }
开发者ID:rhamilton1415,项目名称:OpenRA,代码行数:4,代码来源:MusicPlaylist.cs

示例4: MusicPlaylist

        public MusicPlaylist(World world, MusicPlaylistInfo info)
        {
            this.info = info;

            IsMusicAvailable = world.Map.Rules.InstalledMusic.Any();

            playlist = world.Map.Rules.InstalledMusic.Select(a => a.Value).ToArray();

            if (!IsMusicAvailable)
                return;

            random = playlist.Shuffle(Game.CosmeticRandom).ToArray();

            if (!string.IsNullOrEmpty(info.StartingMusic)
                && world.Map.Rules.Music.ContainsKey(info.StartingMusic)
                && world.Map.Rules.Music[info.StartingMusic].Exists)
            {
                currentSong = world.Map.Rules.Music[info.StartingMusic];
                repeat = info.LoopStartingMusic;
            }
            else
            {
                currentSong = Game.Settings.Sound.Shuffle ? random.First() : playlist.First();
                repeat = Game.Settings.Sound.Repeat;
            }

            Play();
        }
开发者ID:zombie-einstein,项目名称:OpenRA,代码行数:28,代码来源:MusicPlaylist.cs

示例5: Initialize

		public static void Initialize()
		{
			sounds = new Cache<string, ISoundSource>(LoadSound);
			music = null;
			currentMusic = null;
			video = null;
		}
开发者ID:JackKucan,项目名称:OpenRA,代码行数:7,代码来源:Sound.cs

示例6: MusicPlaylist

        public MusicPlaylist(World world, MusicPlaylistInfo info)
        {
            this.info = info;
            this.world = world;

            IsMusicInstalled = world.Map.Rules.InstalledMusic.Any();
            if (!IsMusicInstalled)
                return;

            playlist = world.Map.Rules.InstalledMusic
                .Where(a => !a.Value.Hidden)
                .Select(a => a.Value)
                .ToArray();

            random = playlist.Shuffle(Game.CosmeticRandom).ToArray();
            IsMusicAvailable = playlist.Any();

            if (SongExists(info.StartingMusic))
                currentSong = world.Map.Rules.Music[info.StartingMusic];
            else if (SongExists(info.BackgroundMusic))
            {
                currentSong = currentBackgroundSong = world.Map.Rules.Music[info.BackgroundMusic];
                CurrentSongIsBackground = true;
            }
            else
            {
                // Start playback with a random song, but only if the player has installed more music
                var installData = Game.ModData.Manifest.Get<ContentInstaller>();
                if (playlist.Length > installData.ShippedSoundtracks)
                    currentSong = random.FirstOrDefault();
            }

            Play();
        }
开发者ID:rhamilton1415,项目名称:OpenRA,代码行数:34,代码来源:MusicPlaylist.cs

示例7: MusicPlayerLogic

        public MusicPlayerLogic(Widget widget, Ruleset modRules, Action onExit)
        {
            this.modRules = modRules;

            var panel = widget.Get("MUSIC_PANEL");

            musicList = panel.Get<ScrollPanelWidget>("MUSIC_LIST");
            itemTemplate = musicList.Get<ScrollItemWidget>("MUSIC_TEMPLATE");

            BuildMusicTable();

            Func<bool> noMusic = () => !installed;
            panel.Get("NO_MUSIC_LABEL").IsVisible = noMusic;

            var playButton = panel.Get<ButtonWidget>("BUTTON_PLAY");
            playButton.OnClick = Play;
            playButton.IsDisabled = noMusic;
            playButton.IsVisible = () => !Sound.MusicPlaying;

            var pauseButton = panel.Get<ButtonWidget>("BUTTON_PAUSE");
            pauseButton.OnClick = Sound.PauseMusic;
            pauseButton.IsDisabled = noMusic;
            pauseButton.IsVisible = () => Sound.MusicPlaying;

            var stopButton = panel.Get<ButtonWidget>("BUTTON_STOP");
            stopButton.OnClick = Sound.StopMusic;
            stopButton.IsDisabled = noMusic;

            var nextButton = panel.Get<ButtonWidget>("BUTTON_NEXT");
            nextButton.OnClick = () => { currentSong = GetNextSong(); Play(); };
            nextButton.IsDisabled = noMusic;

            var prevButton = panel.Get<ButtonWidget>("BUTTON_PREV");
            prevButton.OnClick = () => { currentSong = GetPrevSong(); Play(); };
            prevButton.IsDisabled = noMusic;

            var shuffleCheckbox = panel.Get<CheckboxWidget>("SHUFFLE");
            shuffleCheckbox.IsChecked = () => Game.Settings.Sound.Shuffle;
            shuffleCheckbox.OnClick = () => Game.Settings.Sound.Shuffle ^= true;

            var repeatCheckbox = panel.Get<CheckboxWidget>("REPEAT");
            repeatCheckbox.IsChecked = () => Game.Settings.Sound.Repeat;
            repeatCheckbox.OnClick = () => Game.Settings.Sound.Repeat ^= true;

            panel.Get<LabelWidget>("TIME_LABEL").GetText = () => (currentSong == null) ? "" :
                "{0:D2}:{1:D2} / {2:D2}:{3:D2}".F((int)Sound.MusicSeekPosition / 60, (int)Sound.MusicSeekPosition % 60,
                    currentSong.Length / 60, currentSong.Length % 60);

            var musicSlider = panel.Get<SliderWidget>("MUSIC_SLIDER");
            musicSlider.OnChange += x => Sound.MusicVolume = x;
            musicSlider.Value = Sound.MusicVolume;

            panel.Get<ButtonWidget>("BACK_BUTTON").OnClick = () => { Game.Settings.Save(); Ui.CloseWindow(); onExit(); };
        }
开发者ID:RunCraze,项目名称:OpenRA,代码行数:54,代码来源:MusicPlayerLogic.cs

示例8: MusicPlaylist

        public MusicPlaylist(World world, MusicPlaylistInfo info)
        {
            this.info = info;
            this.world = world;

            if (info.DisableWorldSounds)
                Game.Sound.DisableWorldSounds = true;

            IsMusicInstalled = world.Map.Rules.InstalledMusic.Any();
            if (!IsMusicInstalled)
                return;

            playlist = world.Map.Rules.InstalledMusic
                .Where(a => !a.Value.Hidden)
                .Select(a => a.Value)
                .ToArray();

            random = playlist.Shuffle(Game.CosmeticRandom).ToArray();
            IsMusicAvailable = playlist.Any();

            if (SongExists(info.BackgroundMusic))
            {
                currentSong = currentBackgroundSong = world.Map.Rules.Music[info.BackgroundMusic];
                CurrentSongIsBackground = true;
            }
            else
            {
                // Start playback with a random song
                currentSong = random.FirstOrDefault();
            }

            if (SongExists(info.StartingMusic))
            {
                currentSong = world.Map.Rules.Music[info.StartingMusic];
                CurrentSongIsBackground = false;
            }

            Play();
        }
开发者ID:pchote,项目名称:OpenRA,代码行数:39,代码来源:MusicPlaylist.cs

示例9: GameOver

        public void GameOver(World world)
        {
            if (!IsMusicAvailable)
                return;

            var playedSong = currentSong;

            if (world.LocalPlayer.WinState == WinState.Won)
            {
                if (!string.IsNullOrEmpty(info.VictoryMusic)
                && world.Map.Rules.Music.ContainsKey(info.VictoryMusic)
                && world.Map.Rules.Music[info.VictoryMusic].Exists)
                {
                    currentSong = world.Map.Rules.Music[info.VictoryMusic];
                    repeat = info.LoopVictoryMusic;
                }
            }
            else
            {
                // Most RTS treats observers losing the game,
                // no need for a special handling involving them here.
                if (!string.IsNullOrEmpty(info.DefeatMusic)
                && world.Map.Rules.Music.ContainsKey(info.DefeatMusic)
                && world.Map.Rules.Music[info.DefeatMusic].Exists)
                {
                    currentSong = world.Map.Rules.Music[info.DefeatMusic];
                    repeat = info.LoopDefeatMusic;
                }
            }

            if (playedSong != currentSong)
                Play();
        }
开发者ID:zombie-einstein,项目名称:OpenRA,代码行数:33,代码来源:MusicPlaylist.cs

示例10: MusicPlayerLogic

		public MusicPlayerLogic(Widget widget, Ruleset modRules, World world, Action onExit)
		{
			var panel = widget;

			musicList = panel.Get<ScrollPanelWidget>("MUSIC_LIST");
			itemTemplate = musicList.Get<ScrollItemWidget>("MUSIC_TEMPLATE");
			musicPlaylist = world.WorldActor.Trait<MusicPlaylist>();

			BuildMusicTable();

			Func<bool> noMusic = () => !musicPlaylist.IsMusicAvailable || musicPlaylist.CurrentSongIsBackground || currentSong == null;
			panel.Get("NO_MUSIC_LABEL").IsVisible = () => !musicPlaylist.IsMusicAvailable;

			var playButton = panel.Get<ButtonWidget>("BUTTON_PLAY");
			playButton.OnClick = Play;
			playButton.IsDisabled = noMusic;
			playButton.IsVisible = () => !Game.Sound.MusicPlaying;

			var pauseButton = panel.Get<ButtonWidget>("BUTTON_PAUSE");
			pauseButton.OnClick = Game.Sound.PauseMusic;
			pauseButton.IsDisabled = noMusic;
			pauseButton.IsVisible = () => Game.Sound.MusicPlaying;

			var stopButton = panel.Get<ButtonWidget>("BUTTON_STOP");
			stopButton.OnClick = () => { musicPlaylist.Stop(); };
			stopButton.IsDisabled = noMusic;

			var nextButton = panel.Get<ButtonWidget>("BUTTON_NEXT");
			nextButton.OnClick = () => { currentSong = musicPlaylist.GetNextSong(); Play(); };
			nextButton.IsDisabled = noMusic;

			var prevButton = panel.Get<ButtonWidget>("BUTTON_PREV");
			prevButton.OnClick = () => { currentSong = musicPlaylist.GetPrevSong(); Play(); };
			prevButton.IsDisabled = noMusic;

			var shuffleCheckbox = panel.Get<CheckboxWidget>("SHUFFLE");
			shuffleCheckbox.IsChecked = () => Game.Settings.Sound.Shuffle;
			shuffleCheckbox.OnClick = () => Game.Settings.Sound.Shuffle ^= true;
			shuffleCheckbox.IsDisabled = () => musicPlaylist.CurrentSongIsBackground;

			var repeatCheckbox = panel.Get<CheckboxWidget>("REPEAT");
			repeatCheckbox.IsChecked = () => Game.Settings.Sound.Repeat;
			repeatCheckbox.OnClick = () => Game.Settings.Sound.Repeat ^= true;
			repeatCheckbox.IsDisabled = () => musicPlaylist.CurrentSongIsBackground;

			panel.Get<LabelWidget>("TIME_LABEL").GetText = () =>
			{
				if (currentSong == null || musicPlaylist.CurrentSongIsBackground)
					return "";

				var minutes = (int)Game.Sound.MusicSeekPosition / 60;
				var seconds = (int)Game.Sound.MusicSeekPosition % 60;
				var totalMinutes = currentSong.Length / 60;
				var totalSeconds = currentSong.Length % 60;

				return "{0:D2}:{1:D2} / {2:D2}:{3:D2}".F(minutes, seconds, totalMinutes, totalSeconds);
			};

			var musicTitle = panel.GetOrNull<LabelWidget>("TITLE_LABEL");
			if (musicTitle != null)
				musicTitle.GetText = () => currentSong != null ? currentSong.Title : "No song playing";

			var musicSlider = panel.Get<SliderWidget>("MUSIC_SLIDER");
			musicSlider.OnChange += x => Game.Sound.MusicVolume = x;
			musicSlider.Value = Game.Sound.MusicVolume;

			var installButton = widget.GetOrNull<ButtonWidget>("INSTALL_BUTTON");
			if (installButton != null)
			{
				installButton.IsDisabled = () => world.Type != WorldType.Shellmap;
				var args = new[] { "installMusic={0}".F(Game.ModData.Manifest.Mod.Id) };
				installButton.OnClick = () =>
					Game.RunAfterTick(() => Game.InitializeMod("modchooser", new Arguments(args)));

				var installData = Game.ModData.Manifest.Get<ContentInstaller>();
				installButton.IsVisible = () => modRules.InstalledMusic.ToArray().Length <= installData.ShippedSoundtracks;
			}

			var songWatcher = widget.GetOrNull<LogicTickerWidget>("SONG_WATCHER");
			if (songWatcher != null)
			{
				songWatcher.OnTick = () =>
				{
					if (musicPlaylist.CurrentSongIsBackground && currentSong != null)
						currentSong = null;

					if (Game.Sound.CurrentMusic == null || currentSong == Game.Sound.CurrentMusic || musicPlaylist.CurrentSongIsBackground)
						return;

					currentSong = Game.Sound.CurrentMusic;
				};
			}

			var backButton = panel.GetOrNull<ButtonWidget>("BACK_BUTTON");
			if (backButton != null)
				backButton.OnClick = () => { Game.Settings.Save(); Ui.CloseWindow(); onExit(); };
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:97,代码来源:MusicPlayerLogic.cs

示例11: Play

        void Play()
        {
            if (currentSong == null || !IsMusicAvailable)
                return;

            Sound.PlayMusicThen(currentSong, () =>
            {
                if (!repeat)
                    currentSong = GetNextSong();

                Play();
            });
        }
开发者ID:zombie-einstein,项目名称:OpenRA,代码行数:13,代码来源:MusicPlaylist.cs

示例12: GameOver

 public void GameOver(World world)
 {
     if (world.LocalPlayer != null && world.LocalPlayer.WinState == WinState.Won)
     {
         if (SongExists(info.VictoryMusic))
         {
             currentBackgroundSong = world.Map.Rules.Music[info.VictoryMusic];
             Stop();
         }
     }
     else
     {
         // Most RTS treats observers losing the game,
         // no need for a special handling involving them here.
         if (SongExists(info.DefeatMusic))
         {
             currentBackgroundSong = world.Map.Rules.Music[info.DefeatMusic];
             Stop();
         }
     }
 }
开发者ID:rhamilton1415,项目名称:OpenRA,代码行数:21,代码来源:MusicPlaylist.cs

示例13: BuildMusicTable

        public void BuildMusicTable()
        {
            if (!musicPlaylist.IsMusicAvailable)
                return;

            var music = musicPlaylist.AvailablePlaylist();
            currentSong = musicPlaylist.CurrentSong();
            if (currentSong == null && music.Any())
                currentSong = musicPlaylist.GetNextSong();

            musicList.RemoveChildren();
            foreach (var s in music)
            {
                var song = s;
                if (currentSong == null)
                    currentSong = song;

                var item = ScrollItemWidget.Setup(song.Filename, itemTemplate, () => currentSong == song, () => { currentSong = song; Play(); }, () => { });
                item.Get<LabelWidget>("TITLE").GetText = () => song.Title;
                item.Get<LabelWidget>("LENGTH").GetText = () => SongLengthLabel(song);
                musicList.AddChild(item);
            }

            if (currentSong != null)
                musicList.ScrollToItem(currentSong.Filename);
        }
开发者ID:zombie-einstein,项目名称:OpenRA,代码行数:26,代码来源:MusicPlayerLogic.cs

示例14: MusicPlayerLogic

        public MusicPlayerLogic(Widget widget, Ruleset modRules, World world, Action onExit)
        {
            var panel = widget.Get("MUSIC_PANEL");

            musicList = panel.Get<ScrollPanelWidget>("MUSIC_LIST");
            itemTemplate = musicList.Get<ScrollItemWidget>("MUSIC_TEMPLATE");
            musicPlaylist = world.WorldActor.Trait<MusicPlaylist>();

            BuildMusicTable();

            Func<bool> noMusic = () => !musicPlaylist.IsMusicAvailable;
            panel.Get("NO_MUSIC_LABEL").IsVisible = noMusic;

            var playButton = panel.Get<ButtonWidget>("BUTTON_PLAY");
            playButton.OnClick = Play;
            playButton.IsDisabled = noMusic;
            playButton.IsVisible = () => !Sound.MusicPlaying;

            var pauseButton = panel.Get<ButtonWidget>("BUTTON_PAUSE");
            pauseButton.OnClick = Sound.PauseMusic;
            pauseButton.IsDisabled = noMusic;
            pauseButton.IsVisible = () => Sound.MusicPlaying;

            var stopButton = panel.Get<ButtonWidget>("BUTTON_STOP");
            stopButton.OnClick = () => { musicPlaylist.Stop(); };
            stopButton.IsDisabled = noMusic;

            var nextButton = panel.Get<ButtonWidget>("BUTTON_NEXT");
            nextButton.OnClick = () => { currentSong = musicPlaylist.GetNextSong(); Play(); };
            nextButton.IsDisabled = noMusic;

            var prevButton = panel.Get<ButtonWidget>("BUTTON_PREV");
            prevButton.OnClick = () => { currentSong = musicPlaylist.GetPrevSong(); Play(); };
            prevButton.IsDisabled = noMusic;

            var shuffleCheckbox = panel.Get<CheckboxWidget>("SHUFFLE");
            shuffleCheckbox.IsChecked = () => Game.Settings.Sound.Shuffle;
            shuffleCheckbox.OnClick = () => Game.Settings.Sound.Shuffle ^= true;

            var repeatCheckbox = panel.Get<CheckboxWidget>("REPEAT");
            repeatCheckbox.IsChecked = () => Game.Settings.Sound.Repeat;
            repeatCheckbox.OnClick = () => Game.Settings.Sound.Repeat ^= true;

            panel.Get<LabelWidget>("TIME_LABEL").GetText = () => (currentSong == null) ? "" :
                "{0:D2}:{1:D2} / {2:D2}:{3:D2}".F((int)Sound.MusicSeekPosition / 60, (int)Sound.MusicSeekPosition % 60,
                    currentSong.Length / 60, currentSong.Length % 60);

            var musicSlider = panel.Get<SliderWidget>("MUSIC_SLIDER");
            musicSlider.OnChange += x => Sound.MusicVolume = x;
            musicSlider.Value = Sound.MusicVolume;

            var installButton = widget.GetOrNull<ButtonWidget>("INSTALL_BUTTON");
            if (installButton != null)
            {
                installButton.IsDisabled = () => world == null || world.Type != WorldType.Shellmap;
                var args = new string[] { "Install.Music=true" };
                installButton.OnClick = () =>
                    Game.RunAfterTick(() =>
                        Game.InitializeMod(Game.Settings.Game.Mod, new Arguments(args)));

                var installData = Game.ModData.Manifest.Get<ContentInstaller>();
                installButton.IsVisible = () => modRules.InstalledMusic.ToArray().Length <= installData.ShippedSoundtracks;
            }

            var songWatcher = widget.GetOrNull<LogicTickerWidget>("SONG_WATCHER");
            if (songWatcher != null)
            {
                songWatcher.OnTick = () =>
                {
                    if (Sound.CurrentMusic == null || currentSong == Sound.CurrentMusic)
                        return;

                    currentSong = Sound.CurrentMusic;
                };
            }

            panel.Get<ButtonWidget>("BACK_BUTTON").OnClick = () => { Game.Settings.Save(); Ui.CloseWindow(); onExit(); };
        }
开发者ID:zombie-einstein,项目名称:OpenRA,代码行数:78,代码来源:MusicPlayerLogic.cs

示例15: BuildMusicTable

        void BuildMusicTable(Widget list)
        {
            music = Rules.Music.Where(a => a.Value.Exists).Select(a => a.Value).ToArray();
            random = music.Shuffle(Game.CosmeticRandom).ToArray();

            list.RemoveChildren();
            foreach (var s in music)
            {
                var song = s;
                if (currentSong == null)
                    currentSong = song;

                var item = ScrollItemWidget.Setup(itemTemplate, () => currentSong == song, () => { currentSong = song; Play(); });
                item.Get<LabelWidget>("TITLE").GetText = () => song.Title;
                item.Get<LabelWidget>("LENGTH").GetText = () => SongLengthLabel(song);
                list.AddChild(item);
            }
        }
开发者ID:sonygod,项目名称:OpenRA-Dedicated-20120504,代码行数:18,代码来源:CncMusicPlayerLogic.cs


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