/// <inheritdoc/> public override XElement GetXml(string rootElemName, bool suppressDefaults) { XElement rootElem = new XElement(rootElemName); rootElem.Add(new XAttribute("density", Density.ToString(CultureInfo.InvariantCulture))); rootElem.Add(StrengthCfg.GetXml("strength", suppressDefaults)); Validate(rootElem, XsdTypeName); return(rootElem); }
public StrengthCfg GetStrengthCfgData(int pos, int startlv) { StrengthCfg sc = null; Dictionary <int, StrengthCfg> dic = null; //Debug.Log(id); if (strengthDic.TryGetValue(pos, out dic)) { //Debug.Log(data); if (dic.ContainsKey(startlv)) { sc = dic[startlv]; } } return(sc); }
private void InitStrengthCfg(string path) { TextAsset xml = Resources.Load <TextAsset>(path); if (!xml) { PECommon.Log("指定文件不存在,路径:" + path, LogType.Error); } else { XmlDocument doc = new XmlDocument(); doc.LoadXml(xml.text); //选中子节点集合 XmlNodeList nodList = doc.SelectSingleNode("root").ChildNodes; for (int i = 0; i < nodList.Count; i++) { XmlElement ele = nodList[i] as XmlElement; if (ele.GetAttributeNode("ID") == null) {//不包含ID的节点,直接跳到下一个遍历,安全校验 continue; } int ID = Convert.ToInt32(ele.GetAttributeNode("ID").InnerText); StrengthCfg sd = new StrengthCfg { ID = ID }; foreach (XmlElement element in nodList[i].ChildNodes) { switch (element.Name) { case "pos": sd.pos = int.Parse(element.InnerText); break; case "starlv": sd.startlv = int.Parse(element.InnerText); break; case "coin": sd.coin = int.Parse(element.InnerText); break; case "crystal": sd.crystal = int.Parse(element.InnerText); break; case "addhp": sd.addhp = int.Parse(element.InnerText); break; case "addhurt": sd.addhurt = int.Parse(element.InnerText); break; case "adddef": sd.adddef = int.Parse(element.InnerText); break; case "minlv": sd.minlv = int.Parse(element.InnerText); break; default: break; } } Dictionary <int, StrengthCfg> dic = null; if (strengthDic.TryGetValue(sd.pos, out dic)) { dic.Add(sd.startlv, sd); } else { dic = new Dictionary <int, StrengthCfg>(); dic.Add(sd.startlv, sd); strengthDic.Add(sd.pos, dic); } //strengthDic.Add(ID, strengthCfg); //Debug.Log("ID:"+ID+" mapCfg:"+mapCfg.ToString()); } } }
private void RefreshItem() { SetText(txtCoin, pd.coin); switch (currentIndex) { case 0: SetSprite(imgPos, PathDefine.ItemHead); break; case 1: SetSprite(imgPos, PathDefine.ItemBody); break; case 2: SetSprite(imgPos, PathDefine.ItemWaist); break; case 3: SetSprite(imgPos, PathDefine.ItemHand); break; case 4: SetSprite(imgPos, PathDefine.ItemLeg); break; case 5: SetSprite(imgPos, PathDefine.ItemFoot); break; default: break; } int currentStarLv = pd.strengthArray[currentIndex]; SetText(txtStarLv, currentStarLv + "星级");//设置当前部位星级 for (int i = 0; i < starTransGroup.childCount; i++) { Image img = starTransGroup.GetChild(i).GetComponent <Image>(); if (currentStarLv <= i) { SetSprite(img, PathDefine.StarIcon1); } else { SetSprite(img, PathDefine.StarIcon2); } } int nextStarlv = currentStarLv + 1; nextSc = resSvc.GetStrengthCfgData(currentIndex, nextStarlv); if (nextSc != null)//存在下一级 { SetActive(conditionTrans); SetActive(imgArrow1); SetActive(imgArrow2); SetActive(imgArrow3); SetActive(txtHP2); SetActive(txtDamage2); SetActive(txtDef2); SetText(txtHP2, "强化后 +" + nextSc.addhp); SetText(txtDamage2, "强化后 +" + nextSc.addhurt); SetText(txtDef2, "强化后 +" + nextSc.adddef); SetText(txtNeedLv, "需要等级: " + nextSc.minlv); SetText(txtCostCoin, nextSc.coin); SetText(txtCrystal, nextSc.crystal + "/" + pd.crystal); } else { SetActive(conditionTrans, false); SetActive(imgArrow1, false); SetActive(imgArrow2, false); SetActive(imgArrow3, false); SetActive(txtHP2, false); SetActive(txtDamage2, false); SetActive(txtDef2, false); } int sumAddHP = resSvc.GetPropAddValPreLv(currentIndex, currentStarLv, 1); int sumAddHurt = resSvc.GetPropAddValPreLv(currentIndex, currentStarLv, 2); int sumAddDef = resSvc.GetPropAddValPreLv(currentIndex, currentStarLv, 3); SetText(txtHP1, "生命 +" + sumAddHP); SetText(txtDamage1, "伤害 +" + sumAddHurt); SetText(txtDef1, "防御 +" + sumAddDef); }