Exemplo n.º 1
0
 protected void init(Unit unit)
 {
     mUnit  = unit;
     mTime  = 0;
     mState = 1;
     timer  = new TimeMgr.TimeAxis();
     onInit(unit);
 }
Exemplo n.º 2
0
 protected void deinit()
 {
     setUnitState(UnitState.ALL, true);
     mUnit.syncState();
     onDeinit();
     mUnit = null;
     timer = null;
 }
Exemplo n.º 3
0
    void OnGUI()
    {
        int ox = 0;
        int oy = 30;

        if (GUI.Button(new Rect(ox, oy, 100, 30), "事件序列"))
        {
            TimeMgr.TimeAxis ta1 = TimeMgr.single.GetTimeAxis("1");
            if (ta1 != null)
            {
                ta1.Remove();
                return;
            }

            ta1 = TimeMgr.single.GetTimeAxis("1", true);
            ta1.AddAction(new LogAction(0, "event1"));
            ta1.AddAction(new LogAction(1, "event2"));
            ta1.AddAction(new LogAction(2, "event3"));
            ta1.AddAction(new LogAction(3, "event4"));
            ta1.AddAction(new LogAction(4, "event5"));
            ta1.SetParent(TimeMgr.single.realTimeAxis, TimeMgr.single.realTimeAxis.time + 1);
        }

        if (GUI.Button(new Rect(ox, oy += 30, 100, 30), "事件循环"))
        {
            TimeMgr.TimeAxis ta1 = TimeMgr.single.GetTimeAxis("2");
            if (ta1 != null)
            {
                ta1.Remove();
                return;
            }

            ta1 = TimeMgr.single.GetTimeAxis("2", true);
            TimeMgr.Action a = ta1.AddAction(new LogAction(1, "event1"));
            a.onAction += delegate(TimeMgr.Action self)
            {
                self.Loop(2);
            };
            ta1.SetParent(TimeMgr.single.realTimeAxis, TimeMgr.single.realTimeAxis.time + 1);
        }

        if (GUI.Button(new Rect(ox, oy += 30, 100, 30), "时间轴循环"))
        {
            TimeMgr.TimeAxis ta1 = TimeMgr.single.GetTimeAxis("3");
            if (ta1 != null)
            {
                ta1.Remove();
                return;
            }

            ta1 = TimeMgr.single.GetTimeAxis("3", true);
            ta1.AddAction(new LogAction(0, "event1"));
            TimeMgr.Action a = ta1.AddAction(new LogAction(1, "event2"));
            a.onAction += delegate(TimeMgr.Action self)
            {
                ta1.Loop();
            };
            ta1.SetParent(TimeMgr.single.realTimeAxis, TimeMgr.single.realTimeAxis.time + 1);
        }

        if (GUI.Button(new Rect(ox, oy += 30, 100, 30), "定时播报"))
        {
            RTime.R.syncServerTime(System.DateTime.UtcNow.Ticks, System.DateTime.Now.Ticks, false);
            TimeMgr.TimeAxis ta1 = TimeMgr.single.GetTimeAxis("4");
            if (ta1 != null)
            {
                ta1.Remove();
                return;
            }

            ta1 = TimeMgr.single.GetTimeAxis("4", true);
            TimeMgr.DateAction a = ta1.AddAction(new TimeMgr.DateAction()) as TimeMgr.DateAction;
            a.m        = 0;
            a.s        = 0;
            a.onAction = delegate(TimeMgr.Action ac) {
                Debug.Log(RTime.R.time.ToString("yyyy.MM.dd hh:mm:ss") + ":是你想要的吗");
            };
            ta1.SetParent(TimeMgr.single.dateTimeAxis, 0);
        }

        if (GUI.Button(new Rect(ox, oy += 30, 100, 30), "整点事件"))
        {
            if (RTime.R.onDataChanged == null)
            {
                RTime.R.onDataChanged = onDateTimeChange;
            }
            else
            {
                RTime.R.onDataChanged = null;
            }
        }
    }