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

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