protected override SpaceShipControlInput GetControls() { if (CurrentTask != null) { return(CurrentTask.GetConstrols()); } else { return(null); } }
public void NavWillShowViewController(UIViewController viewController) { // let the current task know which of its view controllers was just shown. if (CurrentTask != null) { TaskControllerAnimating = true; CurrentTask.WillShowViewController((TaskUIViewController)viewController); } UpdateBackButton( ); }
protected override void on_stop(bool reset) { if (CurrentTask.Recheck()) { CurrentTask.Kit.CheckoutWorker(this); } if (reset) { reset_current_task(); } }
private void GiveAnswer() { _countScore += CurrentTask.GetResult(); if (_countTask + 1 == CurrentQuiz.Tasks.Count) { new ResultWindow(_countScore, CurrentQuiz).Show(); } else { SetCurrentTask(++CountTask); } }
public void LayoutChanged( ) { if (SubNavigationController != null) { SubNavigationController.View.Bounds = View.Bounds; } if (CurrentTask != null) { CurrentTask.LayoutChanged(View.Bounds); } }
// Call this first public void CancelTasks(Action callback) { if (callback == null) { TaskManager.SafeReport(0, "Operation Cancelled."); } if (this.CancelTokenSource == null) { callback?.Invoke(); return; } if (this.CancelToken == CancellationToken.None) { callback?.Invoke(); return; } if (!this.CancelToken.CanBeCanceled) { callback?.Invoke(); } // If not yet requested, just cancel and do new task // TODO: If already requested... need to somehow cancel other task before assigning this task. if (!this.CancelToken.IsCancellationRequested) { try { this.CancelTokenSource.Cancel(true); for (int i = 15; i > 0; i--) { if (CurrentTask?.Wait(100) != false) { break; } } // Unable to continue after cancelling the task. We must wait it out. } catch (TaskCanceledException) { } catch (AggregateException aex) { if (aex.InnerExceptions.Any(x => x.GetType() != typeof(TaskCanceledException))) { throw; } } callback?.Invoke(); } else if (CurrentTask != null && CurrentTask.IsCompleted) { callback?.Invoke(); } }
/// <summary> /// 生成题目 /// </summary> /// <returns>题目对象</returns> public Problem GenerateProblem() { if (CurrentTask != null) { throw new CurrentTaskException("未完成当前正在进行的任务,请勿开启下一个任务!"); } var result = WeaknessMg.GenerateProblem(); CurrentTask = result; CurrentTask.FinishListener += CurrentTaskFinish; return(result); }
/// <summary> /// Run the task that is selected /// </summary> protected virtual void RunTask() { TaskWorker task = CurrentTask; if (AutoResetTasks && !isRecovering) { CurrentTask.Reset(); } isRecovering = false; task.StateChanged += Task_StateChanged; task.Start(); }
IEnumerator Run() { IsQueueRunning = true; do { CurrentTask = RemoveTask(); CurrentTask.IsDoing = true; yield return(CurrentTaskCoroutine = StartCoroutine(CurrentTask.DoTask())); Debug.Log("po startcor"); } while (tasks.Count > 0); IsQueueRunning = false; }
protected sealed override void OnFiniteTaskFrameRun(float deltaTime) { CurrentTask.RunFrame(deltaTime); while (CurrentTask.IsFinished && !OnLastTask) { #if DEBUGLOG if (ShouldLog) { string finished = $"FINISHED {CurrentTask.GetType().Name}"; string next = $"NEXT {InnerTasks[CurrentIndex + 1].GetType().Name}"; string duration = $"{Timer.Elapsed.ToString("0.00")} / {Timer.ActivationInterval.ToString("0.00")}"; LogUtil.Log($"({duration}) {finished} : {next}"); } #endif CurrentIndex++; CurrentTask.ResetSelf(); float overflowDt = CurrentTask.OverflowDeltaTime; if (overflowDt > 0) { CurrentTask.RunFrame(overflowDt); } } // A rare edge case could occur when the last tasks have a duration close to 0, // and loss of floating point precision causes the base timer to activate // before activating each last task. if (IsFinished) { #if DEBUGLOG if (ShouldLog) { LogUtil.Log($"FINISHED {CurrentTask.GetType().Name}!"); } #endif if (!CurrentTask.IsFinished) { CurrentTask.RunRemainingTime(); CurrentIndex++; while (CurrentIndex <= LastIndex) { CurrentTask.ResetSelf(); CurrentTask.RunRemainingTime(); CurrentIndex++; } } } }
/// <summary> /// Creates a new action based upon an other action which will handle exceptions. Use this to wrap safe action for tasks. /// </summary> /// <param name="function">The orignal action.</param> /// <returns>The safe action.</returns> public static Action CreateSafeAction <T>(Action action) { return(() => { try { action(); } catch { CurrentTask.Abort(); } }); }
private void Add() { if (SelectedTask == null) { return; } foreach (var shape in SelectedItems) { CurrentTask.Add(SelectedTask, shape.GridX, shape.GridY); } SelectedItems.Clear(); }
public void ActivateTask(Task task) { // reset our stack and remove all current view controllers // before changing activities SubNavigationController.ClearViewControllerStack( ); if (CurrentTask != null) { CurrentTask.MakeInActive( ); } _CurrentTask = task; CurrentTask.MakeActive(SubNavigationController, SubNavToolbar, View.Bounds); }
public override void TouchesBegan(NSSet touches, UIEvent evt) { base.TouchesBegan(touches, evt); // only allow panning if the task is ok with it AND we're in portrait mode. if (CurrentTask.CanContainerPan(touches, evt) == true && SpringboardViewController.IsDeviceLandscape( ) == false) { PanGesture.Enabled = true; } else { PanGesture.Enabled = false; } }
protected void current_task_pane() { GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.Label(Colors.Active.Tag("<b>Kit:</b>"), Styles.boxed_label, GUILayout.Width(40), GUILayout.ExpandHeight(true)); draw_task(CurrentTask); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label(Colors.Active.Tag("<b>Part:</b>"), Styles.boxed_label, GUILayout.Width(40), GUILayout.ExpandHeight(true)); CurrentTask.DrawCurrentPart(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); }
/// <summary> /// Creates a new function based upon an other function which will handle exceptions. Use this to wrap safe functions for tasks. /// </summary> /// <typeparam name="T">The return type of the function.</typeparam> /// <param name="function">The orignal function.</param> /// <returns>The safe function.</returns> public static Func <T> CreateSafeFunction <T>(Func <T> function) { return(() => { try { return function(); } catch { CurrentTask.Abort(); return default(T); } }); }
private void RegisterMessages() { _messenger.Register <TaskListItemViewModel>( this, $"{MessageType.NAVIGATIONVIEW_SELECTION_CHANGED}", (taskList) => { _currentTaskList = taskList; _messenger.Send(false, $"{MessageType.OPEN_PANE}"); }); _messenger.Register <TaskItemViewModel>( this, $"{MessageType.NEW_TASK}", async(task) => { await GetAllTaskListAsync(); await InitView(task.TaskID); CurrentTask.Validator = i => { var u = i as TaskItemViewModel; if (string.IsNullOrEmpty(u.Title) || u.Title.Length < 2) { u.Properties[nameof(u.Title)].Errors.Add("Title is required"); } if (string.IsNullOrEmpty(u.Notes) || u.Notes.Length < 2) { u.Properties[nameof(u.Notes)].Errors.Add("Notes are required"); } }; UpdateTaskOperationTitle(CurrentTask.IsNew, CurrentTask.HasParentTask); //IsCurrentTaskTitleFocused = true; CurrentTask.Validate(); }); _messenger.Register <string>( this, $"{MessageType.TASK_DELETED_FROM_CONTENT_FRAME}", OnTaskRemoved); _messenger.Register <bool>( this, $"{MessageType.SHOW_PANE_FRAME_PROGRESS_RING}", (show) => ShowTaskProgressRing = show); _messenger.Register <Tuple <TaskItemViewModel, bool> >( this, $"{MessageType.TASK_STATUS_CHANGED_FROM_CONTENT_FRAME}", (tuple) => OnTaskStatusChanged(tuple.Item1, tuple.Item2)); }
private void Generate() { if (CurrentTask == null) { return; } SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "g-code file (*.gcode)|*.gcode"; if (saveFileDialog.ShowDialog() != true) { return; } //CurrentTask.GridMap = GridMap; CurrentTask.GenerateCode(saveFileDialog.FileName); }
public Task IsQueued(GameObject go) { foreach (Task task in tasks) { if (task.GetTaskGameObject() == go) { return(task); } } if (CurrentTask && CurrentTask.GetTaskGameObject() == go) { return(CurrentTask); } return(null); }
public void LayoutChanging( ) { UpdateBackButton( ); if (SpringboardViewController.IsDeviceLandscape( ) == true) { EnableSpringboardRevealButton(false); } else { EnableSpringboardRevealButton(true); } if (CurrentTask != null) { CurrentTask.LayoutChanging( ); } }
private void Replacer_TaskFinished(CurrentTask currentTask) { SetState(State.Done); switch (currentTask) { case CurrentTask.SearchFiles: SetState(State.AfterSearch); break; case CurrentTask.ReplaceText: SetState(State.Done); break; default: break; } }
/// <summary> /// Queries the current task for suggestions on linear and angular velocities, and sets up thrusters and gyros accordingly. /// </summary> /// <param name="elapsed">How many seconds elapsed since the last update.</param> /// <returns>True if all tasks have been completed.</returns> public bool Update(double elapsed) { if (CurrentTask == null) //if there is nothing to do, drift { return(true); //report that we are done } else //there is something to do { elapsedTime = elapsed; Velocities = Controller.GetShipVelocities(); Mass = Controller.CalculateShipMass(); // current velocities Vector3D LinearV = Velocities.LinearVelocity; Vector3D TargetAngularV = Velocities.AngularVelocity; //task can always set respective velocities to 0 to avoid linear and/or angular motion Controller.DampenersOverride = CurrentTask.DampenersOverride; //query the task. bool done = CurrentTask.Update(this, ref LinearV, ref TargetAngularV); Log?.Invoke($"Task {CurrentTask.ToString()}\nDone: {done}\nLinear {LinearV.ToString()}\nAngular {TargetAngularV.ToString()}"); //whether its done or not, apply changes to thrust/rotation SetRotationVelocity(TargetAngularV, CurrentTask.Reference, CurrentTask.ReferenceForward, CurrentTask.ReferenceUp); SetThrustVector(LinearV); if (done) { //current task has been completed Tasks.RemoveAt(0); if (Tasks.Count > 0) { return(false); } else { //set the ship to manual piloting Controller.DampenersOverride = true; DisableOverrides(); return(true); } } else { return(false); } } }
public CurrentTaskReply CreateReply(CurrentTask currentTask) { Random rand = new Random(); int num = 0; while (true) { num = rand.Next(0, _chars.Length - 1); var key = $"{currentTask.UserId}-{_chars[num]}"; if (!_memoryCache.TryGetValue(key, out _)) { break; } } return(new CurrentTaskReply { ConfirmChar = _chars[num], Task = currentTask }); }
public override void OnListenerMessage(EventParamete parameteData) { if (parameteData.EvendName == SwitchPanel.PanelToState.ToString()) { PanelName panelName = parameteData.GetParameter <PanelName>()[0]; switch (panelName) { case PanelName.WaitPanel: CurrentTask.ChangeTask(new WaitTask(this)); break; case PanelName.MenuPanel: CurrentTask.ChangeTask(new MenuTask(this)); break; default: break; } } }
public override void OnListenerMessage(EventParamete parameteData) { if (parameteData.EvendName == SwitchPanelEvent) { switch (parameteData.GetParameter <SwitchPanelEnum>()[0]) { case SwitchPanelEnum.StartMenuPanel: CurrentTask.ChangeTask(new StartMenutask(this)); break; case SwitchPanelEnum.GamePanel: CurrentTask.ChangeTask(new Gametask(this)); break; case SwitchPanelEnum.AppreciatePanel: CurrentTask.ChangeTask(new AppreciateTask(this)); break; } } }
public void StopEffect() { if (CurrentEffect == null || CurrentTask == null) { return; } CurrentEffect.UseEffect = false; try { CurrentTask.Wait(); } catch (ObjectDisposedException) { } CurrentEffect = null; CurrentTask = null; }
public void PrintTasks() { Log.Write(string.Format("Aisle {0} Elevator {1} - Elevator Task List Print Out", ParentMultiShuttle.Name, ElevatorName)); if (CurrentTask != null) { Log.Write(string.Format("Elevator Current Task - {0}", CurrentTask.ToString())); } if (ElevatorTasks.Count > 0) { foreach (ElevatorTask task in ElevatorTasks) { Log.Write(string.Format("Elevator Task - {0}", task.ToString())); } } else { Log.Write(string.Format("Aisle {0} Elevator {1} - Elevator Task List Empty", ParentMultiShuttle.Name, ElevatorName)); } }
public async void GeneratePointAsync(MaskForm mf, int amount) { if (CurrentTask != null) { await CurrentTask; } CancellationSource = new CancellationTokenSource(); CurrentTask = Task.Run(() => GeneratePointImpl(mf, amount), CancellationSource.Token); await CurrentTask; CurrentTask.Dispose(); CurrentTask = null; CancellationSource.Dispose(); CancellationSource = null; FinishedEvent(); }
//Provide each directory with data private void SetDirectoryData(GameObject go, string dirName) { currentTask = DataManager.Instance.GetData(dirName); //Get saved data for directory currentInfo = currentTask.savedData; int completeLevels = currentInfo.currentLevel - 1; int dirLength = currentTask.dirLength; go.transform.Find("Image").GetComponent <Image>().sprite = completeLevels == 0 ? defaultPicture : CreateSprite(dirName); //Set up directory view go.transform.Find("Text1").GetComponent <Text>().text = currentTask.localizedDir.ToUpper(); //Should it be unlocked? if (CheckIsLocked(dirName)) { go.transform.Find("Text2").GetComponent <Text>().text = DataManager.Instance.GetLocalizedValue(ElementType.locked_text).ToUpper(); go.GetComponent <Button>().onClick.AddListener(() => MusicManager.instance.PlaySound("wrong")); go.transform.GetComponent <Image>().color -= new Color(0, 0, 0, 0.4f); } else { go.transform.Find("Text2").GetComponent <Text>().text = completeLevels + "\u002f" + dirLength; //Set up progress bar float barPercent = (float)completeLevels / (float)dirLength; RectTransform bar = go.transform.Find("Bar/ProgressBar").GetComponent <RectTransform>(); bar.anchoredPosition += new Vector2((bar.sizeDelta.x * barPercent), 0); if (barPercent < 1) { //Add OnClick methods to directory buttons if there are not completed yet go.GetComponent <Button>().onClick.AddListener(() => DataManager.Instance.currentDir = dirName); go.GetComponent <Button>().onClick.AddListener(() => StaticBehaviors.LoadScene(1)); } else { go.GetComponent <Button>().onClick.AddListener(() => SpawnGallery(dirName)); } } }
void Initialize() //Levels data constructor { hintsCost = new int[6]; try { CurrentTask temp = DataManager.Instance.GetData(); type = temp.gameType; infoTosave = temp.savedData; rightAnswer = temp.rightAnswer.ToLower(); rightAnswerNoSpaces = rightAnswer.Replace(" ", string.Empty); imageText = temp.imageText; completeLvlCoins = temp.levelCost; int letterCount = rightAnswerNoSpaces.ToCharArray().Length; hintsCost[2] = DataManager.Instance.solveTaskCost; hintsCost[3] = DataManager.Instance.pixelateCost; hintsCost[4] = DataManager.Instance.plankCost; hintsCost[5] = DataManager.Instance.erasureCost; //Calculations to balance hints cost depending on the words length if (hintsCost[2] >= 100) { hintsCost[1] = Mathf.CeilToInt((hintsCost[2] / 1.8f) / 10) * 10; hintsCost[0] = Mathf.CeilToInt((hintsCost[2] * 2.5f / letterCount) / 10) * 10; } else { hintsCost[1] = Mathf.CeilToInt(hintsCost[2] / 1.8f); hintsCost[0] = Mathf.CeilToInt(hintsCost[2] * 2.5f / letterCount); } fullList = CreateListOfLetters(DataManager.Instance.randomLetters); StaticBehaviors.Shuffle(fullList); } catch (Exception) { Debug.LogError("You should start the game from 'StartMenu' scene. Or some references are broken"); } }