private void label2_Click(object sender, EventArgs e) { Hide(); EquipmentInfo equipmentInfo = new EquipmentInfo(); equipmentInfo.Show(); }
/// <summary> /// 解析xml使用的 /// </summary> /// <param name="_strEquipmentName">设备的名称,或者路径</param> /// <param name="_dic">equipment infomation 列表</param> /// <param name="_strXmlContent">主要用于android下出现的无法读取的问题</param> /// <param name="_bIsPath">第一个变量是否为路径</param> /// <returns>返回为一个设备信息</returns> public EquipmentInfo LoadXml(string _strEquipmentName, ref Dictionary <string, EquipmentInfo> _dic, string _strXmlContent = "", bool _bIsPath = false) { #if UNITY_ANDROID if (true) { #else string v_strFilePath = _bIsPath ? _strEquipmentName : Application.streamingAssetsPath + "/equipment/" + _strEquipmentName + ".xinfo"; if (_bIsPath) { string[] sArray = _strEquipmentName.Split('\\'); _strEquipmentName = sArray[sArray.Length - 1]; _strEquipmentName = _strEquipmentName.Substring(0, _strEquipmentName.LastIndexOf('.')); } if (System.IO.File.Exists(v_strFilePath)) { #endif #if UNITY_ANDROID Debug.Log(_strXmlContent); XElement root = XDocument.Parse(_strXmlContent).Root; //加载对应路径的设备信息 #else XElement root = XDocument.Load(v_strFilePath).Root; //加载对应路径的设备信息 #endif GameObject v_tmpPerfabEquipmentInfo = AddElement(); //添加一个页面 EquipmentInfo equipmentInfo = v_tmpPerfabEquipmentInfo.GetComponent <EquipmentInfo>(); //得到对应物体的脚本 equipmentInfo.onShow.AddListener((string _arg0) => { ShowPnlEquipmentInfo(_arg0); }); //绑定打开事件 equipmentInfo.onClose.AddListener((string _arg0) => { }); //绑定关闭事件 string equipmentName = root.Attribute("name").Value; List <EquipmentInfomation> listEquipmentInfomation = new List <EquipmentInfomation>(); foreach (XElement i in root.Elements()) { EquipmentInfomation equipmentInfomation = new EquipmentInfomation( i.Attribute("patht").Value, int.Parse(i.Attribute("w").Value), int.Parse(i.Attribute("h").Value), i.Attribute("texture").Value, (i.Attribute("h_information") != null ? int.Parse(i.Attribute("h_information").Value) : 498)); Debug.Log(i.Attribute("h_information")); listEquipmentInfomation.Add(equipmentInfomation); } equipmentInfo.Init(_strEquipmentName, equipmentName, listEquipmentInfomation, m_bIsEditor); equipmentInfo.Show(); if (!_dic.ContainsKey(_strEquipmentName)) { _dic.Add(_strEquipmentName, equipmentInfo); } UpdateOutline(); return(equipmentInfo); } return(null); } /// <summary> /// 添加一个元素 /// </summary> /// <returns>将创建的元素返回</returns> GameObject AddElement() { GameObject v_tmpPerfabEquipmentInfo = (GameObject)Instantiate(Resources.Load(m_strEquipmentInformationElement) as GameObject, this.transform); v_tmpPerfabEquipmentInfo.transform.localPosition = Vector3.zero; v_tmpPerfabEquipmentInfo.transform.localScale = Vector3.one; return(v_tmpPerfabEquipmentInfo); } /// <summary> /// 点击新建的时候 /// </summary> void OnAddElement() { if (m_bIsEditor) { GameObject tmp = AddElement(); List <EquipmentInfomation> tmp2 = new List <EquipmentInfomation>(); tmp2.Add(new EquipmentInfomation()); tmp.GetComponent <EquipmentInfo>().Init("设备名称", "设备名称", tmp2, m_bIsEditor); tmp.GetComponent <EquipmentInfo>().onSave.AddListener((string _arg0) => { if (!m_dicEquipmentInfo.ContainsKey(_arg0)) { m_dicEquipmentInfo.Add(_arg0, tmp.GetComponent <EquipmentInfo>()); } UpdateOutline(); }); tmp.GetComponent <EquipmentInfo>().Show(); } }
public void OnSelect() { AudioSource.PlayClipAtPoint(selected, transform.position, GameManager.SFX_Volume); EI.Show(E, EquipmentInfo.Mode.Inventory); }