public bool AutoMoveOnce() { WhoWins result = CheckIfWinning(); if ((CurrentMove == WhoseMove.whiteMove && result == WhoWins.black) || (CurrentMove == WhoseMove.blackMove && result == WhoWins.white)) { MessageBox.Show("恭喜你,你赢了!", "YOU WIN", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } if ((CurrentMove == WhoseMove.whiteMove && result == WhoWins.white) || (CurrentMove == WhoseMove.blackMove && result == WhoWins.black)) { MessageBox.Show("不幸,你输了。", "YOU LOSE", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } if (!Game.AutoMoveNext(ParentSPF)) { MessageBox.Show("调用计算程序失败!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(0); } result = CheckIfWinning(); if ((CurrentMove == WhoseMove.whiteMove && result == WhoWins.black) || (CurrentMove == WhoseMove.blackMove && result == WhoWins.white)) { MessageBox.Show("不幸,你输了。", "YOU LOSE", MessageBoxButtons.OK, MessageBoxIcon.Information); } if ((CurrentMove == WhoseMove.whiteMove && result == WhoWins.white) || (CurrentMove == WhoseMove.blackMove && result == WhoWins.black)) { MessageBox.Show("恭喜你,你赢了!", "YOU WIN", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(true); }
public void SendServer(bool isOpponentLostConnection, WhoWins winner, int ballX, int ballY, int enemyY) { byte[] toSend = new byte[14]; toSend[0] = (byte)(isOpponentLostConnection ? 1 : 0); toSend[1] = (byte)(int)winner; toSend = AddNumberToByteArr(toSend, ballX, 2); toSend = AddNumberToByteArr(toSend, ballY, 6); toSend = AddNumberToByteArr(toSend, enemyY, 10); this.stream.Write(toSend, 0, toSend.Length); }
public Tuple <bool, WhoWins, int, int, int> ReciveServer() { byte[] buffer = new byte[14]; this.stream.Read(buffer, 0, buffer.Length); bool isOpponentLostConnection = (int)buffer[0] != 0; WhoWins winner = (WhoWins)(int)buffer[1]; int[] locations = new int[3]; for (int i = 0; i < 3; i++) { locations[i] = BitConverter.ToInt32(buffer, 2 + (i * 4)); } return(new Tuple <bool, WhoWins, int, int, int>(isOpponentLostConnection, winner, locations[0], locations[1], locations[2])); }