blob: c0049bb0b2a0c1eac5a1975e589dd51b5b193246 (
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
using Photon.Pun;
using Sonigon;
using SoundImplementation;
using UnityEngine;
public class RemoteControl : MonoBehaviour
{
[Header("Sound")]
public SoundEvent soundRemoteSteeringLoop;
private bool soundIsPlaying;
[Header("Settings")]
public bool snap;
public float rotateSpeed = 1f;
private SpawnedAttack spawned;
private MoveTransform move;
private float startVelocity;
private bool isOn;
private ProjectileHit hit;
private ParticleSystem part;
public ParticleSystem boopPart;
private float c;
private PhotonView view;
private ChildRPC childRPC;
private void OnDestroy()
{
if (soundRemoteSteeringLoop != null && spawned != null && spawned.spawner != null && soundIsPlaying)
{
soundIsPlaying = false;
SoundStaticRemoteControl.remoteControl.AddNumberOf(spawned.spawner.transform, -1);
if (SoundStaticRemoteControl.remoteControl.GetNumberOf(spawned.spawner.transform) <= 0)
{
SoundManager.Instance.Stop(soundRemoteSteeringLoop, spawned.spawner.transform);
}
}
}
private void Start()
{
childRPC = GetComponentInParent<ChildRPC>();
view = GetComponentInParent<PhotonView>();
hit = GetComponentInParent<ProjectileHit>();
move = GetComponentInParent<MoveTransform>();
spawned = GetComponentInParent<SpawnedAttack>();
startVelocity = move.velocity.magnitude;
part = GetComponentInChildren<ParticleSystem>();
GetComponentInParent<SyncProjectile>().active = true;
if (soundRemoteSteeringLoop != null && spawned != null && spawned.spawner != null && !soundIsPlaying)
{
soundIsPlaying = true;
if (SoundStaticRemoteControl.remoteControl.GetNumberOf(spawned.spawner.transform) <= 0)
{
SoundManager.Instance.Play(soundRemoteSteeringLoop, spawned.spawner.transform);
}
SoundStaticRemoteControl.remoteControl.AddNumberOf(spawned.spawner.transform, 1);
}
}
public void ToggleOn(bool isOn)
{
}
private void Update()
{
if (!view.IsMine)
{
return;
}
Vector3 zero = Vector3.zero;
if (spawned.spawner.data.playerActions.Device != null)
{
zero = spawned.spawner.data.input.aimDirection;
}
else
{
zero = MainCam.instance.cam.ScreenToWorldPoint(Input.mousePosition) - base.transform.position;
zero.z = 0f;
zero.Normalize();
}
zero += Vector3.Cross(Vector3.forward, zero) * move.selectedSpread;
c += TimeHandler.deltaTime;
if (snap)
{
if (spawned.spawner.data.block.blockedThisFrame)
{
part.Play();
move.velocity *= -1f;
base.enabled = false;
}
}
else if (zero.magnitude > 0.2f && hit.sinceReflect > 2f)
{
move.velocity = Vector3.RotateTowards(move.velocity, zero.normalized * startVelocity, rotateSpeed * TimeHandler.deltaTime, rotateSpeed * TimeHandler.deltaTime * 10f);
if (c > 0.1f)
{
boopPart.transform.parent.rotation = Quaternion.LookRotation(zero);
boopPart?.Emit(1);
c = 0f;
}
if (!isOn)
{
move.simulateGravity++;
}
isOn = true;
}
else
{
if (isOn)
{
move.simulateGravity--;
}
isOn = false;
}
}
}
|