GameManager

GameManager는 게임의 시작과 끝을 관리하고, 치트키를 설정하여 게임을 좀 더 빠르게 테스트한다.

1.게임 시작

TurnManager에 있는 시작 코루틴을 불러와 게임을 시작

    public void StartGame()
    {
        StartCoroutine(TurnManger.Inst.StartGameCo());
    }

2.치트키

Update 문에서 1,2의 치트키를 확인

    void Update()
    {
#if UNITY_EDITOR  //유니티 에디터에서만 작동 (테스트용)
        InputCheatKey();
#endif    
    }
    void InputCheatKey()
    {
        if(Input.GetKeyDown(KeyCode.Keypad1))
        {
            TurnManger.OnAddCard?.Invoke(true);
        }
        if(Input.GetKeyDown(KeyCode.Keypad2))
        {
            TurnManger.Inst.EndTurn();
        }
    }

3.알림


< Attack >
따로 알림 오브젝트를 만들고 오브젝트 안에 텍스트를 넣었다.

using System.Numerics;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using DG.Tweening;

public class Notification : MonoBehaviour
{
    [SerializeField] TMP_Text notificationTMP;
    public void Show(string message)
    {
        notificationTMP.text=message;
        Sequence sequence = DOTween.Sequence() // DOTween을 사용하여 오브젝트에 시쿼스 애니메이션을 넣었다.
            .Append(transform.DOScale(UnityEngine.Vector3.one,0.3f).SetEase(Ease.InOutQuad))
            .AppendInterval(0.9f)
            .Append(transform.DOScale(UnityEngine.Vector3.zero,0.3f).SetEase(Ease.InOutQuad));
    }
    void Start() => ScaleZero();

    [ContextMenu("ScaleOne")]
    void ScaleOne() => transform.localScale = UnityEngine.Vector3.one;
    [ContextMenu("ScaleZero")]
    public void ScaleZero() => transform.localScale = UnityEngine.Vector3.zero;
}
    //GameManager.cs
    public void Notification(string message)
    {
        notification.Show(message);
    }

4.게임오버

게임이 종료 될 때 호출된다. 이 때 턴 종료 버튼은 누를 수 없다.

    public IEnumerator GameOver(bool isMyWin)
    {
        TurnManger.Inst.isLoading =true;
        endTurnBtn.SetActive(false);
        yield return delay1;
        resultPanel.Show(isMyWin ? "승리!!" : "패배...");
        cameraEffect.SetGrayScale(true);
        BackEndMatch.EndMatch(isMyWin); // BackEndMatch에서 게임 결과 전송 함수
    }