Ejemplo n.º 1
0
        protected override bool Exec()
        {
            VarRef timerName = PatheaScript.Util.GetVarRefOrValue(mInfo, "id", VarValue.EType.String, mTrigger);

            Functor initSecFunctor = mFactory.GetFunctor(mInfo, "set1");
            VarRef  initSec        = PatheaScript.Util.GetVarRefOrValue(mInfo, "sec", VarValue.EType.Float, mTrigger);

            Functor speedFunctor = mFactory.GetFunctor(mInfo, "set2");
            VarRef  speed        = PatheaScript.Util.GetVarRefOrValue(mInfo, "speed", VarValue.EType.Float, mTrigger);

            initSecFunctor.Set(new Variable(), initSec.Var);
            initSecFunctor.Do();

            speedFunctor.Set(new Variable(), speed.Var);
            speedFunctor.Do();

            PETimer timer = new PETimer();

            timer.Second      = (double)((float)initSecFunctor.Target.Value);
            timer.ElapseSpeed = (float)speedFunctor.Target.Value;

            //PETimerMgr.Instance.Remove(timerName);

            PeTimerMgr.Instance.Add((string)timerName.Value, timer);
            return(true);
        }
Ejemplo n.º 2
0
        //第二种用法:独立线程检测并处理任务
        static void Test2()
        {
            Queue <TaskPack> tpQue = new Queue <TaskPack>();
            //独立线程驱动计时
            PETimer pt = new PETimer(5);

            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);

            //设置回调处理器
            pt.SetHandle((Action <int> cb, int tid) => {
                if (cb != null)
                {
                    lock (obj) {
                        tpQue.Enqueue(new TaskPack(tid, cb));
                    }
                }
            });
            while (true)
            {
                if (tpQue.Count > 0)
                {
                    TaskPack tp = null;
                    lock (obj) {
                        tp = tpQue.Dequeue();
                    }
                    tp.cb(tp.tid);
                }
            }
        }
Ejemplo n.º 3
0
    void OnStationResidenceTimeChange(string text)
    {
        if (mSelectedStation != null && text.Length > 0)
        {
            PETimer time = PETimerUtil.GetTmpTimer();
            time.Minute = Convert.ToDouble(text);
            if (time.Minute > 0)
            {
                Railway.Route route = Railway.Manager.Instance.GetRouteByPointId(mSelectedStation.mRailPointData.id);
                if (route != null)
                {
                    route.SetStayTime(mSelectedStation.mRailPointData.id, Convert.ToSingle(time.Second));
                }
                else
                {
                    Railway.Point point = Railway.Manager.Instance.GetPoint(mSelectedStation.mRailPointData.id);
                    point.stayTime = Convert.ToSingle(time.Second);
                }


                if (null != e_ResetPointTime)
                {
                    e_ResetPointTime(mSelectedStation.mRailPointData.id, Convert.ToSingle(time.Second));
                }
            }
            time.Second          = mSelectedStation.mRailPointData.realStayTime;
            mRedestanceTime.text = ((int)time.Minute).ToString();
        }
    }
Ejemplo n.º 4
0
 public void InitSvc()
 {
     _timer = new PETimer();
     _timer.SetLog((string info) =>
     {
         Debug.Log(info);
     });
 }
Ejemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        Timer             = new PETimer();
        Timer.ElapseSpeed = 0;

        PlayTime             = new UTimer();
        PlayTime.ElapseSpeed = 1;
    }
Ejemplo n.º 6
0
        void TimerMgrGui()
        {
            PETimer timer = PeTimerMgr.Instance.Get("1");

            if (null != timer)
            {
                GUI.Label(new Rect(500, 50, 100, 20), timer.FormatString("hh:mm:ss"));
            }
        }
Ejemplo n.º 7
0
 public void InitSvc()
 {
     instance = this;
     pt       = new PETimer();
     //日志输出
     pt.SetLog((string info) =>
     {
         Debug.Log(info);
     });
 }
Ejemplo n.º 8
0
 public void InitSvc()
 {
     peTimer = new PETimer();
     //设置日志输出方式
     peTimer.SetLog((string info) =>
     {
         PECommon.Log(info);
     });
     PECommon.Log("Init TimerSvc...");
 }
