//void MoveSwitch(bool dontMove) { // if (stop) return; // if (dontMove) { // Release(); // enabled = false; // } else { // enabled = true; // } //} IEnumerator StartTicker() { for (int i = Generic.gData.startSec; i > 0; i--) // 教學動畫倒數 { yield return(new WaitForSeconds(1f)); } ArrangeHex(); for (int i = Generic.gData.overSec; i >= 0; i--) // 遊戲時間倒數 { tickerText.text = /*"剩餘時間: " +*/ i.ToString(); yield return(new WaitForSeconds(1f)); } #region ================== 時間到後的工作 ================== enabled = false; // 不能再消六角 //stop = true; for (int i = 0; i < hexList.Count; i++) // 消除正在連的 { Release(i); } //print("GameOver"); Dictionary <int, int> d = new Dictionary <int, int>(); foreach (GameObject g in squares) // 計算各顏色剩餘數量 { int n; int ii = g.GetComponent <Square>().colorIndex; if (d.TryGetValue(ii, out n)) { d[ii] = n + 1; } else { d.Add(ii, 1); } } UIRoomManager.client.SendGameResult(d); // 傳送本地端統計結果給伺服器 int colorIndex = 0, max = int.MinValue; // 計算本地端獲勝者 foreach (KeyValuePair <int, int> w in d) { if (w.Value > max) { colorIndex = w.Key; max = w.Value; } } //Debug.Log("本地端獲勝者: " + colorIndex + " - " + UIRoomManager.GetResNameFromColor(colorIndex)); UIGameManager.ins.GameResultUI(); UIGameManager.ins.SetLocalWinner(UIRoomManager.GetResNameFromColor(colorIndex), colorIndex); #endregion ======================================================== }
void RECGameResult(Socket inSocket, string[] inParams) { if (UIRoomManager.curStage != 4) { return; // 只有階段 4 可接收 } string res = null; int colorIndex = 0; try { colorIndex = int.Parse(inParams[0]); } catch { return; } res = UIRoomManager.GetResNameFromColor(colorIndex); if (res == null) { return; } Ticker.StartTicker(0, () => { UIGameManager.ins.SetGlobalWinner(res, colorIndex); }); ClientLeave(mySocket); //UnityEngine.Debug.Log("統計結果: " + colorIndex + " - " + res); }