-
Notifications
You must be signed in to change notification settings - Fork 0
/
GroundCannonHitbox.cs
73 lines (67 loc) · 2.08 KB
/
GroundCannonHitbox.cs
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
using UnityEngine;
using System.Collections;
public class GroundCannonHitbox : MonoBehaviour {
public int cannonHP = 10;
public GameObject explosion;
private Score scores;
public int points = 75;
void Start () {
scores = GameObject.Find("Canvas").GetComponent<Score>();
}
void Update () {
if(cannonHP <= 0)
{
Destroy(gameObject);
Instantiate(explosion, transform.position, new Quaternion());
}
}
void OnTriggerEnter2D(Collider2D collider)
{
if (collider.tag == "p1Bullet" || collider.tag == "p1Bullet2" || collider.tag == "p1Bullet3" || collider.tag == "p1Bomb")
{
scores.hit++;
scores.timer = scores.cTime;
scores.combo++;
if (scores.cmb == true)
{
scores.score += points * scores.combo;
}
else
{
scores.combo = 0;
scores.score += points;
}
}
if (collider.tag == "p2Bullet" || collider.tag == "p2Bullet2" || collider.tag == "p2Bullet3" || collider.tag == "p2Bomb")
{
scores.hit2++;
scores.timer2 = scores.cTime;
scores.combo2++;
if (scores.cmb2 == true)
{
scores.score2 += points * scores.combo2;
}
else
{
scores.combo2 = 0;
scores.score2 += points;
}
}
if (collider.tag == "p1Bullet" || collider.tag == "p2Bullet")
{
cannonHP -= Projectile.bullet1Dmg;
}
if (collider.tag == "p1Bullet2" || collider.tag == "p2Bullet2")
{
cannonHP -= Projectile.bullet2Dmg;
}
if (collider.tag == "p1Bullet3" || collider.tag == "p2Bullet3")
{
cannonHP -= Projectile.bullet3Dmg;
}
if (collider.tag == "p1Bomb" || collider.tag == "p2Bomb")
{
cannonHP -= Projectile.bombDmg;
}
}
}