Exemplo n.º 1
0
        public override void Init(RTSEngine.Data.GameState s, RTSEngine.Controllers.GameplayController c, object args)
        {
            cc = unit.CombatController;
            mc = unit.MovementController;

            unit.TargetingOrders = BehaviorFSM.TargetPassively;
            unit.CombatOrders = BehaviorFSM.UseMeleeAttack;
            unit.MovementOrders = BehaviorFSM.JustMove;
            SetState(BehaviorFSM.Rest);

            teamIndex = unit.Team.Index;

            // Worker Specific Stuff
            targetResource = null;
            targetDistro = null;
            depositing = false;
        }
Exemplo n.º 2
0
        public RTSExecutor(bool supportChinese, int maxthread = 20, int ticks = 100, IRTSLog logger = null)
        {
            m_SupportChinese = supportChinese;
            m_MaxThread      = maxthread > 2 ? maxthread : 2;
            this.ticks       = ticks > 100 ? ticks : 100;

            mEngine   = new RTSEngine(logger == null ? this : logger);
            mCompiler = new RTSCompiler();

            mImmediateT = new RTSThread(-1, 128);
            m_MaxThread = Mathf.Max(1, m_MaxThread);
            mThreads    = new RTSThread[m_MaxThread];
            for (int i = 0; i < mThreads.Length; i++)
            {
                mThreads[i] = new RTSThread(i, i == 0 ? 40 : 20);
            }

            mEngine.addLinker("async", new AsyncL(this));

            AddFunction("type", new RTSPluginFunc(null, _typeof, 1));
            AddFunction("size", new RTSPluginFunc(null, sizeOf, 1));
            AddFunction("yield", new RTSPluginFunc(null, rtsYield, 0));
            AddFunction("sleep", new RTSPluginFunc(null, sleep, 1));
            AddFunction("mk_list", new RTSPluginFunc(null, mk_list, 1));
            AddFunction("mk_cmd", new RTSPluginFunc(null, mk_cmd, 1));
            AddFunction("toInt", new RTSPluginFunc(null, toInt, 1));
            AddFunction("toFloat", new RTSPluginFunc(null, toFloat, 1));
            AddFunction("toLong", new RTSPluginFunc(null, toLong, 1));
            AddFunction("toDouble", new RTSPluginFunc(null, toDouble, 1));
            AddFunction("toUint", new RTSPluginFunc(null, toUint, 1));
            AddFunction("toBool", new RTSPluginFunc(null, toBool, 1));
            AddFunction("toString", new RTSPluginFunc(null, toRTSString, 1));
            AddFunction("split", new RTSPluginFunc(null, split, 2));
            AddFunction("exist", new RTSPluginFunc(null, rtsExist, 1));
            AddFunction("interrupt", new RTSPluginFunc(null, rtsInterrupt, 1));
            AddFunction("logi", new RTSPluginFunc(null, rtsLogI, -1));
            AddFunction("logw", new RTSPluginFunc(null, rtsLogW, -1));
            AddFunction("loge", new RTSPluginFunc(null, rtsLogE, -1));
            AddFunction("compile", new RTSPluginFunc(null, inlineCompile, 1));
            AddFunction("aliasOperator", new RTSPluginFunc(null, aliasOperator, 2));
            AddFunction("aliasFunction", new RTSPluginFunc(null, aliasFunction, 3));
            AddFunction("ticks", new RTSPluginFunc(null, dateTimeTick, 0));
            AddFunction("time", new RTSPluginFunc(null, dateTime, -1));
            AddFunction("registMsg", new RTSPluginFunc(null, registMessage, 2));
            AddFunction("unregistMsg", new RTSPluginFunc(null, unregistMessage, 2));
            AddFunction("sendMsg", new RTSPluginFunc(null, sendMessage, -1));
            AddFunction("axisValue", new RTSPluginFunc(null, axisValue, 1));
            AddFunction("getButton", new RTSPluginFunc(null, getButton, 1));
            AddFunction("getButtonDown", new RTSPluginFunc(null, getButtonDown, 1));
            AddFunction("getButtonUp", new RTSPluginFunc(null, getButtonUp, 1));
            AddFunction("getKey", new RTSPluginFunc(null, getkey, 1));
            AddFunction("getKeyDown", new RTSPluginFunc(null, getkeyDown, 1));
            AddFunction("getKeyUp", new RTSPluginFunc(null, getkeyUp, 1));
            AddFunction("variable", new RTSPluginFunc(null, setValue, 3));
            if (m_SupportChinese)
            {
                RTSTextReader reader = mCompiler.getReader();
                reader.SetOperators("+-*/%&|~!^=<>?:;.,@:;。,");
                reader.SetBrackets("{}()[]()【】");
                mEngine.aliasLinker(";", ";");
                mEngine.aliasLinker(".", "。");
                mEngine.aliasLinker(",", ",");
                mEngine.aliasLinker("(", "(");
                mEngine.aliasLinker(")", ")");
                mEngine.aliasLinker("[", "【");
                mEngine.aliasLinker("]", "】");
                mEngine.aliasLinker("if", "如果");
                mEngine.aliasLinker("then", "就");
                mEngine.aliasLinker("else", "否则");
                mEngine.aliasLinker("for", "循环");
                mEngine.aliasLinker("delete", "删除");
                mEngine.aliasLinker("global", "全局");
                mEngine.aliasLinker("&&", "并且");
                mEngine.aliasLinker("&&", "和");
                mEngine.aliasLinker("||", "或者");
                mEngine.aliasLinker("!", "不是");
                mEngine.aliasLinker("!", "非");
                mEngine.aliasLinker("^", "不同于");
                mEngine.aliasLinker(">", "大于");
                mEngine.aliasLinker("<", "小于");
                mEngine.aliasLinker("=", "赋值");
                mEngine.aliasLinker("==", "等于");
                mEngine.aliasLinker("return", "返回");
                mEngine.aliasLinker("break", "结束");
                mEngine.aliasLinker("continue", "继续");
                mEngine.aliasLinker("async", "同时");
            }
        }
