예제 #1
0
    void Update()
    {
        if (!isAlive)
        {
            return;
        }

        time             = maxTime - (Time.time - startTime);
        towerBars.time   = time;
        towerBars.health = health;

        if (time < maxTime / 2.0f)
        {
            bool show = (int)((Time.time - startTime) * blinkSpeed) % 2 == 0;
            icon.enabled = show;

            if (!hasPlayedSFX)
            {
                hasPlayedSFX = true;
                unitSelection.sfxManager.PlaySound(unitSelection.sfxManager.halfwaySFX);
            }
        }
        else
        {
            icon.enabled = true;
        }

        if (time <= 0)
        {
            unitSelection.GameOver();
            isAlive = false;
        }

        AquireTarget();

        if (currentTarget)
        {
            laser.enabled       = true;
            laser.positionCount = 2;
            laser.SetPositions(new Vector3[] { laserStart.position, currentTarget.transform.position });
            currentTarget.Attack(attackPower * Time.deltaTime);
        }
        else
        {
            laser.enabled = false;
        }

        if (health <= 0)
        {
            isAlive      = false;
            icon.enabled = true;
            OnDeath();
            Destroy(towerBars.gameObject);
            Destroy(this.gameObject);
        }
    }