aboutsummaryrefslogtreecommitdiff
path: root/td
diff options
context:
space:
mode:
authorJakob Stendahl <jakob.stendahl@outlook.com>2017-09-30 16:52:54 +0200
committerJakob Stendahl <jakob.stendahl@outlook.com>2017-09-30 16:52:54 +0200
commit44bbc99517da0b0ee0251fbf519f117a3e7abfdb (patch)
tree40baabf071ffa191bc7dfb3ffc8c790c842f6f62 /td
parentbbf0d25b4681366780a9ed3755c6a1f1619d9996 (diff)
downloadTD-44bbc99517da0b0ee0251fbf519f117a3e7abfdb.tar.gz
TD-44bbc99517da0b0ee0251fbf519f117a3e7abfdb.zip
Worked on UI scaling, and added description to some of the scripts
Diffstat (limited to 'td')
-rw-r--r--td/Assets/Scenes/Level 1.unitybin80776 -> 86048 bytes
-rw-r--r--td/Assets/Scripts/Enemy.cs10
-rw-r--r--td/Assets/Scripts/EnemySpawner.cs3
-rw-r--r--td/Assets/Scripts/PinchZoom.cs144
-rw-r--r--td/Assets/Scripts/cameraHandler.cs1
-rw-r--r--td/Assets/Scripts/enableChild.cs12
-rw-r--r--td/Assets/Scripts/enableChild.cs.meta (renamed from td/Assets/Scripts/PinchZoom.cs.meta)4
-rw-r--r--td/ProjectSettings/ProjectSettings.assetbin52178 -> 52178 bytes
8 files changed, 24 insertions, 150 deletions
diff --git a/td/Assets/Scenes/Level 1.unity b/td/Assets/Scenes/Level 1.unity
index 5cc1e86..80bebb6 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 bd64bd5..eec02c9 100644
--- a/td/Assets/Scripts/Enemy.cs
+++ b/td/Assets/Scripts/Enemy.cs
@@ -3,12 +3,14 @@ using System.Collections.Generic;
using UnityEngine;
public class Enemy : MonoBehaviour {
+ /* This is a general class that contains an enemy,
+ * Currently it follows the pathway, and dies when reacing the end */
- public float speed;
- public float initialHp;
- public List<Vector3> waypoints;
+ public float speed; // Speed multiplier
+ public float initialHp; // HealthPoints
+ public List<Vector3> waypoints; // Pathway waypoints, should be set by the spawner
- Vector3 waypointPos;
+ Vector3 waypointPos; // Current waypoint position
int waypointNum = -1; // Using minus one so that first addition returns 0, first element in array
void Update () {
diff --git a/td/Assets/Scripts/EnemySpawner.cs b/td/Assets/Scripts/EnemySpawner.cs
index df82b34..02aa7d3 100644
--- a/td/Assets/Scripts/EnemySpawner.cs
+++ b/td/Assets/Scripts/EnemySpawner.cs
@@ -3,6 +3,9 @@ using System.Collections.Generic;
using UnityEngine;
public class EnemySpawner : MonoBehaviour {
+ /* This is a class that spawns an enemy with a random interval
+ * it is not very good, but is what it needs to be for testing purposes */
+ // TODO Add wave system with increasing difficulty
public Enemy enemyPrefab;
public Transform pathWay;
diff --git a/td/Assets/Scripts/PinchZoom.cs b/td/Assets/Scripts/PinchZoom.cs
deleted file mode 100644
index b3e6d22..0000000
--- a/td/Assets/Scripts/PinchZoom.cs
+++ /dev/null
@@ -1,144 +0,0 @@
-using UnityEngine;
-using System.Collections;
-
-public class PinchZoom : MonoBehaviour
-{
- /* Dette vil bare funke for et ortografisk kamera! */
-
- private static readonly float PanSpeed = 20f;
- private static readonly float ZoomSpeedTouch = 0.1f;
- private static readonly float ZoomSpeedMouse = .5f;
-
- public static readonly float[] BoundsX = new float[]{-10f, 5f};
- public static readonly float[] BoundsZ = new float[]{-18f, -4f};
- public static readonly float[] ZoomBounds = new float[]{10f, 85f};
-
- private Camera cam;
-
- private bool panActive;
- private Vector3 lastPanPosition;
- private int panFingerId; // Touch mode only
-
- private bool zoomActive;
- private Vector2[] lastZoomPositions; // Touch mode only
-
- void Awake() {
- cam = GetComponent<Camera>();
-
- #if UNITY_ANDROID || UNITY_IOS
- cam.fieldOfView = 60f;
- #endif
- }
-
- void Update() {
- // If there's an open menu, or the clicker is being pressed, ignore the touch.
- /*
- if (GameManager.Instance.MenuManager.HasOpenMenu || GameManager.Instance.BitSpawnManager.IsSpawningBits) {
- return;
- }*/
-
- if (Input.touchSupported && Application.platform != RuntimePlatform.WebGLPlayer) {
- HandleTouch();
- } else {
- HandleMouse();
- }
- }
-
- void HandleTouch() {
- switch(Input.touchCount) {
-
- case 1: // Panning
- zoomActive = false;
-
- // If the touch began, capture its position and its finger ID.
- // Otherwise, if the finger ID of the touch doesn't match, skip it.
- Touch touch = Input.GetTouch(0);
- if (touch.phase == TouchPhase.Began) {
- lastPanPosition = touch.position;
- panFingerId = touch.fingerId;
- panActive = true;
- } else if (touch.fingerId == panFingerId && touch.phase == TouchPhase.Moved) {
- PanCamera(touch.position);
- }
- break;
-
- case 2: // Zooming
- panActive = false;
-
- Vector2[] newPositions = new Vector2[]{Input.GetTouch(0).position, Input.GetTouch(1).position};
- if (!zoomActive) {
- lastZoomPositions = newPositions;
- zoomActive = true;
- } else {
- // Zoom based on the distance between the new positions compared to the
- // distance between the previous positions.
- float newDistance = Vector2.Distance(newPositions[0], newPositions[1]);
- float oldDistance = Vector2.Distance(lastZoomPositions[0], lastZoomPositions[1]);
- float offset = newDistance - oldDistance;
-
- ZoomCamera(offset, ZoomSpeedTouch);
-
- lastZoomPositions = newPositions;
- }
- break;
-
- default:
- panActive = false;
- zoomActive = false;
- break;
- }
- }
-
- void HandleMouse() {
- // On mouse down, capture it's position.
- // On mouse up, disable panning.
- // If there is no mouse being pressed, do nothing.
- if (Input.GetMouseButtonDown(0)) {
- panActive = true;
- lastPanPosition = Input.mousePosition;
- } else if (Input.GetMouseButtonUp(0)) {
- panActive = false;
- } else if (Input.GetMouseButton(0)) {
- PanCamera(Input.mousePosition);
- }
-
- // Check for scrolling to zoom the camera
- float scroll = Input.GetAxis("Mouse ScrollWheel");
- zoomActive = true;
- ZoomCamera(scroll, ZoomSpeedMouse);
- zoomActive = false;
- }
-
- void PanCamera(Vector3 newPanPosition) {
- if (!panActive) {
- return;
- }
-
- // Translate the camera position based on the new input position
- Vector3 offset = cam.ScreenToViewportPoint(lastPanPosition - newPanPosition);
- Vector3 move = new Vector3(offset.x * PanSpeed, 0, offset.y * PanSpeed);
- transform.Translate(move, Space.World);
- ClampToBounds();
-
- lastPanPosition = newPanPosition;
- }
-
- void ZoomCamera(float offset, float speed) {
- if (!zoomActive || offset == 0) {
- return;
- }
-
- cam.fieldOfView = Mathf.Clamp(cam.fieldOfView - (offset * speed), ZoomBounds[0], ZoomBounds[1]);
- }
-
- void ClampToBounds() {
- Vector3 pos = transform.position;
- pos.x = Mathf.Clamp(transform.position.x, BoundsX[0], BoundsX[1]);
- pos.z = Mathf.Clamp(transform.position.z, BoundsZ[0], BoundsZ[1]);
-
- transform.position = pos;
- }
-
-
-
-} \ No newline at end of file
diff --git a/td/Assets/Scripts/cameraHandler.cs b/td/Assets/Scripts/cameraHandler.cs
index 0504a23..c1c4cae 100644
--- a/td/Assets/Scripts/cameraHandler.cs
+++ b/td/Assets/Scripts/cameraHandler.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using UnityEngine;
public class cameraHandler : MonoBehaviour {
+ // TODO Fiks panning, ser idiotisk ut nå så jeg har satt panSpeed til 0. (I editoren)
public float PanSpeed = 20f;
public float ZoomSpeedTouch = 0.1f;
diff --git a/td/Assets/Scripts/enableChild.cs b/td/Assets/Scripts/enableChild.cs
new file mode 100644
index 0000000..50c7844
--- /dev/null
+++ b/td/Assets/Scripts/enableChild.cs
@@ -0,0 +1,12 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class enableChild : MonoBehaviour {
+ /* Denne klassen gjør ikke annet enn å aktivere det første childobjektet,
+ * nyttig om man vil skjule objekter når man designer,
+ * slik at man slipper å drive å skru objektene av og på mellom hver test manuelt */
+ void Start () {
+ this.gameObject.transform.GetChild (0).gameObject.SetActive (true);
+ }
+} \ No newline at end of file
diff --git a/td/Assets/Scripts/PinchZoom.cs.meta b/td/Assets/Scripts/enableChild.cs.meta
index 6303bbc..ab87395 100644
--- a/td/Assets/Scripts/PinchZoom.cs.meta
+++ b/td/Assets/Scripts/enableChild.cs.meta
@@ -1,6 +1,6 @@
fileFormatVersion: 2
-guid: 3770bdc9b6c954c1782333bdf04c01c6
-timeCreated: 1506636352
+guid: c726586371a844ca1adc60878d0dadf1
+timeCreated: 1506778993
licenseType: Free
MonoImporter:
serializedVersion: 2
diff --git a/td/ProjectSettings/ProjectSettings.asset b/td/ProjectSettings/ProjectSettings.asset
index 472756e..3182338 100644
--- a/td/ProjectSettings/ProjectSettings.asset
+++ b/td/ProjectSettings/ProjectSettings.asset
Binary files differ