DataB2R.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using CommonLang.IO.Attribute;
  5. using CommonLang.IO;
  6. using CommonAI.Zone;
  7. using CommonLang.Protocol;
  8. namespace CommonAI.ZoneServer
  9. {
  10. /// <summary>
  11. /// 创建房间额外的参数
  12. /// 由游戏服发起(游戏服->战斗服)
  13. /// </summary>
  14. [MessageType(0x00040000)]
  15. public class CreateRoomInfoR2B : IExternalizable
  16. {
  17. public int SceneID;
  18. public int AverageLevel;
  19. public string EnvironmentVars;
  20. virtual public void WriteExternal(IOutputStream output)
  21. {
  22. output.PutS32(SceneID);
  23. output.PutS32(AverageLevel);
  24. output.PutUTF(EnvironmentVars);
  25. }
  26. virtual public void ReadExternal(IInputStream input)
  27. {
  28. SceneID = input.GetS32();
  29. AverageLevel = input.GetS32();
  30. EnvironmentVars = input.GetUTF();
  31. }
  32. }
  33. /// <summary>
  34. /// 创建玩家单位额外的参数
  35. /// 由游戏服发起(游戏服->战斗服)
  36. /// </summary>
  37. [MessageType(0x00040001)]
  38. public class CreateUnitInfoR2B : IExternalizable
  39. {
  40. /// <summary>
  41. /// 角色模板ID
  42. /// </summary>
  43. public int UnitTemplateID;
  44. /// <summary>
  45. /// 出生阵营
  46. /// </summary>
  47. public int Force;
  48. public int alliesForce;
  49. /// <summary>
  50. /// 玩家出生点
  51. /// </summary>
  52. public string StartFlag;
  53. /// <summary>
  54. /// 玩家扩展属性
  55. /// </summary>
  56. public IExternalizable UnitPropData = null;
  57. virtual public void WriteExternal(IOutputStream output)
  58. {
  59. output.PutS32(UnitTemplateID);
  60. output.PutVS32(Force);
  61. output.PutUTF(StartFlag);
  62. output.PutExt(UnitPropData);
  63. }
  64. virtual public void ReadExternal(IInputStream input)
  65. {
  66. UnitTemplateID = input.GetS32();
  67. Force = input.GetVS32();
  68. StartFlag = input.GetUTF();
  69. UnitPropData = input.GetExtAny();
  70. }
  71. }
  72. /// <summary>
  73. /// 房间战斗结束,结算报文(战斗服->游戏服)
  74. /// </summary>
  75. [MessageType(0x00040002)]
  76. public class RoomFinishInfoB2R : IExternalizable
  77. {
  78. /// <summary>
  79. /// 游戏编辑器对应的Xml场景ID
  80. /// </summary>
  81. public int SceneID;
  82. /// <summary>
  83. /// 胜利方
  84. /// </summary>
  85. public byte WinnerForce;
  86. /// <summary>
  87. /// 自定义消息
  88. /// </summary>
  89. public string Message;
  90. /// <summary>
  91. /// 游戏总共进行时间
  92. /// </summary>
  93. public int TotalTimeSEC;
  94. /// <summary>
  95. /// 玩家所有统计信息
  96. /// </summary>
  97. public List<PlayerResult> PlayerResults = new List<PlayerResult>();
  98. /// <summary>
  99. /// 战斗记录
  100. /// </summary>
  101. public byte[] BinLog;
  102. public void WriteExternal(IOutputStream output)
  103. {
  104. output.PutS32(this.SceneID);
  105. output.PutU8(this.WinnerForce);
  106. output.PutUTF(this.Message);
  107. output.PutS32(this.TotalTimeSEC);
  108. output.PutS32(PlayerResults.Count);
  109. int count = PlayerResults.Count;
  110. for (int i = 0; i < count; i++)
  111. {
  112. PlayerResult pr = PlayerResults[i];
  113. pr.WriteExternal(output);
  114. }
  115. output.PutBytes(BinLog);
  116. }
  117. public void ReadExternal(IInputStream input)
  118. {
  119. this.SceneID = input.GetS32();
  120. this.WinnerForce = input.GetU8();
  121. this.Message = input.GetUTF();
  122. this.TotalTimeSEC = input.GetS32();
  123. int count = input.GetS32();
  124. for (int i = 0; i < count; i++)
  125. {
  126. PlayerResult pr = new PlayerResult();
  127. pr.ReadExternal(input);
  128. PlayerResults.Add(pr);
  129. }
  130. this.BinLog = input.GetBytes();
  131. }
  132. /// <summary>
  133. /// 玩家战斗结果
  134. /// </summary>
  135. public class PlayerResult : IExternalizable
  136. {
  137. /// <summary>
  138. /// 玩家唯一标识
  139. /// </summary>
  140. public string PlayerUUID;
  141. /// <summary>
  142. /// 场景中的ID
  143. /// </summary>
  144. public uint ZoneObjectID;
  145. /// <summary>
  146. /// 是否胜利
  147. /// </summary>
  148. public bool IsWin;
  149. /// <summary>
  150. /// 此次战斗的阵营
  151. /// </summary>
  152. public byte Force;
  153. /// <summary>
  154. /// 获取的金币数量
  155. /// </summary>
  156. public int TotalTakeMoney;
  157. /// <summary>
  158. /// 死亡次数
  159. /// </summary>
  160. public int DeadCount;
  161. /// <summary>
  162. /// 承受伤害
  163. /// </summary>
  164. public long SelfDamage;
  165. /// <summary>
  166. /// 收获的所有道具 编辑器道具ID[]
  167. /// </summary>
  168. public int[] ItemTemplates;
  169. /// <summary>
  170. /// 总共杀死单位数量
  171. /// </summary>
  172. public int KillUnitCount;
  173. /// <summary>
  174. /// 总共杀敌人/小兵数量
  175. /// </summary>
  176. public int KillEnemyCount;
  177. /// <summary>
  178. /// 总共杀野怪数量
  179. /// </summary>
  180. public int KillNeutralityCount;
  181. /// <summary>
  182. /// 总共杀死建筑数量
  183. /// </summary>
  184. public int KillBuildingCount;
  185. /// <summary>
  186. /// 总共杀死玩家数量
  187. /// </summary>
  188. public int KillPlayerCount;
  189. /// <summary>
  190. /// 杀死精英怪物 编辑器单位ID[]
  191. /// </summary>
  192. public int[] KilledEllitMonsters;
  193. /// <summary>
  194. /// 杀死的玩家 玩家UUID[]
  195. /// </summary>
  196. public string[] KillPlayers;
  197. /// <summary>
  198. /// 对怪物造成的总伤害
  199. /// </summary>
  200. public long MonsterDamage;
  201. /// <summary>
  202. /// 对玩家造成的总伤害
  203. /// </summary>
  204. public long PlayerDamage;
  205. public void WriteExternal(IOutputStream output)
  206. {
  207. output.PutUTF(PlayerUUID);
  208. output.PutU32(ZoneObjectID);
  209. output.PutBool(IsWin);
  210. output.PutU8(Force);
  211. output.PutS32(TotalTakeMoney);
  212. output.PutS32(DeadCount);
  213. output.PutS64(SelfDamage);
  214. output.PutArray(ItemTemplates, output.PutS32);
  215. output.PutS32(KillUnitCount);
  216. output.PutS32(KillEnemyCount);
  217. output.PutS32(KillNeutralityCount);
  218. output.PutS32(KillBuildingCount);
  219. output.PutS32(KillPlayerCount);
  220. output.PutArray(KilledEllitMonsters, output.PutS32);
  221. output.PutArray(KillPlayers, output.PutUTF);
  222. output.PutS64(MonsterDamage);
  223. output.PutS64(PlayerDamage);
  224. }
  225. public void ReadExternal(IInputStream input)
  226. {
  227. PlayerUUID = input.GetUTF();
  228. ZoneObjectID = input.GetU32();
  229. IsWin = input.GetBool();
  230. Force = input.GetU8();
  231. TotalTakeMoney = input.GetS32();
  232. DeadCount = input.GetS32();
  233. SelfDamage = input.GetS64();
  234. ItemTemplates = input.GetArray<int>(input.GetS32);
  235. KillUnitCount = input.GetS32();
  236. KillEnemyCount = input.GetS32();
  237. KillNeutralityCount = input.GetS32();
  238. KillBuildingCount = input.GetS32();
  239. KillPlayerCount = input.GetS32();
  240. KilledEllitMonsters = input.GetArray<int>(input.GetS32);
  241. KillPlayers = input.GetUTFArray();
  242. MonsterDamage = input.GetS64();
  243. PlayerDamage = input.GetS64();
  244. }
  245. }
  246. }
  247. /// <summary>
  248. /// 通知玩家杀死怪物 (战斗服->游戏服)
  249. /// </summary>
  250. [MessageType(0x00040003)]
  251. public class UnitKillMonsterB2R : IExternalizable
  252. {
  253. public string PlayerUUID;
  254. public int MonsterId;
  255. virtual public void WriteExternal(IOutputStream output)
  256. {
  257. output.PutUTF(this.PlayerUUID);
  258. output.PutS32(this.MonsterId);
  259. }
  260. virtual public void ReadExternal(IInputStream input)
  261. {
  262. this.PlayerUUID = input.GetUTF();
  263. this.MonsterId = input.GetS32();
  264. }
  265. }
  266. /// <summary>
  267. /// 通知获得道具 (战斗服->游戏服)
  268. /// </summary>
  269. [MessageType(0x00040004)]
  270. public class UnitGotItemB2R : IExternalizable
  271. {
  272. public string PlayerUUID;
  273. public int ItemTemplateID;
  274. public int Count;
  275. virtual public void WriteExternal(IOutputStream output)
  276. {
  277. output.PutUTF(PlayerUUID);
  278. output.PutS32(ItemTemplateID);
  279. output.PutS32(Count);
  280. }
  281. virtual public void ReadExternal(IInputStream input)
  282. {
  283. PlayerUUID = input.GetUTF();
  284. ItemTemplateID = input.GetS32();
  285. Count = input.GetS32();
  286. }
  287. }
  288. /// <summary>
  289. /// 通知获得金币 (战斗服->游戏服)
  290. /// </summary>
  291. [MessageType(0x00040005)]
  292. public class UnitGotMoneyB2R : IExternalizable
  293. {
  294. public string PlayerUUID;
  295. public int Money;
  296. virtual public void WriteExternal(IOutputStream output)
  297. {
  298. output.PutUTF(this.PlayerUUID);
  299. output.PutS32(this.Money);
  300. }
  301. virtual public void ReadExternal(IInputStream input)
  302. {
  303. this.PlayerUUID = input.GetUTF();
  304. this.Money = input.GetS32();
  305. }
  306. }
  307. /// <summary>
  308. /// 客户端请求使用游戏币,(战斗服->游戏服)
  309. /// [Request的MessageID和Response的MessageID必须相等]
  310. /// </summary>
  311. [MessageType(0x00040006)]
  312. public class ClientCostRequestB2R : NetMessage
  313. {
  314. /// <summary>
  315. /// 玩家标识
  316. /// </summary>
  317. public string PlayerUUID;
  318. /// <summary>
  319. /// 消耗付费游戏币
  320. /// </summary>
  321. public int CostDiamond;
  322. /// <summary>
  323. /// 消耗产出金币
  324. /// </summary>
  325. public int CostGold;
  326. /// <summary>
  327. /// 消耗道具
  328. /// </summary>
  329. public int ItemTemplateID;
  330. public override void WriteExternal(IOutputStream output)
  331. {
  332. output.PutS32(base.MessageID);
  333. output.PutUTF(this.PlayerUUID);
  334. output.PutS32(this.CostDiamond);
  335. output.PutS32(this.CostGold);
  336. output.PutS32(this.ItemTemplateID);
  337. }
  338. public override void ReadExternal(IInputStream input)
  339. {
  340. base.MessageID = input.GetS32();
  341. this.PlayerUUID = input.GetUTF();
  342. this.CostDiamond = input.GetS32();
  343. this.CostGold = input.GetS32();
  344. this.ItemTemplateID = input.GetS32();
  345. }
  346. }
  347. /// <summary>
  348. /// 客户端请求使用游戏币回馈,(游戏服->战斗服)
  349. /// [Request的MessageID和Response的MessageID必须相等]
  350. /// </summary>
  351. [MessageType(0x00040007)]
  352. public class ClientCostResponseR2B : NetMessage
  353. {
  354. public const byte RESULT_OK = 1;
  355. public const byte RESULT_FAILED = 2;
  356. public byte Result = 0;
  357. public string Reason = "";
  358. public override void WriteExternal(IOutputStream output)
  359. {
  360. output.PutS32(base.MessageID);
  361. output.PutU8(this.Result);
  362. output.PutUTF(this.Reason);
  363. }
  364. public override void ReadExternal(IInputStream input)
  365. {
  366. base.MessageID = input.GetS32();
  367. this.Result = input.GetU8();
  368. this.Reason = input.GetUTF();
  369. }
  370. }
  371. /// <summary>
  372. /// 使用背包道具 (战斗服->游戏服)
  373. /// </summary>
  374. [MessageType(0x00040008)]
  375. public class UnitUseItemB2R : IExternalizable
  376. {
  377. /// <summary>
  378. /// 玩家标识
  379. /// </summary>
  380. public string PlayerUUID;
  381. public int ItemTemplateID;
  382. virtual public void WriteExternal(IOutputStream output)
  383. {
  384. output.PutUTF(PlayerUUID);
  385. output.PutS32(ItemTemplateID);
  386. }
  387. virtual public void ReadExternal(IInputStream input)
  388. {
  389. PlayerUUID = input.GetUTF();
  390. ItemTemplateID = input.GetS32();
  391. }
  392. }
  393. /// <summary>
  394. /// 游戏服关闭房间
  395. /// </summary>
  396. [MessageType(0x00040009)]
  397. public class CloseRoomNotifyR2B : NetMessage
  398. {
  399. /// <summary>
  400. /// 关闭消息类型
  401. /// </summary>
  402. public int Result;
  403. /// <summary>
  404. /// 关闭消息
  405. /// </summary>
  406. public string Message;
  407. /// <summary>
  408. /// 关闭倒计时
  409. /// </summary>
  410. public int TimeDelayMS;
  411. public override void WriteExternal(IOutputStream output)
  412. {
  413. output.PutS32(base.MessageID);
  414. output.PutS32(this.Result);
  415. output.PutUTF(this.Message);
  416. output.PutS32(this.TimeDelayMS);
  417. }
  418. public override void ReadExternal(IInputStream input)
  419. {
  420. base.MessageID = input.GetS32();
  421. this.Result = input.GetS32();
  422. this.Message = input.GetUTF();
  423. this.TimeDelayMS = input.GetS32();
  424. }
  425. }
  426. /// <summary>
  427. /// 游戏服向战斗服发送
  428. /// </summary>
  429. [MessageType(0x0004000A)]
  430. public class SendMessageR2B : NetMessage
  431. {
  432. public string Message;
  433. public override void WriteExternal(IOutputStream output)
  434. {
  435. output.PutUTF(this.Message);
  436. }
  437. public override void ReadExternal(IInputStream input)
  438. {
  439. this.Message = input.GetUTF();
  440. }
  441. }
  442. /// <summary>
  443. /// 战斗服向游戏服发送
  444. /// </summary>
  445. [MessageType(0x0004000B)]
  446. public class SendMessageB2R : NetMessage
  447. {
  448. public string Message;
  449. public override void WriteExternal(IOutputStream output)
  450. {
  451. output.PutUTF(this.Message);
  452. }
  453. public override void ReadExternal(IInputStream input)
  454. {
  455. this.Message = input.GetUTF();
  456. }
  457. }
  458. /// <summary>
  459. /// 战斗服向游戏服发送自定义事件.
  460. /// </summary>
  461. [MessageType(0x0004000C)]
  462. public class SendEventB2R : NetMessage
  463. {
  464. public IExternalizable evt;
  465. public override void WriteExternal(IOutputStream output)
  466. {
  467. output.PutExt(this.evt);
  468. }
  469. public override void ReadExternal(IInputStream input)
  470. {
  471. evt = input.GetExtAny();
  472. }
  473. }
  474. }