void Update() { if (isServer) { } if (isLocalPlayer) { txtSysMsg.text = SysMsg; txtTipMsg.text = TipMsg; if (IsGameStart) { for (int i = 0; i < HaveCards.Count; i++) { Mycard.Add(HaveCards.GetItem(i).UID); } Mycard.Sort(); //更新UI Update_UI(); IsGameStart = false; } if (LeadOver) { //更新UI Update_UI(); LeadOver = false; } } }
void Update() { switch (process) { case Process.waitLogin: foreach (Player pl in allPlayer) { pl.SysMsg = "等待玩家連線...目前人數:" + allPlayer.Count; } break; case Process.shuffle: foreach (Player pl in allPlayer) { pl.SysMsg = "遊戲開始 開始發牌"; } // 重製卡牌 for (int i = 0; i < NUMBER_OF_CARDS; i++) { Cards[i] = i; } // 進行洗牌 for (int i = 0; i < NUMBER_OF_CARDS; i++) { int swap_index = UnityEngine.Random.Range(0, 51); int t = Cards[i]; Cards[i] = Cards[swap_index]; Cards[swap_index] = t; } // 建立牌庫 for (int i = 0; i < NUMBER_OF_CARDS; i++) { CardStruct card = new CardStruct(); card.UID = Cards[i]; CardList.Add(card); } //建立牌庫並發牌 for (int i = 0; i < 13; i++) { allPlayer[0].Server_AddCard(CardList.GetItem(i)); allPlayer[1].Server_AddCard(CardList.GetItem(13 + i)); allPlayer[2].Server_AddCard(CardList.GetItem(26 + i)); allPlayer[3].Server_AddCard(CardList.GetItem(39 + i)); } allPlayer[0].IsGameStart = true; allPlayer[1].IsGameStart = true; allPlayer[2].IsGameStart = true; allPlayer[3].IsGameStart = true; process = Process.decidePlayer; break; case Process.decidePlayer: foreach (Player pl in allPlayer) { pl.SysMsg = "等待時間 準備開始 尋找梅花3玩家"; } Load(); for (int i = 0; i < NUMBER_OF_CARDS / 4; i++) { if (allPlayer[0].HaveCards.GetItem(i).UID == 8) { process = Process.p1Action; } else if (allPlayer[1].HaveCards.GetItem(i).UID == 8) { process = Process.p2Action; } else if (allPlayer[2].HaveCards.GetItem(i).UID == 8) { process = Process.p3Action; } else if (allPlayer[3].HaveCards.GetItem(i).UID == 8) { process = Process.p4Action; } } break; case Process.p1Action: allPlayer[0].SysMsg = "輪到你了!"; allPlayer[0].SetProcess(Player.Process.action); allPlayer[1].SysMsg = "等待對方..."; allPlayer[1].SetProcess(Player.Process.wait); allPlayer[2].SysMsg = "等待對方..."; allPlayer[2].SetProcess(Player.Process.wait); allPlayer[3].SysMsg = "等待對方..."; allPlayer[3].SetProcess(Player.Process.wait); break; case Process.p2Action: allPlayer[1].SysMsg = "輪到你了!"; allPlayer[1].SetProcess(Player.Process.action); allPlayer[0].SysMsg = "等待對方..."; allPlayer[0].SetProcess(Player.Process.wait); allPlayer[2].SysMsg = "等待對方..."; allPlayer[2].SetProcess(Player.Process.wait); allPlayer[3].SysMsg = "等待對方..."; allPlayer[3].SetProcess(Player.Process.wait); break; case Process.p3Action: allPlayer[2].SysMsg = "輪到你了!"; allPlayer[2].SetProcess(Player.Process.action); allPlayer[0].SysMsg = "等待對方..."; allPlayer[0].SetProcess(Player.Process.wait); allPlayer[1].SysMsg = "等待對方..."; allPlayer[1].SetProcess(Player.Process.wait); allPlayer[2].SysMsg = "等待對方..."; allPlayer[2].SetProcess(Player.Process.wait); break; case Process.p4Action: allPlayer[3].SysMsg = "輪到你了!"; allPlayer[3].SetProcess(Player.Process.action); allPlayer[1].SysMsg = "等待對方..."; allPlayer[1].SetProcess(Player.Process.wait); allPlayer[2].SysMsg = "等待對方..."; allPlayer[2].SetProcess(Player.Process.wait); allPlayer[0].SysMsg = "等待對方..."; allPlayer[0].SetProcess(Player.Process.wait); break; case Process.checkWin: switch (round) { case Round.player1: allPlayer[0].SysMsg = "Winner"; allPlayer[1].SysMsg = "Loser"; break; case Round.player2: allPlayer[1].SysMsg = "Winner"; allPlayer[0].SysMsg = "Loser"; break; } allPlayer[0].SetProcess(Player.Process.end); allPlayer[1].SetProcess(Player.Process.end); process = Process.end; break; } }