示例#1
0
    internal override void OnEnter(TransitionData data)
    {
        Services.EventManager.Register <GameLoadEvent>(OnGameLoad);
        Services.AudioManager.StopClip();
        if (!Services.AudioManager.muted)
        {
            Services.AudioManager.SetVolume(0.5f);
        }
        Services.AudioManager.PlayClip(Clips.TITLE_SONG);
        Services.GameManager.UpdateMutIcon(audioStatusIcon);

        for (int i = 0; i < titleText.Length; i++)
        {
            titleText[i].gameObject.SetActive(false);
        }

        buttonText[0].color = new Color(0, 0, 0, 0);

        TaskQueue titleEntryTasks = new TaskQueue();
        Task      slideTitleIn    = new TitleEntryAnimation(titleText);
        Task      fadeFlockX      = new ActionTask(_flocks[0].FadeInFlockAgents);
        Task      fadeFlockO      = new ActionTask(_flocks[1].FadeInFlockAgents);

        titleEntryTasks.Add(fadeFlockX);
        titleEntryTasks.Add(fadeFlockO);
        titleEntryTasks.Add(slideTitleIn);


        _tm.Do(titleEntryTasks);
    }
示例#2
0
        public void TasksShouldRunInInsertionOrder()
        {
            var results = new List <int>();

            var test = new Thread(() =>
            {
                var q = new TaskQueue();

                Func <Task> task0 = () => Task.Factory.StartNew(() =>
                {
                    Thread.Sleep(200);
                    results.Add(0);
                });

                Func <Task> task1 = () => Task.Factory.StartNew(() =>
                {
                    results.Add(1);
                });

                q.Add(task0);
                q.Add(task1);
            });

            test.Start();

            // Let tasks finish.
            Thread.Sleep(400);

            Assert.IsTrue(results.SequenceEqual(new[] { 0, 1 }));
        }
示例#3
0
    TaskQueue ComicSequence(int roundNumber)
    {
        Transform comicTransform = Services.TransitionComicManager.fightEndComics[roundNumber - 1].transform;

        TaskQueue comicSequence = new TaskQueue(new List <Task>()
        {
            new SlideInPanel(Services.TransitionComicManager.comicBackground, true, 1600 * Vector2.right,
                             Services.TransitionComicManager.panelAppearTime),
            new ActionTask(Services.CameraController.ResetCamera)
        });

        if (roundNumber == 3 || roundNumber == 4)
        {
            comicSequence.Add(new SetObjectStatus(false, arenas[roundNumber - 1]));
        }

        comicSequence.Add(new SetObjectStatus(true, comicTransform.gameObject));

        int numPages = comicTransform.childCount;

        for (int i = 0; i < numPages; i++)
        {
            Transform page = comicTransform.GetChild(i);
            comicSequence.Add(new SetObjectStatus(true, page.gameObject));
            int numPanels = page.childCount;
            for (int j = 0; j < numPanels; j++)
            {
                comicSequence.Then(new TaskQueue(new List <Task>()
                {
                    new SetPanelImage(page.GetChild(j).gameObject),
                    new SlideInPanel(page.GetChild(j).gameObject, true,
                                     Services.TransitionComicManager.comicShifts[roundNumber - 1][i][j], Services.TransitionComicManager.panelAppearTime)
                }));
            }
            if ((i == numPages - 1) && (roundNumber == 5))
            {
                comicSequence.Add(new ActionTask(LastComic));
            }
            comicSequence.Add(new WaitToContinueFromComic(page.gameObject,
                                                          Services.TransitionComicManager.continueButton, Services.TransitionComicManager.continuePromptGrowTime,
                                                          Services.TransitionComicManager.continuePromptShrinkTime));
        }
        if (roundNumber == 3 || roundNumber == 4)
        {
            comicSequence.Then(new TaskQueue(new List <Task>()
            {
                new SetObjectStatus(true, arenas[roundNumber]),
                new SetObjectStatus(false, Services.TransitionComicManager.comicBackground)
            }));
        }

        return(comicSequence);
    }
    public void StartGame()
    {
        hasLoadGame = false;
        TaskQueue startGameTasks = new TaskQueue();
        Task      slideTitleOut  = new TitleEntryAnimation(titleText, true);
        Task      fadeStartText  = new LERPColor(buttonText, buttonText[0].color, transparent, 0.3f);
        Task      beginGame      = new ActionTask(TransitionToGame);

        startGameTasks.Add(fadeStartText);
        startGameTasks.Add(slideTitleOut);
        startGameTasks.Add(beginGame);

        _tm.Do(startGameTasks);
    }
