public void Event(byte[] _baBuffer, GameData.EnumGameCatchStructType _eStructType) { switch (_eStructType) { case GameData.EnumGameCatchStructType.RECEIVE_POPUP_TIME_START_PACKET: { Debug.Log("Receive Popup Time Start Packet"); //1// 서버에서 받은 패킷 deserializing - 모든 플레이어 준비 완료 시 "잠시 후 게임이 시작됩니다." -> 타이머 start GameData.ReceivePopupTimeStartPacket timeStart = new GameData.ReceivePopupTimeStartPacket(); timeStart = Serializer.ByteToStructure <GameData.ReceivePopupTimeStartPacket>(_baBuffer); //1// StopAllPopupTime(); m_goPopup.SetActive(true); StartTime(); } break; case GameData.EnumGameCatchStructType.RECEIVE_POPUP_TIME_END_PACKET: { Debug.Log("Receive Popup Time End Packet"); //1// 서버에서 받은 패킷 deserializing - "잠시 후 게임이 시작됩니다." -> 타이머 end GameData.ReceivePopupTimeEndPacket timeEnd = new GameData.ReceivePopupTimeEndPacket(); timeEnd = Serializer.ByteToStructure <GameData.ReceivePopupTimeEndPacket>(_baBuffer); //1// // "잠시 후 게임이 시작됩니다." -> 팝업 내리고 게임 시작 EndTime(); ChoiceAnswer(); } break; case GameData.EnumGameCatchStructType.RECEIVE_EXAMINER_ANSWERS_PACKET: { Debug.Log("Receive Examiner Answer Packet"); //1// 서버에서 받은 패킷 deserializing - 출제자에게 5개의 정답 선택지 제공 GameData.ReceiveExaminerAnswersPacket examinerAnswers = new GameData.ReceiveExaminerAnswersPacket(); examinerAnswers = Serializer.ByteToStructure <GameData.ReceiveExaminerAnswersPacket>(_baBuffer); //1// //2// 문자열은 UTF8로 따로 인코딩 m_textAnswer1.text = Serializer.EncodingByteArrayToString(_baBuffer, GameData.iStringStartIdx, GameData.iStringAnswerSize); m_textAnswer2.text = Serializer.EncodingByteArrayToString(_baBuffer, GameData.iStringStartIdx + GameData.iStringAnswerSize, GameData.iStringAnswerSize); m_textAnswer3.text = Serializer.EncodingByteArrayToString(_baBuffer, GameData.iStringStartIdx + (GameData.iStringAnswerSize * 2), GameData.iStringAnswerSize); m_textAnswer4.text = Serializer.EncodingByteArrayToString(_baBuffer, GameData.iStringStartIdx + (GameData.iStringAnswerSize * 3), GameData.iStringAnswerSize); m_textAnswer5.text = Serializer.EncodingByteArrayToString(_baBuffer, GameData.iStringStartIdx + (GameData.iStringAnswerSize * 4), GameData.iStringAnswerSize); //2// m_strAnswer = m_textAnswer1.text; } break; case GameData.EnumGameCatchStructType.RECEIVE_SELECT_END_PACKET: { Debug.Log("Receive Select End Packet"); //1// 서버에서 받은 패킷 deserializing - 출제자 선택 완료 신호 GameData.ReceiveSelectCompletePacket examinerAnswer = new GameData.ReceiveSelectCompletePacket(); examinerAnswer = Serializer.ByteToStructure <GameData.ReceiveSelectCompletePacket>(_baBuffer); //1// RoundStart(); } break; case GameData.EnumGameCatchStructType.RECEIVE_INGAME_TIME_PACKET: { Debug.Log("Receive Ingame Time Packet"); //1// 서버에서 받은 패킷 deserializing - 인게임 타이머 GameData.ReceiveIngameTimePacket ingameTime = new GameData.ReceiveIngameTimePacket(); ingameTime = Serializer.ByteToStructure <GameData.ReceiveIngameTimePacket>(_baBuffer); //1// m_iIngameLimitTime = ingameTime.iIngameTime; if (_baBuffer.Length > GameData.iReceiveIngameTimePacketStructSize) { byte[] baNewArray = ResizeArray(_baBuffer, GameData.iReceiveIngameTimePacketStructSize); IngameManager.m_Instance.Event(baNewArray); } } break; case GameData.EnumGameCatchStructType.RECEIVE_POINT_PACKET: { Debug.Log("Receive Point Packet"); //1// 서버에서 받은 패킷 deserializing - 출제자가 그린 점 정보 GameData.ReceivePointPacket point = new GameData.ReceivePointPacket(); point = Serializer.ByteToStructure <GameData.ReceivePointPacket>(_baBuffer); //1// Vector2 vPoint; vPoint.x = point.fX; vPoint.y = point.fY; DrawLine(point.iLineIdx, vPoint, point.iColor); ++m_iRecvPointCount; // 임시 if (_baBuffer.Length > GameData.iReceivePointPacketStructSize) { byte[] baNewArray = ResizeArray(_baBuffer, GameData.iReceivePointPacketStructSize); IngameManager.m_Instance.Event(baNewArray); } } break; case GameData.EnumGameCatchStructType.RECEIVE_CHAT_PACKET: { Debug.Log("Receive Chat Packet"); //1// 서버에서 받은 패킷 deserializing - 채팅 GameData.ReceiveChatPacket chat = new GameData.ReceiveChatPacket(); chat = Serializer.ByteToStructure <GameData.ReceiveChatPacket>(_baBuffer); //1// Chat(chat.strChat, chat.iPlayerIdx, chat.iAnswer); } break; default: break; } }
public void Event(byte[] _baBuffer) { Debug.Log("IngameMGR Event :: " + _baBuffer); //1// 첫 1바이트를 이용해 game type 판별 int iGameTypeStartIdx = 0; //GameData.EnumGameType eGameType = (GameData.EnumGameType)CheckPacketType(_baBuffer, iGameTypeStartIdx); GameData.EnumGameType eGameType = (GameData.EnumGameType)_baBuffer[iGameTypeStartIdx]; //1// //2// 다음 1바이트를 이용해 struct type 판별 int iStructTypeStartIdx = 1; GameData.EnumGameTwentyStructType eGameTwentyStructType = new GameData.EnumGameTwentyStructType(); GameData.EnumGameRelayStructType eGameRelayStructType = new GameData.EnumGameRelayStructType(); GameData.EnumGameBanStructType eGameBanStructType = new GameData.EnumGameBanStructType(); GameData.EnumGameCatchStructType eGameCatchStructType = new GameData.EnumGameCatchStructType(); switch (eGameType) { case GameData.EnumGameType.TWENTY: //eGameTwentyStructType = (GameData.EnumGameTwentyStructType)CheckPacketType(_baBuffer, iStructTypeStartIdx); eGameTwentyStructType = (GameData.EnumGameTwentyStructType)_baBuffer[iStructTypeStartIdx]; break; case GameData.EnumGameType.RELAY: //eGameRelayStructType = (GameData.EnumGameRelayStructType)CheckPacketType(_baBuffer, iStructTypeStartIdx); eGameRelayStructType = (GameData.EnumGameRelayStructType)_baBuffer[iStructTypeStartIdx]; break; case GameData.EnumGameType.BAN: //eGameBanStructType = (GameData.EnumGameBanStructType)CheckPacketType(_baBuffer, iStructTypeStartIdx); eGameBanStructType = (GameData.EnumGameBanStructType)_baBuffer[iStructTypeStartIdx]; break; case GameData.EnumGameType.CATCH: //eGameCatchStructType = (GameData.EnumGameCatchStructType)CheckPacketType(_baBuffer, iStructTypeStartIdx); eGameCatchStructType = (GameData.EnumGameCatchStructType)_baBuffer[iStructTypeStartIdx]; break; default: break; } //2// switch (eGameType) { case GameData.EnumGameType.TWENTY: { switch (eGameTwentyStructType) { case GameData.EnumGameTwentyStructType.RECEIVE_PLAYER_POSITION_PACKET: Debug.Log("Receive Game Twenty Player Position Packet"); LoadGameTwenty(_baBuffer); break; case GameData.EnumGameTwentyStructType.RECEIVE_POPUP_TIME_START_PACKET: case GameData.EnumGameTwentyStructType.RECEIVE_POPUP_TIME_END_PACKET: case GameData.EnumGameTwentyStructType.RECEIVE_EXAMINER_ANSWERS_PACKET: case GameData.EnumGameTwentyStructType.RECEIVE_SELECT_END_PACKET: case GameData.EnumGameTwentyStructType.RECEIVE_INGAME_TIME_PACKET: case GameData.EnumGameTwentyStructType.RECEIVE_QUESTION_PACKET: case GameData.EnumGameTwentyStructType.RECEIVE_YES_OR_NO_PACKET: case GameData.EnumGameTwentyStructType.RECEIVE_CHECK_ANSWER_PACKET: case GameData.EnumGameTwentyStructType.RECEIVE_NEXT_CHALLENGER_PACKET: case GameData.EnumGameTwentyStructType.RECEIVE_ROUND_END_PACKET: case GameData.EnumGameTwentyStructType.RECEIVE_SOCRE_PACKET: case GameData.EnumGameTwentyStructType.RECEIVE_ANSWER_POPUP_ANSWER_PACKET: case GameData.EnumGameTwentyStructType.RECEIVE_ANSWER_POPUP_TIME_START_PACKET: case GameData.EnumGameTwentyStructType.RECEIVE_GAME_END_PACKET: case GameData.EnumGameTwentyStructType.RECEIVE_EXAMINER_EXIT_PACKET: case GameData.EnumGameTwentyStructType.RECEIVE_NON_EXAMINER_EXIT_PACKET: case GameData.EnumGameTwentyStructType.RECEIVE_EXIT_PACKET: case GameData.EnumGameTwentyStructType.RECEIVE_RESERVE_EXIT_OR_CANCEL_NICKNAME_PACEKT: case GameData.EnumGameTwentyStructType.RECEIVE_QUESTION_COUNT_PACKET: m_miniGameTwenty.Event(_baBuffer, eGameTwentyStructType); break; default: break; } } break; case GameData.EnumGameType.RELAY: { switch (eGameRelayStructType) { default: break; } } break; case GameData.EnumGameType.BAN: { switch (eGameBanStructType) { default: break; } } break; case GameData.EnumGameType.CATCH: { switch (eGameCatchStructType) { case GameData.EnumGameCatchStructType.RECEIVE_PLAYER_POSITION_PACKET: Debug.Log("Receive Game Catch Player Position Packet"); LoadGameCatch(_baBuffer); break; case GameData.EnumGameCatchStructType.RECEIVE_POPUP_TIME_START_PACKET: case GameData.EnumGameCatchStructType.RECEIVE_POPUP_TIME_END_PACKET: case GameData.EnumGameCatchStructType.RECEIVE_EXAMINER_ANSWERS_PACKET: case GameData.EnumGameCatchStructType.RECEIVE_SELECT_END_PACKET: case GameData.EnumGameCatchStructType.RECEIVE_INGAME_TIME_PACKET: case GameData.EnumGameCatchStructType.RECEIVE_POINT_PACKET: case GameData.EnumGameCatchStructType.RECEIVE_CHAT_PACKET: m_miniGameCatch.Event(_baBuffer, eGameCatchStructType); break; default: break; } } break; default: break; } }