-
Notifications
You must be signed in to change notification settings - Fork 1
/
BrawlerUpgrade.cs
82 lines (80 loc) · 2.84 KB
/
BrawlerUpgrade.cs
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
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TheForest.Utils;
using UnityEngine;
namespace PlayerUpgradePoints
{
class BrawlerUpgrade :MonoBehaviour
{
List<Transform> EnemiesNearby;
public static float DamageBonus;
public static float DamageReduction;
public static int EnemiesNearbyCount;
private float DamagePerEnemy = 1.2f;
private float ReductionPerEnemy = 0.9f;
private float Radius = 20;
void Start()
{
EnemiesNearby = new List<Transform>();
DamageBonus = 0;
DamageReduction = 0;
StartCoroutine(CheckEnemiesCoroutine());
}
IEnumerator CheckEnemiesCoroutine()
{
while (true)
{
if (UpgradePointsMod.instance.specialUpgrades[45].bought)
{
if (UpgradePointsMod.instance.specialUpgrades[85].bought)
{
DamagePerEnemy = 1.3f;
}
else
{
DamagePerEnemy = 1.2f;
}
if (UpgradePointsMod.instance.specialUpgrades[86].bought)
{
ReductionPerEnemy = 0.85f;
}
else
{
ReductionPerEnemy = 0.9f;
}
EnemiesNearby.Clear();
RaycastHit[] raycastHits = Physics.SphereCastAll(LocalPlayer.Transform.position, Radius, Vector3.one);
for (int x = 0; x < raycastHits.Length; x++)
{
if (raycastHits[x].transform.CompareTag("enemyCollide"))
{
if (!EnemiesNearby.Contains(raycastHits[x].transform.root))
{
EnemiesNearby.Add(raycastHits[x].transform.root);
}
}
}
EnemiesNearbyCount = EnemiesNearby.Count;
DamageBonus = 1;
DamageReduction = 1;
for (int i = 0; i < EnemiesNearby.Count; i++)
{
DamageBonus *= DamagePerEnemy;
DamageReduction *= ReductionPerEnemy;
}
DamageReduction--;
DamageBonus--;
}
else
{
DamageBonus = 0;
DamageReduction = 0;
}
yield return new WaitForSeconds(0.5f);
}
}
}
}