Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 35 additions & 10 deletions Assets/Scripts/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,74 @@ public class GameManager : MonoBehaviour, Subject
{
// 1. Singleton Pattern: Instance() method
private static GameManager _instance;
public static GameManager Instance()
{
return _instance;
}


// �ʱ�ȭ ���� �ٲ��� �� ��
// 초기화 설정 바꾸지 말 것
private int _gameRound = 0;
private string _whoseTurn = "Enemy";
private bool _isEnd = false;

// delegate: TurnHandler, FinishHandler ����
// delegate: TurnHandler, FinishHandler 선언
delegate void TurnUpdate(int round, string turn);
TurnUpdate _turnHandler;

delegate void FinishUpdate(bool isFinish);
FinishUpdate _finishHandler;

/// <summary>
/// 2. RoundNotify:
/// 1) ���� ���� Enemy�̸� ���� gameRound��
/// 1) 현재 턴이 Enemy이면 다음 gameRound로
/// + Debug.Log($"GameManager: Round {gameRound}.");
/// 2) TurnNotify() ȣ��
/// 2) TurnNotify() 호출
/// </summary>
public void RoundNotify()
{

_whoseTurn = "Enemy";
if(_whoseTurn == "Enemy")
{
_gameRound = _gameRound + 1;
Debug.Log($"GameManager: Round {_gameRound}.");
TurnNotify();
}

}

/// <summary>
/// 3. TurnNotify:
/// 1) whoseTurn update
/// + Debug.Log($"GameManager: {_whoseTurn} turn.");
/// 2) _turnHandler ȣ��
/// 2) _turnHandler 호출
/// </summary>
public void TurnNotify()
{

_whoseTurn= "Player";

Debug.Log($"GameManager: {_whoseTurn} turn.");

RoundNotify();
//_turnHandler(_gameRound, _whoseTurn);
}

/// <summary>
/// 4. EndNotify:
/// 1) isEnd update
/// + Debug.Log("GameManager: The End");
/// + Debug.Log($"GameManager: {_whoseTurn} is Win!");
/// 2) _finishHandler ȣ��
/// 2) _finishHandler 호출
/// </summary>
public void EndNotify()
{

_isEnd = true;
Debug.Log("GameManager: The End");
Debug.Log($"GameManager: {_whoseTurn} is Win!");
_finishHandler(_isEnd);
}

// 5. AddCharacter: _turnHandler, _finishHandler ������ �޼ҵ� �߰�
// 5. AddCharacter: _turnHandler, _finishHandler ������ �޼ҵ� �߰�
public void AddCharacter(Character character)
{

Expand Down