Game 종료 및 BackEndMatch 서버로 결과 전송

플레이어의 체력이 0이 되거나, 기권을 하게 되어 게임의 승패가 갈릴 경우에는 게임이 끝나게 된다. 제일 먼저 공격을 받고 플레이어가 죽으면 CheckBossDie 코루틴이 동작한다. 여기서 다시 GameOver 코루틴이 동작하게 된다.

아래의 순서로 게임이 종료되는 것이 진행된다. 게임이 종료되게 되면 BackEnd에 데이터를 전송하고 게임이 종료 된다.

    public IEnumerator CheckBossDie()
    {
        yield return delay2;

        if (myBossEntity.isDie)
            StartCoroutine(GameManager.Inst.GameOver(false));
        if (otherBossEntity.isDie)
            StartCoroutine(GameManager.Inst.GameOver(true));
    }
    public IEnumerator GameOver(bool isMyWin)
    {
        TurnManger.Inst.isLoading =true;
        endTurnBtn.SetActive(false);
        yield return delay1;
        resultPanel.Show(isMyWin ? "승리!!" : "패배...");
        cameraEffect.SetGrayScale(true);
        BackEndMatch.EndMatch(isMyWin);
    }
    public static void EndMatch(bool isMine)
    {
        MatchGameResult nowGameResult = new MatchGameResult();
        nowGameResult.m_winners = new List<SessionId>();
        nowGameResult.m_losers = new List<SessionId>();
        if(isMine)
        {
            Debug.Log("win : " +myinfo.sessionId +"lose : " +otherinfo.sessionId);
            nowGameResult.m_winners.Add(myinfo.sessionId);
            nowGameResult.m_losers.Add(otherinfo.sessionId);
        }
        else
        {
            Debug.Log("win : " +otherinfo.sessionId +"lose : " +myinfo.sessionId);
            nowGameResult.m_winners.Add(otherinfo.sessionId);
            nowGameResult.m_losers.Add(myinfo.sessionId);
        }
        Backend.Match.MatchEnd(nowGameResult);
    }

게임이 종료되게 되면, 화면은 GrayScale로 바뀌게 되고, 결과 Panel이 뜨면서 메인화면으로 갈 수 있게 된다.

< 게임 결과 화면 >