示例#5
0
        public override void CreateTaskQueue()
        {
            IsSave = false;
            TaskQueue.Add(new Unpacker(AsmDef));

            Deobfuscate();
        }
示例#6
0
        public override void CreateTaskQueue()
        {
            TaskQueue.Add(new MethodCleaner(AsmDef));
            TaskQueue.Add(new MetadataFixer(AsmDef));

            if (Globals.DeobContext.ActiveSignature.Ver.Major == 1 && Globals.DeobContext.ActiveSignature.Ver.Minor == 0)
            {
                if (Globals.DeobContext.DynStringCtx == null)
                {
                    TaskQueue.Add(new Tasks._1_0.StringDecryptor(AsmDef));
                }
                else
                {
                    TaskQueue.Add(new GenericStringDecryptor(AsmDef));
                }
            }
            else
            if (Globals.DeobContext.DynStringCtx == null)
            {
                TaskQueue.Add(new Tasks._1_1.StringDecryptor(AsmDef));
            }
            else
            {
                TaskQueue.Add(new GenericStringDecryptor(AsmDef));
            }

            TaskQueue.Add(new Renamer(AsmDef, new RenamingScheme(true)));
            Deobfuscate();
        }
示例#7
0
        /// <summary>
        /// Adds a new task to the list of tasks and begins execution if beginning the task on add
        /// </summary>
        /// <param name="newTask">The new task to add to the list</param>
        /// <param name="removeOnComplete">Indicates to remove the task when it's done</param>
        /// <returns>The key of the task within the dictionary</returns>
        public int AddTask(Task newTask, bool removeOnComplete = false)
        {
            // add the task to the queue
            if (TaskQueue.Count <= 0)
            {
                TaskQueue.Add(0, newTask);
            }
            else
            {
                // figure out what the next best key is
                int newKey = 1;
                while (TaskQueue.Keys.Contains(newKey))
                {
                    newKey++;
                }

                // we now have a valid key, add it to dictionary
                TaskQueue.Add(newKey, newTask);
                if (removeOnComplete)
                {
                    newTask.ContinueWith(m => RemoveTask(newKey));
                }
            }

            // Should we start this task?
            if (ExecuteOnAdd)
            {
                ExecuteTask(TaskQueue.Last().Key);
            }

            // return the last key
            return(TaskQueue.Last().Key);
        }
示例#8
0
    public void StartGame()
    {
        Services.AudioManager.CreateTrackAndPlay(Clips.TAP);
        Services.AudioManager.FadeAudio();

        hasLoadGame = false;
        TaskQueue startGameTasks = new TaskQueue();
        Task      slideTitleOut  = new TitleEntryAnimation(titleText, true);
        Task      fadeStartText  = new LERPColor(buttonText, buttonText[0].color, transparent, 0.3f);
        Task      fadeFlockX     = new ActionTask(_flocks[0].FadeOutFlockAgents);
        Task      fadeFlockO     = new ActionTask(_flocks[1].FadeOutFlockAgents);
        Task      beginGame      = new ActionTask(TransitionToGame);

        startGameTasks.Add(fadeStartText);
        startGameTasks.Add(fadeFlockO);
        startGameTasks.Add(fadeFlockX);
        startGameTasks.Add(slideTitleOut);
        startGameTasks.Add(beginGame);

        _tm.Do(startGameTasks);
    }
示例#9
0
 public override void AssignTask(DTTask dTTask, PhysicalMachine Donor)
 {
     if (AvailableMemory >= dTTask.MemoryConsumption)
     {
         TaskQueue.Add(dTTask);
         AvailableMemory -= dTTask.MemoryConsumption;
         Donor.TaskQueue.Remove(dTTask);
     }
     //else
     //{
     //    throw new Exception("Not enough memory for new task");
     //}
 }
