122 子 【武将】武将系统 / 【武将】武将系统-客户端 - 武将变化
| | |
| | | base.Init(); |
| | | |
| | | PackManager.Instance.refrechPackEvent += refrechPackEvent; |
| | | PackManager.Instance.CreateItemEvent += CreateHero; |
| | | PackManager.Instance.ChangeItemEvent += ChangeHero; |
| | | PackManager.Instance.DeleteItemEvent += DeleteHero; |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize; |
| | | } |
| | |
| | | { |
| | | base.Release(); |
| | | PackManager.Instance.refrechPackEvent -= refrechPackEvent; |
| | | PackManager.Instance.CreateItemEvent -= CreateHero; |
| | | PackManager.Instance.ChangeItemEvent -= ChangeHero; |
| | | PackManager.Instance.DeleteItemEvent -= DeleteHero; |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitialize; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | void CreateHero(PackType packType, string guid) |
| | | // isCreate bool:true代表创建 false 刷新触发 |
| | | void ChangeHero(PackType packType, string guid, bool isCreate) |
| | | { |
| | | if (packType == PackType.Hero) |
| | | { |
| | |
| | | |
| | | foreach (ItemModel hero in heroes.Values) |
| | | { |
| | | CreateHero(hero.packType, hero.guid); |
| | | ChangeHero(hero.packType, hero.guid, true); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | public event Action<PackType> refrechPackEvent; //刷新整个背包数据 |
| | | public event Action<PackType, string> CreateItemEvent; //得到新物品,可能批量创建注意效率 |
| | | 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; //背包空格刷新 |
| | |
| | | { |
| | | itemGUIDDict[itemModel.guid] = itemModel; |
| | | GetItemEventCtrl(itemModel, showNewItem); |
| | | if (showNewItem) |
| | | { |
| | | CreateItemEvent?.Invoke(itemModel.packType, itemModel.guid); |
| | | } |
| | | ChangeItemEvent?.Invoke(itemModel.packType, itemModel.guid, showNewItem); |
| | | } |
| | | |
| | | void DeleteItemDictByGUID(PackType type, string guid) |
| | |
| | | return guid; |
| | | } |
| | | |
| | | //通过index找GUID |
| | | public string GetItemGUIDByIndex(PackType packType, int index) |
| | | { |
| | | string guid = string.Empty; |
| | | if (playerPackDict.ContainsKey(packType)) |
| | | { |
| | | var items = playerPackDict[packType].GetAllItems(); |
| | | guid = items[index].guid; |
| | | } |
| | | |
| | | return guid; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 得到ID相同的物品数量 |
| | | /// </summary> |