public void Start() { while (_selectIndex != -1) { DrawScreenTitle(Data._battleInfo.bag); Write(" " + Helper.RCenter("-" + Data._itemInfo.categories [_catIndex] + "-"), 3, ConsoleColor.DarkYellow); GetSelection(true, _selectIndex); if (_selectIndex != -1) { Item item = _chosenItem; bool canUse = true; bool useSuccessful = (item.accuracy >= PreGameScreen._rand.NextDouble()) ? true : false; int unitIndex = -1; if ((item.flags.Contains("!bo") && !GameFile._inBattle) || (!item.flags.Contains("!b") && GameFile._inBattle)) { canUse = false; } if (canUse) { if (item.flags.Contains("!p")) { MenuUnitsScreen mps = new MenuUnitsScreen(0, "Select the " + " to use this item on.", "There are no " + " that can benefit from this item."); if (item.effect == Item.Effect.HealHP) { for (int i = 0; i < GameFile._units.Count(); i++) { mps._selectionAbles [i] = (GameFile._units [i].hpLeft <= 0 || GameFile._units [i].hpLeft == GameFile._units [i].stats ["HP"]) ? false : true; } } else if (item.effect == Item.Effect.Revive) { for (int i = 0; i < GameFile._units.Count(); i++) { mps._selectionAbles [i] = (GameFile._units [i].hpLeft > 0) ? false : true; } } else if (item.effect == Item.Effect.Cure) { for (int i = 0; i < GameFile._units.Count(); i++) { mps._selectionAbles [i] = (GameFile._units [i].ailment.turns == 0 || GameFile._units [i].hpLeft == 0 || GameFile._units [i].ailment.id != item.effectNum) ? false : true; } } else if (item.effect == Item.Effect.TeachMove || item.effect == Item.Effect.GiveEXP || item.effect == Item.Effect.GiveLevel) { for (int i = 0; i < GameFile._units.Count(); i++) { mps._selectionAbles [i] = (GameFile._units [i].hpLeft == 0) ? false : true; if (GameFile._units [i].level == Data._unitInfo.maxLevel && GameFile._units [i].exp == GameFile._units [i].expNext - 1) { mps._selectionAbles [i] = false; } } } unitIndex = mps.GetSelection(true); if (unitIndex != -1) { TypeWrite(GetItemUseText(item.id, unitIndex), ConsoleColor.DarkYellow, true); if (useSuccessful) { UseItemEvent(item, unitIndex, ref _usedItem); } } else { _usedItem = false; } } else { TypeWrite(GetItemUseText(item.id, unitIndex), ConsoleColor.DarkYellow, true); if (useSuccessful) { UseItemEvent(item, unitIndex, ref _usedItem); } } } if (_usedItem) { if (!item.unlimited) { _stacks [_selectIndex].amount--; } if (_stacks [_selectIndex].amount <= 0) { GameFile._items.Remove(_stacks [_selectIndex]); _stacks.RemoveAt(_selectIndex); } if (useSuccessful) { TypeWrite(GetItemSuccessText(item.id, unitIndex), ConsoleColor.DarkYellow, true); } else { TypeWrite(GetItemFailText(item.id, unitIndex), ConsoleColor.DarkYellow, true); } if (GameFile._inBattle) { _selectIndex = -1; } else { if (GameFile._items.Count() > 0) { ChangeCategory(); } else { _selectIndex = -1; Clear(ClearType.Both); DrawScreenTitle("Menu"); TypeWrite(Data._itemInfo.noItemsText, ConsoleColor.DarkYellow, true, false, true); } } } } } }
public MenuScreen() : base() { _topLine = 5; int selection = 0; AddSelections(new List <string> { Data._battleInfo.units, Data._battleInfo.bag, "Save", "About " + Data._generalInfo.title, "Quit" }, 0, true); while (selection != -1) { Clear(ClearType.Both); DrawScreenTitle("Menu"); Write(" " + new string (' ', Data._generalInfo.width - Data._itemInfo.money.Length - 2 - GameFile._money.ToString().Length) + Data._itemInfo.money + ": " + GameFile._money.ToString(), 3, ConsoleColor.DarkYellow); selection = GetSelection(true, selection); if (selection == 0) { if (GameFile._units.Count() > 0) { int selection2 = 0; while (selection2 != -1) { MenuUnitsScreen mps = new MenuUnitsScreen(0); selection2 = mps.GetSelection(true, selection2, new List <string> { "Select", "Stats", "Swap", "Cancel" }); if (selection2 != -1) { new MenuUnitScreen(GameFile._units [selection2]); } } } else { TypeWrite(Data._unitInfo.noUnitsText, ConsoleColor.DarkYellow, true, false, true); } } else if (selection == 1) { if (GameFile._items.Count() > 0) { MenuBagScreen mbs = new MenuBagScreen(); mbs.UseItemEvent -= onUseItem; mbs.UseItemEvent += onUseItem; mbs.Start(); } else { TypeWrite(Data._itemInfo.noItemsText, ConsoleColor.DarkYellow, true, false, true); } } else if (selection == 2) { if (GameFile._fileName.Length == 0) { Clear(ClearType.Both); Write(Helper.RCenterWrapped(" " + "Enter a name for your save file."), 3, ConsoleColor.DarkYellow); int spaces = Data._generalInfo.width - 20; Write(" " + new string (' ', spaces / 2) + new string ('-', 20), 7, ConsoleColor.DarkYellow); Console.SetCursorPosition(spaces / 2 + 2, 6); string name = ""; ConsoleKey key = ConsoleKey.Applications; while (key != ConsoleKey.Enter) { key = Console.ReadKey(true).Key; if ((name.Length == 0 || name.Replace(" ", "").Length == 0) && key == ConsoleKey.Enter) { key = ConsoleKey.EraseEndOfFile; } if (key != ConsoleKey.Backspace && Console.CursorLeft < spaces / 2 + 20 + 2) { if ("ABCDEFGHIJKLMNOPQRSTUVWXYZ".Contains(key.ToString())) { Console.Write(key.ToString().ToLower()); name += key.ToString().ToLower(); } else if ("1234567890".Contains(key.ToString().Substring(1))) { Console.Write(key.ToString().Substring(1)); name += key.ToString().Substring(1); } else if (key == ConsoleKey.Spacebar) { Console.Write(" "); name += " "; } } else if (key == ConsoleKey.Backspace && Console.CursorLeft > spaces / 2 + 2) { Console.CursorLeft = Console.CursorLeft - 1; Console.Write(" "); Console.CursorLeft = Console.CursorLeft - 1; name = name.Substring(0, name.Length - 1); } } GameFile._fileName = name; } GameFile.SaveFile(); } else if (selection == 3) { new CreditsScreen(); } else if (selection == 4) { GameFile.ClearAll(); GameScreen._quit = true; break; } } }