//Tower upgrades if an elemental tower already exists
    public void UpgradeFromElement(int type)
    {
        if (towerSelected != null)
        {
            Vector3 pos        = towerSelected.transform.position;
            NodeV2  parentNode = towerSelected.GetComponentInParent <NodeV2>();

            if (type == 0)
            {
                //
                //Fire Tower Upgrades
                //
                if (towerSelected.GetComponent <TowerController>().GetTowerType() == "tower_fire")
                {
                    if (GameController.Purchase(CostTemplate.GetCost("tower_fire_2")))
                    {
                        parentNode.ReplaceTower();
                        GameObject newTower = Instantiate(towers["tower_fire_2"], pos, Quaternion.identity) as GameObject;
                        parentNode.SetTowerObject(newTower);
                        towerSelected             = newTower;
                        newTower.transform.parent = parentNode.transform;
                        towerSelected.GetComponent <Outline>().enabled = true;
                        nextUpgradeCost.text     = CostTemplate.GetCost("tower_fire_3").ToString();
                        selectedTowerStatus.text = towerSelected.GetComponent <TowerController>().formattedName;
                        SpawnMenu(towerSelected);
                    }
                    else
                    {
                        guiStatusText.text = "Not enough money to upgrade to Fire Tower 2";
                    }
                }
                else if (towerSelected.GetComponent <TowerController>().GetTowerType() == "tower_fire_2")
                {
                    if (GameController.Purchase(CostTemplate.GetCost("tower_fire_3")))
                    {
                        parentNode.ReplaceTower();
                        GameObject newTower = Instantiate(towers["tower_fire_3"], pos, Quaternion.identity) as GameObject;
                        parentNode.SetTowerObject(newTower);
                        towerSelected             = newTower;
                        newTower.transform.parent = parentNode.transform;

                        nextUpgradeCost.text = "";
                        towerSelected.GetComponent <Outline>().enabled = true;
                        selectedTowerStatus.text = towerSelected.GetComponent <TowerController>().formattedName;

                        SpawnMenu(towerSelected);
                    }
                    else
                    {
                        guiStatusText.text = "Not enough money to upgrade to Fire Tower 3";
                    }
                }
                else if (towerSelected.GetComponent <TowerController>().GetTowerType() == "tower_fire_3")
                {
                    guiStatusText.text = "Cannot upgrade Fire Tower any further.";
                }
                //
                //END FIRE UPGRADES
                //

                //
                //ICE TOWER UPGRADE
                //
                else if (towerSelected.GetComponent <TowerController>().GetTowerType() == "tower_ice")
                {
                    if (GameController.Purchase(CostTemplate.GetCost("tower_ice_2")))
                    {
                        parentNode.ReplaceTower();
                        GameObject newTower = Instantiate(towers["tower_ice_2"], pos, Quaternion.identity) as GameObject;
                        parentNode.SetTowerObject(newTower);
                        towerSelected             = newTower;
                        newTower.transform.parent = parentNode.transform;
                        //
                        //Component Testing Xav
                        //
                        towerSelected.GetComponent <Outline>().enabled = true;
                        nextUpgradeCost.text     = CostTemplate.GetCost("tower_ice_3").ToString();
                        selectedTowerStatus.text = towerSelected.GetComponent <TowerController>().formattedName;
                        SpawnMenu(towerSelected);
                        //
                        ///
                        //
                    }
                    else
                    {
                        guiStatusText.text = "Not enough money to upgrade to Ice Tower 2";
                    }
                }
                else if (towerSelected.GetComponent <TowerController>().GetTowerType() == "tower_ice_2")
                {
                    if (GameController.Purchase(CostTemplate.GetCost("tower_ice_3")))
                    {
                        parentNode.ReplaceTower();
                        GameObject newTower = Instantiate(towers["tower_ice_3"], pos, Quaternion.identity) as GameObject;
                        parentNode.SetTowerObject(newTower);
                        towerSelected             = newTower;
                        newTower.transform.parent = parentNode.transform;
                        //
                        //Component Testing Xav
                        //
                        towerSelected.GetComponent <Outline>().enabled = true;
                        nextUpgradeCost.text     = "";
                        selectedTowerStatus.text = towerSelected.GetComponent <TowerController>().formattedName;
                        SpawnMenu(towerSelected);
                        //
                        ///
                        //
                    }
                    else
                    {
                        guiStatusText.text = "Not enough money to upgrade to Ice Tower 3";
                    }
                }
                else if (towerSelected.GetComponent <TowerController>().GetTowerType() == "tower_ice_3")
                {
                    guiStatusText.text = "Cannot upgrade Ice Tower any further.";
                }
                //
                //END ICE UPGRADES
                //

                //
                //NATURE TOWER UPGRADES
                //
                else if (towerSelected.GetComponent <TowerController>().GetTowerType() == "tower_nature")
                {
                    if (GameController.Purchase(CostTemplate.GetCost("tower_nature_2")))
                    {
                        parentNode.ReplaceTower();
                        GameObject newTower = Instantiate(towers["tower_nature_2"], pos, Quaternion.identity) as GameObject;
                        parentNode.SetTowerObject(newTower);
                        towerSelected             = newTower;
                        newTower.transform.parent = parentNode.transform;
                        //
                        //Component Testing Xav
                        //
                        towerSelected.GetComponent <Outline>().enabled = true;
                        nextUpgradeCost.text     = CostTemplate.GetCost("tower_nature_3").ToString();
                        selectedTowerStatus.text = towerSelected.GetComponent <TowerController>().formattedName;
                        SpawnMenu(towerSelected);
                        //
                        ///
                        //
                    }
                    else
                    {
                        guiStatusText.text = "Not enough money to upgrade to Nature Tower 2";
                    }
                }
                else if (towerSelected.GetComponent <TowerController>().GetTowerType() == "tower_nature_2")
                {
                    if (GameController.Purchase(CostTemplate.GetCost("tower_nature_3")))
                    {
                        parentNode.ReplaceTower();
                        GameObject newTower = Instantiate(towers["tower_nature_3"], pos, Quaternion.identity) as GameObject;
                        parentNode.SetTowerObject(newTower);
                        towerSelected             = newTower;
                        newTower.transform.parent = parentNode.transform;
                        //
                        //Component Testing Xav
                        //
                        towerSelected.GetComponent <Outline>().enabled = true;
                        nextUpgradeCost.text     = "";
                        selectedTowerStatus.text = towerSelected.GetComponent <TowerController>().formattedName;
                        SpawnMenu(towerSelected);
                        //
                        ///
                        //
                    }
                    else
                    {
                        guiStatusText.text = "Not enough money to upgrade to Nature Tower 3";
                    }
                }
                else if (towerSelected.GetComponent <TowerController>().GetTowerType() == "tower_nature_3")
                {
                    guiStatusText.text = "Cannot upgrade Nature Tower any further.";
                }
                //
                //END NATURE UPGRADES
                //
            }
            else if (type == 1)
            {
                //downgrade
            }
            else if (type == 2)
            {
                //sell tower
                SellTower(towerSelected, parentNode);

                //
                //Component Testing
                //
                towerSelected = null;
                DeSpawnMenu();
                //
                //End Testing
                //
            }
        }
    }
    public void UpgradeFromBase(int type)
    {
        if (towerSelected != null)
        {
            Vector3 pos        = towerSelected.transform.position;
            NodeV2  parentNode = towerSelected.GetComponentInParent <NodeV2>();

            switch (type)
            {
            //Purchase Fire Towers
            case 0:
                if (GameController.Purchase(CostTemplate.GetCost("tower_fire")))
                {
                    parentNode.ReplaceTower();
                    GameObject newTower = Instantiate(towers["tower_fire"], pos, Quaternion.identity) as GameObject;
                    parentNode.SetTowerObject(newTower);
                    towerSelected             = newTower;
                    newTower.transform.parent = parentNode.transform;

                    SetNextPurchaseCost(towerSelected);


                    DeSpawnMenu();
                    towerSelected.GetComponent <Outline>().enabled = true;
                    selectedTowerStatus.text = towerSelected.GetComponent <TowerController>().formattedName;
                    SpawnMenu(towerSelected);
                }
                else
                {
                    guiStatusText.text = "Not enough money to upgrade to Fire";
                }
                break;

            //ice
            case 1:
                if (GameController.Purchase(CostTemplate.GetCost("tower_ice")))
                {
                    parentNode.ReplaceTower();
                    GameObject newTower = Instantiate(towers["tower_ice"], pos, Quaternion.identity) as GameObject;
                    towerSelected = newTower;
                    parentNode.SetTowerObject(newTower);
                    newTower.transform.parent = parentNode.transform;

                    SetNextPurchaseCost(towerSelected);

                    DeSpawnMenu();
                    towerSelected.GetComponent <Outline>().enabled = true;
                    selectedTowerStatus.text = towerSelected.GetComponent <TowerController>().formattedName;
                    SpawnMenu(towerSelected);
                }
                else
                {
                    guiStatusText.text = "Not enough money to upgrade to Ice";
                }
                break;

            //nature
            case 2:
                if (GameController.Purchase(CostTemplate.GetCost("tower_nature")))
                {
                    parentNode.ReplaceTower();
                    GameObject newTower = Instantiate(towers["tower_nature"], pos, Quaternion.identity) as GameObject;
                    towerSelected = newTower;
                    parentNode.SetTowerObject(newTower);
                    newTower.transform.parent = parentNode.transform;

                    SetNextPurchaseCost(towerSelected);


                    DeSpawnMenu();
                    towerSelected.GetComponent <Outline>().enabled = true;
                    selectedTowerStatus.text = towerSelected.GetComponent <TowerController>().formattedName;
                    SpawnMenu(towerSelected);
                }
                else
                {
                    guiStatusText.text = "Not enough money to upgrade to Nature";
                }
                break;

            case 3:
                SellTower(towerSelected, parentNode);
                DeSpawnMenu();
                break;
            }
        }
    }