private async Task AbilSelect() { mainMenu.ClearSelection(); int slot = await abilMenu.SelectItemAsync(); if (slot >= 0) { var unit = Global.Instance().Data.Party[slot]; var abilMenu = AbilMenuView.ShowDefault(); await abilMenu.DoMenuAsync(unit); await abilMenu.CloseRoutine(); } }
private async Task <bool> RecruitAndNameAsync(CharaData data) { recruitCells.gameObject.SetActive(false); recruitSummary.gameObject.SetActive(false); unitCell.gameObject.SetActive(true); letterList.gameObject.SetActive(true); var unit = new Unit(data); unitCell.Populate(unit); var chars = new List <char> { ' ' }; for (int i = 'A'; i <= 'Z'; i += 1) { chars.Add((char)i); } chars.Add(' '); chars.Add(' '); for (int i = 'a'; i <= 'z'; i += 1) { chars.Add((char)i); } chars.Add(' '); chars.Add(' '); for (int i = '0'; i <= '9'; i += 1) { chars.Add((char)i); } chars.Add('-'); chars.Add(' '); chars.Add(' '); letterList.Populate(chars, (obj, @char) => { obj.GetComponent <Text>().text = @char.ToString(); }); char[] nameArray = unit.Name.ToCharArray(); Array.Resize(ref nameArray, 10); int letterIndex = 0; bool?result = null; while (!result.HasValue && letterIndex < 10) { var validChars = nameArray.Where(@char => @char != 0 && @char != ' '); if (validChars.Count() > 0) { StringBuilder name = new StringBuilder(); foreach (var c in validChars) { name.Append(c); } unit.SetName(name.ToString().Trim()); } unitCell.Populate(unit); ShowLetterHighlight(letterIndex); var selection = await letterSelector.SelectItemAsync(null, true); if (selection == GenericSelector.CodeCancel) { if (new string(nameArray).Trim().Length > 0 && letterIndex == 0) { for (int i = 0; i < 10; i += 1) { nameArray[i] = ' '; } } if (letterIndex == 0) { result = false; } else { letterIndex -= 1; nameArray[letterIndex] = ' '; } } else if (selection == GenericSelector.CodeMenu) { result = true; } else { if (letterIndex == 0) { for (int i = 0; i < 10; i += 1) { nameArray[i] = ' '; } } var cell = letterSelector.GetCell(selection); nameArray[letterIndex] = cell.GetComponent <Text>().text[0]; letterIndex += 1; } } if (!result.HasValue) { // the name is at the max length result = unit.Name.Length > 0; } if (result.Value) { Global.Instance().Data.Party.AddMember(unit); } else { recruitCells.gameObject.SetActive(true); recruitSummary.gameObject.SetActive(true); unitCell.gameObject.SetActive(false); letterList.gameObject.SetActive(false); } foreach (var highlight in letterHighlights) { highlight.SetActive(false); } return(result.Value); }