diff --git a/Assets/Scenes/Reparation.unity b/Assets/Scenes/Reparation.unity index 7c3f90b..d823ca5 100644 --- a/Assets/Scenes/Reparation.unity +++ b/Assets/Scenes/Reparation.unity @@ -11746,9 +11746,13 @@ PrefabInstance: propertyPath: underwaterVolume value: objectReference: {fileID: 0} + - target: {fileID: 1285577524151521393, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3} + propertyPath: oxygenWarningText + value: + objectReference: {fileID: 1634647095} - target: {fileID: 1285577524151521393, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3} propertyPath: verticalSwimSpeed - value: 2.25 + value: 1.5 objectReference: {fileID: 0} - target: {fileID: 1285577524151521393, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3} propertyPath: underwaterAmbience @@ -24794,6 +24798,140 @@ PrefabInstance: m_AddedGameObjects: [] m_AddedComponents: [] m_SourcePrefab: {fileID: 9199261849990390558, guid: c2c82adf9ac2fdc4cae5ff03189357ae, type: 3} +--- !u!1 &1634647093 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1634647094} + - component: {fileID: 1634647096} + - component: {fileID: 1634647095} + m_Layer: 5 + m_Name: Oxygen Warning + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1634647094 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1634647093} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 101.5} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1773052968} + 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: -48.6, y: -217.6} + m_SizeDelta: {x: 200, y: 50} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1634647095 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1634647093} + 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: + 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: 4294967295 + m_fontColor: {r: 1, g: 1, b: 1, 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: 12 + m_fontSizeBase: 12 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 2 + m_HorizontalAlignment: 2 + m_VerticalAlignment: 512 + 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: -101.54254, 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 &1634647096 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1634647093} + m_CullTransparentMesh: 1 --- !u!4 &1638177897 stripped Transform: m_CorrespondingSourceObject: {fileID: -5819118886272102141, guid: a73df10e437557a40add860503f7acf0, type: 3} @@ -26396,6 +26534,7 @@ RectTransform: - {fileID: 1578620230} - {fileID: 353184057} - {fileID: 1096392007} + - {fileID: 1634647094} - {fileID: 561981529} m_Father: {fileID: 291204632} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/Scripts/WaterLogic.cs b/Assets/Scripts/WaterLogic.cs index 2aa615d..004fe6f 100644 --- a/Assets/Scripts/WaterLogic.cs +++ b/Assets/Scripts/WaterLogic.cs @@ -1,4 +1,5 @@ using System.Collections; +using TMPro; using UnityEngine; using UnityEngine.Serialization; using UnityEngine.UI; @@ -18,6 +19,7 @@ public class WaterLogic : MonoBehaviour public AudioClip oxygenWarning2; public AudioClip oxygenWarning3; public Image blackFadeImage; + public TextMeshProUGUI oxygenWarningText; private AudioSource _audioSource; private Coroutine _oxygenDecrementCoroutine; @@ -99,18 +101,24 @@ private IEnumerator OxygenDecrement() switch (currentOxygen) { case <= 6 when !_hasPlayedWarning3: - Debug.Log("GET OXYGEN NOW, YOU'RE DYING!"); + oxygenWarningText.text = "¡AGARRÁ OXÍGENO YA, TE ESTÁS MURIENDO!"; + oxygenWarningText.color = Color.red; + StartCoroutine(FadeTextAlpha(oxygenWarningText, 1f, 0f, 6f)); _audioSource.PlayOneShot(oxygenWarning3); _hasPlayedWarning3 = true; StartCoroutine(FadeInBlackCanvas()); break; case <= 15 when !_hasPlayedWarning2: - Debug.Log("Oxygen very low! Get oxygen immediately!"); + oxygenWarningText.text = "¡El oxígeno está por el piso! ¡Conseguí oxígeno ya!"; + oxygenWarningText.color = new Color(1f, 0.5f, 0f); + StartCoroutine(FadeTextAlpha(oxygenWarningText, 1f, 0f, 6f)); _audioSource.PlayOneShot(oxygenWarning2); _hasPlayedWarning2 = true; break; case <= 30 when !_hasPlayedWarning1: - Debug.Log("Oxygen critical! Get some oxygen!"); + oxygenWarningText.text = "¡Oxígeno agotándose! ¡Conseguí un poco de oxígeno!"; + oxygenWarningText.color = Color.yellow; + StartCoroutine(FadeTextAlpha(oxygenWarningText, 1f, 0f, 6f)); _audioSource.PlayOneShot(oxygenWarning1); _hasPlayedWarning1 = true; break; @@ -126,6 +134,23 @@ private IEnumerator OxygenDecrement() } } + private static IEnumerator FadeTextAlpha(TextMeshProUGUI text, float startAlpha, float endAlpha, float duration) + { + var elapsedTime = 0f; + var color = text.color; + + while (elapsedTime < duration) + { + elapsedTime += Time.deltaTime; + var alpha = Mathf.Lerp(startAlpha, endAlpha, elapsedTime / duration); + text.color = new Color(color.r, color.g, color.b, alpha); + yield return null; + } + + text.color = new Color(color.r, color.g, color.b, endAlpha); + } + + private IEnumerator RestoreOxygen() { const float lerpDuration = 5f;