diff options
author | marcinzelent <zelent.marcin@gmail.com> | 2019-04-28 08:57:14 +0200 |
---|---|---|
committer | marcinzelent <zelent.marcin@gmail.com> | 2019-04-28 08:57:14 +0200 |
commit | 85441632d65425bdcaa76097e44e1f6f1f3bae7f (patch) | |
tree | 8ab4b462919eb826467563634339490e0b3d993b /nGJ2019/Assets/Scripts | |
parent | 397abd83dc791d0d8cbbd20d918164c0c37143da (diff) |
Added procedural obstacle generation to level 1
Diffstat (limited to 'nGJ2019/Assets/Scripts')
-rw-r--r-- | nGJ2019/Assets/Scripts/ObstacleSpawner.cs | 35 | ||||
-rw-r--r-- | nGJ2019/Assets/Scripts/TitleScreen.cs | 2 |
2 files changed, 29 insertions, 8 deletions
diff --git a/nGJ2019/Assets/Scripts/ObstacleSpawner.cs b/nGJ2019/Assets/Scripts/ObstacleSpawner.cs index bea85b2..84bc0d9 100644 --- a/nGJ2019/Assets/Scripts/ObstacleSpawner.cs +++ b/nGJ2019/Assets/Scripts/ObstacleSpawner.cs @@ -1,4 +1,5 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; using UnityEngine; @@ -73,14 +74,34 @@ public class ObstacleSpawner : MonoBehaviour } else if (scene.name == "Level1") { + System.Random random = new System.Random(); for (int i = 0; i < 1000; i++) { - timeline.Add(i * 2.5f, new Vector3(0, 0, 0), ObstacleType.caveWalls); - timeline.Add(i * 12.5f + 3, new Vector3(0, 2.75f, 0), ObstacleType.rockTop); - timeline.Add(i * 12.5f + 6, new Vector3(0, -2, 0), ObstacleType.rockBottom); - timeline.Add(i * 12.5f + 9, new Vector3(0, 0, 0), ObstacleType.narrowPassage); - timeline.Add(i * 12.5f + 12.5f, new Vector3(0, -2.5f, 2), ObstacleType.rockJaws); - timeline.Add(i * 12.5f + 15f, new Vector3(0, 0.5f, 3), ObstacleType.net); + timeline.Add(i * 2.5f, new Vector3(0,0,0), ObstacleType.caveWalls); + + Array values = Enum.GetValues(typeof(ObstacleType)); + ObstacleType randomObstacle = (ObstacleType)values.GetValue(random.Next(values.Length)); + Vector3 position; + + switch (randomObstacle) + { + case ObstacleType.rockTop: + position = new Vector3(0, 2.75f, 0); + break; + case ObstacleType.rockBottom: + position = new Vector3(0, -2, 0); + break; + case ObstacleType.rockJaws: + position = new Vector3(0, -2.5f, 2); + break; + case ObstacleType.net: + position = new Vector3(0, 0.5f, 3); + break; + default: + position = new Vector3(0,0,0); + break; + } + timeline.Add(i * 4, position, randomObstacle); } } diff --git a/nGJ2019/Assets/Scripts/TitleScreen.cs b/nGJ2019/Assets/Scripts/TitleScreen.cs index 3ec62b2..bf37785 100644 --- a/nGJ2019/Assets/Scripts/TitleScreen.cs +++ b/nGJ2019/Assets/Scripts/TitleScreen.cs @@ -13,7 +13,7 @@ public class TitleScreen : MonoBehaviour Application.Quit(); } - public void ToLevel1() + public void OpenTutorial() { SceneManager.LoadScene("Tutorial"); } |