Blocks are all acting correctly, bomb is acting correctly

This commit is contained in:
2018-04-21 14:41:24 +10:00
parent 0001a875a6
commit ed67e81098
25 changed files with 957 additions and 193 deletions
+22 -1
View File
@@ -6,11 +6,32 @@ public class Bomb : MonoBehaviour {
public float timer;
GameObject explosion;
public GameObject iceBlockPrefab;
void Awake() {
float birthTime;
void Start() {
StartCoroutine (ExplodeAfter (timer));
explosion = transform.GetChild (0).gameObject;
birthTime = Time.time;
}
void OnTriggerEnter2D(Collider2D collider) {
FireDamager fire = collider.gameObject.GetComponent<FireDamager> ();
if (fire != null) {
//explode immediately
StartCoroutine(ExplodeAfter(0));
}
IceDamager ice = collider.gameObject.GetComponent<IceDamager> ();
if (ice != null) {
GameObject iceBlock = Instantiate (iceBlockPrefab);
iceBlock.transform.position = transform.position;
iceBlock.GetComponent<BlockIce> ().bombTimer = timer - (Time.time - birthTime);
Destroy (gameObject);
}
}
IEnumerator ExplodeAfter(float delay) {