From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Assets/Scripts/XMainClient/XNewItemTipsMgr.cs | 111 +++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XNewItemTipsMgr.cs (limited to 'Client/Assets/Scripts/XMainClient/XNewItemTipsMgr.cs') diff --git a/Client/Assets/Scripts/XMainClient/XNewItemTipsMgr.cs b/Client/Assets/Scripts/XMainClient/XNewItemTipsMgr.cs new file mode 100644 index 00000000..f2f9fd93 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XNewItemTipsMgr.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; + +namespace XMainClient +{ + internal class XNewItemTipsMgr + { + public HashSet NewItems + { + get + { + return this._NewItems; + } + } + + public XItemFilter Filter + { + get + { + return this._Filter; + } + } + + public bool bCanClear { get; set; } + + public bool bHasNew + { + get + { + return this._NewItems.Count > 0; + } + } + + private HashSet _NewItems = new HashSet(); + + private XItemFilter _Filter = new XItemFilter(); + + public void ClearItemType() + { + this.Clear(); + this._Filter.Clear(); + this.bCanClear = false; + } + + public bool AddItem(XItem item, bool bDontSave = false) + { + bool flag = this._Filter.Contains(item.Type); + bool result; + if (flag) + { + bool flag2 = !bDontSave; + if (flag2) + { + this._NewItems.Add(item.uid); + } + result = true; + } + else + { + result = false; + } + return result; + } + + public bool AddItems(List items, bool bDontSave = false) + { + bool flag = false; + for (int i = 0; i < items.Count; i++) + { + flag = (this.AddItem(items[i], bDontSave) || flag); + } + return flag; + } + + public bool RemoveItem(ulong uid, ItemType type, bool bConsiderFilter = false) + { + bool flag = this._Filter.Contains(type); + return flag && (this._NewItems.Remove(uid) || bConsiderFilter); + } + + public bool RemoveItems(List items, List types, bool bConsiderFilter = true) + { + bool flag = false; + for (int i = 0; i < items.Count; i++) + { + flag = (this.RemoveItem(items[i], types[i], bConsiderFilter) || flag); + } + return flag; + } + + public void TryClear() + { + bool bCanClear = this.bCanClear; + if (bCanClear) + { + this.Clear(); + } + } + + public void Clear() + { + this._NewItems.Clear(); + this.bCanClear = false; + } + + public bool IsNew(ulong uid) + { + return this._NewItems.Contains(uid); + } + } +} -- cgit v1.1-26-g67d0