private void Game() //確認 時間到0或是分數到頂 { if (user_scro >= 100) { timer1.Stop(); string[] win_play = textBox3.Text.Split(':'); Send("M" + "(系統)" + win_play[0] + ":(WINER) Done"); Start_btu.Show(); } if (this.progressBar1.Value == 0) { Send("T" + 100); timer1.Stop(); if (Player[p_num] != Netname) { OtherPanel(); } else { Gm_btu.Enabled = true; } C.Shapes.Clear(); D.Shapes.Clear(); Draw_panel1.Controls.Clear(); Count = 0; //猜的人數歸零 Skip_btu.Visible = false; } }
private void Recetor(byte[] B, int inLen) { string Msg = Encoding.Default.GetString(B, 0, inLen); //解讀完整訊息 string St = Msg.Substring(0, 1); //取出命令碼 (第一個字) string Str = Msg.Substring(1); //取出命令碼之後的訊息 switch (St) //依命令碼執行功能 { case "L": //接收線上名單 listBox1.Items.Clear(); Player.Clear(); //清除名單 string[] M = Str.Split(','); //拆解名單成陣列 for (int i = 0; i < M.Length; i++) { Player.Add(M[i]); listBox1.Items.Add(M[i] + ":" + user_scro + "分"); } //逐一加入名單 break; case "9": //接收離開玩家 textBox1.AppendText("(系統) :" + Str + " 已離開伺服器! \r\n"); Player.Remove(Str); listBox1.Items.Remove(Str); if (Player.Count == 1) { Start_btu.Show(); this.timer1.Stop(); progressBar1.Value = 100; user_scro = 0; } break; case "3": textBox1.AppendText("(私密)" + Str + "\r\n"); break; //私密訊息 case "C": D.Shapes.Clear(); break; case "P": PointShape(Str); break; case "A": Ans = Str; break; case "G": //Draw 資訊 p_num = int.Parse(Str); Draw_plays = Player[p_num]; textBox1.AppendText("(系統) :" + Draw_plays + " Draw \r\n"); if (Draw_plays != Netname) { OtherPanel(); } p_num++; if (Player.Count - 1 < p_num) { p_num = 0; } break; case "D": textBox1.AppendText("(公開)" + Str + "\r\n"); break; //聊天室 case "M": textBox2.AppendText(Str + "\r\n"); break; //猜題未答對 case "T": if (progressBar1.Value > 0) { progressBar1.Value--; } if (Str != "") { progressBar1.Value = 100; if (p_num > Player.Count - 1) { p_num = 0; } if (Player[p_num] == Netname) { Gm_btu.Enabled = true; } else { OtherPanel(); } C.Shapes.Clear(); Draw_panel1.Controls.Clear(); Count = 0; Game(); } break; case "S": Count++; listBox1.Items.Add(Str); if (Draw_plays == Netname || Count < 1) { user_scro += 10; listBox1.Items.Add(Draw_plays + ":" + user_scro + "分"); } if (p_num > Player.Count - 1) { p_num = 0; } break; } } //接收ServerC回傳