-
Notifications
You must be signed in to change notification settings - Fork 2
develop GameOver
Jeon-YJ1004 edited this page Feb 27, 2023
·
5 revisions
- 캐릭터의 체력이 0보다 작거나 같으면 GameOver가 된다. [Character.cs]
[Character.cs]
public void TakeDamage(float damage)
{
if (isDead == true) return;
currentHp -= damage;
if (currentHp <= 0)//현재 체력으로 Gameover
{
GameManager.instance.GameOverPanelUp();
isDead = true;
}
HpBar.SetState(currentHp, maxHp);
}
[GameManager.cs]
public void GameOverPanelUp()
{
Debug.Log("Game over");
player.enabled = false; // Character object 비활성화
gameoverPanel.SetActive(true); // 판넬 활성화
}
2.1 scene에 판넬 생성
2.2 판넬에 text와 button 생성, button에 text 생성