public IEnumerator TestFade() { IAudio audio = null; yield return(LoadAudio(a => audio = a)); var controller = MusicController.Create(); controller.MountAudio(audio); int fadeEndCount = 0; controller.OnFaded += (f) => fadeEndCount++; controller.Play(); yield return(new WaitForSeconds(1f)); controller.Fade(1f, 0f); yield return(new WaitForSeconds(1f)); Assert.AreEqual(1, fadeEndCount); controller.Fade(1f); yield return(new WaitForSeconds(1f)); Assert.AreEqual(2, fadeEndCount); controller.SetFade(0.5f); yield return(new WaitForSeconds(1f)); Assert.AreEqual(3, fadeEndCount); }
/// <summary> /// Initializes all required modules for the game. /// </summary> protected virtual void InitializeModules() { UnityThread.Initialize(); Dependencies.CacheAs <IGame>(this); Dependencies.CacheAs <IPlatformHost>(platformHost = PlatformHost.CreateHost()); Dependencies.CacheAs <DeepLinker>(deepLinker = platformHost.CreateDeepLinker()); Dependencies.CacheAs <IEnvConfiguration>(envConfiguration = new EnvConfiguration(EnvType.Production)); Dependencies.CacheAs <IModeManager>(modeManager = new ModeManager()); Dependencies.CacheAs <INotificationBox>(notificationBox = new NotificationBox()); Dependencies.CacheAs <IGameConfiguration>(gameConfiguration = new GameConfiguration()); Dependencies.CacheAs <IMapConfiguration>(mapConfiguration = new MapConfiguration()); Dependencies.CacheAs <IMapsetConfiguration>(mapsetConfiguration = new MapsetConfiguration()); Dependencies.CacheAs <IFontManager>(fontManager = new FontManager()); Dependencies.CacheAs <IAtlas <Sprite> >(spriteAtlas = new ResourceSpriteAtlas()); Dependencies.CacheAs <IAtlas <AudioClip> >(audioAtlas = new ResourceAudioAtlas()); Dependencies.CacheAs <IMusicCacher>(musicCacher = new MusicCacher()); Dependencies.CacheAs <IBackgroundCacher>(backgroundCacher = new BackgroundCacher()); Dependencies.CacheAs <IWebImageCacher>(webImageCacher = new WebImageCacher()); Dependencies.CacheAs <IWebMusicCacher>(webMusicCacher = new WebMusicCacher()); Dependencies.CacheAs <IMusicController>(musicController = MusicController.Create()); Dependencies.CacheAs <ISoundTable>(soundTable = new DefaultSoundTable(audioAtlas)); Dependencies.CacheAs <ISoundPool>(soundPool = new SoundPool(soundTable)); Dependencies.CacheAs <IMapsetStore>(mapsetStore = new MapsetStore(modeManager)); Dependencies.CacheAs <IMapSelection>(mapSelection = new MapSelection(musicCacher, backgroundCacher, gameConfiguration, mapsetConfiguration, mapConfiguration)); Dependencies.CacheAs <IMapManager>(mapManager = new MapManager(mapsetStore, notificationBox, mapSelection)); Dependencies.CacheAs <IMetronome>(metronome = new Metronome() { AudioController = musicController }); Dependencies.CacheAs <IMusicPlaylist>(musicPlaylist = new MusicPlaylist()); Dependencies.CacheAs <IDownloadStore>(downloadStore = new DownloadStore()); Dependencies.CacheAs <IApi>(api = new Api(envConfiguration, notificationBox, deepLinker)); Dependencies.CacheAs <IUserManager>(userManager = new UserManager(api, Dependencies)); Dependencies.CacheAs <IRecordStore>(recordStore = new RecordStore()); Dependencies.CacheAs <IRootMain>(rootMain = RootMain.Create(Dependencies)); Dependencies.CacheAs <IRoot3D>(root3D = Root3D.Create(Dependencies)); Dependencies.CacheAs <IColorPreset>(colorPreset = new ColorPreset()); Dependencies.CacheAs <IAnimePreset>(animePreset = new AnimePreset()); Dependencies.CacheAs <IScreenNavigator>(screenNavigator = new ScreenNavigator(rootMain)); Dependencies.CacheAs <IOverlayNavigator>(overlayNavigator = new OverlayNavigator(rootMain)); Dependencies.CacheAs <IDropdownProvider>(dropdownProvider = new DropdownProvider(rootMain)); Dependencies.CacheAs <ITemporaryStore>(temporaryStore = new TemporaryStore()); }
public IEnumerator TestPlay() { IAudio audio = null; yield return(LoadAudio(a => audio = a)); var controller = MusicController.Create(); var clock = controller.Clock; controller.MountAudio(audio); Assert.AreEqual(0f, clock.CurrentTime, Delta); Debug.Log("A"); controller.Play(500); Assert.AreEqual(-500f, clock.CurrentTime, Delta); Debug.Log("B"); controller.Pause(); Assert.AreEqual(-500, clock.CurrentTime, Delta); yield return(new WaitForSeconds(1f)); Assert.AreEqual(-500, clock.CurrentTime, Delta); Debug.Log("C"); controller.Play(); Assert.AreEqual(-500, clock.CurrentTime, Delta); yield return(new WaitForSeconds(1f)); Assert.AreEqual(500, clock.CurrentTime, Delta); Debug.Log("D"); controller.Stop(); Assert.AreEqual(0, clock.CurrentTime, Delta); yield return(new WaitForSeconds(1f)); Assert.AreEqual(0, clock.CurrentTime, Delta); Debug.Log("E"); controller.Seek(1000); Assert.AreEqual(950, clock.CurrentTime, Delta); yield return(new WaitForSeconds(1f)); Assert.AreEqual(950, clock.CurrentTime, Delta); Debug.Log("F"); controller.Play(0); yield return(new WaitForSeconds(1f)); Assert.AreEqual(1000, clock.CurrentTime, Delta); Debug.Log("G"); controller.Seek(5000); Assert.AreEqual(4950, clock.CurrentTime, Delta); yield return(new WaitForSeconds(2f)); }
public IEnumerator TestTempo() { IAudio audio = null; yield return(LoadAudio(a => audio = a)); var controller = MusicController.Create(); controller.MountAudio(audio); controller.SetTempo(1.5f); controller.Play(); yield return(new WaitForSeconds(1f)); Assert.Greater(controller.CurrentTime, 1.5f); }
public IEnumerator TestSetVolume() { IAudio audio = null; yield return(LoadAudio(a => audio = a)); var controller = MusicController.Create(); controller.MountAudio(audio); controller.Play(); yield return(new WaitForSeconds(1f)); controller.SetVolume(0.25f); yield return(new WaitForSeconds(1f)); }