/// <summary> /// Stop server and release resources. /// </summary> public void Dispose() { // - Dispose all modules CocoritaModule.Dispose(); AudioModule.Dispose(); BotChannel.Dispose(); }
public static void CrossFadeToWorldMusic(byte worldIndex) { lock (staticMutationLock) { var soundToLoad = AssetLocator.BackgroundMusic[worldIndex]; if (soundToLoad == curSound) { return; } if (prevSound != null) { prevSound.StopAllInstances(); } string musicFile = Path.Combine(AssetLocator.AudioDir, @"BGM\") + worldIndex + ".mp3"; prevSound = curSound; curSound = soundToLoad; int instanceId = AudioModule.CreateSoundInstance(musicFile); curSound.AddInstance(instanceId); AudioModule.PlaySoundInstance(instanceId, true, 0f); prevMusicInstanceID = curMusicInstanceID; curMusicInstanceID = instanceId; prevMusicVol = curMusicVol; curMusicVol = 0f; } }
public async Task Preview(ISocketMessageChannel channel) { AudioService audioService = (AudioService)Program._services.GetService(typeof(AudioService)); AudioModule am = new AudioModule(audioService, (SocketCommandContext)audioService.Context); try { await am.Music1(); } catch (Exception ex) { Console.WriteLine(ex); } EmbedBuilder e = new EmbedBuilder(); ch = channel; int id = 1; int SimpleID = 0; int MultipleID = 0; string stock = string.Empty; foreach (var q in questions) { if (q.type == QType.text) { // problème sûr à 100% avec async await e.Title = "Aperçu du QCM : " + name; e.Color = Color.DarkBlue; var eb = (EmbedBuilder)q.content; e.AddField("Question " + id, q.name + " | " + q.type + " | " + eb.Title); //if (q.type == QType.text) //await channel.SendMessageAsync("", false,(EmbedBuilder) q.content); } else if (q.type == QType.image) { Console.WriteLine(); // Images multiples List <EmbedBuilder> eb = (List <EmbedBuilder>)q.content; if (q.imageQuestion == ImageQuestion.CorrespondingImageMultiple) { e.AddField("Multiple IMG " + id, q.name + " | " + ebListMultiple[MultipleID].Title); MultipleID++; } // Image unique else { e.AddField("Unique IMG " + id, ebListSimple[SimpleID].Description + " | " + ebListSimple[SimpleID].Title); SimpleID++; } } else { e.AddField("Type non géré par le système de prévisualisation: ", q.type); } id++; } await channel.SendMessageAsync("", false, e); foreach (var field in e.Fields) { Console.WriteLine(field.Name + " : " + field.Value); } }
public async Task DoBotStuff() { _instance = this; _cts = new CancellationTokenSource(); _commands = new CommandService(); _audios = new AudioService(); _audiom = new AudioModule(_audios); _client = new DiscordSocketClient(new DiscordSocketConfig { LogLevel = LogSeverity.Info, MessageCacheSize = 50, AlwaysDownloadUsers = true //TotalShards = 2 }); _services = new ServiceCollection().AddSingleton(_client).AddSingleton(_commands).AddSingleton <AudioService>().BuildServiceProvider(); _client.Log += Log; await InstallCommands(); ConfigureEventHandlers(); CancellationTokenSource tokenSource1 = new CancellationTokenSource(); CancellationTokenSource tokenSource2 = new CancellationTokenSource(); Task timerTask1 = RunPeriodically(_game, TimeSpan.FromSeconds(25), tokenSource1.Token); //Task timerTask2 = ScheduleAction(_transmit, new DateTime(2017, 12, 31, 23, 0, 0)); //Task timerTask2 = RunPeriodically(_bumper, TimeSpan.FromHours(4.00138889), tokenSource2.Token); await _client.LoginAsync(TokenType.Bot, token); await _client.StartAsync(); }
public async Task StartAsync() { Configuration.EnsureExists(); _client = new DiscordSocketClient(new DiscordSocketConfig() { LogLevel = LogSeverity.Info, // Specify console verbose information level. MessageCacheSize = 1000, // Tell discord.net how long to store messages (per channel). }); _client.Log += (l) // Register the console log event. => Console.Out.WriteLineAsync(l.ToString()); var services = ConfigureServices(); await services.GetRequiredService <CommandHandler>().InitializeAsync(services); AudioModule mod = new AudioModule(services.GetService <MusicService>(), services.GetService <InteractiveService>()); GBFModule mod2 = new GBFModule(services.GetService <InteractiveService>()); AnilistModule mod3 = new AnilistModule(services.GetService <InteractiveService>()); await _client.LoginAsync(TokenType.Bot, Configuration.Load().Token); await _client.StartAsync(); await Task.Delay(-1); }
private static void Sounds_LevelStart() { int instanceId = AudioModule.CreateSoundInstance(AssetLocator.RollSound.File); AssetLocator.RollSound.AddInstance(instanceId); AudioModule.PlaySoundInstance(instanceId, true, 0f); }
public static void StartTitleMusic() { lock (staticMutationLock) { var soundToLoad = AssetLocator.BackgroundMusic[11]; if (soundToLoad == prevSound) { return; } string musicFile = Path.Combine(AssetLocator.AudioDir, @"BGM\") + TITLE_MUSIC_FILE; prevSound = curSound; curSound = soundToLoad; int instanceId = AudioModule.CreateSoundInstance(musicFile); curSound.AddInstance(instanceId); AudioModule.PlaySoundInstance(instanceId, true, Config.MusicVolume); prevMusicInstanceID = curMusicInstanceID; curMusicInstanceID = instanceId; prevMusicVol = 0f; curMusicVol = Config.MusicVolume; if (prevSound != null) { prevSound.StopAllInstances(); } } }
public static void Initialize() { ContainerModule.Initialize(); CoreModule.Initialize(); MathModule.Initialize(); EngineModule.Initialize(); InputModule.Initialize(); IOModule.Initialize(); ResourceModule.Initialize(); AudioModule.Initialize(); GraphicsModule.Initialize(); SceneModule.Initialize(); Atomic2DModule.Initialize(); Atomic3DModule.Initialize(); NavigationModule.Initialize(); NetworkModule.Initialize(); PhysicsModule.Initialize(); EnvironmentModule.Initialize(); UIModule.Initialize(); AtomicPlayer.PlayerModule.Initialize(); AtomicInterop.Initialize(); atomicsharp_initialize(); initSubsystems(); }
//public async Task CheckReaction(SocketCommandContext context) //{ // context.Client.ReactionAdded += Client_ReactionAdded; //} //private void Client_ReactionAdded(Cacheable<IUserMessage, ulong> message, ISocketMessageChannel channel, SocketReaction reaction) //{ //// var AllReactions = message.Value.Reactions.ToList(); //// if(reaction.Emote.Name = "🛡" || AllReactions.Contains("❗") || AllReactions.Contains("💎") ) //// { //// } //} public async Task ChoosePassage(SocketCommandContext context, int id, Map m, AudioModule audio) { int time = 20000; await context.Channel.SendMessageAsync(":timer: Fermeture de la salle dans " + time / 1000 + "s"); var msg = await(m.allStructures[id] as Room).ShowIllustrationPassage(context); Console.WriteLine("Choix du passage"); if (msg != null) { JDR.passageMsgsID.Add(msg.Id); //var msg = await p.StartQCM(passageQCM.name); await msg.AddReactionAsync(new Emoji("🛡")); await msg.AddReactionAsync(new Emoji("❗")); await msg.AddReactionAsync(new Emoji("💎")); //await CheckReaction(context); await Task.Delay(time - 4000); // id + 1 car on regarde les passages à venir SelectPassageWithVotes(id + 1); var pass = (m.allStructures[id + 1] as Passages); foreach (var passage in pass.passages) { if (passage.isSelected) { if (passage.isSelectedRandomly) { await context.Channel.SendMessageAsync("Comme les aventuriers n'ont pas pu se départager, un des passages est choisi aléatoirement"); } await context.Channel.SendMessageAsync("Passage sélectionné ! : " + passage.GetName()); if (passage.GetName() == "passage Talisman") { if (JDR.map.allStructures[id + 2] != null) { (JDR.map.allStructures[id + 2] as Room).illustration.Title = ":gem: Salle au Talisman"; } } if (JDR.map.allStructures[id + 1] != null) { JDR.map.allStructures[id + 1] = passage; } } } try { audio = new AudioModule((AudioService)Program._services.GetService(typeof(AudioService)), context);; await audio.DoorCloseSFX(); } catch (Exception ex) { Console.WriteLine(ex); } await context.Channel.SendMessageAsync("En route vers le passage !"); } else { Console.WriteLine("Message nul"); } }
private static void Sounds_LevelPass(LevelPassDetails details) { AssetLocator.RollSound.StopAllInstances(); //AudioModule.StopSound(AssetLocator.RollSound); playingCountdownTimer = false; AssetLocator.CountdownLoopSound.StopAllInstances(); //AudioModule.StopSound(AssetLocator.CountdownLoopSound); int instanceId = AudioModule.CreateSoundInstance(AssetLocator.BellSound); AudioModule.PlaySoundInstance( instanceId, false, PASS_FAIL_VOLUME * Config.SoundEffectVolume ); instanceId = AudioModule.CreateSoundInstance(AssetLocator.PassSound); AudioModule.PlaySoundInstance( instanceId, false, PASS_FAIL_VOLUME * Config.SoundEffectVolume ); instanceId = AudioModule.CreateSoundInstance(AssetLocator.EmotePassSounds[RandomProvider.Next(0, AssetLocator.EmotePassSounds.Length)]); AudioModule.PlaySoundInstance( instanceId, false, 1.7f * Config.SoundEffectVolume, RandomProvider.Next(0.75f, 1.25f) ); switch (details.Star) { case Star.Gold: HUDSoundExtensions.Play(HUDSound.PostPassStarGold, 1.3f); instanceId = AudioModule.CreateSoundInstance(AssetLocator.PassGoldSound); AudioModule.PlaySoundInstance( instanceId, false, PASS_FAIL_VOLUME * Config.SoundEffectVolume ); instanceId = AudioModule.CreateSoundInstance(AssetLocator.PostPassGoldApplauseSound.File); AssetLocator.PostPassGoldApplauseSound.AddInstance(instanceId); AudioModule.PlaySoundInstance(instanceId, true, 0.55f * Config.HUDVolume); break; case Star.Silver: HUDSoundExtensions.Play(HUDSound.PostPassStarGold, 1f); instanceId = AudioModule.CreateSoundInstance(AssetLocator.PostPassSilverApplauseSound.File); AssetLocator.PostPassSilverApplauseSound.AddInstance(instanceId); AudioModule.PlaySoundInstance(instanceId, true, 0.35f * Config.HUDVolume); break; case Star.Bronze: HUDSoundExtensions.Play(HUDSound.PostPassStarGold, 0.7f); instanceId = AudioModule.CreateSoundInstance(AssetLocator.PostPassBronzeApplauseSound.File); AssetLocator.PostPassBronzeApplauseSound.AddInstance(instanceId); AudioModule.PlaySoundInstance(instanceId, true, 0.3f * Config.HUDVolume); break; } }
public static void Initialize() { // Atomic Modules CoreModule.Initialize(); MathModule.Initialize(); EngineModule.Initialize(); InputModule.Initialize(); IOModule.Initialize(); ResourceModule.Initialize(); AudioModule.Initialize(); GraphicsModule.Initialize(); SceneModule.Initialize(); Atomic2DModule.Initialize(); NavigationModule.Initialize(); NetworkModule.Initialize(); PhysicsModule.Initialize(); EnvironmentModule.Initialize(); UIModule.Initialize(); #if ATOMIC_DESKTOP IPCModule.Initialize(); #endif AtomicAppModule.Initialize(); ScriptModule.Initialize(); AtomicNETScriptModule.Initialize(); AtomicNETNativeModule.Initialize(); PlayerModule.Initialize(); coreDelegates = new CoreDelegates(); coreDelegates.eventDispatch = NativeCore.EventDispatch; coreDelegates.updateDispatch = NativeCore.UpdateDispatch; IntPtr coreptr = csi_Atomic_NETCore_Initialize(ref coreDelegates); NETCore core = (coreptr == IntPtr.Zero ? null : NativeCore.WrapNative <NETCore>(coreptr)); if (core != null) { AtomicNET.RegisterSubsystem("NETCore", core); } context = core.Context; NativeCore.Initialize(); CSComponentCore.Initialize(); #if ATOMIC_DESKTOP string[] arguments = Environment.GetCommandLineArgs(); foreach (string arg in arguments) { AppBase.AddArgument(arg); } #endif }
private static void BGMConfigRefresh() { lock (staticMutationLock) { if (curMusicVol > Config.MusicVolume) { curMusicVol = Config.MusicVolume; AudioModule.SetSoundInstanceVolume(curMusicInstanceID.Value, curMusicVol); } } }
public void StopAllInstances() { lock (instanceMutationLock) { foreach (int id in SoundInstanceIds) { AudioModule.StopSoundInstance(id); } SoundInstanceIds.Clear(); } }
public static void Play(this HUDSound sound, float volume = 1f, float pitch = 1f) { int instanceId = AudioModule.CreateSoundInstance(sound.SoundFile()); AudioModule.PlaySoundInstance( instanceId, false, Config.HUDVolume * sound.VolumeModifier() * volume, sound.PitchModifier() * pitch ); }
private async Task StartIntroMusic() { try { AudioModule am = new AudioModule((AudioService)Program._services.GetService(typeof(AudioService)), Context); await am.Music3(); } catch (Exception ex) { await ReplyAsync(ex.ToString()); } }
public static void Main() { // Console.OutputEncoding = Encoding.ASCII; Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("+----------------------------+" + Environment.NewLine + "| SilverBot |" + Environment.NewLine + "| ©SilverDimond and The |" + Environment.NewLine + "| SilverCraft team |" + Environment.NewLine + "| Special thanks to |" + Environment.NewLine + "| ThePajamaSlime#9391 |" + Environment.NewLine + "+ ---------------------------+"); Console.ResetColor(); config = Config.Get(); if (String.IsNullOrEmpty(config.SentryURL)) { Version.Checkforupdates(); Commands.Giphymodule(new Giphy(config.Gtoken)); Commands.SetConfig(config); Fortnite.Setapi(new FortniteApi(config.Fortnite_Api_Token)); AudioModule.SetConfig(config); Imagemodule.SetConfig(config); Weather.SetClient(new Awesomio.Weather.WeatherClient(config.OpenWeatherMap)); prefix = config.Prefix; new Program().RunBotAsync().GetAwaiter().GetResult(); } else { using (SentrySdk.Init(config.SentryURL)) { User user = new User { Username = Environment.UserName }; SentrySdk.ConfigureScope(s => s.User = user); SentrySdk.ConfigureScope(scope => { scope.SetExtra("Version", Version.vnumber); }); Version.Checkforupdates(); Commands.Giphymodule(new Giphy(config.Gtoken)); Commands.SetConfig(config); Fortnite.Setapi(new FortniteApi(config.Fortnite_Api_Token)); AudioModule.SetConfig(config); Imagemodule.SetConfig(config); Weather.SetClient(new Awesomio.Weather.WeatherClient(config.OpenWeatherMap)); prefix = config.Prefix; new Program().RunBotAsync().GetAwaiter().GetResult(); } } }
/// <summary> /// Initialize and run server modules. /// </summary> public async Task RunServer() { var diagnostic = Services.GetService <Diagnostic>(); var logs = Services.GetService <LoggingService>(); BotChannel.RegisterDrawable(0, diagnostic.DiagnosticDrawable); BotChannel.RegisterDrawable(1, CocoritaModule.Drawable); BotChannel.RegisterDrawable(2, Player.Drawer); BotChannel.RegisterDrawable(3, logs.LogDrawable); new Task(async() => await BotChannel.StartAsync()).Start(); new Task(async() => await AudioModule.StartAsync()).Start(); new Task(async() => await CocoritaModule.StartAsync()).Start(); await Task.CompletedTask; }
private static void MaybePlayAllBounce(float speedDifference) { if (lastAllBounceSoundTime - timeRemainingMs < ALL_BOUNCE_SOUND_MIN_INTERVAL) { return; } int instanceId = AudioModule.CreateSoundInstance(AssetLocator.AllBounceSounds[RandomProvider.Next(0, AssetLocator.AllBounceSounds.Length)]); AudioModule.PlaySoundInstance( instanceId, false, (float)MathUtils.Clamp((speedDifference / PhysicsManager.ONE_METRE_SCALED), 0f, 0.5f) * Config.SoundEffectVolume, RandomProvider.Next(0.5f, 1f) ); lastAllBounceSoundTime = timeRemainingMs; }
private static void Sounds_LevelFail(LevelFailReason reason) { Sounds_LevelProgress(); if (reason == LevelFailReason.GameCancelled) { return; } int instanceId = AudioModule.CreateSoundInstance(AssetLocator.EmoteFailSounds[RandomProvider.Next(0, AssetLocator.EmoteFailSounds.Length)]); AudioModule.PlaySoundInstance( instanceId, false, 1.3f * Config.SoundEffectVolume, RandomProvider.Next(0.75f, 1.25f) ); instanceId = AudioModule.CreateSoundInstance(AssetLocator.FailAwwSounds[RandomProvider.Next(0, AssetLocator.FailAwwSounds.Length)]); AudioModule.PlaySoundInstance( instanceId, false, 0.575f * Config.SoundEffectVolume, RandomProvider.Next(0.75f, 1.25f) ); switch (reason) { case LevelFailReason.Dropped: instanceId = AudioModule.CreateSoundInstance(AssetLocator.FailFallSound); AudioModule.PlaySoundInstance( instanceId, false, PASS_FAIL_VOLUME * Config.SoundEffectVolume ); break; case LevelFailReason.TimeUp: instanceId = AudioModule.CreateSoundInstance(AssetLocator.FailTimeoutSound); AudioModule.PlaySoundInstance( instanceId, false, PASS_FAIL_VOLUME * Config.SoundEffectVolume ); break; } }
public static void Initialize() { // Atomic Modules CoreModule.Initialize(); MathModule.Initialize(); EngineModule.Initialize(); InputModule.Initialize(); IOModule.Initialize(); ResourceModule.Initialize(); AudioModule.Initialize(); GraphicsModule.Initialize(); SceneModule.Initialize(); Atomic2DModule.Initialize(); Atomic3DModule.Initialize(); NavigationModule.Initialize(); NetworkModule.Initialize(); PhysicsModule.Initialize(); EnvironmentModule.Initialize(); UIModule.Initialize(); IPCModule.Initialize(); AtomicAppModule.Initialize(); ScriptModule.Initialize(); AtomicNETScriptModule.Initialize(); AtomicNETNativeModule.Initialize(); PlayerModule.Initialize(); coreDelegates = new CoreDelegates(); coreDelegates.eventDispatch = NativeCore.EventDispatch; coreDelegates.updateDispatch = NativeCore.UpdateDispatch; IntPtr coreptr = csb_Atomic_NETCore_Initialize(ref coreDelegates); NETCore core = (coreptr == IntPtr.Zero ? null : NativeCore.WrapNative <NETCore>(coreptr)); if (core != null) { AtomicNET.RegisterSubsystem("NETCore", core); } context = core.Context; NativeCore.Initialize(); CSComponentCore.Initialize(); }
public async Task Pin() { var msg = await ReplyAsync("Hello World"); await msg.AddReactionAsync(new Emoji("😨")); await Context.Client.SetGameAsync("House Party"); // NE MARCHE PAS AVEC CO DE L'EFREI NI MON TEL !!!!!!!!!!!! try { AudioModule am = new AudioModule((AudioService)Program._services.GetService(typeof(AudioService)), Context); await am.Test(); } catch (Exception ex) { await ReplyAsync(ex.ToString()); } }
private static void BGMTick(float deltaTime) { lock (staticMutationLock) { if (deltaTime > 1f) { return; } float cap = Config.MusicVolume; float adjustedFadePerSec = MUSIC_FADE_PER_SEC * cap; if (curMusicInstanceID != null && curMusicVol < cap) { curMusicVol += adjustedFadePerSec * deltaTime; if (curMusicVol > cap) { curMusicVol = cap; } AudioModule.SetSoundInstanceVolume(curMusicInstanceID.Value, curMusicVol); } if (prevMusicInstanceID != null && prevMusicVol > 0f) { prevMusicVol -= adjustedFadePerSec * deltaTime; if (prevMusicVol <= 0f) { prevSound.StopAllInstances(); } else { AudioModule.SetSoundInstanceVolume(prevMusicInstanceID.Value, prevMusicVol); } } if (curMusicVol >= cap && prevMusicVol <= 0f) { if (crossfadeComplete != null) { crossfadeComplete(); } crossfadeComplete = null; } } }
private static void Sounds_Collision(GeometryEntity geom) { if ((!ignoredEggCollisionGeoms.ContainsKey(geom) || ignoredEggCollisionGeoms[geom] - timeRemainingMs >= IMPACT_SOUND_MIN_INTERVAL_SAME_GEOM_MS) && lastImpactSoundTime - timeRemainingMs >= IMPACT_SOUND_MIN_INTERVAL_MS) { int instanceId = AudioModule.CreateSoundInstance(AssetLocator.ImpactSounds[RandomProvider.Next(0, AssetLocator.ImpactSounds.Length)]); AudioModule.PlaySoundInstance( instanceId, false, IMPACT_VOLUME * Config.SoundEffectVolume, RandomProvider.Next(IMPACT_PITCH_MIN, IMPACT_PITCH_MAX) ); if (velocityLastFrame != Vector3.ZERO && egg.Velocity != Vector3.ZERO) { MaybePlayAllBounce(Math.Abs(velocityLastFrame.Length - egg.Velocity.Length)); } lastImpactSoundTime = timeRemainingMs; } ignoredEggCollisionGeoms[geom] = timeRemainingMs; highspeedUpMetadata.CollidedSinceLastSound = highspeedDownMetadata.CollidedSinceLastSound = highspeedParallelMetadata.CollidedSinceLastSound = true; }
static public void Initialize() { ContainerModule.Initialize(); CoreModule.Initialize(); MathModule.Initialize(); EngineModule.Initialize(); InputModule.Initialize(); IOModule.Initialize(); ResourceModule.Initialize(); AudioModule.Initialize(); GraphicsModule.Initialize(); SceneModule.Initialize(); Atomic2DModule.Initialize(); Atomic3DModule.Initialize(); NavigationModule.Initialize(); NetworkModule.Initialize(); PhysicsModule.Initialize(); EnvironmentModule.Initialize(); UIModule.Initialize(); NETCoreModule.Initialize(); NETScriptModule.Initialize(); AtomicPlayer.PlayerModule.Initialize(); }
private static void TickSound(float deltaTime) { Vector3 ballVelo = egg.Velocity; float ballSpeed = ballVelo.Length; float speedLastFrame = velocityLastFrame.Length; const int TICK_SOUND_EARLINESS_MS = 200; // Tick int adjustedTimeRemainingMs = timeRemainingMs - TICK_SOUND_EARLINESS_MS; int timeRemainingSecs = adjustedTimeRemainingMs / 1000; if (timeRemainingSecs != 0 && timeRemainingSecs != (int)(adjustedTimeRemainingMs + deltaTime * 1000f) / 1000) { int instanceId = AudioModule.CreateSoundInstance(AssetLocator.TickSound); AudioModule.PlaySoundInstance( instanceId, false, 0.2f * Config.SoundEffectVolume, adjustedTimeRemainingMs > Config.TimePitchRaiseMs ? 1f : (adjustedTimeRemainingMs > Config.TimeWarningMs ? 1.1f : 1.2f) ); } // Bounce if (velocityLastFrame != Vector3.ZERO && ballSpeed >= MIN_SPEED_FOR_DIFFERENTIAL_ANGLE_BOUNCE_SOUND && Vector3.AngleBetween(ballVelo, velocityLastFrame) >= MIN_VELO_DIFFERENTIAL_ANGLE_FOR_BOUNCE_SOUND) { if (lastBounceSoundTime - timeRemainingMs >= BOUNCE_SOUND_MIN_INTERVAL) { int instanceId = AudioModule.CreateSoundInstance(AssetLocator.ObtuseBounceSound); AudioModule.PlaySoundInstance( instanceId, false, BOUNCE_VOLUME * Config.SoundEffectVolume, RandomProvider.Next(BOUNCE_PITCH_MIN, BOUNCE_PITCH_MAX) ); instanceId = AudioModule.CreateSoundInstance(AssetLocator.ImpactSounds[RandomProvider.Next(0, AssetLocator.ImpactSounds.Length)]); AudioModule.PlaySoundInstance( instanceId, false, IMPACT_VOLUME * Config.SoundEffectVolume, RandomProvider.Next(IMPACT_PITCH_MIN, IMPACT_PITCH_MAX) ); lastBounceSoundTime = timeRemainingMs; } float speedDiff = Math.Abs(speedLastFrame - ballSpeed); int baseBitsCount = 3; if (speedDiff >= PhysicsManager.ONE_METRE_SCALED * 10f) { baseBitsCount = 13; } else if (speedDiff >= PhysicsManager.ONE_METRE_SCALED * 8f) { baseBitsCount = 11; } else if (speedDiff >= PhysicsManager.ONE_METRE_SCALED * 6f) { baseBitsCount = 7; } else if (speedDiff >= PhysicsManager.ONE_METRE_SCALED * 4f) { baseBitsCount = 5; } CollisionBitPool.DisseminateBits(egg.Transform.Translation, -boardDownDir.WithLength(speedDiff * 0.65f), baseBitsCount * (int)Config.PhysicsLevel); MaybePlayAllBounce(speedDiff); } else if (Math.Abs(ballSpeed - speedLastFrame) >= MIN_SPEED_CHANGE_FOR_BOUNCE_SOUND) // bounce in same direction { if (lastBounceSoundTime - timeRemainingMs >= BOUNCE_SOUND_MIN_INTERVAL) { int instanceId = AudioModule.CreateSoundInstance(AssetLocator.AcuteBounceSound); AudioModule.PlaySoundInstance( instanceId, false, BOUNCE_VOLUME * Config.SoundEffectVolume, RandomProvider.Next(BOUNCE_PITCH_MIN, BOUNCE_PITCH_MAX) ); instanceId = AudioModule.CreateSoundInstance(AssetLocator.ImpactSounds[RandomProvider.Next(0, AssetLocator.ImpactSounds.Length)]); AudioModule.PlaySoundInstance( instanceId, false, IMPACT_VOLUME * Config.SoundEffectVolume, RandomProvider.Next(IMPACT_PITCH_MIN, IMPACT_PITCH_MAX) ); lastBounceSoundTime = timeRemainingMs; } float speedDiff = Math.Abs(speedLastFrame - ballSpeed); int baseBitsCount = 2; if (speedDiff >= PhysicsManager.ONE_METRE_SCALED * 10f) { baseBitsCount = 13; } else if (speedDiff >= PhysicsManager.ONE_METRE_SCALED * 8f) { baseBitsCount = 11; } else if (speedDiff >= PhysicsManager.ONE_METRE_SCALED * 6f) { baseBitsCount = 7; } else if (speedDiff >= PhysicsManager.ONE_METRE_SCALED * 4f) { baseBitsCount = 3; } CollisionBitPool.DisseminateBits(egg.Transform.Translation, -boardDownDir.WithLength(speedDiff * 0.65f), baseBitsCount * (int)Config.PhysicsLevel); MaybePlayAllBounce(speedDiff); } // Roll float rollVolFraction = (ballSpeed - GameplayConstants.EGG_SPEED_FOR_MIN_ROLL_VOL) / (GameplayConstants.EGG_SPEED_FOR_MAX_ROLL_VOL - GameplayConstants.EGG_SPEED_FOR_MIN_ROLL_VOL); float rollFreqFraction = (ballSpeed - GameplayConstants.EGG_SPEED_FOR_MIN_ROLL_FREQ) / (GameplayConstants.EGG_SPEED_FOR_MAX_ROLL_FREQ - GameplayConstants.EGG_SPEED_FOR_MIN_ROLL_FREQ); Vector3 eggPos = egg.Transform.Translation; Ray rollTestRay = Ray.FromStartAndEndPoint( eggPos, eggPos + boardDownDir.WithLength(GameplayConstants.EGG_COLLISION_RADIUS + ROLL_MARGIN) ); EntityModule.RayTestAllLessGarbage(rollTestRay, reusableRayTestResultsList); bool isRolling = false; for (int i = 0; i < reusableRayTestResultsList.Count; ++i) { if (reusableRayTestResultsList[i].Entity != egg) { isRolling = true; break; } } if (isRolling) { if (unbrokenRollTime == 0) { unbrokenRollTime = (int)(deltaTime * 1000f); } else { unbrokenRollTime += lastRollTime - timeRemainingMs; } lastRollTime = timeRemainingMs; } else { if (unbrokenRollTime < UNBROKEN_ROLL_TIME_BEFORE_ROLL_SOUND || lastRollTime - timeRemainingMs > ROLL_RAY_FAIL_MAX_TIME_BEFORE_UNBROKEN_ROLL_RESET) { unbrokenRollTime = 0; } } if (unbrokenRollTime < UNBROKEN_ROLL_TIME_BEFORE_ROLL_SOUND || lastRollTime - timeRemainingMs > ROLL_RAY_FAIL_MAX_TIME_BEFORE_NO_SOUND_MS || rollVolFraction <= 0f || rollFreqFraction <= 0f) { AudioModule.SetSoundInstanceVolume(AssetLocator.RollSound.SoundInstanceIds.First(), 0f); } else { if (rollVolFraction > 1f) { rollVolFraction = 1f; } if (rollFreqFraction > 1f) { rollFreqFraction = 1f; } AudioModule.SetSoundInstanceFrequency(AssetLocator.RollSound.SoundInstanceIds.First(), ROLL_FREQ_MIN + (ROLL_FREQ_MAX - ROLL_FREQ_MIN) * rollFreqFraction); AudioModule.SetSoundInstanceVolume(AssetLocator.RollSound.SoundInstanceIds.First(), ROLL_VOLUME_MIN + (ROLL_VOLUME_MAX - ROLL_VOLUME_MIN) * rollVolFraction * Config.SoundEffectVolume); } // Highspeed if (ballSpeed >= HIGHSPEED_SOUND_MIN_SPEED) { float angleToUp = Vector3.AngleBetween(ballVelo, -boardDownDir); float angleToDown = Vector3.AngleBetween(ballVelo, boardDownDir); if (angleToUp <= MathUtils.PI_OVER_TWO * 0.5f) { if (highspeedUpMetadata.TimeAtLastSound - timeRemainingMs >= MIN_INTERVAL_BETWEEN_HIGHSPEED_SOUNDS_MS && highspeedUpMetadata.CollidedSinceLastSound && highspeedUpMetadata.SlowedSinceLastSound) { int instanceId = AudioModule.CreateSoundInstance(AssetLocator.HighSpeedUpSounds[RandomProvider.Next(0, AssetLocator.HighSpeedUpSounds.Length)]); AudioModule.PlaySoundInstance( instanceId, false, HIGHSPEED_VOLUME * Config.SoundEffectVolume, RandomProvider.Next(HIGHSPEED_PITCH_MIN, HIGHSPEED_PITCH_MAX) ); highspeedUpMetadata.CollidedSinceLastSound = highspeedUpMetadata.SlowedSinceLastSound = false; highspeedUpMetadata.TimeAtLastSound = timeRemainingMs; } } else if (angleToDown <= MathUtils.PI_OVER_TWO * 0.5f) { Ray downRay = Ray.FromStartAndEndPoint(eggPos, eggPos + boardDownDir.WithLength(PARALLEL_HIGHSPEED_DOWN_BUFFER)); bool somethingBeneath = EntityModule.RayTestAll(downRay).Any(rtc => rtc.Entity != egg); if (highspeedDownMetadata.TimeAtLastSound - timeRemainingMs >= MIN_INTERVAL_BETWEEN_HIGHSPEED_SOUNDS_MS && highspeedDownMetadata.CollidedSinceLastSound && highspeedDownMetadata.SlowedSinceLastSound && !somethingBeneath) { int instanceId = AudioModule.CreateSoundInstance(AssetLocator.HighSpeedDownSounds[RandomProvider.Next(0, AssetLocator.HighSpeedDownSounds.Length)]); AudioModule.PlaySoundInstance( instanceId, false, HIGHSPEED_VOLUME * Config.SoundEffectVolume, RandomProvider.Next(HIGHSPEED_PITCH_MIN, HIGHSPEED_PITCH_MAX) ); highspeedDownMetadata.CollidedSinceLastSound = highspeedDownMetadata.SlowedSinceLastSound = false; highspeedDownMetadata.TimeAtLastSound = timeRemainingMs; } } else if (ballSpeed >= HIGHSPEED_SOUND_MIN_SPEED + HIGHSPEED_SOUND_ADDITIONAL_SPEED_FOR_PARALLEL) { if (highspeedParallelMetadata.TimeAtLastSound - timeRemainingMs >= MIN_INTERVAL_BETWEEN_HIGHSPEED_SOUNDS_MS && highspeedParallelMetadata.CollidedSinceLastSound && highspeedParallelMetadata.SlowedSinceLastSound) { int instanceId = AudioModule.CreateSoundInstance(AssetLocator.HighSpeedParallelSounds[RandomProvider.Next(0, AssetLocator.HighSpeedParallelSounds.Length)]); AudioModule.PlaySoundInstance( instanceId, false, HIGHSPEED_VOLUME * Config.SoundEffectVolume, RandomProvider.Next(HIGHSPEED_PITCH_MIN, HIGHSPEED_PITCH_MAX) ); highspeedParallelMetadata.CollidedSinceLastSound = highspeedParallelMetadata.SlowedSinceLastSound = false; highspeedParallelMetadata.TimeAtLastSound = timeRemainingMs; } } } else { highspeedUpMetadata.SlowedSinceLastSound = highspeedDownMetadata.SlowedSinceLastSound = highspeedParallelMetadata.SlowedSinceLastSound = true; } // Countdown Timer if (!playingCountdownTimer && timeRemainingMs <= COUNTDOWN_TIMER_START_TIME_MS) { int instanceId = AudioModule.CreateSoundInstance(AssetLocator.CountdownLoopSound.File); AssetLocator.CountdownLoopSound.AddInstance(instanceId); AudioModule.PlaySoundInstance(instanceId, true, COUNTDOWN_VOLUME); playingCountdownTimer = true; } velocityLastFrame = ballVelo; }
public async Task StartQCM([Remainder] string qcmName) { Console.WriteLine(); Qcm qcm = await GetQcm(qcmName); AudioService audioService = (AudioService)Program._services.GetService(typeof(AudioService)); if (am == null) { am = new AudioModule(audioService, Context); } IMessage msg = null; if (!qcm.HasStarted) { stopwatch.Restart(); qcm.HasStarted = true; Console.WriteLine("Affichage Q1"); // Si ça buggue ç'est à cause du display Mode msg = await qcm.DisplayInDiscord(_client.GetChannel(414746672284041222) as ISocketMessageChannel, qcm.questions[0], Qcm.DisplayMode.QCM, am); qcm.questionsID.Add(msg.Id); } else //Problème réussir à bloquer l'affichage Q2 cad ignorer le dernier smiley { ISocketMessageChannel channel = _client.GetChannel(414746672284041222) as ISocketMessageChannel; if (i < qcm.questions.Count) { Console.WriteLine("On arrive à une question de type :" + qcm.questions[i].type); msg = await qcm.DisplayInDiscord(_client.GetChannel(414746672284041222) as ISocketMessageChannel, qcm.questions[i], Qcm.DisplayMode.QCM); qcm.questionsID.Add(msg.Id); Console.WriteLine(stopwatch.ElapsedMilliseconds); } // Tableau des réponses else { // Le tableau des réponses ne s'affiche que pour un affichage de type QCM if (qcm.displayMode == Qcm.DisplayMode.QCM) { await channel.SendMessageAsync("Vous êtes arrivé au bout de ce QCM"); await channel.SendMessageAsync("Réponses enregistrées : " + qcm.allAnswers.Count); EmbedBuilder embed = new EmbedBuilder(); int i = 0; int score = 0; int maxScore = qcm.allAnswers.Count; Console.OutputEncoding = System.Text.Encoding.UTF8; var usersIDThatAnswered = new List <ulong>(); var playerList = new List <QcmPlayer>(); foreach (var ans in qcm.allAnswers) { if (!usersIDThatAnswered.Contains(ans.User.Value.Id)) { usersIDThatAnswered.Add(ans.User.Value.Id); playerList.Add(new QcmPlayer(ans.User.Value)); } } foreach (var ans in qcm.allAnswers) { try { if (ans.Emote.Name != null) { embed.AddField("Votre Réponse n°" + (i + 1) + " : " + ans.Emote.Name, " par " + ans.User.Value.Username); foreach (var player in playerList) { if (ans.Emote.Name == qcm.questions[i].answerLetter && ans.User.Value == player.user) { player.score++; } if (ans.User.Value == player.user) { player.maxScore++; } } embed.AddField("Bonne réponse ", qcm.questions[i].answer + ":" + qcm.questions[i].answerLetter); if (ans.Emote.Name == qcm.questions[i].answerLetter) { score++; } else { Console.WriteLine(ans.Emote.Name + " : " + qcm.questions[i].answerLetter); } } i++; embed.AddField("", ""); } catch (Exception ex) { Console.WriteLine(ex); } } await channel.SendMessageAsync("", false, embed); await channel.SendMessageAsync(" Score Final " + score + " / " + maxScore + "\n Durée : " + (stopwatch.ElapsedMilliseconds / 1000) + "s"); foreach (var player in playerList) { await channel.SendMessageAsync(">> " + player.user.Username + " Score : " + player.score + " / " + player.maxScore); } } } } // return msg; }
public async Task Leave() { AudioService audioService = (AudioService)Program._services.GetService(typeof(AudioService)); AudioModule am = new AudioModule(audioService, Context); await am.LeaveCmd(); }
private static void Sounds_LevelUnpause() { AudioModule.PlaySoundInstance(AssetLocator.RollSound.SoundInstanceIds.First(), true, 0f); }
private static void Sounds_LevelPause() { AudioModule.PauseSoundInstance(AssetLocator.RollSound.SoundInstanceIds.First()); }
public async Task <IMessage> DisplayInDiscord(ISocketMessageChannel channel, Question question, DisplayMode display = DisplayMode.QCM, AudioModule am = null) { Console.WriteLine("Fonction d'affichage lancée ( Nom : DisplayInDiscord ) "); IUserMessage msg; if (display == DisplayMode.QCM) { if (question.type == QType.text) { EmbedBuilder eb = (EmbedBuilder)question.content; msg = await channel.SendMessageAsync("", false, eb); await AddQcmReactions(msg); } else if (question.type == QType.image) { Console.WriteLine("Tentative d'affichage pour type image..."); if (question.content.GetType() == typeof(List <EmbedBuilder>)) // si plusieurs embeds et donc plusieurs iamges { List <EmbedBuilder> imagesEb = (List <EmbedBuilder>)question.content; // Liste d'eb donc liste d'images if (question.imageQuestion == ImageQuestion.CorrespondingImageMultiple) { Console.WriteLine(" Type: images multiples"); foreach (var eb in (List <EmbedBuilder>)question.content) { // on envoie chaque image await channel.SendMessageAsync(question.name, false, eb); } // Enfin, on affiche le nom de la question msg = await channel.SendMessageAsync(question.name); await AddQcmReactions(msg); } else { Console.WriteLine(" Type: image seule dans une Liste"); msg = await channel.SendMessageAsync("", false, imagesEb[SimpleID]); SimpleID++; await AddQcmReactions(msg); } } else { Console.WriteLine("Type: image seule"); // Si ce n'est pas une liste, c'est un seul élément, donc une seule image EmbedBuilder eb = (EmbedBuilder)question.content; msg = await channel.SendMessageAsync("DisplayInDiscord()", false, eb); await AddQcmReactions(msg); } } else if (question.type == QType.audio) { Console.WriteLine(">>>Question Audio"); EmbedBuilder eb = ((question.content as object[])[0] as EmbedBuilder); msg = await channel.SendMessageAsync("DisplayInDiscord()", false, eb); try { // Permet d'empêcher l'audio module d'être recrée, ce qui entraînerait une exception if (audioModule == null) { audioModule = am; } Thread t = new Thread(async() => await audioModule.PlayMusic("./BlindTest/" + ((question.content as object[])[1] as string))); t.Start(); } catch (Exception ex) { Console.WriteLine(ex); } await AddQcmReactions(msg); Console.WriteLine(">>>Succès"); } else { await Console.Out.WriteLineAsync("Pas de type texte ou image"); msg = await channel.SendMessageAsync("Questions de type : " + question.type + " pas encore gérées"); await AddQcmReactions(msg, true); } return(msg); } else { Console.WriteLine("A faire"); return(null); } }
void PluginResetBuffers(VstPlugin input, VstPlugin output, int blockSize) { if (Inputs!=null) { if (Inputs.BlockSize!=blockSize && input!=null) Inputs = PluginResetBuffer(input,blockSize); } else if (input!=null) Inputs = PluginResetBuffer(input,blockSize); if (Outputs!=null) { if (Outputs.BlockSize!=blockSize && output!=null) Outputs = PluginResetBuffer(output,blockSize); } else if (output!=null) Outputs = PluginResetBuffer(output,blockSize); }