Exemplo n.º 1
0
        public void SetPropertyValue(ENTITY_PROPERTY index)
        {
            if (CurrentPlayer == null)
            {
                return;
            }

            EntityView ev     = EntityFactory.getEntityViewByID(CurrentPlayer.nEntityID);
            float      fValue = ev.Property.GetNumProp(index);

            if (!Mathf.Approximately(m_dicPropertyValue[index], fValue))
            {
                m_dicPropertyValue[index] = fValue;

                if (index == ENTITY_PROPERTY.PROPERTY_CRC ||
                    index == ENTITY_PROPERTY.PROPERTY_PCT_COOL_REDUCE ||
                    index == ENTITY_PROPERTY.PROPERTY_PCT_AF)
                {
                    fValue /= 100;
                }

                int nHeroID = ev.Property.GetNumProp(ENTITY_PROPERTY.PROPERTY_VOCATION);

                int nPropIndex = m_dicPropertyIndex[index];

                SSchemePropertyPanel propConfig = PropertyPanelConfig.Instance.GetPropertyPanelConfigList(nHeroID, fValue, nPropIndex);
                if (propConfig == null)
                {
                    Debug.LogError(String.Format("propConfig == null,{0},{1}, {2}", nHeroID, fValue, nPropIndex));
                    return;
                }

                string strValue = "";
                if (index == ENTITY_PROPERTY.PROPERTY_PCT_AF)
                {
                    strValue = String.Format("{0}{1}", (int)fValue, "%");
                }
                else if (index == ENTITY_PROPERTY.PROPERTY_CRC || index == ENTITY_PROPERTY.PROPERTY_PCT_COOL_REDUCE)
                {
                    strValue = fValue.ToString("0") + "%";
                }
                else
                {
                    strValue = fValue.ToString();
                }

                string strNewText = String.Format("<color='#{0}'>{1}</color>", propConfig.strColor, strValue);

                BottomView.SetPropertyValue(nPropIndex - 1, strNewText);
            }
        }
