示例#1
0
    IEnumerator EnemyTurn()
    {
        //for simplicities sake, the opponent will only use tackle on its turns.
        CombatText.text = enemyPoke.currentName + " uses Tackle!";

        yield return(new WaitForSeconds(1f));


        //SoundManager.PlaySound("Hit_01");
        //play animation of player taking damage, red flash or something or fade in and out of sprite.

        bool isDead = playerPoke.TakeDamage(enemyPoke.attackLevel);

        PlayerBar.SetHP(playerPoke.currentHP);

        yield return(new WaitForSeconds(1f));

        //if you die, lose state and start endbattle
        if (isDead)
        {
            state = TurnState.LOST;
            EndBattle();
        }
        else  //if not dead, start players turn
        {
            state = TurnState.PLAYERTURN;
            PlayerTurn();
        }
    }
示例#2
0
    IEnumerator PlayerAttack()
    {
        bool isDead = enemyPoke.TakeDamage(playerPoke.attackLevel);

        //Damage the enemy

        //need play animation of player taking damage, red flash or something or fade in and out of sprite.
        EnemyBar.SetHP(enemyPoke.currentHP);
        CombatText.text = "The move hits!";

        yield return(new WaitForSeconds(2f));

        //SoundManager.PlaySound("Hit_01");
        //if enemy is at 0 or less than 0, win state, run end battle.
        if (isDead)
        {
            state = TurnState.WON;
            EndBattle();
            //if enemy is alive, start enemies turn
        }
        else
        {
            state = TurnState.ENEMYTURN;
            StartCoroutine(EnemyTurn());
        }
    }