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

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

		public int CurrentID { get; set; }

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

		public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader();

		public static OnlineRewardTable RewardTable = new OnlineRewardTable();

		public List<int> Status = new List<int>();

		public List<int> LeftTime = new List<int>();

		public static void Execute(OnLoadedCallback callback = null)
		{
			XOnlineRewardDocument.AsyncLoader.AddTask("Table/OnlineReward", XOnlineRewardDocument.RewardTable, false);
			XOnlineRewardDocument.AsyncLoader.Execute(callback);
		}

		public void SendGetReward(int index)
		{
			RpcC2G_GetOnlineReward rpcC2G_GetOnlineReward = new RpcC2G_GetOnlineReward();
			rpcC2G_GetOnlineReward.oArg.index = (uint)index;
			XSingleton<XClientNetwork>.singleton.Send(rpcC2G_GetOnlineReward);
		}

		public void QueryStatus()
		{
			PtcC2G_OnlineRewardReport proto = new PtcC2G_OnlineRewardReport();
			XSingleton<XClientNetwork>.singleton.Send(proto);
		}

		public void RefreshStatus(List<uint> status, List<uint> leftTime)
		{
			this.Status.Clear();
			this.LeftTime.Clear();
			for (int i = 0; i < status.Count; i++)
			{
				this.Status.Add((int)status[i]);
				this.LeftTime.Add((int)leftTime[i]);
			}
			bool flag = this.Status.Count == 0;
			if (flag)
			{
				this.Status.Add(2);
				this.LeftTime.Add(1);
			}
			this.CurrentID = this.Status.Count - 1;
			for (int j = 0; j < this.Status.Count; j++)
			{
				bool flag2 = this.Status[j] <= 1;
				if (flag2)
				{
					this.CurrentID = j;
					break;
				}
			}
			XSingleton<XGameSysMgr>.singleton.OnlineRewardRemainTime = (float)this.LeftTime[this.CurrentID];
			bool flag3 = DlgBase<XMainInterface, XMainInterfaceBehaviour>.singleton.IsVisible() && XSingleton<XScene>.singleton.SceneType == SceneType.SCENE_HALL;
			if (flag3)
			{
			}
			bool flag4 = !DlgBase<XOnlineRewardView, XOnlineRewardBehaviour>.singleton.IsVisible();
			if (!flag4)
			{
				DlgBase<XOnlineRewardView, XOnlineRewardBehaviour>.singleton.RefreshItemList();
				DlgBase<XOnlineRewardView, XOnlineRewardBehaviour>.singleton.SetGetRewardLabel(this.Status[this.CurrentID]);
			}
		}

		private bool CanClaim()
		{
			for (int i = 0; i < this.Status.Count; i++)
			{
				bool flag = this.Status[i] == 1;
				if (flag)
				{
					return true;
				}
			}
			return false;
		}

		public bool CheckOver()
		{
			for (int i = 0; i < this.Status.Count; i++)
			{
				bool flag = this.Status[i] != 2;
				if (flag)
				{
					return true;
				}
			}
			return false;
		}

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