Example #1
0
    protected void tickRunnerTimer(TriggerActionRunner runner, int delay)
    {
        if (runner.currentTime > 0 && (runner.currentTime -= delay) <= 0)
        {
            runner.currentTime = 0;

            switch (runner.timerType)
            {
            case TriggerActionTimerType.Wait:
            {
                removeTimeRunner(runner);
                runNextAction(runner);
            }
            break;

            case TriggerActionTimerType.WaitUtil:
            {
                if (getBoolean(runner.getCurrentAction().args[0], runner.arg))
                {
                    removeTimeRunner(runner);
                    runNextAction(runner);
                }
                else
                {
                    //继续等
                    runner.currentTime = runner.timeMax;
                }
            }
            break;
            }
        }
    }
Example #2
0
 /** 执行下一个动作 */
 protected void runNextAction(TriggerActionRunner runner)
 {
     //执行完了
     if ((++runner.actionIndex) >= runner.actions.Length)
     {
         completeCurrentAction(runner);
     }
     else
     {
         preActionFunc(runner.getCurrentAction(), runner);
     }
 }
Example #3
0
    /** 完成当前方法区 */
    protected void completeCurrentAction(TriggerActionRunner runner)
    {
        //没有子项父
        if (runner.parent == null)
        {
            TriggerEvent evt;
            if ((evt = runner.arg.evt) != null)
            {
                //回收event
                if ((--evt.refCount) == 0)
                {
                    _eventPool.back(evt);
                }
            }

            TriggerActionRunner parentRunner = runner.arg.parentRunner;

            //回收arg
            _argPool.back(runner.arg);
            disposeActionRunner(runner);

            if (parentRunner != null)
            {
                runNextAction(parentRunner);
            }
        }
        else
        {
            TriggerActionRunner parent = runner.parent;

            bool needBack;

            switch (runner.childType)
            {
            case TriggerChildRunnerType.If:
            {
                needBack = true;
            }
            break;

            case TriggerChildRunnerType.While:
            {
                needBack = !getBoolean(parent.getCurrentAction().args[0], runner.arg);
            }
            break;

            case TriggerChildRunnerType.ForLoop:
            {
                if ((++parent.loop) >= parent.loopCount)
                {
                    parent.loopCount = -1;
                    parent.loop      = 0;

                    needBack = true;
                }
                else
                {
                    needBack = false;
                }
            }
            break;

            case TriggerChildRunnerType.ForEachList:
            {
                int            index = ++parent.loop;
                SList <Object> list  = parent.foreachList;

                if (index >= list.size())
                {
                    parent.foreachList = null;
                    parent.loop        = 0;
                    needBack           = true;
                }
                else
                {
                    needBack = false;
                }
            }
            break;

            default:
            {
                needBack = true;
                throwError("不支持的子组类型");
            }
            break;
            }

            if (needBack)
            {
                disposeActionRunner(runner);
                parent.arg.runner = parent;
                runNextAction(parent);
            }
            else
            {
                //再运行
                runner.actionIndex = -1;
                runNextAction(runner);
            }
        }
    }