ArrayList FindAllComposeResult(ArrayList PropertyBox) { ArrayList result = new ArrayList(); for (int i = 0; i < PropertyBox.Count; i++) { RecipeUI.PropertyElementBase _proBase1 = (RecipeUI.PropertyElementBase)PropertyBox[i]; Materiral.Property p1 = _proBase1.Property; for (int j = i + 1; j < PropertyBox.Count; j++) { RecipeUI.PropertyElementBase _proBase2 = (RecipeUI.PropertyElementBase)PropertyBox[j]; Materiral.Property p2 = _proBase2.Property; //用于储存合成的结果数字(求和)和合成属性的ID,第一个为属性1,第二个为属性2 Result _r = new Result(); _r.sum = p1.ID + p2.ID; _r.Base1 = _proBase1; _r.Base2 = _proBase2; result.Add(_r); } } return(result); }
//读取材料属性列表 public ArrayList loadPropertyEffetXmlToArray() { //保存路径 string filepath = "Config/Materiral/PropertyEffet"; string _result = Resources.Load(filepath).ToString(); ArrayList propertyList = new ArrayList(); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(_result); XmlNodeList nodeList = xmlDoc.SelectSingleNode("PropertyList").ChildNodes; foreach (XmlElement property in nodeList) { Materiral.Property _property = new Materiral.Property(); //读取node内属性,把string转化为对应的属性 if (property.GetAttribute("ID") != "") { _property.ID = int.Parse(property.GetAttribute("ID")); } if (property.GetAttribute("Name") != "") { _property.Name = property.GetAttribute("Name"); } if (property.GetAttribute("Image") != "") { _property.IMG = property.GetAttribute("Image"); } if (property.GetAttribute("des") != "") { _property.Des = property.GetAttribute("des"); } if (property.GetAttribute("Effet") != "") { _property.Effet = int.Parse(property.GetAttribute("Effet")); } //添加进itemList中 propertyList.Add(_property); } return(propertyList); }
public void OpenItemInfo(CharBag.Goods good) { //名称 goodsUIBase.nameText.text = good.Name; //图片icon goodsUIBase.goodsIMG.sprite = Materiral.GetMaterialIcon(good.MateriralType, good.ID); //物品类型 if (good.MateriralType == 0) { goodsUIBase.MaterialtypeText.text = "类型:物品"; } else if (good.MateriralType == 1) { goodsUIBase.MaterialtypeText.text = "类型:概念"; } else { goodsUIBase.MaterialtypeText.text = "类型:未知"; } //数量 goodsUIBase.numText.text = "数量:" + good.Number.ToString(); //品质 goodsUIBase.qualityText.text = "品质:" + good.Quality.ToString(); //价格 goodsUIBase.priceText.text = "价格:" + good.Price.ToString(); //物品效果 if (good.MaterialEffet != 0) { Materiral.Effect _effect = Materiral.FindMaterialEffectByID(good.MaterialEffet); goodsUIBase.effect.text = _effect.Name; effect = _effect; } //物品属性 if (good.Property != null) { for (int i = 0; i < good.Property.Length; i++) { if (good.Property[i] == 0) { break; } Materiral.Property _p = Materiral.GetProNameByProID(good.Property[i]); GameObject p_obj = goodsUIBase.propertys[i]; p_obj.SetActive(true); p_obj.transform.GetChild(0).GetComponent <Text>().text = _p.Name; p_obj.transform.GetChild(1).GetComponent <Image>().sprite = Materiral.GetPropertyIcon(_p.ID); Propertys.Add(_p); } } //类型 goodsUIBase.typeText.text = Materiral.FindTypeNameByID(good.Type).Name; string str = Materiral.GetDesByMaterialID(good.MateriralType, good.ID); //描述 goodsUIBase.des.text = System.Text.RegularExpressions.Regex.Unescape(str); }
//属性效果UI效果 void AddPropertyUIEft(CharBag.Goods _slot) { float actionTime = 0.5f; for (int i = 0; i < _slot.Property.Length; i++) { if (_slot.Property[i] == 0) { continue; } int proID = _slot.Property[i]; RectTransform _property = Instantiate(PropertyListElement).GetComponent <RectTransform>(); _property.transform.SetParent(PropertyListGrid.transform, false); _property.localPosition = GetPropertyPos(PropertyBox.Count + 1); _property.sizeDelta = GetPropertySize(PropertyBox.Count + 1); //获取materiral的颜色 Color _color_image = _property.GetComponent <Image>().color; Color _color_text = _property.transform.Find("Text").GetComponent <Text>().color; Color from = new Color(_color_image.r, _color_image.g, _color_image.b, 0); _property.GetComponent <Image>().color = from; _property.transform.Find("Image").GetComponent <Image>().color = from; _property.transform.Find("Text").GetComponent <Text>().color = from; //渐现效果 LeanTween.value(_property.gameObject, from, _color_image, 0.25f).setDelay(actionTime).setOnUpdate( (Color col) => { _property.GetComponent <Image>().color = col; } ); LeanTween.value(_property.gameObject, from, _color_text, 0.25f).setDelay(actionTime).setOnUpdate( (Color col) => { _property.transform.Find("Text").GetComponent <Text>().color = col; } ); LeanTween.value(_property.gameObject, from, new Color(1, 1, 1, 1), 0.25f).setDelay(actionTime).setOnUpdate( (Color col) => { _property.transform.Find("Image").GetComponent <Image>().color = col; } ); //TODO:点击效果 //EndTODO Materiral.Property _p = Materiral.GetProNameByProID(proID); _property.transform.Find("Text").GetComponent <Text>().text = _p.Name; _property.transform.Find("Image").GetComponent <Image>().sprite = Materiral.GetIconByName(_p.IMG); PropertyElementBase _proBase = new PropertyElementBase(); _proBase.ID = PropertyBox.Count + 1; _proBase.Property = _p; _proBase.Button = _property; PropertyBox.Add(_proBase); } }