Skip to content

Commit

Permalink
AnomalyController 5,7,9,14,25,26 Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
박동호 authored and 박동호 committed Dec 17, 2024
1 parent eb5c6d1 commit 88a40f4
Show file tree
Hide file tree
Showing 13 changed files with 120 additions and 38 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions 302/Assets/Prefabs/sideGirlPrefab/sideGirl.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 63791c65d79f24b35ab1c6fecdb85dd9, type: 3}
m_Name:
m_EditorClassIdentifier:
promptMessage: "\uD074\uB9AD\uD558\uC5EC \uC0C1\uD638\uC791\uC6A9"
interactionRange: 2
interactSound: {fileID: 0}
fadeOutDuration: 2
prompt:
distanceInteractionMax: 2
--- !u!65 &2250832690799726206
BoxCollider:
m_ObjectHideFlags: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ protected override bool Awake_()
{
Instantiate(sideGirlPrefab, spawnPosition, Quaternion.Euler(0, 180, 0));
}
StartAnomaly();

return res;
}

public override bool StartAnomaly()
{
bool res = base.StartAnomaly();
StartCoroutine(PlayMusicAfterDelay());
return res;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,32 @@
using System.Collections.Generic;
using UnityEngine;

public class SideGirl : InteractableObject
public class Anomaly05_SideGirl : AbstractAnomalyInteractable
{
[Header("Side Girl Settings")]

private MeshRenderer meshRenderer;
private bool hasInteracted = false;
private Anomaly05Controller anomalyManager;

private void Awake()
{
meshRenderer = GetComponent<MeshRenderer>();
// Anomaly5Manager 찾기
anomalyManager = FindObjectOfType<Anomaly05Controller>();
}
public override string Name { get; } = "SideGirl";
[Header("Side Girl Settings")]
private MeshRenderer meshRenderer;
private bool hasInteracted = false;
private Anomaly05Controller anomalyManager;
protected override bool Awake_()
{
bool res = base.Awake_();
meshRenderer = GetComponent<MeshRenderer>();
// Anomaly5Manager 찾기
anomalyManager = FindObjectOfType<Anomaly05Controller>();
return res;
}

public override void OnInteract()
{
if (hasInteracted) return;
public override void OnInteract()
{
base.OnInteract();
if (anomalyManager != null){
anomalyManager.StopAnomalyMusic();
}
hasInteracted = true;
StartCoroutine(FadeOutAllMeshRenderers(gameObject));
GameManager.Instance.SetStageClear();
}
}

private IEnumerator FadeOutAllMeshRenderers(GameObject target)
{
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using UnityEngine;

public class Anomaly07Controller : MonoBehaviour
public class Anomaly07Controller : AbstractAnomalyComposite
{
[Header("Russian Roulette Settings")]
[SerializeField] private GameObject gunPrefab;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using UnityEngine;
using System.Collections;

public class Anomaly7_Gun : InteractableObject
public class Anomaly07_Gun : AbstractAnomalyInteractable
{
public override string Name { get; } = "Gun";
[Header("Gun Settings")]
[SerializeField] private Vector3 holdPosition = new Vector3(0.6f, 0f, 0.6f);
[SerializeField] private Vector3 holdRotation = new Vector3(0f, -120f, 0f);
Expand Down Expand Up @@ -33,8 +34,9 @@ public class Anomaly7_Gun : InteractableObject
private Camera mainCamera;
private float currentFlashAlpha = 0f;

private void Awake()
protected override bool Awake_()
{
bool res = base.Awake_();
originalPosition = transform.position;
originalRotation = transform.rotation;

Expand All @@ -53,6 +55,7 @@ private void Awake()
flashMaterial.SetInt("_Cull", (int)UnityEngine.Rendering.CullMode.Off);
flashMaterial.SetInt("_ZWrite", 0);
flashMaterial.SetInt("_ZTest", (int)UnityEngine.Rendering.CompareFunction.Always);
return res;
}

private void OnEnable()
Expand Down
25 changes: 22 additions & 3 deletions 302/Assets/Scripts/SpecificAnomalyManager/Anomaly09Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
using System.Collections;
using System.Collections.Generic;

public class Anomaly09Controller : MonoBehaviour
public class Anomaly09Controller : AbstractAnomalyComposite
{
public override string Name { get; } = "Anomaly09Controller";
[Header("Anomaly Settings")]
public float anomalyDelay = 15f;

Expand Down Expand Up @@ -60,13 +61,15 @@ public class Anomaly09Controller : MonoBehaviour
private List<GameObject> spawnedLights = new List<GameObject>();
private Coroutine anomalyCoroutine;

void Awake()
protected override bool Awake_()
{
bool res = base.Awake_();
audioSource = gameObject.AddComponent<AudioSource>();
audioSource.clip = anomalyMusic;
audioSource.volume = musicVolume;
audioSource.loop = true;
audioSource.playOnAwake = false;
return res;
}

void Start()
Expand All @@ -77,12 +80,26 @@ void Start()

void OnEnable()
{
anomalyCoroutine = StartCoroutine(StartAnomalyWithDelay());
StartAnomaly();
Debug.Log($"이상현상 발생 - {anomalyDelay}초 후 나타납니다.");
}

void OnDisable()
{
ResetAnomaly();
}

public override bool StartAnomaly()
{
bool res = base.StartAnomaly();
anomalyCoroutine = StartCoroutine(StartAnomalyWithDelay());
return res;
}

public override bool ResetAnomaly()
{
bool res = base.ResetAnomaly();

if (anomalyCoroutine != null)
{
StopCoroutine(anomalyCoroutine);
Expand All @@ -92,6 +109,8 @@ void OnDisable()
StopAnomalyMusic();
CleanupSpawnedObjects();
RestoreOriginalLightIntensities();

return res;
}

IEnumerator StartAnomalyWithDelay()
Expand Down
28 changes: 24 additions & 4 deletions 302/Assets/Scripts/SpecificAnomalyManager/Anomaly14Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

using UnityEngine;

public class Anomaly14Controller : MonoBehaviour
public class Anomaly14Controller : AbstractAnomalyComposite
{
public override string Name { get; } = "Anomaly14Controller";
public GameObject SweaterSitGirlPrefab;
public GameObject DifferentPrefab; // 다른 종류의 프리팹
public float yRotation = 180f;
Expand All @@ -15,9 +16,11 @@ private void Start()
{
audioSource = GetComponent<AudioSource>();
}

private void OnEnable()
// 이상현상을 시작하는 메서드
public override bool StartAnomaly()
{
bool res = base.StartAnomaly();

if (audioSource != null)
{
audioSource.Play();
Expand Down Expand Up @@ -62,13 +65,30 @@ private void OnEnable()
}
}
}

return res;
}

private void OnDisable()
public override bool ResetAnomaly()
{
bool res = base.ResetAnomaly();

if (audioSource != null && audioSource.isPlaying)
{
audioSource.Stop();
}

return res;
}

private void OnEnable()
{
StartAnomaly();
}


private void OnDisable()
{
ResetAnomaly();
}
}
22 changes: 16 additions & 6 deletions 302/Assets/Scripts/SpecificAnomalyManager/Anomaly25Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,24 @@
using System.Collections.Generic;
using UnityEngine;

public class Anomaly25Controller : MonoBehaviour
public class Anomaly25Controller : AbstractAnomalyComposite
{
public AudioSource audioSource; // Inspector에서 할당
public override string Name { get; } = "Anomaly25Controller";
public AudioSource audioSource; // Inspector에서 할당

void Start() {
StartCoroutine(ActivateFloatingEffect());
CreateInvisibleCeiling();
}
void Start() {
StartAnomaly();
}

public override bool StartAnomaly()
{
bool res = base.StartAnomaly();

StartCoroutine(ActivateFloatingEffect());
CreateInvisibleCeiling();

return res;
}

IEnumerator ActivateFloatingEffect() {
yield return new WaitForSeconds(15f);
Expand Down
12 changes: 11 additions & 1 deletion 302/Assets/Scripts/SpecificAnomalyManager/Anomaly26Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
using System.Collections;
using System.Collections.Generic;

public class Anomaly26Controller : MonoBehaviour
public class Anomaly26Controller : AbstractAnomalyComposite
{
public override string Name { get; } = "Anomaly26Controller";
[Header("Fire Settings")]
[SerializeField] private GameObject firePrefab;
[SerializeField] private int totalFiresToSpawn = 30;
Expand All @@ -26,7 +27,16 @@ public class Anomaly26Controller : MonoBehaviour

private void OnEnable()
{
StartAnomaly();
}

public override bool StartAnomaly()
{
bool res = base.StartAnomaly();

StartCoroutine(InitialFireSpawnDelay());

return res;
}

private void OnDisable()
Expand Down

0 comments on commit 88a40f4

Please sign in to comment.