Skip to content

Commit

Permalink
Merge branch 'main' into chaehwan/anomaly01
Browse files Browse the repository at this point in the history
  • Loading branch information
Prown0 committed Nov 22, 2024
2 parents 3194a98 + b36c969 commit 5e8111a
Show file tree
Hide file tree
Showing 8 changed files with 52,681 additions and 1,151 deletions.
53,646 changes: 52,515 additions & 1,131 deletions 302/Assets/Scenes/GameStartingScene.unity

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion 302/Assets/Scenes/GameStartingScene.unity.meta

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

7 changes: 7 additions & 0 deletions 302/Assets/Scripts/ClockController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ public void SetTime(int stage)
// stage 1 at 7:00, stage 8 at 8:45
int hour = 7 + ((stage - 1) % 4);
int minute = 15 * ((stage - 1) % 4);

// Added by 박상윤
// 0스테이지는 기존과 다르게 그냥 대입
if(stage == 0) {
hour = 6;
minute = 50;
}

float minuteRotation = minute * 6f; // 6 degrees per minute
float hourRotation = (hour * 30f) + (minute * 0.5f); // 30 degrees per hour + 0.5 degrees per minute
Expand Down
2 changes: 1 addition & 1 deletion 302/Assets/Scripts/DefaultManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class DefaultManager : MonoBehaviour
// Start is called before the first frame update
void Start()
{

GameManager.Instance.SetStageClear();
}

