summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/GuildPassMgr.cs
blob: 35666e3ad668e224a2fb748a541cffccc9047b1c (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
using System;
using System.Collections.Generic;
using KKSG;
using UnityEngine;
using XMainClient.UI;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

namespace XMainClient
{
	internal class GuildPassMgr : XSingleton<GuildPassMgr>
	{
		public Dictionary<uint, GuildPassBoard> attachDic;

		private const int cnt = 6;

		public bool isOpen = false;

		public GameObject m_wait_blue;

		public GameObject m_wait_red;

		public void InitBoard()
		{
			bool flag = this.attachDic == null;
			if (flag)
			{
				this.attachDic = new Dictionary<uint, GuildPassBoard>();
			}
			this.ClearAll();
			this.isOpen = false;
			for (uint num = 0u; num < 6u; num += 1u)
			{
				uint num2 = num + 1u;
				GameObject gameObject = GameObject.Find("guadian/board" + num2);
				GuildPassBoard guildPassBoard = gameObject.AddComponent<GuildPassBoard>();
				uint sceneid = XGuildTerritoryDocument.mGuildTransfer.GetByid(num2).sceneid;
				guildPassBoard.Init(num2, sceneid, gameObject);
				this.attachDic.Add(num2, guildPassBoard);
			}
			for (uint num3 = 0u; num3 < 6u; num3 += 1u)
			{
				uint num4 = num3 + 6u + 1u;
				GameObject gameObject2 = GameObject.Find("guadian/board" + num4);
				GuildPassBoard guildPassBoard2 = gameObject2.AddComponent<GuildPassBoard>();
				uint sceneid2 = XGuildTerritoryDocument.mGuildTransfer.GetByid(num4).sceneid;
				guildPassBoard2.Init(num4, sceneid2, gameObject2);
				this.attachDic.Add(num4, guildPassBoard2);
			}
			this.m_wait_blue = GameObject.Find("DynamicScene/wait_scene/wait_blue");
			this.m_wait_red = GameObject.Find("DynamicScene/wait_scene/wait_red");
		}

		public void UpdateInfo(List<GCFZhanChBriefInfo> infos)
		{
			bool flag = infos != null;
			if (flag)
			{
				for (int i = 0; i < infos.Count; i++)
				{
					foreach (KeyValuePair<uint, GuildPassBoard> keyValuePair in this.attachDic)
					{
						bool flag2 = keyValuePair.Value.sceneid == infos[i].mapid;
						if (flag2)
						{
							keyValuePair.Value.UpdateBoard(infos[i]);
							this.isOpen = infos[i].isopen;
						}
					}
				}
				bool flag3 = this.m_wait_red != null && this.m_wait_blue != null;
				if (flag3)
				{
					this.m_wait_blue.SetActive(!this.isOpen);
					this.m_wait_red.SetActive(!this.isOpen);
				}
				bool flag4 = DlgBase<BattleMain, BattleMainBehaviour>.singleton.IsVisible();
				if (flag4)
				{
					bool flag5 = DlgBase<BattleMain, BattleMainBehaviour>.singleton.m_miniReportHandler != null;
					if (flag5)
					{
						DlgBase<BattleMain, BattleMainBehaviour>.singleton.m_miniReportHandler.ShowPrepare(!this.isOpen);
						DlgBase<BattleMain, BattleMainBehaviour>.singleton.m_miniReportHandler.ShowBegin(this.isOpen);
					}
				}
			}
		}

		public void OpenAll()
		{
			foreach (KeyValuePair<uint, GuildPassBoard> keyValuePair in this.attachDic)
			{
				keyValuePair.Value.UpdateOpenState(true);
			}
		}

		public void ClearAll()
		{
			bool flag = this.attachDic != null;
			if (flag)
			{
				foreach (KeyValuePair<uint, GuildPassBoard> keyValuePair in this.attachDic)
				{
					keyValuePair.Value.ResetOpenState();
					keyValuePair.Value.DestroyGameObjects();
					UnityEngine.Object.Destroy(keyValuePair.Value);
				}
				this.attachDic.Clear();
			}
		}
	}
}