예제 #1
0
 void StartScriptLoop(ScriptBase script)
 {
     if (scriptTask != null && scriptTask.Status == TaskStatus.Running)
     {
         logTools.Error("Already has one running Script Task", false);
         return;
     }
     logTools.Info("StartScriptLoop...");
     mumuState = MumuState.Create();
     script.SetMumuState(mumuState);
     tokenSource = new CancellationTokenSource();
     ct          = tokenSource.Token;
     scriptTask  = new Task(() =>
     {
         viewportRect    = mumuState.ViewportRect;
         viewportCapture = mumuState.DoCapture(viewportRect);
         logTools.Info($"Script: {script.Name} OnStart");
         script.OnStart(viewportCapture, viewportRect);
         while (true)
         {
             if (ct.IsCancellationRequested)
             {
                 ct.ThrowIfCancellationRequested();
             }
             try
             {
                 Thread.Sleep(script.Interval);
                 viewportRect    = mumuState.ViewportRect;
                 viewportCapture = mumuState.DoCapture(viewportRect);
                 logTools.Info($"Script: {script.Name} Tick");
                 script.Tick(viewportCapture, viewportRect);
             }
             catch (Exception e)
             {
                 logTools.Error($"Script: {script.Name} Tick ERROR", false);
                 if (!script.CanKeepOnWhenException || logTools.IsSelfOrChildrenBreakException(e))
                 {
                     throw e;
                 }
                 else
                 {
                     PrintException(e);
                 }
             }
         }
     }, tokenSource.Token);
     scriptTask.ContinueWith((t) =>
     {
         if (t.IsFaulted)
         {
             PrintException(t.Exception);
         }
         else if (t.IsCanceled)
         {
             logTools.Error("Script Canceled", false);
         }
         ScriptBase.OnScriptEnded(script.Name, !t.IsFaulted && !t.IsCanceled);
     });
     scriptTask.Start();
 }
예제 #2
0
        void StartActStageExchangeLoop()
        {
            logTools.Info("StartActStageExchangeLoop...");
            mumuState = GetMumuState();

            script = new ActivityStageExchangeScript();
            StartScriptLoop(script);
        }
예제 #3
0
 MumuState GetMumuState()
 {
     if (mumuState == null)
     {
         mumuState = MumuState.Create();
     }
     return(mumuState);
 }
예제 #4
0
        void StartReceivePresentLoop()
        {
            logTools.Info("StartReceivePresentLoop...");
            mumuState = GetMumuState();

            script = new ReceivePresentScript();
            StartScriptLoop(script);
        }
예제 #5
0
        void StartAutoStageLineLoop()
        {
            logTools.Info("StartAutoStageLineLoop...");
            mumuState = GetMumuState();

            script = new AutoStageLineScript();
            StartScriptLoop(script);
        }
예제 #6
0
        void StartReadReliabilityLoop()
        {
            logTools.Info("StartReadReliabilityLoop...");
            mumuState = GetMumuState();

            script = new ReadReliabilityScript();
            StartScriptLoop(script);
        }
예제 #7
0
        void StartAutoUndergroundLoop()
        {
            logTools.Info("StartAutoUndergroundLoop...");
            mumuState = GetMumuState();

            script = new AutoUndergroundScript();
            StartScriptLoop(script);
        }
예제 #8
0
        void StartStorySkipLoop()
        {
            oldFixedTopBottomY = configMgr.FixedViewportTopBottomY;
            configMgr.FixedViewportTopBottomY = true;
            logTools.Info("StartStorySkipLoop...");
            mumuState = GetMumuState();

            script = new ReadStoryScript();
            StartScriptLoop(script);
        }
예제 #9
0
        void StartArenaSearchLoop()
        {
            configMgr.InitTesseractConfig();
            name = txtName.Text;
            rank = txtRank.Text;

            logTools.Info("StartCaptureLoop...");
            mumuState = GetMumuState();

            var script = new ArenaSearchScript();

            script.SetGetPatternNameFunc(new Func <string>(() =>
            {
                return(name);
            }));
            script.SetGetPatternRankFunc(new Func <string>(() =>
            {
                return(rank);
            }));
            this.script = script;
            StartScriptLoop(script);
        }