summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/XJAComboSkill.cs
blob: 63c27be357d837758a6789245ddbb6003ab72903 (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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
using System;
using UnityEngine;
using XMainClient.UI;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

namespace XMainClient
{
	internal sealed class XJAComboSkill : XArtsSkill
	{
		public bool DuringJA
		{
			get
			{
				return this._during_ja;
			}
		}

		public override int SkillType
		{
			get
			{
				return 0;
			}
		}

		private float _sub_fire_time = 0f;

		private bool _during_ja = false;

		private XTimerMgr.ElapsedEventHandler _ReFire = null;

		private XTimerMgr.ElapsedEventHandler _EnterJA = null;

		private XTimerMgr.ElapsedEventHandler _LeaveJA = null;

		public bool IsInJaPeriod()
		{
			XJAData xjadata = this._data.Ja[0];
			return XSingleton<XCommon>.singleton.IsLess(base.TimeElapsed, xjadata.End * this._time_scale) && XSingleton<XCommon>.singleton.IsGreater(base.TimeElapsed, xjadata.At * this._time_scale);
		}

		public void ReFire(uint id, XEntity target, int slot, float speed, uint sequence)
		{
			this._during_ja = false;
			bool flag = id > 0u;
			if (flag)
			{
				XSkillCore skill = this._skillmgr.GetSkill(id);
				bool flag2 = skill != null;
				if (flag2)
				{
					this._firer.Skill.EndSkill(false, true);
					XAttackEventArgs @event = XEventPool<XAttackEventArgs>.GetEvent();
					@event.Identify = id;
					@event.Firer = this._firer;
					@event.Slot = slot;
					@event.Target = target;
					@event.TimeScale = speed;
					@event.SyncSequence = sequence;
					XSingleton<XEventMgr>.singleton.FireEvent(@event);
				}
			}
			else
			{
				XSkillJAPassedEventArgs event2 = XEventPool<XSkillJAPassedEventArgs>.GetEvent();
				event2.Firer = this._firer;
				event2.Slot = this._slot_pos;
				XSingleton<XEventMgr>.singleton.FireEvent(event2);
			}
		}

		private uint GetNextJAIdentify()
		{
			uint result = 0u;
			bool flag = this.ValidJA();
			if (flag)
			{
				XJAData xjadata = this._data.Ja[0];
				bool isPlayer = this._firer.IsPlayer;
				bool flag2;
				if (isPlayer)
				{
					bool autoPlayOn = (this._firer.Attributes as XPlayerAttributes).AutoPlayOn;
					if (autoPlayOn)
					{
						flag2 = true;
					}
					else
					{
						float lastAttackTime = DlgBase<BattleMain, BattleMainBehaviour>.singleton.SkillHandler.LastAttackTime;
						float a = lastAttackTime - this._sub_fire_time;
						flag2 = (XSingleton<XCommon>.singleton.IsLess(a, xjadata.End * this._time_scale) && XSingleton<XCommon>.singleton.IsGreater(a, xjadata.At * this._time_scale));
					}
				}
				else
				{
					flag2 = true;
				}
				bool flag3 = flag2;
				if (flag3)
				{
					result = XSingleton<XCommon>.singleton.XHash(xjadata.Name);
					DlgBase<BattleMain, BattleMainBehaviour>.singleton.SkillHandler.LastAttackTime = 0f;
				}
				else
				{
					result = XSingleton<XCommon>.singleton.XHash(xjadata.Next_Name);
				}
			}
			return result;
		}

		private void ReFire(object param)
		{
			uint nextJAIdentify = this.GetNextJAIdentify();
			bool flag = nextJAIdentify > 0u;
			if (flag)
			{
				bool syncMode = XSingleton<XGame>.singleton.SyncMode;
				if (!syncMode)
				{
					XSkillCore skill = this._skillmgr.GetSkill(nextJAIdentify);
					bool flag2 = skill != null && skill.CanCast(this._token);
					if (flag2)
					{
						this._firer.Net.ReportSkillAction(null, XSingleton<XCommon>.singleton.XHash(skill.Soul.Name), this._slot_pos);
					}
				}
			}
			else
			{
				this._during_ja = false;
				XSkillJAPassedEventArgs @event = XEventPool<XSkillJAPassedEventArgs>.GetEvent();
				@event.Firer = this._firer;
				@event.Slot = this._slot_pos;
				XSingleton<XEventMgr>.singleton.FireEvent(@event);
			}
		}

		protected override void Start()
		{
			this._sub_fire_time = Time.time;
			this._during_ja = false;
			bool isPlayer = this._firer.IsPlayer;
			if (isPlayer)
			{
				this.JAAt();
			}
			base.Start();
		}

		protected override void Stop(bool cleanUp)
		{
			base.Stop(cleanUp);
			bool flag = !this._firer.Destroying && this._during_ja;
			if (flag)
			{
				this._during_ja = false;
				XSkillJAPassedEventArgs @event = XEventPool<XSkillJAPassedEventArgs>.GetEvent();
				@event.Firer = this._firer;
				@event.Slot = this._slot_pos;
				XSingleton<XEventMgr>.singleton.FireEvent(@event);
			}
		}

		private void OnEnter(object o)
		{
			this._during_ja = true;
		}

		private void OnLeave(object o)
		{
			this._during_ja = false;
		}

		private void JAAt()
		{
			bool flag = this._ReFire == null;
			if (flag)
			{
				this._ReFire = new XTimerMgr.ElapsedEventHandler(this.ReFire);
			}
			bool flag2 = this._EnterJA == null;
			if (flag2)
			{
				this._EnterJA = new XTimerMgr.ElapsedEventHandler(this.OnEnter);
			}
			bool flag3 = this._LeaveJA == null;
			if (flag3)
			{
				this._LeaveJA = new XTimerMgr.ElapsedEventHandler(this.OnLeave);
			}
			bool flag4 = this._data.Ja.Count == 1;
			if (flag4)
			{
				base.AddedTimerToken(XSingleton<XTimerMgr>.singleton.SetTimer(this._data.Ja[0].Point * this._time_scale, this._ReFire, null), true);
				base.AddedTimerToken(XSingleton<XTimerMgr>.singleton.SetTimer(this._data.Ja[0].At * this._time_scale, this._EnterJA, null), true);
				base.AddedTimerToken(XSingleton<XTimerMgr>.singleton.SetTimer(this._data.Ja[0].End * this._time_scale, this._LeaveJA, null), true);
			}
			else
			{
				this._during_ja = true;
			}
		}

		private bool ValidJA()
		{
			return true;
		}
	}
}