summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/XItemDrawerMgr.cs
blob: ee54fc633fba7087634ef381b51706573a75f306 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
using System;
using UnityEngine;
using XUtliPoolLib;

namespace XMainClient
{
	internal class XItemDrawerMgr : XSingleton<XItemDrawerMgr>
	{
		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<XDebug>.singleton.AddErrorLog("type error", null, null, null, null, null);
				result = null;
				break;
			}
			return result;
		}

		private GameObject Load(string perfabName)
		{
			string location = XSingleton<XCommon>.singleton.StringCombine("UI/Common/", perfabName);
			GameObject gameObject = XSingleton<XResourceLoaderMgr>.singleton.CreateFromPrefab(location, true, false) as GameObject;
			bool flag = gameObject == null;
			if (flag)
			{
				XSingleton<XDebug>.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);
		}
	}
}