IEnumerator PlayerHeal()
    {
        playerUnit.specialAbilityOne(enemyUnit);
        playerHUD.setHP(playerUnit.currentHP);
        dialouge.text = playerUnit.unitName + " is recovering!";
        yield return(new WaitForSeconds(2f));

        state = battleStates.ENEMYTURN;
        StartCoroutine(EnemyTurn());
    }
    IEnumerator PlayerHeal()
    {
        playerUnit.Heal(5);

        playerHUD.setHP(playerUnit.currentHP);

        yield return(new WaitForSeconds(1f));

        currentState = GameState.ENEMY;
        StartCoroutine(EnemyTurn());
    }
    //Player Coroutines

    IEnumerator PlayerAttack()
    {
        playerUnit.basicAbility(enemyUnit);
        bool isAlive = enemyUnit.isAlive();

        enemyHUD.setHP(enemyUnit.currentHP);

        if (enemyUnit.blocking)
        {
            dialouge.text = enemyUnit.unitName + " has blocked the attack!";
            enemyUnit.endBlock();
        }
        else
        {
            dialouge.text = playerUnit.unitName + " has attacked!";
        }
        yield return(new WaitForSeconds(2f));

        if (!isAlive)
        {
            state = battleStates.WIN;
            EndBattle();
        }
        else
        {
            state = battleStates.ENEMYTURN;
            StartCoroutine(EnemyTurn());
        }
    }
Beispiel #4
0
    //玩家攻击方法
    IEnumerator PlayerAttack()
    {
        //攻击敌人
        bool isDead = enemyUnit.TakeDamage(playerUnit.damage);

        //更新敌人状态栏
        enemyHUD.setHP(enemyUnit.currentHP);


        dialogueText.text = playerUnit.unitName + "使用撞击!";

        yield return(new WaitForSeconds(2f));

        if (isDead)
        {
            //战斗结束
            state = BattleState.WIN;

            EndBattle();
        }
        else

        {
            //敌方回合
            state = BattleState.ENEMYTURN;
            StartCoroutine(EnemyTurn());
        }
    }
Beispiel #5
0
    //敌方回合
    IEnumerator EnemyTurn()
    {
        dialogueText.text = "敌方回合";

        yield return(new WaitForSeconds(1f));

        bool isDead = playerUnit.TakeDamage(enemyUnit.damage);

        dialogueText.text = enemyUnit.unitName + "使用撞击!";
        yield return(new WaitForSeconds(1f));

        playerHUD.setHP(playerUnit.currentHP);
        playerCurrent.text = playerUnit.currentHP.ToString();

        yield return(new WaitForSeconds(1f));

        if (isDead)
        {
            state = BattleState.LOST;
            EndBattle();
        }
        else
        {
            state = BattleState.PAYERTURN;
            PlayerTurn();
        }
    }
Beispiel #6
0
    IEnumerator PlayerAttack(bool special)
    {
        playerUnit.isDefending = false;
        var mydamage = playerUnit.damage;

        if (special)
        {
            mydamage *= 2;
            playerUnit.useMana(playerUnit.special_mana_cost);
            playerHUD.setMana(playerUnit.currentMana);
        }


        if (enemyUnit.isDefending)
        {
            Debug.Log("Enemy is defending");
            mydamage = mydamage / 60;
            enemyUnit.isDefending = false;
        }

        Debug.Log("Damage given: " + mydamage);

        bool isDead = enemyUnit.takeDamage(mydamage);

        enemyHUD.setHP(enemyUnit.currentHP);
        dialogueText.text = player_special_attack + " attack!";

        Handheld.Vibrate();

        var music = PlayerPrefs.GetString("Music", "Default value");

        if (music == "yes")
        {
            player_attack.Play();
        }

        attackbar.SetActive(false);
        actionbar.SetActive(true);

        yield return(new WaitForSeconds(2f));

        if (isDead)
        {
            state = BattleState.WON;
            StartCoroutine(EndBattle());
        }
        else
        {
            state = BattleState.ENEMYTURN;
            StartCoroutine(EnemyTurn());
        }


        yield return(new WaitForSeconds(2f));
    }
    //PLAYER OPTION FOR HEAL
    IEnumerator PlayerHeal()
    {
        playerUnit.Heal(20);
        Instantiate(playerHealEffect, new Vector3(-6.5f, -1.75f, 0), Quaternion.identity);
        playerHUD.setHP(playerUnit.currentHP);

        /*
         * if(enemySecondUnit.currentHP >= 0f)
         * {
         *  enemySecondUnit.Heal(5);
         *  Instantiate(enemyHealEffect, new Vector3(3f, -2.5f, 0), Quaternion.identity);
         *  enemySecondHUD.setHP(enemySecondUnit.currentHP);
         * }
         * else
         * {
         *  enemySecondUnit.Heal(0);
         * }
         */

        yield return(new WaitForSeconds(1f));

        currentState = GameState.ENEMY;
        StartCoroutine(EnemyTurn());
    }
