Skip to content

Commit

Permalink
feat: welder particles
Browse files Browse the repository at this point in the history
  • Loading branch information
pyoneerC committed Sep 24, 2024
1 parent ff2582d commit e61459b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Assets/Scenes/Reparation.unity
Original file line number Diff line number Diff line change
Expand Up @@ -2445,6 +2445,11 @@ Transform:
m_CorrespondingSourceObject: {fileID: -5819118886272102141, guid: c2c82adf9ac2fdc4cae5ff03189357ae, type: 3}
m_PrefabInstance: {fileID: 470749343}
m_PrefabAsset: {fileID: 0}
--- !u!1 &180829341 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 1329845292236604, guid: 9bba9cf244c53c5439505dfc96fdd11c, type: 3}
m_PrefabInstance: {fileID: 349481580}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &188083860
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -13373,6 +13378,10 @@ PrefabInstance:
propertyPath: weldingSound
value:
objectReference: {fileID: 8300000, guid: 943919089a11d73468a581b3d1940529, type: 3}
- target: {fileID: 4614605577419265582, guid: 6bacecc4f3df9584198879c73a6b6c36, type: 3}
propertyPath: welderParticles
value:
objectReference: {fileID: 180829341}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects:
Expand Down
10 changes: 10 additions & 0 deletions Assets/Scripts/FixLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@ public class FixLogic : MonoBehaviour
public int fixedCount;
public AudioSource audioSource;
public AudioClip weldingSound;
public GameObject welderParticles;

private bool _isOverlapping;
private GameObject _currentLeak;
private bool _isFixing;

private void Start()
{
welderParticles.SetActive(false);
}

private void OnTriggerEnter(Collider other)
{
if (!other.CompareTag("Leak")) return;
Expand All @@ -25,13 +32,15 @@ private void OnTriggerExit(Collider other)
_currentLeak = null;
audioSource.Stop();
Debug.Log("Exited leak area.");
welderParticles.SetActive(false);
}

private void Update()
{
if (!_isOverlapping || !Input.GetKey(KeyCode.F) || _isFixing) return;
StartCoroutine(FixLeak());
audioSource.PlayOneShot(weldingSound);
welderParticles.SetActive(true);
}

private IEnumerator FixLeak()
Expand All @@ -50,6 +59,7 @@ private IEnumerator FixLeak()
if (!_isOverlapping || _currentLeak == null)
{
Debug.Log("No longer overlapping with leak. Fix aborted.");
welderParticles.SetActive(false);
_isFixing = false;
yield break;
}
Expand Down

0 comments on commit e61459b

Please sign in to comment.