public List <DrapItem> ReadToDrapItem(string filePath) { Debug.Log(Application.dataPath + filePath + "경로로 파일을 엽니다."); XmlDocument document = new XmlDocument(); document.Load(Application.dataPath + filePath); XmlElement ElementList = document["rows"]; //list name List <DrapItem> DataList = new List <DrapItem>(); foreach (XmlElement xmlElement in ElementList.ChildNodes) { DrapItem drap = new DrapItem(); drap.drapMonsterID = (xmlElement.ChildNodes[(int)DrapItemDataIndex.MonsterID].InnerText); drap.drapitemID = xmlElement.ChildNodes[(int)DrapItemDataIndex.DrapItemID].InnerText; drap.order = int.Parse(xmlElement.ChildNodes[(int)DrapItemDataIndex.Order].InnerText); drap.drapProb = float.Parse(xmlElement.ChildNodes[(int)DrapItemDataIndex.Probability].InnerText); drap.presentQ = xmlElement.ChildNodes[(int)DrapItemDataIndex.PresentQ].InnerText; drap.preogressQ = xmlElement.ChildNodes[(int)DrapItemDataIndex.PreogressQ].InnerText; //Debug.Log("드랍 아이템 : "+drap.drapitemID); //Debug.Log(monster.m_attack+" "+monster.m_attackSpeed+ " "+monster.m_attackRange+ " " + monster.m_HP+ " " + monster.m_moveSpeed); DataList.Add(drap); } return(DataList); }
public void Setting(DrapItem _drapi) { drapitemID = _drapi.drapitemID; drapMonsterID = _drapi.drapMonsterID; drapProb = _drapi.drapProb; prefab = _drapi.prefab; }
//몬스터아이디를 검사해서 드랍아이템결정 public DrapItem FindToDrapItem(string _monsterid) { List <DrapItem> list = new List <DrapItem>(); for (int i = 0; i < drapItemDBList.Count; i++) { //Debug.Log("drapItemDBList["+i+"].drapMonsterID("+ drapItemDBList[i].drapMonsterID+ ") == _monsterid("+_monsterid+")"); if (drapItemDBList[i].drapMonsterID == _monsterid && drapItemDBList[i].CheckPresent()) { //퀘스트에 따라 리스트에 추가하지 않음. //관계없다면 추가. list.Add(drapItemDBList[i]); } } if (list.Count < 1) { Debug.Log("드랍할 아이템을 찾지 못하였습니다."); return(null); } //우선순위가 있을시 //list.Sort() >인덱스와 인터페이스 사용 DrapItem select = new DrapItem(); select.order = 100; for (int j = 0; j < list.Count; j++) { for (int n = 0; n < list.Count; ++n) { //우선순위 결정. if (select.order > list[n].order) { select = list[n]; } } if (select.ProbabilityDrap()) { DrapItemPrefabsSetting(ref select); return(select); } else { list.Remove(select); list.Sort(); } } return(new DrapItem()); }
//드랍아이템 public virtual void DrapTheItem() { //데이터 덩어리 DrapItem setdrap = MonsterManager.Instance.FindToDrapItem(m_index); if (setdrap.prefab != null) { GameObject ob = Instantiate(setdrap.prefab, gameObject.transform.position + (Vector3.up * 0.5f), gameObject.transform.rotation); DrapItem mydrapitem = ob.AddComponent <DrapItem>(); mydrapitem.Setting(setdrap); if (mydrapitem != null) { mydrapitem.StartCoroutine(mydrapitem.DeleteTimer()); mydrapitem.StartCoroutine(mydrapitem.DrapItemUPAndDown()); } setdrap.prefab = null; } }
public void DrapItemPrefabsSetting(ref DrapItem item) { switch (item.drapitemID) { case "item102": item.prefab = drapItems[0]; break; case "item104": item.prefab = drapItems[1]; break; case "item011": item.prefab = drapItems[2]; break; case "item006": item.prefab = drapItems[3]; break; default: break; } }