Пример #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);
        }