From 85441632d65425bdcaa76097e44e1f6f1f3bae7f Mon Sep 17 00:00:00 2001 From: marcinzelent Date: Sun, 28 Apr 2019 08:57:14 +0200 Subject: Added procedural obstacle generation to level 1 --- nGJ2019/Assets/Scenes/Level1.unity | 4 +-- nGJ2019/Assets/Scenes/TitleScreen.unity | 2 +- nGJ2019/Assets/Scenes/Tutorial.unity | 4 +-- nGJ2019/Assets/Scripts/ObstacleSpawner.cs | 35 ++++++++++++++++++----- nGJ2019/Assets/Scripts/TitleScreen.cs | 2 +- nGJ2019/ProjectSettings/EditorBuildSettings.asset | 3 ++ 6 files changed, 37 insertions(+), 13 deletions(-) (limited to 'nGJ2019') diff --git a/nGJ2019/Assets/Scenes/Level1.unity b/nGJ2019/Assets/Scenes/Level1.unity index f085597..1dd6d50 100644 --- a/nGJ2019/Assets/Scenes/Level1.unity +++ b/nGJ2019/Assets/Scenes/Level1.unity @@ -558,7 +558,7 @@ PrefabInstance: - target: {fileID: 1540055299232912360, guid: 439782ce0455fb740be2c55da31ff44f, type: 3} propertyPath: m_LocalPosition.y - value: 0.13672495 + value: -1.09 objectReference: {fileID: 0} - target: {fileID: 1540055299232912360, guid: 439782ce0455fb740be2c55da31ff44f, type: 3} @@ -871,7 +871,7 @@ MonoBehaviour: type: 3} liveCrystal: {fileID: 2100000, guid: d19c2d3c342b20c46b03be1f5369081d, type: 2} deadCrystal: {fileID: 2100000, guid: a772733e42c983144b0a01570895aa30, type: 2} - lives: 10 + lives: 3 --- !u!4 &1651299503 Transform: m_ObjectHideFlags: 0 diff --git a/nGJ2019/Assets/Scenes/TitleScreen.unity b/nGJ2019/Assets/Scenes/TitleScreen.unity index b1d2c21..84c0188 100644 --- a/nGJ2019/Assets/Scenes/TitleScreen.unity +++ b/nGJ2019/Assets/Scenes/TitleScreen.unity @@ -420,7 +420,7 @@ MonoBehaviour: m_PersistentCalls: m_Calls: - m_Target: {fileID: 164273593} - m_MethodName: ToLevel1 + m_MethodName: OpenTutorial m_Mode: 1 m_Arguments: m_ObjectArgument: {fileID: 0} diff --git a/nGJ2019/Assets/Scenes/Tutorial.unity b/nGJ2019/Assets/Scenes/Tutorial.unity index 4aaf866..667f6ab 100644 --- a/nGJ2019/Assets/Scenes/Tutorial.unity +++ b/nGJ2019/Assets/Scenes/Tutorial.unity @@ -558,7 +558,7 @@ PrefabInstance: - target: {fileID: 1540055299232912360, guid: 439782ce0455fb740be2c55da31ff44f, type: 3} propertyPath: m_LocalPosition.y - value: 0.13672495 + value: -1.09 objectReference: {fileID: 0} - target: {fileID: 1540055299232912360, guid: 439782ce0455fb740be2c55da31ff44f, type: 3} @@ -871,7 +871,7 @@ MonoBehaviour: type: 3} liveCrystal: {fileID: 2100000, guid: d19c2d3c342b20c46b03be1f5369081d, type: 2} deadCrystal: {fileID: 2100000, guid: a772733e42c983144b0a01570895aa30, type: 2} - lives: 10 + lives: 3 --- !u!4 &1651299503 Transform: m_ObjectHideFlags: 0 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"); } diff --git a/nGJ2019/ProjectSettings/EditorBuildSettings.asset b/nGJ2019/ProjectSettings/EditorBuildSettings.asset index 0ee97ee..d3b83c9 100644 --- a/nGJ2019/ProjectSettings/EditorBuildSettings.asset +++ b/nGJ2019/ProjectSettings/EditorBuildSettings.asset @@ -11,6 +11,9 @@ EditorBuildSettings: - enabled: 1 path: Assets/Scenes/TitleScreen.unity guid: c4c57d7c5fa5949e98222bc1dceab32c + - enabled: 1 + path: Assets/Scenes/Tutorial.unity + guid: 414df89fcb738420884bf28a8c6af277 - enabled: 1 path: Assets/Scenes/Level1.unity guid: 2f8dea1770fc3400f8aab8dd0cdc0140 -- cgit v1.2.3