コード例 #1
0
ファイル: TriggerExecutor.cs プロジェクト: shineTeam7/home3
    /** 运行子方法组 */
    protected void runChildActions(int type, TriggerFuncData[] list, TriggerActionRunner parent)
    {
        TriggerActionRunner runner = _actionRunnerPool.getOne();

        runner.initByAction(type, list, parent);
        runNextAction(runner);
    }
コード例 #2
0
ファイル: TriggerArg.cs プロジェクト: shineTeam7/home3
 public void clear()
 {
     instance     = null;
     evt          = null;
     runner       = null;
     parentRunner = null;
 }
コード例 #3
0
ファイル: TriggerExecutor.cs プロジェクト: shineTeam7/home3
    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;
            }
        }
    }
コード例 #4
0
ファイル: TriggerExecutor.cs プロジェクト: shineTeam7/home3
    /** 执行触发器(检查条件) */
    protected void runTriggerAbs(int id, TriggerActionRunner runner)
    {
        TriggerArg arg = _argPool.getOne();

        arg.instance     = getInstance(id);
        arg.parentRunner = runner;
        toRunTriggerAbs(arg);
    }
コード例 #5
0
ファイル: TriggerExecutor.cs プロジェクト: shineTeam7/home3
    /** 执行触发器(检查条件) */
    protected void runTrigger(TriggerInstance instance, TriggerActionRunner runner)
    {
        TriggerArg arg = _argPool.getOne();

        arg.instance     = instance;
        arg.parentRunner = runner;
        toRunTrigger(arg);
    }
コード例 #6
0
    /** 初始化(通过trigger调用) */
    public void initByTrigger(TriggerArg arg)
    {
        this.arg    = arg;
        this.root   = this;
        actionIndex = -1;
        actions     = arg.instance.config.actions;

        arg.runner = this;
    }
コード例 #7
0
ファイル: TriggerExecutor.cs プロジェクト: shineTeam7/home3
    /** 析构actionRunner */
    private void disposeActionRunner(TriggerActionRunner runner)
    {
        if (runner.timerType > 0)
        {
            _timerRunnerDic.remove(runner);
        }

        _actionRunnerPool.back(runner);
    }
コード例 #8
0
    /** 初始化(通过trigger调用) */
    public void initByAction(int type, TriggerFuncData[] list, TriggerActionRunner runner)
    {
        this.arg       = runner.arg;
        this.root      = runner.root;
        this.parent    = runner;
        this.childType = type;
        actionIndex    = -1;
        actions        = list;

        arg.runner = this;
    }
コード例 #9
0
ファイル: TriggerExecutor.cs プロジェクト: shineTeam7/home3
 /** 执行下一个动作 */
 protected void runNextAction(TriggerActionRunner runner)
 {
     //执行完了
     if ((++runner.actionIndex) >= runner.actions.Length)
     {
         completeCurrentAction(runner);
     }
     else
     {
         preActionFunc(runner.getCurrentAction(), runner);
     }
 }
コード例 #10
0
ファイル: TriggerExecutor.cs プロジェクト: shineTeam7/home3
    /** 执行trigger(不带condition) */
    private void toRunTriggerAbs(TriggerArg arg)
    {
        if (arg.evt != null)
        {
            arg.evt.refCount++;
        }

        TriggerActionRunner runner = _actionRunnerPool.getOne();

        runner.initByTrigger(arg);
        runNextAction(runner);
    }
コード例 #11
0
ファイル: TriggerExecutor.cs プロジェクト: shineTeam7/home3
    /** 执行action行为 */
    public void preActionFunc(TriggerFuncData func, TriggerActionRunner runner)
    {
        if (CommonSetting.needTriggerLog)
        {
            log("runAction:", GameC.trigger.getFuncName(func.id), func.args);
        }

        if (!doAsyncActionFunc(func, runner.arg))
        {
            doActionFunc(func, runner.arg);
            runNextAction(runner);
        }
    }
コード例 #12
0
    public void clear()
    {
        arg         = null;
        actionIndex = -1;
        actions     = null;
        root        = null;
        parent      = null;
        childType   = 0;

        loopCount   = -1;
        loop        = 0;
        foreachList = null;

        timerType   = 0;
        timeMax     = 0;
        currentTime = 0;
    }
