private IEnumerator ExecuteCommand(BattleCommand command) { //Actually execute the command executingCommand = true; //Determine which set of display objects to use BattlePokemonDisplay userDisplay = playerDisplay; ScrollingTextbox userTextbox = playerTextbox; BattlePokemonDisplay targetDisplay = enemyDisplay; if (command.userPokemon == enemyPokemon) { userTextbox = enemyTextbox; userDisplay = enemyDisplay; targetDisplay = playerDisplay; } //Display the command text userTextbox.text = command.text; //Execute the move if (command.commandType == BattleCommandType.useMove) { IndividualPokemon user = command.userPokemon; IndividualPokemon target = command.targetPokemon; IndividualPokemonMove move = user.GetMove(command.moveToUse); //Start the command's animation float waitTime = userDisplay.GenericMoveAnimation(move.entry.genericAnimationID); yield return(new WaitForSecondsOrSkip(waitTime)); //Use the move user.GetMove(command.moveToUse).Use(user, target); //Start flashing targetDisplay.TakeDamage(); } executingCommand = false; yield return(null); }
public static BattleCommand CreateUseCommand(IndividualPokemon user, IndividualPokemon target, int moveToUse) { //Constructs a use move command. BattleCommand command = new BattleCommand(); command.commandType = BattleCommandType.useMove; command.moveToUse = moveToUse; command.userPokemon = user; command.targetPokemon = target; MovedexEntry moveEntry = user.GetMove(moveToUse).entry; command.text = user.displayName + " used " + moveEntry.moveName + "!"; return(command); }