void PartySelectorHandler() { if (Input.GetKeyDown(KeyCode.RightArrow)) { ++currentMember; } else if (Input.GetKeyDown(KeyCode.LeftArrow)) { --currentMember; } else if (Input.GetKeyDown(KeyCode.DownArrow)) { currentMember += 2; } else if (Input.GetKeyDown(KeyCode.UpArrow)) { currentMember -= 2; } // limit it to 0-(number of teras in party) index currentMember = Mathf.Clamp(currentMember, 0, playersParty.Party_List.Count - 1); partyScreen.UpdateMemberSelection(currentMember); if (Input.GetKeyDown(KeyCode.E)) { var selectedMember = playersParty.Party_List[currentMember]; if (selectedMember.Health <= 0) { partyScreen.SetMessageText("Can't send out Fainted Teras!"); return; } if (selectedMember == playerUnit.teras) { partyScreen.SetMessageText("Can't send out same Teras!"); return; } partyScreen.gameObject.SetActive(false); if (previousState == BattleState.ActionSelection) { previousState = null; StartCoroutine(RunTurns(BattleAction.SwitchTeras)); } else { state = BattleState.Busy; StartCoroutine(SwitchTeras(selectedMember)); } } else if (Input.GetKeyDown(KeyCode.R)) { partyScreen.gameObject.SetActive(false); PlayerAction(); } }
void HandlePartySelection() { if (Input.GetKeyDown(KeyCode.RightArrow)) { ++currentMember; } else if (Input.GetKeyDown(KeyCode.LeftArrow)) { --currentMember; } else if (Input.GetKeyDown(KeyCode.DownArrow)) { currentMember += 2; } else if (Input.GetKeyDown(KeyCode.UpArrow)) { currentMember -= 2; } currentMember = Mathf.Clamp(currentMember, 0, playerParty.Pokemons.Count - 1); partyScreen.UpdateMemberSelection(currentMember); if (Input.GetKeyDown(KeyCode.Z)) { var selectedMember = playerParty.Pokemons[currentMember]; if (selectedMember.HP <= 0) { partyScreen.SetMessageText("You can't send out a fainted Fantasy Monster"); return; } if (selectedMember == playerUnit.Pokemon) { partyScreen.SetMessageText("You can't switch with the same Fantasy Monster"); return; } partyScreen.gameObject.SetActive(false); if (prevState == BattleState.ActionSelection) { prevState = null; StartCoroutine(RunTurns(BattleAction.SwitchPokemon)); } else { state = BattleState.Busy; StartCoroutine(SwitchPokemon(selectedMember)); } } else if (Input.GetKeyDown(KeyCode.X)) { partyScreen.gameObject.SetActive(false); ActionSelection(); } }
//Permet au joueur de choisir le pokemon qu'il veut avec les flèches dans la selections des pokemon void HandlePartySelection() { if (Input.GetKeyDown(KeyCode.RightArrow)) { ++currentMember; } else if (Input.GetKeyDown(KeyCode.LeftArrow)) { --currentMember; } else if (Input.GetKeyDown(KeyCode.DownArrow)) { currentMember += 2; } else if (Input.GetKeyDown(KeyCode.UpArrow)) { currentMember -= 2; } //Fixe l'index entre 0 et -1 grace à la méthode Clamp disponible dans Mathf currentMember = Mathf.Clamp(currentMember, 0, playerParty.Pokemons.Count - 1); partyScreen.UpdateMemberSelection(currentMember); //Vérifie si le pokemon que le joueur n'est pas mort ou si il n'est pas deja au combat if (Input.GetKeyDown(KeyCode.Space)) { var selectedMember = playerParty.Pokemons[currentMember]; if (selectedMember.HP <= 0) { partyScreen.SetMessageText("You can't send out a fainted pokemon"); return; } if (selectedMember == playerUnit.Pokemon) { partyScreen.SetMessageText("You can't switch with the same pokemon"); return; } //La selection de pokemon est désactivée et la méthode Sxitch est lancée partyScreen.gameObject.SetActive(false); state = BattleState.Busy; StartCoroutine(SwitchPokemon(selectedMember)); } else if (Input.GetKeyDown(KeyCode.R)) { partyScreen.gameObject.SetActive(false); PlayerAction(); } }
void HandlePartySelection() { if (Input.GetKeyDown(KeyCode.RightArrow)) { ++currentMember; } else if (Input.GetKeyDown(KeyCode.LeftArrow)) { --currentMember; } else if (Input.GetKeyDown(KeyCode.DownArrow)) { currentMember += 2; } else if (Input.GetKeyDown(KeyCode.UpArrow)) { currentMember -= 2; } currentMember = Mathf.Clamp(currentMember, 0, servantParty.Servants.Count - 1); partyScreen.UpdateMemberSelection(currentMember); if (Input.GetKeyDown(KeyCode.Z)) { var selectedMember = servantParty.Servants[currentMember]; if (selectedMember.HP <= 0) { partyScreen.SetMessageText("You cannot send out a defeated Servant"); return; } if (selectedMember == playerUnit.servantInfo) { partyScreen.SetMessageText("You cannot switch with the same Servant"); return; } partyScreen.gameObject.SetActive(false); state = BattleState.Busy; StartCoroutine(SwitchServant(selectedMember)); } else if (Input.GetKeyDown(KeyCode.X)) { partyScreen.gameObject.SetActive(false); ActionSelection(); } }
//similar as the above 2 functions, //but now we also are checking to see if the player has selected a valid pokemon void HandlePartySelection() { if (Input.GetKeyDown(KeyCode.RightArrow)) { ++currentMember; } else if (Input.GetKeyDown(KeyCode.LeftArrow)) { --currentMember; } else if (Input.GetKeyDown(KeyCode.DownArrow)) { currentMember += 2; } else if (Input.GetKeyDown(KeyCode.UpArrow)) { currentMember -= 2; } currentMember = Mathf.Clamp(currentMember, 0, playerParty.Pokemons.Count - 1); //clamps current action between 0 and 3 (4 moves) partyScreen.UpdateMemberSelection(currentMember); if (Input.GetKeyDown(KeyCode.Z)) { var selectedMember = playerParty.Pokemons[currentMember]; if (selectedMember.Hp <= 0) { partyScreen.SetMessageText("This pokemon has already fainted!"); return; } if (selectedMember == playerUnit.pokemon) { partyScreen.SetMessageText("This pokemon is already out!"); return; } partyScreen.gameObject.SetActive(false); state = BattleState.Busy; StartCoroutine(SwitchPokemon(selectedMember)); } else if (Input.GetKeyDown(KeyCode.X)) { partyScreen.gameObject.SetActive(false); ActionSelection(); } }
void HandlePartySelection() { if (Input.GetKeyDown(KeyCode.RightArrow)) { ++currentMember; } else if (Input.GetKeyDown(KeyCode.LeftArrow)) { --currentMember; } else if (Input.GetKeyDown(KeyCode.DownArrow)) { currentMember += 2; } else if (Input.GetKeyDown(KeyCode.UpArrow)) { currentMember -= 2; } currentMember = Mathf.Clamp(currentMember, 0, playerParty.Animals.Count - 1); partyScreen.UpdateMemberSelection(currentMember); if (Input.GetKeyDown(KeyCode.Space)) { var selectedMember = playerParty.Animals[currentMember]; if (selectedMember.HP <= 0) { partyScreen.SetMessageText($"{selectedMember.Base.Name} is unable to fight!"); return; } if (selectedMember == playerUnit.Animal) { partyScreen.SetMessageText($"{playerUnit.Animal.Base.Name} is already in the fight!"); return; } partyScreen.gameObject.SetActive(false); if (prevState == BattleState.ActionSelection) { prevState = null; StartCoroutine(RunTurns(BattleAction.SwitchAnimal)); } else { state = BattleState.Busy; StartCoroutine(SwitchAnimal(selectedMember)); } } else if (Input.GetKeyDown(KeyCode.X)) { if (playerUnit.Animal.HP <= 0) { partyScreen.SetMessageText("You must select an animal to continue the duel!"); return; } partyScreen.gameObject.SetActive(false); if (prevState == BattleState.AboutToUse) { prevState = null; StartCoroutine(SendNextOutlawAnimal()); } else { ActionSelection(); } } }
private void HandlePartySelection() { if (Keyboard.current.rightArrowKey.wasPressedThisFrame) { ++_currentMember; } else if (Keyboard.current.leftArrowKey.wasPressedThisFrame) { --_currentMember; } else if (Keyboard.current.downArrowKey.wasPressedThisFrame) { _currentMember += 3; } else if (Keyboard.current.upArrowKey.wasPressedThisFrame) { _currentMember -= 3; } _currentMember = Mathf.Clamp(_currentMember, 0, _playerParty.Monsters.Count - 1); _partyScreen.UpdateMemberSelection(_currentMember); if (Keyboard.current.zKey.wasPressedThisFrame) { MonsterObj selectedMember = _playerParty.Monsters[_currentMember]; if (selectedMember.CurrentHp <= 0) { _partyScreen.SetMessageText("That Battokuri is downed and cannot be used!"); return; } if (selectedMember == _playerMonster.Monster) { _partyScreen.SetMessageText("That Battokuri is already being used!"); return; } _partyScreen.gameObject.SetActive(false); // If player switched monster voluntarily it should count as a turn move // If monster was downed and forced switch then it should trigger a new turn if (_prevState == BattleState.ActionSelection) { _prevState = null; StartCoroutine(ExecuteTurn(BattleAction.SwitchMonster)); } else { _state = BattleState.Busy; StartCoroutine(SwitchMonster(selectedMember)); } } else if (Keyboard.current.xKey.wasPressedThisFrame) { if (_playerMonster.Monster.CurrentHp <= 0) { _partyScreen.SetMessageText("You must select a Battokuri!"); return; } _partyScreen.gameObject.SetActive(false); if (_prevState == BattleState.ChoiceSelection) { _prevState = null; StartCoroutine(SwitchEnemyMonster()); } else { ActionSelection(); } } }
/* * Se encarga de la gestion de la pantalla de seleccionar otro pokemon para salir a la batalla */ void HandlePartyScreenSelection() { if (Input.GetKeyDown(KeyCode.RightArrow)) { currentMember++; } else if (Input.GetKeyDown(KeyCode.LeftArrow)) { currentMember--; } else if (Input.GetKeyDown(KeyCode.DownArrow)) { currentMember += 2; } else if (Input.GetKeyDown(KeyCode.UpArrow)) { currentMember -= 2; } //currentMember = Mathf.Clamp(currentMember, 0, playerParty.Pokemons.Count - 1); currentMember = Mathf.Clamp(currentMember, 0, player1Team.Pokemons.Count - 1); partyScreen.UpdateMemberSelection(currentMember); if (Input.GetKeyDown(KeyCode.Z)) { //Sale a combatir el pokemon seleccionado //var selectedMember = playerParty.Pokemons[currentMember]; var selectedMember = player1Team.Pokemons[currentMember]; if (selectedMember.CurrentHP <= 0) { partyScreen.SetMessageText("You can´t send out a fainted pokemon"); return; } if (selectedMember == playerUnit.Pokemon) { partyScreen.SetMessageText("You can´t switch with the same pokemon"); return; } partyScreen.gameObject.SetActive(false); if (prevState == BattleState.ActionSelection) //En este caso cambia porque quiere, de modo que tras el cambio el enemigo atacara { prevState = null; //StartCoroutine(RunTurns(BattleAction.SwitchPokemon)); player1Slots[currentSlot].battleAction = BattleAction.SwitchPokemon; } else //En este caso significa que ha muerto el anterior { //state = BattleState.Busy;wdas StartCoroutine(SwitchPokemon(selectedMember)); } } else if (Input.GetKeyDown(KeyCode.X)) { //Vuelve hacia atras (solo si tu pokemon esta vivo) if (playerUnit.Pokemon.CurrentHP > 0) { partyScreen.gameObject.SetActive(false); ActionSelection(); } } }
private void HandlePartySelection() { if (!_pressedBtn) { if (Input.GetAxisRaw("Horizontal") > 0) { if (_currentPartyMemberIndex < _playerParty.NuzlonList.Count - 1) { _currentPartyMemberIndex++; _pressedBtn = true; } } else if (Input.GetAxisRaw("Horizontal") < 0) { if (_currentPartyMemberIndex > 0) { _currentPartyMemberIndex--; _pressedBtn = true; } } else if (Input.GetAxisRaw("Vertical") < 0) { if (_currentPartyMemberIndex < _playerParty.NuzlonList.Count - 2) { _currentPartyMemberIndex += 2; _pressedBtn = true; } } else if (Input.GetAxisRaw("Vertical") > 0) { if (_currentPartyMemberIndex > 1) { _currentPartyMemberIndex -= 2; _pressedBtn = true; } } _partyScreen.UpdateMemberSelection(_currentPartyMemberIndex); } if (Input.GetAxisRaw("Vertical") == 0 && Input.GetAxisRaw("Horizontal") == 0) { _pressedBtn = false; } if (Input.GetButtonDown("Jump")) { Nuzlon selectedMember = _playerParty.NuzlonList[_currentPartyMemberIndex]; if (selectedMember.CurrentHP <= 0) { _partyScreen.SetMessageText("You can't send out a fainted Nuzlon"); return; } if (selectedMember == _playerUnit.BattleNuzlon) { _partyScreen.SetMessageText("That Nuzlon is already out"); return; } //_dialogueBox.EnableMoveSelector(false); //_dialogueBox.EnableDialogueText(true); _partyScreen.gameObject.SetActive(false); state = BattleState.Busy; StartCoroutine(SwitchNuzlon(selectedMember)); } else if (Input.GetButtonDown("Fire1")) { if (_playerUnit.BattleNuzlon.CurrentHP <= 0) { return; } _partyScreen.gameObject.SetActive(false); ActionSelection(); } }
void HandlePartySelection() { if (Input.GetKeyDown(KeyCode.RightArrow)) { ++currentMember; } else if (Input.GetKeyDown(KeyCode.LeftArrow)) { --currentMember; } else if (Input.GetKeyDown(KeyCode.DownArrow)) { currentMember += 3; } else if (Input.GetKeyDown(KeyCode.UpArrow)) { currentMember -= 3; } currentMember = Mathf.Clamp(currentMember, 0, playerParty.Pokemons.Count - 1); partyScreen.UpdateMemberSelection(currentMember); if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.Space)) { var selectedMember = playerParty.Pokemons[currentMember]; //Creating a var of the actual pokemon we are on if (selectedMember.HP <= 0) //Making sure the actual pokemon selected ain't fainted { partyScreen.SetMessageText("Vous ne pouvez pas envoyer un pokemon K.O!"); return; } if (selectedMember == playerUnit.Pokemon) //Making sure the actual selected pokemon is not the same as the one in the battle { partyScreen.SetMessageText("Ce pokemon est déjà au combat."); return; } partyScreen.gameObject.SetActive(false); //Changing the actual view on the screen if (prevState == BattleState.ActionSelection) //the player decided to change { prevState = null; //Reste the prev state before doing anything else StartCoroutine(RunTurns(BattleActions.SwitchPokemon)); //Call the coroutine to switch } else //Here the pokemon fainted, so the player won't lost a turn { state = BattleState.Busy; //State is changed to busy so player won't mess with the UI StartCoroutine(SwitchPokemon(selectedMember)); //Calling coroutine to switch pokemons } } else if (Input.GetKeyDown(KeyCode.X) || Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Backspace)) { if (playerUnit.Pokemon.HP <= 0) //Player has to change if the actual pokemon is dead { partyScreen.SetMessageText("Vous devez choisir un pokemon pour continuer."); return; } partyScreen.gameObject.SetActive(false); //Disable party screen if (prevState == BattleState.AboutToUse) { prevState = null; //Change prev state StartCoroutine(SendNextTrainerPokemon()); //Continue battle } else { ActionSelection(); } } }