public void onUserLeftRoom(RoomData eventObj, string username) { msgJson timeoutMsg = new msgJson(); timeoutMsg.msgSend = "Timeout"; string jsonToSend = JsonUtility.ToJson(timeoutMsg); WarpClient.GetInstance().sendMove(jsonToSend, ""); Debug.Log("onUserLeftRoom : " + username); }
public void OnMoveCompleted(MoveEvent _Move) { temp = JsonUtility.FromJson <msgJson>(_Move.getMoveData()); if (temp != null) { if (temp.msgSend == "OwnerReady" && !isOwner) { myTurn = true; if (SC_Multyplayer_Globals.Instance.numberOfShips == 0) { statusStartGame(); return; } } if (temp.msgSend == "Ready") { startGame(); return; } if (temp.msgSend == "shoot" && !myTurn) { string tempMsg; isHit = checkedForHit(temp.index); if (isHit) { SC_Multyplayer_Globals.Instance.mainBtnObjects["Main_Btn (" + temp.index + ")"].GetComponent <Image>().color = new Color(255, 0, 0, 255); tempMsg = "isHit"; SC_Multyplayer_Globals.Instance.PlayerShips--; if (SC_Multyplayer_Globals.Instance.PlayerShips == 0) { tempMsg = "EndGame"; } } else { SC_Multyplayer_Globals.Instance.mainBtnObjects["Main_Btn (" + temp.index + ")"].GetComponent <Image>().color = new Color(113, 113, 113, 255); tempMsg = "miss"; } SendPlayerMove(temp.index, tempMsg); } if (temp.msgSend == "isHit" && myTurn) { SC_Multyplayer_Globals.Instance.EnemyBtnObjects["Enemy_Btn (" + temp.index + ")"].GetComponent <Image>().color = new Color(255, 0, 0, 255); SendPlayerMove(temp.index, "switchTurn"); } if (temp.msgSend == "miss" && myTurn) { Debug.Log("miss"); SC_Multyplayer_Globals.Instance.EnemyBtnObjects["Enemy_Btn (" + temp.index + ")"].GetComponent <Image>().color = new Color(113, 113, 113, 255); SendPlayerMove(temp.index, "switchTurn"); } if (temp.msgSend == "EndGame") { SC_Multyplayer_Globals.Instance.MultiplayerObjects["Panel_EndGame"].SetActive(true); if (SC_Multyplayer_Globals.Instance.PlayerShips == 0) { SC_Multyplayer_Globals.Instance.MultiplayerObjects["Txt_EndGame"].GetComponent <Text>().text = "You Lose"; } else { SC_Multyplayer_Globals.Instance.MultiplayerObjects["Txt_EndGame"].GetComponent <Text>().text = "You Win !"; } WarpClient.GetInstance().stopGame(); } if (temp.msgSend == "Timeout") { SC_Multyplayer_Globals.Instance.MultiplayerObjects["Panel_EndGame"].SetActive(true); SC_Multyplayer_Globals.Instance.MultiplayerObjects["Txt_EndGame"].GetComponent <Text>().text = "Timeout"; } if (temp.msgSend == "switchTurn") { if (myTurn == true) { myTurn = false; SC_Multyplayer_Globals.Instance.MultiplayerObjects["logs"].GetComponent <Text>().text = "Rival Turn"; } else { myTurn = true; SC_Multyplayer_Globals.Instance.MultiplayerObjects["logs"].GetComponent <Text>().text = "Your Turn"; } } } else { SendPlayerMove(0, "Timeout"); } }