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.

CopyInfo.cs 18 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. using Protobuf;
  2. using System.Collections.Generic;
  3. using GameClass.GameObj;
  4. namespace Server
  5. {
  6. public static class CopyInfo
  7. {
  8. // 下面赋值为0的大概率是还没写完 2023-03-03
  9. public static MessageOfObj? Auto(GameObj gameObj)
  10. {
  11. if (gameObj.Type == Preparation.Utility.GameObjType.Character)
  12. {
  13. Character character = (Character)gameObj;
  14. if (character.IsGhost())
  15. return Tricker((Character)character);
  16. else return Student((Character)character);
  17. }
  18. else if (gameObj.Type == Preparation.Utility.GameObjType.Bullet)
  19. return Bullet((Bullet)gameObj);
  20. else if (gameObj.Type == Preparation.Utility.GameObjType.Prop)
  21. return Prop((Prop)gameObj);
  22. else if (gameObj.Type == Preparation.Utility.GameObjType.BombedBullet)
  23. return BombedBullet((BombedBullet)gameObj);
  24. else if (gameObj.Type == Preparation.Utility.GameObjType.PickedProp)
  25. return PickedProp((PickedProp)gameObj);
  26. else return null; //先写着防报错
  27. }
  28. private static MessageOfObj? Student(Character player)
  29. {
  30. MessageOfObj msg = new MessageOfObj();
  31. if (player.IsGhost()) return null;
  32. msg.StudentMessage.X = player.Position.x;
  33. msg.StudentMessage.Y = player.Position.y;
  34. msg.StudentMessage.Speed = player.MoveSpeed;
  35. msg.StudentMessage.Determination = player.HP;
  36. //msg.StudentMessage.FailNum = 0;
  37. foreach (var keyValue in player.TimeUntilActiveSkillAvailable)
  38. msg.StudentMessage.TimeUntilSkillAvailable.Add(keyValue.Value);
  39. //msg.StudentMessage.StudentType; // 下面写
  40. msg.StudentMessage.Guid = player.ID;
  41. msg.StudentMessage.State = StudentState.NullStatus;
  42. msg.StudentMessage.FailTime = 0;
  43. msg.StudentMessage.EmoTime = 0;
  44. msg.StudentMessage.PlayerId = 0;
  45. msg.StudentMessage.ViewRange = 0;
  46. msg.StudentMessage.Radius = 0;
  47. msg.StudentMessage.Damage = 0;
  48. msg.StudentMessage.DangerAlert = 0;
  49. msg.StudentMessage.Score = 0;
  50. msg.StudentMessage.TreatProgress = 0;
  51. msg.StudentMessage.RescueProgress = 0;
  52. foreach (KeyValuePair<Preparation.Utility.BuffType, bool> kvp in player.Buff)
  53. {
  54. if (kvp.Value)
  55. {
  56. switch (kvp.Key) // StudentBuffType具体内容待定
  57. {
  58. case Preparation.Utility.BuffType.Spear:
  59. msg.StudentMessage.Buff.Add(StudentBuffType.NullSbuffType);
  60. break;
  61. case Preparation.Utility.BuffType.AddLIFE:
  62. msg.StudentMessage.Buff.Add(StudentBuffType.NullSbuffType);
  63. break;
  64. case Preparation.Utility.BuffType.Shield:
  65. msg.StudentMessage.Buff.Add(StudentBuffType.NullSbuffType);
  66. break;
  67. case Preparation.Utility.BuffType.AddSpeed:
  68. msg.StudentMessage.Buff.Add(StudentBuffType.NullSbuffType);
  69. break;
  70. default:
  71. break;
  72. }
  73. }
  74. }
  75. //Character的储存方式可能得改,用enum type存道具和子弹,不应该用对象
  76. //现在懒得改了,有时间再重整一波
  77. if (player.PropInventory == null)
  78. msg.StudentMessage.Prop.Add(PropType.NullPropType);
  79. else
  80. {
  81. switch (player.PropInventory.GetPropType())
  82. {
  83. case Preparation.Utility.PropType.Gem:
  84. msg.StudentMessage.Prop.Add(PropType.NullPropType);
  85. break;
  86. /*case Preparation.Utility.PropType.addLIFE:
  87. msg.StudentMessage.MessageOfHuman.Prop = Communication.Proto.PropType.AddLife;
  88. break;
  89. case Preparation.Utility.PropType.addSpeed:
  90. msg.StudentMessage.MessageOfHuman.Prop = Communication.Proto.PropType.AddSpeed;
  91. break;
  92. case Preparation.Utility.PropType.Shield:
  93. msg.StudentMessage.MessageOfHuman.Prop = Communication.Proto.PropType.Shield;
  94. break;
  95. case Preparation.Utility.PropType.Spear:
  96. msg.StudentMessage.MessageOfHuman.Prop = Communication.Proto.PropType.Spear;
  97. break;
  98. default:
  99. msg.StudentMessage.Prop = PropType.NullPropType;
  100. break;*/
  101. }
  102. }
  103. return msg;
  104. }
  105. private static MessageOfObj? Tricker(Character player)
  106. {
  107. MessageOfObj msg = new MessageOfObj();
  108. if (!player.IsGhost()) return null;
  109. msg.TrickerMessage.X = player.Position.x;
  110. msg.TrickerMessage.Y = player.Position.y;
  111. msg.TrickerMessage.Speed = player.MoveSpeed;
  112. msg.TrickerMessage.Damage = 0;
  113. msg.TrickerMessage.TimeUntilSkillAvailable = 0;
  114. //msg.TrickerMessage.Place = 0; 下面写了
  115. //msg.TrickerMessage.Prop = PropType.NullPropType; // 下面写
  116. msg.TrickerMessage.TrickerType = TrickerType.NullTrickerType; // 下面写
  117. msg.TrickerMessage.Guid = 0;
  118. msg.TrickerMessage.Movable = false;
  119. msg.TrickerMessage.PlayerId = 0;
  120. msg.TrickerMessage.ViewRange = 0;
  121. msg.TrickerMessage.Radius = 0;
  122. //msg.TrickerMessage.Buff[0] = ButcherBuffType.NullSbuffType; 下面写了
  123. foreach (KeyValuePair<Preparation.Utility.BuffType, bool> kvp in player.Buff)
  124. {
  125. if (kvp.Value)
  126. {
  127. switch (kvp.Key) // ButcherBuffType具体内容待定
  128. {
  129. case Preparation.Utility.BuffType.Spear:
  130. msg.TrickerMessage.Buff.Add(TrickerBuffType.NullTbuffType);
  131. break;
  132. case Preparation.Utility.BuffType.AddLIFE:
  133. msg.TrickerMessage.Buff.Add(TrickerBuffType.NullTbuffType);
  134. break;
  135. case Preparation.Utility.BuffType.Shield:
  136. msg.TrickerMessage.Buff.Add(TrickerBuffType.NullTbuffType);
  137. break;
  138. case Preparation.Utility.BuffType.AddSpeed:
  139. msg.TrickerMessage.Buff.Add(TrickerBuffType.NullTbuffType);
  140. break;
  141. default:
  142. break;
  143. }
  144. }
  145. }
  146. /*switch (player.Place)
  147. {
  148. case Preparation.Utility.PlaceType.Land:
  149. msg.TrickerMessage.Place = PlaceType.Land;
  150. break;
  151. case Preparation.Utility.PlaceType.Grass1:
  152. msg.TrickerMessage.Place = PlaceType.Grass;
  153. break;
  154. case Preparation.Utility.PlaceType.Grass2:
  155. msg.TrickerMessage.Place = PlaceType.Grass;
  156. break;
  157. case Preparation.Utility.PlaceType.Grass3:
  158. msg.TrickerMessage.Place = PlaceType.Grass;
  159. break;
  160. // case Preparation.Utility.PlaceType.Invisible:
  161. // msg.TrickerMessage.MessageOfHuman.Place = Communication.Proto.PlaceType.Invisible;
  162. // break;
  163. default:
  164. msg.TrickerMessage.Place = PlaceType.NullPlaceType;
  165. break;
  166. }*/
  167. //Character的储存方式可能得改,用enum type存道具和子弹,不应该用对象
  168. //现在懒得改了,有时间再重整一波
  169. /*if (player.PropInventory == null)
  170. msg.TrickerMessage.Prop = PropType.NullPropType;
  171. else
  172. {
  173. switch (player.PropInventory.GetPropType())
  174. {
  175. case Preparation.Utility.PropType.Gem:
  176. msg.TrickerMessage.Prop = PropType.NullPropType;
  177. break;
  178. case Preparation.Utility.PropType.addLIFE:
  179. msg.TrickerMessage.MessageOfHuman.Prop = Communication.Proto.PropType.AddLife;
  180. break;
  181. case Preparation.Utility.PropType.addSpeed:
  182. msg.TrickerMessage.MessageOfHuman.Prop = Communication.Proto.PropType.AddSpeed;
  183. break;
  184. case Preparation.Utility.PropType.Shield:
  185. msg.TrickerMessage.MessageOfHuman.Prop = Communication.Proto.PropType.Shield;
  186. break;
  187. case Preparation.Utility.PropType.Spear:
  188. msg.TrickerMessage.MessageOfHuman.Prop = Communication.Proto.PropType.Spear;
  189. break;
  190. default:
  191. msg.TrickerMessage.Prop = PropType.NullPropType;
  192. break;
  193. }
  194. }*/
  195. return msg;
  196. }
  197. private static MessageOfObj Bullet(Bullet bullet)
  198. {
  199. MessageOfObj msg = new MessageOfObj();
  200. msg.BulletMessage.X = bullet.Position.x;
  201. msg.BulletMessage.Y = bullet.Position.y;
  202. //msg.BulletMessage.FacingDirection = bullet.FacingDirection; // XY转double?
  203. msg.BulletMessage.Guid = bullet.ID;
  204. msg.BulletMessage.Team = PlayerType.NullPlayerType;
  205. msg.BulletMessage.Place = PlaceType.NullPlaceType;
  206. msg.BulletMessage.BombRange = 0;
  207. switch (bullet.TypeOfBullet)
  208. {
  209. case Preparation.Utility.BulletType.AtomBomb:
  210. msg.BulletMessage.Type = BulletType.AtomBomb;
  211. break;
  212. case Preparation.Utility.BulletType.OrdinaryBullet:
  213. msg.BulletMessage.Type = BulletType.OrdinaryBullet;
  214. break;
  215. case Preparation.Utility.BulletType.FastBullet:
  216. msg.BulletMessage.Type = BulletType.FastBullet;
  217. break;
  218. case Preparation.Utility.BulletType.LineBullet:
  219. msg.BulletMessage.Type = BulletType.LineBullet;
  220. break;
  221. default:
  222. msg.BulletMessage.Type = BulletType.NullBulletType;
  223. break;
  224. }
  225. //if (bullet.Parent != null)
  226. //msg.BulletMessage.MessageOfBullet.ParentTeamID = bullet.Parent.TeamID;
  227. /*switch (bullet.Place)
  228. {
  229. case Preparation.Utility.PlaceType.Null:
  230. msg.BulletMessage.MessageOfBullet.Place = Communication.Proto.PlaceType.Null;
  231. break;
  232. case Preparation.Utility.PlaceType.Grass:
  233. msg.BulletMessage.MessageOfBullet.Place = Communication.Proto.PlaceType.Grass;
  234. break;
  235. case Preparation.Utility.PlaceType.Grass:
  236. msg.BulletMessage.MessageOfBullet.Place = Communication.Proto.PlaceType.Grass;
  237. break;
  238. case Preparation.Utility.PlaceType.Grass:
  239. msg.BulletMessage.MessageOfBullet.Place = Communication.Proto.PlaceType.Grass;
  240. break;
  241. default:
  242. msg.BulletMessage.MessageOfBullet.Place = Communication.Proto.PlacccceType.NullPlaceType;
  243. break;
  244. }*/
  245. return msg;
  246. }
  247. private static MessageOfObj Prop(Prop prop)
  248. {
  249. MessageOfObj msg = new MessageOfObj();
  250. //msg.PropMessage.Type = PropType.NullPropType; 下面写
  251. msg.PropMessage.X = prop.Position.x;
  252. msg.PropMessage.Y = prop.Position.y;
  253. msg.PropMessage.FacingDirection = 0;
  254. msg.PropMessage.Guid = 0;
  255. msg.PropMessage.Place = PlaceType.NullPlaceType;
  256. msg.PropMessage.Size = 0;
  257. msg.PropMessage.IsMoving = false;
  258. switch (prop.GetPropType())
  259. {
  260. /*case Preparation.Utility.PropType.Gem:
  261. msg.PropMessage.Type = PropType.Gem;
  262. break;
  263. case Preparation.Utility.PropType.addLIFE:
  264. msg.PropMessage.Type = PropType.AddLife;
  265. break;
  266. case Preparation.Utility.PropType.addSpeed:
  267. msg.PropMessage.Type = PropType.AddSpeed;
  268. break;
  269. case Preparation.Utility.PropType.Shield:
  270. msg.PropMessage.Type = PropType.Shield;
  271. break;
  272. case Preparation.Utility.PropType.Spear:
  273. msg.PropMessage.Type = PropType.Spear;
  274. break;*/
  275. default:
  276. msg.PropMessage.Type = PropType.NullPropType;
  277. break;
  278. }
  279. /*if(prop is Gem)
  280. {
  281. msg.PropMessage.MessageOfProp.Size = ((Gem)prop).Size;
  282. }
  283. else
  284. {
  285. msg.PropMessage.MessageOfProp.Size = 1;
  286. }
  287. switch (prop.Place)
  288. {
  289. case Preparation.Utility.PlaceType.Null:
  290. msg.PropMessage.MessageOfProp.Place = Communication.Proto.PlaceType.Null;
  291. break;
  292. case Preparation.Utility.PlaceType.Grass:
  293. msg.PropMessage.MessageOfProp.Place = Communication.Proto.PlaceType.Grass;
  294. break;
  295. case Preparation.Utility.PlaceType.Grass:
  296. msg.PropMessage.MessageOfProp.Place = Communication.Proto.PlaceType.Grass;
  297. break;
  298. case Preparation.Utility.PlaceType.Grass:
  299. msg.PropMessage.MessageOfProp.Place = Communication.Proto.PlaceType.Grass;
  300. break;
  301. default:
  302. msg.PropMessage.MessageOfProp.Place = Communication.Proto.PlacccceType.NullPlaceType;
  303. break;
  304. }*/
  305. return msg;
  306. }
  307. private static MessageOfObj BombedBullet(BombedBullet bombedBullet)
  308. {
  309. MessageOfObj msg = new MessageOfObj();
  310. msg.BombedBulletMessage.X = bombedBullet.bulletHasBombed.Position.x;
  311. msg.BombedBulletMessage.Y = bombedBullet.bulletHasBombed.Position.y;
  312. //msg.BombedBulletMessage.FacingDirection = bombedBullet.FacingDirection; XY类型转double?
  313. msg.BombedBulletMessage.MappingId = bombedBullet.MappingID;
  314. msg.BombedBulletMessage.BombRange = BulletFactory.BulletRadius(bombedBullet.bulletHasBombed.TypeOfBullet); // 待确认
  315. switch (bombedBullet.bulletHasBombed.TypeOfBullet)
  316. {
  317. case Preparation.Utility.BulletType.OrdinaryBullet:
  318. msg.BombedBulletMessage.Type = BulletType.OrdinaryBullet;
  319. break;
  320. case Preparation.Utility.BulletType.AtomBomb:
  321. msg.BombedBulletMessage.Type = BulletType.AtomBomb;
  322. break;
  323. case Preparation.Utility.BulletType.FastBullet:
  324. msg.BombedBulletMessage.Type = BulletType.FastBullet;
  325. break;
  326. case Preparation.Utility.BulletType.LineBullet:
  327. msg.BombedBulletMessage.Type = BulletType.LineBullet;
  328. break;
  329. default:
  330. msg.BombedBulletMessage.Type = BulletType.NullBulletType;
  331. break;
  332. }
  333. return msg;
  334. }
  335. private static MessageOfObj PickedProp(PickedProp pickedProp)
  336. {
  337. MessageOfObj msg = new MessageOfObj(); // MessageOfObj中没有PickedProp
  338. /*msg.MessageOfPickedProp = new MessageOfPickedProp();
  339. msg.MessageOfPickedProp.MappingID = pickedProp.MappingID;
  340. msg.MessageOfPickedProp.X = pickedProp.PropHasPicked.Position.x;
  341. msg.MessageOfPickedProp.Y = pickedProp.PropHasPicked.Position.y;
  342. msg.MessageOfPickedProp.FacingDirection = pickedProp.PropHasPicked.FacingDirection;
  343. switch (pickedProp.PropHasPicked.GetPropType())
  344. {
  345. case Preparation.Utility.PropType.Gem:
  346. msg.MessageOfPickedProp.Type = Communication.Proto.PropType.Gem;
  347. break;
  348. case Preparation.Utility.PropType.addLIFE:
  349. msg.MessageOfPickedProp.Type = Communication.Proto.PropType.AddLife;
  350. break;
  351. case Preparation.Utility.PropType.addSpeed:
  352. msg.MessageOfPickedProp.Type = Communication.Proto.PropType.AddSpeed;
  353. break;
  354. case Preparation.Utility.PropType.Shield:
  355. msg.MessageOfPickedProp.Type = Communication.Proto.PropType.Shield;
  356. break;
  357. case Preparation.Utility.PropType.Spear:
  358. msg.MessageOfPickedProp.Type = Communication.Proto.PropType.Spear;
  359. break;
  360. default:
  361. msg.MessageOfPickedProp.Type = Communication.Proto.PropType.NullPropType;
  362. break;
  363. }*/
  364. return msg;
  365. }
  366. }
  367. }