private IEnumerator GetRoomData() { while (true) { ReadyRequestGuestInfo op_data; op_data = new ReadyRequestGuestInfo(isHost); string sendDataJson = UnityEngine.JsonUtility.ToJson(op_data); UnityWebRequest request = UnityWebRequest.Put(Constants.ServerAdress, sendDataJson); request.method = UnityWebRequest.kHttpVerbPOST; yield return(request.SendWebRequest()); if (request.responseCode == 200) { string text = request.downloadHandler.text; User2IdData data; data = UnityEngine.JsonUtility.FromJson <User2IdData>(text); if (data.status == "Started") { Constants.SetRandSeed(data.seed); btn.GetComponent <ReadyPanelStartGameScript>().GuestStartGame(); Constants.Enemy_id = data.user_id; Constants.IsYourTurn = false; break; } } yield return(new WaitForSeconds(1.0f)); Constants.SetGameInfo("还没人进来吗?"); } }
private IEnumerator GetGuest() { while (true) { ReadyRequestGuestInfo op_data; op_data = new ReadyRequestGuestInfo(playerData.Instance.user_id); string sendDataJson = UnityEngine.JsonUtility.ToJson(op_data); UnityWebRequest request = UnityWebRequest.Put(Constants.ServerAdress, sendDataJson); request.method = UnityWebRequest.kHttpVerbPOST; yield return(request.SendWebRequest()); if (request.responseCode == 200) { string text = request.downloadHandler.text; User2IdData data; data = UnityEngine.JsonUtility.FromJson <User2IdData>(text); if (data.user2_id != "") { Constants.Enemy_id = data.user2_id; guestName.gameObject.GetComponent <Text>().text = data.user2_id; break; } } yield return(new WaitForSeconds(2.0f)); /*Debug.Log("some one come into my room?");*/ Constants.SetGameInfo("还没人进来吗?"); } }