From 1de388b219e6c835622e298341fff0fa0be1f94d Mon Sep 17 00:00:00 2001 From: Prown0 <100746335+Prown0@users.noreply.github.com> Date: Thu, 5 Dec 2024 18:24:56 +0900 Subject: [PATCH] Change interface for anomaly controller --- 302/Assets/Scenes/DefaultGameScene.unity | 5 +- .../Scripts/AbstractAnomalyController.cs | 17 ++- 302/Assets/Scripts/AbstractAnomalyObject.cs | 1 + 302/Assets/Scripts/AbstractBehaviour.cs | 41 ++++++ 302/Assets/Scripts/GameManager.cs | 17 +-- 302/Assets/Scripts/SlideManager.cs | 121 +++++++----------- .../Anomaly18Manager.cs | 4 +- .../Anomaly18_Interactable.cs | 3 +- .../Anomaly19Manager.cs | 4 +- .../SpecificAnomalyManager/Anomaly19_Slide.cs | 3 +- .../SpecificAnomalyManager/Anomaly1Manager.cs | 4 +- .../SpecificAnomalyManager/Anomaly1_Girl.cs | 3 +- .../Anomaly20Manager.cs | 4 +- .../Anomaly20_Interactable.cs | 3 +- .../Anomaly23Manager.cs | 4 +- .../SpecificAnomalyManager/Anomaly23_Ghost.cs | 3 +- .../SpecificAnomalyManager/Anomaly2Manager.cs | 4 +- .../SpecificAnomalyManager/Anomaly2_Laptop.cs | 3 +- .../SpecificAnomalyManager/Anomaly6Manager.cs | 4 +- .../SpecificAnomalyManager/Anomaly6_Cake.cs | 3 +- 20 files changed, 135 insertions(+), 116 deletions(-) diff --git a/302/Assets/Scenes/DefaultGameScene.unity b/302/Assets/Scenes/DefaultGameScene.unity index 8a14339..a41bd98 100644 --- a/302/Assets/Scenes/DefaultGameScene.unity +++ b/302/Assets/Scenes/DefaultGameScene.unity @@ -26059,8 +26059,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d5f5a6a7b1f18884e843839632af5a6d, type: 3} m_Name: m_EditorClassIdentifier: - nameLeft: SlideLeft - nameRight: SlideRight + names: + - SlideLeft + - SlideRight numSlide: 15 numStage: 8 --- !u!4 &1164630180 diff --git a/302/Assets/Scripts/AbstractAnomalyController.cs b/302/Assets/Scripts/AbstractAnomalyController.cs index dc9a0a3..268a193 100644 --- a/302/Assets/Scripts/AbstractAnomalyController.cs +++ b/302/Assets/Scripts/AbstractAnomalyController.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using UnityEngine; -public abstract class AbstractAnomalyController : AbstractAnomalyObject +public abstract class AbstractAnomalyComposite : AbstractAnomalyObject { /********** * fields * @@ -21,7 +21,7 @@ public abstract class AbstractAnomalyController : AbstractAnomalyObject **************/ // 클래스 이름 - public override string Name { get; } = "AbstractAnomalyController"; + public override string Name { get; } = "AbstractAnomalyComposite"; /************************************* * implementation: AbstractBehaviour * @@ -143,7 +143,7 @@ protected virtual bool InitObjects() /* 양식: 복사해서 사용하기. -// `AbstractAnomalyController`는 이상현상 컨트롤러에 관한 추상 클래스입니다. +// `AbstractAnomalyComposite`은 이상현상 개체 묶음에 관한 추상 클래스입니다. // // 만약 `AbstractAnomalyObject`를 가지는 오브젝트가 강의실 내에 있다면 이름을 `names`에 넣습니다. // 만약 `AbstractAnomalyObject`를 가지는 오브젝트가 프리팹으로 돼 있다면 프리팹을 `prefabs`에 넣습니다. @@ -152,7 +152,7 @@ protected virtual bool InitObjects() // `ResetAnomaly`에서는 모든 개체의 `ResetAnomaly`를 호출합니다. (composite pattern이 이미 구현돼 있습니다.) // 추가적으로 뭘 해야 한다면 오버라이드하면 됩니다. -public class MyClass : AbstractAnomalyController // TODO: 클래스 이름 수정하기. +public class MyClass : AbstractAnomalyComposite // TODO: 클래스 이름 수정하기. { // 클래스 이름 public override string Name { get; } = ""; // TODO: 클래스 이름 추가하기. @@ -174,6 +174,7 @@ protected override bool InitFields() bool res = base.InitFields(); // TODO: 필드 초기화할 것 넣기. 없으면 메서드를 아예 지워도 됨. + // (사실 필드 말고 초기화할 것도 넣어도 됨....) // 함수가 제대로 작동했으면 `true`를, 아니면 `false`를 반환. return res; @@ -184,7 +185,8 @@ public override bool StartAnomaly() { bool res = base.StartAnomaly(); - // TODO: 이상현상 시작하는 코드 넣기. 없으면 메서드를 아예 지워도 됨. + // TODO: 각 개체의 `StartAnomaly`를 호출하는 것 외에 할 게 있으면 추가하기. + // 없으면 메서드를 아예 지워도 됨. // 함수가 제대로 작동했으면 `true`를, 아니면 `false`를 반환. return res; @@ -195,7 +197,8 @@ public override bool ResetAnomaly() { bool res = base.ResetAnomaly(); - // TODO: 이상현상 초기화하는 코드 넣기. 없으면 메서드를 아예 지워도 됨. + // TODO: 각 개체의 `ResetAnomaly`를 호출하는 것 외에 할 게 있으면 추가하기. + // 없으면 메서드를 아예 지워도 됨. // 함수가 제대로 작동했으면 `true`를, 아니면 `false`를 반환. return res; @@ -206,7 +209,7 @@ protected override bool InitObjects() { bool res = base.InitObjects(); - // TODO: 앞에서 말한 방식으로 초기화할 수 없는 오브젝트가 있다면 여기서 초기화하기. + // TODO: 주석에서 말한 방식으로 초기화할 수 없는 오브젝트가 있다면 여기서 초기화하기. // 없으면 메서드를 아예 지워도 됨. // 함수가 제대로 작동했으면 `true`를, 아니면 `false`를 반환. diff --git a/302/Assets/Scripts/AbstractAnomalyObject.cs b/302/Assets/Scripts/AbstractAnomalyObject.cs index 903110e..9a5879f 100644 --- a/302/Assets/Scripts/AbstractAnomalyObject.cs +++ b/302/Assets/Scripts/AbstractAnomalyObject.cs @@ -53,6 +53,7 @@ protected override bool InitFields() bool res = base.InitFields(); // TODO: 필드 초기화할 것 넣기. 없으면 메서드를 아예 지워도 됨. + // (사실 필드 말고 초기화할 것도 넣어도 됨....) // 함수가 제대로 작동했으면 `true`를, 아니면 `false`를 반환. return res; diff --git a/302/Assets/Scripts/AbstractBehaviour.cs b/302/Assets/Scripts/AbstractBehaviour.cs index 9e1eaa8..5562c50 100644 --- a/302/Assets/Scripts/AbstractBehaviour.cs +++ b/302/Assets/Scripts/AbstractBehaviour.cs @@ -104,6 +104,47 @@ protected override bool InitFields() bool res = base.InitFields(); // TODO: 필드 초기화할 것 넣기. 없으면 메서드를 아예 지워도 됨. + // (사실 필드 말고 초기화할 것도 넣어도 됨....) + // 함수가 제대로 작동했으면 `true`를, 아니면 `false`를 반환. + + return res; + } +} */ + +/* 추가 양식: 매니저 구현 용 양식 + +// 싱글턴까지 구현해 놓은 양식입니다. + +public class MyManager : AbstractBehaviour // TODO: 클래스 이름 수정하기. +{ + // 클래스 이름 + public override string Name { get; } = ""; // TODO: 클래스 이름 추가하기. + + // 클래스 인스턴스 + public static MyManager Instance { get; private set; } // TODO: 클래스 이름 수정하기. + + // `Awake` 메시지 용 메서드 + protected override bool Awake_() + { + if (Instance == null) { + Log($"`Instance` has not been set => set `Instance` as `{Name}`"); + Instance = this; + DontDestroyOnLoad(gameObject); + } else { + Log($"`Instance` has already been set => destroy `{gameObject.name}`"); + Destroy(gameObject); + } + + return base.Awake_(); + } + + // 필드를 초기화하는 메서드 + protected override bool InitFields() + { + bool res = base.InitFields(); + + // TODO: 필드 초기화할 것 넣기. 없으면 메서드를 아예 지워도 됨. + // (사실 필드 말고 초기화할 것도 넣어도 됨....) // 함수가 제대로 작동했으면 `true`를, 아니면 `false`를 반환. return res; diff --git a/302/Assets/Scripts/GameManager.cs b/302/Assets/Scripts/GameManager.cs index c1c3801..a596881 100644 --- a/302/Assets/Scripts/GameManager.cs +++ b/302/Assets/Scripts/GameManager.cs @@ -41,8 +41,7 @@ private void Start() // Added by 신 채 환 // 슬라이드 초기화 - SlideManager.Instance.GenerateSlideList(); - StartCoroutine(InitializeSlideAfterLoad()); + SlideManager.Instance.UpdateStage(); } private void InitializeGame() { @@ -100,10 +99,6 @@ public void Sleep() // 스테이지 실패 시, 이상현상 리스트를 초기화, 재생성 해야 하므로 // AnomalyManager의 Stage Failure시 작동하는 함수 호출 AnomalyManager.Instance.ResetAnomaliesOnFailure(); - - // Added by 신 채 환 - // 슬라이드 색인 배열 재생성 - SlideManager.Instance.GenerateSlideList(); } currentStageClear = false; // 클리어 상태 초기화 LoadDefaultScene(); @@ -120,7 +115,7 @@ public void Sleep() // Added by 신 채 환 // 슬라이드 초기화 - StartCoroutine(InitializeSlideAfterLoad()); + SlideManager.Instance.UpdateStage(); } private void LoadDefaultScene() { @@ -142,14 +137,6 @@ private IEnumerator InstantiateAnomalyAfterLoad() AnomalyManager.Instance.CheckAndInstantiateAnomaly(); } - // Added by 신채환 - private IEnumerator InitializeSlideAfterLoad() - { - yield return new WaitForSeconds(0.1f); - - SlideManager.Instance.SetSlide(currentStage); - } - private void GameClear() { gameState = GameState.GameClear; diff --git a/302/Assets/Scripts/SlideManager.cs b/302/Assets/Scripts/SlideManager.cs index dc9b884..6200a33 100644 --- a/302/Assets/Scripts/SlideManager.cs +++ b/302/Assets/Scripts/SlideManager.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using UnityEngine; public class SlideManager : AbstractBehaviour, IStageObserver @@ -7,23 +8,20 @@ public class SlideManager : AbstractBehaviour, IStageObserver **********/ // 슬라이드 오브젝트 이름 - public string nameLeft; - public string nameRight; + public string[] names; // 개수 public int numSlide; public int numStage; - // 무작위성 + // 난수 private SCH_Random _random; // 오브젝트 - private GameObject _objectLeft; - private GameObject _objectRight; + private List _objects; // 슬라이드 컨트롤러 - private SlideController _controllerLeft; - private SlideController _controllerRight; + private List _controllers; // 슬라이드 색인 배열 private int[] _slideList; @@ -35,7 +33,7 @@ public class SlideManager : AbstractBehaviour, IStageObserver // 클래스 이름 public override string Name { get; } = "SlideManager"; - // 클래스 인자 + // 클래스 인스턴스 public static SlideManager Instance { get; private set; } /********************************** @@ -48,28 +46,40 @@ public bool UpdateStage() bool res = true; if (stage == 0) { - GenerateSlideList(); + // generate random slide index list + _slideList = _random.Combination(numSlide, numStage); + Log($"Generate `_slideList` success: [{string.Join(", ", _slideList)}]"); + + // find and put away the slides + Log("Call `FindSlides` begin"); if (FindSlides()) { - _objectLeft.transform.Translate(Vector3.down * 100.0f); - _objectRight.transform.Translate(Vector3.down * 100.0f); + Log("Call `FindSlides` success"); + + foreach (GameObject obj in _objects) { + obj.transform.Translate(Vector3.down * 100.0f); + } + Log("Set slide success: off"); } else { - Log("Set slide failed", mode: 1); + Log("Call `FindSlides` failed", mode: 1); res = false; } } else if (stage > 0 && stage <= numStage) { + // find and update slides + Log("Call `FindSlides` begin"); if (FindSlides()) { - int index = _slideList[stage - 1]; + Log("Call `FindSlides` success"); - _controllerLeft.Index = index; - _controllerRight.Index = index; + int index = _slideList[stage - 1]; - _controllerLeft.ResetSlide(); - _controllerRight.ResetSlide(); + foreach (SlideController controller in _controllers) { + controller.Index = index; + controller.ResetSlide(); + } Log($"Set slide success: {index}"); } else { - Log("Set slide failed", mode: 1); + Log("Call `FindSlides` failed", mode: 1); res = false; } } else { @@ -119,77 +129,32 @@ protected override bool InitFields() * new methods * ***************/ - // 슬라이드 색인 배열을 초기화하는 메서드 - public void GenerateSlideList() - { - _slideList = _random.Combination(numSlide, numStage); - Log($"Generate `_slideList` success: [{string.Join(", ", _slideList)}]"); - } - - // 슬라이드를 초기화하는 메서드 - public void SetSlide(int stage) - { - Log("Call `FindSlides` begin"); - if (FindSlides()) { - Log("Call `FindSlides` success"); - if (stage > 0) { - int index = _slideList[stage - 1]; - - _controllerLeft.Index = index; - _controllerRight.Index = index; - - _controllerLeft.ResetSlide(); - _controllerRight.ResetSlide(); - - Log($"Set slide success: {index}"); - } else { - _objectLeft.transform.Translate(Vector3.down * 100.0f); - _objectRight.transform.Translate(Vector3.down * 100.0f); - } - } else { - Log("Call `FindSlides` failed", mode: 1); - } - } - // 슬라이드를 찾는 메서드 private bool FindSlides() { bool res = true; - // `_objectLeft` 찾기 - _objectLeft = GameObject.Find(nameLeft); - if (_objectLeft != null) { - Log("Find `_objectLeft` success"); + for (int idx = 0; idx < names.Length; idx++) { + GameObject obj = GameObject.Find(names[idx]); - // `_controllerLeft` 찾기 - _controllerLeft = _objectLeft.GetComponent(); - if (_controllerLeft != null) { - Log("Find `_controllerLeft` success"); - } else { - Log("Find `_controllerLeft` failed", mode: 1); - res = false; - } - } else { - Log("Find `_objectLeft` failed", mode: 1); - res = false; - } + if (obj != null) { + Log($"Find `{names[idx]}` success: `{obj.name}`"); - // `_objectRight` 찾기 - _objectRight = GameObject.Find(nameRight); - if (_objectRight != null) { - Log("Find `_objectRight` success"); + SlideController controller = obj.GetComponent(); - // `_controllerRight` 찾기 - _controllerRight = _objectRight.GetComponent(); - if (_controllerRight != null) { - Log("Find `_controllerRight` success"); + if (controller != null) { + Log($"Find `SlideController` of `{obj.name}` success: `{controller.Name}`"); + + _objects.Add(obj); + _controllers.Add(controller); + } else { + Log($"Find `SlideController` of `{obj.name}` failed", mode: 1); + res = false; + } } else { - Log("Find `_controllerRight` failed", mode: 1); + Log($"Find `{names[idx]}` failed", mode: 1); res = false; } - } else { - Log("Find `_objectRight` failed", mode: 1); - res = false; } return res; diff --git a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly18Manager.cs b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly18Manager.cs index 2b59f17..62129fc 100644 --- a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly18Manager.cs +++ b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly18Manager.cs @@ -1,4 +1,4 @@ -public class Anomaly18Manager : AbstractAnomalyController +public class Anomaly18Manager : AbstractAnomalyComposite { /************** * properties * @@ -16,6 +16,7 @@ protected override bool Awake_() { bool res = base.Awake_(); + // Code used before `GameManager` updates begin Log("Call `StartAnomaly` begin"); if (StartAnomaly()) { Log("Call `StartAnomaly` success"); @@ -23,6 +24,7 @@ protected override bool Awake_() Log("Call `StartAnomaly` failed", mode: 1); res = false; } + // Code used before `GameManager` updates end return res; } diff --git a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly18_Interactable.cs b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly18_Interactable.cs index 88c1f38..3171391 100644 --- a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly18_Interactable.cs +++ b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly18_Interactable.cs @@ -31,7 +31,8 @@ public override void OnInteract() Log("Call `GameManager.SetStageClear` end"); // Code used before `GameManager` updates begin - AbstractAnomalyController controller = FindAnyObjectByType(); + GameObject controllerObject = GameObject.Find("Anomaly18Manager"); + AbstractAnomalyObject controller = controllerObject.GetComponent(); Log($"Call `{controller.Name}.ResetAnomaly` begin"); if (controller.ResetAnomaly()) { diff --git a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly19Manager.cs b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly19Manager.cs index d89612f..f558538 100644 --- a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly19Manager.cs +++ b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly19Manager.cs @@ -1,4 +1,4 @@ -public class Anomaly19Manager : AbstractAnomalyController +public class Anomaly19Manager : AbstractAnomalyComposite { /************** * properties * @@ -16,6 +16,7 @@ protected override bool Awake_() { bool res = base.Awake_(); + // Code used before `GameManager` updates begin Log("Call `StartAnomaly` begin"); if (StartAnomaly()) { Log("Call `StartAnomaly` success"); @@ -23,6 +24,7 @@ protected override bool Awake_() Log("Call `StartAnomaly` failed", mode: 1); res = false; } + // Code used before `GameManager` updates end return res; } diff --git a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly19_Slide.cs b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly19_Slide.cs index 3652e1c..b235615 100644 --- a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly19_Slide.cs +++ b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly19_Slide.cs @@ -54,7 +54,8 @@ public override void OnInteract() Log("Call `GameManager.SetStageClear` end"); // Code used before `GameManager` updates begin - AbstractAnomalyController controller = FindAnyObjectByType(); + GameObject controllerObject = GameObject.Find("Anomaly19Manager"); + AbstractAnomalyObject controller = controllerObject.GetComponent(); Log($"Call `{controller.Name}.ResetAnomaly` begin"); if (controller.ResetAnomaly()) { diff --git a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly1Manager.cs b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly1Manager.cs index 4e5f27b..26e0fda 100644 --- a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly1Manager.cs +++ b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly1Manager.cs @@ -1,4 +1,4 @@ -public class Anomaly1Manager : AbstractAnomalyController +public class Anomaly1Manager : AbstractAnomalyComposite { /************** * properties * @@ -16,6 +16,7 @@ protected override bool Awake_() { bool res = base.Awake_(); + // Code used before `GameManager` updates begin Log("Call `StartAnomaly` begin"); if (StartAnomaly()) { Log("Call `StartAnomaly` success"); @@ -23,6 +24,7 @@ protected override bool Awake_() Log("Call `StartAnomaly` failed", mode: 1); res = false; } + // Code used before `GameManager` updates end return res; } diff --git a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly1_Girl.cs b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly1_Girl.cs index e5e63db..4027ac7 100644 --- a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly1_Girl.cs +++ b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly1_Girl.cs @@ -24,7 +24,8 @@ public override void OnInteract() Log("Call `GameManager.SetStageClear` end"); // Code used before `GameManager` updates begin - AbstractAnomalyController controller = FindAnyObjectByType(); + GameObject controllerObject = GameObject.Find("Anomaly1Manager"); + AbstractAnomalyObject controller = controllerObject.GetComponent(); Log($"Call `{controller.Name}.ResetAnomaly` begin"); if (controller.ResetAnomaly()) { diff --git a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly20Manager.cs b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly20Manager.cs index 513dbf1..7d075a4 100644 --- a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly20Manager.cs +++ b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly20Manager.cs @@ -1,4 +1,4 @@ -public class Anomaly20Manager : AbstractAnomalyController +public class Anomaly20Manager : AbstractAnomalyComposite { /************** * properties * @@ -16,6 +16,7 @@ protected override bool Awake_() { bool res = base.Awake_(); + // Code used before `GameManager` updates begin Log("Call `StartAnomaly` begin"); if (StartAnomaly()) { Log("Call `StartAnomaly` success"); @@ -23,6 +24,7 @@ protected override bool Awake_() Log("Call `StartAnomaly` failed", mode: 1); res = false; } + // Code used before `GameManager` updates end return res; } diff --git a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly20_Interactable.cs b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly20_Interactable.cs index 1d817c7..3a3748e 100644 --- a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly20_Interactable.cs +++ b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly20_Interactable.cs @@ -35,7 +35,8 @@ public override void OnInteract() Log("Call `GameManager.SetStageClear` end"); // Code used before `GameManager` updates begin - AbstractAnomalyController controller = FindAnyObjectByType(); + GameObject controllerObject = GameObject.Find("Anomaly20Manager"); + AbstractAnomalyObject controller = controllerObject.GetComponent(); Log($"Call `{controller.Name}.ResetAnomaly` begin"); if (controller.ResetAnomaly()) { diff --git a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly23Manager.cs b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly23Manager.cs index 026a05c..7609e87 100644 --- a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly23Manager.cs +++ b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly23Manager.cs @@ -1,4 +1,4 @@ -public class Anomaly23Manager : AbstractAnomalyController +public class Anomaly23Manager : AbstractAnomalyComposite { /************** * properties * @@ -16,6 +16,7 @@ protected override bool Awake_() { bool res = base.Awake_(); + // Code used before `GameManager` updates begin Log("Call `StartAnomaly` begin"); if (StartAnomaly()) { Log("Call `StartAnomaly` success"); @@ -23,6 +24,7 @@ protected override bool Awake_() Log("Call `StartAnomaly` failed", mode: 1); res = false; } + // Code used before `GameManager` updates end return res; } diff --git a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly23_Ghost.cs b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly23_Ghost.cs index 3513403..0491e0b 100644 --- a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly23_Ghost.cs +++ b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly23_Ghost.cs @@ -91,7 +91,8 @@ void Update() Log("Call `GameManager.SetStageClear` end"); // Code used before `GameManager` updates begin - AbstractAnomalyController controller = FindAnyObjectByType(); + GameObject controllerObject = GameObject.Find("Anomaly23Manager"); + AbstractAnomalyObject controller = controllerObject.GetComponent(); Log($"Call `{controller.Name}.ResetAnomaly` begin"); if (controller.ResetAnomaly()) { diff --git a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly2Manager.cs b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly2Manager.cs index 4cff72d..c562b11 100644 --- a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly2Manager.cs +++ b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly2Manager.cs @@ -1,4 +1,4 @@ -public class Anomaly2Manager : AbstractAnomalyController +public class Anomaly2Manager : AbstractAnomalyComposite { /************** * properties * @@ -16,6 +16,7 @@ protected override bool Awake_() { bool res = base.Awake_(); + // Code used before `GameManager` updates begin Log("Call `StartAnomaly` begin"); if (StartAnomaly()) { Log("Call `StartAnomaly` success"); @@ -23,6 +24,7 @@ protected override bool Awake_() Log("Call `StartAnomaly` failed", mode: 1); res = false; } + // Code used before `GameManager` updates end return res; } diff --git a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly2_Laptop.cs b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly2_Laptop.cs index a9ce138..8f14570 100644 --- a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly2_Laptop.cs +++ b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly2_Laptop.cs @@ -34,7 +34,8 @@ public override void OnInteract() Log("Call `GameManager.SetStageClear` end"); // Code used before `GameManager` updates begin - AbstractAnomalyController controller = FindAnyObjectByType(); + GameObject controllerObject = GameObject.Find("Anomaly2Manager"); + AbstractAnomalyObject controller = controllerObject.GetComponent(); Log($"Call `{controller.Name}.ResetAnomaly` begin"); if (controller.ResetAnomaly()) { diff --git a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly6Manager.cs b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly6Manager.cs index 378099a..347474b 100644 --- a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly6Manager.cs +++ b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly6Manager.cs @@ -1,4 +1,4 @@ -public class Anomaly6Manager : AbstractAnomalyController +public class Anomaly6Manager : AbstractAnomalyComposite { /************** * properties * @@ -16,6 +16,7 @@ protected override bool Awake_() { bool res = base.Awake_(); + // Code used before `GameManager` updates begin Log("Call `StartAnomaly` begin"); if (StartAnomaly()) { Log("Call `StartAnomaly` success"); @@ -23,6 +24,7 @@ protected override bool Awake_() Log("Call `StartAnomaly` failed", mode: 1); res = false; } + // Code used before `GameManager` updates end return res; } diff --git a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly6_Cake.cs b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly6_Cake.cs index e7deb98..a085b91 100644 --- a/302/Assets/Scripts/SpecificAnomalyManager/Anomaly6_Cake.cs +++ b/302/Assets/Scripts/SpecificAnomalyManager/Anomaly6_Cake.cs @@ -30,7 +30,8 @@ public override void OnInteract() Log("Call `GameManager.SetStageClear` end"); // Code used before `GameManager` updates begin - AbstractAnomalyController controller = FindAnyObjectByType(); + GameObject controllerObject = GameObject.Find("Anomaly6Manager"); + AbstractAnomalyObject controller = controllerObject.GetComponent(); Log($"Call `{controller.Name}.ResetAnomaly` begin"); if (controller.ResetAnomaly()) {