From 368b2011816f0d269d56a1cc2565bc43912022e2 Mon Sep 17 00:00:00 2001 From: GamerClassN7 Date: Sat, 29 Jan 2022 22:37:40 +0100 Subject: [PATCH 1/5] Chunks --- .../Prefabs/Level chunks/level chunk 1.prefab | 9 - .../Prefabs/Level chunks/level chunk 2.prefab | 9 - .../Prefabs/Level chunks/level chunk 3.prefab | 9 - .../Prefabs/platforms/platform 2 power.prefab | 2 +- Assets/Scenes/Vasek.unity | 185 ++++++++---------- Assets/Scripts/ProceduralGeneration.cs | 7 +- 6 files changed, 84 insertions(+), 137 deletions(-) diff --git a/Assets/Prefabs/Level chunks/level chunk 1.prefab b/Assets/Prefabs/Level chunks/level chunk 1.prefab index fbf5a19..ed82881 100644 --- a/Assets/Prefabs/Level chunks/level chunk 1.prefab +++ b/Assets/Prefabs/Level chunks/level chunk 1.prefab @@ -9,7 +9,6 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 2957714535164430066} - - component: {fileID: 5113105489977215987} - component: {fileID: -6971605353857731775} m_Layer: 0 m_Name: level chunk 1 @@ -39,14 +38,6 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!33 &5113105489977215987 -MeshFilter: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1316835597118596560} - m_Mesh: {fileID: 0} --- !u!114 &-6971605353857731775 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/Level chunks/level chunk 2.prefab b/Assets/Prefabs/Level chunks/level chunk 2.prefab index 9588100..9b5b9cf 100644 --- a/Assets/Prefabs/Level chunks/level chunk 2.prefab +++ b/Assets/Prefabs/Level chunks/level chunk 2.prefab @@ -9,7 +9,6 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 2957714535164430066} - - component: {fileID: -2509422500240301154} - component: {fileID: -4978173286257615179} m_Layer: 0 m_Name: level chunk 2 @@ -39,14 +38,6 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!33 &-2509422500240301154 -MeshFilter: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1316835597118596560} - m_Mesh: {fileID: 0} --- !u!114 &-4978173286257615179 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/Level chunks/level chunk 3.prefab b/Assets/Prefabs/Level chunks/level chunk 3.prefab index 9af3213..ac6be4f 100644 --- a/Assets/Prefabs/Level chunks/level chunk 3.prefab +++ b/Assets/Prefabs/Level chunks/level chunk 3.prefab @@ -9,7 +9,6 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 2957714535164430066} - - component: {fileID: 1311810020695435140} - component: {fileID: 4501625178067468098} m_Layer: 0 m_Name: level chunk 3 @@ -46,14 +45,6 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!33 &1311810020695435140 -MeshFilter: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1316835597118596560} - m_Mesh: {fileID: 0} --- !u!114 &4501625178067468098 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/platforms/platform 2 power.prefab b/Assets/Prefabs/platforms/platform 2 power.prefab index 869d8c3..cc45524 100644 --- a/Assets/Prefabs/platforms/platform 2 power.prefab +++ b/Assets/Prefabs/platforms/platform 2 power.prefab @@ -112,7 +112,7 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 7678802340880963262} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 7.649} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: diff --git a/Assets/Scenes/Vasek.unity b/Assets/Scenes/Vasek.unity index 3285f3d..59b140c 100644 --- a/Assets/Scenes/Vasek.unity +++ b/Assets/Scenes/Vasek.unity @@ -123,6 +123,16 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} +--- !u!1 &126480931 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 2628890434173161082, guid: aa81b1bce294ebf42a0a5fff43100935, type: 3} + m_PrefabInstance: {fileID: 8134012580551448073} + m_PrefabAsset: {fileID: 0} +--- !u!4 &126480935 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 2628890434173161083, guid: aa81b1bce294ebf42a0a5fff43100935, type: 3} + m_PrefabInstance: {fileID: 8134012580551448073} + m_PrefabAsset: {fileID: 0} --- !u!1 &250075900 stripped GameObject: m_CorrespondingSourceObject: {fileID: 3244356566819001084, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3} @@ -157,7 +167,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: - - {fileID: 708734976} + - {fileID: 126480935} m_Father: {fileID: 0} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -181,9 +191,12 @@ MonoBehaviour: - {fileID: 8768991388683709947, guid: 97d4c453fb5affa448968cb5ce9ca2f4, type: 3} - {fileID: 8768991388683709947, guid: 1e3f34788e0cb3f49a0bef285d5b059a, type: 3} - {fileID: 8768991388683709947, guid: 2e18815c9b04872428df50ccfc059d03, type: 3} + - {fileID: 1316835597118596560, guid: 685c607395b2cfa46a548c481d178540, type: 3} + - {fileID: 1316835597118596560, guid: edd9e993fa2520f4095e33c7552ecd54, type: 3} + - {fileID: 1316835597118596560, guid: b140cd85c7d7ba64cbc9ab71d92e349e, type: 3} spawnedLevelBlocks: [] player: {fileID: 250075900} - lastBlock: {fileID: 708734972} + lastBlock: {fileID: 126480931} --- !u!1 &705507993 GameObject: m_ObjectHideFlags: 0 @@ -278,103 +291,6 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} ---- !u!1 &708734972 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 708734976} - - component: {fileID: 708734975} - - component: {fileID: 708734974} - - component: {fileID: 708734973} - m_Layer: 0 - m_Name: Cube - m_TagString: platform - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!65 &708734973 -BoxCollider: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 708734972} - m_Material: {fileID: 0} - m_IsTrigger: 0 - m_Enabled: 1 - serializedVersion: 2 - m_Size: {x: 1, y: 1, z: 1} - m_Center: {x: 0, y: 0, z: 0} ---- !u!23 &708734974 -MeshRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 708734972} - m_Enabled: 1 - m_CastShadows: 1 - m_ReceiveShadows: 1 - m_DynamicOccludee: 1 - m_StaticShadowCaster: 0 - m_MotionVectors: 1 - m_LightProbeUsage: 1 - m_ReflectionProbeUsage: 1 - m_RayTracingMode: 2 - m_RayTraceProcedural: 0 - m_RenderingLayerMask: 1 - m_RendererPriority: 0 - m_Materials: - - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} - m_StaticBatchInfo: - firstSubMesh: 0 - subMeshCount: 0 - m_StaticBatchRoot: {fileID: 0} - m_ProbeAnchor: {fileID: 0} - m_LightProbeVolumeOverride: {fileID: 0} - m_ScaleInLightmap: 1 - m_ReceiveGI: 1 - m_PreserveUVs: 0 - m_IgnoreNormalsForChartDetection: 0 - m_ImportantGI: 0 - m_StitchLightmapSeams: 1 - m_SelectedEditorRenderState: 3 - m_MinimumChartSize: 4 - m_AutoUVMaxDistance: 0.5 - m_AutoUVMaxAngle: 89 - m_LightmapParameters: {fileID: 0} - m_SortingLayerID: 0 - m_SortingLayer: 0 - m_SortingOrder: 0 - m_AdditionalVertexStreams: {fileID: 0} ---- !u!33 &708734975 -MeshFilter: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 708734972} - m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} ---- !u!4 &708734976 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 708734972} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 6.7204876, y: 1.5078, z: 16.238924} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 327689121} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &1287430439 PrefabInstance: m_ObjectHideFlags: 0 @@ -382,13 +298,13 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 0} m_Modifications: - - target: {fileID: 3244356566819001086, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3} - propertyPath: distanceFromYAxis - value: 30 + - target: {fileID: 3244356566819001085, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3} + propertyPath: m_LocalPosition.y + value: 1.82 objectReference: {fileID: 0} - - target: {fileID: 3244356566819001086, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3} - propertyPath: maxDistanceFromCenterLine - value: 30 + - target: {fileID: 3244356566819001085, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3} + propertyPath: m_LocalPosition.z + value: -0.44 objectReference: {fileID: 0} - target: {fileID: 3244356567786994344, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3} propertyPath: m_Name @@ -404,7 +320,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 3244356567786994345, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3} propertyPath: m_LocalPosition.y - value: 1.95 + value: 0 objectReference: {fileID: 0} - target: {fileID: 3244356567786994345, guid: ec622cf6f0988bc42a99ba84304c15a9, type: 3} propertyPath: m_LocalPosition.z @@ -489,3 +405,60 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1001 &8134012580551448073 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 327689121} + m_Modifications: + - target: {fileID: 2628890434173161082, guid: aa81b1bce294ebf42a0a5fff43100935, type: 3} + propertyPath: m_Name + value: Platform Start + objectReference: {fileID: 0} + - target: {fileID: 2628890434173161083, guid: aa81b1bce294ebf42a0a5fff43100935, type: 3} + propertyPath: m_RootOrder + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 2628890434173161083, guid: aa81b1bce294ebf42a0a5fff43100935, type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2628890434173161083, guid: aa81b1bce294ebf42a0a5fff43100935, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2628890434173161083, guid: aa81b1bce294ebf42a0a5fff43100935, type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2628890434173161083, guid: aa81b1bce294ebf42a0a5fff43100935, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 2628890434173161083, guid: aa81b1bce294ebf42a0a5fff43100935, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2628890434173161083, guid: aa81b1bce294ebf42a0a5fff43100935, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2628890434173161083, guid: aa81b1bce294ebf42a0a5fff43100935, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2628890434173161083, guid: aa81b1bce294ebf42a0a5fff43100935, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2628890434173161083, guid: aa81b1bce294ebf42a0a5fff43100935, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2628890434173161083, guid: aa81b1bce294ebf42a0a5fff43100935, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: aa81b1bce294ebf42a0a5fff43100935, type: 3} diff --git a/Assets/Scripts/ProceduralGeneration.cs b/Assets/Scripts/ProceduralGeneration.cs index 4102ccc..6cfd50d 100644 --- a/Assets/Scripts/ProceduralGeneration.cs +++ b/Assets/Scripts/ProceduralGeneration.cs @@ -22,7 +22,7 @@ public class ProceduralGeneration : MonoBehaviour if (renderers.Length > 0) { Bounds bounds = renderers[0].bounds; - for (int i = 1, ni = renderers.Length; i < ni; i++) + for (int i = 0; i < renderers.Length; i++) { bounds.Encapsulate(renderers[i].bounds); } @@ -32,13 +32,14 @@ public class ProceduralGeneration : MonoBehaviour { return new Bounds(); } + } GameObject drawPlatform(GameObject lastObject, GameObject objToSpawn, GameObject parentLevelObject) { Bounds bounds = this.getPrefabBounds(lastObject); Bounds b = new Bounds(bounds.center, bounds.size); - Vector3 nextBlockLocation = new Vector3(lastObject.transform.position.x, lastObject.transform.position.y, lastObject.transform.position.z + b.size.z + 1.0f); + Vector3 nextBlockLocation = new Vector3(lastObject.transform.position.x, lastObject.transform.position.y, lastObject.transform.position.z + b.size.z); GameObject newObject = Instantiate(objToSpawn, nextBlockLocation, (Quaternion.identity)); newObject.transform.parent = parentLevelObject.transform; @@ -60,7 +61,7 @@ public class ProceduralGeneration : MonoBehaviour Bounds bounds = this.getPrefabBounds(lastObject); Bounds b = new Bounds(bounds.center, bounds.size); - Vector3 centerPoint = new Vector3(lastObject.transform.position.x, (lastObject.transform.position.y + radius), lastObject.transform.position.z + b.size.z + 1.0f); + Vector3 centerPoint = new Vector3(lastObject.transform.position.x, (lastObject.transform.position.y + radius), lastObject.transform.position.z + b.size.z); float heightOffset = radius; From 015cefe9b79c5ab39dc4c651fb649b2940d0f64f Mon Sep 17 00:00:00 2001 From: nexovec Date: Sat, 29 Jan 2022 22:45:27 +0100 Subject: [PATCH 2/5] fixed maxDistanceFromCenterLine --- Assets/Scripts/PlayerController.cs | 3 +-- Assets/Scripts/UiController.cs | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index 1eaf314..1c77170 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -4,7 +4,7 @@ using UnityEngine; public class PlayerController : MonoBehaviour { - public float maxDistanceFromCenterLine; + public float maxDistanceFromCenterLine = 30.0f; [Header("Move")] public float speed = 7.5f; public float maxSpeed = 15.0f; @@ -167,7 +167,6 @@ public class PlayerController : MonoBehaviour Debug.Log("Player fell out of map."); rb.velocity = Vector3.zero; Physics.gravity = -Vector3.up * 9.81f; - UnityEngine.SceneManagement.SceneManager.LoadScene(0); } } diff --git a/Assets/Scripts/UiController.cs b/Assets/Scripts/UiController.cs index 5634f57..8b9e427 100644 --- a/Assets/Scripts/UiController.cs +++ b/Assets/Scripts/UiController.cs @@ -8,6 +8,7 @@ public class UiController : MonoBehaviour public GameObject player = null; private float startPosition; public TextMeshProUGUI uiDistance; + public int highScore; public float distance = 0.0f; private float oldDistance = 0.0f; @@ -17,6 +18,27 @@ public class UiController : MonoBehaviour startPosition = this.player.transform.position.z; Cursor.lockState = CursorLockMode.None; Cursor.visible = true; + + PlayerController.LoadSave(); + } + static void SaveGame() + { + PlayerPrefs.SetInt(PlayerController.highScore); + PlayerPrefs.Save(); + Debug.Log("Game data saved!"); + } + void LoadGame() + { + if (PlayerPrefs.HasKey("HighestScore")) + { + this.highScore = PlayerPrefs.GetInt("SavedInteger"); + Debug.Log("Game data loaded!"); + } + else + { + this.highScore = 0; + } + } // Update is called once per frame From a1b7db1ef191951fb5987f41fe54938eaf7a961c Mon Sep 17 00:00:00 2001 From: nexovec Date: Sat, 29 Jan 2022 22:46:05 +0100 Subject: [PATCH 3/5] fixed UiController error --- Assets/Scripts/UiController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/UiController.cs b/Assets/Scripts/UiController.cs index 8b9e427..996df44 100644 --- a/Assets/Scripts/UiController.cs +++ b/Assets/Scripts/UiController.cs @@ -19,9 +19,9 @@ public class UiController : MonoBehaviour Cursor.lockState = CursorLockMode.None; Cursor.visible = true; - PlayerController.LoadSave(); + this.LoadSave(); } - static void SaveGame() + void SaveGame() { PlayerPrefs.SetInt(PlayerController.highScore); PlayerPrefs.Save(); From 7a964f17d9bea58e0f8d3aa4adc26d09c63e5e37 Mon Sep 17 00:00:00 2001 From: nexovec Date: Sat, 29 Jan 2022 22:46:34 +0100 Subject: [PATCH 4/5] fixed the real UiController error --- Assets/Scripts/UiController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Scripts/UiController.cs b/Assets/Scripts/UiController.cs index 996df44..29489e0 100644 --- a/Assets/Scripts/UiController.cs +++ b/Assets/Scripts/UiController.cs @@ -19,7 +19,7 @@ public class UiController : MonoBehaviour Cursor.lockState = CursorLockMode.None; Cursor.visible = true; - this.LoadSave(); + this.LoadGame(); } void SaveGame() { From bae7aa1239e3052e4077c820816f4c84055d215a Mon Sep 17 00:00:00 2001 From: nexovec Date: Sat, 29 Jan 2022 22:48:48 +0100 Subject: [PATCH 5/5] I am really sorry. --- Assets/Scripts/UiController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/Scripts/UiController.cs b/Assets/Scripts/UiController.cs index 29489e0..3b30171 100644 --- a/Assets/Scripts/UiController.cs +++ b/Assets/Scripts/UiController.cs @@ -23,7 +23,7 @@ public class UiController : MonoBehaviour } void SaveGame() { - PlayerPrefs.SetInt(PlayerController.highScore); + PlayerPrefs.SetInt("HighestScore", this.highScore); PlayerPrefs.Save(); Debug.Log("Game data saved!"); }