Ejemplo n.º 1
0
    public void upgrade()
    {
        Upgradable upgrader = selectedObject.GetComponent <Upgradable>();

        if (upgrader.isUpgradable() && money >= upgrader.getUpgradeCost())
        {
            money -= upgrader.getUpgradeCost();
            upgrader.Upgrade();
        }
    }
Ejemplo n.º 2
0
    void Update()
    {
        if (selectedObject)
        {
            selectedItemPanel.SetActive(true);
            Upgradable upgradeComponent = selectedObject.GetComponent <Upgradable> ();
            Item       itemComponent    = selectedObject.GetComponent <Item> ();
            if (upgradeComponent)
            {
                if (upgradeComponent.isUpgradable())
                {
                    upgradeCost.text = upgradeComponent.getUpgradeCost().ToString();
                    upgradeButton.gameObject.SetActive(true);
                }
                else
                {
                    upgradeCost.text = "N/A";
                    upgradeButton.gameObject.SetActive(false);
                }
                sellAmount.text = upgradeComponent.getSellValue().ToString();
                if (itemComponent)
                {
                    selectedItemText.text    = itemComponent.itemName + " (Level " + upgradeComponent.level + ")";
                    selectedItemImage.sprite = itemComponent.getImage();
                }
            }
        }
        else
        {
            selectedItemPanel.SetActive(false);
        }

        moneyAmount.text = money.ToString();
    }
Ejemplo n.º 3
0
    void Update()
    {
        /*if (Input.GetMouseButtonDown (0)) {
         *      Ray ray = gameCamera.GetComponent<Camera> ().ScreenPointToRay (Input.mousePosition);
         *      RaycastHit hit;
         *      if ( Physics.Raycast (ray,out hit,100.0f)){
         *              //suppose i have two objects here named obj1 and obj2.. how do i select obj1 to be transformed
         *              GameObject hitObject = hit.collider.gameObject;
         *              if(hitObject != null && hitObject.GetComponent<OutlineComponent>() != null) {
         *                      if(selectedObject == hitObject)
         *                      {
         *                              setSelectedItem (null);
         *                      }
         *                      else {
         *                              setSelectedItem (hitObject);
         *                      }
         *              }
         *      }
         * }*/
        if (selectedObject)
        {
            selectedItemPanel.SetActive(true);
            Upgradable upgradeComponent = selectedObject.GetComponent <Upgradable> ();
            Item       itemComponent    = selectedObject.GetComponent <Item> ();
            if (upgradeComponent)
            {
                if (upgradeComponent.isUpgradable())
                {
                    upgradeCost.text = upgradeComponent.getUpgradeCost().ToString();
                    upgradeButton.gameObject.SetActive(true);
                }
                else
                {
                    upgradeCost.text = "N/A";
                    upgradeButton.gameObject.SetActive(false);
                }
                sellAmount.text = upgradeComponent.getSellValue().ToString();
                if (itemComponent)
                {
                    selectedItemText.text    = itemComponent.itemName + " (Level " + upgradeComponent.level + ")";
                    selectedItemImage.sprite = itemComponent.getImage();
                }
            }
        }
        else
        {
            selectedItemPanel.SetActive(false);
        }

        moneyAmount.text = money.ToString();
    }