-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #191 from 2024FALL-SWPP/ref/chaehwan/design-pattern
Ref/chaehwan/design pattern
- Loading branch information
Showing
11 changed files
with
217 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
using UnityEngine; | ||
|
||
public class TimeManager : AbstractBehaviour, IStageObserver | ||
{ | ||
/********** | ||
* fields * | ||
**********/ | ||
|
||
// 오브젝트 이름 | ||
public string nameClock; | ||
public string nameLaptop; | ||
|
||
/************** | ||
* properties * | ||
**************/ | ||
|
||
// 클래스 이름 | ||
public override string Name { get; } = "TimeManager"; | ||
|
||
// 클래스 인스턴스 | ||
public static TimeManager Instance { get; private set; } | ||
|
||
/********************************** | ||
* implementation: IStageObserver * | ||
**********************************/ | ||
|
||
// 단계 변경 시 불리는 메서드 | ||
public bool UpdateStage() | ||
{ | ||
int stage = GameManager.Instance.GetCurrentStage(); | ||
ClockController clock = FindClock(); | ||
LaptopScreenController laptop = FindLaptop(); | ||
bool res = true; | ||
|
||
if (clock != null) { | ||
Log("Find `ClockController` success"); | ||
clock.SetTime(stage); | ||
} else { | ||
Log("Find `ClockController` failed", mode: 1); | ||
res = false; | ||
} | ||
|
||
if (laptop != null) { | ||
Log("Find `LaptopScreenController` success"); | ||
laptop.ChangeScreen(stage); | ||
} else { | ||
Log("Find `LaptopScreenController` failed", mode: 1); | ||
res = false; | ||
} | ||
|
||
return res; | ||
} | ||
|
||
/************************************* | ||
* implementation: AbstractBehaviour * | ||
*************************************/ | ||
|
||
// `Awake` 메시지 용 메서드 | ||
protected override bool Awake_() | ||
{ | ||
bool res = false; | ||
|
||
if (Instance == null) { | ||
Log($"`Instance` has not been set => set `Instance` as `{Name}`"); | ||
Instance = this; | ||
DontDestroyOnLoad(gameObject); | ||
res = base.Awake_(); | ||
} else { | ||
Log($"`Instance` has already been set => destroy `{gameObject.name}`"); | ||
Destroy(gameObject); | ||
} | ||
|
||
return res; | ||
} | ||
|
||
/*************** | ||
* new methods * | ||
***************/ | ||
|
||
// 시계를 찾는 메서드 | ||
private ClockController FindClock() | ||
{ | ||
GameObject obj = GameObject.Find(nameClock); | ||
ClockController clock; | ||
|
||
if (obj != null) { | ||
clock = obj.GetComponent<ClockController>(); | ||
} else { | ||
clock = null; | ||
} | ||
|
||
return clock; | ||
} | ||
|
||
// 노트북을 찾는 메서드 | ||
private LaptopScreenController FindLaptop() | ||
{ | ||
GameObject obj = GameObject.Find(nameLaptop); | ||
LaptopScreenController laptop; | ||
|
||
if (obj != null) { | ||
laptop = obj.GetComponent<LaptopScreenController>(); | ||
} else { | ||
laptop = null; | ||
} | ||
|
||
return laptop; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.