Added a bunch of features

This commit is contained in:
2018-04-11 16:54:57 +10:00
parent 2cd21dc329
commit a13da880b1
17 changed files with 737 additions and 23 deletions
+14 -2
View File
@@ -5,19 +5,31 @@ using UnityEngine;
public class Monster : MonoBehaviour {
public int value;
Rigidbody2D rigidBody;
void Awake() {
StartCoroutine (DestroySelfAfter (30f));
rigidBody = GetComponent<Rigidbody2D> ();
StartCoroutine (ReverseDirectionAfter (2f));
StartCoroutine (DestroySelfAfter (4f));
}
void OnMouseOver() {
if (Input.GetMouseButtonDown(0)) {
//TODO: play death sound
GameObject.Find ("SoundController").GetComponent<SoundController> ().PlaySnapShot ();
GameObject.Find ("Flash").GetComponent<Flash> ().StartFlash ();
PersistentData.score += value;
Destroy (gameObject);
}
}
IEnumerator ReverseDirectionAfter(float seconds) {
yield return new WaitForSeconds (seconds);
rigidBody.velocity = new Vector2 (-rigidBody.velocity.x, -rigidBody.velocity.y);
}
IEnumerator DestroySelfAfter(float seconds) {
//clean up lost objects
yield return new WaitForSeconds (seconds);
Destroy (gameObject);
}