Exemplo n.º 1
0
        public void UpdateIcons(Prop p, Status newStatus)
        {
            if (icon == null)
            {
                return;
            }

            timers.Clear();

            // delete old gameobjects and clear the list
            foreach (KeyValuePair <string, GameObject> pair in icons)
            {
                ObjectFactory.Recycle(pair.Value);
            }
            icons.Clear();

            Vector3 offsetX = Vector3.zero;

            if (character != null)
            {
                Vector3 iconLocalPosition = icon.GetComponent <RectTransform>().localPosition;
                foreach (KeyValuePair <string, Status> pair in character.groupedEffects)
                {
                    Status s = pair.Value;
                    if (s.icon != null)
                    {
                        GameObject ike = ObjectFactory.GetObject(icon);
                        ike.SetActive(true);
                        ike.transform.SetParent(transform);
                        RectTransform rect = ike.GetComponent <RectTransform>();
                        rect.localPosition = iconLocalPosition + offsetX;
                        rect.localScale    = Vector3.one;
                        offsetX           += iconOffset; //todo
                        icons[s.name]      = ike;
                        ike.name           = s.name;

                        // copy the colour and image from global settings
                        ike.GetComponent <Image>().color  = s.tint.GetColor();
                        ike.GetComponent <Image>().sprite = s.icon;

                        Transform counter = ike.transform.Find("Counter");
                        if (counter)
                        {
                            counter.gameObject.SetActive(s.count > 1);
                            Text text = counter.GetComponent <Text>();
                            text.text = "" + s.count;
                        }

                        ToolTipIcon toolTip = ike.GetComponent <ToolTipIcon>();
                        if (toolTip)
                        {
                            Text text = toolTip.toolTip.GetComponentInChildren <Text>();
                            if (text)
                            {
                                text.text = s.GetDescription();
                            }
                        }
                        if (s.duration < 100000)
                        {
                            Transform timer = ike.transform.Find("Timer");
                            if (timer)
                            {
                                timers[s]         = timer.GetComponent <Text>();
                                timers[s].enabled = true;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
 public override string GetDescription(bool brief = false)
 {
     return(status.GetDescription(brief));
 }