summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/XLevelSpawnTask.cs
blob: 56f4eed31ada58d866692db4d5a57e7d70c0ed41 (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
using System;
using KKSG;
using UnityEngine;
using XUtliPoolLib;

namespace XMainClient
{
	internal class XLevelSpawnTask : XLevelBaseTask
	{
		public uint _EnemyID;

		public int _MonsterRotate;

		public int _MonsterIndex;

		public Vector3 _MonsterPos;

		public LevelSpawnType _SpawnType;

		public bool _IsSummonTask;

		public XLevelSpawnTask(XLevelSpawnInfo ls) : base(ls)
		{
			this._IsSummonTask = false;
		}

		public XEntity CreateClientMonster(uint id, float yRotate, Vector3 pos, int _waveid)
		{
			Quaternion rotation = Quaternion.Euler(0f, yRotate, 0f);
			XEntity xentity = XSingleton<XEntityMgr>.singleton.CreateEntity(id, pos, rotation, true, uint.MaxValue);
			bool flag = xentity != null;
			XEntity result;
			if (flag)
			{
				xentity.Wave = _waveid;
				xentity.CreateTime = Time.realtimeSinceStartup;
				XAIEventArgs @event = XEventPool<XAIEventArgs>.GetEvent();
				@event.DepracatedPass = true;
				@event.Firer = XSingleton<XEntityMgr>.singleton.Player;
				@event.EventType = 1;
				@event.EventArg = "SpawnMonster";
				XSingleton<XEventMgr>.singleton.FireEvent(@event, 0.05f);
				result = xentity;
			}
			else
			{
				result = null;
			}
			return result;
		}

		public XEntity CreateServerAttrMonster(UnitAppearance data, float yRotate, Vector3 pos, int _waveid)
		{
			XAttributes xattributes = XSingleton<XAttributeMgr>.singleton.InitAttrFromServer(data.uID, data.nickid, data.unitType, data.unitName, data.attributes, data.fightgroup, data.isServerControl, data.skills, data.bindskills, new XOutLookAttr((OutLook)null), data.level, 0u);
			xattributes.Outlook.SetData(data.outlook, xattributes.TypeID);
			bool flag = xattributes.Type == EntitySpecies.Species_Role;
			XEntity xentity;
			if (flag)
			{
				xentity = XSingleton<XEntityMgr>.singleton.Add(XSingleton<XEntityMgr>.singleton.CreateRole(xattributes, pos, Quaternion.Euler(0f, yRotate, 0f), false, false));
			}
			else
			{
				xentity = XSingleton<XEntityMgr>.singleton.Add(XSingleton<XEntityMgr>.singleton.CreateEntity(xattributes, pos, Quaternion.Euler(0f, yRotate, 0f), false));
			}
			bool flag2 = xentity != null;
			XEntity result;
			if (flag2)
			{
				xentity.Wave = _waveid;
				bool flag3 = XSingleton<XScene>.singleton.SceneType == SceneType.SCENE_BOSSRUSH;
				if (flag3)
				{
					XLevelDocument specificDocument = XDocuments.GetSpecificDocument<XLevelDocument>(XLevelDocument.uuID);
					BossRushTable.RowData bossRushConfig = specificDocument.GetBossRushConfig(XSingleton<XScene>.singleton.SceneID, (uint)(XSingleton<XLevelStatistics>.singleton.ls._total_kill + 1));
					bool flag4 = data != null;
					if (flag4)
					{
						float num = 1f;
						double attr = xentity.Attributes.GetAttr(XAttributeDefine.XAttr_MaxHP_Basic);
						double value = attr * (double)num;
						xentity.Attributes.SetAttr(XAttributeDefine.XAttr_MaxHP_Basic, value);
						xentity.Attributes.SetAttr(XAttributeDefine.XAttr_CurrentHP_Basic, value);
					}
				}
				bool isDead = data.IsDead;
				if (isDead)
				{
					XSingleton<XDeath>.singleton.DeathDetect(xentity, null, true);
					result = null;
				}
				else
				{
					result = xentity;
				}
			}
			else
			{
				result = null;
			}
			return result;
		}

		public override bool Execute(float time)
		{
			base.Execute(time);
			XLevelDynamicInfo xlevelDynamicInfo = null;
			bool flag = !this._IsSummonTask;
			if (flag)
			{
				xlevelDynamicInfo = this._spawner.GetWaveDynamicInfo(this._id);
				bool flag2 = xlevelDynamicInfo == null;
				if (flag2)
				{
					return true;
				}
			}
			XEntity xentity = null;
			bool flag3 = this._SpawnType == LevelSpawnType.Spawn_Source_Monster;
			if (flag3)
			{
				xentity = this.CreateClientMonster(this._EnemyID, (float)this._MonsterRotate, this._MonsterPos + new Vector3(0f, 0.02f, 0f), this._id);
				XSingleton<XLevelStatistics>.singleton.ls.AddLevelSpawnEntityCount(xentity.ID);
			}
			else
			{
				bool flag4 = this._SpawnType == LevelSpawnType.Spawn_Source_Doodad;
				if (!flag4)
				{
					UnitAppearance cacheServerMonster = XSingleton<XLevelSpawnMgr>.singleton.GetCacheServerMonster((uint)this._id);
					bool flag5 = cacheServerMonster != null;
					if (flag5)
					{
						xentity = this.CreateServerAttrMonster(cacheServerMonster, (float)this._MonsterRotate, this._MonsterPos + new Vector3(0f, 0.02f, 0f), this._id);
					}
					XSingleton<XLevelStatistics>.singleton.ls.AddLevelSpawnEntityCount(xentity.ID);
				}
			}
			bool flag6 = xlevelDynamicInfo != null;
			if (flag6)
			{
				bool flag7 = xentity != null;
				if (flag7)
				{
					xlevelDynamicInfo._generateCount++;
					xlevelDynamicInfo._enemyIds.Add(xentity.ID);
				}
				bool flag8 = xlevelDynamicInfo._generateCount == xlevelDynamicInfo._TotalCount;
				if (flag8)
				{
					xlevelDynamicInfo._generatetime = time;
				}
				bool flag9 = xentity != null && xentity.IsBoss;
				if (flag9)
				{
					XSingleton<XTutorialHelper>.singleton.HasBoss = true;
					return false;
				}
			}
			return true;
		}
	}
}