Beispiel #1
0
    void parseChildren(Skill[] children, Skill parent, GameObject parentObject)
    {
        foreach (Skill skill in children)
        {
            if (parent != null)
            {
                skill.parent = parent;
            }
            GameObject inst    = Instantiate(skillTreeSlotPrefab);
            SkillId    skillId = inst.GetComponent <SkillId>();
            skillId.setSkillTree(this);
            skillsObjects.Add(skillId);
            createSkillObject(inst, skill);


            if (parentObject != null)
            {
                inst.transform.SetParent(parentObject.transform);
                onSkillUpgrade(inst, skillId, parentObject, skill);
            }


            int   x1        = 0;
            int   y1        = 1;
            float scale     = 1;
            float positionY = 20f;

            if (skill.enhancementSkill)
            {
                y1 = 0;
                x1 = 1;
                inst.transform.localScale = new Vector3(inst.transform.localScale.x / 1.5f, inst.transform.localScale.y / 1.5f, 1);
                scale     = 2f;
                positionY = 15;
            }
            if (parentObject != null)
            {
                inst.transform.position = new Vector3(parentObject.transform.position.x + (((otherSpellWidthOffset) + parentObject.GetComponent <RectTransform>().sizeDelta.x) * x1) * xType, parentObject.transform.position.y + ((otherSpellHeightOffset * yType) * y1), zRoot);
                createText(inst, skill.enhancementSkill);
            }

            if (hasSkillChildren(skill))
            {
                parseChildren(skill.children, skill, inst);
            }
        }
    }
Beispiel #2
0
    public void initilize(Player player)
    {
        playerNetwork = player.getNetwork();
        this.player   = player;

        GameObject UI                 = GameObject.Find("UI");
        GameObject skillTreeUI        = Tools.findInactiveChild(UI, "SkillTree_UI");
        GameObject panel              = Tools.findInactiveChild(skillTreeUI, "Panel");
        GameObject skillTreeContainer = Tools.findInactiveChild(UI, "SkillTreeContainer");

        this.spritesheet             = Resources.LoadAll <Sprite>("Sprites/SkillIcons/spritesheet");
        this.spritesheet_transparent = Resources.LoadAll <Sprite>("Sprites/SkillIcons/spritesheet_transparent");

        transform.SetParent(skillTreeUI.transform);
        this.UISkillStats = Tools.findInactiveChild(this.transform.parent.gameObject, "Panel").transform.Find("Stats_BG").gameObject;

        this.UISkillStatsWrapper = Tools.findInactiveChild(UISkillStats, "Wrapper");
        this.UISkillStatsPoints  = Tools.findInactiveChild(UISkillStats, "Points").GetComponent <Text>();
        this.UISkillStatsName    = Tools.findInactiveChild(UISkillStats, "Name").GetComponent <Text>();

        UISkillStatsRectTransform = this.UISkillStats.GetComponent <RectTransform>();

        //transform.SetParent(UI.transform.Find("SkillTree_UI").Find("Panel").Find("SkillTreeContainer"));
        Debug.Log("INTIILIZEDIDDDDDDD!!!!");
        UI.GetComponent <UIReferences>().skillTreeReference = this.gameObject;

        Skill skills = JsonManager.readJson <Skill>(e_Paths.JSON_SKILLTREE);

        Debug.Log("e_paths.jsonskilltree: " + JsonManager.getPath(e_Paths.JSON_SKILLTREE));
        Debug.Log("skills: " + skills);

        potrait = Instantiate(skillTreeSlotPrefab);
        Debug.Log("Is  this running? " + potrait);
        potrait.GetComponent <SkillId>().setSkillTree(this);
        potrait.transform.SetParent(this.transform);
        potrait.transform.position    = new Vector3(xRoot, yRoot, zRoot);
        potrait.transform.localScale += new Vector3(1, 1, 0);
        potrait.GetComponent <RectTransform>().sizeDelta = new Vector3(30, 35, 0);
        potrait.GetComponent <Image>().sprite            = spritesheet[0];
        onSkillUpgrade(potrait, potrait.GetComponent <SkillId>(), this.gameObject, null);

        foreach (Skill skill in skills.Potrait)
        {
            chooseType(currentIndex);
            currentIndex++;
            //Create parents
            GameObject inst    = Instantiate(skillTreeSlotPrefab);
            SkillId    skillId = inst.GetComponent <SkillId>();
            skillId.setSkillTree(this);
            skillsObjects.Add(skillId);
            inst.transform.SetParent(potrait.transform);
            createSkillObject(inst, skill);

            masterSpellWidthOffset  = 35 * potrait.transform.localScale.x;
            masterSpellHeightOffset = 35 * potrait.transform.localScale.y;

            inst.transform.position = new Vector3(xRoot + (masterSpellWidthOffset * xType), yRoot + (masterSpellHeightOffset * yType), zRoot);
            createText(inst, false);

            onSkillUpgrade(inst, skillId, potrait, skill);

            if (hasSkillChildren(skill))
            {
                parseChildren(skill.children, skill, inst);
            }
        }
    }