Esempio n. 1
0
        // Use this for initialization
        public void SetPowerSet(PowerSet ps)
        {
            powerSet = ps;
            ScrollRect sr  = GetComponent <ScrollRect>();
            Transform  par = sr ? sr.content : transform;

            // clean up old list of children
            for (int i = 0; i < par.childCount; i++)
            {
                Destroy(par.GetChild(i).gameObject);
            }

            int y = 0;

            foreach (Power p in powerSet.powers)
            {
                GameObject   go = ObjectFactory.GetObject(prefab);
                UIPowerEntry pe = go.GetComponent <UIPowerEntry>();
                pe.power                   = p;
                go.transform.parent        = par;
                go.transform.localPosition = new Vector3(100, -16 + y, 0);
                y -= 33;
                UIPowerIcon icon = go.GetComponentInChildren <UIPowerIcon>();
                if (icon)
                {
                    icon.SetPower(p);
                }
            }
            if (sr)
            {
                sr.content.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 100);
                sr.content.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 33 * powerSet.powers.Length);
            }
        }
Esempio n. 2
0
 public void ApplyPowerSet(PowerSet powerSet)
 {
     for (int i = 0; i < powerSet.powers.Length && i < items.Length; i++)
     {
         character.powers[i] = powerSet.powers[i];
         items[i].Init(character, null, character.powers[i], i);
         items[i].GetComponentInChildren <UIPowerIcon>().SetPower(character.powers[i]);
     }
     character.UpdatePassives();
 }
Esempio n. 3
0
        public void SetPowerSet(PowerSet ps)
        {
            powerSet = ps;
            Image image = GetComponent <Image>();

            if (image)
            {
                image.sprite = powerSet.icon;
                image.color  = powerSet.tint.GetColor();
            }
        }
Esempio n. 4
0
        void Start()
        {
            // create a button for each set
            PowerSetButton button    = GetComponentInChildren <PowerSetButton>();
            GameObject     buttonObj = button.gameObject;

            for (int i = 0; i < powerSets.Length; i++)
            {
                GameObject go = (i == 0) ? buttonObj : Instantiate(buttonObj, buttonObj.transform.position + Vector3.right * 48 * i, Quaternion.identity, transform);
                button = go.GetComponent <PowerSetButton>();
                button.SetPowerSet(powerSets[i]);
                button.parent = this;
            }

            currentPowerSet = powerSets[0];
        }