aboutsummaryrefslogtreecommitdiff
path: root/td/Assets/Scripts/Enemy.cs
diff options
context:
space:
mode:
authorJakob Stendahl <jakob.stendahl@outlook.com>2017-10-07 21:16:23 +0200
committerJakob Stendahl <jakob.stendahl@outlook.com>2017-10-07 21:16:23 +0200
commit69a6cc2555d8dfc8314a08e6cef6b67fa1177bf0 (patch)
treebe48ae23e1085c2522808af2d418c852998a8c58 /td/Assets/Scripts/Enemy.cs
parente13fd4cf1fc0ad9eff857295fd5abc15ab01462c (diff)
downloadTD-69a6cc2555d8dfc8314a08e6cef6b67fa1177bf0.tar.gz
TD-69a6cc2555d8dfc8314a08e6cef6b67fa1177bf0.zip
Made projectiles, and working health system
Diffstat (limited to 'td/Assets/Scripts/Enemy.cs')
-rw-r--r--td/Assets/Scripts/Enemy.cs8
1 files changed, 7 insertions, 1 deletions
diff --git a/td/Assets/Scripts/Enemy.cs b/td/Assets/Scripts/Enemy.cs
index eec02c9..4542902 100644
--- a/td/Assets/Scripts/Enemy.cs
+++ b/td/Assets/Scripts/Enemy.cs
@@ -6,9 +6,13 @@ public class Enemy : MonoBehaviour {
/* This is a general class that contains an enemy,
* Currently it follows the pathway, and dies when reacing the end */
+ [Header("Attributes")]
public float speed; // Speed multiplier
- public float initialHp; // HealthPoints
+ public int initialHp; // HealthPoints
+ public int damage;
public List<Vector3> waypoints; // Pathway waypoints, should be set by the spawner
+ [Header("Scripting vars")]
+ public player player; // Reference to the player object, should be set when instantiating
Vector3 waypointPos; // Current waypoint position
int waypointNum = -1; // Using minus one so that first addition returns 0, first element in array
@@ -24,7 +28,9 @@ public class Enemy : MonoBehaviour {
// Selfdestruct if object reached the end
if (waypointNum + 1 >= waypoints.Count) {
+ player.decreaseHealth (damage);
Destroy (gameObject);
+ return;
}
}