|
@@ -26,10 +26,10 @@ namespace GFGGame
|
|
{
|
|
{
|
|
List<ItemData> result = new List<ItemData>();
|
|
List<ItemData> result = new List<ItemData>();
|
|
int tryCount = 0;
|
|
int tryCount = 0;
|
|
- while(result.Count < count && tryCount < 1000)
|
|
|
|
|
|
+ while (result.Count < count && tryCount < 1000)
|
|
{
|
|
{
|
|
ItemData itemData = GetDropItemData(dropId, true);
|
|
ItemData itemData = GetDropItemData(dropId, true);
|
|
- if(itemData != null)
|
|
|
|
|
|
+ if (itemData != null)
|
|
{
|
|
{
|
|
result.Add(itemData);
|
|
result.Add(itemData);
|
|
}
|
|
}
|
|
@@ -42,17 +42,17 @@ namespace GFGGame
|
|
{
|
|
{
|
|
ItemData itemData = null;
|
|
ItemData itemData = null;
|
|
List<DropOutData> dropOutDatas = null;
|
|
List<DropOutData> dropOutDatas = null;
|
|
- if(!_probDic.ContainsKey(dropId))
|
|
|
|
|
|
+ if (!_probDic.ContainsKey(dropId))
|
|
{
|
|
{
|
|
InitData(dropId);
|
|
InitData(dropId);
|
|
}
|
|
}
|
|
dropOutDatas = _probDic[dropId];
|
|
dropOutDatas = _probDic[dropId];
|
|
- if(dropOutDatas != null)
|
|
|
|
|
|
+ if (dropOutDatas != null)
|
|
{
|
|
{
|
|
float result = Random.Range(0, 1f);
|
|
float result = Random.Range(0, 1f);
|
|
- foreach(DropOutData dropOutData in dropOutDatas)
|
|
|
|
|
|
+ foreach (DropOutData dropOutData in dropOutDatas)
|
|
{
|
|
{
|
|
- if(result <= dropOutData.WeightEnd || !doRandome)
|
|
|
|
|
|
+ if (result <= dropOutData.WeightEnd || !doRandome)
|
|
{
|
|
{
|
|
return GetItemData(dropOutData.dropOutCfg, doRandome);
|
|
return GetItemData(dropOutData.dropOutCfg, doRandome);
|
|
}
|
|
}
|
|
@@ -68,35 +68,35 @@ namespace GFGGame
|
|
var arr = DropOutCfgArray.Instance.GetCfgs(dropId);
|
|
var arr = DropOutCfgArray.Instance.GetCfgs(dropId);
|
|
List<DropOutCfg> cfgs = new List<DropOutCfg>(arr);
|
|
List<DropOutCfg> cfgs = new List<DropOutCfg>(arr);
|
|
float totalWeight = 0;
|
|
float totalWeight = 0;
|
|
- foreach(DropOutCfg cfg in cfgs)
|
|
|
|
|
|
+ foreach (DropOutCfg cfg in cfgs)
|
|
{
|
|
{
|
|
totalWeight += cfg.weight;
|
|
totalWeight += cfg.weight;
|
|
}
|
|
}
|
|
float weightEnd = 0;
|
|
float weightEnd = 0;
|
|
- foreach(DropOutCfg cfg in cfgs)
|
|
|
|
|
|
+ foreach (DropOutCfg cfg in cfgs)
|
|
{
|
|
{
|
|
DropOutData dropOutData = new DropOutData();
|
|
DropOutData dropOutData = new DropOutData();
|
|
dropOutData.dropOutCfg = cfg;
|
|
dropOutData.dropOutCfg = cfg;
|
|
weightEnd += cfg.weight;
|
|
weightEnd += cfg.weight;
|
|
- dropOutData.WeightEnd = weightEnd/totalWeight;
|
|
|
|
|
|
+ dropOutData.WeightEnd = weightEnd / totalWeight;
|
|
dropOutDatas.Add(dropOutData);
|
|
dropOutDatas.Add(dropOutData);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private static ItemData GetItemData(DropOutCfg dropOutCfg, bool doRandomeNum)
|
|
private static ItemData GetItemData(DropOutCfg dropOutCfg, bool doRandomeNum)
|
|
{
|
|
{
|
|
- if(dropOutCfg.item >= 10000000)//掉落id
|
|
|
|
|
|
+ if (dropOutCfg.item >= 10000000)//掉落id
|
|
{
|
|
{
|
|
return GetDropItemData(dropOutCfg.item, doRandomeNum);
|
|
return GetDropItemData(dropOutCfg.item, doRandomeNum);
|
|
}
|
|
}
|
|
- else if(dropOutCfg.item > 0)
|
|
|
|
|
|
+ else if (dropOutCfg.item > 0)
|
|
{
|
|
{
|
|
int num = dropOutCfg.maxNum;
|
|
int num = dropOutCfg.maxNum;
|
|
- if(doRandomeNum)
|
|
|
|
|
|
+ if (doRandomeNum)
|
|
{
|
|
{
|
|
num = Random.Range(dropOutCfg.minNum, dropOutCfg.maxNum + 1);
|
|
num = Random.Range(dropOutCfg.minNum, dropOutCfg.maxNum + 1);
|
|
}
|
|
}
|
|
- if(num > 0)
|
|
|
|
|
|
+ if (num > 0)
|
|
{
|
|
{
|
|
ItemData itemData = ItemDataPool.GetItemData(dropOutCfg.item);
|
|
ItemData itemData = ItemDataPool.GetItemData(dropOutCfg.item);
|
|
itemData.num = num;
|
|
itemData.num = num;
|
|
@@ -105,5 +105,42 @@ namespace GFGGame
|
|
}
|
|
}
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public static List<ItemData> GetDropItemDatas1(int[] dropIds, bool doRandome)
|
|
|
|
+ {
|
|
|
|
+ List<ItemData> result = new List<ItemData>();
|
|
|
|
+ foreach (int dropId in dropIds)
|
|
|
|
+ {
|
|
|
|
+ GetDropItemDatas(dropId, result);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static List<ItemData> GetDropItemDatas(int dropId, List<ItemData> result)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ List<DropOutCfg> dropOutCfgs = DropOutCfgArray.Instance.GetCfgs(dropId);
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < dropOutCfgs.Count; i++)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ List<DropOutCfg> _dropOutCfgs = DropOutCfgArray.Instance.GetCfgs(dropOutCfgs[i].item);
|
|
|
|
+ if (_dropOutCfgs.Count > 0)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ GetDropItemDatas(dropOutCfgs[i].item, result);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ ItemData itemData = ItemUtil.createItemData(dropOutCfgs[i].item, dropOutCfgs[i].maxNum);// GetDropItemData(dropId, doRandome);
|
|
|
|
+ if (dropOutCfgs[i].item > 0 && itemData != null)
|
|
|
|
+ {
|
|
|
|
+ result.Add(itemData);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|