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