Ejemplo n.º 9
0
 public void InitSvc()
 {
     instance = this;
     pt       = new PETimer();
     //设置日志输出
     pt.SetLog((info) =>
     {
         PECommon.Log(info);
     });
     Debug.Log("TimeSvc ResSvc...");
 }
Ejemplo n.º 10
0
    public override void InitSvc()
    {
        pt = new PETimer();

        //设置日志输出
        pt.SetLog((string info) => {
            Debug.Log(info);
        });

        Debug.Log("Init TimerSvc...");
    }
Ejemplo n.º 11
0
    void SetSatationInfo(Railway.Point satation)
    {
        mTitleStationName.text = satation.name;
        mStationName.text      = satation.name;
        PETimer rTime = PETimerUtil.GetTmpTimer();

        rTime.Second = satation.realStayTime;
        int min = Convert.ToInt32(rTime.Minute);

        mRedestanceTime.text = min.ToString();
    }
        private void Awake()
        {
            pt = new PETimer();

            //设置日志输出
            pt.SetLog((string info) => {
                Debug.Log(info);
            });
            _instance = this;
            Debug.Log("Init TimerSvc...");
        }
Ejemplo n.º 13
0
    public void InitSys()
    {
        Instance = this;
        pt       = new PETimer();
        pt.SetLog((string info) => {
            Debug.Log("PETimeLog:" + info);
        });
        //pt.SetLog(delegate(string info) {
        //    Debug.Log("PETimeLog:" + info); });

        Debug.Log("TimerSys Init Done");
    }
Ejemplo n.º 14
0
    public void InitSvc()
    {
        Instance = this;
        pt       = new PETimer();

        //设置日志输出
        pt.SetLog((string info) => {
            Debug.Log(info);
        });

        Debug.Log("Init TimerSvc...");
    }
Ejemplo n.º 15
0
    public void InitSvc()
    {
        _instance = this;

        pt = new PETimer();
        pt.SetLog((info) =>
        {
            Debug.Log(info);
        });

        Debug.Log("Init TimerSvc...");
    }
Ejemplo n.º 16
0
    public void InitSvc()
    {
        Instance = this;
        pt       = new PETimer();

        // 设置日志输出
        pt.SetLog((string info) =>
        {
            PECommon.Log(info);
        });

        PECommon.Log("Init TimeSvc...");
    }
Ejemplo n.º 17
0
    public void InitSvc()
    {
        Instance = this;
        //实例化计时类
        pt = new PETimer();
        //日志工具接口
        pt.SetLog((string info) =>
        {
            PECommon.Log(info);
        });

        PECommon.Log("Init TimerSvc...");
    }
Ejemplo n.º 18
0
    public void InitSvc()
    {
        Instance = this;

        pt = new PETimer();

        // 设置日志输出
        pt.SetLog((info) => {
            Common.Log(info);
        });

        Debug.Log(GetType() + "/InitSvc()/ Init Timer Service...");
    }
Ejemplo n.º 19
0
 public void Init()
 {
     PECommon.Log("TimerSvc Init Done!");
     timer = new PETimer(0);//表征100ms调用一次事件的计时器
     timer.SetLog(info => PECommon.Log(info));
     //设置Handle的逻辑体,即驱动函数在驱动至一个满足条件的回调时,不再执行回调,而是将回调加入队列当中
     timer.SetHandle((cb, tid) =>
     {
         lock (tpQueLock)
         {
             tpQue.Enqueue(new TaskPack(tid, cb));
         }
     });
 }
Ejemplo n.º 20
0
        public void Add(string name, PETimer timer)
        {
            if (null == mDicTimer)
            {
                mDicTimer = new Dictionary <string, PETimer>(2);
            }

            if (mDicTimer.ContainsKey(name))
            {
                Debug.LogError("timer:" + name + " exist.");
                return;
            }

            mDicTimer.Add(name, timer);
        }
Ejemplo n.º 21
0
    void SetLineInfo(Railway.Route route)
    {
        Railway.Route.Stats stats = route.GetStats();

        mTitleLineName.text  = route.name;
        mLineName.text       = route.name;
        mLbStationCount.text = stats.stationNum.ToString();
        mLbNodeCount.text    = stats.jointNum.ToString();
        mLbRangeAblity.text  = stats.totalIntDis.ToString() + " M";
        PETimer time = PETimerUtil.GetTmpTimer();

        time.Second        = route.singleTripTime;
        mLbOneWaytime.text = time.GetStrHhMmSs();
        mRailIcon.SetItem(route.trainId);
    }
