Skip to content

Commit

Permalink
feat: googles ui underwater
Browse files Browse the repository at this point in the history
  • Loading branch information
pyoneerC committed Sep 26, 2024
1 parent c0bd590 commit c9b4a39
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 6 deletions.
24 changes: 18 additions & 6 deletions Assets/Scenes/Reparation.unity
Original file line number Diff line number Diff line change
Expand Up @@ -2956,7 +2956,7 @@ GameObject:
- component: {fileID: 173644482}
- component: {fileID: 173644481}
m_Layer: 0
m_Name: West (1)
m_Name: East
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
Expand Down Expand Up @@ -8901,7 +8901,7 @@ 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, y: 0}
m_AnchoredPosition: {x: 30, y: 0}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &479826998
Expand Down Expand Up @@ -17057,6 +17057,10 @@ PrefabInstance:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 1285577524151521393, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
propertyPath: googles
value:
objectReference: {fileID: 1979774045}
- target: {fileID: 1285577524151521393, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
propertyPath: minimap
value:
Expand Down Expand Up @@ -17097,6 +17101,14 @@ PrefabInstance:
propertyPath: enterWaterSound
value:
objectReference: {fileID: 8300000, guid: 335961129c6c5454a8de1c786544d148, type: 3}
- target: {fileID: 1285577524151521393, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
propertyPath: googlesSupportA
value:
objectReference: {fileID: 1589523900}
- target: {fileID: 1285577524151521393, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
propertyPath: googlesSupportB
value:
objectReference: {fileID: 114400261}
- target: {fileID: 1285577524151521393, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
propertyPath: playerRigidbody
value:
Expand Down Expand Up @@ -34691,14 +34703,14 @@ RectTransform:
m_GameObject: {fileID: 1589523898}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1.7325, y: 1, z: 1}
m_LocalScale: {x: 1.89115, 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: -884.4434, y: 0}
m_AnchoredPosition: {x: -877.9876, y: 0}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1589523900
Expand Down Expand Up @@ -42351,7 +42363,7 @@ GameObject:
- component: {fileID: 1979774045}
- component: {fileID: 1979774047}
m_Layer: 5
m_Name: Image
m_Name: Googles
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
Expand All @@ -42373,7 +42385,7 @@ 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, y: 0}
m_AnchoredPosition: {x: 0.6549353, y: 0}
m_SizeDelta: {x: 200, y: 200}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1979774045
Expand Down
39 changes: 39 additions & 0 deletions Assets/Scripts/WaterLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ public class WaterLogic : MonoBehaviour
public AudioClip oxygenWarning1;
public AudioClip oxygenWarning2;
public AudioClip oxygenWarning3;

public Image blackFadeImage;
public Image minimap;
public Image googlesSupportA;
public Image googlesSupportB;
public Image googles;

public TextMeshProUGUI oxygenWarningText;
public AudioClip enterWaterSound;

Expand All @@ -42,6 +47,9 @@ private void Start()
blackFadeImage.color = new Color(0f, 0f, 0f, 0f);
_audioSource.volume = 1.0f;
minimap.color = new Color(minimap.color.r, minimap.color.g, minimap.color.b, 1f);
googlesSupportA.color = new Color(googlesSupportA.color.r, googlesSupportA.color.g, googlesSupportA.color.b, 0f);
googlesSupportB.color = new Color(googlesSupportB.color.r, googlesSupportB.color.g, googlesSupportB.color.b, 0f);
googles.color = new Color(googles.color.r, googles.color.g, googles.color.b, 0f);
}

private void Update()
Expand Down Expand Up @@ -72,6 +80,37 @@ private void OnTriggerEnter(Collider other)
}

_oxygenDecrementCoroutine = StartCoroutine(OxygenDecrement());

StartCoroutine(FadeInGoogles());
}

private IEnumerator FadeInGoogles()
{
var googlesSupportColor = new Color(0.180f, 0.180f, 0.180f, 0);
var googlesColor = new Color(0f, 0f, 0f, 0f);

const float duration = 2f;
var timeElapsed = 0f;

googlesSupportA.color = googlesSupportColor;
googlesSupportB.color = googlesSupportColor;
googles.color = googlesColor;

while (timeElapsed < duration)
{
timeElapsed += Time.deltaTime;
var alpha = Mathf.Clamp01(timeElapsed / duration);

googlesSupportA.color = new Color(0.180f, 0.180f, 0.180f, alpha);
googlesSupportB.color = new Color(0.180f, 0.180f, 0.180f, alpha);
googles.color = new Color(0f, 0f, 0f, Mathf.Lerp(0f, 0.4f, alpha));

yield return null;
}

googlesSupportA.color = new Color(0.180f, 0.180f, 0.180f, 1f);
googlesSupportB.color = new Color(0.180f, 0.180f, 0.180f, 1f);
googles.color = new Color(0f, 0f, 0f, 0.4f);
}

private void OnTriggerExit(Collider other)
Expand Down

0 comments on commit c9b4a39

Please sign in to comment.