public static void RecurrentTimer(float time, TimerFunction onTimerEnd) { Timer oneShotTimer = new Timer(time, onTimerEnd); onTimerEnd += () => { oneShotTimer.ResetPlay(); }; oneShotTimer.Play(); }
public Timer(float duration, TimerFunction action) { this.duration = duration; this.action = action; MakeRandomID(); }
public Timer(float duration, TimerFunction action, bool ignoreSpeed, string id) { this.duration = duration; this.action = action; this.ignoreSpeed = ignoreSpeed; this.id = id; }
public static void InitializeTimer(DispatcherTimer timer, TimerFunction func) { timer = new DispatcherTimer(); timer.Tick += new EventHandler(func); timer.Interval = new TimeSpan(0, 0, 0, 2); timer.Start(); }
public Timer(float duration, TimerFunction action, bool ignoreSpeed) { this.duration = duration; this.action = action; this.ignoreSpeed = ignoreSpeed; MakeRandomID(); }
public void Action(Action a, float t) { TimerFunction timerFunction = new TimerFunction(); timerFunction.invokeAction = a; timerFunction.timeRemain = t; collection.Add(timerFunction); }
/// <summary>if anything happening; safely ignored otherwise</summary> public void Cancel() { m_Timer.Enabled = false; m_fnTimeUp = null; m_Duration = 0; m_StartAt = Environment.TickCount; Meaning = 0; }
public void Timer_should_log_message() { var logger = (ListLogger)TestFactory.CreateLogger(LoggerTypes.List); TimerFunction.Run(null, logger); var msg = logger.Logs[0]; Assert.Contains("C# Timer trigger function executed at", msg); }
private EasingTimer(int n, TimerFunction func, List<angleXYZ> angles, int dir, rotateAxisType rotateAxis, timerUPFunction funcUp = null) : base(100) { this.firstAngle = 0; this.rotateN = n; this.begin_time = DateTime.Now; this.func = new ElapsedEventHandler(func); this.Elapsed += this.func; this._run = false; this.dir = dir; this.rotateAxis = rotateAxis; this.funcUp = funcUp; }
private void m_Timer_Tick(object sender, EventArgs e) { m_Timer.Enabled = false; if (m_fnTimeUp == null) { return; } TimerFunction fnCurrent = m_fnTimeUp; m_fnTimeUp = null; // must be before the Invoke, which might change this fnCurrent.Invoke(); // must not clear Meaning - Invoke might want to check it }
public void SetTimeoutFunction(string nm, int ms, TimerFunction func) { TimerData t = new TimerData(); t.tickRun = Const.Tick + ms; t.tickCont = 0; t.func = func; if (timerAdd == null) { timerAdd = new Hashtable(); } timerAdd[nm] = t; }
protected override void BeforeProcessFunction() { if (duelScene.GetCurrentPhaseType() == phaseType) { Debug.LogError("当前流程已经是:" + phaseType + "无法重复进入!"); return; } switch (duelScene.GetCurrentPhaseType()) { case PhaseType.Unknown: break; case PhaseType.Draw: break; case PhaseType.Prepare: break; case PhaseType.Main: break; case PhaseType.Battle: EndBattlePhaseTypeEvent(); break; case PhaseType.Second: break; case PhaseType.End: break; default: break; } duelScene.SetCurrentPhaseType(phaseType); duelScene.ResetPhaseTypePanelInfo(); string ex = duelScene.GetCurrentPlayer() == duelScene.GetMyPlayer() ? "我方进入" : "对方进入"; PhaseTypeConfig phaseTypeConfig = ConfigManager.GetConfigByName("PhaseType") as PhaseTypeConfig; GameManager.ShowMessage(ex + phaseTypeConfig.GetRecordById((int)phaseType).value + "流程!"); duelScene.GetCurrentPlayer().GetOpponentPlayer().EnterPhaseNotify(phaseType); TimerFunction timerFunction = new TimerFunction(); timerFunction.SetFunction(1, () => { DoProcessFunction(); }); GameManager.AddTimerFunction(timerFunction); }
public void OpponentSelectFirstOrBack(bool selectFirstOrBack) { GuessFirstSceneScript guessFirstSceneScript = GameObject.Find("Main Camera").GetComponent <GuessFirstSceneScript>(); SetFirst(!selectFirstOrBack); TimerFunction timeFunction = new TimerFunction(); timeFunction.SetFunction(1, () => { GameManager.GetSingleInstance().EnterDuelScene(); }); GameManager.AddTimerFunction(timeFunction); guessFirstSceneScript.HideSelectFirstPanel(); }
/// <summary> /// 设置胜者 /// </summary> /// <param name="player"></param> public void SetWinner(Player player, DuelEndReason duelEndReason) { duelSceneScript.ShowDuelResultPanel(player, duelEndReason); TimerFunction timerFunction = new TimerFunction(); timerFunction.SetFunction(2, () => { Thread.Sleep(2000); GameManager.GetSingleInstance().CleanDuelScene(); GameManager.GetSingleInstance().EnterMainScene(); }); GameManager.AddTimerFunction(timerFunction); startDuel = false; }
/// <summary> /// 检查是否决斗双方都已经初始化完成 /// </summary> public void CheckPlayInit() { if (myPlayer.IAmReady() && opponentPlayer.IAmReady()) { currentPlayer = startPlayer; TimerFunction timerFunction = new TimerFunction(); timerFunction.SetFunction(1, () => { duelSceneScript = GameObject.Find("Main Camera").GetComponent <DuelSceneScript>(); myPlayer.SetHandPanel(myHandCardPanel); opponentPlayer.SetHandPanel(opponentHandCardPanel); StartDuel(); }); GameManager.AddTimerFunction(timerFunction); } }
public void Start(int time, TimerFunction fnTimeUp, Engine.Timings meaning = 0) { m_Timer.Enabled = false; m_fnTimeUp = null; m_Duration = time; m_StartAt = Environment.TickCount; Meaning = meaning; if (time <= 0) { // fire now fnTimeUp.Invoke(); } else { m_fnTimeUp = fnTimeUp; m_Timer.Interval = time; m_Timer.Enabled = true; } }
/// <summary> /// 选择后手事件 /// </summary> public void SelectBackHandEvent() { if (iGuessWin == 1) { duelScene.SetFirst(false); TimerFunction timeFunction = new TimerFunction(); timeFunction.SetFunction(1, () => { GameManager.GetSingleInstance().EnterDuelScene(); }); GameManager.AddTimerFunction(timeFunction); selectFirstPanel.SetActive(false); } else { GameManager.ShowMessage("请等待对方选择!"); } }
public override void SelectFristOrBack() { System.Random random = new System.Random(); int i = random.Next(2); if (i == 0) { duelScene.SetFirst(true); } else { duelScene.SetFirst(false); } TimerFunction timerFunction = new TimerFunction(); timerFunction.SetFunction(1, () => { GameManager.GetSingleInstance().EnterDuelScene(); }); GameManager.AddTimerFunction(timerFunction); }
/// <summary> /// 开始决斗 /// </summary> void StartDuel() { myPlayer.InitBeforDuel(); opponentPlayer.InitBeforDuel(); GameManager.ShowMessage("决斗开始!"); startDuel = true; TimerFunction timerFunction = new TimerFunction(); timerFunction.SetFunction(1, () => { myPlayer.DrawAtFirst(); opponentPlayer.DrawAtFirst(); startPlayer.StartTurn(); }); GameManager.AddTimerFunction(timerFunction); }
public static void Timer(TimerFunction func, int seconds, string registryName) { // seconds must >= 1 if (seconds < 1) { throw new Exception("The \"seconds\" argument in FoeServerScheduler.Timer must be >= 1."); } int timeRemain = 0; try { // Reset registry flag ResetRegistryFlag(); while (!IsStopProcess()) { if (timeRemain <= 0) { // Call function func(null); // reset timer timeRemain = seconds; } else { timeRemain--; } Thread.Sleep(1000); } } catch (Exception except) { throw except; } }
public static void rotate(int n, TimerFunction func, List<angleXYZ> angles, int dir, rotateAxisType rotateAxis, timerUPFunction funcUp = null) { if (t == null) { //MessageBox.Show("firstAngle = " + firstAngle.ToString()); t = new EasingTimer(n, func, angles, dir, rotateAxis, funcUp); t.rotateAxis = rotateAxis; } else { //если прокручивание работает, то просто возвращаем таймер //если прокручинваие уже не работает, то заново инициализируем переменные, как бы вызываем конструктор if (!t._run) { //MessageBox.Show("2: firstAngle = " + firstAngle.ToString()); t.firstAngle = 0; t.rotateN = n; t.begin_time = DateTime.Now; t.Elapsed -= t.func; t.func = new ElapsedEventHandler(func); t.Elapsed += t.func; t.dir = dir; t.rotateAxis = rotateAxis; t.funcUp = funcUp; } } //Если уже пошёл процесс кручения, то выходим if (t._run) { return; } t._run = true; t.Start(); }
public void SetTimerFunction(string nm, int ms, TimerFunction func) { TimerData t=new TimerData(); t.tickRun=Const.Tick+ms; t.tickCont=ms; t.func=func; if(timerAdd==null)timerAdd=new Hashtable(); timerAdd[nm]=t; }
/// <summary> /// Crée un nouveau Timer non affecté par la vitesse d'écoulement du temps en jeu /// </summary> /// <param name="endTime">Temps de fin du chrono</param> /// <param name="function">Fonction déclanché à la fin du timer.</param> public TimeNonAffectedTimer(float endTime, TimerFunction function) : base(endTime, function) { }
/// <summary> /// Crée un nouveau Timer /// </summary> /// <param name="endTime">Temps de fin du chrono</param> /// <param name="function">Fonction déclanché à la fin du timer.</param> /// <param name="isAlreadyFinished">Le timer doit-il être fini tout de suite?</param> public Timer(float endTime, TimerFunction function, bool isAlreadyFinished) : this(endTime, isAlreadyFinished) { OnTimerEnd += function; }
/// <summary> /// Crée un nouveau Timer /// </summary> /// <param name="endTime">Temps de fin du chrono</param> /// <param name="function">Fonction déclanché à la fin du timer.</param> public Timer(float endTime, TimerFunction function) : this(endTime){ OnTimerEnd += function; }
/// <summary> /// Crée un nouveau Timer non affecté par la vitesse d'écoulement du temps en jeu /// </summary> /// <param name="endTime">Temps de fin du chrono</param> /// <param name="function">Fonction déclanché à la fin du timer.</param> /// <param name="isAlreadyFinished">Le timer doit-il être fini tout de suite?</param> public TimeNonAffectedTimer(float endTime, TimerFunction function, bool isAlreadyFinished) : base(endTime, function, isAlreadyFinished) { }
// Starts a timer with "time" as endTime that's fired immediatly // Will play the onTimerEnd function as expected public static void OneShotTimer(float time, TimerFunction onTimerEnd) { Timer oneShotTimer = new Timer(time, onTimerEnd); oneShotTimer.Play(); }
/// <summary> /// 决定谁先出牌 /// </summary> public void DecideGuessFirst() { if (iGuessWin != 0) { return; } GuessEnum myGuessEnum = duelScene.GetMyPlayer().GetGuessEnum(); GuessEnum opponentGuessEnum = duelScene.GetOpponentPlayer().GetGuessEnum(); if (myGuessEnum != GuessEnum.Unknown && opponentGuessEnum != GuessEnum.Unknown) { if (myGuessEnum == opponentGuessEnum) { TimerFunction reguessTimeFunction = new TimerFunction(); reguessTimeFunction.SetFunction(1, () => { ClearChoose(); }); GameManager.AddTimerFunction(reguessTimeFunction); GameManager.ShowMessage("双方选择相同,需重新选择!"); return; } int tempValue = (int)myGuessEnum - (int)opponentGuessEnum; StringResConfig stringResConfig = ConfigManager.GetConfigByName("StringRes") as StringResConfig; string title; if (tempValue == 1 || tempValue == -2) { iGuessWin = 1; title = stringResConfig.GetRecordById(13).value; } else { iGuessWin = 2; title = stringResConfig.GetRecordById(14).value; } TimerFunction timerFunction = new TimerFunction(); timerFunction.SetFunction(1, () => { selectCardGroupPanel.SetActive(false); guessFirstPanel.SetActive(false); selectFirstPanel.SetActive(true); selectFirstPanel.transform.GetChild(0).GetComponent <Text>().text = title; if (iGuessWin == 1) { duelScene.GetMyPlayer().SelectFristOrBack(); } if (iGuessWin == 2) { duelScene.GetOpponentPlayer().SelectFristOrBack(); } }); GameManager.AddTimerFunction(timerFunction); } }
public Timer(float d, TimerFunction t) { duration = d; onTimer = t; }