// Update is called once per frame
    void Update()
    {
        #region Scale Sprite

        switch (currentLevel)
        {
        case 1:
            transform.localScale = startScale * ((2250f - (float)growthTimer) / 1800f);

            if (transform.localScale.x > .5f)
            {
                transform.localScale = new Vector3(.5f, .5f, .5f);
            }
            break;

        case 2:
            transform.localScale = startScale * ((5400f - (float)growthTimer) / 3600f);

            if (transform.localScale.x > .75f)
            {
                transform.localScale = new Vector3(.75f, .75f, .75f);
            }
            break;

        case 3:
            transform.localScale = startScale;
            break;
        }

        #endregion

        if (!GameManager.Instance.pauseGame && (GameManager.Instance.gameStarted || Tutorial_Manager.Instance.tutorialStartred))
        {
            currentTarget  = FindClosestEnemy();
            testEnemyExist = GameObject.FindGameObjectWithTag("Enemy");
            shootTimer--;

            if ((currentLevel < GameManager.maxPlantLevel) && (thisTile.GetComponent <Farm_Controller>().waterLevel > 0) && (GameManager.Instance.currentPhase == GameManager.Phase.DAY))
            {
                if (isFertilized)
                {
                    growthTimer -= (1 * (currentLevel)) * 2;
                }
                else
                {
                    growthTimer -= 1 * (currentLevel);
                }
            }

            #region Flash Transparency

            if (currentLevel == 3)
            {
                currentAlpha       = 255f;
                spriteRender.color = new Color(spriteRender.color.r, spriteRender.color.g, spriteRender.color.b, currentAlpha / 255f);
            }
            else if (((currentAlpha >= 255) || (thisTile.GetComponent <Farm_Controller>().waterLevel <= 0)) && (GameManager.Instance.currentPhase == GameManager.Phase.NIGHT))
            {
                currentAlpha       = 125f;
                spriteRender.color = new Color(spriteRender.color.r, spriteRender.color.g, spriteRender.color.b, currentAlpha / 255f);
            }
            else
            {
                if (currentAlpha < 255)
                {
                    currentAlpha++;
                }

                spriteRender.color = new Color(spriteRender.color.r, spriteRender.color.g, spriteRender.color.b, currentAlpha / 255f);
            }

            #endregion

            #region LevelUp Plant

            if (growthTimer <= 0)
            {
                if (currentLevel == 1)
                {
                    currentLevel++;
                    range++;
                    growthTimer = 1800;
                }
                else
                {
                    currentLevel++;
                    range++;
                    growthTimer = 3600;

                    //TODO: add some sort of animation or particle effect to show that this plant is now fully grown
                }
            }

            if (Tutorial_Manager.Instance.tutorialStartred && Tutorial_Manager.Instance.InstructionsIndex == 10 && thisPlant == GameManager.ShopItems.FIRE)
            {
                currentLevel = 3;
                range        = 3;
            }

            #endregion

            if (shootTimer == 0)
            {
                canShoot = true;
            }

            #region Shoot

            if (canShoot && (testEnemyExist != null) && (currentTarget != null))
            {
                if (thisTile.GetComponent <Farm_Controller>().waterLevel > 0)
                {
                    if (Vector2.Distance(currentTarget.transform.position, this.gameObject.transform.position) <= range)
                    {
                        audioManager.PlayPlantShoot();
                        createdBullet = Instantiate(bullet, new Vector3(transform.position.x, transform.position.y, 0f), transform.rotation);
                        createdBullet.GetComponent <Bullet>().move   = true;
                        createdBullet.GetComponent <Bullet>().target = currentTarget;
                        createdBullet.GetComponent <Bullet>().damage = createdBullet.GetComponent <Bullet>().damage *(currentLevel + 1);
                        createdBullet.GetComponent <Bullet>().type   = thisPlant;
                        canShoot   = false;
                        shootTimer = 60 - ((currentLevel - 1) * 20);

                        if (currentLevel < 3)
                        {
                            if (GameManager.Instance.purchasedWaterEfficiency)
                            {
                                thisTile.GetComponent <Farm_Controller>().waterLevel -= .5f;
                            }
                            else
                            {
                                thisTile.GetComponent <Farm_Controller>().waterLevel -= 1;
                            }
                        }

                        if (thisPlant == GameManager.ShopItems.VOID)
                        {
                            shootTimer = shootTimer / 2;
                        }

                        switch (thisPlant)
                        {
                        case GameManager.ShopItems.BASIC:
                            createdBullet.GetComponent <Bullet>().thisSprite = basicBullet;
                            break;

                        case GameManager.ShopItems.FIRE:
                            createdBullet.GetComponent <Bullet>().thisSprite = fireBullet;
                            break;

                        case GameManager.ShopItems.ICE:
                            createdBullet.GetComponent <Bullet>().thisSprite = iceBullet;
                            break;

                        case GameManager.ShopItems.VOID:
                            createdBullet.GetComponent <Bullet>().thisSprite = voidBullet;
                            break;

                        default:
                            createdBullet.GetComponent <Bullet>().thisSprite = basicBullet;
                            break;
                        }
                    }
                }
            }

            #endregion
        }
    }