diff --git a/Assets/Prefabs/FloatingTextManager.prefab b/Assets/Prefabs/FloatingTextManager.prefab new file mode 100644 index 0000000000000000000000000000000000000000..5905cf69e82547e5b253c5670723f21f99303eeb --- /dev/null +++ b/Assets/Prefabs/FloatingTextManager.prefab @@ -0,0 +1,146 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &3903489558000995093 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 3903489558000995092} + - component: {fileID: 3903489558000995089} + - component: {fileID: 3903489558000995094} + - component: {fileID: 3903489558000995095} + m_Layer: 0 + m_Name: FloatingTextCanvas + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &3903489558000995092 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3903489558000995093} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0, y: 0, z: 0} + m_Children: [] + m_Father: {fileID: 3903489558206960123} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0, y: 0} +--- !u!223 &3903489558000995089 +Canvas: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3903489558000995093} + m_Enabled: 1 + serializedVersion: 3 + m_RenderMode: 0 + m_Camera: {fileID: 0} + m_PlaneDistance: 100 + m_PixelPerfect: 0 + m_ReceivesEvents: 1 + m_OverrideSorting: 0 + m_OverridePixelPerfect: 0 + m_SortingBucketNormalizedSize: 0 + m_AdditionalShaderChannelsFlag: 0 + m_SortingLayerID: 0 + m_SortingOrder: 0 + m_TargetDisplay: 0 +--- !u!114 &3903489558000995094 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3903489558000995093} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3} + m_Name: + m_EditorClassIdentifier: + m_UiScaleMode: 1 + m_ReferencePixelsPerUnit: 100 + m_ScaleFactor: 1 + m_ReferenceResolution: {x: 1920, y: 1080} + m_ScreenMatchMode: 0 + m_MatchWidthOrHeight: 0 + m_PhysicalUnit: 3 + m_FallbackScreenDPI: 96 + m_DefaultSpriteDPI: 96 + m_DynamicPixelsPerUnit: 1 +--- !u!114 &3903489558000995095 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3903489558000995093} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreReversedGraphics: 1 + m_BlockingObjects: 0 + m_BlockingMask: + serializedVersion: 2 + m_Bits: 4294967295 +--- !u!1 &3903489558206960120 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 3903489558206960123} + - component: {fileID: 3903489558206960122} + m_Layer: 0 + m_Name: FloatingTextManager + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &3903489558206960123 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3903489558206960120} + 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_Children: + - {fileID: 3903489558000995092} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &3903489558206960122 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3903489558206960120} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c5c647f5ad81cbf428f21edb577a9036, type: 3} + m_Name: + m_EditorClassIdentifier: + FloatingTextCanvas: {fileID: 3903489558000995089} + TextPrefab: {fileID: 3314287206162268615, guid: d1cb0dd035e18834ca5b458d85a57941, type: 3} diff --git a/Assets/Prefabs/FloatingTextManager.prefab.meta b/Assets/Prefabs/FloatingTextManager.prefab.meta new file mode 100644 index 0000000000000000000000000000000000000000..ab2dd2940e4ed4abff0d2d4f88c55fa81de0507f --- /dev/null +++ b/Assets/Prefabs/FloatingTextManager.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 67033b8396c8c6c4da47b8d93154ff3c +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/LoadingScreenUI.prefab b/Assets/Prefabs/LoadingScreenUI.prefab index d966810ffcae406cb1ca2aafd8ffde9f6ac7e921..59121379aba84c07c7b0cbec7343afadfc7e59ac 100644 --- a/Assets/Prefabs/LoadingScreenUI.prefab +++ b/Assets/Prefabs/LoadingScreenUI.prefab @@ -70,8 +70,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: -0.20215, y: -0.000026426} - m_SizeDelta: {x: 87.7954, y: 39.4311} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 120, y: 39} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &7468275152216525744 CanvasRenderer: @@ -108,13 +108,13 @@ MonoBehaviour: m_BestFit: 0 m_MinSize: 10 m_MaxSize: 40 - m_Alignment: 5 + m_Alignment: 4 m_AlignByGeometry: 0 m_RichText: 1 m_HorizontalOverflow: 0 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: 69 % + m_Text: 100 % --- !u!1 &7468275152310657227 GameObject: m_ObjectHideFlags: 0 @@ -368,7 +368,7 @@ GameObject: - component: {fileID: 7468275153108109267} - component: {fileID: 7468275153108109294} m_Layer: 5 - m_Name: LoadingScreen + m_Name: LoadingScreenUI m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 diff --git a/Assets/Scenes/DialogueTest.unity b/Assets/Scenes/DialogueTest.unity index 8ad8bb2a2099ad248fc86bb4097c733d84d10fc5..e2092fc29e263f4a3369658eaec0a3248c8bda8a 100644 --- a/Assets/Scenes/DialogueTest.unity +++ b/Assets/Scenes/DialogueTest.unity @@ -215,104 +215,6 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} ---- !u!1 &101395008 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 101395009} - - component: {fileID: 101395012} - - component: {fileID: 101395011} - - component: {fileID: 101395010} - m_Layer: 0 - m_Name: FloatingTextCanvas - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &101395009 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 101395008} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 0, y: 0, z: 0} - m_Children: [] - m_Father: {fileID: 441249966} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0, y: 0} ---- !u!114 &101395010 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 101395008} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} - m_Name: - m_EditorClassIdentifier: - m_IgnoreReversedGraphics: 1 - m_BlockingObjects: 0 - m_BlockingMask: - serializedVersion: 2 - m_Bits: 4294967295 ---- !u!114 &101395011 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 101395008} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3} - m_Name: - m_EditorClassIdentifier: - m_UiScaleMode: 1 - m_ReferencePixelsPerUnit: 100 - m_ScaleFactor: 1 - m_ReferenceResolution: {x: 1920, y: 1080} - m_ScreenMatchMode: 0 - m_MatchWidthOrHeight: 0 - m_PhysicalUnit: 3 - m_FallbackScreenDPI: 96 - m_DefaultSpriteDPI: 96 - m_DynamicPixelsPerUnit: 1 ---- !u!223 &101395012 -Canvas: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 101395008} - m_Enabled: 1 - serializedVersion: 3 - m_RenderMode: 0 - m_Camera: {fileID: 0} - m_PlaneDistance: 100 - m_PixelPerfect: 0 - m_ReceivesEvents: 1 - m_OverrideSorting: 0 - m_OverridePixelPerfect: 0 - m_SortingBucketNormalizedSize: 0 - m_AdditionalShaderChannelsFlag: 0 - m_SortingLayerID: 0 - m_SortingOrder: 0 - m_TargetDisplay: 0 --- !u!1 &159660441 GameObject: m_ObjectHideFlags: 0 @@ -424,53 +326,8 @@ MonoBehaviour: PossibleDialogues: - {fileID: 11400000, guid: 8fffe6cd434f1fd42a0902d2564c44f2, type: 2} - {fileID: 11400000, guid: af66aded814ea204a8eb249d9b95e561, type: 2} - FloatingText: I am a floater. ---- !u!1 &441249965 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 441249966} - - component: {fileID: 441249967} - m_Layer: 0 - m_Name: FloatingText - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &441249966 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 441249965} - 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_Children: - - {fileID: 101395009} - m_Father: {fileID: 0} - m_RootOrder: 2 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &441249967 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 441249965} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: c5c647f5ad81cbf428f21edb577a9036, type: 3} - m_Name: - m_EditorClassIdentifier: - FloatingTextCanvas: {fileID: 101395012} - TextPrefab: {fileID: 3314287206162268615, guid: d1cb0dd035e18834ca5b458d85a57941, type: 3} + FloatingText: Press [E] to interact + FloatingTextOffset: {x: 0, y: 50} --- !u!114 &923385324 stripped MonoBehaviour: m_CorrespondingSourceObject: {fileID: 3502585139780388008, guid: d3160128b1c973948b2d0f02702bb7b6, type: 3} @@ -899,3 +756,60 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: d3160128b1c973948b2d0f02702bb7b6, type: 3} +--- !u!1001 &3903489558101336405 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 3903489558206960120, guid: 67033b8396c8c6c4da47b8d93154ff3c, type: 3} + propertyPath: m_Name + value: FloatingTextManager + objectReference: {fileID: 0} + - target: {fileID: 3903489558206960123, guid: 67033b8396c8c6c4da47b8d93154ff3c, type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3903489558206960123, guid: 67033b8396c8c6c4da47b8d93154ff3c, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3903489558206960123, guid: 67033b8396c8c6c4da47b8d93154ff3c, type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3903489558206960123, guid: 67033b8396c8c6c4da47b8d93154ff3c, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3903489558206960123, guid: 67033b8396c8c6c4da47b8d93154ff3c, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3903489558206960123, guid: 67033b8396c8c6c4da47b8d93154ff3c, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3903489558206960123, guid: 67033b8396c8c6c4da47b8d93154ff3c, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 3903489558206960123, guid: 67033b8396c8c6c4da47b8d93154ff3c, type: 3} + propertyPath: m_RootOrder + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 3903489558206960123, guid: 67033b8396c8c6c4da47b8d93154ff3c, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3903489558206960123, guid: 67033b8396c8c6c4da47b8d93154ff3c, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 3903489558206960123, guid: 67033b8396c8c6c4da47b8d93154ff3c, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 67033b8396c8c6c4da47b8d93154ff3c, type: 3} diff --git a/Assets/Scripts/Dialogue/Interactable.cs b/Assets/Scripts/Dialogue/Interactable.cs index f517cf6553ef522ada8c88fcf7be49d3c6f87a2f..8e2781227f16e95942b1af554c8e81b255756617 100644 --- a/Assets/Scripts/Dialogue/Interactable.cs +++ b/Assets/Scripts/Dialogue/Interactable.cs @@ -1,4 +1,5 @@ using UnityEngine; +using UnityEngine.UI; namespace Nudle.Scripts.Dialogue { @@ -6,7 +7,11 @@ namespace Nudle.Scripts.Dialogue { //public Dialogue dialogue; public Dialogue[] PossibleDialogues; - public string FloatingText; + + public string FloatingText = "Press [E] to interact."; + public Vector2 FloatingTextOffset = Vector2.zero; + + private Text Floater; private DialogueManager GetDialogueManager() => FindObjectOfType<DialogueManager>(); @@ -31,16 +36,25 @@ namespace Nudle.Scripts.Dialogue internal void OnTriggerEnter(Collider other) { - if (other.gameObject.CompareTag("Player")) - if (FloatingText != null) - FindObjectOfType<FloatingTextManager>().ShowText(FloatingText, gameObject.transform.position, 5f); - //TriggerDialogue(); + if (!other.gameObject.CompareTag("Player")) + return; + + if (FloatingText != null && Floater == null) + { + Floater = FindObjectOfType<FloatingTextManager>().ShowText(FloatingText, gameObject.transform.position, FloatingTextOffset); + } + //TriggerDialogue(); } internal void OnTriggerExit(Collider other) { - if (other.gameObject.CompareTag("Player") && !GetDialogueManager().IsInDialogue()) - EndDialogue(); + if (!other.gameObject.CompareTag("Player")) + return; + if (Floater != null) + { + Destroy(Floater.gameObject); + Floater = null; + } } } } \ No newline at end of file diff --git a/Assets/Scripts/FloatingText.cs b/Assets/Scripts/FloatingText.cs index 873853726863109fe089049700b981c60ef58343..4be4f14ebf1dcba1612c1e17dd1ffd51d441143d 100644 --- a/Assets/Scripts/FloatingText.cs +++ b/Assets/Scripts/FloatingText.cs @@ -17,7 +17,7 @@ namespace Nudle.Scripts internal void Update() { var screenPos = Camera.main.WorldToScreenPoint(SourcePosition); - Transform.anchoredPosition = new Vector2(screenPos.x, screenPos.y) + Offset; + Transform.anchoredPosition = new Vector2(screenPos.x / Screen.width * 1920, screenPos.y / Screen.height * 1080) + Offset; } } } diff --git a/Assets/Scripts/FloatingTextManager.cs b/Assets/Scripts/FloatingTextManager.cs index 3a4baa6ebab780101027a2e8f75670321fb6b1c5..33a16ca62f8749e4c879ad23de0ac281f379b3d3 100644 --- a/Assets/Scripts/FloatingTextManager.cs +++ b/Assets/Scripts/FloatingTextManager.cs @@ -10,7 +10,7 @@ namespace Nudle.Scripts public Canvas FloatingTextCanvas; public Text TextPrefab; - internal void ShowText(string text, Vector3 sourcePos, Vector2 offset, float time) + internal Text ShowText(string text, Vector3 sourcePos, Vector2 offset, float time = -1f) { var uiText = Instantiate(TextPrefab); uiText.transform.SetParent(FloatingTextCanvas.transform); @@ -19,15 +19,11 @@ namespace Nudle.Scripts var floatingText = uiText.gameObject.GetComponent<FloatingText>(); floatingText.SourcePosition = sourcePos; floatingText.Offset = offset; - StartCoroutine(DeleteAfter(uiText.gameObject, time)); + if (time > 0f) + StartCoroutine(Util.DeleteAfter(uiText.gameObject, time)); + return uiText; } - internal void ShowText(string text, Vector3 sourcePos, float time) => ShowText(text, sourcePos, Vector2.zero, time); - - internal IEnumerator DeleteAfter(GameObject toDelete, float after) - { - yield return new WaitForSeconds(after); - Destroy(toDelete); - } + internal void ShowText(string text, Vector3 sourcePos, float time = -1f) => ShowText(text, sourcePos, Vector2.zero, time); } } diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index 7372d7adc16fe0904ed556b332c77f21a261dae9..61831d3185c7a8242660674a031b5bb0fc84c6c7 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -1,32 +1,32 @@ -using UnityEngine; - -namespace Nudle.Scripts -{ - public class PlayerController : MonoBehaviour - { - public CharacterController CharacterController; - public Animator Animator; - public float MovementSpeed = 2f; - public float SprintSpeed = 4f; - - private const float gravity = -9.81f; - private bool isSprinting = false; - - [SerializeField] - private float verticalVel; - - internal void Update() - { - DoMove(); - } - - private void DoMove() - { - var sMove = Input.GetAxis("Horizontal"); - var fMove = Input.GetAxis("Vertical"); - - var input = new Vector3(sMove, 0, fMove).normalized; - +using UnityEngine; + +namespace Nudle.Scripts +{ + public class PlayerController : MonoBehaviour + { + public CharacterController CharacterController; + public Animator Animator; + public float MovementSpeed = 2f; + public float SprintSpeed = 4f; + + private const float gravity = -9.81f; + private bool isSprinting = false; + + [SerializeField] + private float verticalVel; + + internal void Update() + { + DoMove(); + } + + private void DoMove() + { + var sMove = Input.GetAxis("Horizontal"); + var fMove = Input.GetAxis("Vertical"); + + var input = new Vector3(sMove, 0, fMove).normalized; + verticalVel = CharacterController.isGrounded ? 0 : verticalVel + (gravity * Time.deltaTime); if (Input.GetKey(KeyCode.LeftShift)) @@ -43,7 +43,7 @@ namespace Nudle.Scripts Animator.SetBool("isWalking", input.magnitude > 0f); transform.rotation = Quaternion.LookRotation(Vector3.RotateTowards(transform.forward, input, 10f * Time.deltaTime, 0.0F)); CharacterController.Move(((transform.forward * MovementSpeed * input.magnitude) + new Vector3(0, verticalVel, 0)) * Time.deltaTime); - } - } - } + } + } + } } \ No newline at end of file diff --git a/Assets/Scripts/SceneSwitcher.cs b/Assets/Scripts/SceneSwitcher.cs index 8a39415ff71e8f23f0449ba74467f8160fe34930..f05f1bcfa6c6709e1954cff51de83b57730d0c54 100644 --- a/Assets/Scripts/SceneSwitcher.cs +++ b/Assets/Scripts/SceneSwitcher.cs @@ -25,8 +25,7 @@ namespace Nudle.Scripts while (!op.isDone) { var progress = Mathf.Clamp01(op.progress / .9f); - Debug.Log($"Loading: {progress * 100}%"); - ProgressText.text = $"{progress * 100} %"; + ProgressText.text = $"{progress:P}"; ProgressBar.value = progress; yield return null; diff --git a/Assets/Scripts/Util.cs b/Assets/Scripts/Util.cs index b6e0ad3f72f5e558316e4402e160c5c2eff29824..2d4f9b3f0d72087db5430337465103b797900383 100644 --- a/Assets/Scripts/Util.cs +++ b/Assets/Scripts/Util.cs @@ -1,6 +1,9 @@ -using System.Collections.Generic; +using System; +using System.Collections; +using System.Collections.Generic; using System.Linq; using UnityEngine; +using Random = UnityEngine.Random; namespace Nudle.Scripts { @@ -21,5 +24,23 @@ namespace Nudle.Scripts return from.Take(elements); } + + internal static IEnumerator In<Arg>(float seconds, Action<Arg> action, Arg arg) + { + yield return new WaitForSeconds(seconds); + action.Invoke(arg); + } + + internal static IEnumerator In(float seconds, Action action) + { + yield return new WaitForSeconds(seconds); + action.Invoke(); + } + + internal static IEnumerator DeleteAfter(GameObject toDelete, float after) + { + yield return new WaitForSeconds(after); + UnityEngine.Object.Destroy(toDelete); + } } } \ No newline at end of file