Пример #1
0
    IEnumerator returnFromAttack()
    {
        //Wait
        yield return(new WaitForSeconds(1));

        //Return player to old position
        GetComponent <Transform>().position = oldpos;

        //Let them attack you
        BattleFlowManager.ToggleBattefieldReady();

        //Destroy text clone
        Destroy(clone);
    }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        if (BattleFlowManager.currentTurn == order && BattleFlowManager.battleFieldsReady)
        {
            //Constrains enemy attacks
            BattleFlowManager.BlockBattlefield();

            //Set animator to attack
            //GetComponent<Animator>().SetTrigger("attack");

            //Set oldpos to get back after the attack
            oldpos = GetComponent<Transform>().position;

            //Set the target position
            Vector3 targetPosition = new Vector3(-18f, oldpos.y, oldpos.z);

            //In case of distance attack, instantiate arrow

            //Change position to put the player in front of enemy
            GetComponent<Transform>().position = targetPosition;

            //Change the turn
            BattleFlowManager.UpdateCurrentTurn();

            //Execute Damage
            BattleFlowManager.DoDamage("enemyAttacks", combat_enemy_attack);
            clone = (GameObject)Instantiate(damageText, new Vector3(-18f, oldpos.y+1, oldpos.z), Quaternion.Euler(Vector3.zero));
            var _canvas = GameObject.FindGameObjectWithTag("Canvas").GetComponent<Canvas>();
            clone.transform.SetParent(_canvas.transform);

            StartCoroutine(returnFromAttack());
        }
        if(combat_enemy_hp <= 0)
        {
            isDeath = true;
            Destroy(gameObject);

        }

    }