Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ref/seozzi/anomaly16 #198

Merged
merged 3 commits into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions 302/Assets/Scripts/SpecificAnomalyManager/Anomaly15_spider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ public override bool ResetAnomaly()
return res;
}

public override virtual OnInteract()
{
base.OnInteract();
GameManager.Instance.SetStageClear();
}

private IEnumerator DelayedDestroy()
{
Expand Down
68 changes: 24 additions & 44 deletions 302/Assets/Scripts/SpecificAnomalyManager/Anomaly16_marker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
using System.Collections;
using System.Collections.Generic;

public class Anomaly16_marker : InteractableObject, IInteractable
public class Anomaly16_marker : AbstractAnomalyInteractable
{
private bool hasInteracted = false;
private Anomaly16Controller anomalyManager; // Reference to Anomaly16Controller
public override string Name { get; } = "Anomaly16_marker";
private Anomaly16Controller anomalyManager;

private Transform cameraTransform;

Expand All @@ -28,7 +28,7 @@ public class Anomaly16_marker : InteractableObject, IInteractable
private const float endZ = -14.26f;
private bool isDrawing = false;

private void Start()
public override bool StartAnomaly()
{
// Set up the camera
GameObject mainCamera = GameObject.FindWithTag("MainCamera");
Expand All @@ -44,6 +44,11 @@ private void Start()
audioSource = gameObject.AddComponent<AudioSource>();
audioSource.clip = markerSoundClip;
audioSource.loop = true;
audioSource.spatialBlend = 1f; // Enable 3D audio
audioSource.minDistance = 1f; // Start fading volume after 1 unit
audioSource.maxDistance = 15f; // Completely fade out at 15 units
audioSource.rolloffMode = AudioRolloffMode.Linear; // Smooth volume transitions


// Initialize LineRenderer for drawing
lineRenderer.positionCount = 1;
Expand All @@ -59,6 +64,21 @@ private void Start()
StartCoroutine(StartDrawingWithDelay());
}

public override bool ResetAnomaly()
{
if (anomalyManager != null)
{
anomalyManager.DestroyMarkerLineWithSound();
audioSource.Stop();
}
}

public override virtual OnInteract()
{
base.OnInteract();
GameManager.Instance.SetStageClear();
}

private IEnumerator StartDrawingWithDelay()
{
yield return new WaitForSeconds(3f); // Wait for 3 seconds
Expand All @@ -67,26 +87,12 @@ private IEnumerator StartDrawingWithDelay()

private void Update()
{
HandleAudioBasedOnDistance();
if (isDrawing)
{
DrawLineWithRandomness();
}
}

private void HandleAudioBasedOnDistance()
{
float distanceToCamera = Vector3.Distance(lastPosition, cameraTransform.position);
if (distanceToCamera <= 15f && !hasInteracted)
{
if (!audioSource.isPlaying) audioSource.Play();
}
else
{
if (audioSource.isPlaying) audioSource.Stop();
}
}

private void DrawLineWithRandomness()
{
if (lastPosition.z <= endZ)
Expand Down Expand Up @@ -177,30 +183,4 @@ private void UpdateMeshCollider()
meshCollider.sharedMesh = null;
meshCollider.sharedMesh = lineMesh;
}

public string GetInteractionPrompt()
{
return "Press Left Click to interact with the red line";
}

public bool CanInteract(float distance)
{
return !hasInteracted;
}
// modified by 신채환
// CanInteract 메서드가 거리를 인자로 받도록 변경

public void OnInteract()
{
if (hasInteracted) return;

hasInteracted = true;
if (anomalyManager != null)
{
anomalyManager.DestroyMarkerLineWithSound();
audioSource.Stop();
}
GameManager.Instance.SetStageClear(); // Mark the stage as clear

}
}
Loading