Ejemplo n.º 1
0
    void updateSkill(GameObject skillDisplay, WeaponSkill weaponSkill)
    {
        Text name = skillDisplay.transform.Find("Name").GetComponent <Text>();

        name.text = weaponSkill.getName();

        Text description = skillDisplay.transform.Find("Description").GetComponent <Text>();

        description.text = weaponSkill.getDescription();
        // Current stats
        updateStats(skillDisplay, "Current", weaponSkill.getCurrent());

        Button upgradeButton = skillDisplay.transform.Find("Button").GetComponent <Button>();

        if (weaponSkill.isMaxed())
        {
            skillDisplay.transform.Find("Next").GetComponent <Canvas>().enabled = false;
            skillDisplay.transform.Find("Max").GetComponent <Canvas>().enabled  = true;
            upgradeButton.interactable = false;
            upgradeButton.transform.Find("Text").GetComponent <Text>().text = "Upgrade";
        }
        else
        {
            // make sure everything is displaying even if you change weapons
            skillDisplay.transform.Find("Next").GetComponent <Canvas>().enabled = true;
            skillDisplay.transform.Find("Max").GetComponent <Canvas>().enabled  = false;

            int pointsNeeded = weaponSkill.getLevel() * 100;
            upgradeButton.GetComponent <UpgradeButton>().setPointsNeeded(pointsNeeded);
            upgradeButton.transform.Find("Text").GetComponent <Text>().text = "Upgrade (" + pointsNeeded.ToString() + " pts)";

            upgradeButton.interactable = player.getPoints() >= pointsNeeded ? true : false;
            // update the next skill values
            updateStats(skillDisplay, "Next", weaponSkill.getNext());
        }
    }