Esempio n. 1
0
    void Update()
    {
        Attack();

        if (Vector3.Distance(starship.position, this.transform.position) > 350)
        {
            EnemiesManager.decreaseEnemyCounter();
            DestroyEnemy();
        }

        if (health <= 0 && !isExploded)
        {
            EnemiesManager.decreaseEnemyCounter();
            isExploded = true;
            GetComponent <Collider>().enabled      = false;
            GetComponent <MeshRenderer>().enabled  = false;
            GetComponent <TrailRenderer>().enabled = false;
            gameObject.layer  = LayerMask.NameToLayer("Default");
            healthBar.enabled = false;
            GetComponent <Outline>().enabled = false;
            StartCoroutine(Explode());
        }

        healthBar.value = Mathf.Lerp(healthBar.value, health, Time.deltaTime * 6);
    }