//public GetSurroundingRes SurroundingRes; // private void OnGUI() { // GUI.Label(new Rect(5, Screen.height - 60, 1000, 20), msg); //} IEnumerator Start() { print("111"); msg = "1111"; // First, check if user has location service enabled if (!Input.location.isEnabledByUser) { yield break; } print("222"); msg = "2222"; // Start service before querying location Input.location.Start(); // Wait until service initializes int maxWait = 20; while (Input.location.status == LocationServiceStatus.Initializing && maxWait > 0) { yield return(new WaitForSeconds(1)); maxWait--; } // Service didn't initialize in 20 seconds if (maxWait < 1) { msg = "Timed out"; yield break; } print("333"); // Connection has failed if (Input.location.status == LocationServiceStatus.Failed) { msg = "Unable to determine device location"; yield break; } else { // Access granted and location value could be retrieved msg = "Location: " + Input.location.lastData.latitude + " " + Input.location.lastData.longitude + " " + Input.location.lastData.altitude + " " + Input.location.lastData.horizontalAccuracy + " " + Input.location.lastData.timestamp; //StartCoroutine(SurroundingRes.Get("https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=+" + Input.location.lastData.latitude + "," + Input.location.lastData.longitude + "&radius=500&type=restaurant&key=AIzaSyDiC9HjxWI0dBa9x5hYL9xOmOnWJcFE-zU")); } // Stop service if there is no need to query location updates continuously Input.location.Stop(); LogUI.Show(msg, 60); print("Msg: " + msg); }
//=======呼叫進入/創立房間介面========== // 雖然共用,但創房 和 進房 還是需要分別 (color) public void buttonCer(bool isCreate) { if (UIRoomManager.roomWaitForServer) // 正在等待伺服器回傳房間狀態 { LogUI.Show("正在等待伺服器回應..."); } else { CreateOrJoinRoom = isCreate; ShowCreateOrJoinRoomUI(); } Sounds.PlayButton(); }
public void GoButton() { if (playersInRoom.Count > 0) // 已經進入等待室,不能再按這個按鈕 (實際在UI時,這情況不會發生) { LogUI.Show("已經在等待室"); return; } myInfos.ready = false; curStage = 2; client.SendPlayerInfos(myInfos); // 傳送自己的 Infos 給 伺服器,伺服器將回傳在房裡的人和自己的ID //if (myInfos.foodSelected != DataClient.preRes && GetRes.getLocSucceed) { // new DataClient().ConnectToServer(Generic.gData.DataServerIP, Generic.gData.DataServerPort); //} }
public void NickNameButton(Text inputField) { string name = inputField.text; myInfos.nickName = name; PlayerPrefs.SetString(nickNameSaveStr, name); if (name == "") { LogUI.Show("請輸入暱稱"); } else { CheckAllSet(); } }
void Init() { if (instance != null) { Destroy(gameObject); return; } instance = this; logDialog.SetActive(false); popup.SetActive(false); onPopup = false; onDialog = false; Application.logMessageReceived += HandleLog; DontDestroyOnLoad(gameObject); }
/// <summary> /// 如果尚未連線則嘗試連線,若連線失敗返回 false /// </summary> public void ConnectToServer() { if (client == null) { myInfos.roomName = ""; client = new TcpClient(); client.OnJoinedRoom = JoinRoomCallback; client.OnPlayerListChanged = ListChangedCallback; client.OnStartGame = StartGameCallback; client.OnMyInfoChanged = MyInfoChanged; client.OnConnectFailed = () => { LogUI.Show("伺服器未開啟"); roomWaitForServer = false; }; } if (client.connectStatus != ClientActions.ConnectStatus.Connecting) { client.ConnectToServer(Generic.gData.ServerIP, Generic.gData.ServerPort); } }
public void JoinRoom(string name) { tmpRoomName = name; ConnectToServer(); if (tmpRoomName == "") { LogUI.Show("請輸入房名"); } else if (tmpRoomName != myInfos.roomName) // 一樣的房名不再加入 { if (client.connectStatus == ClientActions.ConnectStatus.Connected) { client.JoinRoom(tmpRoomName); } else if (client.connectStatus == ClientActions.ConnectStatus.Connecting) { client.OnConnectedToServer = () => { client.JoinRoom(tmpRoomName); }; } roomWaitForServer = true; } }
public void StartGameButton() { Sounds.PlayButton(); if (tmpRoomName == "") { return; } bool canGO = true; if (myInfos.ready) // 如果自己 Ready 了再檢查別人 { for (int i = 0; i < playersInRoom.Count; i++) { // 有一個人沒有 Ready,不給進入遊戲 if (!playersInRoom[i].ready) { canGO = false; break; } } } else { canGO = false; } if (canGO) { client.SendGameReady(); } else { LogUI.Show("等待所有玩家都 Ready 才可以 GO"); } }
void ShowResDetailInfo(Details d) { if (d == null) { LogUI.Show("無法取得這間餐廳的資料"); return; } string closed = ""; System.Text.StringBuilder str = new System.Text.StringBuilder(); FoodLis.resInfoText[0].text = d.name; FoodLis.resInfoText[1].text = d.phoneNum; FoodLis.resInfoText[2].text = d.address; if (d.openingHours == null) { str = new System.Text.StringBuilder("無資料 _(´ཀ`」 ∠)_"); } else { foreach (string s in d.openingHours) { str.AppendLine(s); } } if (str.ToString().Length <= 1) { FoodLis.resInfoText[3].text = "無資料 _(´ཀ`」 ∠)_"; } else { FoodLis.resInfoText[3].text = str.ToString(); } FoodLis.resInfoText[4].text = "評價:" + d.rating.ToString() + "/5"; if (d.permanentlyClosed) { closed = "已歇業"; } else if (!d.permanentlyClosed) { closed = ""; } FoodLis.resInfoText[5].text = closed; str = new System.Text.StringBuilder(); foreach (Reviews s in d.reviews) { str.AppendLine("評價者: " + s.name); str.AppendLine("評價分數: " + s.rating); str.AppendLine("留言: " + s.text); str.AppendLine("留言時間: " + s.time.ToString("yyyy-MM-dd HH:mm:ss \n\n\n")); } FoodLis.resInfoText[6].text = str.ToString(); if (d.openNow == 0) { FoodLis.resInfoText[7].text = "營業中"; } else if (d.openNow == 1) { FoodLis.resInfoText[7].text = "已打烊/休息中"; } else { FoodLis.resInfoText[7].text = "無營業時段資訊"; } }
void JoinRoomCallback(TcpClient.RoomStatus status) { if (status == NetworkBehaviour.RoomStatus.Created) // 成功創建房間 (CreateRoom) //Debug.Log("創建成功"); { if (curStage > 1) { return; // 只能是階段 1 } Ticker.StartTicker(0, () => { ButtonManager.ins.EnterOrCreateRoomOK(true); }); myInfos.roomName = tmpRoomName; Ticker.StartTicker(0, () => { CheckAllSet(); }); } else if (status == NetworkBehaviour.RoomStatus.RoomExists) // 房間已存在 (CreateRoom) { if (curStage > 1) { return; // 只能是階段 1 } LogUI.Show("房間已存在,請重新輸入"); } else if (status == NetworkBehaviour.RoomStatus.Joined) // 成功加入房間 (JoinRoom) //Debug.Log("加入成功"); { if (curStage > 1) { return; // 只能是階段 1 } Ticker.StartTicker(0, () => { ButtonManager.ins.EnterOrCreateRoomOK(false); }); myInfos.roomName = tmpRoomName; Ticker.StartTicker(0, () => { CheckAllSet(); }); } else if (status == NetworkBehaviour.RoomStatus.RoomNotExists) // 房間不存在 (JoinRoom) { if (curStage > 1) { return; // 只能是階段 1 } LogUI.Show("房間不存在,請重新輸入"); } else if (status == NetworkBehaviour.RoomStatus.RoomFulled) { if (curStage > 1) { return; // 只能是階段 1 } LogUI.Show("這個房間已滿"); } else if (status == NetworkBehaviour.RoomStatus.Others) { if (curStage == 4) { return; // 開始遊戲後不再接收這個指令 } LogUI.Show("這個房間已經開始遊戲"); Ticker.StartTicker(0, LeaveRoom); } //else { // 未知錯誤 // LogUI.Show("錯誤"); //} roomWaitForServer = false; }
void OnGetLocationFailed(string errorMsg) { LogUI.Show(errorMsg); }
void Awake() { Instance = this; txt = GetComponentInChildren <Text>(); }
public void SetDialog(LogUI dialog) { this.dialog = dialog; }