blob: b2a25b280afcd454db5cae0d8607467e44df2683 (
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
|
using System.Collections;
using Photon.Pun;
using UnityEngine;
public class ScaleShake : MonoBehaviour
{
public bool useTimeScale = true;
public float targetScale = 1f;
public float multiplier = 1f;
private float velocity;
public float drag = 1f;
public float spring = 1f;
public float clampVelocity;
internal float high;
internal float low;
private void Update()
{
float num = Mathf.Clamp(useTimeScale ? TimeHandler.deltaTime : Time.unscaledDeltaTime, 0f, 0.02f);
if (clampVelocity != 0f)
{
velocity = Mathf.Clamp(velocity, 0f - clampVelocity, clampVelocity);
}
velocity += (targetScale - base.transform.localScale.x) * num * 50f * spring;
velocity -= drag * velocity * 20f * num;
base.transform.localScale += Vector3.one * (velocity * 10f * num);
}
public void AddForce(float force)
{
velocity += force * multiplier * 5f;
}
public void AddForce()
{
velocity += 1f * multiplier * 5f;
}
public void SetTarget(float target)
{
targetScale = target;
}
public void SetHigh()
{
targetScale = high;
}
public void SetLow()
{
targetScale = low;
}
public void ScaleOutRootPhoton()
{
StartCoroutine(GoAwayOutRootPhoton());
}
private IEnumerator GoAwayOutRootPhoton()
{
while (base.transform.localScale.x > 0f)
{
targetScale = 0f;
yield return null;
}
PhotonNetwork.Destroy(base.transform.root.gameObject);
}
}
|