summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/XItemMorePowerfulTipMgr.cs
blob: eaa6dba0d536314b21f72a5806c9cf748b49be7e (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
using System;
using System.Collections.Generic;
using UILib;
using UnityEngine;
using XUtliPoolLib;

namespace XMainClient
{
	internal class XItemMorePowerfulTipMgr
	{
		public bool bLoaded
		{
			get
			{
				return this.m_Tip != null;
			}
		}

		private XUIPool m_Pool = new XUIPool(XSingleton<XGameUI>.singleton.m_uiTool);

		private GameObject m_Tip = null;

		private Dictionary<IXUISprite, GameObject> m_TipsDic = new Dictionary<IXUISprite, GameObject>();

		private bool m_bLoadFromUI = false;

		public int DeltaDepth = 60;

		public void Load(string prefabName)
		{
			this._Load("UI/Common/" + prefabName);
		}

		public void LoadFromUI(GameObject go)
		{
			this.m_Tip = go;
			this.m_bLoadFromUI = true;
		}

		private void _Load(string prefab)
		{
			this._Destroy();
			this.m_Tip = (XSingleton<XResourceLoaderMgr>.singleton.CreateFromPrefab(prefab, true, false) as GameObject);
			this.m_bLoadFromUI = false;
		}

		public void SetupPool(GameObject parent)
		{
			bool flag = this.m_Tip == null;
			if (flag)
			{
				this.Load("ItemMorePowerfulTip");
			}
			this.m_Pool.SetupPool(parent, this.m_Tip, 2u, false);
		}

		private void _Destroy()
		{
			bool flag = !this.m_bLoadFromUI;
			if (flag)
			{
				XResourceLoaderMgr.SafeDestroy(ref this.m_Tip, true);
			}
			this.m_TipsDic.Clear();
		}

		public void Unload()
		{
			this._Destroy();
		}

		public void ReturnAll()
		{
			this.m_Pool.ReturnAll(false);
			this.m_TipsDic.Clear();
		}

		public void ReturnInstance(IXUISprite bg)
		{
			GameObject go;
			bool flag = this.m_TipsDic.TryGetValue(bg, out go);
			if (flag)
			{
				this.m_Pool.ReturnInstance(go, false);
				this.m_TipsDic.Remove(bg);
			}
		}

		public void FakeReturnAll()
		{
			this.m_Pool.FakeReturnAll();
			this.m_TipsDic.Clear();
		}

		public void ActualReturnAll()
		{
			this.m_Pool.ActualReturnAll(false);
		}

		public GameObject SetTip(GameObject bg)
		{
			IXUISprite tip = bg.GetComponent("XUISprite") as IXUISprite;
			return this.SetTip(tip);
		}

		public GameObject SetTip(IXUISprite bg)
		{
			GameObject gameObject;
			bool flag = this.m_TipsDic.TryGetValue(bg, out gameObject);
			GameObject result;
			if (flag)
			{
				result = gameObject;
			}
			else
			{
				gameObject = this.m_Pool.FetchGameObject(false);
				gameObject.transform.parent = bg.gameObject.transform;
				gameObject.transform.localPosition = Vector3.zero;
				gameObject.transform.localScale = Vector3.one;
				gameObject.name = this.m_Tip.name;
				IXUISprite ixuisprite = gameObject.transform.Find("Icon").GetComponent("XUISprite") as IXUISprite;
				bool flag2 = !this.m_bLoadFromUI;
				if (flag2)
				{
					ixuisprite.spriteDepth = bg.spriteDepth + this.DeltaDepth;
				}
				this.m_TipsDic.Add(bg, gameObject);
				result = gameObject;
			}
			return result;
		}
	}
}