From b1a279b551e2127ff9f530b205f2e1590ae51e9f Mon Sep 17 00:00:00 2001 From: marcinzelent Date: Sat, 27 Apr 2019 12:19:37 +0200 Subject: Added level obstacles spawning --- nGJ2019/Assets/Scripts/ObstacleSpawner.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'nGJ2019/Assets/Scripts/ObstacleSpawner.cs') diff --git a/nGJ2019/Assets/Scripts/ObstacleSpawner.cs b/nGJ2019/Assets/Scripts/ObstacleSpawner.cs index d007513..7be5b33 100644 --- a/nGJ2019/Assets/Scripts/ObstacleSpawner.cs +++ b/nGJ2019/Assets/Scripts/ObstacleSpawner.cs @@ -8,6 +8,7 @@ public class ObstacleSpawner : MonoBehaviour public GameObject alfaPrefab; public GameObject betaPrefab; + public LevelScrolling scrolling; public float spawnLine; @@ -21,15 +22,16 @@ public class ObstacleSpawner : MonoBehaviour if(e.type == EventTimeline.SpawnEventType.beta) prefab = betaPrefab; - Instantiate(prefab, new Vector3(spawnLine, e.height, 0), Quaternion.identity); + var transformT = ((GameObject) Instantiate(prefab, new Vector3(spawnLine, e.height, 0), Quaternion.identity)).transform; + scrolling.Obstacles.Add(transformT); } void Start() { - timeline.Add(2, 2, EventTimeline.SpawnEventType.alfa); - timeline.Add(4, 2, EventTimeline.SpawnEventType.beta); - timeline.Add(5, -2, EventTimeline.SpawnEventType.beta); - timeline.Add(7, -3, EventTimeline.SpawnEventType.alfa); + for(int i = 0; i < 120; i += 5) + { + timeline.Add(i, 0, EventTimeline.SpawnEventType.alfa); + } timeline.OnSpawnEvent += spawnOnEvent; } -- cgit v1.2.3 From 78bb8f508879ae0fdfec7b1970aa83bbce4c404e Mon Sep 17 00:00:00 2001 From: marcinzelent Date: Sat, 27 Apr 2019 12:25:51 +0200 Subject: Fixed level obstacle spawning --- nGJ2019/Assets/Scripts/ObstacleSpawner.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nGJ2019/Assets/Scripts/ObstacleSpawner.cs') diff --git a/nGJ2019/Assets/Scripts/ObstacleSpawner.cs b/nGJ2019/Assets/Scripts/ObstacleSpawner.cs index 58c0ebb..102df97 100644 --- a/nGJ2019/Assets/Scripts/ObstacleSpawner.cs +++ b/nGJ2019/Assets/Scripts/ObstacleSpawner.cs @@ -30,7 +30,7 @@ public class ObstacleSpawner : MonoBehaviour { for(int i = 0; i < 120; i += 5) { - timeline.Add(i, 0, EventTimeline.SpawnEventType.alfa); + timeline.Add(i, 0, ObstacleType.alfa); } timeline.OnSpawnEvent += spawnOnEvent; -- cgit v1.2.3