示例#1
0
    private void Update()
    {
        pt.Update();

        //定时替换
        if (Input.GetKeyDown(KeyCode.R))
        {
            bool succ = pt.ReplaceTimeTask(tempID, (int tid) => {
                Debug.Log("定时等待删除......");
            }, 2, PETimeUnit.Second, 0);

            if (succ)
            {
                Debug.Log("替换成功");
            }
        }

        //定时删除
        if (Input.GetKeyDown(KeyCode.D))
        {
            bool succ = pt.DeleteTimeTask(tempID);
            if (succ)
            {
                Debug.Log("删除成功");
            }
        }
    }
 public void Update()
 {
     if (pt == null)
     {
         return;
     }
     pt.Update();
 }
示例#3
0
    // Update is called once per frame
    void Update()
    {
        if (Timer != null)
        {
            if (_passingTime)
            {
                if (Timer.Tick >= _targetTick)
                {
                    Timer.Tick        = _targetTick;
                    _passingTime      = false;
                    _targetTick       = 0;
                    Timer.ElapseSpeed = NormalTimeSpeed;
                }
            }

            Timer.Update(Time.deltaTime);
            PlayTime.Update(Time.deltaTime);

            if (Application.isEditor)
            {
                if (Input.GetKeyDown(KeyCode.Keypad1))
                {
                    Timer.ElapseSpeed = 10000;
                }
                if (Input.GetKeyUp(KeyCode.Keypad1))
                {
                    Timer.ElapseSpeed = NormalTimeSpeed;
                }
                if (Input.GetKey(KeyCode.Keypad1))
                {
                    Timer.ElapseSpeed *= 1.01f;
                    if (Timer.ElapseSpeed > 1000000)
                    {
                        Timer.ElapseSpeed = 1000000;
                    }
                }
            }

#if DEBUG_TIMER
            if (Application.isEditor)
            {
                m_ElapseSpeed = Timer.ElapseSpeed;
                m_Tick        = Timer.Tick.ToString("#,##0");
                m_Day         = Timer.Day;
                m_Hour        = Timer.Hour;
                m_Minute      = Timer.Minute;
                m_Second      = Timer.Second;
                m_TimeInDay   = Timer.TimeInDay;
                m_HourInDay   = Timer.HourInDay;
                m_MinuteInDay = Timer.MinuteInDay;
                m_SecondInDay = Timer.SecondInDay;
                m_CycleInDay  = Timer.CycleInDay;
                m_TimeString  = Timer.FormatString("D hh:mm:ss AP");
            }
#endif
        }
    }
示例#4
0
文件: Program.cs 项目: Eam727/PETimer
        //第一种用法:运行线程检测并处理任务
        static void Test1()
        {
            //运行线程驱动计时
            PETimer pt = new PETimer();

            pt.SetLog((string info) => {
                Console.WriteLine("LogInfo:" + info);
            });

            pt.AddTimeTask((int tid) => {
                Console.WriteLine("Process线程ID:{0}", Thread.CurrentThread.ManagedThreadId.ToString());
            }, 10, PETimeUnit.Millisecond, 0);

            while (true)
            {
                pt.Update();
            }
        }
示例#5
0
        //在主线程检测并处理
        static void Test1()
        {
            PETimer pt = new PETimer();

            pt.SetLog((string info) => {
                Console.WriteLine("ConsoleLog:" + info);
            });

            pt.AddTimeTask((int tid) => {
                Console.WriteLine("Time:" + DateTime.Now);
                Console.WriteLine("Process线程ID:{0}", Thread.CurrentThread.ManagedThreadId.ToString());
            }, 1000, 0, PETimeUnit.Millisecond);

            while (true)
            {
                pt.Update();
            }
        }
示例#6
0
    // Update is called once per frame
    void Update()
    {
        if (!m_PauseTimer)
        {
            if (m_Assembly != null)
            {
                m_Assembly.Update();

                m_Timer.ElapseSpeed = GameTime.Timer.ElapseSpeed;
                m_Timer.Update(Time.deltaTime);
            }
            else
            {
                m_Timer.ElapseSpeed = 0;
            }
        }

        foreach (KeyValuePair <int, CSCommon> kvp in m_CommonEntities)
        {
            kvp.Value.Update();
        }

        foreach (CSPersonnel personnel in m_MainNpcs)
        {
            personnel.Update();
        }

        foreach (CSPersonnel personnel in m_RandomNpcs)
        {
            personnel.Update();
        }

        if (m_Clod != null && Time.frameCount % 8192 == 0 && Assembly != null && Assembly.Farm != null && Assembly.Farm.IsRunning)
        {
            if (!IsAdjustingClods)
            {
                StartCoroutine(AdjustClodsProc());
            }
        }
        if (m_Clod != null && Time.frameCount % 8192 == 4096 && Assembly != null && Assembly.Farm != null && !Assembly.isSearchingClod && Assembly.Farm.IsRunning && Assembly.ModelObj != null)
        {
            StartCoroutine(CSMain.Instance.SearchVaildClodForAssembly(Assembly));
        }
    }
示例#7
0
    /// <summary>
    /// 在主线程检测并处理
    /// </summary>
    private static void Test1()
    {
        PETimer pt = new PETimer();

        pt.SetLog((string info) =>
        {
            Console.WriteLine($"ConsoleLog{info}");
        });

        pt.AddTimeTask((int tid) =>
        {
            Console.WriteLine($"Time:{DateTime.Now}");
            Console.WriteLine($"Process线程ID:{Thread.CurrentThread.ManagedThreadId.ToString()}");
        }, 1000, 0);

        while (true)
        {
            pt.Update();
            //休眠20毫秒 不然CPU占用率高
            Thread.Sleep(20);
        }
    }
示例#8
0
 public void Update()
 {
     pt.Update();
 }
示例#9
0
 private void Update()
 {
     pt.Update();
 }
示例#10
0
 public void Update()
 {
     pt.Update(); // 驱动整个定时任务的检测
 }
示例#11
0
 private void Update()
 {
     peTimer.Update();
 }
示例#12
0
 public void Update()
 {
     _timer.Update();
 }
示例#13
0
 private void FixedUpdate()
 {
     pt.Update();
 }