diff --git a/Assets/BuildingExitCollider.cs b/Assets/BuildingExitCollider.cs index 92470e4..95afa28 100644 --- a/Assets/BuildingExitCollider.cs +++ b/Assets/BuildingExitCollider.cs @@ -17,10 +17,7 @@ public class BuildingExitCollider : MonoBehaviour building.PlayerExitedfromBuilding = true; } } - else - { - Debug.Log("Exit From: " + other.gameObject.name); - } + } void alreadyDisabler() { diff --git a/Assets/BuildingParent.cs b/Assets/BuildingParent.cs index a11a64a..49d2c3a 100644 --- a/Assets/BuildingParent.cs +++ b/Assets/BuildingParent.cs @@ -57,7 +57,7 @@ public class BuildingParent : MonoBehaviour } if (percentAgeObstacle < 30) { - InstantiatedObstacle = Instantiate(obstacleObj, transform); + InstantiatedObstacle = Instantiate(obstacleObj, temp.transform); } } @@ -66,13 +66,12 @@ public class BuildingParent : MonoBehaviour public void ObjPooler() { int temp = counter % BuildingPool.Count; - Debug.Log("temp: " + temp + " counter: " + counter); BuildingPool[temp].transform.localPosition = new Vector3(0, 0, -100 - (10 * counter)); counter++; Destroy(InstantiatedObstacle); int percentAgeObstacle = Random.Range(0, 100); if (percentAgeObstacle < 20) - InstantiatedObstacle = Instantiate(obstacleObj, transform); + InstantiatedObstacle = Instantiate(obstacleObj, BuildingPool[temp].transform); int percentAge = Random.Range(0, 100); if (percentAge < 40) diff --git a/Assets/CharacterController.cs b/Assets/CharacterController.cs index b42f94b..ed7a030 100644 --- a/Assets/CharacterController.cs +++ b/Assets/CharacterController.cs @@ -15,6 +15,7 @@ public class CharacterController : MonoBehaviour } private void OnCollisionEnter(Collision collision) { + Debug.Log("Collided with: "+collision.gameObject.name); if(collision.gameObject.layer==LayerMask.NameToLayer("Obstacle")) { Health -= 0.5f; diff --git a/Assets/Obstacle.cs b/Assets/Obstacle.cs index 385cc5f..c836f89 100644 --- a/Assets/Obstacle.cs +++ b/Assets/Obstacle.cs @@ -9,7 +9,7 @@ public class Obstacle : MonoBehaviour { Starter(); } - void Starter() + public void Starter() { int rand=Random.Range(0, obstacleObjs.Count); obstacleObjs[rand].gameObject.SetActive(true); diff --git a/Assets/ObstacleHitReceiver.cs b/Assets/ObstacleHitReceiver.cs new file mode 100644 index 0000000..011e17a --- /dev/null +++ b/Assets/ObstacleHitReceiver.cs @@ -0,0 +1,16 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ObstacleHitReceiver : MonoBehaviour +{ + private void OnCollisionEnter(Collision collision) + { + Debug.Log("Collided with: " + collision.gameObject.name); + if (collision.gameObject.layer == LayerMask.NameToLayer("Player")) + { + UIManager.instance.player.Health -= Random.Range(1,5); + UIManager.instance.UpdateHealth(); + } + } +} diff --git a/Assets/ObstacleHitReceiver.cs.meta b/Assets/ObstacleHitReceiver.cs.meta new file mode 100644 index 0000000..c550d70 --- /dev/null +++ b/Assets/ObstacleHitReceiver.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2e4c2115f7c8919458497c9aea88d927 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/Building.prefab b/Assets/Prefabs/Building.prefab index 52abeef..7d6d15f 100644 --- a/Assets/Prefabs/Building.prefab +++ b/Assets/Prefabs/Building.prefab @@ -12,6 +12,7 @@ GameObject: - component: {fileID: 5720042706500366912} - component: {fileID: 4468223268677451386} - component: {fileID: 6980732545797632941} + - component: {fileID: 4030030059389142992} m_Layer: 7 m_Name: Cube m_TagString: Untagged @@ -105,6 +106,18 @@ BoxCollider: serializedVersion: 3 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} +--- !u!114 &4030030059389142992 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3345311276052987917} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2e4c2115f7c8919458497c9aea88d927, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &3547235919439060679 GameObject: m_ObjectHideFlags: 0 @@ -291,6 +304,7 @@ GameObject: - component: {fileID: 5284522536813788558} - component: {fileID: 8638442990055863102} - component: {fileID: 8087269535889161167} + - component: {fileID: 8799695828369176589} m_Layer: 7 m_Name: Cube (2) m_TagString: Untagged @@ -384,6 +398,18 @@ BoxCollider: serializedVersion: 3 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} +--- !u!114 &8799695828369176589 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5440686397038675175} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2e4c2115f7c8919458497c9aea88d927, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &8673850858292973711 GameObject: m_ObjectHideFlags: 0 @@ -396,6 +422,7 @@ GameObject: - component: {fileID: 7833155270876741958} - component: {fileID: 3760240394921634743} - component: {fileID: 4194740081033469840} + - component: {fileID: 3379276762863398788} m_Layer: 7 m_Name: Cube (1) m_TagString: Untagged @@ -489,6 +516,18 @@ BoxCollider: serializedVersion: 3 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} +--- !u!114 &3379276762863398788 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8673850858292973711} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2e4c2115f7c8919458497c9aea88d927, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &8963123750152084695 GameObject: m_ObjectHideFlags: 0 @@ -501,6 +540,7 @@ GameObject: - component: {fileID: 254044348044277630} - component: {fileID: 1614102577441840113} - component: {fileID: 3465556752757544187} + - component: {fileID: 5894220820422870137} m_Layer: 7 m_Name: Cube (3) m_TagString: Untagged @@ -594,3 +634,15 @@ BoxCollider: serializedVersion: 3 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} +--- !u!114 &5894220820422870137 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8963123750152084695} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2e4c2115f7c8919458497c9aea88d927, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/Assets/Prefabs/Obstacle.prefab b/Assets/Prefabs/Obstacle.prefab index 82a2412..4e3295c 100644 --- a/Assets/Prefabs/Obstacle.prefab +++ b/Assets/Prefabs/Obstacle.prefab @@ -44,6 +44,7 @@ GameObject: - component: {fileID: 3869990772878308359} - component: {fileID: 2894026819963306455} - component: {fileID: 3187310684239429858} + - component: {fileID: 4179707478091206525} m_Layer: 7 m_Name: Cube m_TagString: Untagged @@ -137,6 +138,18 @@ BoxCollider: serializedVersion: 3 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} +--- !u!114 &4179707478091206525 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1577995798430993878} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2e4c2115f7c8919458497c9aea88d927, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &1787290293472421831 GameObject: m_ObjectHideFlags: 0 @@ -181,6 +194,7 @@ GameObject: - component: {fileID: 1934242005780975504} - component: {fileID: 132781675721411416} - component: {fileID: 2489360659515964890} + - component: {fileID: 5519556815215249700} m_Layer: 7 m_Name: Cube m_TagString: Untagged @@ -274,6 +288,18 @@ BoxCollider: serializedVersion: 3 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} +--- !u!114 &5519556815215249700 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2176866969402284360} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2e4c2115f7c8919458497c9aea88d927, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &2267476507392630717 GameObject: m_ObjectHideFlags: 0 @@ -286,6 +312,7 @@ GameObject: - component: {fileID: 738140874179904123} - component: {fileID: 3106685463841959516} - component: {fileID: 6112997783246297251} + - component: {fileID: 2488742608958214131} m_Layer: 7 m_Name: Capsule m_TagString: Untagged @@ -381,6 +408,18 @@ CapsuleCollider: m_Height: 2 m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} +--- !u!114 &2488742608958214131 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2267476507392630717} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2e4c2115f7c8919458497c9aea88d927, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &3145214791736818536 GameObject: m_ObjectHideFlags: 0 @@ -393,6 +432,7 @@ GameObject: - component: {fileID: 4799435858410384380} - component: {fileID: 5521792786852621617} - component: {fileID: 3855201530291334490} + - component: {fileID: 8295631785149944746} m_Layer: 7 m_Name: Cube m_TagString: Untagged @@ -486,6 +526,18 @@ BoxCollider: serializedVersion: 3 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} +--- !u!114 &8295631785149944746 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3145214791736818536} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2e4c2115f7c8919458497c9aea88d927, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &3538677608111202394 GameObject: m_ObjectHideFlags: 0 @@ -498,6 +550,7 @@ GameObject: - component: {fileID: 4241992485719357569} - component: {fileID: 4757788996510623846} - component: {fileID: 2592458662843584037} + - component: {fileID: 7105180655307349342} m_Layer: 7 m_Name: Cube m_TagString: Untagged @@ -591,6 +644,18 @@ BoxCollider: serializedVersion: 3 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} +--- !u!114 &7105180655307349342 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3538677608111202394} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2e4c2115f7c8919458497c9aea88d927, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &4070348558281142435 GameObject: m_ObjectHideFlags: 0 @@ -603,6 +668,7 @@ GameObject: - component: {fileID: 3205405760505763146} - component: {fileID: 4275165362657368192} - component: {fileID: 7974730601669538336} + - component: {fileID: 2753438306603955334} m_Layer: 7 m_Name: Cube m_TagString: Untagged @@ -696,6 +762,18 @@ BoxCollider: serializedVersion: 3 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} +--- !u!114 &2753438306603955334 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4070348558281142435} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2e4c2115f7c8919458497c9aea88d927, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &5023188510960135218 GameObject: m_ObjectHideFlags: 0 @@ -708,6 +786,7 @@ GameObject: - component: {fileID: 965605946053083999} - component: {fileID: 6289450457232285118} - component: {fileID: 1642609181628294372} + - component: {fileID: 5867167429585405865} m_Layer: 7 m_Name: Capsule (1) m_TagString: Untagged @@ -803,6 +882,18 @@ CapsuleCollider: m_Height: 2 m_Direction: 1 m_Center: {x: 0, y: 0, z: 0} +--- !u!114 &5867167429585405865 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5023188510960135218} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2e4c2115f7c8919458497c9aea88d927, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &5123622407992111394 GameObject: m_ObjectHideFlags: 0 @@ -972,6 +1063,7 @@ GameObject: - component: {fileID: 5831133788385772849} - component: {fileID: 3662293740914732157} - component: {fileID: 4634139621965691611} + - component: {fileID: 2013647800512166614} m_Layer: 7 m_Name: Cube m_TagString: Untagged @@ -1065,6 +1157,18 @@ BoxCollider: serializedVersion: 3 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} +--- !u!114 &2013647800512166614 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7232985979888883490} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2e4c2115f7c8919458497c9aea88d927, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &7435278529207429878 GameObject: m_ObjectHideFlags: 0 @@ -1174,6 +1278,7 @@ GameObject: - component: {fileID: 5766972642684363900} - component: {fileID: 5571340124040483216} - component: {fileID: 825149862492978043} + - component: {fileID: 7802651041208828445} m_Layer: 7 m_Name: Cube m_TagString: Untagged @@ -1267,3 +1372,15 @@ BoxCollider: serializedVersion: 3 m_Size: {x: 1, y: 1, z: 1} m_Center: {x: 0, y: 0, z: 0} +--- !u!114 &7802651041208828445 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 9199462185720323440} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2e4c2115f7c8919458497c9aea88d927, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 1b7d96e..bfc901d 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -601,6 +601,7 @@ RectTransform: m_ConstrainProportionsScale: 0 m_Children: - {fileID: 2121086327} + - {fileID: 1433600730} - {fileID: 1449631439} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -625,6 +626,141 @@ MonoBehaviour: player: {fileID: 5023099893569217184} GameOverPanel: {fileID: 1449631438} cameraFollow: {fileID: 963194229} + ScoreText: {fileID: 447965983} +--- !u!1 &447965981 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 447965982} + - component: {fileID: 447965984} + - component: {fileID: 447965983} + m_Layer: 5 + m_Name: Score + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &447965982 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 447965981} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1433600730} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &447965983 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 447965981} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_text: 'Score: 0' + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4278190080 + m_fontColor: {r: 0, g: 0, b: 0, a: 1} + m_enableVertexGradient: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_fontSize: 72 + m_fontSizeBase: 36 + m_fontWeight: 400 + m_enableAutoSizing: 1 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 1 + m_VerticalAlignment: 256 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 1 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 + m_VertexBufferAutoSizeReduction: 0 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0} + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_hasFontAssetChanged: 0 + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} +--- !u!222 &447965984 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 447965981} + m_CullTransparentMesh: 1 --- !u!1 &539522475 GameObject: m_ObjectHideFlags: 0 @@ -1762,7 +1898,7 @@ Transform: serializedVersion: 2 m_LocalRotation: {x: 0, y: 0.7071068, z: -0.7071068, w: 0} m_LocalPosition: {x: 0, y: -0.23100013, z: -0.07500011} - m_LocalScale: {x: 0.5, y: 0.5, z: 0.5} + m_LocalScale: {x: 0.75, y: 0.75, z: 0.75} m_ConstrainProportionsScale: 1 m_Children: [] m_Father: {fileID: 0} @@ -1943,6 +2079,82 @@ MeshFilter: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1173495650} m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0} +--- !u!1 &1433600729 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1433600730} + - component: {fileID: 1433600732} + - component: {fileID: 1433600731} + m_Layer: 5 + m_Name: ScoreBG + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1433600730 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1433600729} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 447965982} + m_Father: {fileID: 391446497} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 400, y: 100} + m_Pivot: {x: 0, y: 1} +--- !u!114 &1433600731 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1433600729} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1433600732 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1433600729} + m_CullTransparentMesh: 1 --- !u!1 &1442169890 GameObject: m_ObjectHideFlags: 0 @@ -2751,7 +2963,7 @@ GameObject: - component: {fileID: 2121086329} - component: {fileID: 2121086328} m_Layer: 5 - m_Name: Image + m_Name: HealthBG m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -2775,7 +2987,7 @@ RectTransform: m_AnchorMin: {x: 1, y: 1} m_AnchorMax: {x: 1, y: 1} m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 500, y: 100} + m_SizeDelta: {x: 400, y: 100} m_Pivot: {x: 1, y: 1} --- !u!114 &2121086328 MonoBehaviour: @@ -3750,7 +3962,7 @@ Rigidbody: m_ImplicitCom: 1 m_ImplicitTensor: 1 m_UseGravity: 1 - m_IsKinematic: 1 + m_IsKinematic: 0 m_Interpolate: 0 m_Constraints: 0 m_CollisionDetection: 0 diff --git a/Assets/UIManager.cs b/Assets/UIManager.cs index faee7a9..e7c5bdb 100644 --- a/Assets/UIManager.cs +++ b/Assets/UIManager.cs @@ -10,6 +10,9 @@ public class UIManager : MonoBehaviour public CharacterController player; public GameObject GameOverPanel; public CameraFollow cameraFollow; + bool isGameOver = false; + float Score; + public TextMeshProUGUI ScoreText; private void Awake() { instance = this; @@ -17,18 +20,39 @@ public class UIManager : MonoBehaviour private void Start() { UpdateHealth(); + StartCoroutine(ScoreUpdateRoutine()); + } + IEnumerator ScoreUpdateRoutine() + { + while(!isGameOver) + { + Score += Time.fixedDeltaTime; + ScoreText.text = Mathf.FloorToInt(Score).ToString(); + yield return new WaitForSeconds(Time.fixedDeltaTime); + + } } public void UpdateHealth() { - Health.text = "Health: " + player.Health.ToString(); - if (player.Health <= 2) + if (!isGameOver) { - GameOver(); + if (player.Health <= 0) + { + Health.text = "Health: 0"; + GameOver(); + + } + else + { + Health.text = "Health: " + player.Health.ToString(); + } } } void GameOver() { - player.SpineHingeJoint.connectedBody = null; + isGameOver = true; + Destroy(player.SpineHingeJoint); + GameOverPanel.SetActive(true); cameraFollow.isPlaying = false; } public void Restart()