예제 #1
0
    /// <summary>
    /// 获取强化数据
    /// </summary>
    /// <param name="pos">位置</param>
    /// <param name="starLv">星级</param>
    /// <returns></returns>
    public StrongerCfg GetStrongerCfgData(int stongerType, int starLv)
    {
        StrongerCfg data = null;
        Dictionary <int, StrongerCfg> tmpDic = null;

        if (dictStrongerCfgData.TryGetValue(stongerType, out tmpDic))
        {
            if (tmpDic.ContainsKey(starLv))
            {
                data = tmpDic[starLv];
            }
        }

        return(data);
    }
예제 #2
0
    /// <summary>
    /// 刷新项目数据
    /// </summary>
    private void RefreshItemInfo()
    {
        //剩余金币
        SetText(txtLeftCoin, playerData.coin);

        //星级
        SetText(txtStarLv, playerData.strongerArray[curSelectIdx] + "星级");
        int curStarLv = playerData.strongerArray[curSelectIdx];

        for (int i = 0; i < starTransGroup.childCount; i++)
        {
            Image imgStar = starTransGroup.GetChild(i).GetComponent <Image>();
            if (i < curStarLv)
            {
                SetSprite(imgStar, PathDefine.cItemIconLightingStar);
            }
            else
            {
                SetSprite(imgStar, PathDefine.cItemIconDarkStar);
            }
        }

        //升级前属性数据
        int addHp   = _resSvc.GetPropsIncreaseValue(curSelectIdx, curStarLv + 1, Constants.PlayerPropType.PropType_Hp);
        int addHurt = _resSvc.GetPropsIncreaseValue(curSelectIdx, curStarLv + 1, Constants.PlayerPropType.PropType_Hurt);
        int addDef  = _resSvc.GetPropsIncreaseValue(curSelectIdx, curStarLv + 1, Constants.PlayerPropType.PropType_Def);

        SetText(txtPropHP1, "生命 +" + addHp);
        SetText(txtPropHurt1, "伤害 +" + addHurt);
        SetText(txtPropDef1, "防御 +" + addDef);

        //下一星级属性数据
        int nextStarLv = curStarLv + 1;

        nextCfg = _resSvc.GetStrongerCfgData(curSelectIdx, nextStarLv);
        if (nextCfg != null)
        {
            SetNextPropShow(true);

            SetText(txtPropHp2, "强化后 +" + nextCfg.addHp);
            SetText(txtPropHurt2, "+" + nextCfg.addHurt);
            SetText(txtPropDef2, "+" + nextCfg.addDef);

            SetText(txtNeedLv, "需要等级:" + nextCfg.minLv);
            SetText(txtCostCoin, "需要消耗:      " + nextCfg.coin);
            SetText(txtCostCrystal, nextCfg.crystal + "/" + playerData.crystal);
        }
        else
        {
            SetNextPropShow(false);
        }

        //道具图标设置
        switch (curSelectIdx)
        {
        case 0:
            SetSprite(imgCurSelectPos, PathDefine.cItemIconHelmet);
            break;

        case 1:
            SetSprite(imgCurSelectPos, PathDefine.cItemIconBody);
            break;

        case 2:
            SetSprite(imgCurSelectPos, PathDefine.cItemIconWaist);
            break;

        case 3:
            SetSprite(imgCurSelectPos, PathDefine.cItemIconArm);
            break;

        case 4:
            SetSprite(imgCurSelectPos, PathDefine.cItemIconLeg);
            break;

        case 5:
            SetSprite(imgCurSelectPos, PathDefine.cItemIconShoes);
            break;
        }
    }
예제 #3
0
    private void InitStrongerCfgData(string xmlPath)
    {
        TextAsset xmlText = Resources.Load <TextAsset>(xmlPath);

        if (!xmlText)
        {
            CommonTools.Log("xml file: " + PathDefine.cPath_RandomNameCfg + "not exits!",
                            LogType.LogType_Error);
            return;
        }

        //开始解析xml文件
        XmlDocument doc = new XmlDocument();

        doc.LoadXml(xmlText.text);

        XmlNodeList nodeList = doc.SelectSingleNode("root").ChildNodes;

        for (int i = 0; i < nodeList.Count; i++)
        {
            XmlElement element = nodeList[i] as XmlElement;

            if (element.GetAttributeNode("ID") == null)
            {
                continue;
            }
            int id = Convert.ToInt32(element.GetAttributeNode("ID").InnerText);

            StrongerCfg strongerData = new StrongerCfg
            {
                ID = id,
            };

            #region 遍历解析
            foreach (XmlElement elem in nodeList[i].ChildNodes)
            {
                int value = int.Parse(elem.InnerText);
                switch (elem.Name)
                {
                case "pos":
                    strongerData.stongerType = value;
                    break;

                case "starlv":
                    strongerData.starLv = value;
                    break;

                case "addhp":
                    strongerData.addHp = value;
                    break;

                case "addhurt":
                    strongerData.addHurt = value;
                    break;

                case "adddef":
                    strongerData.addDef = value;
                    break;

                case "minlv":
                    strongerData.minLv = value;
                    break;

                case "coin":
                    strongerData.coin = value;
                    break;

                case "crystal":
                    strongerData.crystal = value;
                    break;
                }
            }
            #endregion

            Dictionary <int, StrongerCfg> tmpDic = null;

            if (dictStrongerCfgData.TryGetValue(strongerData.stongerType, out tmpDic))
            {
                tmpDic.Add(strongerData.starLv, strongerData);
            }
            else
            {
                tmpDic = new Dictionary <int, StrongerCfg>();
                tmpDic.Add(strongerData.starLv, strongerData);
                dictStrongerCfgData.Add(strongerData.stongerType, tmpDic);
            }
        }
    }