Exemplo n.º 1
0
    protected override void Update()
    {
        if (enemyHealth.getHealth() > 0 && playerHealth.getHealth() > 0 && baseHealth.getHealth() > 0)
        {
            if (body != null && body.velocity.magnitude <= 0.1f && !nav.enabled)
            {
                body.isKinematic = false;
                nav.enabled      = true;
            }

            bool playerFind = Vector3.Distance(gameObject.transform.position, player.position) < Vector3.Distance(gameObject.transform.position, baseObject.position);

            if (playerFind)
            {
                nav.SetDestination(player.position);
            }
            else
            {
                nav.SetDestination(baseObject.position);
            }
        }
        else
        {
            nav.enabled = false;
        }
    }
Exemplo n.º 2
0
 protected virtual void Update()
 {
     if (playerHealth.getHealth() <= 0 && baseHealth.getHealth() <= 0)
     {
         anim.SetTrigger("GameOver");
         restartTimer += Time.deltaTime;
         if (restartTimer >= restartDelay)
         {
             SceneManager.LoadScene(SceneManager.GetActiveScene().name);
         }
     }
 }
Exemplo n.º 3
0
    void Update()
    {
        timer += Time.deltaTime;

        if (timer >= timeBetweenAttacks && enemyHealth.getHealth() > 0 && baseHealth.getHealth() > 0)
        {
            if (attackToPlayer)
            {
                Attack(true);
            }

            if (attackToBase)
            {
                Attack(false);
            }
        }



        if (playerHealth.getHealth() <= 0 || baseHealth.getHealth() <= 0)
        {
            anim.SetTrigger("PlayerDead");
        }
    }