public void OnPointerDown(PointerEventData data) { MenuGlobal global = MenuGlobal.instance; PlayerStats stats = PlayerStats.instance; global.SetDescriptionText(shipDescription + "\n \nПрочность корпуса: " + stats.health + "/" + stats.maxHealth); }
void Awake() { if (instance == null) { instance = this; } anwser1InitText = anwser1ButtonText.text; anwser2InitText = anwser2ButtonText.text; anwser3InitText = anwser3ButtonText.text; questInitText = questText.text; }
void Start() { Cursor.lockState = CursorLockMode.None; Cursor.visible = true; if (instance == null) { instance = this; } DragItem[] itemsInScene = inventoryPanel.transform.GetComponentsInChildren <DragItem>(); foreach (DragItem item in itemsInScene) { // Debug.Log("add"); items.Add(item); } }
/// <summary> /// Prompts the user a series of navigation options. The prompt will take a certain action dependent on the user's choice. /// The menu's selector position (relative to MenuGlobal NOT console buffer line) is moved here. /// </summary> /// <seealso cref="RunMenu"/> override protected void PromptNav() { int lastMenuItemIndex = MenuGlobal.Count - 1; int unchangedSelectorPosition = SelectorPosition; if (Console.OutputEncoding.EncodingName == "Unicode (UTF-8)") { Console.WriteLine("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"); Console.WriteLine(" ↑/ U - Up, ↓/ D - Down, ←╯/ S - Select"); } else { Console.WriteLine("----------------------------------------------------------------"); Console.WriteLine(" Up-Arrow/ U - Up, Down-Arrow/ D - Down, Enter/ S - Select"); } while (true) { ConsoleKeyInfo KeyPressed = Console.ReadKey(true); if (KeyPressed.Key == ConsoleKey.U || KeyPressed.Key == ConsoleKey.UpArrow) { //If doable, move selector up by 1 if (SelectorPosition > 0) { SelectorPosition--; } else { continue; } //If selector is pointing at a non-menu-item... if (!(MenuGlobal[SelectorPosition] is MenuItem)) { //While selector position hits bar, keep moving selector up till it hits a menu item while (!(MenuGlobal[SelectorPosition] is MenuItem) && SelectorPosition > 0) { SelectorPosition--; } //If only bars encountered, move selector to the first menu item if (!(MenuGlobal[SelectorPosition] is MenuItem)) { SelectorPosition = MenuGlobal.FindIndex(item => item is MenuItem); } //If no menu items can be found, set selector position to 0 if (SelectorPosition == -1) { SelectorPosition = 0; } } //---------------------------------------------------------------- goto SelectorMoved; } else if (KeyPressed.Key == ConsoleKey.D || KeyPressed.Key == ConsoleKey.DownArrow) { //If doable, move selector down by 1 if (SelectorPosition < lastMenuItemIndex) { SelectorPosition++; } else { continue; } //If selector is pointing at a non-menu-item... if (!(MenuGlobal[SelectorPosition] is MenuItem)) { //While selector position hits bar, keep moving selector down till it hits a true menu item while (!(MenuGlobal[SelectorPosition] is MenuItem) && SelectorPosition < lastMenuItemIndex) { SelectorPosition++; } //If only bars encountered, move selector to the first menu item if (!(MenuGlobal[SelectorPosition] is MenuItem)) { SelectorPosition = MenuGlobal.FindLastIndex(item => item is MenuItem); } //If no true menu items can be found, set selector position to 0 if (!(MenuGlobal[SelectorPosition] is MenuItem)) { SelectorPosition = 0; } } //----------------------------------------------------------------- goto SelectorMoved; } else if (KeyPressed.Key == ConsoleKey.S || KeyPressed.Key == ConsoleKey.Enter) { goto MenuItemInvoked; } } /* Note: * I get it, you don't like goto statements, and for good reason. * That being said, know it prevented a situation of loop build-up * over a series of method calls and that better options * , at the time, could not be found. */ MenuItemInvoked: MenuGlobal[SelectorPosition].Action?.DynamicInvoke(); SelectorMoved: this.RunMenu(ref unchangedSelectorPosition, ref SelectorPosition); }