//홈 버튼 클릭 public void HomeButton() { stageUI.DeactivateUI(); gameOverUI.go_GameOverUI.SetActive(false); Destroy(StageManager.instance.currentStage.gameObject); StageManager.instance.go_Player.SetActive(false); StageManager.instance.currentStageSlot.transform.parent.parent.parent.gameObject.SetActive(true); }
//게임이 끝날 때 public void SetFinishUI() { //일반 스테이지라면 StageSlot currentStageSlot = StageManager.instance.currentStageSlot; StageManager.instance.go_Player.SetActive(false); if (currentStageSlot != null) { stageUI.DeactivateUI(); //starCount가 1개 이상이면 Stage Clear if (starCount > 0 && StageManager.instance.isGoal) { SoundManager.instance.PlaySFX("Game_Clear"); //만약 현재 stageSlot이 Open만 된 상태였다면 Clear로 변경 if (currentStageSlot.stageStatus == StageSlot.StageStatus.Open) { currentStageSlot.stageStatus = StageSlot.StageStatus.Clear; //현재 Stage를 Clear 했으니 다음 Stage를 Open 시켜준다. int stageIdx = currentStageSlot.stageNumber + 1; if (stageIdx != stageSlots.Length) { if (stageSlots[stageIdx] == null) { Debug.Log("다음 스테이지 슬롯이 비어있습니다. 스테이지를 추가해주세요."); } else { stageSlots[stageIdx].StageSlotOpen(); } } else { //보스 스테이지 슬롯 오픈 bossStageSlot.BossStageSlotOpen(); } } stageClearUI.S_ActiveClearUI(); } //클리어 못했을 시 else { SoundManager.instance.PlaySFX("Game_Over"); youDiedUI.S_ActiveYouDiedUI(); } } //보스 스테이지라면 else { bossStageUI.DeactivateUI(); if (StageManager.instance.currentBossStageSlot.currentHp <= 0) { if (StageManager.instance.currentBossStageSlot.bossStageType != BossStageSlot.BossStageType.BounceAttack) { if (StageManager.instance.panaltyPoint <= 0) { SoundManager.instance.PlaySFX("Game_Over"); youDiedUI.BS_ActiveYouDiedUI(); return; } if (StageManager.instance.panaltyPoint >= StageManager.instance.currentBossStageSlot.panaltyPoints[0] - StageManager.instance.currentBossStageSlot.panaltyPoints[1]) { starCount = 3; } else if (StageManager.instance.panaltyPoint > 0 && StageManager.instance.panaltyPoint < StageManager.instance.currentBossStageSlot.panaltyPoints[0] - StageManager.instance.currentBossStageSlot.panaltyPoints[1]) { starCount = 2; } else if (StageManager.instance.panaltyPoint > 0) { starCount = 1; } } else { starCount = 3; } SoundManager.instance.PlaySFX("Boss_Clear"); int total = 0; if (StageManager.instance.currentBossStageSlot.bossStageStatus == BossStageSlot.BossStageStatus.Open) { StageManager.instance.currentBossStageSlot.bossStageStatus = BossStageSlot.BossStageStatus.Clear; } if (bossStageSlot.bossStageStatus == BossStageSlot.BossStageStatus.Clear) { if (StageManager.instance.currentBossStageSlot.starCount < starCount) { StageManager.instance.currentBossStageSlot.starCount = starCount; } StageManager.instance.chaptersStarCount[StageManager.instance.currentChapter - 1] += bossStageSlot.starCount; } for (int i = 0; i < StageManager.instance.currentChapter; i++) { total += StageManager.instance.chaptersStarCount[i]; } if (StageManager.instance.currentChapter != 4 && total >= StageManager.instance.chaptersUnlockStarCount[StageManager.instance.currentChapter - 1]) { nextButton.interactable = true; } else { nextButton.interactable = false; } stageClearUI.BS_ActiveClearUI(); } else { SoundManager.instance.PlaySFX("Game_Over"); youDiedUI.BS_ActiveYouDiedUI(); } } }
//게임이 끝날 때 public void SetFinishUI() { //일반 스테이지라면 if (StageManager.instance.currentStageSlot != null) { //starCount가 1개 이상이면 Stage Clear if (starCount > 0 && StageManager.instance.isGoal) { gameOverUI.gameoverText.text = "STAGE CLEAR!"; gameOverUI.gameoverText.color = Color.blue; //만약 현재 stageSlot이 Open만 된 상태였다면 Clear로 변경 if (StageManager.instance.currentStageSlot.stageStatus == StageSlot.StageStatus.Open) { StageManager.instance.currentStageSlot.stageStatus = StageSlot.StageStatus.Clear; //현재 Stage를 Clear 했으니 다음 Stage를 Open 시켜준다. if (StageManager.instance.currentStageSlot.stageNumber + 1 != stageSlots.Length) { stageSlots[StageManager.instance.currentStageSlot.stageNumber + 1].StageSlotOpen(); } else { //보스 스테이지 슬롯 오픈 bossStageSlot.BossStageSlotOpen(); } } } else { gameOverUI.gameoverText.text = "GAME OVER"; gameOverUI.gameoverText.color = Color.red; } if (StageManager.instance.currentStageSlot.stageNumber + 1 != stageSlots.Length) { if (stageSlots[StageManager.instance.currentStageSlot.stageNumber + 1] != null) { if (stageSlots[StageManager.instance.currentStageSlot.stageNumber + 1].stageStatus != StageSlot.StageStatus.Rock) { nextButton.interactable = true; } else { nextButton.interactable = false; } } else { nextButton.interactable = false; } } else { if (bossStageSlot.bossStageStatus != BossStageSlot.BossStageStatus.Rock) { nextButton.interactable = true; } else { nextButton.interactable = false; } } gameOverUI.gameoverScoreText.text = StageManager.instance.score.ToString(); stageUI.DeactivateUI(); gameOverUI.go_StageGameoverUI.SetActive(true); } //보스 스테이지라면 else { if (StageManager.instance.currentBossStageSlot.currentHp <= 0) { if (StageManager.instance.currentBossStageSlot.challengeCount <= StageManager.instance.currentBossStageSlot.checkChallengeCount[0]) { for (int i = 0; i < 3; i++) { gameOverUI.bossStageStarImages[i].sprite = starSprite; } starCount = 3; } else if (StageManager.instance.currentBossStageSlot.challengeCount <= StageManager.instance.currentBossStageSlot.checkChallengeCount[1]) { for (int i = 0; i < 2; i++) { gameOverUI.bossStageStarImages[i].sprite = starSprite; } starCount = 2; } else { gameOverUI.bossStageStarImages[0].sprite = starSprite; starCount = 1; } gameOverUI.bossGameoverText.text = "BOSS CLEAR!"; gameOverUI.bossGameoverText.color = Color.blue; } else { gameOverUI.bossGameoverText.text = "GAME OVER"; gameOverUI.bossGameoverText.color = Color.red; } gameOverUI.SetGameoverUI(); bossStageUI.DeactivateUI(); } }