예제 #1
0
    protected override void onInit(Unit unit)
    {
        mUnit.sendUnitEvent((int)UnitEvent.SkillBegin, null, true);
        setUnitState(mGS.state, true);
        if (mGS.pointType != Skill.PointType.None)
        {
            mUnit.forward(mUnit.skill.targetPos);
        }
        if (!string.IsNullOrEmpty(mGS.anim))
        {
            mUnit.anim.sendEvent(AnimPlugin.PlayAnim, mGS.anim);
        }

        for (int i = 0, max = mGS.actions.Count; i < max; ++i)
        {
            SkillAction    act = mGS.actions[i];
            TimeMgr.Action a   = timer.AddAction(new TimeMgr.Action());
            a.doTime   = act.time;
            a.onAction = onAction;
            a.userData = act;
        }
        state = 1;
        //lua call
        if (mGS.lua != null)
        {
            mTB.lua = mGS.lua;
            base.onInit(mUnit);
        }
    }
예제 #2
0
    void onAction(TimeMgr.Action a)
    {
        SkillAction act = a.userData as SkillAction;

        setUnitState(act.state, true);
        for (int i = 0; i < act.nodes.Count; ++i)
        {
            SkillNode n = act.nodes[i];
            switch (n.type)
            {
            case SkillNode.Type.Anim:
                animProcess(n as SkillAnim);
                break;

            case SkillNode.Type.Harm:
                harmProcess(n as SkillHarm);
                break;

            case SkillNode.Type.Bullet:
                bulletProcess(n as SkillBullet);
                break;

            case SkillNode.Type.Buff:
                buffProcess(n as SkillBuff);
                break;

            case SkillNode.Type.Event:
                eventProcess(n as SkillEvent);
                break;

            case SkillNode.Type.Move:
                moveProcess(n as SkillMove);
                break;

            case SkillNode.Type.Lua:
                luaProcess(n as SkillLua);
                break;
            }
        }

        if (act.loopTimes-- > 0)
        {
            a.Loop(act.loopInterval);
        }
        else if (act.end)
        {
            state = 0;
        }
    }
예제 #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;
            }
        }
    }