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

namespace XMainClient
{
	internal class XBillBoardDocument : XDocComponent
	{
		public override uint ID
		{
			get
			{
				return XBillBoardDocument.uuID;
			}
		}

		public new static readonly uint uuID = XSingleton<XCommon>.singleton.XHash("BillboardDocument");

		public static GameObject GetBillboard(Vector3 position, Quaternion quaternion)
		{
			return XSingleton<XResourceLoaderMgr>.singleton.CreateFromPrefab(XBillboardComponent.HPBAR_TEMPLATE, position, quaternion, true, false);
		}

		public static void ReturnBillboard(GameObject go)
		{
			bool flag = go != null;
			if (flag)
			{
				XSingleton<XResourceLoaderMgr>.singleton.UnSafeDestroy(go, true, false);
			}
		}

		public static void PreLoad(int count)
		{
			XSingleton<XResourceLoaderMgr>.singleton.CreateInAdvance(XBillboardComponent.HPBAR_TEMPLATE, count, ECreateHideType.NotHide);
		}

		protected override void EventSubscribe()
		{
			base.EventSubscribe();
			base.RegisterEvent(XEventDefine.XEvent_FightGroupChanged, new XComponent.XEventHandler(this.FightGroupChangeMyself));
		}

		private bool FightGroupChangeMyself(XEventArgs e)
		{
			XFightGroupChangedArgs xfightGroupChangedArgs = e as XFightGroupChangedArgs;
			bool flag = xfightGroupChangedArgs == null || xfightGroupChangedArgs.targetEntity == null || !xfightGroupChangedArgs.targetEntity.IsPlayer;
			bool result;
			if (flag)
			{
				result = true;
			}
			else
			{
				List<XEntity> all = XSingleton<XEntityMgr>.singleton.GetAll();
				for (int i = 0; i < all.Count; i++)
				{
					bool flag2 = all[i].Attributes == null;
					if (!flag2)
					{
						bool flag3 = all[i].BillBoard != null;
						if (flag3)
						{
							all[i].BillBoard.Refresh();
						}
					}
				}
				result = true;
			}
			return result;
		}

		public override void OnEnterScene()
		{
			base.OnEnterScene();
			bool flag = XSingleton<XGameUI>.singleton.HpbarRoot != null;
			if (flag)
			{
				XSingleton<XGameUI>.singleton.HpbarRoot.gameObject.SetActive(true);
			}
			bool flag2 = XSingleton<XGameUI>.singleton.NpcHpbarRoot != null;
			if (flag2)
			{
				XSingleton<XGameUI>.singleton.NpcHpbarRoot.gameObject.SetActive(true);
			}
		}

		public override void OnEnterSceneFinally()
		{
			bool flag = XSingleton<XGame>.singleton.CurrentStage.Stage != EXStage.Hall;
			if (flag)
			{
				bool flag2 = !XSingleton<XSceneMgr>.singleton.IsPVPScene() && !XSingleton<XSceneMgr>.singleton.IsPVEScene();
				if (flag2)
				{
					XSingleton<XDebug>.singleton.AddErrorLog("Please set the scene PVE or PVP", null, null, null, null, null);
				}
			}
		}

		public static void SetAllBillBoardState(BillBoardHideType type, bool state)
		{
			List<XEntity> all = XSingleton<XEntityMgr>.singleton.GetAll();
			for (int i = 0; i < all.Count; i++)
			{
				bool flag = all[i].BillBoard == null;
				if (!flag)
				{
					XBillboardShowCtrlEventArgs @event = XEventPool<XBillboardShowCtrlEventArgs>.GetEvent();
					@event.show = state;
					@event.type = type;
					@event.Firer = all[i];
					XSingleton<XEventMgr>.singleton.FireEvent(@event);
				}
			}
		}

		protected override void OnReconnected(XReconnectedEventArgs arg)
		{
		}
	}
}