Ejemplo n.º 22
0
    void Awake()
    {
        m_Type = CSConst.CreatorType.Managed;

        m_CommonEntities = new Dictionary <int, CSCommon>();

        m_MainNpcs   = new List <CSPersonnel>();
        m_RandomNpcs = new List <CSPersonnel>();

        CSPersonnel.RegisterStateChangedListener(OnPersonnelChangeState);
        CSPersonnel.RegisterOccupaChangedListener(OnPersonnelChangeOccupation);
        CSPersonnel.RegisterWorkTypeChangedListener(OnPersonnelChangeWorkType);

        // Init Timer
        m_Timer = new PETimer();
    }
Ejemplo n.º 23
0
 public void Init()
 {
     PETimer = new PETimer(100);
     taskPackQueue.Clear();
     PETimer.SetLog((string info) => PeRoot.Log(info));//设置日志输出
     PETimer.SetHandle((Action <int> cb, int tid) =>
     {
         if (cb != null)
         {
             lock (queueLock)
             {
                 taskPackQueue.Enqueue(new TaskPack(tid, cb));
             }
         }
     });
     PeRoot.Log("TimerSvc Init Done.||计时服务.");
 }
Ejemplo n.º 24
0
    public static void PassTime(double gameTime, double trueTime = 1)
    {
        if (trueTime < 0.1f)
        {
            trueTime = 0.1f;
        }
        PETimer tar = new PETimer();

        tar.Tick = Timer.Tick;
        PETimer add = new PETimer();

        add.Second = gameTime;
        tar.AddTime(add);
        _targetTick = tar.Tick;

        Timer.ElapseSpeed = (float)(gameTime / trueTime);
        _passingTime      = true;
    }
Ejemplo n.º 25
0
        //第一种用法:运行线程检测并处理任务
        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();
            }
        }
Ejemplo n.º 26
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();
            }
        }
Ejemplo n.º 27
0
        public override bool Do()
        {
            if (false == base.Do())
            {
                return(false);
            }

            PETimer timer = PeTimerMgr.Instance.Get((string)mTimerName.Value);

            if (null == timer)
            {
                return(false);
            }

            VarValue second = new VarValue((float)timer.Second);

            return(mCompare.Do(second, mRef.Value));
        }
Ejemplo n.º 28
0
    void Init()
    {
        if (!_Init)
        {
            _Init = true;

            m_Timer = assembly.m_Entity.m_Creator.Timer;
            m_Data  = assembly.m_Entity.m_Creator.m_DataInst.m_Siege;

            assembly.m_Entity.AddEventListener(OnEntityEventListener);

            Import();

            if (_nextHour == 0)
            {
                CreateNextSiege();
            }
        }
    }
Ejemplo n.º 29
0
    void UpdateStationArriveTime()
    {
        if (mSelectedStation == null)
        {
            return;
        }

        float arriveTime = mSelectedStation.mRailPointData.GetArriveTime();

        if (arriveTime - 0f < PETools.PEMath.Epsilon)
        {
            mArriveTime.text = "--";
        }
        else
        {
            PETimer time = PETimerUtil.GetTmpTimer();
            time.Second      = arriveTime;
            mArriveTime.text = time.GetStrHhMmSs();
        }
    }
Ejemplo n.º 30
0
    public TimeStruct TickToTimeStruct(long tick)
    {
        PETimer timer = PETimerUtil.GetTmpTimer();

        timer.Tick = tick;
        double     day = timer.Day;
        TimeStruct ts  = DayToCalendar((int)(System.Math.Floor(day)));

        double inday = timer.TimeInDay;

        ts.Millisecond = (int)(inday * Day2Sec * 1000);
        ts.Second      = ts.Millisecond / 1000;
        ts.Millisecond = ts.Millisecond % 1000;
        ts.Minute      = ts.Second / ((int)c_Min2Sec);
        ts.Second      = ts.Second % ((int)c_Min2Sec);
        ts.Hour        = ts.Minute / ((int)c_Hour2Min);
        ts.Minute      = ts.Minute % ((int)c_Hour2Min);
        ts.Hour        = ts.Hour % ((int)c_Day2Hour);
        return(ts);
    }