blob: 6d1fa0327dd120598440e0bcc2d316f6828d0b2e (
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
|
using System.Collections;
using Rewired;
using UnityEngine;
public class PlayerScept : MonoBehaviour, DayNightCycle.IDaytimeSensitive
{
public GameObject loadoutParent;
public Transform scept;
public Transform scepterInteractionTarget;
public AnimationCurve inCurve;
public AnimationCurve outCurve;
public float inTime = 0.2f;
public float outTime = 0.4f;
private Player input;
private Vector3 initPos;
private void Start()
{
DayNightCycle.Instance.RegisterDaytimeSensitiveObject(this);
input = ReInput.players.GetPlayer(0);
initPos = scept.localPosition;
}
private void Update()
{
if (input.GetButtonDown("Interact"))
{
StopAllCoroutines();
StartCoroutine(AnimationIn());
}
if (input.GetButtonUp("Interact"))
{
StopAllCoroutines();
StartCoroutine(AnimationOut());
}
}
private IEnumerator AnimationIn()
{
float timer = 0f;
Vector3 startPos = scept.localPosition;
while (timer < inTime)
{
timer += Time.deltaTime;
scept.localPosition = Vector3.Lerp(startPos, scepterInteractionTarget.localPosition, inCurve.Evaluate(Mathf.InverseLerp(0f, inTime, timer)));
yield return null;
}
scept.localPosition = scepterInteractionTarget.localPosition;
}
private IEnumerator AnimationOut()
{
float timer = 0f;
_ = scept.localPosition;
while (timer < outTime)
{
timer += Time.deltaTime;
scept.localPosition = Vector3.Lerp(scept.localPosition, initPos, outCurve.Evaluate(Mathf.InverseLerp(0f, outTime, timer)));
yield return null;
}
scept.localPosition = initPos;
}
public void OnDawn_AfterSunrise()
{
loadoutParent.SetActive(value: true);
}
public void OnDawn_BeforeSunrise()
{
}
public void OnDusk()
{
loadoutParent.SetActive(value: false);
}
}
|