コード例 #1
0
    public static void RecurrentTimer(float time, TimerFunction onTimerEnd)
    {
        Timer oneShotTimer = new Timer(time, onTimerEnd);

        onTimerEnd += () => { oneShotTimer.ResetPlay(); };
        oneShotTimer.Play();
    }
コード例 #2
0
    public Timer(float duration, TimerFunction action)
    {
        this.duration = duration;
        this.action   = action;

        MakeRandomID();
    }
コード例 #3
0
 public Timer(float duration, TimerFunction action, bool ignoreSpeed, string id)
 {
     this.duration    = duration;
     this.action      = action;
     this.ignoreSpeed = ignoreSpeed;
     this.id          = id;
 }
コード例 #4
0
 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();
 }
コード例 #5
0
    public Timer(float duration, TimerFunction action, bool ignoreSpeed)
    {
        this.duration    = duration;
        this.action      = action;
        this.ignoreSpeed = ignoreSpeed;

        MakeRandomID();
    }
コード例 #6
0
ファイル: TimeDelegate.cs プロジェクト: lutherkaran/MovoLit
    public void Action(Action a, float t)
    {
        TimerFunction timerFunction = new TimerFunction();

        timerFunction.invokeAction = a;
        timerFunction.timeRemain   = t;
        collection.Add(timerFunction);
    }
コード例 #7
0
ファイル: StateTimer.cs プロジェクト: stuart2w/SAW
 /// <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;
 }
コード例 #8
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);
        }
コード例 #9
0
ファイル: Form1.cs プロジェクト: junkissa/CubeR
 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;
 }
コード例 #10
0
ファイル: StateTimer.cs プロジェクト: stuart2w/SAW
        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
        }
コード例 #11
0
        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;
        }
コード例 #12
0
        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);
        }
コード例 #13
0
ファイル: DuelScene.cs プロジェクト: wlzs04/DuelMonsters
        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();
        }
コード例 #14
0
ファイル: DuelScene.cs プロジェクト: wlzs04/DuelMonsters
        /// <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;
        }
コード例 #15
0
ファイル: DuelScene.cs プロジェクト: wlzs04/DuelMonsters
        /// <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);
            }
        }
コード例 #16
0
ファイル: StateTimer.cs プロジェクト: stuart2w/SAW
 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;
     }
 }
コード例 #17
0
    /// <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("请等待对方选择!");
        }
    }
コード例 #18
0
ファイル: ComputerPlayer.cs プロジェクト: wlzs04/DuelMonsters
        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);
        }
コード例 #19
0
ファイル: DuelScene.cs プロジェクト: wlzs04/DuelMonsters
        /// <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);
        }
コード例 #20
0
        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;
            }
        }
コード例 #21
0
        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;
            }
        }
コード例 #22
0
ファイル: Form1.cs プロジェクト: junkissa/CubeR
        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();
        }
コード例 #23
0
ファイル: Net.cs プロジェクト: karliky/wowwow
 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;
 }
コード例 #24
0
 /// <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)
 {
 }
コード例 #25
0
 /// <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;
 }
コード例 #26
0
 /// <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;
 }
コード例 #27
0
 /// <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)
 {
 }
コード例 #28
0
    // 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();
    }
コード例 #29
0
    /// <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);
        }
    }
コード例 #30
0
 public Timer(float d, TimerFunction t)
 {
     duration = d;
     onTimer  = t;
 }