| | |
| | | using System.Linq; |
| | | using UnityEngine; |
| | | using LitJson; |
| | | using System.Text.RegularExpressions; |
| | | using System.Collections; |
| | | using System.IO; |
| | | |
| | | public class PackManager : GameSystemManager<PackManager> |
| | | //public class PackModel : Model, IBeforePlayerDataInitialize, IAfterPlayerDataInitialize, IPlayerLoginOk |
| | | { |
| | | public event Action<PackType> refrechPackEvent; //刷新整个背包数据 |
| | | |
| | | //物品(创建)刷新,可能批量创建注意效率; bool:true代表创建 false 刷新; 注意0707物品数量刷新不包含在此事件 |
| | | public event Action<PackType, string, bool> ChangeItemEvent; // 背包类型,GUID,是否创建 |
| | | |
| | | //删除物品,可能批量删除注意效率 |
| | | public event Action<PackType, string, int, int, int> DeleteItemEvent; // 背包类型,GUID, 物品ID,索引, 删除原因 |
| | | |
| | | // 单物品刷新 在得到新物品、物品数量的改变,清理该物品时均会触发 ; 但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 event Action<PackType, string, bool> RefreshItemLockEvent; //物品锁定刷新 背包类型,guid,锁定状态 |
| | | |
| | | |
| | | 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 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() |
| | | { |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize; |
| | | DTC0102_tagCDBPlayer.afterPlayerDataInitializeEvent += OnAfterPlayerDataInitialize; |
| | | DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent += OnPlayerLoginOk; |
| | | ParseConfig(); |
| | | //SysNotifyMgr.Instance.sysNotifyEvent += RefreshSysInfo; |
| | |
| | | // } |
| | | // } |
| | | |
| | | ParseItemCount(); |
| | | |
| | | autoUseItemIDs = JsonMapper.ToObject<int[]>(FuncConfigConfig.Get("ItemTipsNum").Numerical2); |
| | | |
| | | } |
| | | |
| | | |
| | | public override void Release() |
| | | { |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitialize; |
| | | DTC0102_tagCDBPlayer.afterPlayerDataInitializeEvent -= OnAfterPlayerDataInitialize; |
| | | DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent -= OnPlayerLoginOk; |
| | | FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent; |
| | | // 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) |
| | |
| | | itemDayUseCntDict.Clear(); |
| | | itemSumUseCntDict.Clear(); |
| | | itemGUIDDict.Clear(); |
| | | isPlayBetterEquipEffect = false; |
| | | PackGirdServerBuyCountDict.Clear(); |
| | | } |
| | | |
| | | public void OnAfterPlayerDataInitialize() |
| | | { |
| | | |
| | | } |
| | | |
| | | public void OnPlayerLoginOk() |
| | | { |
| | |
| | | // } |
| | | } |
| | | |
| | | public event Action<PackType> refrechPackEvent; //刷新整个背包数据 |
| | | public event Action<PackType, string, bool> ChangeItemEvent; //物品刷新,可能批量创建注意效率; bool:true代表创建 false 刷新 |
| | | public event Action<PackType, string> DeleteItemEvent; //删除物品,可能批量删除注意效率 |
| | | public event Action<PackType, int, int> refreshItemCountEvent; // 慎用会卡(单个)最新物品数量刷新(旧的弃用)在得到新物品、物品数量的改变,清理该物品时均会触发 int 位置索引 int物品id |
| | | public event Action<PackType> gridRefreshEvent; //背包空格刷新 |
| | | public event Action<PackType, int, int> itemCntAddEvent; //物品数量增加 int 位置索引 int物品id |
| | | public event Action<PackType, int, int> itemCntReduceEvent; //物品数量减少的改变 int 位置索引 int物品id |
| | | 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) |
| | | { |
| | |
| | | playerPackDict.Add(packType, new SinglePack(packType)); |
| | | } |
| | | |
| | | if (isPlayBetterEquipEffect) |
| | | { |
| | | ItemLogicUtility.Instance.ClearSortedBetterEquip(); |
| | | } |
| | | |
| | | for (int i = 0; i < packInfo.ItemCount; i++) |
| | | { |
| | | var itemInfo = new ItemInfo(packInfo.ItemInfo[i]); |
| | | var item = playerPackDict[packType].UpdateItem(itemInfo); |
| | | AddItemGUIDDict(item, false); |
| | | AddItemGUIDDict(item, true); |
| | | |
| | | if (isPlayBetterEquipEffect) |
| | | { |
| | | ItemLogicUtility.Instance.SetBagSortBetterEquipList(GetItemByGuid(itemInfo.guid)); |
| | | } |
| | | |
| | | } |
| | | |
| | | if (refrechPackEvent != null) |
| | |
| | | |
| | | public void UpdateItem(H0704_tagRolePackRefresh serverItem) |
| | | { |
| | | isPlayBetterEquipEffect = false; |
| | | SetLookIndex(null); |
| | | PackType type = (PackType)serverItem.PackType; |
| | | if (!playerPackDict.ContainsKey(type)) |
| | |
| | | var item = playerPackDict[type].UpdateItem(itemInfo); |
| | | AddItemGUIDDict(item, showNewItem); |
| | | |
| | | if (refreshItemCountEvent != null) |
| | | if (RefreshItemEvent != null) |
| | | { |
| | | refreshItemCountEvent(type, itemInfo.index, itemInfo.itemId); |
| | | RefreshItemEvent(type, itemInfo.index, itemInfo.itemId); |
| | | } |
| | | |
| | | if (itemCntAddEvent != null) |
| | | { |
| | | itemCntAddEvent(type, itemInfo.index, itemInfo.itemId); |
| | | } |
| | | |
| | | // if (type == PackType.Equip) |
| | | // { |
| | |
| | | } |
| | | |
| | | |
| | | public void UpdateItemLockState(H0722_tagItemDeadLockRefresh netPack) |
| | | { |
| | | var singlePack = GetSinglePack((PackType)netPack.PackType); |
| | | var item = singlePack.GetItemByIndex(netPack.ItemIndex); |
| | | if (item == null) |
| | | { |
| | | return; |
| | | } |
| | | item.itemInfo.isLock = netPack.IsLock == 1; |
| | | RefreshItemLockEvent?.Invoke((PackType)netPack.PackType, item.guid, item.itemInfo.isLock); |
| | | } |
| | | |
| | | 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) |
| | | { |
| | | var curPackGirdCnt = GetSinglePack(packType).unlockedGridCount; |
| | | if (curPackGirdCnt >= PackMaxCountDict[(int)packType]) |
| | | return null; |
| | | |
| | | int buyTimes = 0; |
| | | PackGirdServerBuyCountDict.TryGetValue((int)packType, out buyTimes); |
| | | var moneyType = openGirdMoneyDict[(int)packType]; |
| | | var moneyCntList = openGirdMoneyValueDict[(int)packType]; |
| | | var money = moneyCntList[Math.Min(buyTimes, moneyCntList.Length - 1)]; |
| | | var girdCntList = openGirdCountDict[(int)packType]; |
| | | var buyGirdCnt = girdCntList[Math.Min(buyTimes, girdCntList.Length - 1)]; |
| | | return new[] {moneyType, money, buyGirdCnt}; |
| | | } |
| | | |
| | | public void BuyPackGird(PackType packType) |
| | | { |
| | | var netPack = new C0741_tagCOpenPackCount(); |
| | | netPack.PackType = (byte)packType; |
| | | GameNetSystem.Instance.SendInfo(netPack); |
| | | } |
| | | |
| | | public void UpdateUnlockedGridCount(H0724_tagRolePackCanUseCount useCount) |
| | | { |
| | |
| | | UpdatePackRedpoint(type); |
| | | } |
| | | |
| | | |
| | | |
| | | public void RefreshItemCount(H0707_tagItemCountRefresh refresh) |
| | | { |
| | | SetLookIndex(null); |
| | | isPlayBetterEquipEffect = false; |
| | | PackType type = (PackType)refresh.PackType; |
| | | SinglePack singlePack = null; |
| | | playerPackDict.TryGetValue(type, out singlePack); |
| | |
| | | ItemModel itemModel = singlePack.GetItemByIndex(refresh.ItemIndex); |
| | | if (itemModel != null) |
| | | { |
| | | bool isAddItemCount = false; |
| | | if (refresh.ItemCount > itemModel.count) |
| | | { |
| | | isAddItemCount = true; |
| | | } |
| | | |
| | | itemModel.RefreshCount((int)refresh.ItemCount); |
| | | |
| | | if (isAddItemCount) |
| | | if (RefreshItemEvent != null) |
| | | { |
| | | if (itemCntAddEvent != null) |
| | | { |
| | | itemCntAddEvent(type, itemModel.gridIndex, itemModel.itemId); |
| | | } |
| | | ItemLogicUtility.Instance.RefreshPickItem(type, itemModel.itemId.ToString()); |
| | | } |
| | | else |
| | | { |
| | | if (itemCntReduceEvent != null) |
| | | { |
| | | itemCntReduceEvent(type, itemModel.gridIndex, itemModel.itemId); |
| | | } |
| | | } |
| | | |
| | | if (refreshItemCountEvent != null) |
| | | { |
| | | refreshItemCountEvent(type, itemModel.gridIndex, itemModel.itemId); |
| | | RefreshItemEvent(type, itemModel.gridIndex, itemModel.itemId); |
| | | } |
| | | |
| | | } |
| | |
| | | DeleteItemDictByGUID(type, guid); |
| | | } |
| | | } |
| | | |
| | | |
| | | refrechPackEvent?.Invoke(type); |
| | | } |
| | | |
| | | public void RemoveItem(H0709_tagClearItem clearItem) |
| | | { |
| | | isPlayBetterEquipEffect = false; |
| | | SetLookIndex(null); |
| | | PackType type = (PackType)clearItem.PackType; |
| | | |
| | |
| | | guid = itemModel.guid; |
| | | int itemId = itemModel.itemId; |
| | | |
| | | DeleteItemDictByGUID(type, itemModel.guid); |
| | | |
| | | singlePack.RemoveItem(clearItem.ItemIndex); |
| | | if (refreshItemCountEvent != null) |
| | | DeleteItemDictByGUID(type, itemModel.guid,itemId, clearItem.ItemIndex, clearItem.ClearType); |
| | | |
| | | if (RefreshItemEvent != null) |
| | | { |
| | | refreshItemCountEvent(type, clearItem.ItemIndex, itemId); |
| | | RefreshItemEvent(type, clearItem.ItemIndex, itemId); |
| | | } |
| | | |
| | | if (itemCntReduceEvent != null) |
| | | { |
| | | itemCntReduceEvent(type, clearItem.ItemIndex, itemId); |
| | | } |
| | | } |
| | | |
| | | UpdatePackRedpoint(type); |
| | |
| | | |
| | | public void UseItemSuccess(H0706_tagUseItemSuccess success) |
| | | { |
| | | isPlayBetterEquipEffect = false; |
| | | SetLookIndex(null); |
| | | if (success.PlayerID != PlayerDatas.Instance.baseData.PlayerID) |
| | | { |
| | |
| | | ChangeItemEvent?.Invoke(itemModel.packType, itemModel.guid, showNewItem); |
| | | } |
| | | |
| | | void DeleteItemDictByGUID(PackType type, string guid) |
| | | void DeleteItemDictByGUID(PackType type, string guid, int itemID = 0, int index = 0, int clearType = -1) |
| | | { |
| | | if (itemGUIDDict.ContainsKey(guid)) |
| | | { |
| | | if (itemGUIDDict[guid].packType == type) |
| | | { |
| | | itemGUIDDict.Remove(guid); |
| | | DeleteItemEvent?.Invoke(type, guid); |
| | | } |
| | | //只是背包转移,不删除但也要通知 |
| | | DeleteItemEvent?.Invoke(type, guid, itemID, index, clearType); |
| | | } |
| | | } |
| | | |
| | |
| | | // } |
| | | // } |
| | | |
| | | #endregion |
| | | |
| | | #region 玩家装备特殊逻辑 |
| | | void ParseConfig() |
| | | { |
| | | |
| | | |
| | | var config = FuncConfigConfig.Get("CommonShowAwards"); |
| | | commonShowAwardEvents = JsonMapper.ToObject<List<string>>(config.Numerical1); |
| | | ParsePackConfigIni(); |
| | | autoUseItemIDs = JsonMapper.ToObject<int[]>(FuncConfigConfig.Get("AutoUseItem").Numerical1); |
| | | var config= FuncConfigConfig.Get("InitBagCellCount"); |
| | | initBagGridCount = int.Parse(config.Numerical1); |
| | | |
| | | config = FuncConfigConfig.Get("PackageSortPriority"); |
| | | itemPackSortTyps = ConfigParse.GetMultipleStr<int>(config.Numerical1); |
| | | |
| | | 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() |
| | | { |
| | | string[] lines = LoadConfigIni("MapServerConfig"); |
| | | foreach (string line in lines) |
| | | { |
| | | if (line.StartsWith("PackCnt") && line.Contains("=")) |
| | | { |
| | | string[] parts = line.Split('='); |
| | | if (parts.Length == 2 && int.TryParse(parts[1], out int count)) |
| | | { |
| | | string packTypeStr = parts[0].Replace("PackCnt", ""); |
| | | if (int.TryParse(packTypeStr, out int packTypeIndex)) |
| | | { |
| | | PackMaxCountDict[packTypeIndex] = count; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | public string[] LoadConfigIni(string name) |
| | | { |
| | | string path = string.Empty; |
| | | #if UNITY_EDITOR |
| | | if (!AssetSource.isUseAssetBundle) |
| | | { |
| | | path = ResourcesPath.CONFIG_FODLER + "/" + name + ".ini"; |
| | | } |
| | | else |
| | | #endif |
| | | { |
| | | //从服务端拷贝是ini,打包用txt统一处理 |
| | | path = AssetVersionUtility.GetAssetFilePath($"Config/{name}.txt"); |
| | | } |
| | | |
| | | return File.ReadAllLines(path); |
| | | } |
| | | |
| | | public int GetCanBuyPackGirdCount(PackType type) |
| | | { |
| | | if (!PackMaxCountDict.ContainsKey((int)type)) |
| | | { |
| | | return 0; |
| | | } |
| | | return PackMaxCountDict[(int)type] - GetSinglePack(type).unlockedGridCount; |
| | | } |
| | | |
| | | |
| | | private void UpdateSecond() |
| | |
| | | public SinglePack GetSinglePack(PackType type) |
| | | { |
| | | SinglePack singlePack = null; |
| | | playerPackDict.TryGetValue(type, out singlePack); |
| | | if (!playerPackDict.TryGetValue(type, out singlePack)) |
| | | { |
| | | singlePack = new SinglePack(type); |
| | | playerPackDict.Add(type, singlePack); |
| | | } |
| | | return singlePack; |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | public List<ItemModel> GetItems(PackType packType) |
| | | { |
| | | if (playerPackDict.ContainsKey(packType)) |
| | | { |
| | | return playerPackDict[packType].GetItems(); |
| | | } |
| | | else |
| | | { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | //通过id找物品,注意检查是否指定背包 |
| | | public string GetItemGUIDByID(int itemId, bool includeAuction = true, PackType packType = PackType.Item) |
| | | { |
| | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 得到ID相同的物品数量 |
| | | /// 得到ID相同的物品数量; 也可以获得部分货币和物品绑定的数量 |
| | | /// </summary> |
| | | /// <param name="type"></param> |
| | | /// <param name="id"></param> |
| | | /// <returns></returns> |
| | | public int GetItemCountByID(PackType type, int id, bool includeAuction = true) |
| | | public long GetItemCountByID(PackType type, int id, bool includeAuction = true) |
| | | { |
| | | int count = 0; |
| | | long count = 0; |
| | | var singlePack = GetSinglePack(type); |
| | | if (singlePack != null) |
| | | { |
| | |
| | | { |
| | | 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; |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | public void SetLookIndex(string guid, int singleRowCount = 5) |
| | | { |
| | | if (string.IsNullOrEmpty(guid) || guid == "") |
| | | { |
| | | lookLineIndex = -1; |
| | | lookItemGUID = ""; |
| | | } |
| | | else |
| | | { |
| | | int index = GetItemByGuid(guid).gridIndex; |
| | | lookLineIndex = index / singleRowCount; |
| | | lookItemGUID = guid; |
| | | } |
| | | return; |
| | | // if (string.IsNullOrEmpty(guid) || guid == "") |
| | | // { |
| | | // lookLineIndex = -1; |
| | | // lookItemGUID = ""; |
| | | // } |
| | | // else |
| | | // { |
| | | // int index = GetItemByGuid(guid).gridIndex; |
| | | // lookLineIndex = index / singleRowCount; |
| | | // lookItemGUID = guid; |
| | | // } |
| | | |
| | | if (lookEquipEvent != null) |
| | | { |
| | | lookEquipEvent(); |
| | | } |
| | | // if (lookEquipEvent != null) |
| | | // { |
| | | // lookEquipEvent(); |
| | | // } |
| | | } |
| | | |
| | | public event Action RefreshBagEvent; |
| | |
| | | |
| | | private void AddItemUseTypeDict(int id) |
| | | { |
| | | SkillConfig skillConfig = GetSkillConfig(id); |
| | | int itemCount = GetItemCountByID(PackType.Item, id); |
| | | if (skillConfig != null && itemCount > 0) |
| | | { |
| | | if (!itemUseTypeDict.ContainsKey(skillConfig.SkillTypeID)) |
| | | { |
| | | itemUseTypeDict.Add(skillConfig.SkillTypeID, id); |
| | | } |
| | | else |
| | | { |
| | | SkillConfig preSkillConfig = GetSkillConfig(itemUseTypeDict[skillConfig.SkillTypeID]); |
| | | if (skillConfig.SkillLV > preSkillConfig.SkillLV) |
| | | { |
| | | itemUseTypeDict[skillConfig.SkillTypeID] = id; |
| | | } |
| | | } |
| | | } |
| | | // SkillConfig skillConfig = GetSkillConfig(id); |
| | | // int itemCount = GetItemCountByID(PackType.Item, id); |
| | | // if (skillConfig != null && itemCount > 0) |
| | | // { |
| | | // if (!itemUseTypeDict.ContainsKey(skillConfig.SkillTypeID)) |
| | | // { |
| | | // itemUseTypeDict.Add(skillConfig.SkillTypeID, id); |
| | | // } |
| | | // else |
| | | // { |
| | | // SkillConfig preSkillConfig = GetSkillConfig(itemUseTypeDict[skillConfig.SkillTypeID]); |
| | | // if (skillConfig.SkillLV > preSkillConfig.SkillLV) |
| | | // { |
| | | // itemUseTypeDict[skillConfig.SkillTypeID] = id; |
| | | // } |
| | | // } |
| | | // } |
| | | } |
| | | |
| | | |
| | |
| | | #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; |
| | | // } |
| | | // } |
| | | // 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 remainSumCnt = 0; |
| | | // if (fruitConfig != null) |
| | | // { |
| | | // remainSumCnt = fruitConfig.basicUseLimit - sumHaveUseCnt; |
| | | // if (remainSumCnt <= remainDayCnt && itemModel.count > remainSumCnt) |
| | | // { |
| | | // count = (ulong)remainSumCnt; |
| | | // } |
| | | // } |
| | | int remainSumCnt = 0; |
| | | // if (fruitConfig != null) |
| | | // { |
| | | // remainSumCnt = fruitConfig.basicUseLimit - sumHaveUseCnt; |
| | | // if (remainSumCnt <= remainDayCnt && itemModel.count > remainSumCnt) |
| | | // { |
| | | // count = (ulong)remainSumCnt; |
| | | // } |
| | | // } |
| | | |
| | | // 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); |
| | | } |
| | | } |