コード例 #13
0
ファイル: TriggerExecutor.cs プロジェクト: shineTeam7/home3
    /** 执行异步方法 */
    protected virtual bool toDoAsyncActionFunc(TriggerFuncData func, TriggerArg arg)
    {
        switch (func.id)
        {
        case TriggerFunctionType.If:
        {
            if (getBoolean(func.args[0], arg))
            {
                TriggerFuncListData listFunc = (TriggerFuncListData)func.args[1];

                runChildActions(TriggerChildRunnerType.If, listFunc.funcList, arg.runner);
            }
            else
            {
                if (func.args.Length > 2)
                {
                    TriggerFuncListData listFunc = (TriggerFuncListData)func.args[2];

                    if (listFunc.funcList.Length > 0)
                    {
                        runChildActions(TriggerChildRunnerType.If, listFunc.funcList, arg.runner);
                    }
                    else
                    {
                        //直接下一个
                        runNextAction(arg.runner);
                    }
                }
                else
                {
                    //直接下一个
                    runNextAction(arg.runner);
                }
            }
        }
        break;

        case TriggerFunctionType.While:
        {
            if (getBoolean(func.args[0], arg))
            {
                TriggerFuncListData listFunc = (TriggerFuncListData)func.args[1];

                runChildActions(TriggerChildRunnerType.While, listFunc.funcList, arg.runner);
            }
            else
            {
                //直接下一个
                runNextAction(arg.runner);
            }
        }
        break;

        case TriggerFunctionType.ForLoop:
        {
            int loop = getInt(func.args[0], arg.runner.arg);

            if (loop <= 0)
            {
                //直接下一个
                runNextAction(arg.runner);
            }
            else
            {
                arg.runner.loopCount = loop;
                arg.runner.loop      = 0;

                TriggerFuncListData listFunc = (TriggerFuncListData)func.args[1];

                runChildActions(TriggerChildRunnerType.ForLoop, listFunc.funcList, arg.runner);
            }
        }
        break;

        case TriggerFunctionType.RunTrigger:
        {
            runTrigger(getInt(func.args[0], arg), arg.runner);
        }
        break;

        case TriggerFunctionType.RunTriggerAbs:
        {
            runTriggerAbs(getInt(func.args[0], arg), arg.runner);
        }
        break;

        case TriggerFunctionType.BreakTrigger:
        {
            //直接完成根节点
            completeCurrentAction(arg.runner.root);
        }
        break;

        case TriggerFunctionType.BreakLoop:
        {
            if (arg.runner.isInLoop())
            {
                TriggerActionRunner parent = arg.runner.parent;
                if (parent == null)
                {
                    throwError("不该找不到父");
                    return(false);
                }

                disposeActionRunner(arg.runner);
                parent.arg.runner = parent;
                runNextAction(parent);
            }
            else
            {
                warnLog("breakLoop时,不是循环");
                runNextAction(arg.runner);
            }
        }
        break;

        case TriggerFunctionType.ContinueLoop:
        {
            if (arg.runner.isInLoop())
            {
                completeCurrentAction(arg.runner);
            }
            else
            {
                warnLog("continueLoop时,不是循环");
                runNextAction(arg.runner);
            }
        }
        break;

        case TriggerFunctionType.Wait:
        {
            arg.runner.timerType   = TriggerActionTimerType.Wait;
            arg.runner.currentTime = arg.runner.timeMax = getInt(func.args[0], arg);
            addTimeRunner(arg.runner);
        }
        break;

        case TriggerFunctionType.WaitUtil:
        {
            //判定成功直接过
            if (getBoolean(arg.runner.getCurrentAction().args[0], arg))
            {
                runNextAction(arg.runner);
            }
            else
            {
                //加入等待
                arg.runner.timerType   = TriggerActionTimerType.WaitUtil;
                arg.runner.currentTime = arg.runner.timeMax = getInt(func.args[1], arg);
                addTimeRunner(arg.runner);
            }
        }
        break;

        case TriggerFunctionType.ForeachList:
        {
            SList <Object> list = getList(func.args[0], arg);

            if (list.isEmpty())
            {
                //直接下一个
                runNextAction(arg.runner);
            }
            else
            {
                arg.runner.foreachList = list;
                arg.runner.loop        = 0;

                TriggerFuncListData listFunc = (TriggerFuncListData)func.args[1];
                runChildActions(TriggerChildRunnerType.ForEachList, listFunc.funcList, arg.runner);
            }
        }
        break;

        default:
        {
            return(false);
        }
        }

        return(true);
    }
コード例 #14
0
ファイル: TriggerExecutor.cs プロジェクト: shineTeam7/home3
 protected void removeTimeRunner(TriggerActionRunner runner)
 {
     _timerRunnerDic.remove(runner);
 }
コード例 #15
0
ファイル: TriggerExecutor.cs プロジェクト: shineTeam7/home3
 protected void addTimeRunner(TriggerActionRunner runner)
 {
     _timerRunnerDic.add(runner);
 }
コード例 #16
0
ファイル: TriggerExecutor.cs プロジェクト: shineTeam7/home3
    /** 完成当前方法区 */
    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);
            }
        }
    }
コード例 #17
0
ファイル: TriggerExecutor.cs プロジェクト: shineTeam7/home3
 /** 执行触发器(检查条件) */
 protected void runTrigger(int id, TriggerActionRunner runner)
 {
     runTrigger(getInstance(id), runner);
 }