| | |
| | | |
| | | public class PackManager : GameSystemManager<PackManager> |
| | | { |
| | | public event Action<PackType> refrechPackEvent; //刷新整个背包数据 |
| | | |
| | | //物品(创建)刷新,可能批量创建注意效率; bool:true代表创建 false 刷新; 注意0707物品数量刷新不包含在此事件 |
| | | public event Action<PackType, string, bool> ChangeItemEvent; // 背包类型,GUID,是否创建 |
| | | |
| | | //删除物品,可能批量删除注意效率 |
| | | public event Action<PackType, string> DeleteItemEvent; // 背包类型,GUID |
| | | |
| | | // 单物品刷新 在得到新物品、物品数量的改变,清理该物品时均会触发 ; 但0725整个背包刷新不触发,如果有需要单独数量刷新事件另外处理 |
| | | // 触发比较频繁,界面使用时可以做个汇总后延迟刷新 |
| | | public event Action<PackType, int, int> RefreshItemEvent; //背包类型,位置索引,物品id |
| | | public event Action<PackType> gridRefreshEvent; //背包可用格子数刷新 |
| | | public event Action<int, int> useItemSuccessEvent; //物品使用成功 int 位置索引 int物品id |
| | | |
| | | public event Action<int> refreshItemDayUseCountEvent; //刷新物品每日使用数量 |
| | | public event Action<int> refreshItemSumUseCountEvent; //刷新物品总使用数量 |
| | | |
| | | public bool isPlayBetterEquipEffect { get; set; } //整理背包时是否播放特效 |
| | | |
| | | |
| | | private Dictionary<PackType, SinglePack> playerPackDict = new Dictionary<PackType, SinglePack>(); |
| | | private Dictionary<string, ItemModel> itemGUIDDict = new Dictionary<string, ItemModel>(); |
| | | |
| | | private Dictionary<int, int> PackGirdServerBuyCountDict = new Dictionary<int, int>(); //背包类型:购买格子的次数 |
| | | |
| | | //读表数据 |
| | | public Dictionary<int, int> PackMaxCountDict = new Dictionary<int, int>(); //背包类型:背包格子最大数量 |
| | | public Dictionary<int, int> PackInitCountDict = new Dictionary<int, int>(); //背包类型:初始数量 |
| | | public int initBagGridCount { get; private set; } //初始物品背包格子数 |
| | | public int[] itemPackSortTyps { get; private set; } //背包物品的按类型排序 |
| | | public List<string> composeItemGuidList = new List<string>(); //合成列表物品guid |
| | | |
| | | //开格子 |
| | | public Dictionary<int, int> openGirdMoneyDict = new Dictionary<int, int>(); //背包类型:消耗货币类型 |
| | | public Dictionary<int, int[]> openGirdMoneyValueDict = new Dictionary<int, int[]>(); //背包类型:消耗货币值(按次数定价) |
| | | public Dictionary<int, int[]> openGirdCountDict = new Dictionary<int, int[]>(); //背包类型:每次开的格子数量 |
| | | public static string StrengthAttrShift_RecordKey = ""; |
| | | public const string RecordKnapsackTitle = "RecordKnapsackTitle"; |
| | | |
| | |
| | | Dictionary<int, List<int>> sharedUseCountItemDict { get; set; } |
| | | bool isUpdatePlayerLv = false; |
| | | |
| | | //AlchemyModel alchemyModel { get { return ModelCenter.Instance.GetModel<AlchemyModel>(); } } |
| | | //ItemTipsModel itemTipsModel { get { return ModelCenter.Instance.GetModel<ItemTipsModel>(); } } |
| | | |
| | | List<string> commonShowAwardEvents = new List<string>(); |
| | | |
| | | public int[] gameCashShow; //代金券特殊显示 除以100 |
| | | public int[] autoUseItemIDs; |
| | | public override void Init() |
| | | { |
| | |
| | | // } |
| | | // } |
| | | |
| | | ParseItemCount(); |
| | | |
| | | autoUseItemIDs = JsonMapper.ToObject<int[]>(FuncConfigConfig.Get("ItemTipsNum").Numerical2); |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | // SysNotifyMgr.Instance.sysNotifyEvent -= RefreshSysInfo; |
| | | } |
| | | |
| | | public Dictionary<int, string> textCountShow = new Dictionary<int, string>(); |
| | | public int[] textCountShow2; |
| | | public List<int> gameCashShow = new List<int>(); |
| | | |
| | | public void ParseItemCount() |
| | | { |
| | | var textConfig = FuncConfigConfig.Get("ItemCountShow"); |
| | | var json = JsonMapper.ToObject(textConfig.Numerical1); |
| | | foreach (var key in json.Keys) |
| | | { |
| | | var itemID = int.Parse(key); |
| | | textCountShow[itemID] = json[key].ToString(); |
| | | } |
| | | |
| | | textCountShow2 = JsonMapper.ToObject<int[]>(textConfig.Numerical2); |
| | | gameCashShow = JsonMapper.ToObject<List<int>>(textConfig.Numerical3); |
| | | } |
| | | |
| | | |
| | | private void OnFuncStateChangeEvent(int id) |
| | |
| | | // } |
| | | } |
| | | |
| | | public event Action<PackType> refrechPackEvent; //刷新整个背包数据 |
| | | |
| | | //物品(创建)刷新,可能批量创建注意效率; bool:true代表创建 false 刷新; 注意0707物品数量刷新不包含在此事件 |
| | | public event Action<PackType, string, bool> ChangeItemEvent; // 背包类型,GUID,是否创建 |
| | | |
| | | //删除物品,可能批量删除注意效率 |
| | | public event Action<PackType, string> DeleteItemEvent; // 背包类型,GUID |
| | | |
| | | // 单物品刷新 在得到新物品、物品数量的改变,清理该物品时均会触发 ; 但0725整个背包刷新不触发,如果有需要单独数量刷新事件另外处理 |
| | | // 触发比较频繁,界面使用时可以做个汇总后延迟刷新 |
| | | public event Action<PackType, int, int> RefreshItemEvent; //背包类型,位置索引,物品id |
| | | public event Action<PackType> gridRefreshEvent; //背包可用格子数刷新 |
| | | public event Action<int, int> useItemSuccessEvent; //物品使用成功 int 位置索引 int物品id |
| | | |
| | | public event Action<int> refreshItemDayUseCountEvent; //刷新物品每日使用数量 |
| | | public event Action<int> refreshItemSumUseCountEvent; //刷新物品总使用数量 |
| | | |
| | | public bool isPlayBetterEquipEffect { get; set; } //整理背包时是否播放特效 |
| | | |
| | | #region 接收服务端数据 |
| | | private Dictionary<PackType, SinglePack> playerPackDict = new Dictionary<PackType, SinglePack>(); |
| | | private Dictionary<string, ItemModel> itemGUIDDict = new Dictionary<string, ItemModel>(); |
| | | |
| | | public void UpdatePack(H0725_tagRolePackRefreshEx packInfo) |
| | | { |
| | |
| | | } |
| | | |
| | | |
| | | public void UpdateBuyPackGirdCount(HA207_tagSCPackBuyInfo netPack) |
| | | { |
| | | for (int i = 0; i < netPack.BuyInfoList.Length; i++) |
| | | { |
| | | PackGirdServerBuyCountDict[netPack.BuyInfoList[i].PackType] = netPack.BuyInfoList[i].BuyCnt; |
| | | } |
| | | } |
| | | |
| | | public int[] BuyPackGirdNeedData(PackType packType) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | public void UpdateUnlockedGridCount(H0724_tagRolePackCanUseCount useCount) |
| | | { |
| | |
| | | // } |
| | | // } |
| | | |
| | | #endregion |
| | | |
| | | #region 玩家装备特殊逻辑 |
| | | void ParseConfig() |
| | | { |
| | | var config = FuncConfigConfig.Get("CommonShowAwards"); |
| | | commonShowAwardEvents = JsonMapper.ToObject<List<string>>(config.Numerical1); |
| | | |
| | | config= FuncConfigConfig.Get("InitBagCellCount"); |
| | | ParsePackConfigIni(); |
| | | autoUseItemIDs = JsonMapper.ToObject<int[]>(FuncConfigConfig.Get("AutoUseItem").Numerical1); |
| | | var config= FuncConfigConfig.Get("InitBagCellCount"); |
| | | initBagGridCount = int.Parse(config.Numerical1); |
| | | PackInitCountDict = ConfigParse.ParseIntDict(config.Numerical2); |
| | | |
| | | config = FuncConfigConfig.Get("PackageSortPriority"); |
| | | itemPackSortTyps = ConfigParse.GetMultipleStr<int>(config.Numerical1); |
| | | ParsePackConfigIni(); |
| | | |
| | | config = FuncConfigConfig.Get("OpenPack"); |
| | | openGirdMoneyDict = ConfigParse.ParseIntDict(config.Numerical1); |
| | | openGirdMoneyValueDict = ConfigParse.ParseIntArrayDict(config.Numerical2); |
| | | openGirdCountDict = ConfigParse.ParseIntArrayDict(config.Numerical3); |
| | | |
| | | config = FuncConfigConfig.Get("ItemCountShow"); |
| | | gameCashShow = JsonMapper.ToObject<int[]>(config.Numerical1); |
| | | } |
| | | |
| | | void ParsePackConfigIni() |
| | |
| | | } |
| | | |
| | | return File.ReadAllLines(path); |
| | | } |
| | | |
| | | public int GetCanBuyPackGirdCount(PackType type) |
| | | { |
| | | if (!PackMaxCountDict.ContainsKey((int)type)) |
| | | { |
| | | return 0; |
| | | } |
| | | return PackMaxCountDict[(int)type] - GetSinglePack(type).unlockedGridCount; |
| | | } |
| | | |
| | | |
| | |
| | | { |
| | | int useCnt = 0; |
| | | List<int> shareIdlist = null; |
| | | bool isShare = TryGetShareNumItem(itemId, out shareIdlist); |
| | | if (isShare) |
| | | { |
| | | foreach (var id in shareIdlist) |
| | | { |
| | | int singleUseCnt = 0; |
| | | itemDayUseCntDict.TryGetValue(id, out singleUseCnt); |
| | | useCnt += singleUseCnt; |
| | | } |
| | | } |
| | | else |
| | | // bool isShare = TryGetShareNumItem(itemId, out shareIdlist); |
| | | // if (isShare) |
| | | // { |
| | | // foreach (var id in shareIdlist) |
| | | // { |
| | | // int singleUseCnt = 0; |
| | | // itemDayUseCntDict.TryGetValue(id, out singleUseCnt); |
| | | // useCnt += singleUseCnt; |
| | | // } |
| | | // } |
| | | // else |
| | | { |
| | | itemDayUseCntDict.TryGetValue(itemId, out useCnt); |
| | | } |
| | |
| | | const int ITEMPACK_REDKEY = 102011003; |
| | | Redpoint redpointItemPack = new Redpoint(MainRedDot.RedPoint_BagFuncKey, ITEMPACK_REDKEY); |
| | | |
| | | const int LS_REDKEY = 102011015; |
| | | Redpoint redpointLS = new Redpoint(MainRedDot.RedPoint_BagFuncKey, LS_REDKEY); |
| | | |
| | | |
| | | private void UpdatePackRedpoint(PackType type) |
| | | { |
| | |
| | | } |
| | | |
| | | break; |
| | | case PackType.Warehouse: |
| | | if (singlePack.GetEmptyGridCount() <= 0) |
| | | { |
| | | MainRedDot.Instance.redPointDepotFunc.state = RedPointState.Full; |
| | | } |
| | | else |
| | | { |
| | | MainRedDot.Instance.redPointDepotFunc.state = RedPointState.None; |
| | | } |
| | | break; |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | #endregion |
| | | |
| | | #region 判断物品是否达到使用上限 |
| | | // public bool IsReachUseLimit(string guid, out ulong count) |
| | | // { |
| | | // count = 0; |
| | | // ItemModel itemModel = GetItemByGuid(guid); |
| | | // if (itemModel == null) return false; |
| | | public bool IsReachUseLimit(string guid, out ulong count) |
| | | { |
| | | count = 0; |
| | | ItemModel itemModel = GetItemByGuid(guid); |
| | | if (itemModel == null) return false; |
| | | |
| | | // AttrFruitConfig fruitConfig = AttrFruitConfig.Get(itemModel.itemId); |
| | | // int haveUseCnt = GetItemUsedTimesToday(itemModel.itemId); |
| | | // int sumHaveUseCnt = GetItemTotalUsedTimes(itemModel.itemId); |
| | | // count = (ulong)itemModel.count; |
| | | // bool isReach = false; |
| | | // int remainDayCnt = 0; |
| | | // if (itemModel.config.MaxSkillCnt > 0) |
| | | // { |
| | | // remainDayCnt = itemModel.config.MaxSkillCnt - haveUseCnt; |
| | | // if (itemModel.count > remainDayCnt) |
| | | // { |
| | | // count = (ulong)remainDayCnt; |
| | | // } |
| | | // } |
| | | int haveUseCnt = GetItemUsedTimesToday(itemModel.itemId); |
| | | int sumHaveUseCnt = GetItemTotalUsedTimes(itemModel.itemId); |
| | | count = (ulong)itemModel.count; |
| | | bool isReach = false; |
| | | int remainDayCnt = 0; |
| | | if (itemModel.config.MaxSkillCnt > 0) |
| | | { |
| | | remainDayCnt = itemModel.config.MaxSkillCnt - haveUseCnt; |
| | | if (itemModel.count > remainDayCnt) |
| | | { |
| | | count = (ulong)remainDayCnt; |
| | | } |
| | | } |
| | | |
| | | // int remainSumCnt = 0; |
| | | int remainSumCnt = 0; |
| | | // if (fruitConfig != null) |
| | | // { |
| | | // remainSumCnt = fruitConfig.basicUseLimit - sumHaveUseCnt; |
| | |
| | | // } |
| | | // } |
| | | |
| | | // if (count < (ulong)itemModel.count) |
| | | // { |
| | | // isReach = true; |
| | | // } |
| | | if (count < (ulong)itemModel.count) |
| | | { |
| | | isReach = true; |
| | | } |
| | | |
| | | // return isReach; |
| | | // } |
| | | return isReach; |
| | | } |
| | | #endregion |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | public void ReceiveAwardNotify(HA801_tagMCGiveAwardInfo netPack) |
| | | { |
| | | var eventName = UIHelper.ServerStringTrim(netPack.EventName); |
| | | if (eventName == "BuyItem") |
| | | return; |
| | | |
| | | // 仙盟攻城战 |
| | | // if (eventName == "FamilyGCZSQGrid" || eventName == "FamilyGCZSQPass" || eventName == "FamilyGCZSQPassAll" || |
| | | // eventName == "FamilyGCZContiribution" || eventName == "FamilyGCZAtk") |
| | | // { |
| | | // ModelCenter.Instance.GetModel<FairySiegeActModel>()?.OnUpdateAwardInfoAction(netPack); |
| | | // return; |
| | | // } |
| | | if (!commonShowAwardEvents.Contains(eventName)) |
| | | return; |
| | | |
| | | List<Item> showItems = new List<Item>(); |
| | | |
| | | if (netPack.Exp != 0 || netPack.ExpPoint != 0) |
| | | { |
| | | ulong expValue = netPack.Exp + netPack.ExpPoint * (ulong)Constants.ExpPointValue; |
| | | showItems.Add(new Item(GeneralDefine.expDisplayId, expValue)); |
| | | } |
| | | if (netPack.MoneyList.Length != 0) |
| | | { |
| | | for (int i = 0; i < netPack.MoneyLen; i++) |
| | | { |
| | | var moneyType = netPack.MoneyList[i].MoneyType; |
| | | if (GeneralDefine.moneyDisplayIds.ContainsKey(moneyType) && netPack.MoneyList[i].MoneyValue != 0) |
| | | { |
| | | showItems.Add(new Item(GeneralDefine.moneyDisplayIds[moneyType], netPack.MoneyList[i].MoneyValue)); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | if (netPack.ItemList.Length != 0) |
| | | { |
| | | for (int i = 0; i < netPack.ItemLen; i++) |
| | | { |
| | | showItems.Add(new Item((int)netPack.ItemList[i].ItemID, netPack.ItemList[i].Count, netPack.ItemList[i].IsBind)); |
| | | } |
| | | } |
| | | |
| | | |
| | | string info = string.Empty; |
| | | if (LanguageConfig.HasKey("commonShowAwardEvents_" + eventName)) |
| | | info = Language.Get("commonShowAwardEvents_" + eventName); |
| | | |
| | | if (showItems.Count == 0) |
| | | return; |
| | | |
| | | ItemLogicUtility.Instance.ShowGetItem(showItems, info, 0, eventName: eventName); |
| | | } |
| | | } |