// Update is called once per frame
    void Update()
    {
        currentDelay -= Time.deltaTime;
        if (health <= 0)
        {
            PlayMusic.BaseMusic();
            Destroy(this.gameObject);
            player.GetComponent <PlayerController>().AlterCash(50);
        }
        if (health > maxHealth / 2)
        {
            float r = 1 - (float)(health / maxHealth);
            indicator.GetComponent <Renderer>().material.color = new Color(r, 1f, 0f, 1f);
        }
        else
        {
            float g = (health / maxHealth * 2);
            indicator.GetComponent <Renderer>().material.color = new Color(1f, g, 0f, 1f);
        }


        if (isActive)
        {
            speed = 10f;
            if (!moving && !attacking && !spawning)
            {
                GameObject randomPoint = GetRandomPoint();
                StartCoroutine(Wander(randomPoint));
            }
            if (isInvincible)
            {
                invincibleTimer -= Time.deltaTime;
                if (invincibleTimer <= 0)
                {
                    ResetInvincible();
                }
            }
        }
        else
        {
            speed = 5f;
            if (!moving)
            {
                GameObject randomPoint = GetRandomIdlePoint();
                StartCoroutine(Wander(randomPoint));
            }
        }
    }