|  | @@ -0,0 +1,186 @@
 | 
	
		
			
				|  |  | +using System.Collections.Generic;
 | 
	
		
			
				|  |  | +using System.Linq;
 | 
	
		
			
				|  |  | +using Excel2Json;
 | 
	
		
			
				|  |  | +using Fort23.UTool;
 | 
	
		
			
				|  |  | +using GameLogic.Bag;
 | 
	
		
			
				|  |  | +using UnityEngine;
 | 
	
		
			
				|  |  | +using Utility;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +namespace GameLogic.Player
 | 
	
		
			
				|  |  | +{
 | 
	
		
			
				|  |  | +    public class SummonManager
 | 
	
		
			
				|  |  | +    {
 | 
	
		
			
				|  |  | +        public Map<int, AccountFileInfo.SummonData> summonDataMap = new Map<int, AccountFileInfo.SummonData>();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        public void CustomInit()
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            OpenBoxConfig[] openBoxConfigs = ConfigComponent.Instance.GetAll<OpenBoxConfig>();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            //每次进游戏检查是否有新的抽卡
 | 
	
		
			
				|  |  | +            foreach (var openBoxConfig in openBoxConfigs)
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                if (AccountFileInfo.Instance.playerData.SummonDatas.FirstOrDefault(s => s.id == openBoxConfig.ID) == null)
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    AccountFileInfo.SummonData summonData = new AccountFileInfo.SummonData();
 | 
	
		
			
				|  |  | +                    summonData.id = openBoxConfig.ID;
 | 
	
		
			
				|  |  | +                    AccountFileInfo.Instance.playerData.SummonDatas.Add(summonData);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            foreach (var playerDataSummonData in AccountFileInfo.Instance.playerData.SummonDatas)
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                if (!summonDataMap.ContainsKey(playerDataSummonData.id))
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    summonDataMap.Add(playerDataSummonData.id, playerDataSummonData);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            AccountFileInfo.Instance.SavePlayerData();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        public List<ItemInfo> Summon(int id, int count)
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            AccountFileInfo.SummonData summonData = summonDataMap[id];
 | 
	
		
			
				|  |  | +            OpenBoxConfig openBoxConfig = ConfigComponent.Instance.Get<OpenBoxConfig>(summonData.id);
 | 
	
		
			
				|  |  | +            List<ItemInfo> allIitem = new List<ItemInfo>();
 | 
	
		
			
				|  |  | +            //单抽
 | 
	
		
			
				|  |  | +            if (count == 1)
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                //有免费次数,并且让到时间了就免费抽
 | 
	
		
			
				|  |  | +                if (summonData.freeCount < openBoxConfig.oneConsumeFreePara[1] && PlayerManager.Instance.serverTime >= summonData.nextFreeTime)
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    allIitem = Summon(summonData, 1);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                    summonData.nextFreeTime = PlayerManager.Instance.serverTime + openBoxConfig.oneConsumeFreePara[0] * 1000;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                else
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    //验证道具是否足够
 | 
	
		
			
				|  |  | +                    if (PlayerManager.Instance.BagController.IsEnough(openBoxConfig.CostItemID, openBoxConfig.oneConsume))
 | 
	
		
			
				|  |  | +                    {
 | 
	
		
			
				|  |  | +                        PlayerManager.Instance.BagController.DeductCoin(openBoxConfig.oneConsume);
 | 
	
		
			
				|  |  | +                        allIitem = Summon(summonData, 1);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                        summonData.nextFreeTime = PlayerManager.Instance.serverTime + openBoxConfig.oneConsumeFreePara[0] * 1000;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    else
 | 
	
		
			
				|  |  | +                    {
 | 
	
		
			
				|  |  | +                        return null;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            //十连抽
 | 
	
		
			
				|  |  | +            else if (count == 10)
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                //有免费次数,并且让到时间了就免费抽
 | 
	
		
			
				|  |  | +                if (summonData.payCount < openBoxConfig.oneConsumeFreePara_1[1] && PlayerManager.Instance.serverTime >= summonData.nextPayTime)
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    allIitem = Summon(summonData, 10);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                    summonData.nextPayTime = PlayerManager.Instance.serverTime + openBoxConfig.oneConsumeChargePara[0] * 1000;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                else
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    //验证道具是否足够
 | 
	
		
			
				|  |  | +                    if (PlayerManager.Instance.BagController.IsEnough(openBoxConfig.CostItemID, openBoxConfig.tenConsume))
 | 
	
		
			
				|  |  | +                    {
 | 
	
		
			
				|  |  | +                        PlayerManager.Instance.BagController.DeductCoin(openBoxConfig.tenConsume);
 | 
	
		
			
				|  |  | +                        allIitem = Summon(summonData, 10);
 | 
	
		
			
				|  |  | +                        summonData.nextPayTime = PlayerManager.Instance.serverTime + openBoxConfig.oneConsumeChargePara[0] * 1000;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    else
 | 
	
		
			
				|  |  | +                    {
 | 
	
		
			
				|  |  | +                        return null;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            return allIitem;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        public List<ItemInfo> Summon(AccountFileInfo.SummonData summonData, int count)
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            List<ItemInfo> allIitem = new List<ItemInfo>();
 | 
	
		
			
				|  |  | +            OpenBoxConfig openBoxConfig = ConfigComponent.Instance.Get<OpenBoxConfig>(summonData.id);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            bool isBoadi2 = false;
 | 
	
		
			
				|  |  | +            //找到保底池子所有道具
 | 
	
		
			
				|  |  | +            List<int> baodiItems = new List<int>();
 | 
	
		
			
				|  |  | +            DropConfig dropConfig = ConfigComponent.Instance.Get<DropConfig>(openBoxConfig.reward2);
 | 
	
		
			
				|  |  | +            for (var i = 0; i < dropConfig.dropGroupID.Length; i++)
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                DropGroupConfig dropGroupConfig = ConfigComponent.Instance.Get<DropGroupConfig>(dropConfig.dropGroupID[i]);
 | 
	
		
			
				|  |  | +                for (var i1 = 0; i1 < dropGroupConfig.dropItemID.Length; i1++)
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    DropItemConfig dropItemConfig = ConfigComponent.Instance.Get<DropItemConfig>(dropGroupConfig.dropItemID[i1]);
 | 
	
		
			
				|  |  | +                    for (var i2 = 0; i2 < dropItemConfig.itemID.Length; i2++)
 | 
	
		
			
				|  |  | +                    {
 | 
	
		
			
				|  |  | +                        baodiItems.Add(dropItemConfig.itemID[i2]);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            for (int i = 0; i < count; i++)
 | 
	
		
			
				|  |  | +            {
 | 
	
		
			
				|  |  | +                isBoadi2 = false;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                //十连保底1 每10次十连必出这个池子
 | 
	
		
			
				|  |  | +                if (summonData.baodiCount1 >= 10)
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    List<ItemInfo> addItem = DropManager.Instance.DropItem(openBoxConfig.reward1);
 | 
	
		
			
				|  |  | +                    PlayerManager.Instance.BagController.AddItem(addItem);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                    allIitem.AddRange(addItem);
 | 
	
		
			
				|  |  | +                    summonData.baodiCount1 = 0;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                    foreach (var baodiItem in baodiItems)
 | 
	
		
			
				|  |  | +                    {
 | 
	
		
			
				|  |  | +                        //除了保底2池子里的道具直接重置保底2
 | 
	
		
			
				|  |  | +                        if (addItem.FirstOrDefault(i => i.itemID == baodiItem) != null)
 | 
	
		
			
				|  |  | +                        {
 | 
	
		
			
				|  |  | +                            summonData.baodiCount2 = 0;
 | 
	
		
			
				|  |  | +                            break;
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                    continue;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                //十连保底2 每reward2para1次十连必出这个池子
 | 
	
		
			
				|  |  | +                if (summonData.baodiCount2 >= openBoxConfig.reward2para1)
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    List<ItemInfo> addItem1 = DropManager.Instance.DropItem(openBoxConfig.reward2);
 | 
	
		
			
				|  |  | +                    PlayerManager.Instance.BagController.AddItem(addItem1);
 | 
	
		
			
				|  |  | +                    summonData.baodiCount2 = 0;
 | 
	
		
			
				|  |  | +                    continue;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                List<ItemInfo> addItem2 = DropManager.Instance.DropItem(openBoxConfig.reward);
 | 
	
		
			
				|  |  | +                PlayerManager.Instance.BagController.AddItem(addItem2);
 | 
	
		
			
				|  |  | +                allIitem.AddRange(addItem2);
 | 
	
		
			
				|  |  | +                summonData.baodiCount1++;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                foreach (var baodiItem in baodiItems)
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    //除了保底2池子里的道具直接重置保底2
 | 
	
		
			
				|  |  | +                    if (addItem2.FirstOrDefault(i => i.itemID == baodiItem) != null)
 | 
	
		
			
				|  |  | +                    {
 | 
	
		
			
				|  |  | +                        summonData.baodiCount2 = 0;
 | 
	
		
			
				|  |  | +                        isBoadi2 = true;
 | 
	
		
			
				|  |  | +                        break;
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                if (!isBoadi2)
 | 
	
		
			
				|  |  | +                {
 | 
	
		
			
				|  |  | +                    summonData.baodiCount2++;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            AccountFileInfo.Instance.SavePlayerData();
 | 
	
		
			
				|  |  | +            return allIitem;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +}
 |