示例#10
0
        public TaskWorker AddTaskActivities(params UntypedTaskActivity[] taskActivityObjects)
        {
            foreach (UntypedTaskActivity instance in taskActivityObjects)
            {
                Debug.WriteLine($"Adding Task {instance.GetType()}");
                instance.onAdded();
                queue.Add(instance);
            }

            //queue.CompleteAdding();

            return(this);
        }
示例#11
0
        private void BT_Process_Click(object sender, RoutedEventArgs e)
        {
            //check
            if (resizeImages.QueueCount == 0 && resizeImages.RunningCount == 0)
            {
                if (string.IsNullOrEmpty(resizeWindowViewModel.Data) || string.IsNullOrEmpty(InputPath) || string.IsNullOrEmpty(OutputPath) ||
                    !Directory.Exists(InputPath) || !Directory.Exists(OutputPath))
                {
                    System.Windows.MessageBox.Show("Chưa có input/output/chuỗi", "Lỗi", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                List <double> vals = new List <double>();
                resizeWindowViewModel.Data.Split(';').Where(x => !string.IsNullOrEmpty(x)).ToList().ForEach(x =>
                {
                    if (double.TryParse(x, out double result))
                    {
                        vals.Add(result);
                    }
                });

                if (vals.Count == 0)
                {
                    System.Windows.MessageBox.Show("Chuỗi đầu vào rỗng", "Lỗi", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                ResizeImageQueue.OutputFolder = OutputPath;
                ResizeImageQueue.SizePercents.Clear();
                ResizeImageQueue.SizePercents.AddRange(vals);
                resizeImages.ShutDown();

                var files = Directory.GetFiles(InputPath);
                foreach (var file in files)
                {
                    resizeImages.Add(new ResizeImageQueue(file));
                }
                totalRun       = resizeImages.QueueCount;
                totalCompleted = 0;
                resizeWindowViewModel.RunButtonText = "Stop";
                resizeImages.MaxRun = resizeWindowViewModel.Threads;
            }
            else
            {
                if (System.Windows.MessageBox.Show("Cancel?", "Confirm", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    resizeImages.ShutDown();
                }
            }
        }
示例#12
0
        public override void CreateTaskQueue()
        {
            TaskQueue.Add(new MethodCleaner(AsmDef));
            TaskQueue.Add(new CFlowCleaner(AsmDef));

            if (Globals.DeobContext.DynStringCtx == null)
                TaskQueue.Add(new StringDecryptor(AsmDef));
            else
                TaskQueue.Add(new GenericStringDecryptor(AsmDef));

            TaskQueue.Add(new Renamer(AsmDef, new RenamingScheme(true)));

            Deobfuscate();
        }
示例#13
0
        public override void CreateTaskQueue()
        {
            TaskQueue.Add(new MethodCleaner(AsmDef));
            //TaskQueue.Add(new MetadataFixer(AsmDef));

            if (Globals.DeobContext.DynStringCtx != null)
            {
                TaskQueue.Add(new GenericStringDecryptor(AsmDef));
            }

            TaskQueue.Add(new Renamer(AsmDef, new RenamingScheme(true)
            {
                Resources = false
            }));

            Deobfuscate();
        }
示例#14
0
        public override void CreateTaskQueue()
        {
            if (IsAssemblyEncrypted())
            {
                Logger.VSLog("Detected assembly encryption; dumping original assembly...");
                //TaskQueue.Add(new StubDumper2(AsmDef));
            }

            TaskQueue.Add(new MethodCleaner(AsmDef));
            TaskQueue.Add(new StringDecryptor(AsmDef));
            TaskQueue.Add(new Renamer(AsmDef, new RenamingScheme(true)
            {
                Resources = false
            }));


            Deobfuscate();
        }
    internal override void OnEnter(TransitionData data)
    {
        Services.EventManager.Register <GameLoadEvent>(OnGameLoad);

        for (int i = 0; i < titleText.Length; i++)
        {
            titleText[i].gameObject.SetActive(false);
        }

        buttonText[0].color = new Color(0, 0, 0, 0);

        TaskQueue titleEntryTasks = new TaskQueue();
        Task      slideTitleIn    = new TitleEntryAnimation(titleText);

        titleEntryTasks.Add(slideTitleIn);


        _tm.Do(titleEntryTasks);
    }
示例#16
0
        public override void CreateTaskQueue()
        {
            TaskQueue.Add(new MetadataFixer(AsmDef));
            TaskQueue.Add(new MethodCleaner(AsmDef));
            //TaskQueue.Add(new Renamer(AsmDef, new RenamingScheme(true) {Resources = false}));
            TaskQueue.Add(new Renamer(AsmDef, new RenamingScheme(false)
            {
                Methods = true, Fields = true, Properties = true, Parameters = true, Events = true, Delegates = true
            }));

            if (Globals.DeobContext.DynStringCtx == null)
            {
                TaskQueue.Add(new StringDecryptor(AsmDef));
            }
            else
            {
                TaskQueue.Add(new GenericStringDecryptor(AsmDef));
            }

            Deobfuscate();
        }
示例#17
0
        private void SyncRepositoryToQueue()
        {
            var repository = Provider.GetService <ISourceRepository>();
            var registry   = Provider.GetService <IProjectModuleRegistry>();

            var currentDateTime = DateTime.Now;
            var actualTasks     = repository.ScheduleTasks().Where(task =>
                                                                   (task.State == ScheduleTaskState.Initiated && task.DateTime <= task.DateTime.AddMilliseconds(Range)) ||
                                                                   Math.Abs((currentDateTime - task.DateTime).TotalMilliseconds) <= Range);

            foreach (var task in actualTasks)
            {
                var targetTask = TaskQueue.Find(item => item.Id == task.Id);
                if (targetTask == null)
                {
                    var moduleTask = registry.CreateModuleTask(task.Module.Code, new object[] { Provider, task.ProjectModuleId, task.Module.Project.UserId });
                    task.Task = moduleTask;

                    TaskQueue.Add(task);
                }
            }
        }
        public virtual void Submit(Action task)
        {
            if (task == null)
            {
                throw new ArgumentNullException("task is null");
            }

            if (HasQueue)
            {
                if (TrySubmit(task))
                {
                    return;
                }

                TaskQueue.Add(task);
                return;
            }

            IEntry <WorkerThread> entry = ObjectPool.Acquire();

            entry.Object.SetTask(task);
        }
示例#19
0
        public override void CreateTaskQueue()
        {
            switch ((Globals.DeobContext.ActiveSignature).Ver.Minor)
            {
            case 7:
                TaskQueue.Add(new MetadataFixer(AsmDef));
                //TaskQueue.Add(new MethodCleaner2(AsmDef));
                //TaskQueue.Add(new ProxyResolver(AsmDef));
                TaskQueue.Add(new MethodCleaner(AsmDef));
                TaskQueue.Add(new ResourceDecryptor(AsmDef));
                //TaskQueue.Add(new ProxyResolver2(AsmDef));
                TaskQueue.Add(new ConstantsDecryptor(AsmDef));
                TaskQueue.Add(new StackUnderflowCleaner(AsmDef));
                TaskQueue.Add(new WatermarkRemover(AsmDef));
                TaskQueue.Add(new AntiDump(AsmDef));
                TaskQueue.Add(new AntiDebug(AsmDef));
                TaskQueue.Add(new AntiILDasm(AsmDef));
                TaskQueue.Add(new Renamer(AsmDef, new RenamingScheme(true)
                {
                    Resources = false
                }));
                break;

            case 8:
                TaskQueue.Add(new MetadataFixer(AsmDef));
                TaskQueue.Add(new WatermarkRemover(AsmDef));
                break;

            case 9:
                TaskQueue.Add(new MetadataFixer(AsmDef));
                TaskQueue.Add(new ProxyResolver2(AsmDef));
                break;
            }

            Deobfuscate();
        }
示例#20
0
    TaskQueue ComicSequence(Transform scenarioTransform, int comicNum)
    {
        int       numPages   = scenarioTransform.childCount;
        TaskQueue comicTasks = new TaskQueue();

        comicTasks.Add(new SetObjectStatus(true, scenarioTransform.gameObject));
        for (int i = 0; i < numPages; i++)
        {
            Transform page = scenarioTransform.GetChild(i);
            comicTasks.Add(new SetObjectStatus(true, page.gameObject));
            int numPanels = page.childCount;
            for (int j = 0; j < numPanels; j++)
            {
                comicTasks.Add(new SlideInPanel(page.GetChild(j).gameObject, true, comicShifts[comicNum][i][j],
                                                Services.ComicPanelManager.panelAppearTime));
            }
            if (i == 0)
            {
                comicTasks.Add(new ActionTask(Services.ComicPanelManager.PositionAndActivateCalendarCircle));
            }
            comicTasks.Add(new WaitToContinueFromComic(page.gameObject, Services.ComicPanelManager.continueButton,
                                                       Services.TransitionUIManager.readyPromptGrowTime, Services.TransitionUIManager.readyPromptShrinkTime));
            if (i == 0)
            {
                comicTasks.Add(new SetObjectStatus(false, Services.ComicPanelManager.calendarCircle));
            }
        }

        comicTasks.Then(new TaskQueue(new List <Task>()
        {
            new SetObjectStatus(false, Services.DialogueUIManager.dialogueContainer),
            new SetObjectStatus(false, Services.ComicPanelManager.comicBackground)
        }));

        return(comicTasks);
    }
示例#21
0
        protected virtual void BeginFlush(DateTime date)
        {
            try
            {
                if (Disabled)
                {
                    return;
                }
                if (Queue.Count() == 0)
                {
                    return;
                }

                if (Client.CanSendData == false)
                {
                    return;
                }

                if (Client.CanConvertToServerDate() == false)
                {
                    return;
                }

                List <BufferEventData> allEvents = null;
                lock (Queue.SynchRoot)
                {
                    allEvents = Queue.GetAll();
                }

                if (allEvents == null || allEvents.Count == 0)
                {
                    return;
                }

                // получаем события для отправки
                int maxSendCount = Client.Config.Events.EventManager.MaxSend;

                var sendEvents = allEvents
                                 .Where(x =>
                                        x.Status == AddEventStatus.WaitForSend &&
                                        x.CreateDate <= date &&
                                        x.ComponentControl.IsFake() == false)
                                 .OrderBy(x => x.Errors)
                                 .ThenBy(x => x.CreateDate)
                                 .Take(maxSendCount)
                                 .ToList();

                // получаем события для склейки
                int maxJoinCount = Client.Config.Events.EventManager.MaxJoin;

                var joinEvents = allEvents
                                 .Where(x =>
                                        x.Status == AddEventStatus.WaitForJoin &&
                                        x.ComponentControl.IsFake() == false &&
                                        x.LastAttempSendOrJoinDate <= date)
                                 .OrderBy(x => x.Errors)
                                 .Take(maxJoinCount)
                                 .ToList();

                // создаем задачи для отправки
                foreach (var bufferEventData in sendEvents)
                {
                    BufferEventData data = bufferEventData;
                    TaskQueue.Add(() => SendOneEvent(data));
                }

                // создаем задачи для склейки
                if (joinEvents.Any(x => x.ComponentControl.Info == null))
                {
                    throw new Exception("joinEvents.Any(x => x.ComponentControl.Info == null)");
                }
                joinEvents = joinEvents.OrderBy(x => x.ComponentControl.Info.Id).ToList();
                const int batchCount  = 20;// будем продлевать 20 событий за раз
                var       batchEvents = new List <BufferEventData>(batchCount);
                foreach (var bufferEventData in joinEvents)
                {
                    batchEvents.Add(bufferEventData);
                    if (batchEvents.Count == batchCount)
                    {
                        var tempEvents1 = new List <BufferEventData>();
                        tempEvents1.AddRange(batchEvents);
                        TaskQueue.Add(() => JoinEvents(tempEvents1));
                        batchEvents.Clear();
                    }
                }
                if (batchEvents.Count > 0)
                {
                    var tempEvents = new List <BufferEventData>();
                    tempEvents.AddRange(batchEvents);
                    TaskQueue.Add(() => JoinEvents(tempEvents));
                }
            }
            catch (Exception exception)
            {
                Client.InternalLog.Error("Ошибка обработки очереди событий", exception);
            }
        }
示例#22
0
        protected virtual void ProcessQueue(object state)
        {
            // если очередь переполнена, то почистим ее
            int maxSize     = Client.Config.Logs.WebLog.QueueBytes;
            int currentSize = LogQueue.Bytes();

            if (currentSize > maxSize)
            {
                Client.InternalLog.Warning("Очищаем очередь веб-логов");
                LogQueue.ClearBySize(maxSize / 2); // очищаем половину очереди
                Client.InternalLog.Debug("Очередь веб-логов очищена");
            }

            if (Disabled)
            {
                return;
            }

            if (LogQueue.Count() == 0)
            {
                return;
            }

            // если все потоки заняты, то ждем следующей итерации
            if (TaskQueue.HasFreeThreads == false)
            {
                return;
            }
            if (TaskQueue.RunTasks > 0)
            {
                return;
            }

            // если канал оффлайн, то ничего не отправляем
            if (Client.CanSendData == false)
            {
                return;
            }

            // если не можем вычислить разницу по времени, значит канал дохлый
            if (Client.CanConvertToServerDate() == false)
            {
                return;
            }

            // разбиваем все логи по пачкам и отправляем
            int batchSize = Client.Config.Logs.WebLog.BatchBytes;

            lock (LogQueue.SynchRoot)
            {
                // todo отправляются ВСЕ логи которые сейчас в очереди,
                // т.е. по факту в памяти будет логов = размер очереди * 2 (1 часть логов в тасках, 2-ая в очереди),
                // надо подумать можно ли так много доставать из очереди
                while (true)
                {
                    // получим пачку логов для отправки
                    var batchLogs = LogQueue.GetBatchMessages(batchSize);
                    if (batchLogs.Count == 0)
                    {
                        Order = 0;
                        return;
                    }

                    // установим серверное время
                    foreach (var log in batchLogs)
                    {
                        if (log.Date == null)
                        {
                            log.Date = Client.ToServerTime(log.CreateDate);
                        }
                    }

                    // отправим
                    TaskQueue.Add(SendBatchLogs, batchLogs, "SendBatchLogs");
                }
            }
        }
示例#23
0
        public async Task ExecTest()
        {
            var que = new TaskQueue <bool>();

            //失败重试
            que.Add(_ => Run(1000), 0, "cmd1");
            que.Add(_ => Run(500, false), 2, "cmd2");
            que.Add(_ => Run(500), 0, "cmd3");
            await que.Exec();

            que.History.Select(p => p.Result).Should().BeEquivalentTo(new[] { true, false, true });

            //固定超时
            que.Clear();
            que.Add(token => Run(1000, true, token), 0, "cmd1");
            que.Add(token => Run(1000, true, token), 0, "cmd2");
            que.Add(token => Run(1000, true, token), 0, "cmd3");
            await Assert.ThrowsAsync(typeof(OperationCanceledException), async() => await que.Exec(1.7));

            que.History.Count(p => p.Result).Should().Be(2);

            //取消任务
            que.Clear();
            que.Add(token => Run(500, true, token), 0, "cmd1");
            que.Add(token => Run(500, true, token), 0, "cmd2");
            que.Add(token => Run(500, true, token), 0, "cmd3");
            que.Add(token => Run(500, true, token), 0, "cmd4");
            que.Add(token => Run(500, true, token), 0, "cmd5");
            que.Add(token => Run(500, true, token), 0, "cmd6");
            var cts = new CancellationTokenSource();

            cts.CancelAfter(2100);
            await Assert.ThrowsAsync(typeof(OperationCanceledException), async() => await que.Exec(cts.Token));

            que.History.Count().Should().Be(5);

            //暂停 继续
            que.Build();
            await Assert.ThrowsAsync(typeof(OperationCanceledException), async() => await que.Exec(1.2));

            que.History.Count(p => p.Result).Should().Be(2);
            que.History.Count(p => !p.Result).Should().Be(1);
            que.PendingQueue.Count().Should().Be(4);
            await que.Exec();

            que.History.Count(p => p.Result).Should().Be(6);
            que.History.Count(p => !p.Result).Should().Be(1);
            que.PendingQueue.Count().Should().Be(0);
        }
示例#24
0
 public void AddQueue(Func <IReader> getReader)
 {
     _queue.Add((self, id) => getReader().Get <T>(data => self.AddValue(id, data)));
 }
示例#25
0
 /// <summary>
 /// Adds a task at the end of the queue
 /// </summary>
 /// <param name="task">Task to add to queue</param>
 public void AddTask(ITask task)
 {
     TaskQueue.Add(task);
 }