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.

MainWindow.xaml.cs 69 kB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. using System.Diagnostics;
  16. using System.Windows.Threading;
  17. using Grpc.Core;
  18. using Protobuf;
  19. using Playback;
  20. using CommandLine;
  21. using Preparation.Utility;
  22. // 目前MainWindow还未复现的功能:
  23. // private void ClickToSetMode(object sender, RoutedEventArgs e)
  24. // private void Bonus()
  25. namespace Client
  26. {
  27. /// <summary>
  28. /// Interaction logic for MainWindow.xaml
  29. /// </summary>
  30. public partial class MainWindow : Window
  31. {
  32. public MainWindow()
  33. {
  34. unitHeight = unitWidth = unit = 13;
  35. bonusflag = true;
  36. timer = new DispatcherTimer
  37. {
  38. Interval = new TimeSpan(50000) // 每50ms刷新一次
  39. };
  40. timer.Tick += new EventHandler(Refresh); // 定时器初始化
  41. InitializeComponent();
  42. timer.Start();
  43. SetStatusBar();
  44. isClientStocked = true;
  45. isPlaybackMode = false;
  46. drawPicLock = new();
  47. listOfProp = new List<MessageOfProp>();
  48. listOfHuman = new List<MessageOfStudent>();
  49. listOfButcher = new List<MessageOfTricker>();
  50. listOfBullet = new List<MessageOfBullet>();
  51. listOfBombedBullet = new List<MessageOfBombedBullet>();
  52. listOfAll = new List<MessageOfAll>();
  53. listOfChest = new List<MessageOfChest>();
  54. listOfClassroom = new List<MessageOfClassroom>();
  55. listOfDoor = new List<MessageOfDoor>();
  56. listOfGate = new List<MessageOfGate>();
  57. WindowStartupLocation = WindowStartupLocation.CenterScreen;
  58. ReactToCommandline();
  59. }
  60. private void SetStatusBar()
  61. {
  62. StatusBarsOfSurvivor = new StatusBarOfSurvivor[4];
  63. StatusBarsOfHunter = new StatusBarOfHunter(MainGrid, 3, 0);
  64. StatusBarsOfCircumstance = new StatusBarOfCircumstance(MainGrid, 1, 0);
  65. for (int i = 4; i < 8; i++)
  66. {
  67. StatusBarsOfSurvivor[i - 4] = new(MainGrid, i / 2 + 2, i % 2);
  68. }
  69. }
  70. // 获得地图信息,未更新数值
  71. private void GetMap(MessageOfMap obj)
  72. {
  73. int[,] map = new int[50, 50];
  74. try
  75. {
  76. for (int i = 0; i < 50; i++)
  77. {
  78. for (int j = 0; j < 50; j++)
  79. {
  80. map[i, j] = Convert.ToInt32(obj.Row[i].Col[j]) + 4;//与proto一致
  81. }
  82. }
  83. }
  84. catch
  85. {
  86. mapFlag = false;
  87. }
  88. finally
  89. {
  90. defaultMap = map;
  91. mapFlag = true;
  92. }
  93. }
  94. private void ReactToCommandline()
  95. {
  96. string[] args = Environment.GetCommandLineArgs();
  97. if (args.Length == 2)
  98. {
  99. Playback(args[1]);
  100. return;
  101. }
  102. _ = Parser.Default.ParseArguments<ArgumentOptions>(args).WithParsed(o =>
  103. { options = o; });
  104. if ((args.Length == 3 || args.Length == 4) && options != null && Convert.ToInt64(options.PlayerID) > 2023)
  105. {
  106. spectatorMode = true;
  107. string[] comInfo = new string[3];
  108. comInfo[0] = options.Ip;
  109. comInfo[1] = options.Port;
  110. comInfo[2] = options.PlayerID;
  111. ConnectToServer(comInfo);
  112. OnReceive();
  113. return;
  114. }
  115. if (options == null || options.cl == false)
  116. {
  117. OnReceive();
  118. }
  119. else
  120. {
  121. if (options.PlaybackFile == DefaultArgumentOptions.FileName)
  122. {
  123. try
  124. {
  125. string[] comInfo = new string[5];
  126. comInfo[0] = options.Ip;
  127. comInfo[1] = options.Port;
  128. comInfo[2] = options.PlayerID;
  129. comInfo[3] = options.PlayerType;
  130. comInfo[4] = options.Occupation;
  131. ConnectToServer(comInfo);
  132. OnReceive();
  133. }
  134. catch
  135. {
  136. OnReceive();
  137. }
  138. }
  139. else
  140. {
  141. Playback(options.PlaybackFile, options.PlaybackSpeed);
  142. }
  143. }
  144. }
  145. private void Playback(string fileName, double pbSpeed = 2.0)
  146. {
  147. var pbClient = new PlaybackClient(fileName, pbSpeed);
  148. int[,]? map;
  149. if ((map = pbClient.ReadDataFromFile(listOfProp, listOfHuman, listOfButcher, listOfBullet, listOfBombedBullet, listOfAll, listOfChest, listOfClassroom, listOfDoor, listOfGate, drawPicLock)) != null)
  150. {
  151. isClientStocked = false;
  152. isPlaybackMode = true;
  153. defaultMap = map;
  154. mapFlag = true;
  155. }
  156. else
  157. {
  158. MessageBox.Show("Failed to read the playback file!");
  159. isClientStocked = true;
  160. }
  161. }
  162. // 连接Server,comInfo[]的格式:0-ip 1- port 2-playerID 3-human/TrickerType 4-occupation
  163. private void ConnectToServer(string[] comInfo)
  164. {
  165. if (!isPlaybackMode)
  166. {
  167. if (!spectatorMode && comInfo.Length != 5 || spectatorMode && comInfo.Length != 3)
  168. throw new Exception("注册信息有误!");
  169. playerID = Convert.ToInt64(comInfo[2]);
  170. Connect.Background = Brushes.Gray;
  171. string connect = new string(comInfo[0]);
  172. connect += ':';
  173. connect += comInfo[1];
  174. Channel channel = new Channel(connect, ChannelCredentials.Insecure);
  175. client = new AvailableService.AvailableServiceClient(channel);
  176. PlayerMsg playerMsg = new PlayerMsg();
  177. playerMsg.PlayerId = playerID;
  178. if (!spectatorMode)
  179. {
  180. playerType = Convert.ToInt64(comInfo[3]) switch
  181. {
  182. 0 => PlayerType.NullPlayerType,
  183. 1 => PlayerType.StudentPlayer,
  184. 2 => PlayerType.TrickerPlayer,
  185. };
  186. playerMsg.PlayerType = playerType;
  187. if (Convert.ToInt64(comInfo[3]) == 1)
  188. {
  189. humanOrButcher = true;
  190. }
  191. else if (Convert.ToInt64(comInfo[3]) == 2)
  192. {
  193. humanOrButcher = false;
  194. }
  195. if (playerType == PlayerType.StudentPlayer)
  196. {
  197. switch (Convert.ToInt64(comInfo[4]))
  198. {
  199. case 1:
  200. playerMsg.StudentType = StudentType.Athlete;
  201. break;
  202. case 2:
  203. playerMsg.StudentType = StudentType.Teacher;
  204. break;
  205. case 3:
  206. playerMsg.StudentType = StudentType.StraightAStudent;
  207. break;
  208. case 4:
  209. playerMsg.StudentType = StudentType.Robot;
  210. break;
  211. case 5:
  212. playerMsg.StudentType = StudentType.TechOtaku;
  213. break;
  214. case 0:
  215. default:
  216. playerMsg.StudentType = StudentType.NullStudentType;
  217. break;
  218. }
  219. }
  220. else if (playerType == PlayerType.TrickerPlayer)
  221. {
  222. switch (Convert.ToInt64(comInfo[4]))
  223. {
  224. case 1:
  225. playerMsg.TrickerType = TrickerType.Assassin;
  226. break;
  227. case 2:
  228. playerMsg.TrickerType = TrickerType.Klee;
  229. break;
  230. case 3:
  231. playerMsg.TrickerType = TrickerType.ANoisyPerson;
  232. break;
  233. case 4:
  234. playerMsg.TrickerType = TrickerType._4;
  235. break;
  236. case 0:
  237. default:
  238. playerMsg.TrickerType = TrickerType.NullTrickerType;
  239. break;
  240. }
  241. }
  242. }
  243. responseStream = client.AddPlayer(playerMsg);
  244. Connect.Background = Brushes.Transparent;
  245. isClientStocked = false;
  246. PorC.Content = "⏸";
  247. // 建立连接的同时加入人物
  248. }
  249. }
  250. // 绘制道具
  251. private void DrawProp(MessageOfProp data, string text)
  252. {
  253. TextBox icon = new()
  254. {
  255. FontSize = 10,
  256. Width = 20,
  257. Height = 20,
  258. Text = text,
  259. HorizontalAlignment = HorizontalAlignment.Left,
  260. VerticalAlignment = VerticalAlignment.Top,
  261. Margin = new Thickness(data.Y * unitWidth / 1000.0 - unitWidth / 2, data.X * unitHeight / 1000.0 - unitHeight / 2, 0, 0),
  262. Background = Brushes.Transparent,
  263. BorderBrush = Brushes.Transparent,
  264. IsReadOnly = true
  265. };
  266. UpperLayerOfMap.Children.Add(icon);
  267. }
  268. private void ZoomMap()
  269. {
  270. for (int i = 0; i < 50; i++)
  271. {
  272. for (int j = 0; j < 50; j++)
  273. {
  274. if (mapPatches[i, j] != null)
  275. {
  276. mapPatches[i, j].Width = UpperLayerOfMap.ActualWidth / 50;
  277. mapPatches[i, j].Height = UpperLayerOfMap.ActualHeight / 50;
  278. mapPatches[i, j].HorizontalAlignment = HorizontalAlignment.Left;
  279. mapPatches[i, j].VerticalAlignment = VerticalAlignment.Top;
  280. mapPatches[i, j].Margin = new Thickness(UpperLayerOfMap.ActualWidth / 50 * j, UpperLayerOfMap.ActualHeight / 50 * i, 0, 0);
  281. }
  282. }
  283. }
  284. }
  285. private void DrawMap()
  286. {
  287. for (int i = 0; i < defaultMap.GetLength(0); i++)
  288. {
  289. for (int j = 0; j < defaultMap.GetLength(1); j++)
  290. {
  291. mapPatches[i, j] = new()
  292. {
  293. Width = unitWidth,
  294. Height = unitHeight,
  295. HorizontalAlignment = HorizontalAlignment.Left,
  296. VerticalAlignment = VerticalAlignment.Top,
  297. Margin = new Thickness(Width * (j), Height * (i), 0, 0)
  298. };
  299. switch (defaultMap[i, j])
  300. {
  301. case 6:
  302. mapPatches[i, j].Fill = Brushes.Brown;
  303. mapPatches[i, j].Stroke = Brushes.Brown;
  304. break;//wall
  305. case 7:
  306. mapPatches[i, j].Fill = Brushes.Green;
  307. mapPatches[i, j].Stroke = Brushes.Green;
  308. break;//grass
  309. case 8:
  310. mapPatches[i, j].Fill = Brushes.LightPink;
  311. mapPatches[i, j].Stroke = Brushes.LightPink;
  312. break;//machine
  313. case 9:
  314. mapPatches[i, j].Fill = Brushes.LightSkyBlue;
  315. mapPatches[i, j].Stroke = Brushes.LightSkyBlue;
  316. break;//gate
  317. case 10:
  318. foreach (var obj in listOfAll)
  319. {
  320. if (obj.SubjectFinished >= Preparation.Utility.GameData.numOfGeneratorRequiredForEmergencyExit)
  321. {
  322. mapPatches[i, j].Fill = Brushes.LightSalmon;
  323. mapPatches[i, j].Stroke = Brushes.LightSalmon;
  324. }
  325. }
  326. break;//emergency
  327. case 11:
  328. mapPatches[i, j].Fill = Brushes.Gray;
  329. mapPatches[i, j].Stroke = Brushes.Gray;
  330. break;//window
  331. case 12:
  332. case 13:
  333. case 14:
  334. mapPatches[i, j].Fill = Brushes.Khaki;
  335. mapPatches[i, j].Stroke = Brushes.Khaki;
  336. break;//door
  337. case 15:
  338. mapPatches[i, j].Fill = Brushes.Orange;
  339. mapPatches[i, j].Stroke = Brushes.Orange;
  340. break;//chest
  341. default:
  342. break;
  343. }
  344. UnderLayerOfMap.Children.Add(mapPatches[i, j]);
  345. }
  346. }
  347. hasDrawed = true;
  348. }
  349. //三个参数分别为攻击者的位置,攻击方位角(窗口坐标)和攻击半径
  350. private void DrawLaser(Point source, double theta, double range, double Width) // 三个参数分别为攻击者的位置,攻击方位角(窗口坐标)和攻击半径
  351. {
  352. Point[] endPoint = new Point[4];
  353. Point target = new();
  354. target.X = source.X + range * Math.Cos(theta);
  355. target.Y = source.Y + range * Math.Sin(theta);
  356. endPoint[0].X = source.X + Width * Math.Cos(theta - Math.PI / 2);
  357. endPoint[0].Y = source.Y + Width * Math.Sin(theta - Math.PI / 2);
  358. endPoint[1].X = target.X + Width * Math.Cos(theta - Math.PI / 2);
  359. endPoint[1].Y = target.Y + Width * Math.Sin(theta - Math.PI / 2);
  360. endPoint[2].X = target.X + Width * Math.Cos(theta + Math.PI / 2);
  361. endPoint[2].Y = target.Y + Width * Math.Sin(theta + Math.PI / 2);
  362. endPoint[3].X = source.X + Width * Math.Cos(theta + Math.PI / 2);
  363. endPoint[3].Y = source.Y + Width * Math.Sin(theta + Math.PI / 2);
  364. Polygon laserIcon = new();
  365. laserIcon.Stroke = System.Windows.Media.Brushes.Red;
  366. laserIcon.Fill = System.Windows.Media.Brushes.Red;
  367. laserIcon.StrokeThickness = 2;
  368. laserIcon.HorizontalAlignment = HorizontalAlignment.Left;
  369. laserIcon.VerticalAlignment = VerticalAlignment.Top;
  370. PointCollection laserEndPoints = new();
  371. for (int i = 0; i < 4; i++)
  372. {
  373. laserEndPoints.Add(endPoint[i]);
  374. }
  375. laserIcon.Points = laserEndPoints;
  376. UpperLayerOfMap.Children.Add(laserIcon);
  377. }
  378. private async void OnReceive() // 已按照3.5版proto更新信息,但是左侧信息栏还未填充。log未更新,switch1,2,3更新log
  379. {
  380. try
  381. {
  382. while (responseStream != null && await responseStream.ResponseStream.MoveNext())
  383. {
  384. lock (drawPicLock) // 加锁是必要的,画图操作和接收信息操作不能同时进行,否则画图时foreach会有bug
  385. {
  386. listOfHuman.Clear();
  387. listOfButcher.Clear();
  388. listOfProp.Clear();
  389. listOfBombedBullet.Clear();
  390. listOfBullet.Clear();
  391. listOfAll.Clear();
  392. listOfChest.Clear();
  393. listOfClassroom.Clear();
  394. listOfDoor.Clear();
  395. listOfGate.Clear();
  396. MessageToClient content = responseStream.ResponseStream.Current;
  397. switch (content.GameState)
  398. {
  399. case GameState.GameStart:
  400. foreach (var obj in content.ObjMessage)
  401. {
  402. switch (obj.MessageOfObjCase)
  403. {
  404. case MessageOfObj.MessageOfObjOneofCase.StudentMessage:
  405. if (humanOrButcher && obj.StudentMessage.PlayerId == playerID)
  406. {
  407. human = obj.StudentMessage;
  408. if (human.TimeUntilSkillAvailable[0] >= 0)
  409. coolTime0 = human.TimeUntilSkillAvailable[0];
  410. if (human.TimeUntilSkillAvailable[1] >= 0)
  411. coolTime1 = human.TimeUntilSkillAvailable[1];
  412. if (human.TimeUntilSkillAvailable[2] >= 0)
  413. coolTime2 = human.TimeUntilSkillAvailable[2];
  414. }
  415. listOfHuman.Add(obj.StudentMessage);
  416. break;
  417. case MessageOfObj.MessageOfObjOneofCase.TrickerMessage:
  418. if (!humanOrButcher && obj.TrickerMessage.PlayerId == playerID)
  419. {
  420. butcher = obj.TrickerMessage;
  421. if (butcher.TimeUntilSkillAvailable[0] >= 0)
  422. coolTime0 = butcher.TimeUntilSkillAvailable[0];
  423. if (butcher.TimeUntilSkillAvailable[1] >= 0)
  424. coolTime1 = butcher.TimeUntilSkillAvailable[1];
  425. if (butcher.TimeUntilSkillAvailable[2] >= 0)
  426. coolTime2 = butcher.TimeUntilSkillAvailable[2];
  427. }
  428. listOfButcher.Add(obj.TrickerMessage);
  429. break;
  430. case MessageOfObj.MessageOfObjOneofCase.PropMessage:
  431. listOfProp.Add(obj.PropMessage);
  432. break;
  433. case MessageOfObj.MessageOfObjOneofCase.BombedBulletMessage:
  434. listOfBombedBullet.Add(obj.BombedBulletMessage);
  435. break;
  436. case MessageOfObj.MessageOfObjOneofCase.BulletMessage:
  437. listOfBullet.Add(obj.BulletMessage);
  438. break;
  439. case MessageOfObj.MessageOfObjOneofCase.ChestMessage:
  440. listOfChest.Add(obj.ChestMessage);
  441. break;
  442. case MessageOfObj.MessageOfObjOneofCase.ClassroomMessage:
  443. listOfClassroom.Add(obj.ClassroomMessage);
  444. break;
  445. case MessageOfObj.MessageOfObjOneofCase.DoorMessage:
  446. listOfDoor.Add(obj.DoorMessage);
  447. break;
  448. case MessageOfObj.MessageOfObjOneofCase.GateMessage:
  449. listOfGate.Add(obj.GateMessage);
  450. break;
  451. case MessageOfObj.MessageOfObjOneofCase.MapMessage:
  452. GetMap(obj.MapMessage);
  453. break;
  454. }
  455. }
  456. listOfAll.Add(content.AllMessage);
  457. break;
  458. case GameState.GameRunning:
  459. foreach (var obj in content.ObjMessage)
  460. {
  461. switch (obj.MessageOfObjCase)
  462. {
  463. case MessageOfObj.MessageOfObjOneofCase.StudentMessage:
  464. if (humanOrButcher && obj.StudentMessage.PlayerId == playerID)
  465. {
  466. human = obj.StudentMessage;
  467. }
  468. listOfHuman.Add(obj.StudentMessage);
  469. break;
  470. case MessageOfObj.MessageOfObjOneofCase.TrickerMessage:
  471. if (!humanOrButcher && obj.TrickerMessage.PlayerId == playerID)
  472. {
  473. butcher = obj.TrickerMessage;
  474. }
  475. listOfButcher.Add(obj.TrickerMessage);
  476. break;
  477. case MessageOfObj.MessageOfObjOneofCase.PropMessage:
  478. listOfProp.Add(obj.PropMessage);
  479. break;
  480. case MessageOfObj.MessageOfObjOneofCase.BombedBulletMessage:
  481. listOfBombedBullet.Add(obj.BombedBulletMessage);
  482. break;
  483. case MessageOfObj.MessageOfObjOneofCase.BulletMessage:
  484. listOfBullet.Add(obj.BulletMessage);
  485. break;
  486. case MessageOfObj.MessageOfObjOneofCase.ChestMessage:
  487. listOfChest.Add(obj.ChestMessage);
  488. break;
  489. case MessageOfObj.MessageOfObjOneofCase.ClassroomMessage:
  490. listOfClassroom.Add(obj.ClassroomMessage);
  491. break;
  492. case MessageOfObj.MessageOfObjOneofCase.DoorMessage:
  493. listOfDoor.Add(obj.DoorMessage);
  494. break;
  495. case MessageOfObj.MessageOfObjOneofCase.GateMessage:
  496. listOfGate.Add(obj.GateMessage);
  497. break;
  498. }
  499. }
  500. listOfAll.Add(content.AllMessage);
  501. break;
  502. case GameState.GameEnd:
  503. foreach (var obj in content.ObjMessage)
  504. {
  505. switch (obj.MessageOfObjCase)
  506. {
  507. case MessageOfObj.MessageOfObjOneofCase.StudentMessage:
  508. listOfHuman.Add(obj.StudentMessage);
  509. break;
  510. case MessageOfObj.MessageOfObjOneofCase.TrickerMessage:
  511. listOfButcher.Add(obj.TrickerMessage);
  512. break;
  513. case MessageOfObj.MessageOfObjOneofCase.PropMessage:
  514. listOfProp.Add(obj.PropMessage);
  515. break;
  516. case MessageOfObj.MessageOfObjOneofCase.BombedBulletMessage:
  517. listOfBombedBullet.Add(obj.BombedBulletMessage);
  518. break;
  519. case MessageOfObj.MessageOfObjOneofCase.BulletMessage:
  520. listOfBullet.Add(obj.BulletMessage);
  521. break;
  522. case MessageOfObj.MessageOfObjOneofCase.ChestMessage:
  523. listOfChest.Add(obj.ChestMessage);
  524. break;
  525. case MessageOfObj.MessageOfObjOneofCase.ClassroomMessage:
  526. listOfClassroom.Add(obj.ClassroomMessage);
  527. break;
  528. case MessageOfObj.MessageOfObjOneofCase.DoorMessage:
  529. listOfDoor.Add(obj.DoorMessage);
  530. break;
  531. case MessageOfObj.MessageOfObjOneofCase.GateMessage:
  532. listOfGate.Add(obj.GateMessage);
  533. break;
  534. }
  535. }
  536. listOfAll.Add(content.AllMessage);
  537. break;
  538. }
  539. }
  540. if (responseStream == null)
  541. {
  542. throw new Exception("Unconnected");
  543. }
  544. }
  545. }
  546. catch (Exception ex)
  547. {
  548. ErrorDisplayer error = new("Error: " + ex.ToString());
  549. error.Show();
  550. }
  551. }
  552. //待修改
  553. private bool CanSee(MessageOfStudent msg)
  554. {
  555. if (msg.PlayerState == PlayerState.Quit)
  556. return false;
  557. if (spectatorMode)
  558. return true;
  559. if (humanOrButcher && human != null)
  560. {
  561. if (human.Guid == msg.Guid) // 自己能看见自己
  562. return true;
  563. }
  564. if (msg.Place == Protobuf.PlaceType.Grass || msg.Place == Protobuf.PlaceType.Gate || msg.Place == Protobuf.PlaceType.HiddenGate)
  565. return false;
  566. if (msg.Place == Protobuf.PlaceType.Land || msg.Place == Protobuf.PlaceType.Classroom)
  567. return true;
  568. if (humanOrButcher && human != null)
  569. {
  570. if (msg.Place != human.Place)
  571. return false;
  572. }
  573. else if (!humanOrButcher && butcher != null)
  574. {
  575. if (msg.Place != butcher.Place)
  576. return false;
  577. }
  578. return true;
  579. }
  580. private bool CanSee(MessageOfTricker msg)
  581. {
  582. if (spectatorMode)
  583. return true;
  584. if (!humanOrButcher && butcher != null)
  585. {
  586. if (butcher.Guid == msg.Guid) // 自己能看见自己
  587. return true;
  588. }
  589. if (msg.Place == Protobuf.PlaceType.Grass || msg.Place == Protobuf.PlaceType.Gate || msg.Place == Protobuf.PlaceType.HiddenGate)
  590. return false;
  591. if (msg.Place == Protobuf.PlaceType.Land || msg.Place == Protobuf.PlaceType.Classroom)
  592. return true;
  593. if (humanOrButcher && human != null)
  594. {
  595. if (msg.Place != human.Place)
  596. return false;
  597. }
  598. else if (!humanOrButcher && butcher != null)
  599. {
  600. if (msg.Place != butcher.Place)
  601. return false;
  602. }
  603. return true;
  604. }
  605. private bool CanSee(MessageOfProp msg)
  606. {
  607. if (spectatorMode)
  608. return true;
  609. if (msg.Place == Protobuf.PlaceType.Land)
  610. return true;
  611. if (humanOrButcher && human != null)
  612. {
  613. if (msg.Place != human.Place)
  614. return false;
  615. }
  616. else if (!humanOrButcher && butcher != null)
  617. {
  618. if (msg.Place != butcher.Place)
  619. return false;
  620. }
  621. return true;
  622. }
  623. private bool CanSee(MessageOfBullet msg)
  624. {
  625. if (spectatorMode)
  626. return true;
  627. if (msg.Place == Protobuf.PlaceType.Land)
  628. return true;
  629. if (humanOrButcher && human != null)
  630. {
  631. if (msg.Place != human.Place)
  632. return false;
  633. }
  634. else if (!humanOrButcher && butcher != null)
  635. {
  636. if (msg.Place != butcher.Place)
  637. return false;
  638. }
  639. return true;
  640. }
  641. private void Refresh(object? sender, EventArgs e) // 已按照3.5版proto更新信息,circumstance栏未更新 log未更新
  642. {
  643. // Bonus();
  644. if (WindowState == WindowState.Maximized)
  645. MaxButton.Content = "❐";
  646. else
  647. MaxButton.Content = "🗖";
  648. if (StatusBarsOfSurvivor != null)
  649. for (int i = 4; i < 8; i++)
  650. {
  651. StatusBarsOfSurvivor[i - 4].SetFontSize(12 * UpperLayerOfMap.ActualHeight / 650);
  652. }
  653. if (StatusBarsOfHunter != null)
  654. StatusBarsOfHunter.SetFontSize(12 * UpperLayerOfMap.ActualHeight / 650);
  655. if (StatusBarsOfCircumstance != null)
  656. StatusBarsOfCircumstance.SetFontSize(12 * UpperLayerOfMap.ActualHeight / 650);
  657. // 完成窗口信息更新
  658. if (!isClientStocked)
  659. {
  660. unit = Math.Sqrt(UpperLayerOfMap.ActualHeight * UpperLayerOfMap.ActualWidth) / 50;
  661. unitHeight = UpperLayerOfMap.ActualHeight / 50;
  662. unitWidth = UpperLayerOfMap.ActualWidth / 50;
  663. try
  664. {
  665. // if (log != null)
  666. //{
  667. // string temp = "";
  668. // for (int i = 0; i < dataDict[GameObjType.Character].Count; i++)
  669. // {
  670. // temp += Convert.ToString(dataDict[GameObjType.Character][i].MessageOfCharacter.TeamID) + "\n";
  671. // }
  672. // log.Content = temp;
  673. // }
  674. UpperLayerOfMap.Children.Clear();
  675. // if ((communicator == null || !communicator.Client.IsConnected) && !isPlaybackMode)
  676. //{
  677. // UnderLayerOfMap.Children.Clear();
  678. // throw new Exception("Client is unconnected.");
  679. // }
  680. // else
  681. //{
  682. lock (drawPicLock) // 加锁是必要的,画图操作和接收信息操作不能同时进行
  683. {
  684. foreach (var data in listOfAll)
  685. {
  686. StatusBarsOfCircumstance.SetValue(data, gateOpened);
  687. }
  688. if (!hasDrawed && mapFlag)
  689. DrawMap();
  690. foreach (var data in listOfHuman)
  691. {
  692. StatusBarsOfSurvivor[data.PlayerId].SetValue(data, coolTime0, coolTime1, coolTime2);
  693. if (CanSee(data))
  694. {
  695. Ellipse icon = new()
  696. {
  697. Width = 2 * radiusTimes * unitWidth,
  698. Height = 2 * radiusTimes * unitHeight,
  699. HorizontalAlignment = HorizontalAlignment.Left,
  700. VerticalAlignment = VerticalAlignment.Top,
  701. Margin = new Thickness(data.Y * unitWidth / 1000.0 - unitWidth * radiusTimes, data.X * unitHeight / 1000.0 - unitHeight * radiusTimes, 0, 0),
  702. Fill = Brushes.BlueViolet,
  703. };
  704. UpperLayerOfMap.Children.Add(icon);
  705. }
  706. }
  707. foreach (var data in listOfButcher)
  708. {
  709. StatusBarsOfHunter.SetValue(data, coolTime0, coolTime1, coolTime2);
  710. if (CanSee(data))
  711. {
  712. Ellipse icon = new()
  713. {
  714. Width = 2 * radiusTimes * unitWidth,
  715. Height = 2 * radiusTimes * unitHeight,
  716. HorizontalAlignment = HorizontalAlignment.Left,
  717. VerticalAlignment = VerticalAlignment.Top,
  718. Margin = new Thickness(data.Y * unitWidth / 1000.0 - unitWidth * radiusTimes, data.X * unitHeight / 1000.0 - unitHeight * radiusTimes, 0, 0),
  719. Fill = Brushes.Chocolate,
  720. };
  721. UpperLayerOfMap.Children.Add(icon);
  722. }
  723. }
  724. foreach (var data in listOfProp)
  725. {
  726. if (CanSee(data))
  727. {
  728. switch (data.Type)
  729. {
  730. case Protobuf.PropType.Key3:
  731. DrawProp(data, "🔑");
  732. break;
  733. case Protobuf.PropType.Key5:
  734. DrawProp(data, "🔑");
  735. break;
  736. case Protobuf.PropType.Key6:
  737. DrawProp(data, "🔑");
  738. break;
  739. case Protobuf.PropType.AddSpeed:
  740. DrawProp(data, "⛸");
  741. break;
  742. case Protobuf.PropType.AddHpOrAp:
  743. DrawProp(data, "♥");
  744. break;
  745. case Protobuf.PropType.AddLifeOrClairaudience:
  746. DrawProp(data, "🏅");
  747. break;
  748. case Protobuf.PropType.ShieldOrSpear:
  749. DrawProp(data, "🛡");
  750. break;
  751. case Protobuf.PropType.RecoveryFromDizziness:
  752. DrawProp(data, "🕶");
  753. break;
  754. default:
  755. DrawProp(data, "");
  756. break;
  757. }
  758. }
  759. }
  760. foreach (var data in listOfBullet)
  761. {
  762. if (CanSee(data))
  763. {
  764. Ellipse icon = new()
  765. {
  766. Width = 10,
  767. Height = 10,
  768. HorizontalAlignment = HorizontalAlignment.Left,
  769. VerticalAlignment = VerticalAlignment.Top,
  770. Margin = new Thickness(data.Y * unitWidth / 1000.0 - unitWidth / 2, data.X * unitHeight / 1000.0 - unitHeight / 2, 0, 0),
  771. //Fill = Brushes.Red,
  772. };
  773. switch (data.Type)
  774. {
  775. case Protobuf.BulletType.FlyingKnife:
  776. icon.Fill = Brushes.Blue;
  777. break;
  778. case Protobuf.BulletType.CommonAttackOfTricker:
  779. case Protobuf.BulletType.BombBomb:
  780. case Protobuf.BulletType.JumpyDumpty:
  781. icon.Fill = Brushes.Red;
  782. break;
  783. default:
  784. break;
  785. }
  786. UpperLayerOfMap.Children.Add(icon);
  787. }
  788. }
  789. foreach (var data in listOfBombedBullet)
  790. {
  791. switch (data.Type)
  792. {
  793. case Protobuf.BulletType.BombBomb:
  794. {
  795. Ellipse icon = new();
  796. double bombRange = data.BombRange / 1000;
  797. icon.Width = bombRange * unitWidth;
  798. icon.Height = bombRange * unitHeight;
  799. icon.HorizontalAlignment = HorizontalAlignment.Left;
  800. icon.VerticalAlignment = VerticalAlignment.Top;
  801. icon.Margin = new Thickness(data.Y * unitWidth / 1000.0 - bombRange * unitWidth / 2, data.X * unitHeight / 1000.0 - bombRange * unitHeight / 2, 0, 0);
  802. icon.Fill = Brushes.Red;
  803. UpperLayerOfMap.Children.Add(icon);
  804. break;
  805. }
  806. case Protobuf.BulletType.JumpyDumpty:
  807. {
  808. Ellipse icon = new Ellipse();
  809. double bombRange = data.BombRange / 1000;
  810. icon.Width = bombRange * unitWidth;
  811. icon.Height = bombRange * unitHeight;
  812. icon.HorizontalAlignment = HorizontalAlignment.Left;
  813. icon.VerticalAlignment = VerticalAlignment.Top;
  814. icon.Margin = new Thickness(data.Y * unitWidth / 1000.0 - bombRange * unitWidth / 2, data.X * unitHeight / 1000.0 - bombRange * unitHeight / 2, 0, 0);
  815. icon.Fill = Brushes.Red;
  816. UpperLayerOfMap.Children.Add(icon);
  817. break;
  818. }
  819. //case Protobuf.BulletType.LineBullet:
  820. // {
  821. // double bombRange = data.BombRange / 1000;
  822. // DrawLaser(new Point(data.Y * unitWidth / 1000.0, data.X * unitHeight / 1000.0), -data.FacingDirection + Math.PI / 2, bombRange * unitHeight, 0.5 * unitWidth);
  823. // break;
  824. // }
  825. default:
  826. break;
  827. }
  828. }
  829. foreach (var data in listOfClassroom)
  830. {
  831. int deg = (int)(100.0 * data.Progress / Preparation.Utility.GameData.degreeOfFixedGenerator);
  832. TextBox icon = new()
  833. {
  834. FontSize = 8 * UpperLayerOfMap.ActualHeight / 650,
  835. Width = unitWidth,
  836. Height = unitHeight,
  837. Text = Convert.ToString(deg),
  838. HorizontalAlignment = HorizontalAlignment.Left,
  839. VerticalAlignment = VerticalAlignment.Top,
  840. Margin = new Thickness(data.Y * unitWidth / 1000.0 - unitWidth / 2, data.X * unitHeight / 1000.0 - unitHeight / 2, 0, 0),
  841. Background = Brushes.Transparent,
  842. BorderBrush = Brushes.Transparent,
  843. IsReadOnly = true
  844. };
  845. if (deg == 100)
  846. {
  847. icon.Text = "A+";
  848. }
  849. UpperLayerOfMap.Children.Add(icon);
  850. }
  851. foreach (var data in listOfChest)
  852. {
  853. int deg = (int)(100.0 * data.Progress / Preparation.Utility.GameData.degreeOfOpenedChest);
  854. TextBox icon = new()
  855. {
  856. FontSize = 8 * UpperLayerOfMap.ActualHeight / 650,
  857. Width = unitWidth,
  858. Height = unitHeight,
  859. Text = Convert.ToString(deg),
  860. HorizontalAlignment = HorizontalAlignment.Left,
  861. VerticalAlignment = VerticalAlignment.Top,
  862. Margin = new Thickness(data.Y * unitWidth / 1000.0 - unitWidth / 2, data.X * unitHeight / 1000.0 - unitHeight / 2, 0, 0),
  863. Background = Brushes.Transparent,
  864. BorderBrush = Brushes.Transparent,
  865. IsReadOnly = true
  866. };
  867. if (deg == 100)
  868. {
  869. icon.Text = "Ø";
  870. }
  871. UpperLayerOfMap.Children.Add(icon);
  872. }
  873. foreach (var data in listOfGate)
  874. {
  875. int deg = (int)(100.0 * data.Progress / Preparation.Utility.GameData.degreeOfOpenedDoorway);
  876. TextBox icon = new()
  877. {
  878. FontSize = 8 * UpperLayerOfMap.ActualHeight / 650,
  879. Width = unitWidth,
  880. Height = unitHeight,
  881. Text = Convert.ToString(deg),
  882. HorizontalAlignment = HorizontalAlignment.Left,
  883. VerticalAlignment = VerticalAlignment.Top,
  884. Margin = new Thickness(data.Y * unitWidth / 1000.0 - unitWidth / 2, data.X * unitHeight / 1000.0 - unitHeight / 2, 0, 0),
  885. Background = Brushes.Transparent,
  886. BorderBrush = Brushes.Transparent,
  887. IsReadOnly = true
  888. };
  889. if (deg == 100)
  890. {
  891. gateOpened = true;
  892. icon.Text = "🔓";
  893. }
  894. UpperLayerOfMap.Children.Add(icon);
  895. }
  896. foreach (var data in listOfDoor)
  897. {
  898. TextBox icon = new()
  899. {
  900. FontSize = 9 * UpperLayerOfMap.ActualHeight / 650,
  901. Width = unitWidth,
  902. Height = unitHeight,
  903. HorizontalAlignment = HorizontalAlignment.Left,
  904. VerticalAlignment = VerticalAlignment.Top,
  905. Margin = new Thickness(data.Y * unitWidth / 1000.0 - unitWidth / 2, data.X * unitHeight / 1000.0 - unitHeight / 2, 0, 0),
  906. Background = Brushes.Transparent,
  907. BorderBrush = Brushes.Transparent,
  908. IsReadOnly = true
  909. };
  910. if (data.IsOpen)
  911. {
  912. icon.Text = Convert.ToString("🔓");
  913. }
  914. else
  915. {
  916. icon.Text = Convert.ToString("🔒");
  917. }
  918. UpperLayerOfMap.Children.Add(icon);
  919. }
  920. //}
  921. ZoomMap();
  922. }
  923. }
  924. catch (Exception exc)
  925. {
  926. ErrorDisplayer error = new("Error: " + exc.ToString());
  927. error.Show();
  928. isClientStocked = true;
  929. PorC.Content = "▶";
  930. }
  931. }
  932. counter++;
  933. }
  934. // 键盘控制,未完善
  935. private void KeyBoardControl(object sender, KeyEventArgs e)
  936. {
  937. if (!isPlaybackMode)
  938. {
  939. switch (e.Key)
  940. {
  941. case Key.W:
  942. case Key.NumPad8:
  943. MoveMsg msgW = new()
  944. {
  945. PlayerId = playerID,
  946. TimeInMilliseconds = 50,
  947. Angle = Math.PI
  948. };
  949. client.Move(msgW);
  950. break;
  951. case Key.S:
  952. case Key.NumPad2:
  953. MoveMsg msgS = new()
  954. {
  955. PlayerId = playerID,
  956. TimeInMilliseconds = 50,
  957. Angle = 0
  958. };
  959. client.Move(msgS);
  960. break;
  961. case Key.D:
  962. case Key.NumPad6:
  963. MoveMsg msgD = new()
  964. {
  965. PlayerId = playerID,
  966. TimeInMilliseconds = 50,
  967. Angle = Math.PI / 2
  968. };
  969. client.Move(msgD);
  970. break;
  971. case Key.A:
  972. case Key.NumPad4:
  973. MoveMsg msgA = new()
  974. {
  975. PlayerId = playerID,
  976. TimeInMilliseconds = 50,
  977. Angle = 3 * Math.PI / 2
  978. };
  979. client.Move(msgA);
  980. break;
  981. case Key.J:
  982. AttackMsg msgJ = new()
  983. {
  984. PlayerId = playerID,
  985. Angle = Math.PI
  986. };
  987. client.Attack(msgJ);
  988. break;
  989. case Key.K:
  990. IDMsg msgK = new()
  991. {
  992. PlayerId = playerID,
  993. };
  994. client.StartLearning(msgK);
  995. break;
  996. case Key.R:
  997. TreatAndRescueMsg msgR = new()
  998. {
  999. PlayerId = playerID,
  1000. };
  1001. client.StartRescueMate(msgR);
  1002. break;
  1003. case Key.T:
  1004. TreatAndRescueMsg msgT = new()
  1005. {
  1006. PlayerId = playerID,
  1007. };
  1008. client.StartTreatMate(msgT);
  1009. break;
  1010. case Key.G:
  1011. IDMsg msgG = new()
  1012. {
  1013. PlayerId = playerID,
  1014. };
  1015. client.Graduate(msgG);
  1016. break;
  1017. case Key.H:
  1018. IDMsg msgH = new()
  1019. {
  1020. PlayerId = playerID,
  1021. };
  1022. client.StartOpenGate(msgH);
  1023. break;
  1024. case Key.O:
  1025. IDMsg msgO = new()
  1026. {
  1027. PlayerId = playerID,
  1028. };
  1029. client.OpenDoor(msgO);
  1030. break;
  1031. case Key.P:
  1032. IDMsg msgP = new()
  1033. {
  1034. PlayerId = playerID,
  1035. };
  1036. client.CloseDoor(msgP);
  1037. break;
  1038. case Key.U:
  1039. IDMsg msgU = new()
  1040. {
  1041. PlayerId = playerID,
  1042. };
  1043. client.SkipWindow(msgU);
  1044. break;
  1045. case Key.I:
  1046. IDMsg msgI = new()
  1047. {
  1048. PlayerId = playerID,
  1049. };
  1050. client.StartOpenChest(msgI);
  1051. break;
  1052. case Key.E:
  1053. IDMsg msgE = new()
  1054. {
  1055. PlayerId = playerID,
  1056. };
  1057. client.EndAllAction(msgE);
  1058. break;
  1059. case Key.F:
  1060. PropMsg msgF = new()
  1061. {
  1062. PlayerId = playerID,
  1063. PropType = Protobuf.PropType.NullPropType,
  1064. };
  1065. client.PickProp(msgF);
  1066. break;
  1067. case Key.C:
  1068. PropMsg msgC = new()
  1069. {
  1070. PlayerId = playerID,
  1071. PropType = Protobuf.PropType.NullPropType,
  1072. };
  1073. client.ThrowProp(msgC);
  1074. break;
  1075. case Key.V:
  1076. PropMsg msgV = new()
  1077. {
  1078. PlayerId = playerID,
  1079. PropType = Protobuf.PropType.NullPropType,
  1080. };
  1081. client.UseProp(msgV);
  1082. break;
  1083. case Key.B:
  1084. SkillMsg msgB = new()
  1085. {
  1086. PlayerId = playerID,
  1087. SkillId = 0,
  1088. };
  1089. client.UseSkill(msgB);
  1090. break;
  1091. case Key.N:
  1092. SkillMsg msgN = new()
  1093. {
  1094. PlayerId = playerID,
  1095. SkillId = 1,
  1096. };
  1097. client.UseSkill(msgN);
  1098. break;
  1099. case Key.M:
  1100. SkillMsg msgM = new()
  1101. {
  1102. PlayerId = playerID,
  1103. SkillId = 2,
  1104. };
  1105. client.UseSkill(msgM);
  1106. break;
  1107. default:
  1108. break;
  1109. }
  1110. }
  1111. }
  1112. //鼠标双击
  1113. private void Attack(object sender, RoutedEventArgs e)
  1114. {
  1115. if (!isPlaybackMode)
  1116. {
  1117. if (humanOrButcher && human != null)
  1118. {
  1119. AttackMsg msgJ = new()
  1120. {
  1121. PlayerId = playerID
  1122. };
  1123. double mouseY = Mouse.GetPosition(UpperLayerOfMap).X * 1000 / unitWidth;
  1124. double mouseX = Mouse.GetPosition(UpperLayerOfMap).Y * 1000 / unitHeight;
  1125. msgJ.Angle = Math.Atan2(mouseY - human.Y, mouseX - human.X);
  1126. client.Attack(msgJ);
  1127. }
  1128. if (!humanOrButcher && butcher != null)
  1129. {
  1130. AttackMsg msgJ = new()
  1131. {
  1132. PlayerId = playerID
  1133. };
  1134. double mouseY = Mouse.GetPosition(UpperLayerOfMap).X * 1000 / unitWidth;
  1135. double mouseX = Mouse.GetPosition(UpperLayerOfMap).Y * 1000 / unitHeight;
  1136. msgJ.Angle = Math.Atan2(mouseY - butcher.Y, mouseX - butcher.X);
  1137. client.Attack(msgJ);
  1138. }
  1139. }
  1140. }
  1141. // 之后需要修改,现在只具有修改按钮形状的功能,并不能实现暂停/继续
  1142. private void ClickToPauseOrContinue(object sender, RoutedEventArgs e)
  1143. {
  1144. if (!isClientStocked)
  1145. {
  1146. isClientStocked = true;
  1147. PorC.Content = "▶";
  1148. }
  1149. else
  1150. {
  1151. isClientStocked = false;
  1152. PorC.Content = "⏸";
  1153. }
  1154. }
  1155. // 未复现
  1156. private void ClickToConnect(object sender, RoutedEventArgs e)
  1157. {
  1158. }
  1159. // 窗口最大化、关闭、最小化、拖拽
  1160. private void ClickToMaxmize(object sender, RoutedEventArgs e)
  1161. {
  1162. if (WindowState != WindowState.Maximized)
  1163. WindowState = WindowState.Maximized;
  1164. else
  1165. WindowState = WindowState.Normal;
  1166. }
  1167. private void ClickToClose(object sender, RoutedEventArgs e)
  1168. {
  1169. Application.Current.Shutdown();
  1170. }
  1171. private void ClickToMinimize(object sender, RoutedEventArgs e)
  1172. {
  1173. WindowState = WindowState.Minimized;
  1174. }
  1175. private void DragWindow(object sender, RoutedEventArgs e)
  1176. {
  1177. DragMove();
  1178. }
  1179. // 寻求帮助、访问EESAST(部分功能未复原)
  1180. private void ClickForHelp(object sender, RoutedEventArgs e)
  1181. {
  1182. PleaseWait();
  1183. }
  1184. private void ClickToVisitEESAST(object sender, RoutedEventArgs e)
  1185. {
  1186. try
  1187. {
  1188. _ = Process.Start("C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe", "https://eesast.com");
  1189. }
  1190. catch (Exception)
  1191. {
  1192. //ErrorDisplayer error = new("发生错误。以下是系统报告\n" + exc.ToString());
  1193. //error.Show();
  1194. }
  1195. }
  1196. // 配置连接(未复原)、我的AI(THUAI5未实现)、获取更新、天梯信息(可能需要网站协助)
  1197. private void ClickToSetConnect(object sender, RoutedEventArgs e)
  1198. {
  1199. // ConnectRegister crg = new();
  1200. // crg.Show();
  1201. }
  1202. private void ClickToEnterVS(object sender, RoutedEventArgs e)
  1203. {
  1204. // try
  1205. //{
  1206. // if (!File.Exists("VSRoute.txt"))
  1207. // {
  1208. // File.Create("VSRoute.txt");
  1209. // Exception ex = new("没有路径存储文件,已为您创建。请将VS路径输入该文件,并重新操作。");
  1210. // throw ex;
  1211. // }//创建路径文件
  1212. // using StreamReader sr = new("VSRoute.txt");
  1213. // _ = Process.Start(sr.ReadLine());
  1214. // }
  1215. // catch (Exception exc)
  1216. //{
  1217. // ErrorDisplayer error = new("发生错误。以下是系统报告:\n" + exc.ToString());
  1218. // error.Show();
  1219. // }
  1220. PleaseWait();
  1221. }
  1222. private void ClickForUpdate(object sender, RoutedEventArgs e)
  1223. {
  1224. PleaseWait();
  1225. }
  1226. private void ClickToCheckLadder(object sender, RoutedEventArgs e)
  1227. {
  1228. PleaseWait();
  1229. }
  1230. // 敬请期待函数
  1231. private void PleaseWait()
  1232. {
  1233. try
  1234. {
  1235. throw new Exception("敬请期待");
  1236. }
  1237. catch (Exception)
  1238. {
  1239. //ErrorDisplayer error = new(exc.Message)
  1240. //error.Show()
  1241. }
  1242. }
  1243. // 以下为Mainwindow自定义属性
  1244. private readonly DispatcherTimer timer; // 定时器
  1245. private long counter; // 预留的取时间变量
  1246. AvailableService.AvailableServiceClient client;
  1247. AsyncServerStreamingCall<MessageToClient>? responseStream;
  1248. private StatusBarOfSurvivor[] StatusBarsOfSurvivor;
  1249. private StatusBarOfHunter StatusBarsOfHunter;
  1250. private StatusBarOfCircumstance StatusBarsOfCircumstance;
  1251. private bool isClientStocked;
  1252. private bool isPlaybackMode;
  1253. private long playerID;
  1254. private PlayerType playerType;
  1255. private double unit;
  1256. private double unitHeight;
  1257. private double unitWidth;
  1258. private readonly Rectangle[,] mapPatches = new Rectangle[50, 50];
  1259. private List<MessageOfProp> listOfProp;
  1260. private List<MessageOfStudent> listOfHuman;
  1261. private List<MessageOfTricker> listOfButcher;
  1262. private List<MessageOfBullet> listOfBullet;
  1263. private List<MessageOfBombedBullet> listOfBombedBullet;
  1264. private List<MessageOfAll> listOfAll;
  1265. private List<MessageOfChest> listOfChest;
  1266. private List<MessageOfClassroom> listOfClassroom;
  1267. private List<MessageOfDoor> listOfDoor;
  1268. private List<MessageOfGate> listOfGate;
  1269. private object drawPicLock = new object();
  1270. private MessageOfStudent? human = null;
  1271. private MessageOfTricker? butcher = null;
  1272. private bool humanOrButcher;//true for human
  1273. private bool bonusflag;
  1274. private bool mapFlag = false;
  1275. private bool hasDrawed = false;
  1276. public int[,] defaultMap = new int[,] {
  1277. { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 },//6墙,1-5出生点
  1278. { 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6 },//7草
  1279. { 6, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 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  1325. { 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 6, 7, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 6, 0, 0, 0, 7, 7, 6, 6, 0, 0, 0, 6 },
  1326. { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 }
  1327. };
  1328. private string[] comInfo = new string[5];
  1329. ArgumentOptions? options = null;
  1330. bool gateOpened = false;
  1331. bool spectatorMode = false;
  1332. double coolTime0 = -1, coolTime1 = -1, coolTime2 = -1;
  1333. const double radiusTimes = 1.0 * Preparation.Utility.GameData.characterRadius / Preparation.Utility.GameData.numOfPosGridPerCell;
  1334. }
  1335. }