public List <ItemSample> ReturnItems(short resGotMultiplier, int num) { NaturalRes resData; num = mRemoveList.Count; List <ItemSample> itemGridList = new List <ItemSample>(); for (int index = 0; index < num; index++) { if ((resData = NaturalRes.GetTerrainResData(mRemoveList[index].Type)) != null && resData.m_itemsGot.Count > 0) { List <float> randVars = new List <float>(); ItemSample[] itemGrids = new ItemSample[resData.m_itemsGot.Count]; for (int i = 0; i < resData.m_itemsGot.Count; i++) { itemGrids[i] = new ItemSample(resData.m_itemsGot[i].m_id, 0); } float resGet = 0; if (resData.mFixedNum > 0) { resGet = resData.mFixedNum; } else { resGet = (resGotMultiplier + resData.mSelfGetNum); } for (int i = 0; i < resGet; i++) { randVars.Add(UnityEngine.Random.Range(0, 100)); } for (int i = 0; i < randVars.Count; i++) { for (int j = 0; j < resData.m_itemsGot.Count; j++) { if (randVars[i] < resData.m_itemsGot[j].m_probablity) { itemGrids[j].IncreaseStackCount(1); break; } } } //extra item get below, add by yinrui List <ItemSample> itemGetExtra = new List <ItemSample>(); if (resData.m_extraGot.extraPercent > 0 && Random.value < resGet * resData.m_extraGot.extraPercent) { for (int i = 0; i < resData.m_extraGot.m_extraGot.Count; i++) { itemGetExtra.Add(new ItemSample(resData.m_extraGot.m_extraGot[i].m_id, 0)); } resGet *= resData.m_extraGot.extraPercent; int rand; for (int i = 0; i < resGet; i++) { rand = Random.Range(0, 100); for (int j = 0; j < resData.m_extraGot.m_extraGot.Count; j++) { if (rand < resData.m_extraGot.m_extraGot[j].m_probablity) { itemGetExtra[j].IncreaseStackCount(1); break; } } } } //part1 end for (int i = 0; i < itemGrids.Length; i++) { if (itemGrids[i].GetCount() > 0) { ItemSample findItem = itemGridList.Find(itr => itr.protoId == itemGrids[i].protoId); if (null != findItem) { findItem.IncreaseStackCount(itemGrids[i].GetCount()); } else { itemGridList.Add(itemGrids[i]); } } } //part2 foreach (ItemSample data in itemGetExtra) { if (data.GetCount() > 0) { ItemSample findItem = itemGridList.Find(itr => itr.protoId == data.protoId); if (null != findItem) { findItem.IncreaseStackCount(data.GetCount()); } else { itemGridList.Add(data); } } } //part2 end } } mRemoveList.Clear(); return(itemGridList); }