Esempio n. 1
0
    public void Attack(int skillnum)
    {
        skillnum = skillnum - 1;         // for indexing
        WeaponSkill skill = skills[skillnum];

        Collider[] colliders = Physics.OverlapSphere(transform.position, skill.getCurrent().getRange() * 5);
        foreach (Collider c in colliders)
        {
            Debug.Log(c.gameObject.name);
            if (c.gameObject.tag == "Enemy")
            {
                Vector3 enemypos = c.transform.position - transform.position;
                if (Vector3.Dot(transform.forward, enemypos) > 0)
                {
                    //c.gameObject.SetActive(false);
                    Enemy e = c.GetComponent <Enemy>();
                    Debug.Log("power is " + skill.getCurrent().getPower());
                    e.isAttacked(skill.getCurrent().getPower());
                }
            }
        }
    }
Esempio n. 2
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());
        }
    }