mirror of
				https://github.com/boudji-ludwig-pett/cnam-geometry-dash.git
				synced 2025-06-27 11:58:51 +02:00 
			
		
		
		
	feat: handle dynamically the winner wall (#40)
This commit is contained in:
		| @@ -1,5 +1,17 @@ | ||||
| { | ||||
|     "name": "Back on Track", | ||||
|     "musicName": "BackOnTrack", | ||||
|     "order": 2 | ||||
|     "order": 2, | ||||
|     "elements": [ | ||||
|         { | ||||
|             "type": 1, | ||||
|             "x": -6.684000015258789, | ||||
|             "y": -2.8970000743865969 | ||||
|         }, | ||||
|         { | ||||
|             "type": 1, | ||||
|             "x": -3.059999942779541, | ||||
|             "y": -2.930000066757202 | ||||
|         } | ||||
|     ] | ||||
| } | ||||
|   | ||||
							
								
								
									
										136
									
								
								Assets/Resources/Prefabs/WinnerWall.prefab
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										136
									
								
								Assets/Resources/Prefabs/WinnerWall.prefab
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,136 @@ | ||||
| %YAML 1.1 | ||||
| %TAG !u! tag:unity3d.com,2011: | ||||
| --- !u!1 &230614802678176698 | ||||
| GameObject: | ||||
|   m_ObjectHideFlags: 0 | ||||
|   m_CorrespondingSourceObject: {fileID: 0} | ||||
|   m_PrefabInstance: {fileID: 0} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
|   serializedVersion: 6 | ||||
|   m_Component: | ||||
|   - component: {fileID: 6101474696094060898} | ||||
|   - component: {fileID: 2586486806421690950} | ||||
|   - component: {fileID: 4807228918295367566} | ||||
|   m_Layer: 0 | ||||
|   m_Name: WinnerWall | ||||
|   m_TagString: Win | ||||
|   m_Icon: {fileID: 0} | ||||
|   m_NavMeshLayer: 0 | ||||
|   m_StaticEditorFlags: 0 | ||||
|   m_IsActive: 1 | ||||
| --- !u!4 &6101474696094060898 | ||||
| Transform: | ||||
|   m_ObjectHideFlags: 0 | ||||
|   m_CorrespondingSourceObject: {fileID: 0} | ||||
|   m_PrefabInstance: {fileID: 0} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
|   m_GameObject: {fileID: 230614802678176698} | ||||
|   serializedVersion: 2 | ||||
|   m_LocalRotation: {x: -0.027460787, y: -0.027460786, z: 0.70657337, w: 0.70657337} | ||||
|   m_LocalPosition: {x: 40.61, y: -5.69, z: 0} | ||||
|   m_LocalScale: {x: 10, y: 0.8581, z: 1} | ||||
|   m_ConstrainProportionsScale: 0 | ||||
|   m_Children: [] | ||||
|   m_Father: {fileID: 0} | ||||
|   m_LocalEulerAnglesHint: {x: 0, y: -4.451, z: 90} | ||||
| --- !u!212 &2586486806421690950 | ||||
| SpriteRenderer: | ||||
|   m_ObjectHideFlags: 0 | ||||
|   m_CorrespondingSourceObject: {fileID: 0} | ||||
|   m_PrefabInstance: {fileID: 0} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
|   m_GameObject: {fileID: 230614802678176698} | ||||
|   m_Enabled: 1 | ||||
|   m_CastShadows: 0 | ||||
|   m_ReceiveShadows: 0 | ||||
|   m_DynamicOccludee: 1 | ||||
|   m_StaticShadowCaster: 0 | ||||
|   m_MotionVectors: 1 | ||||
|   m_LightProbeUsage: 1 | ||||
|   m_ReflectionProbeUsage: 1 | ||||
|   m_RayTracingMode: 0 | ||||
|   m_RayTraceProcedural: 0 | ||||
|   m_RayTracingAccelStructBuildFlagsOverride: 0 | ||||
|   m_RayTracingAccelStructBuildFlags: 1 | ||||
|   m_SmallMeshCulling: 1 | ||||
|   m_RenderingLayerMask: 1 | ||||
|   m_RendererPriority: 0 | ||||
|   m_Materials: | ||||
|   - {fileID: 10754, 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: 0 | ||||
|   m_MinimumChartSize: 4 | ||||
|   m_AutoUVMaxDistance: 0.5 | ||||
|   m_AutoUVMaxAngle: 89 | ||||
|   m_LightmapParameters: {fileID: 0} | ||||
|   m_SortingLayerID: 0 | ||||
|   m_SortingLayer: 0 | ||||
|   m_SortingOrder: 0 | ||||
|   m_Sprite: {fileID: -2257217325195158302, guid: a192a62ef32304b4182909c80a175f39, type: 3} | ||||
|   m_Color: {r: 1, g: 1, b: 1, a: 1} | ||||
|   m_FlipX: 0 | ||||
|   m_FlipY: 0 | ||||
|   m_DrawMode: 0 | ||||
|   m_Size: {x: 5.12, y: 5.12} | ||||
|   m_AdaptiveModeThreshold: 0.5 | ||||
|   m_SpriteTileMode: 0 | ||||
|   m_WasSpriteAssigned: 1 | ||||
|   m_MaskInteraction: 0 | ||||
|   m_SpriteSortPoint: 0 | ||||
| --- !u!61 &4807228918295367566 | ||||
| BoxCollider2D: | ||||
|   m_ObjectHideFlags: 0 | ||||
|   m_CorrespondingSourceObject: {fileID: 0} | ||||
|   m_PrefabInstance: {fileID: 0} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
|   m_GameObject: {fileID: 230614802678176698} | ||||
|   m_Enabled: 1 | ||||
|   serializedVersion: 3 | ||||
|   m_Density: 1 | ||||
|   m_Material: {fileID: 0} | ||||
|   m_IncludeLayers: | ||||
|     serializedVersion: 2 | ||||
|     m_Bits: 0 | ||||
|   m_ExcludeLayers: | ||||
|     serializedVersion: 2 | ||||
|     m_Bits: 0 | ||||
|   m_LayerOverridePriority: 0 | ||||
|   m_ForceSendLayers: | ||||
|     serializedVersion: 2 | ||||
|     m_Bits: 4294967295 | ||||
|   m_ForceReceiveLayers: | ||||
|     serializedVersion: 2 | ||||
|     m_Bits: 4294967295 | ||||
|   m_ContactCaptureLayers: | ||||
|     serializedVersion: 2 | ||||
|     m_Bits: 4294967295 | ||||
|   m_CallbackLayers: | ||||
|     serializedVersion: 2 | ||||
|     m_Bits: 4294967295 | ||||
|   m_IsTrigger: 0 | ||||
|   m_UsedByEffector: 0 | ||||
|   m_CompositeOperation: 0 | ||||
|   m_CompositeOrder: 0 | ||||
|   m_Offset: {x: 0, y: 0} | ||||
|   m_SpriteTilingProperty: | ||||
|     border: {x: 0, y: 0, z: 0, w: 0} | ||||
|     pivot: {x: 0.5, y: 0.5} | ||||
|     oldSize: {x: 5.12, y: 5.12} | ||||
|     newSize: {x: 5.12, y: 5.12} | ||||
|     adaptiveTilingThreshold: 0.5 | ||||
|     drawMode: 0 | ||||
|     adaptiveTiling: 0 | ||||
|   m_AutoTiling: 0 | ||||
|   m_Size: {x: 5.12, y: 5.12} | ||||
|   m_EdgeRadius: 0 | ||||
							
								
								
									
										7
									
								
								Assets/Resources/Prefabs/WinnerWall.prefab.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								Assets/Resources/Prefabs/WinnerWall.prefab.meta
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,7 @@ | ||||
| fileFormatVersion: 2 | ||||
| guid: b4ab610574c1d61afb90b28c5d673fe1 | ||||
| PrefabImporter: | ||||
|   externalObjects: {} | ||||
|   userData:  | ||||
|   assetBundleName:  | ||||
|   assetBundleVariant:  | ||||
| @@ -5493,6 +5493,8 @@ MonoBehaviour: | ||||
|   m_EditorClassIdentifier:  | ||||
|   levelsLoader: {fileID: 0} | ||||
|   audioSource: {fileID: 1999482188} | ||||
|   obstaclePrefab: {fileID: 0} | ||||
|   spikePrefab: {fileID: 0} | ||||
| --- !u!4 &1999482187 | ||||
| Transform: | ||||
|   m_ObjectHideFlags: 0 | ||||
| @@ -5605,140 +5607,6 @@ AudioSource: | ||||
|     m_PreInfinity: 2 | ||||
|     m_PostInfinity: 2 | ||||
|     m_RotationOrder: 4 | ||||
| --- !u!1 &2062107675 | ||||
| GameObject: | ||||
|   m_ObjectHideFlags: 0 | ||||
|   m_CorrespondingSourceObject: {fileID: 0} | ||||
|   m_PrefabInstance: {fileID: 0} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
|   serializedVersion: 6 | ||||
|   m_Component: | ||||
|   - component: {fileID: 2062107678} | ||||
|   - component: {fileID: 2062107677} | ||||
|   - component: {fileID: 2062107676} | ||||
|   m_Layer: 0 | ||||
|   m_Name: WinnerWall | ||||
|   m_TagString: Win | ||||
|   m_Icon: {fileID: 0} | ||||
|   m_NavMeshLayer: 0 | ||||
|   m_StaticEditorFlags: 0 | ||||
|   m_IsActive: 1 | ||||
| --- !u!61 &2062107676 | ||||
| BoxCollider2D: | ||||
|   m_ObjectHideFlags: 0 | ||||
|   m_CorrespondingSourceObject: {fileID: 0} | ||||
|   m_PrefabInstance: {fileID: 0} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
|   m_GameObject: {fileID: 2062107675} | ||||
|   m_Enabled: 1 | ||||
|   serializedVersion: 3 | ||||
|   m_Density: 1 | ||||
|   m_Material: {fileID: 0} | ||||
|   m_IncludeLayers: | ||||
|     serializedVersion: 2 | ||||
|     m_Bits: 0 | ||||
|   m_ExcludeLayers: | ||||
|     serializedVersion: 2 | ||||
|     m_Bits: 0 | ||||
|   m_LayerOverridePriority: 0 | ||||
|   m_ForceSendLayers: | ||||
|     serializedVersion: 2 | ||||
|     m_Bits: 4294967295 | ||||
|   m_ForceReceiveLayers: | ||||
|     serializedVersion: 2 | ||||
|     m_Bits: 4294967295 | ||||
|   m_ContactCaptureLayers: | ||||
|     serializedVersion: 2 | ||||
|     m_Bits: 4294967295 | ||||
|   m_CallbackLayers: | ||||
|     serializedVersion: 2 | ||||
|     m_Bits: 4294967295 | ||||
|   m_IsTrigger: 0 | ||||
|   m_UsedByEffector: 0 | ||||
|   m_CompositeOperation: 0 | ||||
|   m_CompositeOrder: 0 | ||||
|   m_Offset: {x: 0, y: 0} | ||||
|   m_SpriteTilingProperty: | ||||
|     border: {x: 0, y: 0, z: 0, w: 0} | ||||
|     pivot: {x: 0.5, y: 0.5} | ||||
|     oldSize: {x: 5.12, y: 5.12} | ||||
|     newSize: {x: 5.12, y: 5.12} | ||||
|     adaptiveTilingThreshold: 0.5 | ||||
|     drawMode: 0 | ||||
|     adaptiveTiling: 0 | ||||
|   m_AutoTiling: 0 | ||||
|   m_Size: {x: 5.12, y: 5.12} | ||||
|   m_EdgeRadius: 0 | ||||
| --- !u!212 &2062107677 | ||||
| SpriteRenderer: | ||||
|   m_ObjectHideFlags: 0 | ||||
|   m_CorrespondingSourceObject: {fileID: 0} | ||||
|   m_PrefabInstance: {fileID: 0} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
|   m_GameObject: {fileID: 2062107675} | ||||
|   m_Enabled: 1 | ||||
|   m_CastShadows: 0 | ||||
|   m_ReceiveShadows: 0 | ||||
|   m_DynamicOccludee: 1 | ||||
|   m_StaticShadowCaster: 0 | ||||
|   m_MotionVectors: 1 | ||||
|   m_LightProbeUsage: 1 | ||||
|   m_ReflectionProbeUsage: 1 | ||||
|   m_RayTracingMode: 0 | ||||
|   m_RayTraceProcedural: 0 | ||||
|   m_RayTracingAccelStructBuildFlagsOverride: 0 | ||||
|   m_RayTracingAccelStructBuildFlags: 1 | ||||
|   m_SmallMeshCulling: 1 | ||||
|   m_RenderingLayerMask: 1 | ||||
|   m_RendererPriority: 0 | ||||
|   m_Materials: | ||||
|   - {fileID: 10754, 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: 0 | ||||
|   m_MinimumChartSize: 4 | ||||
|   m_AutoUVMaxDistance: 0.5 | ||||
|   m_AutoUVMaxAngle: 89 | ||||
|   m_LightmapParameters: {fileID: 0} | ||||
|   m_SortingLayerID: 0 | ||||
|   m_SortingLayer: 0 | ||||
|   m_SortingOrder: 0 | ||||
|   m_Sprite: {fileID: -2257217325195158302, guid: a192a62ef32304b4182909c80a175f39, type: 3} | ||||
|   m_Color: {r: 1, g: 1, b: 1, a: 1} | ||||
|   m_FlipX: 0 | ||||
|   m_FlipY: 0 | ||||
|   m_DrawMode: 0 | ||||
|   m_Size: {x: 5.12, y: 5.12} | ||||
|   m_AdaptiveModeThreshold: 0.5 | ||||
|   m_SpriteTileMode: 0 | ||||
|   m_WasSpriteAssigned: 1 | ||||
|   m_MaskInteraction: 0 | ||||
|   m_SpriteSortPoint: 0 | ||||
| --- !u!4 &2062107678 | ||||
| Transform: | ||||
|   m_ObjectHideFlags: 0 | ||||
|   m_CorrespondingSourceObject: {fileID: 0} | ||||
|   m_PrefabInstance: {fileID: 0} | ||||
|   m_PrefabAsset: {fileID: 0} | ||||
|   m_GameObject: {fileID: 2062107675} | ||||
|   serializedVersion: 2 | ||||
|   m_LocalRotation: {x: -0.027460787, y: -0.027460786, z: 0.70657337, w: 0.70657337} | ||||
|   m_LocalPosition: {x: 40.61, y: -5.69, z: 0} | ||||
|   m_LocalScale: {x: 10, y: 0.8581, z: 1} | ||||
|   m_ConstrainProportionsScale: 0 | ||||
|   m_Children: [] | ||||
|   m_Father: {fileID: 0} | ||||
|   m_LocalEulerAnglesHint: {x: 0, y: -4.451, z: 90} | ||||
| --- !u!1660057539 &9223372036854775807 | ||||
| SceneRoots: | ||||
|   m_ObjectHideFlags: 0 | ||||
| @@ -5746,5 +5614,4 @@ SceneRoots: | ||||
|   - {fileID: 519420032} | ||||
|   - {fileID: 1267397458} | ||||
|   - {fileID: 1235900594} | ||||
|   - {fileID: 2062107678} | ||||
|   - {fileID: 1999482187} | ||||
|   | ||||
| @@ -7,51 +7,55 @@ public class LevelLoader : MonoBehaviour | ||||
|     public AudioSource audioSource; | ||||
|     public GameObject obstaclePrefab; | ||||
|     public GameObject spikePrefab; | ||||
|     public GameObject winnerWall; | ||||
|  | ||||
|     void Start() | ||||
|     private GameObject GetPrefab(LevelElement.Type type) | ||||
|     { | ||||
|         if (type == LevelElement.Type.Spike) | ||||
|         { | ||||
|             return spikePrefab; | ||||
|         } | ||||
|         return obstaclePrefab; | ||||
|     } | ||||
|  | ||||
|     private void LoadAudio() | ||||
|     { | ||||
|         audioSource.clip = Resources.Load<AudioClip>(Path.Combine("Musics", levelsLoader.levelCurrent.musicName)); | ||||
|         audioSource.Play(); | ||||
|     } | ||||
|  | ||||
|     private void LoadElements() | ||||
|     { | ||||
|         obstaclePrefab = Resources.Load<GameObject>("Prefabs/Obstacle"); | ||||
|         spikePrefab = Resources.Load<GameObject>("Prefabs/Spike"); | ||||
|         winnerWall = Resources.Load<GameObject>("Prefabs/WinnerWall"); | ||||
|  | ||||
|         Level current = levelsLoader.levelCurrent; | ||||
|         foreach (var element in current.elements) | ||||
|         { | ||||
|             GameObject prefab = GetPrefab(element.type); | ||||
|             Instantiate(prefab, new Vector3(element.x, element.y, 0), Quaternion.identity); | ||||
|         } | ||||
|  | ||||
|         LevelElement lastElement = current.elements[^1]; | ||||
|         float lastX = 15; | ||||
|         if (lastElement != null) | ||||
|         { | ||||
|             lastX += lastElement.x; | ||||
|         } | ||||
|         Instantiate(winnerWall, new Vector3(lastX, 0, 0), Quaternion.Euler(0, 0, 90)); | ||||
|     } | ||||
|  | ||||
|     public void Start() | ||||
|     { | ||||
|         levelsLoader = GameObject.FindGameObjectWithTag("LevelsLoader").GetComponent<LevelsLoader>(); | ||||
|         levelsLoader.IncreaseTotalAttempts(); | ||||
|  | ||||
|         audioSource.clip = Resources.Load<AudioClip>(Path.Combine("Musics", levelsLoader.levelCurrent.musicName)); | ||||
|         audioSource.Play(); | ||||
|  | ||||
|         obstaclePrefab = Resources.Load<GameObject>("Prefabs/Obstacle"); | ||||
|         spikePrefab = Resources.Load<GameObject>("Prefabs/Spike"); | ||||
|  | ||||
|         Level current = levelsLoader.levelCurrent; | ||||
|         // Debug.Log("Level: " + current.name); | ||||
|         // for (int i = 0; i < current.elements.Count; i++) | ||||
|         // { | ||||
|         //     LevelElement element = current.elements[i]; | ||||
|         //     Debug.Log("Element: " + element.type + " " + element.x + " " + element.y); | ||||
|         // } | ||||
|  | ||||
|         for (int index = 0; index < current.elements.Count; index++) | ||||
|         { | ||||
|             LevelElement element = current.elements[index]; | ||||
|             GameObject prefab = obstaclePrefab; | ||||
|  | ||||
|             if (element.type == LevelElement.Type.Spike) | ||||
|             { | ||||
|                 prefab = spikePrefab; | ||||
|             } | ||||
|  | ||||
|             Instantiate(prefab, new Vector3(element.x, element.y, 0), Quaternion.identity); | ||||
|         } | ||||
|  | ||||
|         // // Obstacle | ||||
|         // // x=-6.684, y=-2.897, 0 | ||||
|         // // scale=0.96055, 0.2326, 1 | ||||
|         // Instantiate(obstaclePrefab, new Vector3(-6.684f, -2.897f, 0), Quaternion.identity); | ||||
|  | ||||
|         // // Spike | ||||
|         // // -3.06, -2.93 | ||||
|         // // scale=0.15, 0.15, 1 | ||||
|         // Instantiate(spikePrefab, new Vector3(-3.06f, -2.93f, 0), Quaternion.identity); | ||||
|         LoadAudio(); | ||||
|         LoadElements(); | ||||
|     } | ||||
|  | ||||
|     void Update() | ||||
|     public void Update() | ||||
|     { | ||||
|  | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user