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/XItemDrawerMgr.cs | 149 +++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XItemDrawerMgr.cs (limited to 'Client/Assets/Scripts/XMainClient/XItemDrawerMgr.cs') diff --git a/Client/Assets/Scripts/XMainClient/XItemDrawerMgr.cs b/Client/Assets/Scripts/XMainClient/XItemDrawerMgr.cs new file mode 100644 index 00000000..ee54fc63 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XItemDrawerMgr.cs @@ -0,0 +1,149 @@ +using System; +using UnityEngine; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XItemDrawerMgr : XSingleton + { + public GameObject LeftDownCornerGo; + + public GameObject LeftUpCornerGo; + + public GameObject RightDownCornerGo; + + public GameObject RightUpCornerGo; + + public GameObject MaskGo; + + public GameObject ProfGo; + + public XNormalItemDrawer normalItemDrawer = new XNormalItemDrawer(); + + public XEquipItemDrawer equipItemDrawer = new XEquipItemDrawer(); + + public XJadeSlotDrawer jadeSlotDrawer = new XJadeSlotDrawer(); + + public XJadeItemDrawer jadeItemDrawer = new XJadeItemDrawer(); + + public XEmblemItemDrawer emblemItemDrawer = new XEmblemItemDrawer(); + + public XFashionDrawer fashionDrawer = new XFashionDrawer(); + + public static XItemDrawerParam Param = new XItemDrawerParam(); + + public void DrawItem(GameObject go, XItem item) + { + bool flag = item == null; + if (flag) + { + this.normalItemDrawer.DrawItem(go, null, 0, false); + } + else + { + item.Description.ItemDrawer.DrawItem(go, item, false); + } + } + + public void Init(uint profession) + { + XItemDrawerParam.DefaultProfession = profession % 10u; + XItemDrawerMgr.Param.Reset(); + } + + public GameObject GetGo(ItemCornerType type) + { + GameObject result; + switch (type) + { + case ItemCornerType.LeftDown: + { + bool flag = this.LeftDownCornerGo == null; + if (flag) + { + this.LeftDownCornerGo = this.Load("LeftDownCorner"); + } + result = this.LeftDownCornerGo; + break; + } + case ItemCornerType.LeftUp: + { + bool flag2 = this.LeftUpCornerGo == null; + if (flag2) + { + this.LeftUpCornerGo = this.Load("LeftUpCorner"); + } + result = this.LeftUpCornerGo; + break; + } + case ItemCornerType.RightDown: + { + bool flag3 = this.RightDownCornerGo == null; + if (flag3) + { + this.RightDownCornerGo = this.Load("RightDownCorner"); + } + result = this.RightDownCornerGo; + break; + } + case ItemCornerType.RightUp: + { + bool flag4 = this.RightUpCornerGo == null; + if (flag4) + { + this.RightUpCornerGo = this.Load("RightUpCorner"); + } + result = this.RightUpCornerGo; + break; + } + case ItemCornerType.Center: + { + bool flag5 = this.MaskGo == null; + if (flag5) + { + this.MaskGo = this.Load("Mask"); + } + result = this.MaskGo; + break; + } + case ItemCornerType.Prof: + { + bool flag6 = this.ProfGo == null; + if (flag6) + { + this.ProfGo = this.Load("RightUpProf"); + } + result = this.ProfGo; + break; + } + default: + XSingleton.singleton.AddErrorLog("type error", null, null, null, null, null); + result = null; + break; + } + return result; + } + + private GameObject Load(string perfabName) + { + string location = XSingleton.singleton.StringCombine("UI/Common/", perfabName); + GameObject gameObject = XSingleton.singleton.CreateFromPrefab(location, true, false) as GameObject; + bool flag = gameObject == null; + if (flag) + { + XSingleton.singleton.AddErrorLog("type error,perfabName = " + perfabName, null, null, null, null, null); + } + return gameObject; + } + + public void OnleaveScene() + { + XResourceLoaderMgr.SafeDestroy(ref this.LeftDownCornerGo, true); + XResourceLoaderMgr.SafeDestroy(ref this.LeftUpCornerGo, true); + XResourceLoaderMgr.SafeDestroy(ref this.RightDownCornerGo, true); + XResourceLoaderMgr.SafeDestroy(ref this.RightUpCornerGo, true); + XResourceLoaderMgr.SafeDestroy(ref this.MaskGo, true); + XResourceLoaderMgr.SafeDestroy(ref this.ProfGo, true); + } + } +} -- cgit v1.1-26-g67d0