blob: 63c2d75837dd024520c4f209d7555b131cbd656a (
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
|
using UnityEngine;
using UnityEngine.Events;
[RequireComponent(typeof(Hp))]
public class AutoRevive : MonoBehaviour, DayNightCycle.IDaytimeSensitive
{
[HideInInspector]
public UnityEvent onReviveTrigger = new UnityEvent();
private Hp hp;
public float reviveAfterBeingKnockedOutFor = 20f;
private float hasBeenKnockedOutFor;
private bool ringOfResurection;
private bool quickReviveAvailable = true;
private bool godOfDeathActive;
[SerializeField]
private Equippable ringOfResurectionPerk;
private float ReviveAfterBeingKnockedOutFor
{
get
{
if (ringOfResurection && quickReviveAvailable)
{
return 2f;
}
return reviveAfterBeingKnockedOutFor;
}
}
public float TimeTillRevive
{
get
{
if (hasBeenKnockedOutFor <= 0f)
{
return -1f;
}
return ReviveAfterBeingKnockedOutFor - hasBeenKnockedOutFor;
}
}
public void OnDusk()
{
}
public void OnDawn_AfterSunrise()
{
quickReviveAvailable = true;
}
public void OnDawn_BeforeSunrise()
{
}
private void Start()
{
godOfDeathActive = PerkManager.instance.GodOfDeathActive;
if (godOfDeathActive)
{
reviveAfterBeingKnockedOutFor *= PerkManager.instance.godOfDeath_playerRespawnMultiplyer;
}
hp = GetComponent<Hp>();
ringOfResurection = PerkManager.IsEquipped(ringOfResurectionPerk);
DayNightCycle.Instance.RegisterDaytimeSensitiveObject(this);
}
private void Update()
{
if (hp.KnockedOut)
{
hasBeenKnockedOutFor += Time.deltaTime;
if (hasBeenKnockedOutFor >= ReviveAfterBeingKnockedOutFor)
{
hp.Revive();
onReviveTrigger.Invoke();
quickReviveAvailable = false;
}
}
else
{
hasBeenKnockedOutFor = 0f;
}
}
}
|