public ArrayList loadTypeXmlToArray() { ArrayList _typeList = new ArrayList(); string filepath = "Config/Materiral/MaterialType"; string _result = Resources.Load(filepath).ToString(); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(_result); XmlNodeList nodeList = xmlDoc.SelectSingleNode("TypeList").ChildNodes; foreach (XmlElement type in nodeList) { Materiral.MaterialType _type = new Materiral.MaterialType(); if (type.GetAttribute("ID") != "") { _type.ID = int.Parse(type.GetAttribute("ID")); } if (type.GetAttribute("Name") != "") { _type.Name = type.GetAttribute("Name"); } if (type.GetAttribute("Image") != "") { _type.IMG = type.GetAttribute("Image"); } _typeList.Add(_type); } return(_typeList); }
//设置合成界面槽的信息和位置 void SetSlot(Recipe.RecipeMap map) { int num = map.Slots.Length; //TODO:游戏道具的名称和ID,以及按钮的表现效果 Vector3 base_point = new Vector3(0, -100, 0); int targetAngel = 0; SlotList = new Dictionary <int, SlotBox>(); for (int i = 0; i < num; i++) { GameObject recipeSlot = Instantiate(btn_recipeSlot); recipeSlot.transform.SetParent(recipeSlotsList.transform, false); //设置按钮位置 targetAngel = 360 / num * i; Vector3 target_pos = Quaternion.Euler(0, 0, targetAngel) * base_point; recipeSlot.transform.localPosition = target_pos; //判断slot中材料的类型,0为固定材料,1为材料种类 if (map.Slots[i].SlotType == Recipe.SlotTypeList.Material) { //固定材料 if (map.Slots[i].MatType == 0) //Item { Materiral.Items _item = Materiral.FindItemByID(map.Slots[i].MatId); recipeSlot.name = i.ToString(); recipeSlot.transform.Find("Text").GetComponent <Text>().text = "[" + _item.Name + "]"; recipeSlot.transform.Find("Bottom/Image").GetComponent <Image>().sprite = Materiral.GetIconByName(_item.IMG); recipeSlot.transform.Find("Bottom/Image").GetComponent <Image>().color = new Color(1, 1, 1, 0.5f); } else if (map.Slots[i].MatType == 1) //Mind { Materiral.Minds _mind = Materiral.FindMindByID(map.Slots[i].MatId); recipeSlot.name = i.ToString(); recipeSlot.transform.Find("Text").GetComponent <Text>().text = "[" + _mind.Name + "]"; recipeSlot.transform.Find("Bottom/Image").GetComponent <Image>().sprite = Materiral.GetIconByName(_mind.IMG); recipeSlot.transform.Find("Bottom/Image").GetComponent <Image>().color = new Color(1, 1, 1, 0.5f); } } else if (map.Slots[i].SlotType == Recipe.SlotTypeList.MaterialType) { //材料类型 recipeSlot.name = i.ToString(); int typeID = map.Slots[i].MatType; Materiral.MaterialType type = Materiral.FindTypeNameByID(typeID); recipeSlot.transform.Find("Text").GetComponent <Text>().text = "<color=red>[" + type.Name + "]\n(类型)</color>"; recipeSlot.transform.Find("Bottom/Image").GetComponent <Image>().sprite = Materiral.GetIconByName(type.IMG); recipeSlot.transform.Find("Bottom/Image").GetComponent <Image>().color = new Color(1, 1, 1, 0.5f); } else { Debug.Log("Can't find recipe slots!"); } //设置参数容器中的参数 Parameter.Box parameter = new Parameter.Box(); parameter.ID = i; //ID为slot的序号 parameter.callback = ClickInBag; parameter.obj = map.Slots[i]; parameter.subobj = SlotList; //添加记录到合成系统用容器中 SlotBox slot = new SlotBox(); slot.button = recipeSlot; SlotList.Add(i, slot); //设置点击事件 GameObject _slot = recipeSlot.transform.Find("Bottom/Image").gameObject; EventTriggerListener.Get(_slot).parameter = parameter; EventTriggerListener.Get(_slot).onClickByParameter = OpenBag; } }