//controls party selector void HandlePartySelection() { Action onSelected = () => { var selectedUnit = partyscreen.SelectedUnit; if (selectedUnit.HP <= 0) { partyscreen.SetMessageText("he is no loger with us"); return; } if (selectedUnit == playerUnit.Piece) { partyscreen.SetMessageText("he already in the fight"); return; } partyscreen.gameObject.SetActive(false); if (partyscreen.CalledFrom == BattleState.ActionSelection) { // if switch during turn StartCoroutine(RunTurns(BattleAction.SwitchPiece)); } else { //if piece is dead state = BattleState.Busy; bool isEnemyAboutToUse = partyscreen.CalledFrom == BattleState.AboutToUse; StartCoroutine(SwitchUnit(selectedUnit, isEnemyAboutToUse)); } partyscreen.CalledFrom = null; }; Action onBack = () => { if (playerUnit.Piece.HP <= 0) { partyscreen.SetMessageText("piece must be in play"); return; } partyscreen.gameObject.SetActive(false); if (partyscreen.CalledFrom == BattleState.AboutToUse) { StartCoroutine(SendNextEnemyPiece()); } else { ActionSelection(); } partyscreen.CalledFrom = null; }; partyscreen.HandleUpdate(onSelected, onBack); }
public void HandleUpdate(Action onBack, Action onItemUsed = null) { this.onItemUsed = onItemUsed; if (state == InventoryUIState.ItemSelection) { int prevSelection = selectedItem; if (Input.GetKeyDown(KeyCode.DownArrow)) { ++selectedItem; } else if (Input.GetKeyDown(KeyCode.UpArrow)) { --selectedItem; } selectedItem = Mathf.Clamp(selectedItem, 0, inventory.Slots.Count - 1); if (prevSelection != selectedItem) { UpdateItemSelection(); } if (Input.GetKeyDown(KeyCode.Z)) { OpenPartyScreen(); } else if (Input.GetKeyDown(KeyCode.X)) { onBack?.Invoke(); } } else if (state == InventoryUIState.PartySelection) { Action onSelected = () => { StartCoroutine(UseItem()); }; Action onBackPartyScreen = () => { ClosePartyScreen(); }; partyScreen.HandleUpdate(onSelected, onBackPartyScreen); } }
private void Update() { //checking overall game state if (state == GameState.FreeRoam) { playerController.HandleUpdate(); if (Input.GetKeyDown(KeyCode.Escape)) { menuController.OpenMenu(); state = GameState.Menu; } // save/load if (Input.GetKeyDown(KeyCode.F1)) { SavingSystem.i.Save("saveSlot1"); } if (Input.GetKeyDown(KeyCode.F2)) { SavingSystem.i.Load("saveSlot1"); } } else if (state == GameState.Battle) { battleSystem.HandleUpdate(); } else if (state == GameState.Dialog) { DialogManager.Instance.HandleUpdate(); } else if (state == GameState.Menu) { menuController.HandleUpdates(); } else if (state == GameState.PartyScreen) { Action onSelected = () => { //go to stat screen }; Action onBack = () => { partyScreen.gameObject.SetActive(false); state = GameState.FreeRoam; }; partyScreen.HandleUpdate(onSelected, onBack); } else if (state == GameState.Bag) { Action onBack = () => { inventoryUI.gameObject.SetActive(false); state = GameState.FreeRoam; }; inventoryUI.HandleUpdate(onBack); } }