public void Enqueue(TaskQueue q, IEnumerable <object> targetIDs) { _tasks.Clear(); int i = 1; foreach (object targetID in targetIDs) { Task <int> task = CreateTask(delay: i * 10); _tasks.Add(task); var item = new DelegateItem <int>(() => { task.Start(); return(task); }, targetID); q.Send(new Enqueue(item)).Wait(); } }
private void CheckControls() { //back button if (Globals.inputController.isButtonPressed(Buttons.B, null)) { this.fadeOutCompleteCallback = backToGame; this.StartTransitionOff(); } //select (enter) else if (Globals.inputController.isButtonPressed(Buttons.A, null)) { //Globals.audioManager.PlayMenuSound("menu_select"); /* */ if (submenus[currentSubMenuIndex].items[submenus[currentSubMenuIndex].selected] is TransitionItem) { TransitionItem current = (TransitionItem)submenus[currentSubMenuIndex].items[submenus[currentSubMenuIndex].selected]; int destination = current.destination; if (destination == -1) { this.StartTransitionOff(); } else { currentSubMenuIndex = destination; } } else if (submenus[currentSubMenuIndex].items[submenus[currentSubMenuIndex].selected] is DelegateItem) { DelegateItem current = (DelegateItem)submenus[currentSubMenuIndex].items[submenus[currentSubMenuIndex].selected]; this.fadeOutCompleteCallback = current.function; this.StartTransitionOff(); } } //GOING UP IN MENUS else if (Globals.inputController.isButtonPressed(Buttons.DPadUp, null) || Globals.inputController.isButtonPressed(Buttons.LeftThumbstickUp, null)) { int selectedIndex = submenus[currentSubMenuIndex].selected; int size = submenus[currentSubMenuIndex].items.Count(); int newIndex = selectedIndex - 1; if (newIndex < 0) { newIndex = size - 1; } submenus[currentSubMenuIndex].selected = newIndex; } //GOING DOWN IN MENUS else if (Globals.inputController.isButtonPressed(Buttons.DPadDown, null) || Globals.inputController.isButtonPressed(Buttons.LeftThumbstickDown, null)) { int selectedIndex = submenus[currentSubMenuIndex].selected; int size = submenus[currentSubMenuIndex].items.Count(); int newIndex = ++selectedIndex; if (newIndex == size) { newIndex = 0; } submenus[currentSubMenuIndex].selected = newIndex; } //GOING LEFT IN MENUS (TOGGLE) else if (Globals.inputController.isButtonPressed(Buttons.DPadLeft, null) || Globals.inputController.isButtonPressed(Buttons.LeftThumbstickLeft, null)) { if (submenus[currentSubMenuIndex].items[submenus[currentSubMenuIndex].selected] is ToggleItem) { ToggleItem currentToggle = (ToggleItem)submenus[currentSubMenuIndex].items[submenus[currentSubMenuIndex].selected]; int selectedIndex = currentToggle.current; int size = currentToggle.values.Count(); int newIndex = selectedIndex - 1; if (newIndex < 0) { newIndex = size - 1; } currentToggle.current = newIndex; } } //GOING RIGHT IN MENUS (TOGGLE) else if (Globals.inputController.isButtonPressed(Buttons.DPadRight, null) || Globals.inputController.isButtonPressed(Buttons.LeftThumbstickRight, null)) { if (submenus[currentSubMenuIndex].items[submenus[currentSubMenuIndex].selected] is ToggleItem) { ToggleItem currentToggle = (ToggleItem)submenus[currentSubMenuIndex].items[submenus[currentSubMenuIndex].selected]; int selectedIndex = currentToggle.current; int size = currentToggle.values.Count(); int newIndex = ++selectedIndex; if (newIndex == size) { newIndex = 0; } currentToggle.current = newIndex; } } }
private void CheckControls() { //back button if (Globals.inputController.isButtonPressed(Buttons.B, null)) { this.fadeOutCompleteCallback = backToMain; this.StartTransitionOff(); } //select (enter) else if (Globals.inputController.isButtonPressed(Buttons.A, null)) { if (submenus[currentSubMenuIndex].items[submenus[currentSubMenuIndex].selected] is TransitionItem) { TransitionItem current = (TransitionItem)submenus[currentSubMenuIndex].items[submenus[currentSubMenuIndex].selected]; int destination = current.destination; if (destination == -1) { this.StartTransitionOff(); } else { currentSubMenuIndex = destination; } } else if (submenus[currentSubMenuIndex].items[submenus[currentSubMenuIndex].selected] is DelegateItem) { DelegateItem current = (DelegateItem)submenus[currentSubMenuIndex].items[submenus[currentSubMenuIndex].selected]; this.fadeOutCompleteCallback = current.function; this.StartTransitionOff(); } } //GOING UP IN MENUS else if (Globals.inputController.isButtonPressed(Buttons.DPadUp, null) || Globals.inputController.isButtonPressed(Buttons.LeftThumbstickUp, null)) { int selectedIndex = submenus[currentSubMenuIndex].selected; int size = submenus[currentSubMenuIndex].items.Count(); int newIndex = selectedIndex - 1; if (newIndex < 0) { newIndex = size - 1; } submenus[currentSubMenuIndex].selected = newIndex; } //GOING DOWN IN MENUS else if (Globals.inputController.isButtonPressed(Buttons.DPadDown, null) || Globals.inputController.isButtonPressed(Buttons.LeftThumbstickDown, null)) { int selectedIndex = submenus[currentSubMenuIndex].selected; int size = submenus[currentSubMenuIndex].items.Count(); int newIndex = ++selectedIndex; if (newIndex == size) { newIndex = 0; } submenus[currentSubMenuIndex].selected = newIndex; } }