Exemplo n.º 1
0
    IEnumerator ExcecutePlayerMove()
    {
        state = BattleState.Busy;
        var move = playerU.pkmn.Moves[currentMove];

        move.PP--;  // reducir el PP del movimiento y actualizar en HUD
        yield return(dialogB.TD($"{playerU.pkmn.pBase.GetPName} used {move.Base.GetMoveName()}"));

        yield return(new WaitForSeconds(1f));

        bool isDefeated = enemyU.pkmn.DealDamage(move, playerU.pkmn);

        yield return(enemyH.AffectHP());

        if (isDefeated)
        {
            yield return(dialogB.TD($"{enemyU.pkmn.pBase.GetPName} was defeated"));

            // aquí llamaríamos a la animación
            yield return(new WaitForSeconds(2f));

            OnDefeat(true);
        }
        else
        {
            StartCoroutine(ExcecuteEnemyMove());
        }
    }
Exemplo n.º 2
0
    IEnumerator ExcecuteEnemyMove()
    {
        state = BattleState.EnemyMove;
        var move = enemyU.pkmn.ChooseMove();

        move.PP--;

        yield return(dialogB.TD($"{enemyU.pkmn.pBase.GetPName} used {move.Base.GetMoveName()}"));

        yield return(new WaitForSeconds(1f));

        bool isDefeated = playerU.pkmn.DealDamage(move, enemyU.pkmn);

        yield return(playerH.AffectHP());

        if (isDefeated)
        {
            yield return(dialogB.TD($"{playerU.pkmn.pBase.GetPName} was defeated"));

            // aquí sería llamar a alguna animación

            yield return(new WaitForSeconds(2f));

            var NextAlivePokemon = playerTeam.GetAlivePokemon();
            // Llamamos a la funcion GetAlivePokemon para saber si quedan Pokemones vivos en el Team
            if (NextAlivePokemon != null)
            {
                // El jugador puede escoger el siguiente pokemon a sacar
                ViewTeamScreen();
            }
            else
            {
                yield return(dialogB.TD("You have met your fate. Game Over."));

                yield return(new WaitForSeconds(3.0f));

                OnDefeat(false);     // si no quedan pokemon vivos, el jugador pierde la pelea
            }
        }
        else
        {
            PlayerAction();     // es turno del player de atacar
        }
    }