blob: f913b71266aa04fdc5c131eb97785b584056f1be (
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
|
using System;
using UnityEngine;
[Serializable]
public class Spawn
{
public float delay;
public GameObject enemyPrefab;
public int count;
public float interval;
public Transform spawnLine;
public int goldCoins;
private int[] goldCoinsPerEnemy;
private float waitBeforeNextSpawn;
private int spawnedUnits;
private bool finished;
private bool tauntTheTiger;
private bool tauntTheTurtle;
private bool tauntTheFalcon;
private bool tauntTheRat;
private Hp hpTemp;
public int SpawnedUnits => spawnedUnits;
public bool Finished => finished;
public void Reset(bool _resetGold = true)
{
tauntTheTiger = PerkManager.IsEquipped(PerkManager.instance.tigerGodPerk);
tauntTheTurtle = PerkManager.IsEquipped(PerkManager.instance.turtleGodPerk);
tauntTheFalcon = PerkManager.IsEquipped(PerkManager.instance.falconGodPerk);
tauntTheRat = PerkManager.IsEquipped(PerkManager.instance.ratGodPerk);
waitBeforeNextSpawn = delay;
spawnedUnits = 0;
finished = false;
goldCoinsPerEnemy = new int[count];
int num = goldCoins;
if (tauntTheRat)
{
num = Mathf.FloorToInt((float)num / 2f);
}
for (int i = 0; i < num; i++)
{
goldCoinsPerEnemy[UnityEngine.Random.Range(0, goldCoinsPerEnemy.Length)] = 0;
}
if (_resetGold)
{
for (int j = 0; j < num; j++)
{
goldCoinsPerEnemy[UnityEngine.Random.Range(0, goldCoinsPerEnemy.Length)]++;
}
}
}
public void Update()
{
if (finished)
{
return;
}
waitBeforeNextSpawn -= Time.deltaTime;
if (waitBeforeNextSpawn > 0f)
{
return;
}
waitBeforeNextSpawn = interval;
Vector3 randomPointOnSpawnLine = GetRandomPointOnSpawnLine();
GameObject gameObject;
if (spawnLine == enemyPrefab.transform)
{
gameObject = enemyPrefab;
gameObject.SetActive(value: true);
}
else
{
gameObject = UnityEngine.Object.Instantiate(enemyPrefab, randomPointOnSpawnLine, Quaternion.identity);
EnemySpawnManager instance = EnemySpawnManager.instance;
if ((bool)instance.weaponOnSpawn)
{
instance.weaponOnSpawn.Attack(randomPointOnSpawnLine + Vector3.up * instance.weaponAttackHeight, null, Vector3.forward, gameObject.GetComponent<TaggedObject>());
}
}
if (goldCoinsPerEnemy.Length > spawnedUnits)
{
gameObject.GetComponentInChildren<Hp>().coinCount = goldCoinsPerEnemy[spawnedUnits];
}
if (tauntTheTurtle)
{
hpTemp = gameObject.GetComponentInChildren<Hp>();
hpTemp.maxHp *= PerkManager.instance.tauntTheTurtle_hpMultiplyer;
hpTemp.Heal(float.MaxValue);
}
if (tauntTheTiger)
{
AutoAttack[] componentsInChildren = gameObject.GetComponentsInChildren<AutoAttack>();
for (int i = 0; i < componentsInChildren.Length; i++)
{
componentsInChildren[i].DamageMultiplyer *= PerkManager.instance.tauntTheTiger_damageMultiplyer;
}
Hp[] componentsInChildren2 = gameObject.GetComponentsInChildren<Hp>();
for (int i = 0; i < componentsInChildren2.Length; i++)
{
componentsInChildren2[i].DamageMultiplyer *= PerkManager.instance.tauntTheTiger_damageMultiplyer;
}
}
if (tauntTheFalcon)
{
PathfindMovementEnemy[] componentsInChildren3 = gameObject.GetComponentsInChildren<PathfindMovementEnemy>();
foreach (PathfindMovementEnemy obj in componentsInChildren3)
{
obj.movementSpeed *= PerkManager.instance.tauntTheFalcon_speedMultiplyer;
obj.agroTimeWhenAttackedByPlayer *= PerkManager.instance.tauntTheFalcon_chasePlayerTimeMultiplyer;
}
}
spawnedUnits++;
if (spawnedUnits >= count)
{
finished = true;
}
}
public Vector3 GetRandomPointOnSpawnLine()
{
float num = GetTotalSpawnLineLength() * UnityEngine.Random.value;
float num2 = 0f;
for (int i = 0; i < spawnLine.childCount - 1; i++)
{
float magnitude = (spawnLine.GetChild(i).position - spawnLine.GetChild(i + 1).position).magnitude;
if (magnitude != 0f)
{
if (magnitude + num2 >= num)
{
num -= num2;
float t = num / magnitude;
Vector3 position = Vector3.Lerp(spawnLine.GetChild(i).position, spawnLine.GetChild(i + 1).position, t);
return AstarPath.active.GetNearest(position).position;
}
num2 += magnitude;
}
}
if (spawnLine.childCount > 0)
{
return AstarPath.active.GetNearest(spawnLine.GetChild(0).position).position;
}
return AstarPath.active.GetNearest(spawnLine.position).position;
}
public float GetTotalSpawnLineLength()
{
float num = 0f;
for (int i = 0; i < spawnLine.childCount - 1; i++)
{
num += (spawnLine.GetChild(i).position - spawnLine.GetChild(i + 1).position).magnitude;
}
return num;
}
}
|