diff options
author | marcinzelent <zelent.marcin@gmail.com> | 2019-04-27 12:19:37 +0200 |
---|---|---|
committer | marcinzelent <zelent.marcin@gmail.com> | 2019-04-27 12:19:37 +0200 |
commit | b1a279b551e2127ff9f530b205f2e1590ae51e9f (patch) | |
tree | 3c4518fbec740f51cbf138edb1087eccdaf1305e /nGJ2019/Assets/Scripts/ObstacleSpawner.cs | |
parent | dd7a4adbea30ab2e4435a314e8a3a570ed09a695 (diff) |
Added level obstacles spawning
Diffstat (limited to 'nGJ2019/Assets/Scripts/ObstacleSpawner.cs')
-rw-r--r-- | nGJ2019/Assets/Scripts/ObstacleSpawner.cs | 12 |
1 files changed, 7 insertions, 5 deletions
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; } |