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