IEnumerator PowerUp()
    {
        playerUnit.PowerUp(10);
        playerHUD.SetHealth(playerUnit.currentHealth);

        dialogueMessage.text = "YOU HAVE POWERED UP!"; //24.show the attack in the dialogue to show good feedback and communication

        yield return(new WaitForSeconds(2f));

        gameStateTwo = BattleStateTwo.ENEMYSTURN; //26.Enemy turn //22. and then change state based on the results
        StartCoroutine(EnemysTurn());             //27. then we need to start enemy's turn after a few seconds
    }
    IEnumerator PlayerFertlizing()
    {
        bool isDead = enemyUnit.TakeDamageForFertlizer(playerUnit.fertilzerDamage);    //20. damage the enemy by changing the enemyUnit but we not going to affect the health drectly but we goin to create a function where the health is affected and use that instead

        enemyHUD.SetHealth(enemyUnit.currentHealth);                                   //23. o after we have attacked the enemy we need to show that the enemy has taken damage so we change the slider in the HUD
        dialogueMessage.text = "Fertilizer is destroying possible bacteria infection"; //24.show the attack in the dialogue to show good feedback and communication

        yield return(new WaitForSeconds(2f));

        if (isDead)                            //21. we need to check if enemy is dead
        {
            gameStateTwo = BattleStateTwo.WON; //25. the enemy is dead so that means we won
            EndtheBattle();
            SceneManager.LoadScene(2);
        }
        else
        {
            gameStateTwo = BattleStateTwo.ENEMYSTURN; //26.Enemy turn //22. and then change state based on the results
            StartCoroutine(EnemysTurn());             //27. then we need to start enemy's turn after a few seconds
        }
    }
예제 #3
0
    public IEnumerator PlayerAttack()
    {
        //Damage the enemy
        //Use skills
        enemyHUD.SetHealth(enemyCharacter.currentHealth);

        enemyCharacter.TakeDamage(playerCharacter.baseDamage);

        if (enemyCharacter.currentHealth <= 0)
        {
            state = BattleState.WON;
            StartCoroutine(EndBattle());
            //End battle
        }
        else
        {
            state = BattleState.ENEMYTURN;
            StartCoroutine(EnemyTurn());
        }
        yield return(new WaitForSeconds(5f));
    }
예제 #4
0
    void Update()
    {
        if (state == GameState.BATTLE)
        {
            //update HUD
            leftHUD.SetHealth((int)leftChar.charStats.currentHealth);
            leftHUD.SetStamina((int)leftChar.charStats.currentStamina);
            leftHUD.SetAbility((int)leftChar.charStats.currentCooldown);

            rightHUD.SetHealth((int)rightChar.charStats.currentHealth);
            rightHUD.SetStamina((int)rightChar.charStats.currentStamina);
            rightHUD.SetAbility((int)rightChar.charStats.currentCooldown);
        }
    }
    IEnumerator DamagePlayer()
    {
        dialogueMessage.text = enemyUnit.unitTitle + " attacks!";        //30. if it is enemy's turn then player will take damage so add text

        yield return(new WaitForSeconds(1f));                            //31. wait a few seconds before player takes damage

        bool isDead = playerUnit.TakeDamageEnemy(enemyUnit.enemyDamage); //32. we need to check if player has died and if not then its player's turn

        playerHUD.SetHealth(playerUnit.currentHealth);

        yield return(new WaitForSeconds(1f));

        if (isDead) //33. determine player died and change game state
        {
            gameStateTwo = BattleStateTwo.LOST;
            EndtheBattle();
            SceneManager.LoadScene(3);
        }
        else
        {
            gameStateTwo = BattleStateTwo.PLAYERSTURN;
            PlayersTurn();
        }
    }
예제 #6
0
    IEnumerator EnemyTurn()
    {
        enemyHUD.SetHealth(enemyCharacter.currentHealth);

        infoDialogue.text = "Enemy turn";
        yield return(new WaitForSeconds(1f));

        bool isDead = playerCharacter.TakeDamage(enemyCharacter.baseDamage);

        playerHUD.SetHealth(playerCharacter.currentHealth);
        yield return(new WaitForSeconds(1f));

        if (isDead == true)
        {
            Debug.Log("ded");
            state = BattleState.LOST;
            EndBattle();
        }
        else
        {
            state = BattleState.PLAYERTURN;
            PlayerTurn();
        }
    }