Exemple #1
0
        public void SetIndex(int index)
        {
            if (index > m_btnParent.childCount - 1 || index < 0)
            {
                return;
            }

            Transform trans = UIItem.GetChild(m_btnParent, index.ToString());

            if (null == trans || trans == m_focus)
            {
                return;
            }

            m_index = index;
            if (m_focus != null)
            {
                m_focus.gameObject.SetActiveNew(true);
                m_focus.SetParent(trans);
                m_focus.localPosition = Vector3.zero;
                m_focus.localScale    = Vector3.one;
                m_focus.SetSiblingIndex(1);
            }
            if (m_aniable)
            {
                SetTabAnima(index);
            }
        }
Exemple #2
0
        /// <summary>
        /// 显示刻度
        /// </summary>
        public void SetPlateValue(Transform head, float blood)
        {
            Transform item = head.FindChild("plate");

            if (null == item)
            {
                item = ((GameObject)GameObject.Instantiate(m_plateGo.gameObject)).GetComponent <RectTransform>();
                item.gameObject.SetActiveNew(true);
                item.SetParent(head);
                item.name          = "plate";
                item.localPosition = m_platePos;
                item.localRotation = Quaternion.identity;
                item.localScale    = Vector3.one;
            }
            int count = (int)blood / 200;

            count = count > 8 ? 8 : count;
            float maxLength = item.GetComponent <RectTransform>().sizeDelta.x;

            blood = blood > 1500 ? 1500 : blood;

            if (blood > 0)
            {
                for (int i = 0; i < count + 1; i++)
                {
                    Transform cItem = UIItem.GetChild(item, i.ToString());
                    cItem.gameObject.SetActiveNew(true);
                    float x = (200 * i * maxLength) / blood - maxLength * 0.5f;
                    cItem.localPosition = new Vector2(x, 0);
                }
            }
        }
Exemple #3
0
        public static void SetSliderValue(Transform parent, string name, float slider_value)
        {
            Image slider = UIItem.GetChild(parent, name).GetComponent <Image>();

            if (slider != null)
            {
                slider.fillAmount = slider_value;
            }
        }
Exemple #4
0
        public void Init()
        {
            if (m_init)
            {
                return;
            }
            m_init = true;

            if (m_btnParent == null)
            {
                m_btnParent = transform;
            }
            if (m_focus == null)
            {
                m_focus = transform.FindChild("focus").GetComponent <RectTransform>();
            }

            if (m_aniable)
            {
                for (int i = 0; i < m_btnParent.childCount - 2; i++)
                {
                    UIEventListener listener = UIEventListener.Get(m_btnParent.FindChild(i.ToString()).gameObject);
                    listener.onClick   = OnClickBtn;
                    listener.parameter = i;
                    //UIButton.Get(listener.gameObject);
                }
            }
            else
            {
                for (int i = 0; i < m_btnParent.childCount - 1; i++)
                {
                    UIEventListener listener = UIEventListener.Get(m_btnParent.FindChild(i.ToString()).gameObject);
                    listener.onClick   = OnClickBtn;
                    listener.parameter = i;
                    //UIButton.Get(listener.gameObject);
                }
            }


            if (m_btnParent.childCount - 1 > 0 && m_changeTextColor)
            {
                //UIButton.Get(m_btnParent.FindChild("0").gameObject).SetTextColor(m_focusTextColor);
            }


            if (m_aniable)
            {
                pos       = transform.FindChild("light/pos");
                m_tabList = new GameObject[m_btnParent.transform.childCount - 2];
                for (int i = 0; i < m_tabList.Length; i++)
                {
                    m_tabList[i] = UIItem.GetChild(m_btnParent.transform, i.ToString()).gameObject;
                }
            }
        }
Exemple #5
0
        public static void SetItemMask(Transform parent, string txt)
        {
            Transform item = UIItem.GetChild(parent, "fg_mask");

            if (txt == null)
            {
                item.gameObject.SetActiveNew(false);
            }
            else
            {
                item.gameObject.SetActiveNew(true);
                UIItem.SetText(item, "txt", txt);
            }
        }
