public void ResetInfo(StartDestDot startDestDot, bool special, int number) { StartDestPos = startDestDot; Special = special; Number = number; Owner = Camp.None; }
public Passenger(StartDestDot startDestDot, bool special, int number) { StartDestPos = startDestDot; Special = special; Number = number; Owner = Camp.None; }
public static StartDestDot OppoDots(StartDestDot prevDot) { StartDestDot newDots = new StartDestDot(); newDots.StartPos.x = prevDot.StartPos.y; newDots.StartPos.y = prevDot.StartPos.x; newDots.DestPos.x = prevDot.DestPos.y; newDots.DestPos.y = prevDot.DestPos.x; return(newDots); }
public byte[] PackMessage() { byte[] message = new byte[64]; //上位机传递的信息 message[0] = (byte)(((byte)state << 6) | (Round >> 8)); message[1] = (byte)Round; StartDestDot[] P = new StartDestDot[5]; for (int i = 0; i != 5; ++i) { P[i] = Passengers[i].StartDestPos; if (i >= CurrPassengerNumber) { P[i].StartPos.x = 0; P[i].StartPos.y = 0; P[i].DestPos.x = 0; P[i].DestPos.y = 0; } } message[2] = (byte)((CarA.Pos.x >> 1 & 0x80) | (CarA.Pos.y >> 2 & 0x40) | (CarB.Pos.x >> 3 & 0x20) | (CarB.Pos.y >> 4 & 0x10) | (P[0].StartPos.x >> 5 & 0x08) | (P[0].StartPos.y >> 6 & 0x04) | (P[0].DestPos.x >> 7 & 0x02) | (P[0].DestPos.y >> 8 & 0x01)); message[3] = (byte)((P[1].StartPos.x >> 1 & 0x80) | (P[1].StartPos.y >> 2 & 0x40) | (P[1].DestPos.x >> 3 & 0x20) | (P[1].DestPos.y >> 4 & 0x10) | (P[2].StartPos.x >> 5 & 0x08) | (P[2].StartPos.y >> 6 & 0x04) | (P[2].DestPos.x >> 7 & 0x02) | (P[2].DestPos.y >> 8 & 0x01)); message[4] = (byte)((P[3].StartPos.x >> 1 & 0x80) | (P[3].StartPos.y >> 2 & 0x40) | (P[3].DestPos.x >> 3 & 0x20) | (P[3].DestPos.y >> 4 & 0x10) | (P[4].StartPos.x >> 5 & 0x08) | (P[4].StartPos.y >> 6 & 0x04) | (P[4].DestPos.x >> 7 & 0x02) | (P[4].DestPos.y >> 8 & 0x01)); message[5] = (byte)CarA.Pos.x; message[6] = (byte)CarA.Pos.y; message[7] = (byte)CarB.Pos.x; message[8] = (byte)CarB.Pos.y; message[9] = (byte)((CurrPassengerNumber << 2) | (byte)Passengers[0].Owner); message[10] = (byte)((byte)Passengers[1].Owner << 6 | (byte)Passengers[2].Owner << 4 | (byte)Passengers[3].Owner << 2 | (byte)Passengers[4].Owner); for (int i = 0; i != 5; ++i) { message[11 + i * 4] = (byte)P[i].StartPos.x; message[12 + i * 4] = (byte)P[i].StartPos.y; message[13 + i * 4] = (byte)P[i].DestPos.x; message[14 + i * 4] = (byte)P[i].DestPos.y; } message[31] = (byte)CarA.FoulCnt; message[32] = (byte)CarB.FoulCnt; message[33] = (byte)(CarA.Score >> 8); message[34] = (byte)(CarA.Score); message[35] = (byte)(CarB.Score >> 8); message[36] = (byte)(CarB.Score); message[62] = 0x0D; message[63] = 0x0A; return(message); }
public void NewPassenger(int num) //刷新这一位置的新乘客 { StartDestDot temp = new StartDestDot(); if (num == 1 || num == 3) { temp = Generator.NextA(); } else if (num == 2 || num == 4) { temp = Generator.NextB(); } else { temp = Generator.NextS(); } Passengers[num - 1] = new Passenger(temp, num == 5, num); }
private void updatePassengerBtn_Click(object sender, EventArgs e) { int i = Convert.ToInt32(nextPassengerTB.Text); int start_x = Convert.ToInt32(nextPassengerStartXTB.Text); int start_y = Convert.ToInt32(nextPassengerStartYTB.Text); int end_x = Convert.ToInt32(nextPassengerEndXTB.Text); int end_y = Convert.ToInt32(nextPassengerEndYTB.Text); Dot start_pos = new Dot { x = start_x, y = start_y }; Dot end_pos = new Dot { x = end_x, y = end_y }; StartDestDot start_dest_dot = new StartDestDot { StartPos = start_pos, DestPos = end_pos }; lock (game) // 更新game里的ground_truth { game.Passengers[i - 1] = new Passenger(start_dest_dot, (i == 5), i); } lock (flags) // 更新flags里的信息 { i--; flags.posPassengerStart[i].X = game.Passengers[i].StartDestPos.StartPos.x; flags.posPassengerStart[i].Y = game.Passengers[i].StartDestPos.StartPos.y; flags.posPassengerEnd[i].X = game.Passengers[i].StartDestPos.DestPos.x; flags.posPassengerEnd[i].Y = game.Passengers[i].StartDestPos.DestPos.y; flags.passengerState[i] = game.Passengers[i].Owner; } nextPassengerTB.Text = ""; nextPassengerStartXTB.Text = ""; nextPassengerStartYTB.Text = ""; nextPassengerEndXTB.Text = ""; nextPassengerEndYTB.Text = ""; }