Skip to content

Commit

Permalink
feat: character ui for equipment
Browse files Browse the repository at this point in the history
  • Loading branch information
pyoneerC committed Sep 23, 2024
1 parent 73bf025 commit eae357e
Show file tree
Hide file tree
Showing 4 changed files with 207 additions and 50 deletions.
114 changes: 103 additions & 11 deletions Assets/Scenes/Preparation.unity
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,10 @@ PrefabInstance:
propertyPath: m_Name
value: scuba_goggles_and_snorkel
objectReference: {fileID: 0}
- target: {fileID: -5609321221556402741, guid: 38ce9918939f80843a2531ce0061691d, type: 3}
propertyPath: m_TagString
value: goggles
objectReference: {fileID: 0}
- target: {fileID: 5146681718063874739, guid: 38ce9918939f80843a2531ce0061691d, type: 3}
propertyPath: m_LocalScale.x
value: 2
Expand Down Expand Up @@ -778,7 +782,7 @@ GameObject:
- component: {fileID: 90427957}
- component: {fileID: 90427956}
m_Layer: 0
m_Name: FeetR
m_Name: FeetL
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
Expand Down Expand Up @@ -2421,7 +2425,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.06666667, g: 0.06666667, b: 0.06666667, a: 1}
m_Color: {r: 0.7176471, g: 0.7176471, b: 0.7176471, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
Expand Down Expand Up @@ -4170,7 +4174,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.06666667, g: 0.06666667, b: 0.06666667, a: 1}
m_Color: {r: 0.7176471, g: 0.7176471, b: 0.7176471, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
Expand Down Expand Up @@ -4939,6 +4943,10 @@ PrefabInstance:
propertyPath: m_Name
value: wetsuit
objectReference: {fileID: 0}
- target: {fileID: -5609321221556402741, guid: f9346ec1c47cfde4ca92420e8e23eb82, type: 3}
propertyPath: m_TagString
value: body
objectReference: {fileID: 0}
- target: {fileID: 5146681718063874739, guid: f9346ec1c47cfde4ca92420e8e23eb82, type: 3}
propertyPath: m_LocalPosition.x
value: 0
Expand Down Expand Up @@ -5006,6 +5014,10 @@ PrefabInstance:
propertyPath: m_Name
value: utility_knife
objectReference: {fileID: 0}
- target: {fileID: -5609321221556402741, guid: 3d4a18cd1b824194d88111e9ab8fa122, type: 3}
propertyPath: m_TagString
value: knife
objectReference: {fileID: 0}
- target: {fileID: 5146681718063874739, guid: 3d4a18cd1b824194d88111e9ab8fa122, type: 3}
propertyPath: m_LocalScale.x
value: 0.01
Expand Down Expand Up @@ -5329,10 +5341,70 @@ PrefabInstance:
propertyPath: m_AdditionalShaderChannelsFlag
value: 25
objectReference: {fileID: 0}
- target: {fileID: 6724316082960878885, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
propertyPath: body
value:
objectReference: {fileID: 1458228973}
- target: {fileID: 6724316082960878885, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
propertyPath: head
value:
objectReference: {fileID: 213717843}
- target: {fileID: 6724316082960878885, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
propertyPath: legL
value:
objectReference: {fileID: 64918167}
- target: {fileID: 6724316082960878885, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
propertyPath: legR
value:
objectReference: {fileID: 22388702}
- target: {fileID: 6724316082960878885, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
propertyPath: feetL
value:
objectReference: {fileID: 472777021}
- target: {fileID: 6724316082960878885, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
propertyPath: feetR
value:
objectReference: {fileID: 90427956}
- target: {fileID: 6724316082960878885, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
propertyPath: knifeUp
value:
objectReference: {fileID: 1401687115}
- target: {fileID: 6724316082960878885, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
propertyPath: weightL
value:
objectReference: {fileID: 428812745}
- target: {fileID: 6724316082960878885, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
propertyPath: weightR
value:
objectReference: {fileID: 1993754776}
- target: {fileID: 6724316082960878885, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
propertyPath: breather
value:
objectReference: {fileID: 768781764}
- target: {fileID: 6724316082960878885, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
propertyPath: oxygenTank
value:
objectReference: {fileID: 631903965}
- target: {fileID: 6724316082960878885, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
propertyPath: gogglesLeft
value:
objectReference: {fileID: 182934934}
- target: {fileID: 6724316082960878885, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
propertyPath: rayDistance
value: 3
objectReference: {fileID: 0}
- target: {fileID: 6724316082960878885, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
propertyPath: gogglesRight
value:
objectReference: {fileID: 211642282}
- target: {fileID: 6724316082960878885, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
propertyPath: equipmentCount
value:
objectReference: {fileID: 936678402}
- target: {fileID: 6724316082960878885, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
propertyPath: oxygenTankCharge
value:
objectReference: {fileID: 146618611}
m_RemovedComponents:
- {fileID: 1285577524151521393, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
- {fileID: 4614605577419265582, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
Expand Down Expand Up @@ -5367,6 +5439,9 @@ PrefabInstance:
- targetCorrespondingSourceObject: {fileID: 4459864851551516607, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
insertIndex: -1
addedObject: {fileID: 472777020}
- targetCorrespondingSourceObject: {fileID: 4459864851551516607, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
insertIndex: -1
addedObject: {fileID: 90427955}
- targetCorrespondingSourceObject: {fileID: 4459864851551516607, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
insertIndex: -1
addedObject: {fileID: 1919588077}
Expand All @@ -5388,9 +5463,6 @@ PrefabInstance:
- targetCorrespondingSourceObject: {fileID: 4459864851551516607, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
insertIndex: -1
addedObject: {fileID: 428812744}
- targetCorrespondingSourceObject: {fileID: 4459864851551516607, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
insertIndex: -1
addedObject: {fileID: 90427955}
- targetCorrespondingSourceObject: {fileID: 4459864851551516607, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
insertIndex: -1
addedObject: {fileID: 22388701}
Expand Down Expand Up @@ -5937,7 +6009,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: 446.99997, y: 208}
m_AnchoredPosition: {x: 445.5, y: 208}
m_SizeDelta: {x: 200, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &936678402
Expand Down Expand Up @@ -5971,8 +6043,8 @@ MonoBehaviour:
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
rgba: 4278190335
m_fontColor: {r: 1, g: 0, b: 0, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
Expand Down Expand Up @@ -6248,6 +6320,10 @@ PrefabInstance:
propertyPath: m_Name
value: flipper_v2
objectReference: {fileID: 0}
- target: {fileID: -5609321221556402741, guid: 3e2f404f33a296a45a1ddecb0d2b9404, type: 3}
propertyPath: m_TagString
value: feet
objectReference: {fileID: 0}
- target: {fileID: 5146681718063874739, guid: 3e2f404f33a296a45a1ddecb0d2b9404, type: 3}
propertyPath: m_LocalScale.x
value: 0.002
Expand Down Expand Up @@ -7206,6 +7282,10 @@ PrefabInstance:
propertyPath: m_Name
value: respirator_282_bake
objectReference: {fileID: 0}
- target: {fileID: -5609321221556402741, guid: bba6730b0e5f81448b9319cc916613b3, type: 3}
propertyPath: m_TagString
value: breather
objectReference: {fileID: 0}
- target: {fileID: 5146681718063874739, guid: bba6730b0e5f81448b9319cc916613b3, type: 3}
propertyPath: m_LocalScale.x
value: 0.002
Expand Down Expand Up @@ -7698,6 +7778,10 @@ PrefabInstance:
propertyPath: m_Name
value: gym_weights_-_game_asset
objectReference: {fileID: 0}
- target: {fileID: -5609321221556402741, guid: 21bca9556154d7c488b86e8802f0b2c7, type: 3}
propertyPath: m_TagString
value: weight
objectReference: {fileID: 0}
- target: {fileID: 5146681718063874739, guid: 21bca9556154d7c488b86e8802f0b2c7, type: 3}
propertyPath: m_LocalScale.x
value: 0.01
Expand Down Expand Up @@ -9062,7 +9146,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.06666667, g: 0.06666667, b: 0.06666667, a: 1}
m_Color: {r: 0.7176471, g: 0.7176471, b: 0.7176471, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
Expand Down Expand Up @@ -9137,7 +9221,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Color: {r: 0.7176471, g: 0.7176471, b: 0.7176471, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
Expand Down Expand Up @@ -9231,6 +9315,10 @@ PrefabInstance:
propertyPath: m_Name
value: oxygen_tank
objectReference: {fileID: 0}
- target: {fileID: -5609321221556402741, guid: 81cbcba4a3466e740ba6000a37d4d4b4, type: 3}
propertyPath: m_TagString
value: oxygenTank
objectReference: {fileID: 0}
- target: {fileID: 5146681718063874739, guid: 81cbcba4a3466e740ba6000a37d4d4b4, type: 3}
propertyPath: m_LocalScale.x
value: 2
Expand Down Expand Up @@ -10181,6 +10269,10 @@ PrefabInstance:
propertyPath: m_Name
value: simple_oxygen_tank
objectReference: {fileID: 0}
- target: {fileID: -5609321221556402741, guid: d0c8a7ba71a837d47a972faf58eb4732, type: 3}
propertyPath: m_TagString
value: oxygenTankCharge
objectReference: {fileID: 0}
- target: {fileID: 5146681718063874739, guid: d0c8a7ba71a837d47a972faf58eb4732, type: 3}
propertyPath: m_LocalScale.x
value: 0.2
Expand Down
117 changes: 96 additions & 21 deletions Assets/Scripts/Raycast.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.Collections;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class Raycast : MonoBehaviour
{
Expand All @@ -9,6 +11,29 @@ public class Raycast : MonoBehaviour
public int itemCount;
public int goalCount = 8;

public Image head;
public Image body;
public Image oxygenTank;
public Image oxygenTankCharge;

public Image legL;
public Image legR;

public Image feetR;
public Image feetL;

public Image breather;

public Image knifeUp;

public Image weightL;
public Image weightR;

public Image gogglesRight;
public Image gogglesLeft;

public TextMeshProUGUI equipmentCount;

private bool _isCountingDown;

private void Update()
Expand All @@ -24,36 +49,86 @@ private IEnumerator TryPickUpItem()
var ray = mainCamera.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0));
RaycastHit hit;

if (Physics.Raycast(ray, out hit, rayDistance) && hit.collider.CompareTag("elementos"))
if (!Physics.Raycast(ray, out hit, rayDistance) || !hit.collider.CompareTag("elementos")) yield break;
var halo = hit.collider.GetComponent("Halo");

if (!halo)
{
var halo = hit.collider.GetComponent("Halo");
_isCountingDown = true;
Debug.DrawRay(ray.origin, ray.direction * rayDistance, Color.green, 4f);
Debug.Log("Countdown started! Picking up item in 4 seconds...");

if (halo != null)
{
Debug.Log("Halo detected! Picking up item automatically.");
PickUpItem(hit.collider);
}
else
{
_isCountingDown = true;
Debug.DrawRay(ray.origin, ray.direction * rayDistance, Color.green, 4f);
Debug.Log("Countdown started! Picking up item in 4 seconds...");
yield return new WaitForSeconds(4f);
}

yield return new WaitForSeconds(4f);
PickUpItem(hit.collider);
}
PickUpItem(hit.collider);

_isCountingDown = false;
}
_isCountingDown = false;
}

private void PickUpItem(Collider itemCollider)
{
itemCount++;
equipmentCount.text = itemCount.ToString();
UpdateEquipmentCountColor(); // Update color based on item count

Destroy(itemCollider.gameObject);
Debug.Log("Contador de ítems: " + itemCount);

if (itemCount != goalCount) return;
SceneManager.LoadScene("Reparation");
foreach (Transform child in itemCollider.transform)
{
switch (child.tag)
{
case "oxygenTank":
oxygenTank.color = Color.green;
break;
case "body":
body.color = Color.green;
legL.color = Color.green;
legR.color = Color.green;
break;
case "goggles":
gogglesLeft.color = Color.green;
gogglesRight.color = Color.green;
break;
case "feet":
feetL.color = Color.green;
feetR.color = Color.green;
break;
case "weight":
weightL.color = Color.green;
weightR.color = Color.green;
break;
case "oxygenTankCharge":
oxygenTankCharge.color = Color.green;
break;
case "breather":
breather.color = Color.green;
break;
case "knife":
knifeUp.color = Color.green;
break;
default:
Debug.Log("No matching tag found.");
break;
}
}

if (itemCount == goalCount)
{
SceneManager.LoadScene("Reparation");
}
}

private void UpdateEquipmentCountColor()
{
float progress = (float)itemCount / goalCount;

equipmentCount.color = progress switch
{
<= 0.375f => Color.red,
> 0.375f and <= 0.75f => new Color(1f, 0.65f, 0f),
> 0.75f => Color.green,
_ => equipmentCount.color
};
}
}
}
Loading

0 comments on commit eae357e

Please sign in to comment.