// GameLoop void Update() { if (isReachLimit) { return; } // 換AI出手 if (m_WhichOnePlay == WhichOne.Ai1) { int NextNumber = m_ComBoard1.GetNextNumber(); m_ComBoard1.SetNumber(NextNumber); m_ComBoard2.SetNumber(NextNumber); m_WhichOnePlay = WhichOne.Ai2; useGridTimer1++; } else { int NextNumber = m_ComBoard2.GetNextNumber(); m_ComBoard2.SetNumber(NextNumber); m_ComBoard1.SetNumber(NextNumber); m_WhichOnePlay = WhichOne.Ai1; useGridTimer2++; } // 顯示雙方賓果盤 // 計算雙方分數及顯示 int ComLine = m_ComBoard1.CountLine(); //m_ComLine1.text = string.Format ("目前連線數:{0}", ComLine); int ComLine2 = m_ComBoard2.CountLine(); // m_ComLine2.text = string.Format ("目前連線數:{0}", ComLine2); // 判斷勝利 if (ComLine2 >= 5 && ComLine < 5) { m_WhichOnePlay = WhichOne.GameOver; winTimer2++; isGameOver = true; } if (ComLine >= 5 && ComLine2 < 5) { m_WhichOnePlay = WhichOne.GameOver; winTimer1++; isGameOver = true; } if (ComLine2 >= 5 && ComLine >= 5) { m_WhichOnePlay = WhichOne.GameOver; tieTimer++; isGameOver = true; } // 顯示Board內容 ShowComBingoBoard(); ShowCom2BingoBoard(); m_ComLine2.text = "總共:" + (winTimer1 + winTimer2 + tieTimer) + "場" + " 平手:" + tieTimer + "場"; if (winTimer1 + winTimer2 + tieTimer > 9999) { isReachLimit = true; } else if (isGameOver) { m_ComBoard1.InitBoard(); m_ComBoard2.InitBoard(); ResetButton(); isGameOver = false; avg1 += useGridTimer1; avg2 += useGridTimer2; useGridTimer1 = 0; useGridTimer2 = 0; WhichOne m_WhichOnePlay = WhichOne.Ai1; m_ComLine1.text = "Ai1: " + winTimer1 + "場(" + string.Format("{0:0.000}", ((float)avg1 / (winTimer1 + winTimer2))) + ") versus " + "Ai2: " + winTimer2 + "場(" + string.Format("{0:0.000}", ((float)avg2 / (winTimer1 + winTimer2))) + ")"; } // DateTime time_start = DateTime.Now;//計時開始 取得目前時間 // DateTime time_end = DateTime.Now;//計時結束 取得目前時間 // //後面的時間減前面的時間後 轉型成TimeSpan即可印出時間差 // string result2 = ((TimeSpan)(time_end - time_start)).TotalMilliseconds.ToString(); // Debug.Log (result2); }