From 69a6cc2555d8dfc8314a08e6cef6b67fa1177bf0 Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Sat, 7 Oct 2017 21:16:23 +0200 Subject: Made projectiles, and working health system --- td/Assets/Scripts/Enemy.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'td/Assets/Scripts/Enemy.cs') 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 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; } } -- cgit v1.2.3