Exemplo n.º 3
0
        public RTSUnityRuntime()
        {
            mEngine   = new RTSEngine(this);
            mCompiler = new RTSCompiler();

            mImmediateT = new RTSThread(-1, 128);

            mEngine.addLinker("async", new AsyncL(this));

            AddFunction("type", new RTSPluginFunc(null, _typeof, 1));
            AddFunction("size", new RTSPluginFunc(null, sizeOf, 1));
            AddFunction("yield", new RTSPluginFunc(null, rtsYield, 0));
            AddFunction("sleep", new RTSPluginFunc(null, sleep, 1));
            AddFunction("mk_list", new RTSPluginFunc(null, mk_list, 1));
            AddFunction("toInt", new RTSPluginFunc(null, toInt, 1));
            AddFunction("toFloat", new RTSPluginFunc(null, toFloat, 1));
            AddFunction("toLong", new RTSPluginFunc(null, toLong, 1));
            AddFunction("toDouble", new RTSPluginFunc(null, toDouble, 1));
            AddFunction("toUint", new RTSPluginFunc(null, toUint, 1));
            AddFunction("toBool", new RTSPluginFunc(null, toBool, 1));
            AddFunction("toString", new RTSPluginFunc(null, toRTSString, 1));
            AddFunction("split", new RTSPluginFunc(null, split, 2));
            AddFunction("exist", new RTSPluginFunc(null, rtsExist, 1));
            AddFunction("interrupt", new RTSPluginFunc(null, rtsInterrupt, 1));
            AddFunction("logi", new RTSPluginFunc(null, rtsLogI, -1));
            AddFunction("logw", new RTSPluginFunc(null, rtsLogW, -1));
            AddFunction("loge", new RTSPluginFunc(null, rtsLogE, -1));
            AddFunction("compile", new RTSPluginFunc(null, inlineCompile, 1));
            AddFunction("aliasOperator", new RTSPluginFunc(null, aliasOperator, 2));
            AddFunction("aliasFunction", new RTSPluginFunc(null, aliasFunction, 3));
            AddFunction("ticks", new RTSPluginFunc(null, dateTimeTick, 0));
            AddFunction("time", new RTSPluginFunc(null, dateTime, -1));
            AddFunction("registMsg", new RTSPluginFunc(null, registMessage, 2));
            AddFunction("unregistMsg", new RTSPluginFunc(null, unregistMessage, 2));
            AddFunction("sendMsg", new RTSPluginFunc(null, sendMessage, -1));

            if (m_SupportChinese)
            {
                RTSTextReader reader = mCompiler.getReader();
                reader.SetOperators("+-*/%&|~!^=<>?:;.,@:;。,");
                reader.SetBrackets("{}()[]()【】");
                mEngine.aliasLinker(";", ";");
                mEngine.aliasLinker(".", "。");
                mEngine.aliasLinker(",", ",");
                mEngine.aliasLinker("(", "(");
                mEngine.aliasLinker(")", ")");
                mEngine.aliasLinker("[", "【");
                mEngine.aliasLinker("]", "】");
                mEngine.aliasLinker("if", "如果");
                mEngine.aliasLinker("then", "就");
                mEngine.aliasLinker("else", "否则");
                mEngine.aliasLinker("for", "循环");
                mEngine.aliasLinker("delete", "删除");
                mEngine.aliasLinker("global", "全局");
                mEngine.aliasLinker("&&", "并且");
                mEngine.aliasLinker("&&", "和");
                mEngine.aliasLinker("||", "或者");
                mEngine.aliasLinker("!", "不是");
                mEngine.aliasLinker("!", "非");
                mEngine.aliasLinker("^", "不同于");
                mEngine.aliasLinker(">", "大于");
                mEngine.aliasLinker("<", "小于");
                mEngine.aliasLinker("=", "赋值");
                mEngine.aliasLinker("==", "等于");
                mEngine.aliasLinker("return", "返回");
                mEngine.aliasLinker("break", "结束");
                mEngine.aliasLinker("continue", "继续");
                mEngine.aliasLinker("async", "同时");
            }
        }