Exemplo n.º 1
0
 void addFX(string name)
 {
     controller.Play(name);
     //Debug.Log("Played effect");
 }
Exemplo n.º 2
0
    private IEnumerator wait()
    {
        float totalTime = 2f;
        float timer     = .5f;

        if (attack > 0)
        {
            playerScript.anim.SetTrigger("Attack");
            while (timer >= 0)
            {
                timer -= Time.deltaTime;
                yield return(null);
            }
            enemyScript.takeDamage(attack);
            enemyHealthText.GetComponent <UnityEngine.UI.Text>().text = enemyScript.health.ToString() + "/" + enemyScript.maxHealth.ToString();
            enemyHPSlider.GetComponent <Slider>().value = (float)enemyScript.health / (float)enemyScript.maxHealth;
            //Debug.Log("Enemy HP Fraction: " + (enemyScript.health / enemyScript.maxHealth));
        }

        if (attack > 0)
        {
            if (enemyScript.health <= 0)
            {
                enemyScript.anim.SetTrigger("Dead");
            }
            else
            {
                enemyScript.anim.SetTrigger("Hurt");
            }
            timer = totalTime;
            while (timer >= 0)
            {
                timer -= Time.deltaTime;
                yield return(null);
            }
        }

        if (enemyScript.health <= 0)
        {
            winCanvas.SetActive(true);
            sfx.Play("Win");
        }

        if (enemyScript.health > 0)
        {
            enemyScript.anim.SetTrigger("Attack");
            timer = .5f;
            while (timer >= 0)
            {
                timer -= Time.deltaTime;
                yield return(null);
            }
        }


        if (enemyScript.health > 0)
        {
            enemyScript.anim.SetTrigger("Attack");
            playerScript.takeDamage(enemyAttack);
            healthText.GetComponent <UnityEngine.UI.Text>().text = playerScript.health.ToString() + "/" + playerScript.maxHealth.ToString();
            playerHPSlider.GetComponent <Slider>().value         = (float)playerScript.health / (float)playerScript.maxHealth;
            if (playerScript.health <= 0)
            {
                playerScript.anim.SetTrigger("Dead");
            }
            else
            {
                playerScript.anim.SetTrigger("Hurt");
            }
            timer = totalTime;

            while (timer >= 0)
            {
                timer -= Time.deltaTime;
                yield return(null);
            }
        }

        if (playerScript.health <= 0)
        {
            loseCanvas.SetActive(true);
            sfx.Play("Lose");
        }



        gameScript.Reset();
        canvas.SetActive(true);
        attack = 0;
        block  = 0;
        attack_text.GetComponent <UnityEngine.UI.Text>().text = attack.ToString();
        block_text.GetComponent <UnityEngine.UI.Text>().text  = block.ToString();
        enemyAttack = enemyScript.enemyAttack();
        enemyAttackText.GetComponent <UnityEngine.UI.Text>().text = enemyAttack.ToString();
    }