public void DisplayEndScreen(string endMessage, string xp, List <string> foundItems) { /*Create end screen UI object for player and parent it to the canvas*/ //Instantiate ability UI box GameObject endScreen = (GameObject)GameObject.Instantiate(uiEndCombatScreen); //Get reference to the script of the actin menu this.endScreenScript = endScreen.GetComponent <CombatEndScreenScript>(); //Print out for test if (TestScript._instance.TestMode) { Debug.Log("~~~~ Create Action End Screen Called ~~~~"); } //Parent action menu to the canvas endScreen.transform.SetParent(_uiContainer.transform, false); endScreenScript.SetElements(endMessage, xp, foundItems); }
/// <summary> /// Handles the input. /// </summary> /// <param name="keyPressed">Key pressed.</param> public void HandleInput(KeyCode keyPressed) { // if (TestScript._instance.TestMode) // { // Debug.LogWarning("~~~~2. Combat UI Handling Input ~~~~"); // } Debug.Log(CombatMgr._instance.currentTurnChar.stats.CharName + "=>HANDLING INPUT and menu level is" + CombatUIManager._instance.MenuLevel.ToString()); if (CombatUIManager._instance.MenuLevel == GameConstants.CombatMenuPage.Action) { switch (keyPressed) { case (KeyCode.LeftArrow): //Reduce Index by 2 if under the right conditions. If index is over count if (actMenuScript.CurrIndex >= (actMenuScript.ActionMenuItems.Count - actMenuScript.ActionMenuItems.Count / 2)) { actMenuScript.SetSelectedAction(false, -1 * (actMenuScript.ActionMenuItems.Count / 2)); } break; case (KeyCode.RightArrow): if (actMenuScript.CurrIndex <= (actMenuScript.ActionMenuItems.Count / 2)) { actMenuScript.SetSelectedAction(false, 2); } break; case (KeyCode.UpArrow): actMenuScript.SetSelectedAction(false, -1); break; case (KeyCode.DownArrow): actMenuScript.SetSelectedAction(false, 1); break; case (KeyCode.Space): //Selection key, so set ui active state and start action menu actMenuScript.ActionMenuItems[actMenuScript.CurrIndex].Action(CombatMgr._instance.currentTurnChar); break; case (KeyCode.Escape): break; default: break; } } else if (CombatUIManager._instance.MenuLevel == GameConstants.CombatMenuPage.Attack) { switch (keyPressed) { case (KeyCode.LeftArrow): break; case (KeyCode.RightArrow): break; case (KeyCode.UpArrow): //Update the selected target UpdateSelectionAttackTarget(-1); break; case (KeyCode.DownArrow): //Update the selected target UpdateSelectionAttackTarget(1); break; case (KeyCode.Space): //Execute attack CombatMgr._instance.PerformAttack(CombatMgr._instance.currentTurnChar.GetBasicAttack(), currTargets); break; case (KeyCode.Escape): /*Exit this menu level and go back to action select*/ //Revert UI states CombatUIManager._instance.actMenuScript.SetSelectedState(GameConstants.ActionOptionIndices.Attack, false); //Remove selection arrows and hp text foreach (CharMgrScript c in currTargets) { c.HighlightArrowStatus(false); } //reset target lists possibleTargets.Clear(); currTargets.Clear(); //Set the flag for menu state CombatUIManager._instance.MenuLevel = GameConstants.CombatMenuPage.Action; break; default: break; } } else if (CombatUIManager._instance.MenuLevel == GameConstants.CombatMenuPage.Ability) { switch (keyPressed) { case (KeyCode.LeftArrow): break; case (KeyCode.RightArrow): break; case (KeyCode.UpArrow): break; case (KeyCode.DownArrow): break; case (KeyCode.Space): break; case (KeyCode.Escape): break; default: break; } } else if (CombatUIManager._instance.MenuLevel == GameConstants.CombatMenuPage.Flee) { switch (keyPressed) { case (KeyCode.LeftArrow): break; case (KeyCode.RightArrow): break; case (KeyCode.UpArrow): break; case (KeyCode.DownArrow): break; case (KeyCode.Space): break; case (KeyCode.Escape): break; default: break; } } else if (CombatUIManager._instance.MenuLevel == GameConstants.CombatMenuPage.Item) { switch (keyPressed) { case (KeyCode.LeftArrow): break; case (KeyCode.RightArrow): break; case (KeyCode.UpArrow): break; case (KeyCode.DownArrow): break; case (KeyCode.Space): break; case (KeyCode.Escape): break; default: break; } } else if (CombatUIManager._instance.MenuLevel == GameConstants.CombatMenuPage.AnimationAction) { switch (keyPressed) { case (KeyCode.LeftArrow): break; case (KeyCode.RightArrow): break; case (KeyCode.UpArrow): break; case (KeyCode.DownArrow): break; case (KeyCode.Space): break; case (KeyCode.Escape): break; default: break; } } else if (CombatUIManager._instance.MenuLevel == GameConstants.CombatMenuPage.EndScreen) { switch (keyPressed) { case (KeyCode.LeftArrow): break; case (KeyCode.RightArrow): break; case (KeyCode.UpArrow): break; case (KeyCode.DownArrow): break; case (KeyCode.Space): //TODO:Clean up combat UI. This can be handled here: Call methods needed to hide or destroy objects. //Clean up action menu object and remove from screen Destroy(this.actMenuScript.gameObject); actMenuScript = null; //Clean up end of combat UI Destroy(this.endScreenScript.gameObject); endScreenScript = null; //Reset state flags as needed this.MenuLevel = GameConstants.CombatMenuPage.Unopened; //Leave combat scene and load overworld scene CombatMgr._instance.LeaveCombatScene(); break; case (KeyCode.Escape): break; default: break; } } }