Beispiel #8
0
    IEnumerator PlayerAttack()
    {
        bool isDead = enemyPrefab.GetComponent <Unit>().TakeDamage(playerPrefab.GetComponent <Unit>().damage);

        enemyHUD.setHP(enemyPrefab.GetComponent <Unit>().currentHP);

        yield return(new WaitForSeconds(.5f));

        if (isDead == true)
        {
            state = BattleState.WON;
            EndBattle();
        }
        else
        {
            endTurn = true;
        }
    }
Beispiel #9
0
    void _enemyTurn()
    {
        enemyHasPlayed        = true;
        setedEnemyTurn        = true;
        battleStatusText.text = "Enemy Turn";
        Debug.Log("Enemy turno");

        bool isDead = playerPrefab.GetComponent <Unit>().TakeDamage(enemyPrefab.GetComponent <Unit>().damage);

        playerHud.setHP(playerPrefab.GetComponent <Unit>().currentHP);
        if (isDead)
        {
            state = BattleState.LOST;
            EndBattle();
        }
        else
        {
            endTurn = true;
        }
    }
Beispiel #10
0
    IEnumerator EnemyTurn()
    {
        _dialogueText.text = _enemyUnit.unitName + " attaque !";
        _enemyGo.GetComponent <Animator>().Play("Hit");
        yield return(new WaitForSeconds(1f));

        bool isDead = _playerUnit.TakeDamage(_enemyUnit.damage);

        _playerHUD.setHP(_playerUnit.currentHp);
        yield return(new WaitForSeconds(2f));

        if (isDead)
        {
            _state = BattleState.LOSE;
            endBattle();
        }
        else
        {
            _state = BattleState.PLAYERTURN;
            PlayerTurn();
        }
    }
Beispiel #11
0
    IEnumerator PlayerAttack(string type, int dmg)
    {
        bool isDead = _enemyUnit.TakeDamage(dmg);

        _playerGo.GetComponent <Animator>().Play("Hit");
        yield return(new WaitForSeconds(1f));

        _enemyHUD.setHP(_enemyUnit.currentHp);
        _dialogueText.text = "Touché !";
        yield return(new WaitForSeconds(2f));

        if (type == "sword")
        {
            _dialogueText.text = "Ton épée s'est brisée contre le corps du lion";

            yield return(new WaitForSeconds(2f));
        }
        if (type == "mace")
        {
            _dialogueText.text = "Le bruit dérange " + _enemyUnit.unitName;
            yield return(new WaitForSeconds(2f));

            _dialogueText.text = "La massue s'est brisée";
            yield return(new WaitForSeconds(2f));
        }
        if (isDead)
        {
            _state = BattleState.WIN;
            endBattle();
        }
        else
        {
            _state = BattleState.ENEMYTURN;
            StartCoroutine(EnemyTurn());
        }
    }
Beispiel #12
0
    IEnumerator EnemyTurn()
    {
        enemyUnit.isDefending = false;
        int  random   = UnityEngine.Random.Range(0, 3);
        bool isDead   = false;
        var  mydamage = enemyUnit.damage;

        Debug.Log("Random is: " + random);

        if (random == 1 || random == 0)
        {
            if (random == 1)
            {
                if (enemyUnit.currentMana > enemyUnit.special_mana_cost)
                {
                    mydamage *= 2;
                    enemyUnit.useMana(enemyUnit.special_mana_cost);
                    enemyHUD.setMana(enemyUnit.currentMana);
                }
            }
            var music = PlayerPrefs.GetString("Music", "Default value");
            if (music == "yes")
            {
                enemy_attack.Play();
            }

            dialogueText.text = enemyUnit.unitName + " uses " + enemy_special_attack + "!";
            Handheld.Vibrate();

            if (playerUnit.isDefending)
            {
                playerUnit.isDefending = false;
                mydamage = mydamage / 60;
            }



            isDead = playerUnit.takeDamage(mydamage);
            playerHUD.setHP(playerUnit.currentHP);
        }

        if (random == 2)
        {
            enemyUnit.isDefending  = true;
            enemyUnit.currentMana += 30;
            if (enemyUnit.currentMana > 100)
            {
                enemyUnit.currentMana = 100;
            }
            enemyHUD.setMana(enemyUnit.currentMana);
            dialogueText.text = enemyUnit.unitName + " defense mode!";
        }



        yield return(new WaitForSeconds(1f));


        if (isDead)
        {
            state = BattleState.LOST;
            Debug.Log("Player is dead");
            StartCoroutine(EndBattle());
        }
        else
        {
            state = BattleState.PLAYERTURN;
            playerTurn();
        }
    }