blob: 742e29a67e802820f103840cd32a4b8cbe86646e (
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
|
using System;
using Sonigon;
using UnityEngine;
public class Empower : MonoBehaviour
{
public SoundEvent soundEmpowerSpawn;
public GameObject addObjectToBullet;
public float dmgMultiplier = 2f;
public float speedMultiplier = 2f;
public Color empowerColor;
private CharacterData data;
private ParticleSystem[] parts;
private Transform particleTransform;
private bool empowered;
private bool isOn;
private void Start()
{
particleTransform = base.transform.GetChild(0);
data = GetComponentInParent<CharacterData>();
parts = GetComponentsInChildren<ParticleSystem>();
HealthHandler healthHandler = GetComponentInParent<Player>().data.healthHandler;
healthHandler.reviveAction = (Action)Delegate.Combine(healthHandler.reviveAction, new Action(ResetEmpower));
Gun gun = data.weaponHandler.gun;
gun.ShootPojectileAction = (Action<GameObject>)Delegate.Combine(gun.ShootPojectileAction, new Action<GameObject>(Attack));
Block componentInParent = GetComponentInParent<Block>();
componentInParent.BlockAction = (Action<BlockTrigger.BlockTriggerType>)Delegate.Combine(componentInParent.BlockAction, new Action<BlockTrigger.BlockTriggerType>(Block));
}
private void OnDestroy()
{
HealthHandler healthHandler = GetComponentInParent<Player>().data.healthHandler;
healthHandler.reviveAction = (Action)Delegate.Remove(healthHandler.reviveAction, new Action(ResetEmpower));
Gun gun = data.weaponHandler.gun;
gun.ShootPojectileAction = (Action<GameObject>)Delegate.Remove(gun.ShootPojectileAction, new Action<GameObject>(Attack));
Block componentInParent = GetComponentInParent<Block>();
componentInParent.BlockAction = (Action<BlockTrigger.BlockTriggerType>)Delegate.Remove(componentInParent.BlockAction, new Action<BlockTrigger.BlockTriggerType>(Block));
}
private void ResetEmpower()
{
empowered = false;
}
public void Block(BlockTrigger.BlockTriggerType trigger)
{
if (trigger != BlockTrigger.BlockTriggerType.Echo && trigger != BlockTrigger.BlockTriggerType.Empower && trigger != BlockTrigger.BlockTriggerType.ShieldCharge)
{
empowered = true;
}
}
public void Attack(GameObject projectile)
{
SpawnedAttack component = projectile.GetComponent<SpawnedAttack>();
if (!component)
{
return;
}
if (empowered)
{
ProjectileHit component2 = projectile.GetComponent<ProjectileHit>();
MoveTransform component3 = projectile.GetComponent<MoveTransform>();
component.SetColor(empowerColor);
component2.damage *= dmgMultiplier;
component3.localForce *= speedMultiplier;
if ((bool)addObjectToBullet)
{
UnityEngine.Object.Instantiate(addObjectToBullet, projectile.transform.position, projectile.transform.rotation, projectile.transform);
}
}
empowered = false;
}
private void Update()
{
if (empowered)
{
particleTransform.transform.position = data.weaponHandler.gun.transform.position;
particleTransform.transform.rotation = data.weaponHandler.gun.transform.rotation;
if (!isOn)
{
SoundManager.Instance.PlayAtPosition(soundEmpowerSpawn, SoundManager.Instance.GetTransform(), base.transform);
for (int i = 0; i < parts.Length; i++)
{
parts[i].Play();
}
isOn = true;
}
}
else if (isOn)
{
for (int j = 0; j < parts.Length; j++)
{
parts[j].Stop();
}
isOn = false;
}
}
}
|