| | |
| | | {
|
| | | 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>(); } }
|
| | |
| | | public override void Init()
|
| | | {
|
| | | ItemLogicUtility.Instance.GetPreciousItemEvent += OnGetPreciousItem;
|
| | | ItemLogicUtility.Instance.GetExpItemEvent += OnGetPreciousExpItem;
|
| | | playerPack.refrechPackEvent += OnPackageRefresh;
|
| | | playerPack.refreshItemCountEvent += OnPackageItemRefresh;
|
| | | FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;
|
| | |
| | | public override void UnInit()
|
| | | {
|
| | | ItemLogicUtility.Instance.GetPreciousItemEvent -= OnGetPreciousItem;
|
| | | ItemLogicUtility.Instance.GetExpItemEvent -= OnGetPreciousExpItem;
|
| | | playerPack.refrechPackEvent -= OnPackageRefresh;
|
| | | playerPack.refreshItemCountEvent -= OnPackageItemRefresh;
|
| | | FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
|
| | |
| | | if (string.IsNullOrEmpty(_preciousItem.guid))
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | if (itemExpGuids.Contains(_preciousItem.guid))
|
| | | {
|
| | | itemExpGuids.Remove(_preciousItem.guid);
|
| | | }
|
| | |
|
| | | if (itemGuids.Contains(_preciousItem.guid))
|
| | |
| | | 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)
|
| | |
| | |
|
| | | 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;
|
| | | }
|
| | |
| | |
|
| | | 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]];
|