// HQ가 파괴되었다는 패킷 수신 함수 public void OnReceiveGameFinishPacket(PacketId id, byte[] data) { GameFinishPacket packet = new GameFinishPacket(data); GameFinishData winnerData = packet.GetPacket(); HTTPManager httpManager = new HTTPManager(); UserInfo userInfo = GameObject.Find("DataObject").GetComponent <UserInfo>(); bool win = userInfo.userData.playerCamp == winnerData.winnerCamp; httpManager.UpdateUserWinReq(userInfo.userData.id, win); UIManager.instance.ActivateGameEnd(win); // 서버에 보낼 게임 정보 업데이트 userInfo.userPlayData.achievescore = 0; userInfo.userPlayData.victory = 0; userInfo.userPlayData.lose = 0; userInfo.userPlayData.death = 1; userInfo.userPlayData.imageid = 0; userInfo.userPlayData.kill = killCount; userInfo.userPlayData.damage = (int)damageCount; // Flask 서버에 업적 업데이트 및 점수 업데이트. httpManager.UpdateAchieveReq(userInfo.userData.id, userInfo.userPlayData); // n 초 뒤에 로비씬으로 이동. StartCoroutine(GoBackToLobby()); }
protected override void Update() { if (status.CHP <= 0) { GameFinishData data = new GameFinishData(); if (CampNum == 1) { Debug.Log("1P의 패배!"); data.winnerCamp = 2; // 참고 : if GetComponent<UserInfo>().userData.playerCamp == 1 then is1p = true. } else { Debug.Log("2P의 패배!"); data.winnerCamp = 1; } GameFinishPacket packet = new GameFinishPacket(data); GameObject.Find("NetworkManager").GetComponent <NetworkManager>().SendReliable <GameFinishData>(packet); Destroy(gameObject); } }