void HoldNote() { if (detector.IsHoldingLongNote) { if (m_ComboTimer == null) { m_ComboTimer = new RepeatingTimer(0.1f, () => { LevelManager.instance.Score += 50; ComboCounter.instance.IncreaseCombo(); }); } if (!longEffect.isPlaying) { longEffect.Play(); } } else { m_ComboTimer = null; if (!longEffect.isStopped) { longEffect.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear); } } }
public BusSubscriptionsWithOutboxShould() { var logger = Substitute.For <ILogger <BusSubscriptionsWithOutbox> >(); outboxRepository = Substitute.For <OutboxRepository>(new object[] { null }); timer = new RepeatingTimer(new TimerConfiguration() { DueSeconds = -1, PeriodSeconds = -1 }); busSubscriptions = new BusSubscriptionsWithOutbox(logger, outboxRepository, timer); }
public static Task startTimer() { Loop = new Timer() { Interval = RepeatingTimer.SecondsToMilli(5), AutoReset = false, Enabled = true }; Loop.Elapsed += onTimerTicked; return(Task.CompletedTask); }
// Start the spawning of this wave. public virtual int Init() { if (enemiesToSpawn.Count == 0) { return(0); } spawnTimer = new RepeatingTimer(delayToNextSpawn, SpawnCurrent); StartTimer(spawnTimer); waveManager = FindObjectOfType <WaveManager>(); return(enemiesToSpawn.Count); }
/// <summary> /// Initializes the Wave /// </summary> public virtual void Init() { // If the wave is empty then warn the level designer and fire complete event if (spawnInstructions.Count == 0) { Debug.LogWarning("[LEVEL] Empty Wave"); SafelyBroadcastWaveCompletedEvent(); return; } m_SpawnTimer = new RepeatingTimer(spawnInstructions[0].delayToSpawn, SpawnCurrent); StartTimer(m_SpawnTimer); }
/// <summary> /// 初始化波次 /// </summary> public virtual void Init() { if (spawnInstructions.Count == 0) { Debug.LogWarning("[LEVEL] Empty Wave"); SafelyBroadcastWaveCompletedEvent(); return; } m_SpawnTimer = new RepeatingTimer(spawnInstructions[0].delayToSpawn, SpawnCurrent); StartTimer(m_SpawnTimer); }
private Task Client_GuildMemberUpdated(SocketGuildUser arg1, SocketGuildUser arg2) { if (!userCheck(arg1, arg2)) { return(Task.CompletedTask); } string mes = DateTime.Now + " | ARG1: " + arg1 + "\tARG2: " + arg2; Log.AddTextToLog(mes); Console.WriteLine(mes); RepeatingTimer.UpdateAuditLog().GetAwaiter().GetResult(); return(Task.CompletedTask); }
private async Task Client_UserJoined(SocketGuildUser user) { await RepeatingTimer.UpdateAuditLog(user.Guild); ServerConfig config = ServerConfigs.GetConfig(user.Guild); string username = user.Username + "#" + user.Discriminator; if (config.NewUserMessage) { var channel = client.GetChannel(config.NewUserChannel) as SocketTextChannel; // Gets the channel to send the message in if (config.EnableServerStats) { await CreateStatChannels(user.Guild); await updMemberChan(user.Guild); } UserAccount account = UserAccounts.GetAccount(user); string msg = String.Format(Global.Welcome[rand.Next(Global.Welcome.Length)], username, user.Guild); //Welcome Message /* * var embed = new EmbedBuilder(); * embed.WithTitle("New User Joined!"); * embed.WithDescription(msg); * embed.WithThumbnailUrl(user.GetAvatarUrl()); * embed.WithColor(config.EmbedColorRed, config.EmbedColorGreen, config.EmbedColorBlue); * if (config.FooterText != "") * embed.WithFooter(config.FooterText); * if (config.TimeStamp) * embed.WithCurrentTimestamp(); * if (user.Id != BotID) * await channel.SendMessageAsync("", false, embed.Build()); //Welcomes the new user */ if (user.Id != BotID) { await channel.SendMessageAsync(msg); //Welcomes the new user } } Console.WriteLine(DateTime.Now.ToLocalTime() + " | " + username + " joined " + user.Guild.Name); if (config.RequiresVerification) { if (GetTChannel(user.Guild.TextChannels, "verification") == null) { await user.Guild.CreateTextChannelAsync("verification"); } await GetTChannel(user.Guild.TextChannels, "verification").SendMessageAsync("Type " + config.Prefix + "verify to verify your account."); } }
public async Task CheckAns(int answer) { int solution = RepeatingTimer.MathProblemSolver(); Console.WriteLine(solution); Console.WriteLine(answer); if (solution == answer) { await Context.Channel.SendMessageAsync(Context.User.Username + "got the right answer!!"); } else { await Context.Channel.SendMessageAsync(Context.User.Username + "wrong answer"); } }
public void UpdateGainRate(float currencyGainRate) { constantCurrencyGainRate = currencyGainRate; if (currencyGainRate < 0) { throw new ArgumentOutOfRangeException("currencyGainRate"); } if (_gainTimer == null) { _gainTimer = new RepeatingTimer(1 / constantCurrencyGainRate, ConstantGain); } else { _gainTimer.SetTime(1 / constantCurrencyGainRate); } }
void ReleaseNote() { if (detector.Notes.Count <= 0) { return; } // Only LongNote can be released var longNote = detector.Notes[0] as LongNote; if (longNote && longNote.Triggered) { m_ComboTimer = null; // Force reset timer when release long note longNote.Pressing = false; detector.Remove(longNote, false); } }
public MovingPlatform(vec3 scale, vec3 p1, vec3 p2, float duration) : base(EntityGroups.Platform) { this.scale = scale; this.p1 = p1; this.p2 = p2; var mid = (p1 + p2) / 2; this.p1 = mid; this.p2 = mid; timer = new RepeatingTimer(t => { direction = !direction; return(true); }, duration, TimerFlags.None); }
protected void SpawnBar() { if (m_BeatCount >= m_Beatmap.Count) { m_SpawnBarTimer = null; return; } for (int i = 0; i < 4; i++) { if (m_Beatmap[m_BeatCount].tracks[i]) { var bar = PoolManager.instance.GetPoolable(barPoolable).GetComponent <SingleNote>(); bar.gameObject.SetActive(true); bar.transform.position = spawnPoint[i]; m_ActiveBars.Add(bar); } } m_SpawnBarTimer.SetTime(m_Beatmap[m_BeatCount].delay); m_BeatCount++; }
private async Task Client_ready() { await RepeatingTimer.StartTimer(); // start timer to change bot status message await _client.SetGameAsync("DuckyBot | !help"); // set the bots "Playing" status await _client.SetStatusAsync(UserStatus.Online); // set the bots online status // EVENT HANDLERS //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _client.MessageReceived += General.Gay; _client.MessageReceived += General.JackFrags; _client.MessageReceived += General.HempusJibberish; _client.MessageReceived += Whiskers.GiveFeels; _client.MessageReceived += Ducky.FacebookOUT; _client.MessageReceived += Trucks.GiveDonut; _client.MessageReceived += Boon.GivePepega; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ await ConsoleInput().ConfigureAwait(false); }
public TextProcessor() { builder = new StringBuilder(); repeatDelay = new SingleTimer(t => repeatTimer.IsPaused = false); repeatTimer = new RepeatingTimer(t => { switch (repeatType) { case TextRepeatTypes.Left: cursor--; if (cursor == 0) { return(false); } break; case TextRepeatTypes.Right: cursor++; if (cursor == builder.Length) { return(false); } break; case TextRepeatTypes.Backspace: return(Backspace()); case TextRepeatTypes.Delete: return(Delete()); } return(true); }); repeatType = TextRepeatTypes.None; }
public void invoke_handler_every_period_passes_Starting_immediately() { var invokedTime = new Stopwatch(); invokedTime.Start(); var invocations = 0; var timer = new RepeatingTimer(new TimerConfiguration() { DueSeconds = 0, PeriodSeconds = 1 }) { OnTick = () => invocations += 1 }; while (invocations < 3) { Thread.Sleep(5); } timer.Dispose(); invokedTime.Stop(); Assert.True(invokedTime.ElapsedMilliseconds >= 20); }
public void not_process_if_another_process_is_still_running() { var invocations = 0; var timer = new RepeatingTimer(new TimerConfiguration() { DueSeconds = 0, PeriodSeconds = 1 }) { OnTick = () => { Thread.Sleep(11); invocations += 1; } }; while (invocations < 1) { Thread.Sleep(15); } timer.Dispose(); Assert.Equal(1, invocations); }
public void invoke_handler_for_first_time_when_dueTime_passes() { var invokedTime = new Stopwatch(); invokedTime.Start(); var invocations = 0; var timer = new RepeatingTimer(new TimerConfiguration() { DueSeconds = 1, PeriodSeconds = -1 }) { OnTick = () => invocations += 1 }; while (invocations < 1) { Thread.Sleep(5); } invokedTime.Stop(); timer.Dispose(); Assert.True(invokedTime.ElapsedMilliseconds >= 10); }
private async Task Client_UserLeft(SocketGuildUser user) { await RepeatingTimer.UpdateAuditLog(user.Guild); ServerConfig config = ServerConfigs.GetConfig(user.Guild); string username = user.Username + "#" + user.Discriminator; if (config.NewUserMessage) { var channel = client.GetChannel(config.NewUserChannel) as SocketTextChannel; // Gets the channel to send the message in if (config.EnableServerStats) { await CreateStatChannels(user.Guild); await updMemberChan(user.Guild); } string msg = String.Format(Global.Bye[rand.Next(Global.Bye.Length)], username, user.Guild) + " 👋"; //Bye message /* * var embed = new EmbedBuilder(); * embed.WithTitle($"{user.Username} Left"); * embed.WithThumbnailUrl(user.GetAvatarUrl()); * embed.WithDescription(msg); * embed.WithColor(config.EmbedColorRed, config.EmbedColorGreen, config.EmbedColorBlue); * if (config.FooterText != "") * embed.WithFooter(config.FooterText); * if (config.TimeStamp) * embed.WithCurrentTimestamp(); * if (user.Id != BotID) * await channel.SendMessageAsync("", false, embed.Build()); //Send byebye */ if (user.Id != BotID) { await channel.SendMessageAsync(msg); //Send byebye } } Console.WriteLine(DateTime.Now.ToLocalTime() + " | " + username + " left " + user.Guild.Name); }
private async Task Client_RoleCreated(SocketRole arg) { await RepeatingTimer.UpdateAuditLog(); }
void Start() { _timer = new RepeatingTimer(_shootRate, SpawnProjectile); }
public static RepeatingTimer StartTimer(this IContext context, TimeSpan period, bool startImmediatelly = true) { var timer = new RepeatingTimer(period, startImmediatelly); context.Run(timer); return timer; }
private async Task Client_UserUnbanned(SocketUser arg1, SocketGuild arg2) { await RepeatingTimer.UpdateAuditLog(); }
private async Task Client_ChannelUpdated(SocketChannel channel, SocketChannel socketChannel) { await RepeatingTimer.UpdateAuditLog(); }
protected void StartSpawning() { m_SpawnDelayTimer = null; m_SpawnBarTimer = new RepeatingTimer(1f / (BPM / 60.0f), SpawnBar); }
private async Task Client_UserUpdated(SocketUser arg1, SocketUser arg2) { //RepeatingTimer.UpdateAuditLog().GetAwaiter().GetResult(); //return Task.CompletedTask; await RepeatingTimer.UpdateAuditLog(); }
private async Task Client_MessageDeleted(Cacheable <IMessage, ulong> arg1, ISocketMessageChannel arg2) { await RepeatingTimer.UpdateAuditLog(); }
private async Task Client_GuildUpdated(SocketGuild arg1, SocketGuild arg2) { await RepeatingTimer.UpdateAuditLog(); }