aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Stendahl <jakob.stendahl@outlook.com>2017-09-29 17:27:14 +0200
committerJakob Stendahl <jakob.stendahl@outlook.com>2017-09-29 17:27:14 +0200
commit9fbde9c25ee0707379ef7bd7a1b8d4a2e9531437 (patch)
treec266ad8684f8d389b54be541bcef1c74e6aaa882
parentda2d66ed82bec696e2d759fc1e9215fabea07ce3 (diff)
downloadTD-9fbde9c25ee0707379ef7bd7a1b8d4a2e9531437.tar.gz
TD-9fbde9c25ee0707379ef7bd7a1b8d4a2e9531437.zip
Small workaround for where the enemy catches player
-rw-r--r--td/Assets/Scenes/Level 1.unitybin47656 -> 47976 bytes
-rw-r--r--td/Assets/Scripts/Enemy.cs15
-rw-r--r--td/Assets/Scripts/EnemySpawner.cs3
-rw-r--r--td/Assets/Scripts/cameraHandler.cs4
4 files changed, 9 insertions, 13 deletions
diff --git a/td/Assets/Scenes/Level 1.unity b/td/Assets/Scenes/Level 1.unity
index d48cc6e..aeb84e1 100644
--- a/td/Assets/Scenes/Level 1.unity
+++ b/td/Assets/Scenes/Level 1.unity
Binary files differ
diff --git a/td/Assets/Scripts/Enemy.cs b/td/Assets/Scripts/Enemy.cs
index edd9e29..bd64bd5 100644
--- a/td/Assets/Scripts/Enemy.cs
+++ b/td/Assets/Scripts/Enemy.cs
@@ -12,21 +12,18 @@ public class Enemy : MonoBehaviour {
int waypointNum = -1; // Using minus one so that first addition returns 0, first element in array
void Update () {
- updateWaypoint ();
+ 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);
- if (waypointNum == waypoints.Count - 1) {
+ // Selfdestruct if object reached the end
+ if (waypointNum + 1 >= waypoints.Count) {
Destroy (gameObject);
}
}
-
- void updateWaypoint() {
- if ( (transform.position == waypointPos && waypointNum < waypoints.Count - 1) || waypointNum == -1) {
- waypointNum++;
- waypointPos = new Vector3 (waypoints [waypointNum].x, 0.483f, waypoints [waypointNum].z);
- }
- }
}
diff --git a/td/Assets/Scripts/EnemySpawner.cs b/td/Assets/Scripts/EnemySpawner.cs
index f1eeb84..df82b34 100644
--- a/td/Assets/Scripts/EnemySpawner.cs
+++ b/td/Assets/Scripts/EnemySpawner.cs
@@ -7,9 +7,8 @@ public class EnemySpawner : MonoBehaviour {
public Enemy enemyPrefab;
public Transform pathWay;
public Transform gameWorld;
- List<Vector3> waypoints = new List<Vector3>();
- int wave;
+ List<Vector3> waypoints = new List<Vector3>();
int next = 1;
int n = 0;
diff --git a/td/Assets/Scripts/cameraHandler.cs b/td/Assets/Scripts/cameraHandler.cs
index a4aa660..0504a23 100644
--- a/td/Assets/Scripts/cameraHandler.cs
+++ b/td/Assets/Scripts/cameraHandler.cs
@@ -36,9 +36,9 @@ public class cameraHandler : MonoBehaviour {
if (Input.touchSupported && Application.platform != RuntimePlatform.WebGLPlayer) {
HandleTouch();
} else {
- //HandleMouse();
+ HandleMouse();
}
- HandleTouch ();
+ //HandleTouch ();
}
void HandleTouch() {