blob: 883366096e97b5cc2aff6f3c27ef2d3fb5f821fc (
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
|
using UnityEngine;
public class ProjectileCollision : ProjectileHitSurface
{
public bool scaleWithDMG;
public float health;
private float deathThreshold;
private RayHitReflect reflect;
private ChildRPC rpc;
private float startDMG;
private bool hasCollided;
public GameObject sparkObject;
private void Start()
{
rpc = GetComponentInParent<ChildRPC>();
rpc.childRPCs.Add("KillBullet", Die);
reflect = GetComponentInParent<RayHitReflect>();
ProjectileHit componentInParent = GetComponentInParent<ProjectileHit>();
if (scaleWithDMG)
{
base.transform.localScale *= (componentInParent.damage / 55f + 1f) * 0.5f;
health = componentInParent.damage;
}
startDMG = componentInParent.damage;
deathThreshold = health * 0.1f;
}
public override HasToStop HitSurface(HitInfo hit, GameObject projectile)
{
if (Vector2.Angle(base.transform.root.forward, projectile.transform.forward) < 45f)
{
return HasToStop.HasToStop;
}
if ((bool)reflect && reflect.timeOfBounce + 0.5f > Time.time)
{
return HasToStop.HasToStop;
}
ProjectileCollision componentInChildren = projectile.GetComponentInChildren<ProjectileCollision>();
if ((bool)componentInChildren)
{
reflect = componentInChildren.GetComponentInParent<RayHitReflect>();
if ((bool)reflect && reflect.timeOfBounce + 0.5f > Time.time)
{
return HasToStop.HasToStop;
}
float dmg = health;
float dmg2 = componentInChildren.health;
componentInChildren.TakeDamage(dmg);
TakeDamage(dmg2);
}
return HasToStop.HasToStop;
}
public void TakeDamage(float dmg)
{
if (!hasCollided)
{
health -= dmg;
if ((bool)rpc && health < deathThreshold)
{
rpc.CallFunction("KillBullet");
}
}
}
public void Die()
{
if (!hasCollided)
{
hasCollided = true;
RaycastHit2D raycastHit2D = default(RaycastHit2D);
raycastHit2D.normal = -base.transform.root.forward;
raycastHit2D.point = base.transform.position;
Object.Instantiate(sparkObject, base.transform.position, base.transform.rotation).transform.localScale = Vector3.one * ((startDMG / 55f + 1f) * 0.5f);
GetComponentInParent<ProjectileHit>().Hit(HitInfo.GetHitInfo(raycastHit2D), forceCall: true);
}
}
}
|