Exemplo n.º 2
0
        //数值属性回调函数
        public void ResponseEntityNumPropEvent(EntityNumPropEventArgs e)
        {
            if (e.objev == null || m_wndView == null || !e.objev.IsHero || !bMobaState)
            {
                return;
            }

            entity_view_update_Numproperty data = e.data;
            int nUpdateValue = data.nValue;

            switch (data.nPropID)
            {
            case (int)ENTITY_PROPERTY.PROPERTY_VOCATION:
            {
                SetHeroVocationProtrait(nUpdateValue);
            }
            break;

            case (int)ENTITY_PROPERTY.PROPERTY_EXP:
            {
                SetHeroExp(nUpdateValue, data.nOtherData);
            }
            break;

            case (int)ENTITY_PROPERTY.PROPERTY_LEVEL:
            {
                SetHeroLevel(nUpdateValue);
            }
            break;

            case (int)ENTITY_PROPERTY.PROPERTY_STAMINA:
            {
                m_currentStamina = nUpdateValue;
                SetHeroStamina();
            }
            break;

            case (int)ENTITY_PROPERTY.PROPERTY_MAX_STAMINA:
            {
                m_maxStamina = nUpdateValue;
                SetHeroStamina();
            }
            break;

            case (int)ENTITY_PROPERTY.PROPERTY_MP:
            case (int)ENTITY_PROPERTY.PROPERTY_ENERGY:
            {
                m_currentMp = nUpdateValue;
                SetHeroMP();
            }
            break;

            case (int)ENTITY_PROPERTY.PROPERTY_MAX_MP:
            case (int)ENTITY_PROPERTY.PROPERTY_MAX_ENERGY:
            {
                m_maxMp = nUpdateValue;
                SetHeroMP();
            }
            break;

            case (int)ENTITY_PROPERTY.PROPERTY_TALENT_POINT:    //金钱
            {
                SetGoodsStoreMoney(nUpdateValue);
            }
            break;

            case (int)ENTITY_PROPERTY.PROPERTY_HP:
            {
                m_currentHp = nUpdateValue;
                SetHeroHP();
            }
            break;

            case (int)ENTITY_PROPERTY.PROPERTY_MAX_HP:
            {
                m_maxHp = nUpdateValue;
                SetHeroHP();
            }
            break;

            case (int)ENTITY_PROPERTY.PROPERTY_SHIELD:
            {
                SetHeroHP();
            }
            break;

            case (int)ENTITY_PROPERTY.PROPERTY_PA:
            case (int)ENTITY_PROPERTY.PROPERTY_MA:
            case (int)ENTITY_PROPERTY.PROPERTY_PD:
            case (int)ENTITY_PROPERTY.PROPERTY_MD:
            case (int)ENTITY_PROPERTY.PROPERTY_SD:
            case (int)ENTITY_PROPERTY.PROPERTY_PCT_AF:
            case (int)ENTITY_PROPERTY.PROPERTY_CRC:
            case (int)ENTITY_PROPERTY.PROPERTY_PCT_COOL_REDUCE:
            {
                ENTITY_PROPERTY index  = (ENTITY_PROPERTY)e.data.nPropID;
                float           fValue = e.data.nValue;
                if (!Mathf.Approximately(m_dicPropertyValue[index], fValue))
                {
                    m_dicPropertyValue[index] = fValue;

                    if (e.data.nPropID == (int)ENTITY_PROPERTY.PROPERTY_CRC ||
                        e.data.nPropID == (int)ENTITY_PROPERTY.PROPERTY_PCT_COOL_REDUCE ||
                        e.data.nPropID == (int)ENTITY_PROPERTY.PROPERTY_PCT_AF)
                    {
                        fValue /= 100;
                    }

                    // 取得配置区间值
                    if (EntityFactory.MainHeroView == null)
                    {
                        break;
                    }

                    int nHeroID = EntityFactory.MainHeroView.Property.GetNumProp(ENTITY_PROPERTY.PROPERTY_VOCATION);

                    int nPropIndex = m_dicPropertyIndex[(ENTITY_PROPERTY)data.nPropID];

                    SSchemePropertyPanel propConfig = PropertyPanelConfig.Instance.GetPropertyPanelConfigList(nHeroID, fValue, nPropIndex);
                    if (propConfig == null)
                    {
                        Debug.LogError(String.Format("propConfig == null,{0},{1}, {2}", nHeroID, fValue, nPropIndex));
                        break;
                    }

                    string strValue = "";
                    if (index == ENTITY_PROPERTY.PROPERTY_PCT_AF)
                    {
                        strValue = String.Format("{0}{1}", (int)fValue, "%");
                    }
                    else if (index == ENTITY_PROPERTY.PROPERTY_CRC || index == ENTITY_PROPERTY.PROPERTY_PCT_COOL_REDUCE)
                    {
                        strValue = fValue.ToString("0") + "%";
                    }
                    else
                    {
                        strValue = fValue.ToString();
                    }

                    string strNewText = String.Format("<color='#{0}'>{1}</color>", propConfig.strColor, strValue);

                    m_wndView.SetPropertyValue(nPropIndex - 1, strNewText);
                }
            }
            break;

            default:
                break;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 属性等级解析
        /// </summary>
        /// <param name="reg"></param>
        /// <param name="strText"></param>
        /// <returns></returns>
        public string PropertyLevel_Callback(RegexInfo reg, string strText)
        {
            // 取得属性值
            string          strPropPattern = @"\[(PA|PD|PASD|CRC|MA|MD|COOL|SD|PAF)\s*=\s*(\d*)([+*\-/]?)(\d*)\]";
            Regex           re             = new Regex(strPropPattern);
            MatchCollection matchs         = re.Matches(strText);

            if (matchs.Count == 0)
            {
                return(strText);
            }

            float  fPropValue = 0;
            string strKey     = "";

            do
            {
                Match node = matchs[0];
                if (node.Groups.Count == 0)
                {
                    break;
                }
                strKey = node.Groups[1].ToString();// 正则键值
                if (!m_nodeList.ContainsKey(strKey))
                {
                    break;
                }
                float fPropVal = getPropertyValue(strKey);

                string strOldValue = node.Groups[2].ToString();// 这个值为20或20*5之类的形式
                float  fOldValue   = 1.0f;
                float.TryParse(strOldValue, out fOldValue);
                fPropValue = fPropVal * fOldValue / 100.0f;
            } while (false);
            if (String.IsNullOrEmpty(strKey))
            {
                return(strText);
            }

            // 取得配置区间值
            if (EntityFactory.MainHeroView == null)
            {
                return(strText);
            }

            int nHeroID = EntityFactory.MainHeroView.Property.GetNumProp(ENTITY_PROPERTY.PROPERTY_VOCATION);

            int nIndex = m_dicPropertyLevel[strKey];

            SSchemePropertyPanel propConfig = PropertyPanelConfig.Instance.GetPropertyPanelConfigList(nHeroID, fPropValue, nIndex);

            if (propConfig == null)
            {
                //Debug.LogError(String.Format("propConfig == null,{0},{1}, {2}", nHeroID, fValue, nPropIndex));
                return(strText);
            }

            if (nIndex <= 0)
            {
                return(strText);
            }

            // 取得匹配值
            MatchCollection matchLevel = reg.r.Matches(strText);

            if (matchLevel.Count == 0)
            {
                return(strText);
            }

            string strNewText = String.Format("<color='#{0}'>({1})</color>", propConfig.strColor, propConfig.strDesc);

            Match  levelNode   = matchLevel[0];
            string strOldText  = levelNode.Groups[0].ToString();
            int    nStartPos   = levelNode.Index;
            int    nTextLength = levelNode.Length;

            StringBuilder builder = new StringBuilder(strText);

            // 替换
            builder.Replace(strOldText, strNewText, nStartPos, nTextLength);

            return(builder.ToString());
        }