diff options
author | Jakob Stendahl <jakob.stendahl@outlook.com> | 2017-10-07 22:57:48 +0200 |
---|---|---|
committer | Jakob Stendahl <jakob.stendahl@outlook.com> | 2017-10-07 22:57:48 +0200 |
commit | 09c0b2eed74a77010ba686061b147c9cace88ed6 (patch) | |
tree | 9b5c013fc7a679ccca3e2074773d29d7f1674bbc /td/Assets/Scripts/Enemy.cs | |
parent | 69a6cc2555d8dfc8314a08e6cef6b67fa1177bf0 (diff) | |
download | TD-09c0b2eed74a77010ba686061b147c9cace88ed6.tar.gz TD-09c0b2eed74a77010ba686061b147c9cace88ed6.zip |
Trur æ la te VCS, ikke meninga, men æ trur itj de e nå problem egt
Diffstat (limited to 'td/Assets/Scripts/Enemy.cs')
-rw-r--r-- | td/Assets/Scripts/Enemy.cs | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/td/Assets/Scripts/Enemy.cs b/td/Assets/Scripts/Enemy.cs index 4542902..3074003 100644 --- a/td/Assets/Scripts/Enemy.cs +++ b/td/Assets/Scripts/Enemy.cs @@ -1,5 +1,4 @@ -using System.Collections; -using System.Collections.Generic; +using System.Collections.Generic; using UnityEngine; public class Enemy : MonoBehaviour { @@ -7,28 +6,28 @@ public class Enemy : MonoBehaviour { * Currently it follows the pathway, and dies when reacing the end */ [Header("Attributes")] - public float speed; // Speed multiplier - public int initialHp; // HealthPoints - public int damage; - public List<Vector3> waypoints; // Pathway waypoints, should be set by the spawner + public float Speed; // Speed multiplier + 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 + 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 + private Vector3 _waypointPos; // Current waypoint position + private int _waypointNum = -1; // Using minus one so that first addition returns 0, first element in array void Update () { - if ( (transform.position == waypointPos && waypointNum + 1 < waypoints.Count) || waypointNum == -1) { - waypointNum++; - waypointPos = new Vector3 (waypoints [waypointNum].x, 0.483f, waypoints [waypointNum].z); + if ( (transform.position == _waypointPos && _waypointNum + 1 < Waypoints.Count) || _waypointNum == -1) { + _waypointNum++; + _waypointPos = new Vector3 (Waypoints [_waypointNum].x, 0.483f, Waypoints [_waypointNum].z); } - float transformStep = speed * Time.deltaTime; - transform.position = Vector3.MoveTowards (transform.position, waypointPos, transformStep); + float transformStep = Speed * Time.deltaTime; + transform.position = Vector3.MoveTowards (transform.position, _waypointPos, transformStep); // Selfdestruct if object reached the end - if (waypointNum + 1 >= waypoints.Count) { - player.decreaseHealth (damage); + if (_waypointNum + 1 >= Waypoints.Count) { + Player.DecreaseHealth (Damage); Destroy (gameObject); return; } |