private void LootWithScore(List <LootObjData> dataList, LootData lootData, float score) { int count = 0; while (score > 0) { LootWeight lootWeight = GetRandomLootWeight(lootData._lootList); if (lootWeight != null) { int lootCount = UnityEngine.Random.Range(lootWeight._countMin, lootWeight._countMax); float lootScore = 0; if (lootWeight._itemId == "money") { lootScore = lootCount; } else { ItemData data = getItemData(lootWeight._itemId); lootScore = lootCount * (data == null ? 0 : 0); } //Debug.Log("score: "+ score + " :" + lootWeight._itemId + " "+ lootCount + " " +lootScore +" " + (lootScore < score * 2)); if (lootScore < score * 2) { score -= lootScore; LootObjData lootObj = new LootObjData(); lootObj._lootId = lootWeight._itemId; lootObj._lootCount = lootCount; dataList.Add(lootObj); } } count++; if (count >= _lootMax) { //Debug.LogWarning("CalLootWithScore:["+count+"] totalScore:" + totalScore + " remainScore:"+ score); break; } } /* * string result = "result : "; * foreach(LootObjData tmp in dataList) * { * result += tmp._lootId + " "; * } * Debug.Log(result); */ }
private void GetOneLoot(List <LootObjData> dataList, LootData lootData) { LootWeight lootWeight = GetRandomLootWeight(lootData._lootList); if (lootWeight != null) { LootObjData lootObj = new LootObjData(); lootObj._lootId = lootWeight._itemId; lootObj._lootCount = UnityEngine.Random.Range(lootWeight._countMin, lootWeight._countMax);; dataList.Add(lootObj); } }