Exemple #6
0
        /// <summary>
        /// 设置未读
        /// </summary>
        /// <param name="index">0>leng-1</param>
        /// <param name="unread"></param>
        public void SetUnread(int index, bool unread)
        {
            if (index >= m_btnParent.childCount || index < 0)
            {
                return;
            }
            Transform item = m_btnParent.FindChild(index.ToString());

            if (item == null)
            {
                Debug.LogError("item:" + index);
            }
            else
            {
                GameObject obj = item.gameObject;
                UIItem.GetChild(obj.transform, "unread").gameObject.SetActiveNew(unread);
            }
        }
Exemple #7
0
        /// <summary>
        /// 更新BUFF图标列表
        /// </summary>
        public void UpdateBuffList(Transform head, List <UIHeadBuff> list)
        {
            Transform buffItem   = head.FindChild("buff");
            Transform listParent = buffItem.FindChild("list");

            UIItem.ClearList(listParent);
            int index = 0;

            for (int i = 0; i < list.Count; i++)
            {
                int iconId = list[i].icon;
                if (iconId == 0)
                {
                    continue;
                }

                Transform icon = UIItem.GetChild(listParent, index.ToString());
                icon.gameObject.SetActiveNew(true);
                UIItem.SetRawImage(icon, iconId, this);
                index++;
            }
            UIItem.SetItemAlign(UIItem.eItemAlignType.Center, listParent);
        }
Exemple #8
0
        /// <summary>
        /// 设置道具,返回icon对象
        /// </summary>
        public static GameObject SetGoodsItem(Transform item, GoodsItem itemVal)
        {
            if (null == item || null == itemVal)
            {
                return(null);
            }
            UIItem.SetText(item, UIItemTitle.txtName, itemVal.name);

            //物品描述
            if (itemVal.describe != "")
            {
                UIItem.SetText(item, UIItemTitle.txtDescribe, itemVal.describe);
            }
            // 图标
            //GameObject iconObject = UIItem.SetImage(item, UIItemTitle.imgIcon, itemVal.iconId, itemVal.icon, true);
            GameObject iconObject = UIItem.GetChild(item, UIItemTitle.imgIcon).gameObject;

            if (String.IsNullOrEmpty(itemVal.icon))
            {
                iconObject.SetActiveNew(false);
            }
            else
            {
                UnityEngine.Profiling.Profiler.BeginSample("LoadImage");
                UIItem.SetImage(item, UIItemTitle.imgIcon, int.Parse(itemVal.icon));
                if (!iconObject.ActiveSelfNew())
                {
                    iconObject.SetActiveNew(true);
                }
                UnityEngine.Profiling.Profiler.EndSample();
                //UIButton.Get(iconObject);
            }
            // 强化等级
            //if (itemVal.level != "" && IsInt(itemVal.level) && int.Parse(itemVal.level) > 0)
            UIItem.SetText(item, UIItemTitle.txtLevel, itemVal.level);
            GameObject tmpBgLevel = UIItem.GetBtn(item, "bg_level");

            if (tmpBgLevel != null)
            {
                if (itemVal.rate == null)
                {
                    tmpBgLevel.SetActiveNew(false);
                }
                else
                {
                    tmpBgLevel.SetActiveNew(true);
                }
            }
            //else
            //    UIItem.SetText(item, UIItemTitle.txtLevel, "");

            // 数量
            if (itemVal.count != "" && IsInt(itemVal.count) && int.Parse(itemVal.count) >= 0)
            {
                UIItem.SetText(item, UIItemTitle.txtCount, itemVal.count);
            }
            else
            {
                UIItem.SetText(item, UIItemTitle.txtCount, "");
            }

            if (itemVal.price >= 0)
            {
                UIItem.SetText(item, UIItemTitle.txtPrice, itemVal.price.ToString());
            }
            // 品质
            if (itemVal.rank != "")
            {
                UIItem.SetText(item, UIItemTitle.txtRank, itemVal.rank);
            }
            //星级
            if (itemVal.starLevel >= 0)
            {
                UIItem.SetStarLevel(item, UIItemTitle.txtStarLevel, itemVal.starLevel);
            }

            // 宝石孔
            UIItem.SetText(item, "gem_count", itemVal.gemHoleNum + "/6");

            if (itemVal.currency > 0)
            {
            }
            // 还有一个类型,用于特效预留
            return(iconObject);
        }