少年修仙传客户端代码仓库
hch
2019-11-06 00b138479540bb0877eccff23fbc56f570fa5a98
0312 主界面物品快捷使用 经验丹物品优先显示 物品类型13
2个文件已修改
68 ■■■■■ 已修改文件
System/BetterItemGet/PreciousItemGetModel.cs 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/KnapSack/Logic/ItemLogicUtility.cs 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/BetterItemGet/PreciousItemGetModel.cs
@@ -14,6 +14,7 @@
    {
        Dictionary<string, PreciousItem> itemStack = new Dictionary<string, PreciousItem>();
        List<string> itemGuids = new List<string>();
        List<string> itemExpGuids = new List<string>();
        PackModel playerPack { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
        DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
@@ -27,6 +28,7 @@
        public override void Init()
        {
            ItemLogicUtility.Instance.GetPreciousItemEvent += OnGetPreciousItem;
            ItemLogicUtility.Instance.GetExpItemEvent += OnGetPreciousExpItem;
            playerPack.refrechPackEvent += OnPackageRefresh;
            playerPack.refreshItemCountEvent += OnPackageItemRefresh;
            FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;
@@ -35,6 +37,7 @@
        public override void UnInit()
        {
            ItemLogicUtility.Instance.GetPreciousItemEvent -= OnGetPreciousItem;
            ItemLogicUtility.Instance.GetExpItemEvent -= OnGetPreciousExpItem;
            playerPack.refrechPackEvent -= OnPackageRefresh;
            playerPack.refreshItemCountEvent -= OnPackageItemRefresh;
            FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
@@ -72,6 +75,11 @@
            if (string.IsNullOrEmpty(_preciousItem.guid))
            {
                return;
            }
            if (itemExpGuids.Contains(_preciousItem.guid))
            {
                itemExpGuids.Remove(_preciousItem.guid);
            }
            if (itemGuids.Contains(_preciousItem.guid))
@@ -154,6 +162,19 @@
            RefreshCurrrentShowPreciousItem();
        }
        private void OnGetPreciousExpItem(PackType type, string guid)
        {
            var preciousItem = new PreciousItem(type, guid);
            if (!itemExpGuids.Contains(guid))
            {
                itemExpGuids.Add(guid);
            }
            itemStack[guid] = preciousItem;
            RefreshCurrrentShowPreciousItem();
        }
        private void OnPackageRefresh(PackType _type)
        {
            if (_type != PackType.Item)
@@ -183,13 +204,22 @@
        private bool FindLatestItem(out PreciousItem _item)
        {
            if (itemGuids.Count == 0)
            string guid;
            if (itemExpGuids.Count == 0)
            {
                _item = default(PreciousItem);
                return false;
            }
                if (itemGuids.Count == 0)
                {
                    _item = default(PreciousItem);
                    return false;
                }
                else
                    guid = itemGuids[itemGuids.Count - 1];
            var guid = itemGuids[itemGuids.Count - 1];
            }
            else
                guid = itemExpGuids[itemExpGuids.Count - 1];
            _item = itemStack[guid];
            return true;
        }
@@ -227,6 +257,16 @@
        private void Trim()
        {
            for (int i = itemExpGuids.Count - 1; i >= 0; i--)
            {
                var item = itemStack[itemExpGuids[i]];
                if (playerPack.GetItemByGuid(item.guid) == null
                    || playerPack.GetItemByGuid(item.guid).packType != PackType.Item)
                {
                    itemExpGuids.RemoveAt(i);
                }
            }
            for (int i = itemGuids.Count - 1; i >= 0; i--)
            {
                var item = itemStack[itemGuids[i]];
System/KnapSack/Logic/ItemLogicUtility.cs
@@ -416,7 +416,7 @@
        #region 主界面物品弹框展示
        public event Action<PackType, string> GetPreciousItemEvent; //得到珍品  value 物品的实例ID
        public event Action<PackType, string> GetExpItemEvent; //得到经验物品  value 物品的实例ID
        public void RecommendItem(ItemModel item)
        {
            if (!preciousItemTypes.Contains(item.config.Type))
@@ -456,10 +456,20 @@
                    return;
                }
            }
            if (GetPreciousItemEvent != null)
            if (item.config.Type == 13)
            {
                GetPreciousItemEvent(item.packType, item.guid);
                if (GetExpItemEvent != null)
                {
                    GetExpItemEvent(item.packType, item.guid);
                }
            }
            else
            {
                if (GetPreciousItemEvent != null)
                {
                    GetPreciousItemEvent(item.packType, item.guid);
                }
            }
        }