public void upgrade(boolean button)
    {
        if (level < 3)
        {
            power = power + Math.round(power * .2f);
            range = range + Math.round(range * .2f);

            if (attackRate >  0){
                attackRate-=3;
                if (attackRate <= 0){
                    attackRate = 1; 
                }
            }

            if (level == 2)
            {
                changeWeapon("pierce");
                //power = (int)Math.round(power*0.1f);
                attackRate = 40;
            }
            else if (level == 1)
            {
                changeWeapon("artillery");
                attackRate= 80;
            }

            cost = upgradeCost[level];
            currentCost += upgradeCost[level-1];
            level++;
            this.setImage (fileName + (level) + ".png");
            counter = attackRate;
            if (!button){
                map.displayMessage("Tower Upgraded", 2); 
            }
        }

        if (!button){
            map.resetUi(); //refreshes the ui after upgrade
        }
    }