// Update is called once per frame
Expand Down
4 changes: 2 additions & 2 deletions 302/Assets/Scripts/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class GameManager : MonoBehaviour
{
public static GameManager Instance { get; private set; }
// 스테이지 관리
[SerializeField] private int currentStage = 1;
[SerializeField] private int currentStage = 0;
[SerializeField] private bool currentStageClear = false; // 현재 스테이지 클리어 여부
[SerializeField] private ClockController clockController;
private const string DEFAULT_SCENE = "DefaultGameScene";
Expand Down Expand Up @@ -41,7 +41,7 @@ private void Start()
}
private void InitializeGame()
{
currentStage = 1;
currentStage = 0;
currentStageClear = false;
gameState = GameState.Playing;
LoadDefaultScene();
Expand Down
88 changes: 88 additions & 0 deletions 302/Assets/Scripts/StartingCameraController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
using UnityEngine;
using System;

public class StartingCameraController : MonoBehaviour
{
[SerializeField] private ScreenFader screenFader; // ScreenFader 컴포넌트
[SerializeField] private float fadeOutDuration = 2f; // 화면 어두워지는 시간
[SerializeField] private float fadeInDuration = 2f; // 화면 밝아지는 시간
[SerializeField] private float waitBeforeFadeIn = 0.5f; // 화면이 어두워진 상태에서 대기 시간

public event Action OnFadeComplete; // 페이드 완료 시 이벤트
private bool isFading = false;

void Start()
{
if (screenFader == null)
{
screenFader = FindObjectOfType<ScreenFader>();
if (screenFader == null)
{
Debug.LogError("ScreenFader component not found in the scene!");
return;
}
}
}

public void PlayFadeSequence()
{
if (!isFading)
{
StartCoroutine(FadeSequence());
}
}

public void PlayFadeOut()
{
if (!isFading)
{
StartCoroutine(FadeOut());
}
}

public void PlayFadeIn()
{
if (!isFading)
{
StartCoroutine(FadeIn());
}
}

private System.Collections.IEnumerator FadeSequence()
{
isFading = true;

// Fade Out
yield return FadeOut();

// 대기
yield return new WaitForSeconds(waitBeforeFadeIn);

// Fade In
yield return FadeIn();

yield return FadeOut();
yield return new WaitForSeconds(waitBeforeFadeIn);
yield return FadeIn();
yield return FadeOut();

isFading = false;

// 애니메이션 완료 신호 전송
OnFadeComplete?.Invoke();
}

private System.Collections.IEnumerator FadeOut()
{
isFading = true;
screenFader.StartFade(1f, fadeOutDuration);
yield return new WaitForSeconds(fadeOutDuration);
}

private System.Collections.IEnumerator FadeIn()
{
screenFader.StartFade(0f, fadeInDuration);
yield return new WaitForSeconds(fadeInDuration);
isFading = false;
}
}
11 changes: 11 additions & 0 deletions 302/Assets/Scripts/StartingCameraController.cs.meta

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

72 changes: 56 additions & 16 deletions 302/Assets/Scripts/UIManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,74 @@ public class UIManager : MonoBehaviour
{
public GameObject titleText; // 타이틀 텍스트 오브젝트
public Button startButton; // 시작 버튼
public GameObject difficultyButtonGroup; // 난이도 버튼 그룹
public Button normalButton; // 노말 난이도 버튼
public Button hardButton; // 하드 난이도 버튼
private int difficultyLevel; // 난이도 변수
private StartingCameraController startingCameraController;

private AsyncOperation sceneLoadOperation; // 비동기 씬 로드 작업

void Start()
{
// 초기 설정
difficultyButtonGroup.SetActive(false); // 난이도 선택 그룹 숨기기
startingCameraController = FindObjectOfType<StartingCameraController>();
if (startingCameraController == null)
{
Debug.LogError("StartingCameraController not found in the scene!");
}
else
{
startingCameraController.OnFadeComplete += OnFadeComplete; // 애니메이션 완료 이벤트 연결
}

// 버튼에 이벤트 연결
startButton.onClick.AddListener(OnStartButtonClicked); // Start 버튼
normalButton.onClick.AddListener(() => SetDifficultyAndStartGame(0)); // Normal 버튼
hardButton.onClick.AddListener(() => SetDifficultyAndStartGame(1)); // Hard 버튼
startButton.onClick.AddListener(OnStartButtonClicked); // Start 버튼
}

// 시작 버튼 클릭 시 호출
private void OnStartButtonClicked()
{
titleText.SetActive(false); // 타이틀 텍스트 숨기기
startButton.gameObject.SetActive(false); // 시작 버튼 숨기기
difficultyButtonGroup.SetActive(true); // 난이도 선택 그룹 표시

// 비동기 씬 로드 시작
StartCoroutine(PreloadDefaultScene());

if (startingCameraController != null)
{
startingCameraController.PlayFadeSequence(); // 화면 어두워졌다 밝아지는 애니메이션 실행
}
}

private System.Collections.IEnumerator PreloadDefaultScene()
{
Debug.Log("Starting to preload DefaultGameScene...");
sceneLoadOperation = SceneManager.LoadSceneAsync("DefaultGameScene");
sceneLoadOperation.allowSceneActivation = false; // 씬 전환은 막아둠

while (!sceneLoadOperation.isDone)
{
// 진행도 출력
Debug.Log($"Scene Load Progress: {sceneLoadOperation.progress * 100}%");

// 진행도가 90% 이상이면 준비 완료 상태
if (sceneLoadOperation.progress >= 0.9f)
{
Debug.Log("Scene preload completed. Waiting for animation.");
break;
}
yield return null;
}
}

private void OnFadeComplete()
{
Debug.Log("Fade animation complete. Activating preloaded scene.");
if (sceneLoadOperation != null)
{
sceneLoadOperation.allowSceneActivation = true; // 씬 전환 허용
}
}

// 난이도 설정 및 씬 전환
private void SetDifficultyAndStartGame(int difficulty)
private void OnDestroy()
{
difficultyLevel = difficulty; // 난이도 설정
SceneManager.LoadScene("DefaultGameScene"); // 씬 전환
if (startingCameraController != null)
{
startingCameraController.OnFadeComplete -= OnFadeComplete; // 이벤트 연결 해제
}
}
}

0 comments on commit 5e8111a

Please sign in to comment.