public void PresentNewMoveUI(DeltemonClass playerDelt) { for (int i = 0; i < 4; i++) { MoveClass tmp = playerDelt.moveset[i]; Transform button = NewMoveUI.transform.GetChild(i); button.GetComponent <Image>().color = tmp.majorType.background; button.GetChild(0).GetComponent <Text>().text = (tmp.moveName + System.Environment.NewLine + "PP: " + tmp.PP); } NewMoveUI.SetActive(true); }
// REFACTOR_TODO: Is this necessary? // New move button press starts coroutine //public void NewMoveButton(bool isLearn) //{ // StartCoroutine(NewMoveButtonCoroutine(isLearn)); //} // User clicks Learn New Move or Don't Learn public void NewMoveButtonPress(bool isLearn, System.Action OnFinish) { // REFACTOR_TODO: Make references Text cancelText = NewMoveUI.transform.GetChild(5).GetChild(0).GetComponent <Text>(); Text learnText = NewMoveUI.transform.GetChild(4).GetChild(0).GetComponent <Text>(); DeltemonClass delt = State.PlayerState.DeltInBattle; // Presses the cancel button if (!isLearn) { // Player affirms not learning new move if (cancelText.text == "Sure?") { BattleManager.AddToBattleQueue(string.Format("{0} didn't learn the move {1}!", delt.nickname, delt.moveset[4].moveName)); // Remove tmp 5th new move delt.moveset.RemoveAt(4); NewMoveUI.SetActive(false); UIManager.Inst.PosseUI.CloseMoveOverviews(); OnFinish(); } // Cancel button must be pressed again to confirm else { cancelText.text = "Sure?"; learnText.text = "Switch" + System.Environment.NewLine + "Moves"; } } // Presses learn new move button without selecting an old move first else if (!UIManager.Inst.PosseUI.MoveTwoOverview.gameObject.activeInHierarchy) { BattleManager.AddToBattleQueue("You must select a move to switch out first!"); } // User tries to forget a move else { // Player affirms learning new move if (learnText.text == "Sure?") { // Save index of move being forgotten int forgetMoveIndex = UIManager.Inst.secondMoveLoaded; // Set move overviews and new move ui to inactive NewMoveUI.SetActive(false); UIManager.Inst.PosseUI.CloseMoveOverviews(); BattleManager.AddToBattleQueue(string.Format("{0} forgot the move {1}!", delt.nickname, delt.moveset[forgetMoveIndex].moveName)); // Instantiate and learn new move MoveClass newMove = Instantiate(delt.moveset[4], delt.transform); delt.moveset[forgetMoveIndex] = newMove; // Remove 5th move delt.moveset.RemoveAt(4); BattleManager.AddToBattleQueue(string.Format("{0} learned the move {1}!", delt.nickname, newMove.moveName)); OnFinish(); } // Cancel button must be pressed again to confirm else { learnText.text = "Sure?"; cancelText.text = "Don't" + System.Environment.NewLine + "Learn"; } } }