Ejemplo n.º 1
0
 private void TimeUntilIncrementHandler(object sender, TimerArgs e)
 {
     if (OnSecondsTillIncrementUpdated != null)
     {
         OnSecondsTillIncrementUpdated(e.TimeLeft);
     }
 }
Ejemplo n.º 2
0
 private void logic_TimerUp(object sender, TimerArgs e)
 {
     Device.BeginInvokeOnMainThread(() =>
     {
         VerstricheneZeit = e.Timer;
     });
 }
Ejemplo n.º 3
0
 void TaskDialog_Timer(ITaskDialog sender, TimerArgs args)
 {
     Console.WriteLine("Timer invoked. Current count: {0}ms", args.TickCount);
     if (ResetCallbackTimer)
     {
         ResetCallbackTimer = false;
         args.Reset         = true;
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 延迟指定时间后执行
 /// </summary>
 /// <param name="time">延迟时间(秒)</param>
 public ITimer Delay(float time)
 {
     GuardComplete("Delay");
     Guard.Requires <ArgumentOutOfRangeException>(time > 0);
     args = new TimerArgs
     {
         Type      = TimerTypes.DelayTime,
         FloatArgs = new[] { time, 0 }
     };
     return(this);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 循环执行,直到函数返回false
 /// </summary>
 /// <param name="callback">循环状态函数</param>
 public ITimer Loop(Func <bool> callback)
 {
     GuardComplete("Loop");
     Guard.NotNull(callback, "callback");
     args = new TimerArgs
     {
         Type        = TimerTypes.LoopFunc,
         FuncBoolArg = callback
     };
     return(this);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 延迟指定帧数帧后执行
 /// </summary>
 /// <param name="frame">帧数</param>
 public ITimer DelayFrame(int frame)
 {
     GuardComplete("DelayFrame");
     Guard.Requires <ArgumentOutOfRangeException>(frame > 0);
     args = new TimerArgs
     {
         Type    = TimerTypes.DelayFrame,
         IntArgs = new[] { frame, 0 }
     };
     return(this);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 循环执行指定时间
 /// </summary>
 /// <param name="time">循环时间(秒)</param>
 public ITimer Loop(float time)
 {
     GuardCompleted("Loop");
     Guard.Requires <ArgumentOutOfRangeException>(time > 0);
     args = new TimerArgs
     {
         Type      = TimerTypes.LoopTime,
         FloatArgs = new[] { time, 0 }
     };
     return(this);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 循环执行指定帧数
 /// </summary>
 /// <param name="frame">循环执行的帧数</param>
 public ITimer LoopFrame(int frame)
 {
     GuardComplete("LoopFrame");
     Guard.Requires <ArgumentOutOfRangeException>(frame > 0);
     frame = Math.Max(0, frame);
     args  = new TimerArgs
     {
         Type    = TimerTypes.LoopFrame,
         IntArgs = new[] { frame, 0 }
     };
     return(this);
 }
Ejemplo n.º 9
0
        /// <summary>
        /// 间隔多少帧执行一次
        /// </summary>
        /// <param name="frame">间隔的帧数</param>
        /// <param name="life">最多允许触发的次数</param>
        public ITimer IntervalFrame(int frame, int life = 0)
        {
            GuardComplete("IntervalFrame");
            Guard.Requires <ArgumentOutOfRangeException>(frame > 0);
            if (task == null)
            {
                throw new RuntimeException("Timer Task can not be null");
            }

            args = new TimerArgs
            {
                Type    = TimerTypes.IntervalFrame,
                IntArgs = new[] { frame, 0, life, 0 }
            };
            return(this);
        }
Ejemplo n.º 10
0
        static void TimerCallback(SchedulerTask task)
        {
            TimerArgs args = (TimerArgs)task.State;
            Player    p    = args.Player;

            args.Repeats--;
            if (args.Repeats == 0 || !p.cmdTimer)
            {
                p.Message("Timer ended.");
                p.cmdTimer     = false;
                task.Repeating = false;
            }
            else
            {
                p.level.Message(args.Message);
                p.level.Message("Timer has " + (args.Repeats * 5) + " seconds remaining.");
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 间隔多少时间执行一次
        /// </summary>
        /// <param name="time">间隔的时间</param>
        /// <param name="life">最多允许触发的次数</param>
        public ITimer Interval(float time, int life = 0)
        {
            GuardComplete("Interval");
            Guard.Requires <ArgumentOutOfRangeException>(time > 0);
            if (task == null)
            {
                throw new RuntimeException("Timer Task can not be null");
            }

            time = Math.Max(0, time);
            args = new TimerArgs
            {
                Type      = TimerTypes.Interval,
                FloatArgs = new[] { time, 0 },
                IntArgs   = new[] { life, 0 }
            };
            return(this);
        }
Ejemplo n.º 12
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (p.cmdTimer)
            {
                p.Message("Can only have one timer at a time. Use /abort to cancel your previous timer."); return;
            }
            if (message.Length == 0)
            {
                Help(p); return;
            }

            int TotalTime = 0;

            try
            {
                TotalTime = int.Parse(message.SplitSpaces()[0]);
                message   = message.Substring(message.IndexOf(' ') + 1);
            }
            catch
            {
                TotalTime = 60;
            }

            if (TotalTime > 300)
            {
                p.Message("Cannot have more than 5 minutes in a timer"); return;
            }

            TimerArgs args = new TimerArgs();

            args.Message = message;
            args.Repeats = (int)(TotalTime / 5) + 1;
            args.Player  = p;

            p.cmdTimer = true;
            p.level.Message("Timer lasting for " + TotalTime + " seconds has started.");
            p.level.Message(args.Message);
            Server.MainScheduler.QueueRepeat(TimerCallback, args, TimeSpan.FromSeconds(5));
        }
Ejemplo n.º 13
0
 private void HandleOnEnergyTimerUpdate(object sender, TimerArgs e)
 {
     // handle e.TimeLeft
 }
Ejemplo n.º 14
0
 public void ShowMessage(object sender, TimerArgs e)
 {
     Console.WriteLine($"Lister get message {e.msg} from {sender.ToString()}");
 }
Ejemplo n.º 15
0
        protected void OnTimer(string Timer)
        {
            var args = new TimerArgs(Timer);

            TimerUp(this, args);
        }