Esempio n. 1
0
    void RefreshProperty()
    {
        RoleInstance role  = GameRuntimeData.Instance.Player;
        int          count = m_propertyRoot.childCount;

        for (int i = 0; i < count; i++)
        {
            Transform trans = m_propertyRoot.GetChild(i);
            Text      label = trans.Find("Text").GetComponent <Text>();
            Image     BG    = trans.Find("Bg").GetComponent <Image>();

            if (!GameConst.ProItemDic.ContainsKey(trans.name))
            {
                continue;
            }
            PropertyItem item     = GameConst.ProItemDic[trans.name];
            var          proValue = (int)role.GetType().GetProperty(item.PropertyName).GetValue(role, null);
            string       text     = string.Format("{0}:{1}", item.Name, proValue);
            label.text = text;

            bool  showBg = false;
            Color color  = GetNameColor(ref showBg, item, proValue);
            label.color = color;
            BG.gameObject.SetActive(showBg);
        }
    }
Esempio n. 2
0
    void ShowProperty()
    {
        StringBuilder sb = new StringBuilder();

        for (int i = 0; i < m_showPropertyIds.Count; i++)
        {
            string proId = m_showPropertyIds[i].ToString();
            if (!GameConst.ProItemDic.ContainsKey(proId))
            {
                continue;
            }
            var proItem = GameConst.ProItemDic[proId];
            if (proItem.PropertyName == "Hp")
            {
                sb.Append($"{proItem.Name}:{m_role.Hp}/{m_role.MaxHp}\n");
            }
            else if (proItem.PropertyName == "Tili")
            {
                sb.Append($"{proItem.Name}:{m_role.Tili}/{Jyx2Consts.MaxTili}\n");
            }
            else if (proItem.PropertyName == "Mp")
            {
                sb.Append($"{proItem.Name}:{m_role.Mp}/{m_role.MaxMp}\n");
            }
            else
            {
                int value = (int)m_role.GetType().GetProperty(proItem.PropertyName).GetValue(m_role, null);
                sb.Append($"{proItem.Name}:{value}\n");
            }
        }
        m_roleInfo.text = sb.ToString();
    }
Esempio n. 3
0
    public void OnNoBtnClick()
    {
        RoleInstance role = GameRuntimeData.Instance.Player;

        for (int i = 1; i <= 12; i++)
        {
            string key = i.ToString();
            if (!GameConst.ProItemDic.ContainsKey(key))
            {
                continue;
            }
            PropertyItem item  = GameConst.ProItemDic[key];
            int          value = Tools.GetRandomInt(item.DefaulMin, item.DefaulMax);
            role.GetType().GetProperty(item.PropertyName).SetValue(role, value);
        }
        RefreshProperty();
    }