aboutsummaryrefslogtreecommitdiff
path: root/Assets/Scripts/Enemy.cs
diff options
context:
space:
mode:
authorTom Harley2018-09-03 23:34:21 +0100
committerTom Harley2018-09-03 23:36:01 +0100
commit5440734d820606b29a795c46172ade5d7eba8efb (patch)
tree85867f40afb02cfa2a5028b515ed0a195866b7e9 /Assets/Scripts/Enemy.cs
downloadpowerless-5440734d820606b29a795c46172ade5d7eba8efb.tar.gz
powerless-5440734d820606b29a795c46172ade5d7eba8efb.zip

Initial commit

Diffstat (limited to 'Assets/Scripts/Enemy.cs')
-rw-r--r--Assets/Scripts/Enemy.cs28
1 files changed, 28 insertions, 0 deletions
diff --git a/Assets/Scripts/Enemy.cs b/Assets/Scripts/Enemy.cs
new file mode 100644
index 0000000..a7af21f
--- /dev/null
+++ b/Assets/Scripts/Enemy.cs
@@ -0,0 +1,28 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class Enemy : MonoBehaviour {
+ private Vector2 start;
+
+ void OnTriggerStay2D(Collider2D other) {
+ GameObject ogo = other.gameObject;
+ switch (ogo.tag) {
+ case "Player":
+ CharacterControl script = ogo.GetComponent<CharacterControl>();
+ script.Damaged();
+ break;
+ }
+ }
+
+ void Start() {
+ start = this.transform.position;
+ }
+
+ public void Reset() {
+ Debug.Log(this);
+ this.transform.position = start;
+ GetComponent<SpriteRenderer>().enabled = true;
+ GetComponent<BoxCollider2D>().enabled = true;
+ }
+}