Wind blows over gaps

This commit is contained in:
2018-04-21 15:03:13 +10:00
parent ed67e81098
commit 7d10afcbf9
7 changed files with 176 additions and 1 deletions
+6
View File
@@ -0,0 +1,6 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BlockGap : MonoBehaviour {
}
+13
View File
@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 07e0c3a4814d62f418256b87b1da3ed5
timeCreated: 1524286791
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+11
View File
@@ -3,10 +3,16 @@ using System.Collections.Generic;
using UnityEngine;
public class BlockIce : MonoBehaviour {
Rigidbody2D rigidBody;
public float bombTimer = -1;
public GameObject bombPrefab;
void Awake() {
rigidBody = GetComponent<Rigidbody2D> ();
}
void OnTriggerEnter2D(Collider2D collider) {
//TODO: use durability class?
FireDamager fire = collider.gameObject.GetComponent<FireDamager> ();
@@ -18,5 +24,10 @@ public class BlockIce : MonoBehaviour {
}
Destroy (gameObject);
}
WindDamager wind = collider.gameObject.GetComponent<WindDamager> ();
if (wind != null) {
rigidBody.AddForce (collider.gameObject.GetComponent<Rigidbody2D> ().velocity * 20, ForceMode2D.Impulse);
}
}
}
+11
View File
@@ -3,6 +3,8 @@ using System.Collections.Generic;
using UnityEngine;
public class Bomb : MonoBehaviour {
Rigidbody2D rigidBody;
public float timer;
GameObject explosion;
@@ -10,6 +12,10 @@ public class Bomb : MonoBehaviour {
float birthTime;
void Awake() {
rigidBody = GetComponent<Rigidbody2D> ();
}
void Start() {
StartCoroutine (ExplodeAfter (timer));
@@ -32,6 +38,11 @@ public class Bomb : MonoBehaviour {
iceBlock.GetComponent<BlockIce> ().bombTimer = timer - (Time.time - birthTime);
Destroy (gameObject);
}
WindDamager wind = collider.gameObject.GetComponent<WindDamager> ();
if (wind != null) {
rigidBody.AddForce (collider.gameObject.GetComponent<Rigidbody2D> ().velocity / 2, ForceMode2D.Impulse);
}
}
IEnumerator ExplodeAfter(float delay) {
+1 -1
View File
@@ -5,7 +5,7 @@ using UnityEngine;
//shootable
public class WindDamager : DamagerBase {
void OnTriggerEnter2D(Collider2D collider) {
if (collider.gameObject.GetComponent<WindDamager> () == null) { //pass through other instances of self
if (collider.gameObject.GetComponent<WindDamager> () == null && collider.gameObject.GetComponent<BlockGap> () == null) {
Destroy (gameObject);
}
}