You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

Program.cs 1.5 kB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using Grpc.Core;
  2. using Protobuf;
  3. namespace ClientTest
  4. {
  5. public class Program
  6. {
  7. public static async Task Main(string[] args)
  8. {
  9. Thread.Sleep(3000);
  10. Channel channel = new Channel("127.0.0.1:8888", ChannelCredentials.Insecure);
  11. var client = new AvailableService.AvailableServiceClient(channel);
  12. PlayerMsg playerInfo = new();
  13. playerInfo.PlayerId = 0;
  14. playerInfo.PlayerType = PlayerType.StudentPlayer;
  15. playerInfo.StudentType = StudentType.NullStudentType;
  16. var call = client.AddPlayer(playerInfo);
  17. MoveMsg moveMsg = new();
  18. moveMsg.PlayerId = 0;
  19. moveMsg.PlayerType = PlayerType.StudentPlayer;
  20. moveMsg.TimeInMilliseconds = 100;
  21. moveMsg.Angle = 0;
  22. while (true)
  23. {
  24. Console.ReadLine();
  25. client.Move(moveMsg);
  26. Console.WriteLine("Move!");
  27. }
  28. while (await call.ResponseStream.MoveNext())
  29. {
  30. var currentGameInfo = call.ResponseStream.Current;
  31. if (playerInfo.PlayerType == PlayerType.StudentPlayer)
  32. {
  33. for (int i = 0; i < currentGameInfo.ObjMessage.Count; i++)
  34. {
  35. //Console.WriteLine($"Human is at ({currentGameInfo.StudentMessage[i].X}, {currentGameInfo.StudentMessage[i].Y})");
  36. }
  37. }
  38. }
  39. }
  40. }
  41. }