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

namespace XMainClient.UI
{
	internal class GVGBattleRankFrameBase : IGVGBattleMember
	{
		private int _index = 0;

		private IXUIScrollView _scrollView;

		private IXUIWrapContent _wrapContent;

		private GameObject _gameObject;

		private Transform _transform;

		private List<GmfRole> _roles;

		private GVGBattleInfo _battleInfo;

		public void ReFreshData(GVGBattleInfo battleInfo)
		{
			this._battleInfo = battleInfo;
			bool flag = this._roles == null;
			if (flag)
			{
				this._roles = new List<GmfRole>();
			}
			else
			{
				this._roles.Clear();
			}
			bool flag2 = battleInfo.Group != null;
			if (flag2)
			{
				this._roles.AddRange(battleInfo.Group);
			}
			this._wrapContent.SetContentCount(this._roles.Count, false);
			this._wrapContent.RefreshAllVisibleContents();
		}

		public void Setup(GameObject sv, int index)
		{
			this._index = index;
			this._gameObject = sv;
			this._transform = sv.transform;
			this._scrollView = (this._transform.GetComponent("XUIScrollView") as IXUIScrollView);
			this._wrapContent = (this._transform.Find("RankList").GetComponent("XUIWrapContent") as IXUIWrapContent);
			this._wrapContent.RegisterItemUpdateEventHandler(new WrapItemUpdateEventHandler(this._OnWrapContentUpdate));
		}

		private void _OnWrapContentUpdate(Transform t, int index)
		{
			bool flag = this._roles.Count <= index;
			if (!flag)
			{
				IXUIProgress ixuiprogress = t.Find("HpBar").GetComponent("XUIProgress") as IXUIProgress;
				IXUILabel ixuilabel = t.Find("Name").GetComponent("XUILabel") as IXUILabel;
				IXUILabel ixuilabel2 = t.Find("KillValue").GetComponent("XUILabel") as IXUILabel;
				IXUILabel ixuilabel3 = t.Find("DieValue").GetComponent("XUILabel") as IXUILabel;
				IXUISprite ixuisprite = t.Find("job").GetComponent("XUISprite") as IXUISprite;
				GmfRole gmfRole = this._roles[index];
				ixuisprite.SetSprite(XSingleton<XProfessionSkillMgr>.singleton.GetProfIcon(gmfRole.profession));
				ixuilabel.SetText(gmfRole.rolename);
				GmfCombat gmfCombat = null;
				bool flag2 = this._battleInfo != null && this._battleInfo.TryGetCombat(gmfRole.roleID, out gmfCombat);
				if (flag2)
				{
					ixuilabel2.SetText(gmfCombat.killcount.ToString());
					ixuilabel3.SetText(gmfCombat.deadcount.ToString());
				}
				else
				{
					ixuilabel2.SetText("0");
					ixuilabel3.SetText("0");
				}
				XEntity entity = XSingleton<XEntityMgr>.singleton.GetEntity(gmfRole.roleID);
				float value = 1f;
				bool flag3 = entity != null && entity.Attributes != null;
				if (flag3)
				{
					int num = (int)entity.Attributes.GetAttr(XAttributeDefine.XAttr_MaxHP_Total);
					int num2 = (int)entity.Attributes.GetAttr(XAttributeDefine.XAttr_CurrentHP_Basic);
					bool flag4 = num2 < 0;
					if (flag4)
					{
						num2 = 0;
					}
					value = (float)num2 / (float)num;
				}
				ixuiprogress.value = value;
			}
		}

		public void OnUpdate()
		{
			bool flag = !this.IsActive();
			if (!flag)
			{
				this._wrapContent.RefreshAllVisibleContents();
			}
		}

		public void SetActive(bool active)
		{
			bool flag = this._transform != null;
			if (flag)
			{
				this._transform.gameObject.SetActive(active);
			}
		}

		public bool IsActive()
		{
			return this._transform != null && this._transform.gameObject.activeSelf;
		}

		public void Recycle()
		{
			bool flag = this._roles != null;
			if (flag)
			{
				this._roles.Clear();
				this._roles = null;
			}
		}
	}
}