Example #1
0
 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);
         }
     }
 }
Example #2
0
        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);
        }
Example #3
0
 public static Task startTimer()
 {
     Loop = new Timer()
     {
         Interval  = RepeatingTimer.SecondsToMilli(5),
         AutoReset = false,
         Enabled   = true
     };
     Loop.Elapsed += onTimerTicked;
     return(Task.CompletedTask);
 }
Example #4
0
 // 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);
 }
Example #5
0
 /// <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);
 }
Example #6
0
        /// <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);
        }
Example #7
0
        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);
        }
Example #8
0
        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.");
            }
        }
Example #9
0
        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");
            }
        }
Example #10
0
 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);
     }
 }
Example #11
0
    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);
        }
    }
Example #12
0
        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++;
 }
Example #14
0
        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);
        }
Example #15
0
        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);
        }
Example #19
0
        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);
        }
Example #20
0
 private async Task Client_RoleCreated(SocketRole arg)
 {
     await RepeatingTimer.UpdateAuditLog();
 }
 void Start()
 {
     _timer = new RepeatingTimer(_shootRate, SpawnProjectile);
 }
Example #22
0
 public static RepeatingTimer StartTimer(this IContext context, TimeSpan period, bool startImmediatelly = true)
 {
     var timer = new RepeatingTimer(period, startImmediatelly);
     context.Run(timer);
     return timer;
 }
Example #23
0
 private async Task Client_UserUnbanned(SocketUser arg1, SocketGuild arg2)
 {
     await RepeatingTimer.UpdateAuditLog();
 }
Example #24
0
 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);
 }
Example #26
0
 private async Task Client_UserUpdated(SocketUser arg1, SocketUser arg2)
 {
     //RepeatingTimer.UpdateAuditLog().GetAwaiter().GetResult();
     //return Task.CompletedTask;
     await RepeatingTimer.UpdateAuditLog();
 }
Example #27
0
 private async Task Client_MessageDeleted(Cacheable <IMessage, ulong> arg1, ISocketMessageChannel arg2)
 {
     await RepeatingTimer.UpdateAuditLog();
 }
Example #28
0
 private async Task Client_GuildUpdated(SocketGuild arg1, SocketGuild arg2)
 {
     await RepeatingTimer.UpdateAuditLog();
 }