-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpeedThreshold.cs
More file actions
86 lines (75 loc) · 2.73 KB
/
SpeedThreshold.cs
File metadata and controls
86 lines (75 loc) · 2.73 KB
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace Godspeed
{
class SpeedThreshold : MonoBehaviour
{
CustomBossBar bossSource;
BossHealthBar bossBar;
float timeLeft = -1f;
int currentDamage = 5;
public void Start()
{
bossSource = gameObject.AddComponent<CustomBossBar>();
CreateBar();
}
public void Update()
{
if (Godspeed.player.dead) currentDamage = 5;
if (Godspeed.player.dead || !MonoSingleton<PlayerTracker>.Instance.levelStarted) return;
float velocity = MonoSingleton<PlayerTracker>.Instance.GetPlayerVelocity(true).magnitude;
if (timeLeft < 0f && velocity < Godspeed.speedThreshold.value)
{
timeLeft = Godspeed.leniency.value;
}
else if (timeLeft >= 0f)
{
if (velocity > Godspeed.speedThreshold.value)
{
timeLeft = -1f;
bossSource.Health = Godspeed.leniency.value;
return;
}
timeLeft -= Time.deltaTime;
bossSource.Health = timeLeft;
if (timeLeft < 0f)
{
switch (Godspeed.punishment.value)
{
case Godspeed.Punishments.Death:
Godspeed.player.GetHurt(5000000, false);
break;
case Godspeed.Punishments.Damage:
Godspeed.player.GetHurt(20, false);
break;
case Godspeed.Punishments.Ramping:
Godspeed.player.GetHurt(currentDamage, false);
currentDamage += 5;
break;
case Godspeed.Punishments.Restart:
MonoSingleton<OptionsManager>.Instance.RestartMission();
break;
//case Godspeed.Punishments.Maurice:
// //Instantiate<SpiderBody>();
// break;
default:
break;
}
timeLeft = -1f;
}
}
}
private void CreateBar()
{
bossSource.Health = Godspeed.leniency.value + 0.001f;
bossBar = gameObject.AddComponent<BossHealthBar>();
bossBar.bossName = "SPEED UP";
bossBar.secondaryBar = false;
bossBar.source = bossSource;
}
}
}