//-- host 정보가 세팅 되었는지 확인하고 되었다면 접속 알림 void Update() { if (Input.GetKeyUp(KeyCode.Space)) { string t = "userName : "******" index " + GameManager.Instance().PLAYER.NETWORK_INDEX + " aasset " + GameManager.Instance().PLAYER.SKELETON_DATA_ASSET; PopupManager.Instance().MessagePopupOK("Check", t); } if (!string.IsNullOrEmpty(NetworkOrderController.ORDER_NAME) && !m_hostCheck) { //접속 되었음 ! m_hostCheck = true; NetworkManager.Instance().SendOrderMessage(JSONMessageTool.ToJsonOrderUserEnter( GameManager.Instance().PLAYER.NETWORK_INDEX, GameManager.Instance().PLAYER.STATUS, GameManager.Instance().PLAYER.USER_NAME, GameManager.Instance().PLAYER.SKELETON_DATA_ASSET, false)); } }
// 다른 사람 정보 void NetworkManager.NetworkMessageEventListenrer.ReceiveNetworkMessage( NetworkManager.MessageEvent e) { //연결된게 아닌 경우 / if (e.msgType != NetworkManager.USER_CONNECT) { // 다른사람이 내게 요청을 했다. 나의 정보를 if (e.msgType == NetworkManager.USER_INFO_REQ) { NetworkManager.Instance().SendOrderMessage( JSONMessageTool.ToJsonOrderUserEnter( GameManager.Instance().PLAYER.NETWORK_INDEX, GameManager.Instance().PLAYER.STATUS, GameManager.Instance().PLAYER.USER_NAME, GameManager.Instance().PLAYER.SKELETON_DATA_ASSET, m_readyButton.sprite.name == m_sprReady_setting.name)); } //유저가 나갔다 else if (e.msgType == NetworkManager.USER_LOGOUT) { // 로그아웃 GameObject user = m_playerList[(int)e.msg .GetField(NetworkManager.USER_LOGOUT) .GetField(NetworkManager.USER_LOGOUT).i - 2]; if (GetProfileWait(user) != null) { GetProfileWait(user).enabled = true; } GetProfileHide(user).enabled = true; GetProfileName(user).enabled = false; GetProfileImage(user).color = Color.black; SetPlayerStatus(user, 0, 0); SetPlayerStatus(user, 1, 0); SetPlayerStatus(user, 2, 0); // 레디 정보를 받아와야함 if (e.msg.GetField(NetworkManager.USER_LOGOUT) .GetField(NetworkManager.READY_STATE).b) { m_readyCount--; GetRush(m_playerList[(int)e.orders.GetField(NetworkManager.MSG) .GetField(NetworkManager.USER_LOGOUT) .GetField(NetworkManager.USER_INDEX).i - 2]).SetActive(false); } if (m_readyCount >= 3) { m_startButton.sprite = m_sprStart_setting; } else { m_startButton.sprite = m_sprStart_normal; } } else if (e.msgType == NetworkManager.USER_READY) { //레디 bool b = e.msg.GetField(NetworkManager.USER_READY) .GetField(NetworkManager.USER_READY).b; if (b) { GetRushName( m_playerList[(int)e.msg .GetField(NetworkManager.USER_READY) .GetField(NetworkManager.USER_INDEX).i - 2]) .text = e.targetName; GetRush(m_playerList[(int)e.msg .GetField(NetworkManager.USER_READY) .GetField(NetworkManager.USER_INDEX).i - 2]).SetActive(true); m_readyCount++; SoundManager.Instance().PlaySound(m_ready); } else { GetRush(m_playerList[(int)e.msg .GetField(NetworkManager.USER_READY).GetField(NetworkManager.USER_INDEX).i - 2]) .SetActive(false); m_readyCount--; } if (m_readyCount >= 3) { m_startButton.sprite = m_sprStart_setting; } else { m_startButton.sprite = m_sprStart_normal; } } else if (e.msgType == NetworkManager.GAME_START) { SoundManager.Instance().PlaySound(m_gameStart); // 여기서 게임 시작 처리 List <string> users = new List <string>(); for (int i = 0; i < m_playerList.Count; i++) { MDebug.Log(" " + i + " " + GetProfileName(m_playerList[i]).text); if (string.IsNullOrEmpty(GetProfileName(m_playerList[i]).text)) { continue; } users.Add(GetProfileName(m_playerList[i]).text); } GameManager.Instance().HudSetup(users); //NetworkManager.Instance().GameStartSetup(m_playerAssetList); NetworkManager.Instance().RemoveNetworkOrderMessageEventListener(this); PopupManager.Instance().ClosePopup(gameObject); } return; } //########################################################################################## //#### 다른 유저의 정보가 넘어왔으니 세팅 ################################################## int index = (int)e.msg .GetField(NetworkManager.USER_CONNECT).GetField(NetworkManager.USER_CONNECT).i; bool check = false; foreach (Test t in m_playerAssetList) { if (index == 1) { check = true; break; } if (t.networkIndex == index) { check = true; break; } } if (!check) { m_playerAssetList.Add(new Test(e.msg.GetField(NetworkManager.USER_CONNECT) .GetField(NetworkManager.USER_SKELETON_DATA_ASSET).str, e.orders.GetField(NetworkManager.MSG) .GetField(NetworkManager.USER_CONNECT).GetField(NetworkManager.CLIENT_ID).str, index)); } // 나자신을 세팅할 필요는 없음 if (index == GameManager.Instance().PLAYER.NETWORK_INDEX) { return; } if (index - 2 < 0) { return; } if (index - 2 == 0 && NetworkOrderController.OBSERVER_MODE) { GameManager.Instance().PLAYER.SKELETON_DATA_ASSET = e.msg.GetField(NetworkManager.USER_CONNECT) .GetField(NetworkManager.USER_SKELETON_DATA_ASSET).str; } GameObject player = m_playerList[index - 2]; if (player == null) { return; } // 이미 세팅되어있다면 패스 if (GetProfileName(player).text == e.msg .GetField(NetworkManager.USER_CONNECT).GetField(NetworkManager.CLIENT_ID).str) { return; } else { // 정보를 던져줘야함 NetworkManager.Instance().SendOrderMessage(JSONMessageTool.ToJsonOrderUserEnter( GameManager.Instance().PLAYER.NETWORK_INDEX, GameManager.Instance().PLAYER.STATUS, GameManager.Instance().PLAYER.USER_NAME, GameManager.Instance().PLAYER.SKELETON_DATA_ASSET, false)); } if (GetProfileWait(player) != null) { GetProfileWait(player).enabled = false; } GetProfileHide(player).enabled = false; GetProfileName(player).enabled = true; GetProfileImage(player).color = Color.white; GetProfileName(player).text = e.orders.GetField(NetworkManager.MSG) .GetField(NetworkManager.USER_CONNECT).GetField(NetworkManager.CLIENT_ID).str; SetPlayerStatus(player, 0, (int)e.msg.GetField(NetworkManager.USER_CONNECT).GetField(NetworkManager.STATUS_SPEED).i); SetPlayerStatus(player, 1, (int)e.msg.GetField(NetworkManager.USER_CONNECT).GetField(NetworkManager.STATUS_POWER).i); SetPlayerStatus(player, 2, (int)e.msg.GetField(NetworkManager.USER_CONNECT).GetField(NetworkManager.STATUS_REPAIR).i); try { GetRush(player).SetActive(e.orders.GetField(NetworkManager.MSG).GetField(NetworkManager.USER_CONNECT).GetField(NetworkManager.READY_STATE).b); GetRushName(player).text = e.orders.GetField(NetworkManager.MSG).GetField(NetworkManager.USER_CONNECT).GetField(NetworkManager.CLIENT_ID).str; }catch (Exception) { } }