-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlockade.cs
33 lines (29 loc) · 945 Bytes
/
Blockade.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
using UnityEngine;
using System.Collections;
public class Blockade : MonoBehaviour {
public FaceScript polyFaceScript;
public int strength = 0;
// Use this for initialization
void Start () {
PolygonCollider2D thisPolygon = gameObject.AddComponent<PolygonCollider2D> () as PolygonCollider2D;
thisPolygon.isTrigger = true;
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter2D(Collider2D other) {
if (other.gameObject.GetComponent<BoardBarrier>() == null && other.gameObject.GetComponent<ShapeIdentifier>() == null && other.gameObject.GetComponent<Blockade>() == null) { //Only collect polyfaces.
polyFaceScript = other.GetComponent<FaceScript>();
if (polyFaceScript.strength == 1) {
Destroy (other.gameObject);
Debug.Log("Destroying GameObject!");
}
else {
polyFaceScript.strength -= (strength + 1);
}
if (strength == 0) {
Destroy (gameObject);
}
}
}
}