Messages.cs 130 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494
  1. using System;
  2. using System.IO;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using CommonAI.RTS;
  6. using CommonLang.Vector;
  7. using CommonLang.IO;
  8. using CommonLang.ByteOrder;
  9. using CommonLang.IO.Attribute;
  10. using CommonLang;
  11. using CommonLang.Protocol;
  12. using CommonAI.Zone.Helper;
  13. using CommonAI.ZoneClient;
  14. using CommonAI.Zone.Instance;
  15. using CommonLang.Log;
  16. using CommonAI.ZoneServer.JSGModule;
  17. using CommonAI.Data;
  18. namespace CommonAI.Zone
  19. {
  20. #region ABSTRACT
  21. /// <summary>
  22. /// 向服务器端发送的指令
  23. /// </summary>
  24. abstract public class Action : IMessage, BattleMessage
  25. {
  26. //private static int Inxexer = 0;
  27. public GameEntity sender;
  28. public int MessageID { get; set; }
  29. public Action() { }
  30. abstract public void WriteExternal(IOutputStream output);
  31. abstract public void ReadExternal(IInputStream input);
  32. virtual public void BeforeWrite(TemplateManager templates) { }
  33. virtual public void EndRead(TemplateManager templates) { }
  34. }
  35. /// <summary>
  36. /// 客户端接收到的消息
  37. /// </summary>
  38. abstract public class Event : IMessage, BattleMessage
  39. {
  40. public GameEntity sender;
  41. public int MessageID { get; set; }
  42. abstract public void WriteExternal(IOutputStream output);
  43. abstract public void ReadExternal(IInputStream input);
  44. virtual public void BeforeWrite(TemplateManager templates) { }
  45. virtual public void EndRead(TemplateManager templates) { }
  46. }
  47. public interface BattleMessage
  48. {
  49. void BeforeWrite(TemplateManager templates);
  50. void EndRead(TemplateManager templates);
  51. }
  52. /// <summary>
  53. /// 某个位置上的事件
  54. /// </summary>
  55. public interface PositionMessage
  56. {
  57. float X { get; }
  58. float Y { get; }
  59. }
  60. /// <summary>
  61. /// 主角的事件
  62. /// </summary>
  63. public interface ActorMessage
  64. {
  65. uint ObjectID { get; }
  66. }
  67. /** 单人事件 */
  68. public abstract class PlayerSingleMsg : ObjectEvent
  69. {
  70. }
  71. /// <summary>
  72. /// 系统消息
  73. /// </summary>
  74. public interface SystemMessage
  75. {
  76. }
  77. //--------------------------------------------------------------------------
  78. /// <summary>
  79. /// 向服务器端某个单位发送的指令
  80. /// </summary>
  81. abstract public class ObjectAction : Action
  82. {
  83. /// <summary>
  84. /// 不需要传输object_id, 使用sender对象来绑定Session和InstanceUnit的关联//
  85. /// </summary>
  86. public uint object_id;
  87. protected ObjectAction() { }
  88. protected ObjectAction(uint obj_id)
  89. {
  90. this.object_id = obj_id;
  91. }
  92. override public void WriteExternal(IOutputStream output)
  93. {
  94. // 不需要传输object_id, 使用sender对象来绑定Session和InstanceUnit//
  95. }
  96. override public void ReadExternal(IInputStream input)
  97. {
  98. // 不需要传输object_id, 使用sender对象来绑定Session和InstanceUnit//
  99. }
  100. }
  101. /// <summary>
  102. /// 某个单位的事件消息
  103. /// </summary>
  104. abstract public class ObjectEvent : Event
  105. {
  106. public uint object_id;
  107. public uint ObjectID { get { return object_id; } }
  108. protected ObjectEvent() { }
  109. protected ObjectEvent(uint obj_id)
  110. {
  111. this.object_id = obj_id;
  112. }
  113. override public void WriteExternal(IOutputStream output)
  114. {
  115. output.PutVU32(object_id);
  116. }
  117. override public void ReadExternal(IInputStream input)
  118. {
  119. this.object_id = input.GetVU32();
  120. }
  121. }
  122. //--------------------------------------------------------------------------
  123. /// <summary>
  124. /// 向服务器端某个单位发送的请求
  125. /// </summary>
  126. abstract public class ActorRequest : ObjectAction
  127. {
  128. protected ActorRequest() { }
  129. protected ActorRequest(uint obj_id)
  130. : base(obj_id)
  131. {
  132. }
  133. }
  134. /// <summary>
  135. /// 向服务器端某个单位发送请求对应的回馈
  136. /// </summary>
  137. abstract public class ActorResponse : ObjectEvent, ActorMessage
  138. {
  139. protected ActorResponse() { }
  140. protected ActorResponse(uint obj_id)
  141. : base(obj_id)
  142. {
  143. }
  144. }
  145. #endregion
  146. //--------------------------------------------------------------------------
  147. #region ZONE_EVENTS_0x8000
  148. public abstract class ZoneEvent : Event
  149. {
  150. }
  151. /// <summary>
  152. /// 添加单位事件
  153. /// </summary>
  154. [MessageType(0x8001)]
  155. public class AddUnitEvent : ZoneEvent
  156. {
  157. public SyncUnitInfo Sync;
  158. public string ErrorMessage;
  159. public byte flag; //标记:0:正常生成,1:归属某个服务器
  160. public uint unit_id
  161. {
  162. get
  163. {
  164. if (Sync != null)
  165. {
  166. return Sync.ObjectID;
  167. }
  168. return 0;
  169. }
  170. }
  171. public AddUnitEvent() { }
  172. public AddUnitEvent(SyncUnitInfo sync)
  173. {
  174. this.Sync = sync;
  175. }
  176. override public void WriteExternal(IOutputStream output)
  177. {
  178. output.PutExt(Sync);
  179. output.PutUTF(ErrorMessage);
  180. output.PutU8(flag);
  181. }
  182. override public void ReadExternal(IInputStream input)
  183. {
  184. this.Sync = input.GetExt<SyncUnitInfo>();
  185. this.ErrorMessage = input.GetUTF();
  186. this.flag = input.GetU8();
  187. }
  188. }
  189. /// <summary>
  190. /// 添加法术/飞行道具效果事件
  191. /// </summary>
  192. [MessageType(0x8002)]
  193. public class AddSpellEvent : ZoneEvent
  194. {
  195. private BitSet8 mask = new BitSet8();
  196. public bool IsLauncherSender
  197. {
  198. get { return mask.Get(0); }
  199. private set { mask.Set(0, value); }
  200. }
  201. public bool IsTargetPos
  202. {
  203. get { return mask.Get(1); }
  204. private set { mask.Set(1, value); }
  205. }
  206. public bool IsTargetObject
  207. {
  208. get { return mask.Get(2); }
  209. private set { mask.Set(2, value); }
  210. }
  211. public bool IsHeight
  212. {
  213. get { return mask.Get(3); }
  214. private set { mask.Set(3, value); }
  215. }
  216. public bool IsSyncPos
  217. {
  218. get { return mask.Get(4); }
  219. private set { mask.Set(4, value); }
  220. }
  221. public bool IsHalf
  222. {
  223. get { return mask.Get(7); }
  224. private set { mask.Set(7, value); }
  225. }
  226. public int spell_template_id
  227. {
  228. get { return (launch_data != null) ? launch_data.SpellID : 0; }
  229. }
  230. public LaunchSpell LaunchData
  231. {
  232. get { return launch_data; }
  233. }
  234. private LaunchSpell launch_data;
  235. private uint launch_data_sn = 0;
  236. public uint spell_id;
  237. public uint launcher_unit_id;
  238. public uint sender_unit_id;
  239. public uint target_obj_id;
  240. public Vector2 target_pos;
  241. public float x;
  242. public float y;
  243. public float direction;
  244. public float height;
  245. public int SpellID;
  246. public AddSpellEvent() { }
  247. public AddSpellEvent(InstanceSpell spell)
  248. {
  249. this.launch_data = spell.LaunchData;
  250. this.spell_id = spell.ID;
  251. this.sender_unit_id = spell.SenderID;
  252. this.launcher_unit_id = spell.LauncherID;
  253. this.target_obj_id = spell.TargetID;
  254. this.target_pos = spell.TargetPos;
  255. this.x = spell.X;
  256. this.y = spell.Y;
  257. this.direction = spell.Direction;
  258. this.height = spell.Z;
  259. //mask//
  260. this.IsLauncherSender = (launcher_unit_id == sender_unit_id);
  261. this.IsTargetPos = (spell.Info.MType == SpellTemplate.MotionType.Cannon || spell.Info.MType == SpellTemplate.MotionType.CurveMissile) && (target_pos != null);
  262. this.IsTargetObject = (target_obj_id != 0);
  263. this.IsHeight = (height != 0);
  264. this.IsHalf = spell.Parent.IsHalfSync;
  265. this.IsSyncPos = spell.Info.IsLaunchSpellEventSyncPos;
  266. this.SpellID = this.launch_data.SpellID;
  267. }
  268. public override void BeforeWrite(TemplateManager templates)
  269. {
  270. base.BeforeWrite(templates);
  271. if (launch_data != null)
  272. {
  273. this.launch_data_sn = this.LaunchData.IsCodeCreate() ? uint.MaxValue: launch_data.SerialNumber;
  274. }
  275. }
  276. public override void EndRead(TemplateManager templates)
  277. {
  278. base.EndRead(templates);
  279. if(this.launch_data_sn == uint.MaxValue)
  280. {
  281. this.launch_data = JSGGlobalData.GetUnConfigSpellByID((int)this.SpellID);
  282. //System.Console.WriteLine("123123123: " + this.launch_data.SpellID + ", " + this.launch_data.FromUnitBody);
  283. }
  284. else
  285. {
  286. this.launch_data = templates.GetSnData<LaunchSpell>(launch_data_sn);
  287. }
  288. }
  289. override public void WriteExternal(IOutputStream output)
  290. {
  291. output.PutU8(mask.Mask);
  292. output.PutVU32(spell_id);
  293. output.PutVU32(launch_data_sn);
  294. if (this.IsLauncherSender)
  295. {
  296. output.PutVU32(launcher_unit_id);
  297. }
  298. else
  299. {
  300. output.PutVU32(sender_unit_id);
  301. output.PutVU32(launcher_unit_id);
  302. }
  303. if (this.IsTargetObject)
  304. {
  305. output.PutVU32(target_obj_id);
  306. }
  307. if (this.IsTargetPos)
  308. {
  309. MoveHelper.WritePos(IsHalf, target_pos.X, target_pos.Y, output);
  310. }
  311. if (this.IsSyncPos)
  312. {
  313. MoveHelper.WritePosAndDirection(IsHalf, x, y, direction, output);
  314. }
  315. if (this.IsHeight)
  316. {
  317. MoveHelper.WritePos(IsHalf, height, output);
  318. }
  319. if (this.LaunchData.IsCodeCreate())
  320. {
  321. output.PutS32(this.SpellID);
  322. }
  323. //System.Console.WriteLine("AddSpell: " + this.launch_data.SpellID + ", ID: " + spell_id + ", XY:" + this.x + ", " + this.y + ", d:" + this.direction);
  324. }
  325. override public void ReadExternal(IInputStream input)
  326. {
  327. this.mask.Mask = input.GetU8();
  328. this.spell_id = input.GetVU32();
  329. this.launch_data_sn = input.GetVU32();
  330. if (this.IsLauncherSender)
  331. {
  332. this.launcher_unit_id = this.sender_unit_id = input.GetVU32();
  333. }
  334. else
  335. {
  336. this.sender_unit_id = input.GetVU32();
  337. this.launcher_unit_id = input.GetVU32();
  338. }
  339. if (this.IsTargetObject)
  340. {
  341. this.target_obj_id = input.GetVU32();
  342. }
  343. if (this.IsTargetPos)
  344. {
  345. this.target_pos = new Vector2();
  346. MoveHelper.ReadPos(IsHalf, ref target_pos, input);
  347. }
  348. if (this.IsSyncPos)
  349. {
  350. MoveHelper.ReadPosAndDirection(IsHalf, out x, out y, out direction, input);
  351. }
  352. if (this.IsHeight)
  353. {
  354. MoveHelper.ReadPos(IsHalf, out height, input);
  355. }
  356. if(this.launch_data_sn == uint.MaxValue)
  357. {
  358. this.SpellID = input.GetS32();
  359. }
  360. }
  361. }
  362. /// <summary>
  363. /// 单位动作中击中别的单位
  364. /// </summary>
  365. [MessageType(0x8003)]
  366. public class AddEffectEvent : ZoneEvent, PositionMessage
  367. {
  368. public uint hostId = 0;
  369. public float x;
  370. public float y;
  371. public float direction;
  372. private uint effect_sn = 0;
  373. public LaunchEffect effect { get; set; }
  374. public AddEffectEvent() { }
  375. public AddEffectEvent(uint hostId , float x, float y, float dir, LaunchEffect effect)
  376. {
  377. this.hostId = hostId;
  378. this.x = x;
  379. this.y = y;
  380. this.direction = dir;
  381. this.effect = effect;
  382. }
  383. override public void WriteExternal(IOutputStream output)
  384. {
  385. output.PutVU32(hostId);
  386. output.PutF32(x);
  387. output.PutF32(y);
  388. output.PutF32(direction);
  389. output.PutVU32(effect_sn);
  390. }
  391. override public void ReadExternal(IInputStream input)
  392. {
  393. this.hostId = input.GetVU32();
  394. this.x = input.GetF32();
  395. this.y = input.GetF32();
  396. this.direction = input.GetF32();
  397. this.effect_sn = input.GetVU32();
  398. }
  399. public override void BeforeWrite(TemplateManager templates)
  400. {
  401. if (effect != null)
  402. {
  403. this.effect_sn = effect.SerialNumber;
  404. }
  405. }
  406. public override void EndRead(TemplateManager templates)
  407. {
  408. this.effect = templates.GetSnData<LaunchEffect>(effect_sn);
  409. }
  410. public float X { get { return x; } }
  411. public float Y { get { return y; } }
  412. }
  413. /// <summary>
  414. /// 添加道具事件
  415. /// </summary>
  416. [MessageType(0x8004)]
  417. public class AddItemEvent : ZoneEvent
  418. {
  419. public SyncItemInfo Sync;
  420. public string ErrorMessage;
  421. public uint unit_id
  422. {
  423. get { if (Sync != null) { return Sync.ObjectID; } return 0; }
  424. }
  425. public AddItemEvent() { }
  426. public AddItemEvent(SyncItemInfo sync)
  427. {
  428. this.Sync = sync;
  429. }
  430. override public void WriteExternal(IOutputStream output)
  431. {
  432. output.PutExt(Sync);
  433. output.PutUTF(ErrorMessage);
  434. }
  435. override public void ReadExternal(IInputStream input)
  436. {
  437. this.Sync = input.GetExt<SyncItemInfo>();
  438. this.ErrorMessage = input.GetUTF();
  439. }
  440. }
  441. /// <summary>
  442. /// 某个对象从场景中移除
  443. /// </summary>
  444. [MessageType(0x8005)]
  445. public class RemoveObjectEvent : ZoneEvent
  446. {
  447. public uint object_id;
  448. public RemoveObjectEvent() { }
  449. public RemoveObjectEvent(uint oid)
  450. {
  451. this.object_id = oid;
  452. }
  453. override public void WriteExternal(IOutputStream output)
  454. {
  455. //Console.WriteLine(" - RemoveObjectEvent - " + this.object_id);
  456. output.PutVU32(object_id);
  457. }
  458. override public void ReadExternal(IInputStream input)
  459. {
  460. this.object_id = input.GetVU32();
  461. }
  462. }
  463. /// <summary>
  464. /// 同步场景中移动单位的坐标
  465. /// </summary>
  466. [MessageType(0x8006)]
  467. public class SyncPosEvent : ZoneEvent
  468. {
  469. public struct UnitPos : IVector2
  470. {
  471. private uint m_ID;
  472. private float m_X;
  473. private float m_Y;
  474. private float m_Z;
  475. private float m_Direction;
  476. public uint ID { get { return m_ID; } }
  477. public float Direction { get { return m_Direction; } set { m_Direction = value; } }
  478. public float X { get { return m_X; } set { m_X = value; } }
  479. public float Y { get { return m_Y; } set { m_Y = value; } }
  480. public float Z { get { return m_Z; } set { m_Z = value; } }
  481. public void SetObject(InstanceZoneObject obj)
  482. {
  483. this.m_ID = obj.ID;
  484. this.m_X = obj.X;
  485. this.m_Y = obj.Y;
  486. this.m_Z = obj.Z;
  487. this.m_Direction = obj.Direction;
  488. }
  489. internal void Write(IOutputStream output, bool half, bool sync_z)
  490. {
  491. output.PutVU32(m_ID);
  492. if (half)
  493. {
  494. output.PutU16(MoveHelper.ToPos16(m_X));
  495. output.PutU16(MoveHelper.ToPos16(m_Y));
  496. if (sync_z) output.PutU16(MoveHelper.ToPos16(m_Z));
  497. }
  498. else
  499. {
  500. output.PutF32(m_X);
  501. output.PutF32(m_Y);
  502. if (sync_z) output.PutF32(m_Z);
  503. }
  504. output.PutU8(MoveHelper.ToDirectionD8(m_Direction));
  505. //if (m_ID == 2649)
  506. //{
  507. // Console.WriteLine("SyncPos, " + TimeUtil.GetTimestampMS() + ", X: " + this.m_X + ",Y: " + this.m_Y);
  508. //}
  509. }
  510. internal void Read(IInputStream input, bool half, bool sync_z)
  511. {
  512. m_ID = input.GetVU32();
  513. if (half)
  514. {
  515. m_X = MoveHelper.ToPosF32(input.GetU16());
  516. m_Y = MoveHelper.ToPosF32(input.GetU16());
  517. if (sync_z) m_Z = MoveHelper.ToPosF32(input.GetU16());
  518. }
  519. else
  520. {
  521. m_X = input.GetF32();
  522. m_Y = input.GetF32();
  523. if (sync_z) m_Z = input.GetF32();
  524. }
  525. m_Direction = MoveHelper.ToDirectionF32(input.GetU8());
  526. }
  527. public void SetX(float value)
  528. {
  529. //throw new NotImplementedException();
  530. }
  531. public void SetY(float value)
  532. {
  533. //throw new NotImplementedException();
  534. }
  535. public void AddX(float value)
  536. {
  537. //throw new NotImplementedException();
  538. }
  539. public void AddY(float value)
  540. {
  541. //throw new NotImplementedException();
  542. }
  543. }
  544. public struct UnitState
  545. {
  546. private uint m_ID;
  547. private byte m_UnitMainState;
  548. private byte m_UnitSubState;
  549. public uint ID { get { return m_ID; } }
  550. public UnitActionStatus UnitMainState
  551. {
  552. get { return (UnitActionStatus)m_UnitMainState; }
  553. set { m_UnitMainState = (byte)value; }
  554. }
  555. public byte UnitSubState
  556. {
  557. get { return m_UnitSubState; }
  558. set { m_UnitSubState = value; }
  559. }
  560. public void SetObject(InstanceUnit obj)
  561. {
  562. this.m_ID = obj.ID;
  563. this.m_UnitMainState = (byte)obj.CurrentActionStatus;
  564. this.m_UnitSubState = (byte)obj.CurrentActionSubstate;
  565. }
  566. internal void Write(IOutputStream output)
  567. {
  568. output.PutVU32(m_ID);
  569. output.PutU8(m_UnitMainState);
  570. output.PutU8(m_UnitSubState);
  571. //if (m_ID == 2649)
  572. //{
  573. // Console.WriteLine("SyncPos - " + this.ID + ", m_UnitMainState = " + m_UnitMainState + ", m_UnitSubState = " + m_UnitSubState);
  574. //}
  575. }
  576. internal void Read(IInputStream input)
  577. {
  578. m_ID = input.GetVU32();
  579. m_UnitMainState = input.GetU8();
  580. m_UnitSubState = input.GetU8();
  581. }
  582. }
  583. private BitSet8 mask = new BitSet8();
  584. private long pass_time_ms;
  585. public UnitPos[] units_pos;
  586. public UnitState[] units_st;
  587. public bool IsHalf
  588. {
  589. get { return mask.Get(0); }
  590. private set { mask.Set(0, value); }
  591. }
  592. public bool IsSyncZ
  593. {
  594. get { return mask.Get(1); }
  595. private set { mask.Set(1, value); }
  596. }
  597. public long PassTimeMS { get { return pass_time_ms; } }
  598. public bool IsEmpty { get { return (units_pos == null || units_pos.Length == 0) && (units_st == null || units_st.Length == 0); } }
  599. public SyncPosEvent() { }
  600. public SyncPosEvent(bool half, bool sync_z, long passtime)
  601. {
  602. this.IsHalf = half;
  603. this.IsSyncZ = sync_z;
  604. this.pass_time_ms = passtime;
  605. }
  606. override public void WriteExternal(IOutputStream output)
  607. {
  608. output.PutU8(mask.Mask);
  609. output.PutVS64(pass_time_ms);
  610. bool syncz = IsSyncZ;
  611. bool half = IsHalf;
  612. if (units_pos != null)
  613. {
  614. output.PutVS32(units_pos.Length);
  615. for (int i = 0; i < units_pos.Length; i++)
  616. {
  617. units_pos[i].Write(output, half, syncz);
  618. }
  619. }
  620. else
  621. {
  622. output.PutVS32(0);
  623. }
  624. if (units_st != null)
  625. {
  626. output.PutVS32(units_st.Length);
  627. for (int i = 0; i < units_st.Length; i++)
  628. {
  629. units_st[i].Write(output);
  630. }
  631. }
  632. else
  633. {
  634. output.PutVS32(0);
  635. }
  636. }
  637. override public void ReadExternal(IInputStream input)
  638. {
  639. this.mask.Mask = input.GetU8();
  640. this.pass_time_ms = input.GetVS64();
  641. bool syncz = IsSyncZ;
  642. bool half = IsHalf;
  643. this.units_pos = new UnitPos[input.GetVS32()];
  644. for (int i = 0; i < units_pos.Length; i++)
  645. {
  646. units_pos[i].Read(input, half, syncz);
  647. }
  648. this.units_st = new UnitState[input.GetVS32()];
  649. for (int i = 0; i < units_st.Length; i++)
  650. {
  651. //UnityEngine.Debug.Log("m_ID = "+units_st[i].ID + " UnitMainState = " +units_st[i].UnitMainState);
  652. units_st[i].Read(input);
  653. }
  654. }
  655. }
  656. /// <summary>
  657. /// 服务端通知客户端执行一段脚本
  658. /// </summary>
  659. [MessageType(0x8007)]
  660. public class DoScriptEvent : ZoneEvent
  661. {
  662. public string ScriptFileName;
  663. public DoScriptEvent() { }
  664. public DoScriptEvent(string filename)
  665. {
  666. this.ScriptFileName = filename;
  667. }
  668. override public void WriteExternal(IOutputStream output)
  669. {
  670. output.PutUTF(ScriptFileName);
  671. }
  672. override public void ReadExternal(IInputStream input)
  673. {
  674. this.ScriptFileName = input.GetUTF();
  675. }
  676. }
  677. /// <summary>
  678. /// 脚本系统指令
  679. /// </summary>
  680. [MessageType(0x8008)]
  681. public class ScriptCommandEvent : ZoneEvent
  682. {
  683. public string message;
  684. public ScriptCommandEvent() { }
  685. public ScriptCommandEvent(string msg)
  686. {
  687. this.message = msg;
  688. }
  689. override public void WriteExternal(IOutputStream output)
  690. {
  691. output.PutUTF(message);
  692. }
  693. override public void ReadExternal(IInputStream input)
  694. {
  695. this.message = input.GetUTF();
  696. }
  697. }
  698. /// <summary>
  699. /// 游戏结束指令
  700. /// </summary>
  701. [MessageType(0x8009)]
  702. public class GameOverEvent : ZoneEvent
  703. {
  704. public string message;
  705. public int WinForce;
  706. public GameOverEvent() { }
  707. public GameOverEvent(int force, string msg)
  708. {
  709. this.WinForce = force;
  710. this.message = msg;
  711. }
  712. override public void WriteExternal(IOutputStream output)
  713. {
  714. output.PutUTF(message);
  715. output.PutS32(WinForce);
  716. }
  717. override public void ReadExternal(IInputStream input)
  718. {
  719. this.message = input.GetUTF();
  720. this.WinForce = input.GetS32();
  721. }
  722. }
  723. [MessageType(0x800A)]
  724. public class DecorationChangedEvent : ZoneEvent
  725. {
  726. public string Name;
  727. public bool Enable;
  728. public DecorationChangedEvent() { }
  729. public DecorationChangedEvent(string name, bool enable)
  730. {
  731. this.Name = name;
  732. this.Enable = enable;
  733. }
  734. override public void WriteExternal(IOutputStream output)
  735. {
  736. output.PutUTF(Name);
  737. output.PutBool(Enable);
  738. }
  739. override public void ReadExternal(IInputStream input)
  740. {
  741. this.Name = input.GetUTF();
  742. this.Enable = input.GetBool();
  743. }
  744. }
  745. [MessageType(0x800B)]
  746. public class SyncEnvironmentVarEvent : ZoneEvent
  747. {
  748. public string Key;
  749. public object Value;
  750. public SyncEnvironmentVarEvent() { }
  751. public SyncEnvironmentVarEvent(string key, object value)
  752. {
  753. this.Key = key;
  754. this.Value = value;
  755. }
  756. override public void WriteExternal(IOutputStream output)
  757. {
  758. output.PutUTF(Key);
  759. output.PutData(Value);
  760. }
  761. override public void ReadExternal(IInputStream input)
  762. {
  763. DataType dtype;
  764. this.Key = input.GetUTF();
  765. this.Value = input.GetData(out dtype);
  766. }
  767. }
  768. [MessageType(0x800C)]
  769. public class ChangeBGMEvent : ZoneEvent
  770. {
  771. public string FileName;
  772. public ChangeBGMEvent() { }
  773. public ChangeBGMEvent(string file)
  774. {
  775. this.FileName = file;
  776. }
  777. override public void WriteExternal(IOutputStream output)
  778. {
  779. output.PutUTF(FileName);
  780. }
  781. override public void ReadExternal(IInputStream input)
  782. {
  783. this.FileName = input.GetUTF();
  784. }
  785. }
  786. [MessageType(0x800D)]
  787. public class FlagTagChangedEvent : ZoneEvent
  788. {
  789. public string Name;
  790. public string Tag;
  791. public FlagTagChangedEvent() { }
  792. public FlagTagChangedEvent(string name, string tag = null)
  793. {
  794. this.Name = name;
  795. this.Tag = tag;
  796. }
  797. override public void WriteExternal(IOutputStream output)
  798. {
  799. output.PutUTF(Name);
  800. output.PutUTF(Tag);
  801. }
  802. override public void ReadExternal(IInputStream input)
  803. {
  804. this.Name = input.GetUTF();
  805. this.Tag = input.GetUTF();
  806. }
  807. }
  808. #endregion
  809. //--------------------------------------------------------------------------
  810. #region OBJECT_EVENTS_0x8100
  811. /// <summary>
  812. /// 同步单位数据,频繁需要改变的数据
  813. /// </summary>
  814. [MessageType(0x8100)]
  815. public class UnitFieldChangedEvent : ObjectEvent
  816. {
  817. public const uint MASK_ALL = 0xFFFF;
  818. public const uint MASK_HP = 1;
  819. public const uint MASK_MP = 1 << 1;
  820. public const uint MASK_MAX_HP = 1 << 2;
  821. public const uint MASK_MAX_MP = 1 << 3;
  822. public const uint MASK_SPEED = 1 << 4;
  823. public const uint MASK_SP = 1 << 5;
  824. public const uint MASK_MAX_SP = 1 << 6;
  825. public const uint MASK_FCR = 1 << 7;
  826. public const uint MASK_MONEY = 1 << 8;
  827. public const uint MASK_LEVEL = 1 << 9;
  828. public const uint MASK_DUMMY_0 = 1 << 10;
  829. public const uint MASK_DUMMY_1 = 1 << 11;
  830. public const uint MASK_DUMMY_2 = 1 << 12;
  831. public const uint MASK_DUMMY_3 = 1 << 13;
  832. public const uint MASK_DUMMY_4 = 1 << 14;
  833. public const uint MASK_DUMMY_5 = 1 << 15;
  834. //-- NEW Property
  835. public const uint MASK_SKILL_CD_ACC = 1 << 16;
  836. public const uint MASK_CONTROLED_ACC = 1 << 17;
  837. public uint mask = 0;
  838. public int currentHP;
  839. public int currentMP;
  840. public int maxHP;
  841. public int maxMP;
  842. public int currentSP;
  843. public int maxSP;
  844. public float currentSpeed;
  845. public float currentFCR;
  846. public int currentMoney;
  847. public int level;
  848. public int dummy_0;
  849. public int dummy_1;
  850. public int dummy_2;
  851. public int dummy_3;
  852. public int dummy_4;
  853. public int dummy_5;
  854. //-- NEW Property
  855. public int skill_cd_acc;
  856. public int controled_acc;
  857. public UnitFieldChangedEvent() { }
  858. public UnitFieldChangedEvent(uint unit_id, ushort mask)
  859. : base(unit_id)
  860. {
  861. this.mask = mask;
  862. }
  863. override public void WriteExternal(IOutputStream output)
  864. {
  865. base.WriteExternal(output);
  866. output.PutVU32(mask);
  867. if ((mask & MASK_HP) != 0) output.PutS32(currentHP);
  868. if ((mask & MASK_MP) != 0) output.PutS32(currentMP);
  869. if ((mask & MASK_MAX_HP) != 0) output.PutS32(maxHP);
  870. if ((mask & MASK_MAX_MP) != 0) output.PutS32(maxMP);
  871. if ((mask & MASK_SP) != 0) output.PutS32(currentSP);
  872. if ((mask & MASK_MAX_SP) != 0) output.PutS32(maxSP);
  873. if ((mask & MASK_SPEED) != 0) output.PutF32(currentSpeed);
  874. if ((mask & MASK_FCR) != 0) output.PutF32(currentFCR);
  875. if ((mask & MASK_MONEY) != 0) output.PutS32(currentMoney);
  876. if ((mask & MASK_LEVEL) != 0) output.PutS32(level);
  877. if ((mask & MASK_DUMMY_0) != 0) output.PutS32(dummy_0);
  878. if ((mask & MASK_DUMMY_1) != 0) output.PutS32(dummy_1);
  879. if ((mask & MASK_DUMMY_2) != 0) output.PutS32(dummy_2);
  880. if ((mask & MASK_DUMMY_3) != 0) output.PutS32(dummy_3);
  881. if ((mask & MASK_DUMMY_4) != 0) output.PutS32(dummy_4);
  882. if ((mask & MASK_DUMMY_5) != 0) output.PutS32(dummy_5);
  883. //-- NEW Property
  884. if ((mask & MASK_SKILL_CD_ACC) != 0) output.PutS32(skill_cd_acc);
  885. if ((mask & MASK_CONTROLED_ACC) != 0) output.PutS32(controled_acc);
  886. }
  887. override public void ReadExternal(IInputStream input)
  888. {
  889. base.ReadExternal(input);
  890. this.mask = input.GetVU32();
  891. if ((mask & MASK_HP) != 0) this.currentHP = input.GetS32();
  892. if ((mask & MASK_MP) != 0) this.currentMP = input.GetS32();
  893. if ((mask & MASK_MAX_HP) != 0) this.maxHP = input.GetS32();
  894. if ((mask & MASK_MAX_MP) != 0) this.maxMP = input.GetS32();
  895. if ((mask & MASK_SP) != 0) this.currentSP = input.GetS32();
  896. if ((mask & MASK_MAX_SP) != 0) this.maxSP = input.GetS32();
  897. if ((mask & MASK_SPEED) != 0) this.currentSpeed = input.GetF32();
  898. if ((mask & MASK_FCR) != 0) this.currentFCR = input.GetF32();
  899. if ((mask & MASK_MONEY) != 0) this.currentMoney = input.GetS32();
  900. if ((mask & MASK_LEVEL) != 0) this.level = input.GetS32();
  901. if ((mask & MASK_DUMMY_0) != 0) this.dummy_0 = input.GetS32();
  902. if ((mask & MASK_DUMMY_1) != 0) this.dummy_1 = input.GetS32();
  903. if ((mask & MASK_DUMMY_2) != 0) this.dummy_2 = input.GetS32();
  904. if ((mask & MASK_DUMMY_3) != 0) this.dummy_3 = input.GetS32();
  905. if ((mask & MASK_DUMMY_4) != 0) this.dummy_4 = input.GetS32();
  906. if ((mask & MASK_DUMMY_5) != 0) this.dummy_5 = input.GetS32();
  907. //-- NEW Property
  908. if ((mask & MASK_SKILL_CD_ACC) != 0) this.skill_cd_acc = input.GetS32();
  909. if ((mask & MASK_CONTROLED_ACC) != 0) this.controled_acc = input.GetS32();
  910. }
  911. }
  912. /// <summary>
  913. /// 单位进入吟唱状态
  914. /// </summary>
  915. [MessageType(0x810a)]
  916. public class UnitChantSkillEvent : ObjectEvent
  917. {
  918. public int skill_id;
  919. public int chant_ms;
  920. public UnitChantSkillEvent() { }
  921. public UnitChantSkillEvent(uint unit_id, SkillTemplate sk)
  922. : base(unit_id)
  923. {
  924. this.skill_id = sk.TemplateID;
  925. this.chant_ms = sk.ChantTimeMS;
  926. }
  927. override public void WriteExternal(IOutputStream output)
  928. {
  929. base.WriteExternal(output);
  930. output.PutS32(skill_id);
  931. output.PutVS32(chant_ms);
  932. }
  933. override public void ReadExternal(IInputStream input)
  934. {
  935. base.ReadExternal(input);
  936. this.skill_id = input.GetS32();
  937. this.chant_ms = input.GetVS32();
  938. }
  939. }
  940. /// <summary>
  941. /// 单位进入技能状态
  942. /// </summary>
  943. [MessageType(0x810b)]
  944. public class UnitLaunchSkillEvent : ObjectEvent
  945. {
  946. public int skill_id { get; private set; }
  947. /// <summary>
  948. /// 如果是单一动作,则标识是哪一段攻击
  949. /// </summary>
  950. public byte action_index { get; private set; }
  951. /// <summary>
  952. /// 技能每段动作的时间,单一动作的话(SkillTemplate.IsSingleAction),长度为1
  953. /// </summary>
  954. public int[] action_time_array { get; private set; }
  955. public int TotalCDTimeMS { get; private set; }
  956. public float action_speed { get; private set; }
  957. public Vector2 spell_target_pos { get; private set; }
  958. public uint target_object_id { get; private set; }
  959. //节点动作加速(加法)
  960. public float [] action_speed_add { get; private set; }
  961. private BitSet8 bitMask = new BitSet8();
  962. public bool IsSingleAction
  963. {
  964. get { return bitMask.Get(0); }
  965. private set { bitMask.Set(0, value); }
  966. }
  967. public bool ActionSpeedAddition
  968. {
  969. get { return bitMask.Get(1); }
  970. private set { bitMask.Set(1, value); }
  971. }
  972. public bool IsActionSpeedUP
  973. {
  974. get { return bitMask.Get(2); }
  975. private set { bitMask.Set(2, value); }
  976. }
  977. public bool IsActionTimeChanged
  978. {
  979. get { return bitMask.Get(3); }
  980. private set { bitMask.Set(3, value); }
  981. }
  982. public bool IsAutoFocusNearTarget
  983. {
  984. get { return bitMask.Get(4); }
  985. private set { bitMask.Set(4, value); }
  986. }
  987. public bool IsSpellTargetPos
  988. {
  989. get { return bitMask.Get(5); }
  990. private set { bitMask.Set(5, value); }
  991. }
  992. public bool IsTargetObject
  993. {
  994. get { return bitMask.Get(6); }
  995. private set { bitMask.Set(6, value); }
  996. }
  997. public bool IsChangeTotalCDTime
  998. {
  999. get { return bitMask.Get(7); }
  1000. private set { bitMask.Set(7, value); }
  1001. }
  1002. public int TotalActionTimeMS
  1003. {
  1004. get
  1005. {
  1006. int total = 0;
  1007. if (action_time_array != null)
  1008. {
  1009. foreach (int timeMS in action_time_array)
  1010. {
  1011. total += timeMS;
  1012. }
  1013. }
  1014. return total;
  1015. }
  1016. }
  1017. public UnitLaunchSkillEvent() { }
  1018. public UnitLaunchSkillEvent(
  1019. uint unit_id,
  1020. SkillTemplate sk,
  1021. byte actionIndex,
  1022. float actionSpeed,
  1023. int totalCDTimeMS,
  1024. bool isAutoFaceToTarget,
  1025. Vector2 spellTargetPos,
  1026. uint targetObjectID,
  1027. int lockActionStep)
  1028. : base(unit_id)
  1029. {
  1030. this.skill_id = sk.TemplateID;
  1031. this.action_speed = actionSpeed;
  1032. this.TotalCDTimeMS = totalCDTimeMS;
  1033. this.spell_target_pos = spellTargetPos;
  1034. this.target_object_id = targetObjectID;
  1035. this.IsAutoFocusNearTarget = isAutoFaceToTarget;
  1036. this.IsSingleAction = sk.IsSingleAction;
  1037. this.IsActionSpeedUP = (actionSpeed != 1f);
  1038. this.IsTargetObject = (targetObjectID != 0);
  1039. this.IsSpellTargetPos = spellTargetPos != null;
  1040. this.IsChangeTotalCDTime = totalCDTimeMS != sk.CoolDownMS;
  1041. this.action_speed_add = new float[sk.ActionQueue.Count];
  1042. for(int i = 0; i < sk.ActionQueue.Count; i++)
  1043. {
  1044. if(sk.ActionQueue[i].ActionSpeedRate != 0.0f)
  1045. {
  1046. this.action_speed_add[i] = sk.ActionQueue[i].ActionSpeedRate;
  1047. this.ActionSpeedAddition = true;
  1048. }
  1049. }
  1050. if (sk.IsSingleAction || lockActionStep >= 0)
  1051. {
  1052. this.action_index = actionIndex;
  1053. this.action_time_array = new int[] { sk.ActionQueue[actionIndex].TotalTimeMS };
  1054. }
  1055. else
  1056. {
  1057. this.action_index = 0;
  1058. this.action_time_array = sk.ActionQueueTimeArray;
  1059. }
  1060. }
  1061. public override void BeforeWrite(TemplateManager templates)
  1062. {
  1063. base.BeforeWrite(templates);
  1064. var orgin_temp = templates.getSkill(skill_id);
  1065. if (this.action_time_array == null)
  1066. {
  1067. this.IsActionTimeChanged = false;
  1068. }
  1069. else if (this.IsSingleAction)
  1070. {
  1071. this.IsActionTimeChanged = (this.action_time_array[0] != orgin_temp.ActionQueue[action_index].TotalTimeMS);
  1072. }
  1073. else
  1074. {
  1075. this.IsActionTimeChanged = !CUtils.ArraysEqual<int>(this.action_time_array, orgin_temp.ActionQueueTimeArray);
  1076. }
  1077. }
  1078. public override void EndRead(TemplateManager templates)
  1079. {
  1080. base.EndRead(templates);
  1081. }
  1082. override public void WriteExternal(IOutputStream output)
  1083. {
  1084. base.WriteExternal(output);
  1085. output.PutS32(skill_id);
  1086. output.PutU8(bitMask.Mask);
  1087. if (IsSingleAction)
  1088. {
  1089. output.PutU8(action_index);
  1090. if (IsActionTimeChanged) output.PutS32(action_time_array[0]);
  1091. }
  1092. else
  1093. {
  1094. if (IsActionTimeChanged) output.PutArray<int>(action_time_array, output.PutS32);
  1095. }
  1096. if (IsActionSpeedUP)
  1097. {
  1098. output.PutF32(action_speed);
  1099. }
  1100. if (IsChangeTotalCDTime)
  1101. {
  1102. output.PutVS32(TotalCDTimeMS);
  1103. }
  1104. if (IsTargetObject)
  1105. {
  1106. output.PutU32(this.target_object_id);
  1107. }
  1108. if (IsSpellTargetPos)
  1109. {
  1110. output.PutF32(spell_target_pos.X);
  1111. output.PutF32(spell_target_pos.Y);
  1112. }
  1113. if(ActionSpeedAddition)
  1114. {
  1115. output.PutArray<float>(this.action_speed_add, output.PutF32);
  1116. }
  1117. //System.Console.WriteLine("释放技能:" + this.skill_id + ", " + this.action_index);
  1118. }
  1119. override public void ReadExternal(IInputStream input)
  1120. {
  1121. base.ReadExternal(input);
  1122. this.skill_id = input.GetS32();
  1123. this.bitMask.Mask = input.GetU8();
  1124. if (IsSingleAction)
  1125. {
  1126. this.action_index = input.GetU8();
  1127. if (IsActionTimeChanged) this.action_time_array = new int[] { input.GetS32() };
  1128. }
  1129. else
  1130. {
  1131. if (IsActionTimeChanged) this.action_time_array = input.GetArray<int>(input.GetS32);
  1132. }
  1133. if (IsActionSpeedUP)
  1134. {
  1135. this.action_speed = input.GetF32();
  1136. }
  1137. else
  1138. {
  1139. this.action_speed = 1f;
  1140. }
  1141. if (IsChangeTotalCDTime)
  1142. {
  1143. this.TotalCDTimeMS = input.GetVS32();
  1144. }
  1145. if (IsTargetObject)
  1146. {
  1147. this.target_object_id = input.GetU32();
  1148. }
  1149. if (IsSpellTargetPos)
  1150. {
  1151. spell_target_pos = new Vector2();
  1152. spell_target_pos.SetX(input.GetF32());
  1153. spell_target_pos.SetY(input.GetF32());
  1154. }
  1155. if (ActionSpeedAddition)
  1156. {
  1157. this.action_speed_add = input.GetArray<float>(input.GetF32);
  1158. }
  1159. }
  1160. public override string ToString()
  1161. {
  1162. return string.Format("LaunchSkill: {0}@{1}", skill_id, action_index);
  1163. }
  1164. }
  1165. /// <summary>
  1166. /// 单位动作中击中别的单位
  1167. /// </summary>
  1168. [MessageType(0x810d)]
  1169. public class UnitEffectEvent : ObjectEvent
  1170. {
  1171. private uint effect_sn = 0;
  1172. /// <summary>
  1173. /// 特效名字
  1174. /// </summary>
  1175. public LaunchEffect effect { get; set; }
  1176. public UnitEffectEvent() { }
  1177. public UnitEffectEvent(uint unit_id, LaunchEffect effect)
  1178. : base(unit_id)
  1179. {
  1180. this.effect = effect;
  1181. }
  1182. override public void WriteExternal(IOutputStream output)
  1183. {
  1184. base.WriteExternal(output);
  1185. output.PutVU32(effect_sn);
  1186. }
  1187. override public void ReadExternal(IInputStream input)
  1188. {
  1189. base.ReadExternal(input);
  1190. this.effect_sn = input.GetVU32();
  1191. }
  1192. public override void BeforeWrite(TemplateManager templates)
  1193. {
  1194. if (effect != null)
  1195. {
  1196. this.effect_sn = effect.SerialNumber;
  1197. }
  1198. }
  1199. public override void EndRead(TemplateManager templates)
  1200. {
  1201. this.effect = templates.GetSnData<LaunchEffect>(effect_sn);
  1202. }
  1203. }
  1204. /// <summary>
  1205. /// 单位仅做一个动作
  1206. /// </summary>
  1207. [MessageType(0x810e)]
  1208. public class UnitDoActionEvent : ObjectEvent
  1209. {
  1210. public string ActionName;
  1211. public UnitDoActionEvent() { }
  1212. public UnitDoActionEvent(uint unit_id, string actionName)
  1213. : base(unit_id)
  1214. {
  1215. this.ActionName = actionName;
  1216. }
  1217. override public void WriteExternal(IOutputStream output)
  1218. {
  1219. base.WriteExternal(output);
  1220. output.PutUTF(ActionName);
  1221. }
  1222. override public void ReadExternal(IInputStream input)
  1223. {
  1224. base.ReadExternal(input);
  1225. ActionName = input.GetUTF();
  1226. }
  1227. }
  1228. /// <summary>
  1229. /// 单位被击中
  1230. /// </summary>
  1231. [MessageType(0x810f)]
  1232. public class UnitHitEvent : ObjectEvent
  1233. {
  1234. public bool isDead
  1235. {
  1236. get { return BitMask.BitGetMask(bitMask, 0); }
  1237. set { BitMask.BitSetMask(ref bitMask, 0, value); }
  1238. }
  1239. //特殊来源的伤害
  1240. public bool isSpecialHit
  1241. {
  1242. get { return BitMask.BitGetMask(bitMask, 1); }
  1243. set { BitMask.BitSetMask(ref bitMask, 1, value); }
  1244. }
  1245. public bool isCritical
  1246. {
  1247. get { return BitMask.BitGetMask(bitMask, 2); }
  1248. set { BitMask.BitSetMask(ref bitMask, 2, value); }
  1249. }
  1250. public bool HasEffect
  1251. {
  1252. get { return BitMask.BitGetMask(bitMask, 3); }
  1253. private set { BitMask.BitSetMask(ref bitMask, 3, value); }
  1254. }
  1255. public bool HasSourceAttack
  1256. {
  1257. get { return BitMask.BitGetMask(bitMask, 6); }
  1258. private set { BitMask.BitSetMask(ref bitMask, 6, value); }
  1259. }
  1260. public uint senderId;
  1261. public int hp;
  1262. public byte client_state;
  1263. private byte bitMask = 0;
  1264. private LaunchEffect biteffect;
  1265. private uint biteffect_sn;
  1266. private AttackProp sourceAttack;
  1267. private uint sourceAttack_sn;
  1268. // 伤害来源,非def才需要额外处理
  1269. public DamageSource dmgSrc;
  1270. //内部字段
  1271. //针对特殊伤害的特殊处理
  1272. public bool InViewForceSend = false;
  1273. public uint senderMasterId; //如果sender为召唤物,这个存放主人id(用来广播判断,非网络字段)
  1274. public uint hitMasterId; //单位的masterid
  1275. public LaunchEffect effect
  1276. {
  1277. get { return biteffect; }
  1278. set
  1279. {
  1280. this.biteffect = value;
  1281. this.HasEffect = (value != null);
  1282. }
  1283. }
  1284. public AttackProp SourceAttack
  1285. {
  1286. get { return sourceAttack; }
  1287. set
  1288. {
  1289. this.sourceAttack = value;
  1290. this.HasSourceAttack = (value != null);
  1291. }
  1292. }
  1293. public UnitHitEvent() { }
  1294. public UnitHitEvent(uint unit_id)
  1295. : base(unit_id)
  1296. {
  1297. }
  1298. override public void WriteExternal(IOutputStream output)
  1299. {
  1300. base.WriteExternal(output);
  1301. output.PutVU32(senderId);
  1302. output.PutVS32(hp);
  1303. output.PutU8(client_state);
  1304. output.PutU8(bitMask);
  1305. if (HasEffect)
  1306. {
  1307. output.PutVU32(biteffect_sn);
  1308. }
  1309. if (HasSourceAttack)
  1310. {
  1311. output.PutVU32(sourceAttack_sn);
  1312. }
  1313. if(isSpecialHit)
  1314. {
  1315. output.PutEnum8(dmgSrc);
  1316. }
  1317. //Console.WriteLine("WWW.object_id: " + object_id + ", senderId: " + senderId + ", hp: " + this.hp + ", mask : " + this.bitMask);
  1318. }
  1319. override public void ReadExternal(IInputStream input)
  1320. {
  1321. base.ReadExternal(input);
  1322. this.senderId = input.GetVU32();
  1323. this.hp = input.GetVS32();
  1324. this.client_state = input.GetU8();
  1325. this.bitMask = input.GetU8();
  1326. if (HasEffect)
  1327. {
  1328. this.biteffect_sn = input.GetVU32();
  1329. }
  1330. if (HasSourceAttack)
  1331. {
  1332. this.sourceAttack_sn = input.GetVU32();
  1333. }
  1334. if(isSpecialHit)
  1335. {
  1336. this.dmgSrc = input.GetEnum8<DamageSource>();
  1337. }
  1338. //System.Console.WriteLine("sdfasdf: " + isSpecialHit + ", " + this.dmgSrc);
  1339. //UnityEngine.Debug.LogError("RRR.object_id: " + object_id + ", senderId: " + senderId + ", hp: " + this.hp + ", mask : " + this.bitMask);
  1340. }
  1341. public override void BeforeWrite(TemplateManager templates)
  1342. {
  1343. if (HasEffect)
  1344. {
  1345. this.biteffect_sn = biteffect.SerialNumber;
  1346. }
  1347. if (HasSourceAttack)
  1348. {
  1349. this.sourceAttack_sn = sourceAttack.SerialNumber;
  1350. }
  1351. }
  1352. public override void EndRead(TemplateManager templates)
  1353. {
  1354. if (HasEffect)
  1355. {
  1356. this.biteffect = templates.GetSnData<LaunchEffect>(biteffect_sn);
  1357. }
  1358. if (HasSourceAttack)
  1359. {
  1360. this.sourceAttack = templates.GetSnData<AttackProp>(sourceAttack_sn);
  1361. }
  1362. }
  1363. }
  1364. /// <summary>
  1365. /// 单位被击中
  1366. /// </summary>
  1367. [MessageType(0x8111)]
  1368. public class UnitDeadEvent : ObjectEvent
  1369. {
  1370. public bool Crushed;
  1371. public uint attacker_id;
  1372. public int RebirthTimeMS;
  1373. public UnitDeadEvent() { }
  1374. public UnitDeadEvent(uint unit_id, uint attacker_id, bool crushed, int rebirthTimeMS)
  1375. : base(unit_id)
  1376. {
  1377. this.Crushed = crushed;
  1378. this.attacker_id = attacker_id;
  1379. this.RebirthTimeMS = rebirthTimeMS;
  1380. }
  1381. override public void WriteExternal(IOutputStream output)
  1382. {
  1383. base.WriteExternal(output);
  1384. output.PutBool(Crushed);
  1385. output.PutVU32(attacker_id);
  1386. output.PutVS32(RebirthTimeMS);
  1387. }
  1388. override public void ReadExternal(IInputStream input)
  1389. {
  1390. base.ReadExternal(input);
  1391. this.Crushed = input.GetBool();
  1392. this.attacker_id = input.GetVU32();
  1393. this.RebirthTimeMS = input.GetVS32();
  1394. }
  1395. }
  1396. /// <summary>
  1397. /// 单位中BUFF
  1398. /// </summary>
  1399. [MessageType(0x8112)]
  1400. public class UnitLaunchBuffEvent : ObjectEvent
  1401. {
  1402. public bool IsEquip
  1403. {
  1404. get { return BitMask.BitGetMask(bitMask, 0); }
  1405. set { BitMask.BitSetMask(ref bitMask, 0, value); }
  1406. }
  1407. public bool IsOverlayLevel
  1408. {
  1409. get { return BitMask.BitGetMask(bitMask, 1); }
  1410. set { BitMask.BitSetMask(ref bitMask, 1, value); }
  1411. }
  1412. public bool IsHasExtData
  1413. {
  1414. get { return BitMask.BitGetMask(bitMask, 2); }
  1415. set { BitMask.BitSetMask(ref bitMask, 2, value); }
  1416. }
  1417. private byte bitMask = 0;
  1418. public int buffTemplateID;
  1419. public int buffTimeMS;
  1420. public byte overlayLevel;
  1421. public uint senderID;
  1422. public int buffExtData; //buff的扩展字段,
  1423. public UnitLaunchBuffEvent() { }
  1424. public UnitLaunchBuffEvent(uint unit_id, int buffID, uint senderID, int timeMS, bool equip, byte overlayLevel, int extData)
  1425. : base(unit_id)
  1426. {
  1427. this.buffTemplateID = buffID;
  1428. this.buffTimeMS = timeMS;
  1429. this.senderID = senderID;
  1430. this.IsEquip = equip;
  1431. if (overlayLevel > 0)
  1432. {
  1433. this.IsOverlayLevel = true;
  1434. this.overlayLevel = overlayLevel;
  1435. }
  1436. if(extData > 0)
  1437. {
  1438. this.IsHasExtData = true;
  1439. this.buffExtData = extData;
  1440. }
  1441. }
  1442. override public void WriteExternal(IOutputStream output)
  1443. {
  1444. base.WriteExternal(output);
  1445. output.PutU8(bitMask);
  1446. output.PutS32(buffTemplateID);
  1447. output.PutVU32(senderID);
  1448. if (!IsEquip)
  1449. {
  1450. output.PutVS32(buffTimeMS);
  1451. }
  1452. if (IsOverlayLevel)
  1453. {
  1454. output.PutU8(overlayLevel);
  1455. }
  1456. if (IsHasExtData)
  1457. {
  1458. output.PutVS32(buffExtData);
  1459. }
  1460. //System.Console.WriteLine("UnitLaunchBuffEvent: " + buffTemplateID + ", " + buffTimeMS);
  1461. }
  1462. override public void ReadExternal(IInputStream input)
  1463. {
  1464. base.ReadExternal(input);
  1465. this.bitMask = input.GetU8();
  1466. this.buffTemplateID = input.GetS32();
  1467. this.senderID = input.GetVU32();
  1468. if (!IsEquip)
  1469. {
  1470. this.buffTimeMS = input.GetVS32();
  1471. }
  1472. if (IsOverlayLevel)
  1473. {
  1474. this.overlayLevel = input.GetU8();
  1475. }
  1476. if (IsHasExtData)
  1477. {
  1478. this.buffExtData = input.GetVS32();
  1479. }
  1480. }
  1481. }
  1482. /// <summary>
  1483. /// 单位停止BUFF
  1484. /// </summary>
  1485. [MessageType(0x8113)]
  1486. public class UnitStopBuffEvent : ObjectEvent
  1487. {
  1488. public int buffTemplateID;
  1489. public uint senderID;
  1490. public UnitStopBuffEvent() { }
  1491. public UnitStopBuffEvent(uint unit_id, int buffID, uint senderID)
  1492. : base(unit_id)
  1493. {
  1494. this.buffTemplateID = buffID;
  1495. this.senderID = senderID;
  1496. }
  1497. override public void WriteExternal(IOutputStream output)
  1498. {
  1499. base.WriteExternal(output);
  1500. output.PutS32(buffTemplateID);
  1501. output.PutVU32(senderID);
  1502. }
  1503. override public void ReadExternal(IInputStream input)
  1504. {
  1505. base.ReadExternal(input);
  1506. this.buffTemplateID = input.GetS32();
  1507. this.senderID = input.GetVU32();
  1508. }
  1509. }
  1510. /// <summary>
  1511. /// 单位同步【库存道具】
  1512. /// </summary>
  1513. [MessageType(0x8114)]
  1514. public class UnitSyncInventoryItemEvent : ObjectEvent, ActorMessage
  1515. {
  1516. public int ItemTemplateID;
  1517. public int Index;
  1518. public int Count;
  1519. public UnitSyncInventoryItemEvent() { }
  1520. public UnitSyncInventoryItemEvent(uint unit_id, int itemID, int index, int count)
  1521. : base(unit_id)
  1522. {
  1523. this.ItemTemplateID = itemID;
  1524. this.Index = index;
  1525. this.Count = count;
  1526. }
  1527. override public void WriteExternal(IOutputStream output)
  1528. {
  1529. base.WriteExternal(output);
  1530. output.PutS32(ItemTemplateID);
  1531. output.PutVS32(Index);
  1532. output.PutVS32(Count);
  1533. }
  1534. override public void ReadExternal(IInputStream input)
  1535. {
  1536. base.ReadExternal(input);
  1537. this.ItemTemplateID = input.GetS32();
  1538. this.Index = input.GetVS32();
  1539. this.Count = input.GetVS32();
  1540. }
  1541. }
  1542. /// <summary>
  1543. /// 单位使用道具
  1544. /// </summary>
  1545. [MessageType(0x8115)]
  1546. public class UnitUseItemEvent : ObjectEvent, ActorMessage
  1547. {
  1548. public int ItemTemplateID;
  1549. public UnitUseItemEvent() { }
  1550. public UnitUseItemEvent(uint unit_id, int itemID)
  1551. : base(unit_id)
  1552. {
  1553. this.ItemTemplateID = itemID;
  1554. }
  1555. override public void WriteExternal(IOutputStream output)
  1556. {
  1557. base.WriteExternal(output);
  1558. output.PutS32(ItemTemplateID);
  1559. }
  1560. override public void ReadExternal(IInputStream input)
  1561. {
  1562. base.ReadExternal(input);
  1563. this.ItemTemplateID = input.GetS32();
  1564. }
  1565. }
  1566. [MessageType(0x8116)]
  1567. public class UnitSyncMultiTimeLine : ObjectEvent
  1568. {
  1569. public List<bool> timelines;
  1570. public UnitSyncMultiTimeLine() { }
  1571. public UnitSyncMultiTimeLine(uint unit_id) : base(unit_id) { }
  1572. public bool Update(List<MultiTimeLine> tlines)
  1573. {
  1574. bool ret = false;
  1575. if (timelines == null)
  1576. {
  1577. timelines = new List<bool>(tlines.Count);
  1578. }
  1579. if (timelines.Count != tlines.Count)
  1580. {
  1581. CUtils.SetListSize<bool>(timelines, tlines.Count);
  1582. ret = true;
  1583. }
  1584. for (int i = tlines.Count - 1; i >= 0; --i)
  1585. {
  1586. if (timelines[i] != tlines[i].Enable)
  1587. {
  1588. timelines[i] = tlines[i].Enable;
  1589. ret = true;
  1590. }
  1591. }
  1592. return ret;
  1593. }
  1594. override public void WriteExternal(IOutputStream output)
  1595. {
  1596. base.WriteExternal(output);
  1597. output.PutList(timelines, output.PutBool);
  1598. }
  1599. override public void ReadExternal(IInputStream input)
  1600. {
  1601. base.ReadExternal(input);
  1602. this.timelines = input.GetList<bool>(input.GetBool);
  1603. }
  1604. }
  1605. /// <summary>
  1606. /// 单位复活
  1607. /// </summary>
  1608. [MessageType(0x8117)]
  1609. public class UnitRebirthEvent : ObjectEvent
  1610. {
  1611. public UnitRebirthEvent() { }
  1612. public UnitRebirthEvent(uint unit_id) : base(unit_id) { }
  1613. }
  1614. /// <summary>
  1615. /// 用户连斩数
  1616. /// </summary>
  1617. [MessageType(0x8118)]
  1618. public class UnitContinueKillValue : ObjectEvent
  1619. {
  1620. public short continuekills;
  1621. public UnitContinueKillValue() { }
  1622. public UnitContinueKillValue(uint unit_id, short continuekills)
  1623. : base(unit_id)
  1624. {
  1625. this.continuekills = continuekills;
  1626. }
  1627. override public void WriteExternal(IOutputStream output)
  1628. {
  1629. base.WriteExternal(output);
  1630. output.PutS16(continuekills);
  1631. }
  1632. override public void ReadExternal(IInputStream input)
  1633. {
  1634. base.ReadExternal(input);
  1635. continuekills = input.GetS16();
  1636. }
  1637. }
  1638. /// <summary>
  1639. /// 单位受攻击
  1640. /// </summary>
  1641. [MessageType(0x8119)]
  1642. public class UnitDamageEvent : ObjectEvent
  1643. {
  1644. public bool HasDamageTime
  1645. {
  1646. get { return mask.Get(0); }
  1647. private set { mask.Set(0, value); }
  1648. }
  1649. public bool HasFly
  1650. {
  1651. get { return mask.Get(1); }
  1652. private set { mask.Set(1, value); }
  1653. }
  1654. public bool HasZLimit
  1655. {
  1656. get { return mask.Get(2); }
  1657. private set { mask.Set(2, value); }
  1658. }
  1659. public bool HasKnockDown
  1660. {
  1661. get { return mask.Get(3); }
  1662. private set { mask.Set(3, value); }
  1663. }
  1664. public bool HasZGravity
  1665. {
  1666. get { return mask.Get(4); }
  1667. private set { mask.Set(4, value); }
  1668. }
  1669. public bool HasMoveTime
  1670. {
  1671. get { return mask.Get(5); }
  1672. private set { mask.Set(5, value); }
  1673. }
  1674. public AttackProp Source { get; private set; }
  1675. /// <summary>
  1676. /// 总共受击时间(位移时间+受击时间)
  1677. /// </summary>
  1678. public int TotalTimeMS
  1679. {
  1680. get { return MoveTimeMS + DamageTimeMS; }
  1681. }
  1682. /// <summary>
  1683. /// 特殊受击动作
  1684. /// </summary>
  1685. public string DamageActionName
  1686. {
  1687. get { return Source.DamageActionName; }
  1688. }
  1689. /// <summary>
  1690. /// 受击的特殊动作
  1691. /// </summary>
  1692. public bool HasDamageAction
  1693. {
  1694. get { return !string.IsNullOrEmpty(Source.DamageActionName); }
  1695. }
  1696. private BitSet8 mask = new BitSet8();
  1697. private uint source_sn = 0;
  1698. public int DamageTimeMS = 0;
  1699. public int MoveTimeMS = 0;
  1700. public float ZSpeedSEC = 0;
  1701. public float ZLimit = 0;
  1702. public float ZGravity = 0;
  1703. public UnitDamageEvent() { }
  1704. public UnitDamageEvent(uint unit_id, int damageTimeMS, int moveTimeMS, float zspeed, float zgravity, float zlimit, bool knockDown, AttackProp source)
  1705. : base(unit_id)
  1706. {
  1707. this.Source = source;
  1708. this.DamageTimeMS = damageTimeMS;
  1709. this.MoveTimeMS = moveTimeMS;
  1710. this.ZSpeedSEC = zspeed;
  1711. this.ZLimit = zlimit;
  1712. this.ZGravity = zgravity;
  1713. this.HasDamageTime = (DamageTimeMS != 0);
  1714. this.HasMoveTime = (MoveTimeMS != 0);
  1715. this.HasFly = (zspeed != 0);
  1716. this.HasZGravity = (zgravity != 0);
  1717. this.HasZLimit = (zlimit > 0);
  1718. this.HasKnockDown = knockDown;
  1719. }
  1720. override public void WriteExternal(IOutputStream output)
  1721. {
  1722. base.WriteExternal(output);
  1723. output.PutU8(mask.Mask);
  1724. output.PutVU32(source_sn);
  1725. if (HasDamageTime)
  1726. {
  1727. output.PutVS32(DamageTimeMS);
  1728. }
  1729. if (HasMoveTime)
  1730. {
  1731. output.PutVS32(MoveTimeMS);
  1732. }
  1733. if (HasFly)
  1734. {
  1735. output.PutF32(ZSpeedSEC);
  1736. }
  1737. if (HasZLimit)
  1738. {
  1739. output.PutF32(ZLimit);
  1740. }
  1741. if (HasZGravity)
  1742. {
  1743. output.PutF32(ZGravity);
  1744. }
  1745. }
  1746. override public void ReadExternal(IInputStream input)
  1747. {
  1748. base.ReadExternal(input);
  1749. this.mask.Mask = input.GetU8();
  1750. this.source_sn = input.GetVU32();
  1751. if (HasDamageTime)
  1752. {
  1753. this.DamageTimeMS = input.GetVS32();
  1754. }
  1755. if (HasMoveTime)
  1756. {
  1757. this.MoveTimeMS = input.GetVS32();
  1758. }
  1759. if (HasFly)
  1760. {
  1761. this.ZSpeedSEC = input.GetF32();
  1762. }
  1763. if (HasZLimit)
  1764. {
  1765. this.ZLimit = input.GetF32();
  1766. }
  1767. if (HasZGravity)
  1768. {
  1769. this.ZGravity = input.GetF32();
  1770. }
  1771. }
  1772. public override void BeforeWrite(TemplateManager templates)
  1773. {
  1774. if (Source != null)
  1775. {
  1776. this.source_sn = Source.SerialNumber;
  1777. }
  1778. }
  1779. public override void EndRead(TemplateManager templates)
  1780. {
  1781. if (source_sn != 0)
  1782. {
  1783. this.Source = templates.GetSnData<AttackProp>(source_sn);
  1784. }
  1785. }
  1786. }
  1787. /// <summary>
  1788. /// 技能动作序列被意外取消
  1789. /// </summary>
  1790. [MessageType(0x811A)]
  1791. public class UnitSkillActionChangeEvent : ObjectEvent
  1792. {
  1793. public byte ActionIndex;
  1794. public UnitSkillActionChangeEvent() { }
  1795. public UnitSkillActionChangeEvent(uint unit_id, byte index)
  1796. : base(unit_id)
  1797. {
  1798. this.ActionIndex = index;
  1799. }
  1800. override public void WriteExternal(IOutputStream output)
  1801. {
  1802. base.WriteExternal(output);
  1803. output.PutU8(ActionIndex);
  1804. }
  1805. override public void ReadExternal(IInputStream input)
  1806. {
  1807. base.ReadExternal(input);
  1808. this.ActionIndex = input.GetU8();
  1809. }
  1810. }
  1811. /// <summary>
  1812. /// 单位开始检取道具读条
  1813. /// </summary>
  1814. [MessageType(0x811B)]
  1815. public class UnitStartPickObjectEvent : ObjectEvent
  1816. {
  1817. public int PickTimeMS;
  1818. public uint PickObjectID;
  1819. public string PickStatus;
  1820. public UnitStartPickObjectEvent() { }
  1821. public UnitStartPickObjectEvent(uint unit_id, int pickTimeMS, uint pickObjID, string status)
  1822. : base(unit_id)
  1823. {
  1824. this.PickTimeMS = pickTimeMS;
  1825. this.PickObjectID = pickObjID;
  1826. this.PickStatus = status;
  1827. }
  1828. override public void WriteExternal(IOutputStream output)
  1829. {
  1830. base.WriteExternal(output);
  1831. output.PutVS32(PickTimeMS);
  1832. output.PutVU32(PickObjectID);
  1833. output.PutUTF(PickStatus);
  1834. }
  1835. override public void ReadExternal(IInputStream input)
  1836. {
  1837. base.ReadExternal(input);
  1838. this.PickTimeMS = input.GetVS32();
  1839. this.PickObjectID = input.GetVU32();
  1840. this.PickStatus = input.GetUTF();
  1841. }
  1842. }
  1843. [MessageType(0x811C)]
  1844. public class UnitStopPickObjectEvent : ObjectEvent
  1845. {
  1846. public string StopReason;
  1847. public UnitStopPickObjectEvent() { }
  1848. public UnitStopPickObjectEvent(uint unit_id, string reason)
  1849. : base(unit_id)
  1850. {
  1851. this.StopReason = reason;
  1852. }
  1853. override public void WriteExternal(IOutputStream output)
  1854. {
  1855. base.WriteExternal(output);
  1856. output.PutUTF(StopReason);
  1857. }
  1858. override public void ReadExternal(IInputStream input)
  1859. {
  1860. base.ReadExternal(input);
  1861. this.StopReason = input.GetUTF();
  1862. }
  1863. }
  1864. /// <summary>
  1865. /// 单位从场景中获得道具
  1866. /// </summary>
  1867. [MessageType(0x811D)]
  1868. public class UnitGotInstanceItemEvent : ObjectEvent, ActorMessage
  1869. {
  1870. public uint ItemObjectID;
  1871. public byte flag; //0-后续可以继续采集,1-后续不可继续采集
  1872. public UnitGotInstanceItemEvent() { }
  1873. public UnitGotInstanceItemEvent(uint unit_id, uint pickObjID, byte flag = 0)
  1874. : base(unit_id)
  1875. {
  1876. this.ItemObjectID = pickObjID;
  1877. this.flag = flag;
  1878. }
  1879. override public void WriteExternal(IOutputStream output)
  1880. {
  1881. base.WriteExternal(output);
  1882. output.PutU32(ItemObjectID);
  1883. }
  1884. override public void ReadExternal(IInputStream input)
  1885. {
  1886. base.ReadExternal(input);
  1887. this.ItemObjectID = input.GetU32();
  1888. }
  1889. }
  1890. /// <summary>
  1891. /// 别的单位释放技能跳起
  1892. /// </summary>
  1893. [MessageType(0x811E)]
  1894. public class UnitJumpEvent : ObjectEvent
  1895. {
  1896. public float ZSpeed;
  1897. public float ZLimit;
  1898. public float ZGravity;
  1899. public UnitJumpEvent() { }
  1900. public UnitJumpEvent(uint unit_id, float zspeed, float zgravity, float zlimit)
  1901. : base(unit_id)
  1902. {
  1903. this.ZSpeed = zspeed;
  1904. this.ZLimit = zlimit;
  1905. this.ZGravity = zgravity;
  1906. }
  1907. override public void WriteExternal(IOutputStream output)
  1908. {
  1909. base.WriteExternal(output);
  1910. output.PutF32(ZSpeed);
  1911. output.PutF32(ZLimit);
  1912. output.PutF32(ZGravity);
  1913. }
  1914. override public void ReadExternal(IInputStream input)
  1915. {
  1916. base.ReadExternal(input);
  1917. this.ZSpeed = input.GetF32();
  1918. this.ZLimit = input.GetF32();
  1919. this.ZGravity = input.GetF32();
  1920. }
  1921. }
  1922. /// <summary>
  1923. /// 立即同步客户端坐标,比如单位传送之类,用于MoveByClient的模式
  1924. /// </summary>
  1925. [MessageType(0x811F)]
  1926. public class UnitForceSyncPosEvent : ObjectEvent
  1927. {
  1928. public float X;
  1929. public float Y;
  1930. public float Direction;
  1931. public byte UnitMainState;
  1932. public byte UnitSubState;
  1933. public UnitForceSyncPosEvent() { }
  1934. public UnitForceSyncPosEvent(uint unit_id, float x, float y, float d, byte state, byte sub_state)
  1935. : base(unit_id)
  1936. {
  1937. this.X = x;
  1938. this.Y = y;
  1939. this.Direction = d;
  1940. this.UnitMainState = state;
  1941. this.UnitSubState = sub_state;
  1942. }
  1943. override public void WriteExternal(IOutputStream output)
  1944. {
  1945. base.WriteExternal(output);
  1946. output.PutF32(this.X);
  1947. output.PutF32(this.Y);
  1948. output.PutF32(this.Direction);
  1949. output.PutU8(this.UnitMainState);
  1950. output.PutU8(this.UnitSubState);
  1951. //if (this.object_id == 2649)
  1952. //{
  1953. // Console.WriteLine("ForceSync-" + this.object_id + ", X: " + this.X + ", \t Y: " + this.Y + ", " + this.UnitMainState + ", " + this.UnitSubState);
  1954. //}
  1955. }
  1956. override public void ReadExternal(IInputStream input)
  1957. {
  1958. base.ReadExternal(input);
  1959. this.X = input.GetF32();
  1960. this.Y = input.GetF32();
  1961. this.Direction = input.GetF32();
  1962. this.UnitMainState = input.GetU8();
  1963. this.UnitSubState = input.GetU8();
  1964. }
  1965. }
  1966. /// <summary>
  1967. /// 立即同步客户端坐标,比如单位传送之类,用于MoveByClient的模式
  1968. /// </summary>
  1969. [MessageType(0x8120)]
  1970. public class ObjectForceSyncPosEvent : ObjectEvent
  1971. {
  1972. public float X;
  1973. public float Y;
  1974. public float Direction;
  1975. public ObjectForceSyncPosEvent() { }
  1976. public ObjectForceSyncPosEvent(uint unit_id, float x, float y, float d)
  1977. : base(unit_id)
  1978. {
  1979. this.X = x;
  1980. this.Y = y;
  1981. this.Direction = d;
  1982. }
  1983. override public void WriteExternal(IOutputStream output)
  1984. {
  1985. base.WriteExternal(output);
  1986. output.PutF32(this.X);
  1987. output.PutF32(this.Y);
  1988. output.PutF32(this.Direction);
  1989. }
  1990. override public void ReadExternal(IInputStream input)
  1991. {
  1992. base.ReadExternal(input);
  1993. this.X = input.GetF32();
  1994. this.Y = input.GetF32();
  1995. this.Direction = input.GetF32();
  1996. }
  1997. }
  1998. /// <summary>
  1999. /// Missile类法术,锁定单位时触发
  2000. /// </summary>
  2001. [MessageType(0x8130)]
  2002. public class SpellLockTargetEvent : ObjectEvent, PositionMessage
  2003. {
  2004. public uint target_obj_id;
  2005. private float x;
  2006. private float y;
  2007. public SpellLockTargetEvent() { }
  2008. public SpellLockTargetEvent(uint spell_id, uint target_obj_id, float x, float y)
  2009. : base(spell_id)
  2010. {
  2011. this.target_obj_id = target_obj_id;
  2012. this.x = x;
  2013. this.y = y;
  2014. }
  2015. override public void WriteExternal(IOutputStream output)
  2016. {
  2017. base.WriteExternal(output);
  2018. output.PutVU32(target_obj_id);
  2019. }
  2020. override public void ReadExternal(IInputStream input)
  2021. {
  2022. base.ReadExternal(input);
  2023. this.target_obj_id = input.GetVU32();
  2024. }
  2025. public float X { get { return x; } }
  2026. public float Y { get { return y; } }
  2027. }
  2028. #endregion
  2029. //--------------------------------------------------------------------------
  2030. #region CONTROL_0x8200
  2031. /// <summary>
  2032. /// 单位待机
  2033. /// </summary>
  2034. [MessageType(0x8200)]
  2035. public class UnitGuardAction : ObjectAction
  2036. {
  2037. public bool guard = false;
  2038. public string reason = null;
  2039. public bool forceNotify = false;
  2040. public UnitGuardAction() { }
  2041. public UnitGuardAction(uint unit_id, bool guard)
  2042. : base(unit_id)
  2043. {
  2044. this.guard = guard;
  2045. }
  2046. public UnitGuardAction(uint unit_id, bool guard, string reason)
  2047. : base(unit_id)
  2048. {
  2049. this.guard = guard;
  2050. this.reason = reason;
  2051. }
  2052. override public void WriteExternal(IOutputStream output)
  2053. {
  2054. base.WriteExternal(output);
  2055. output.PutBool(guard);
  2056. output.PutUTF(reason);
  2057. }
  2058. override public void ReadExternal(IInputStream input)
  2059. {
  2060. base.ReadExternal(input);
  2061. this.guard = input.GetBool();
  2062. this.reason = input.GetUTF();
  2063. }
  2064. }
  2065. /// <summary>
  2066. /// A过去
  2067. /// </summary>
  2068. [MessageType(0x8206)]
  2069. public class UnitAttackToAction : ObjectAction
  2070. {
  2071. public float targetX;
  2072. public float targetY;
  2073. public bool attack;
  2074. public UnitAttackToAction() { }
  2075. public UnitAttackToAction(uint unit_id, float x, float y, bool attack)
  2076. : base(unit_id)
  2077. {
  2078. this.targetX = x;
  2079. this.targetY = y;
  2080. this.attack = attack;
  2081. }
  2082. override public void WriteExternal(IOutputStream output)
  2083. {
  2084. base.WriteExternal(output);
  2085. output.PutF32(targetX);
  2086. output.PutF32(targetY);
  2087. output.PutBool(attack);
  2088. }
  2089. override public void ReadExternal(IInputStream input)
  2090. {
  2091. base.ReadExternal(input);
  2092. this.targetX = input.GetF32();
  2093. this.targetY = input.GetF32();
  2094. this.attack = input.GetBool();
  2095. }
  2096. }
  2097. /// <summary>
  2098. /// 单位移动
  2099. /// </summary>
  2100. [MessageType(0x8201)]
  2101. public class UnitMoveAction : ObjectAction
  2102. {
  2103. public float x;
  2104. public float y;
  2105. public UnitMoveAction() { }
  2106. public UnitMoveAction(uint unit_id, float x, float y)
  2107. : base(unit_id)
  2108. {
  2109. this.x = x;
  2110. this.y = y;
  2111. }
  2112. override public void WriteExternal(IOutputStream output)
  2113. {
  2114. base.WriteExternal(output);
  2115. output.PutF32(x);
  2116. output.PutF32(y);
  2117. }
  2118. override public void ReadExternal(IInputStream input)
  2119. {
  2120. base.ReadExternal(input);
  2121. this.x = input.GetF32();
  2122. this.y = input.GetF32();
  2123. }
  2124. }
  2125. /// <summary>
  2126. /// 玩家选择朝向
  2127. /// </summary>
  2128. [MessageType(0x8202)]
  2129. public class UnitFaceToAction : ObjectAction
  2130. {
  2131. public float Direction;
  2132. public UnitFaceToAction() { }
  2133. public UnitFaceToAction(uint unit_id, float d)
  2134. : base(unit_id)
  2135. {
  2136. this.Direction = d;
  2137. }
  2138. override public void WriteExternal(IOutputStream output)
  2139. {
  2140. base.WriteExternal(output);
  2141. output.PutF32(Direction);
  2142. }
  2143. override public void ReadExternal(IInputStream input)
  2144. {
  2145. base.ReadExternal(input);
  2146. this.Direction = input.GetF32();
  2147. }
  2148. }
  2149. /// <summary>
  2150. /// 单位移动
  2151. /// </summary>
  2152. [MessageType(0x8203)]
  2153. public class UnitSlipAction : ObjectAction
  2154. {
  2155. public float x;
  2156. public float y;
  2157. public UnitSlipAction() { }
  2158. public UnitSlipAction(uint unit_id, float x, float y)
  2159. : base(unit_id)
  2160. {
  2161. this.x = x;
  2162. this.y = y;
  2163. }
  2164. override public void WriteExternal(IOutputStream output)
  2165. {
  2166. base.WriteExternal(output);
  2167. output.PutF32(x);
  2168. output.PutF32(y);
  2169. }
  2170. override public void ReadExternal(IInputStream input)
  2171. {
  2172. base.ReadExternal(input);
  2173. this.x = input.GetF32();
  2174. this.y = input.GetF32();
  2175. }
  2176. }
  2177. /// <summary>
  2178. /// 锁定目标
  2179. /// </summary>
  2180. [MessageType(0x8204)]
  2181. public class UnitFocuseTargetAction : ObjectAction
  2182. {
  2183. public uint targetUnitID;
  2184. public UnitFocuseTargetAction() { }
  2185. public UnitFocuseTargetAction(uint unit_id, uint target_id)
  2186. : base(unit_id)
  2187. {
  2188. this.targetUnitID = target_id;
  2189. }
  2190. override public void WriteExternal(IOutputStream output)
  2191. {
  2192. base.WriteExternal(output);
  2193. output.PutU32(targetUnitID);
  2194. }
  2195. override public void ReadExternal(IInputStream input)
  2196. {
  2197. base.ReadExternal(input);
  2198. this.targetUnitID = input.GetU32();
  2199. }
  2200. }
  2201. /// <summary>
  2202. /// 单位技能动作
  2203. /// </summary>
  2204. [MessageType(0x8205)]
  2205. public class UnitLaunchSkillAction : ObjectAction
  2206. {
  2207. private BitSet8 mask = new BitSet8();
  2208. public bool IsAutoFocusNearTarget
  2209. {
  2210. get { return mask.Get(0); }
  2211. set { mask.Set(0, value); }
  2212. }
  2213. private bool IsTargetID
  2214. {
  2215. get { return mask.Get(1); }
  2216. set { mask.Set(1, value); }
  2217. }
  2218. private bool IsTargetPos
  2219. {
  2220. get { return mask.Get(2); }
  2221. set { mask.Set(2, value); }
  2222. }
  2223. public bool SyncDirection
  2224. {
  2225. get { return mask.Get(3); }
  2226. set { mask.Set(3, value); }
  2227. }
  2228. public int SkillID;
  2229. public uint TargetObjID = 0;
  2230. public Vector2 SpellTargetPos = null;
  2231. public float Direction = 0;
  2232. public UnitLaunchSkillAction() { }
  2233. public UnitLaunchSkillAction(uint unit_id, int skill_id, bool autoFocuseTarget = false, uint targetObjID = 0, Vector2 spellTargetPos = null, float direction = 0.0f)
  2234. : base(unit_id)
  2235. {
  2236. this.SkillID = skill_id;
  2237. this.TargetObjID = targetObjID;
  2238. this.SpellTargetPos = spellTargetPos;
  2239. this.IsAutoFocusNearTarget = autoFocuseTarget;
  2240. this.Direction = direction;
  2241. }
  2242. override public void WriteExternal(IOutputStream output)
  2243. {
  2244. this.IsTargetID = (TargetObjID != 0);
  2245. this.IsTargetPos = (SpellTargetPos != null);
  2246. base.WriteExternal(output);
  2247. mask.WriteExternal(output);
  2248. output.PutS32(SkillID);
  2249. if (SyncDirection)
  2250. {
  2251. output.PutF32(Direction);
  2252. }
  2253. if (IsTargetID)
  2254. {
  2255. output.PutU32(TargetObjID);
  2256. }
  2257. if (IsTargetPos)
  2258. {
  2259. output.PutF32(SpellTargetPos.X);
  2260. output.PutF32(SpellTargetPos.Y);
  2261. }
  2262. }
  2263. override public void ReadExternal(IInputStream input)
  2264. {
  2265. base.ReadExternal(input);
  2266. mask.ReadExternal(input);
  2267. this.SkillID = input.GetS32();
  2268. if (SyncDirection)
  2269. {
  2270. this.Direction = input.GetF32();
  2271. }
  2272. if (IsTargetID)
  2273. {
  2274. this.TargetObjID = input.GetU32();
  2275. }
  2276. if (IsTargetPos)
  2277. {
  2278. this.SpellTargetPos = new Vector2();
  2279. this.SpellTargetPos.SetX(input.GetF32());
  2280. this.SpellTargetPos.SetY(input.GetF32());
  2281. }
  2282. }
  2283. }
  2284. /// <summary>
  2285. /// 客户端手动控制同步包
  2286. /// </summary>
  2287. [MessageType(0x8207)]
  2288. public class UnitAxisAction : ObjectAction
  2289. {
  2290. public bool IsZero { get { return dx == 0 && dy == 0; } }
  2291. public float dx;
  2292. public float dy;
  2293. public UnitAxisAction() { }
  2294. public UnitAxisAction(uint unit_id)
  2295. : base(unit_id)
  2296. {
  2297. }
  2298. override public void WriteExternal(IOutputStream output)
  2299. {
  2300. base.WriteExternal(output);
  2301. float angle = (float)Math.Atan2(dy, dx);
  2302. output.PutS8((sbyte)(Math.Cos(angle) * 100f));
  2303. output.PutS8((sbyte)(Math.Sin(angle) * 100f));
  2304. }
  2305. override public void ReadExternal(IInputStream input)
  2306. {
  2307. base.ReadExternal(input);
  2308. this.dx = input.GetS8() / 100f;
  2309. this.dy = input.GetS8() / 100f;
  2310. }
  2311. public bool AxisEquals(UnitAxisAction obj)
  2312. {
  2313. if (obj == null) return false;
  2314. return (obj.dx == this.dx) && (obj.dy == this.dy);
  2315. }
  2316. }
  2317. /// <summary>
  2318. /// 客户端手动控制同步包
  2319. /// </summary>
  2320. [MessageType(0x8208)]
  2321. public class UnitStopMoveAction : ObjectAction
  2322. {
  2323. public UnitStopMoveAction() { }
  2324. public UnitStopMoveAction(uint unit_id)
  2325. : base(unit_id)
  2326. {
  2327. }
  2328. override public void WriteExternal(IOutputStream output)
  2329. {
  2330. base.WriteExternal(output);
  2331. }
  2332. override public void ReadExternal(IInputStream input)
  2333. {
  2334. base.ReadExternal(input);
  2335. }
  2336. }
  2337. /// <summary>
  2338. /// 单位使用道具
  2339. /// </summary>
  2340. [MessageType(0x8209)]
  2341. public class UnitUseItemAction : ObjectAction
  2342. {
  2343. public int Index;
  2344. public int Count;
  2345. public UnitUseItemAction() { }
  2346. public UnitUseItemAction(uint unit_id, int index, int count = 1)
  2347. : base(unit_id)
  2348. {
  2349. this.Index = index;
  2350. this.Count = count;
  2351. }
  2352. override public void WriteExternal(IOutputStream output)
  2353. {
  2354. base.WriteExternal(output);
  2355. output.PutVS32(this.Index);
  2356. output.PutVS32(this.Count);
  2357. }
  2358. override public void ReadExternal(IInputStream input)
  2359. {
  2360. base.ReadExternal(input);
  2361. this.Index = input.GetVS32();
  2362. this.Count = input.GetVS32();
  2363. }
  2364. }
  2365. /// <summary>
  2366. /// 单位手动检取场景道具
  2367. /// </summary>
  2368. [MessageType(0x820A)]
  2369. public class UnitPickObjectAction : ObjectAction
  2370. {
  2371. public uint PickableObjectID;
  2372. public UnitPickObjectAction() { }
  2373. public UnitPickObjectAction(uint unit_id, uint item_obj_id)
  2374. : base(unit_id)
  2375. {
  2376. this.PickableObjectID = item_obj_id;
  2377. }
  2378. override public void WriteExternal(IOutputStream output)
  2379. {
  2380. base.WriteExternal(output);
  2381. output.PutVU32(this.PickableObjectID);
  2382. }
  2383. override public void ReadExternal(IInputStream input)
  2384. {
  2385. base.ReadExternal(input);
  2386. this.PickableObjectID = input.GetVU32();
  2387. }
  2388. }
  2389. /// <summary>
  2390. /// 单位移动
  2391. /// </summary>
  2392. [MessageType(0x820B)]
  2393. public class UnitUpdatePosAction : ObjectAction
  2394. {
  2395. public bool isHalf;
  2396. public float x;
  2397. public float y;
  2398. public float d;
  2399. public UnitActionStatus st;
  2400. public UnitUpdatePosAction() { }
  2401. public UnitUpdatePosAction(uint unit_id, bool isHalf, float x, float y, float d, UnitActionStatus s)
  2402. : base(unit_id)
  2403. {
  2404. this.isHalf = isHalf;
  2405. this.x = x;
  2406. this.y = y;
  2407. this.d = d;
  2408. this.st = s;
  2409. }
  2410. override public void WriteExternal(IOutputStream output)
  2411. {
  2412. base.WriteExternal(output);
  2413. output.PutBool(isHalf);
  2414. if (isHalf)
  2415. {
  2416. output.PutU16(MoveHelper.ToPos16(x));
  2417. output.PutU16(MoveHelper.ToPos16(y));
  2418. output.PutU8(MoveHelper.ToDirectionD8(d));
  2419. }
  2420. else
  2421. {
  2422. output.PutF32(x);
  2423. output.PutF32(y);
  2424. output.PutF32(d);
  2425. }
  2426. output.PutEnum8(st);
  2427. }
  2428. override public void ReadExternal(IInputStream input)
  2429. {
  2430. base.ReadExternal(input);
  2431. this.isHalf = input.GetBool();
  2432. if (isHalf)
  2433. {
  2434. this.x = MoveHelper.ToPosF32(input.GetU16());
  2435. this.y = MoveHelper.ToPosF32(input.GetU16());
  2436. this.d = MoveHelper.ToDirectionF32(input.GetU8());
  2437. }
  2438. else
  2439. {
  2440. this.x = input.GetF32();
  2441. this.y = input.GetF32();
  2442. this.d = input.GetF32();
  2443. }
  2444. this.st = input.GetEnum8<UnitActionStatus>();
  2445. //Console.WriteLine("-------------------UnitUpdatePosAction : " + TimeUtil.GetTimestampMS() + this.x + ", " + this.y + " \t \t" + this.st);
  2446. }
  2447. public bool DataEquals(UnitUpdatePosAction o)
  2448. {
  2449. if (o == null) return false;
  2450. return o.x == this.x && o.y == this.y && o.d == this.d && o.st == this.st;
  2451. }
  2452. public void Set(UnitUpdatePosAction other)
  2453. {
  2454. this.object_id = other.object_id;
  2455. this.isHalf = other.isHalf;
  2456. this.x = other.x;
  2457. this.y = other.y;
  2458. this.d = other.d;
  2459. this.st = other.st;
  2460. }
  2461. }
  2462. [MessageType(0x820C)]
  2463. public class UnitSetSyncModeAction : ObjectAction
  2464. {
  2465. public SyncMode Mode;
  2466. public UnitSetSyncModeAction() { }
  2467. public UnitSetSyncModeAction(uint unit_id, SyncMode mode)
  2468. : base(unit_id)
  2469. {
  2470. this.Mode = mode;
  2471. }
  2472. override public void WriteExternal(IOutputStream output)
  2473. {
  2474. base.WriteExternal(output);
  2475. output.PutEnum8(Mode);
  2476. }
  2477. override public void ReadExternal(IInputStream input)
  2478. {
  2479. base.ReadExternal(input);
  2480. this.Mode = input.GetEnum8<SyncMode>();
  2481. }
  2482. }
  2483. [MessageType(0x820D)]
  2484. public class UnitCancelBuffAction : ObjectAction
  2485. {
  2486. public int BuffID;
  2487. public UnitCancelBuffAction() { }
  2488. public UnitCancelBuffAction(uint unit_id, int buffID)
  2489. : base(unit_id)
  2490. {
  2491. this.BuffID = buffID;
  2492. }
  2493. override public void WriteExternal(IOutputStream output)
  2494. {
  2495. base.WriteExternal(output);
  2496. output.PutS32(BuffID);
  2497. }
  2498. override public void ReadExternal(IInputStream input)
  2499. {
  2500. base.ReadExternal(input);
  2501. this.BuffID = input.GetS32();
  2502. }
  2503. }
  2504. /// <summary>
  2505. /// 单位统计数据
  2506. /// </summary>
  2507. public class UnitStatisticData : IExternalizable
  2508. {
  2509. public uint ObjectID;
  2510. /// <summary>
  2511. /// 死亡次数
  2512. /// </summary>
  2513. public int DeadCount;
  2514. /// <summary>
  2515. /// 总共杀死单位数量
  2516. /// </summary>
  2517. public int KillUnitCount;
  2518. /// <summary>
  2519. /// 总共杀死玩家数量
  2520. /// </summary>
  2521. public int KillPlayerCount;
  2522. /// <summary>
  2523. /// 承受伤害
  2524. /// </summary>
  2525. public long SelfDamage;
  2526. /// <summary>
  2527. /// 对所有单位造成的总伤害
  2528. /// </summary>
  2529. public long TotalDamage;
  2530. /// <summary>
  2531. /// 对玩家造成的总伤害
  2532. /// </summary>
  2533. public long PlayerDamage;
  2534. /// <summary>
  2535. /// 对所有单位输出的总治疗量
  2536. /// </summary>
  2537. public long TotalHealing;
  2538. /// <summary>
  2539. /// 对玩家输出的总治疗量
  2540. /// </summary>
  2541. public long PlayerHealing;
  2542. public virtual void WriteExternal(IOutputStream output)
  2543. {
  2544. output.PutVU32(ObjectID);
  2545. output.PutVS32(DeadCount);
  2546. output.PutVS32(KillUnitCount);
  2547. output.PutVS32(KillPlayerCount);
  2548. output.PutVS64(SelfDamage);
  2549. output.PutVS64(TotalDamage);
  2550. output.PutVS64(PlayerDamage);
  2551. output.PutVS64(TotalHealing);
  2552. output.PutVS64(PlayerHealing);
  2553. }
  2554. public virtual void ReadExternal(IInputStream input)
  2555. {
  2556. ObjectID = input.GetVU32();
  2557. DeadCount = input.GetVS32();
  2558. KillUnitCount = input.GetVS32();
  2559. KillPlayerCount = input.GetVS32();
  2560. SelfDamage = input.GetVS64();
  2561. TotalDamage = input.GetVS64();
  2562. PlayerDamage = input.GetVS64();
  2563. TotalHealing = input.GetVS64();
  2564. PlayerHealing = input.GetVS64();
  2565. }
  2566. }
  2567. [MessageType(0x8210)]
  2568. public class UnitGetStatisticRequest : ActorRequest
  2569. {
  2570. public uint[] RequestObjectsID;
  2571. public UnitGetStatisticRequest() { }
  2572. public UnitGetStatisticRequest(uint objID, params uint[] objectsID) : base(objID)
  2573. {
  2574. this.RequestObjectsID = objectsID;
  2575. }
  2576. public override void WriteExternal(IOutputStream output)
  2577. {
  2578. base.WriteExternal(output);
  2579. output.PutS32(MessageID);
  2580. output.PutArray(RequestObjectsID, output.PutU32);
  2581. }
  2582. public override void ReadExternal(IInputStream input)
  2583. {
  2584. base.ReadExternal(input);
  2585. this.MessageID = input.GetS32();
  2586. this.RequestObjectsID = input.GetArray<uint>(input.GetU32);
  2587. }
  2588. }
  2589. [MessageType(0x8211)]
  2590. public class UnitGetStatisticResponse : ActorResponse
  2591. {
  2592. public HashMap<uint, UnitStatisticData> Statistics = new HashMap<uint, UnitStatisticData>();
  2593. public override void WriteExternal(IOutputStream output)
  2594. {
  2595. base.WriteExternal(output);
  2596. output.PutS32(MessageID);
  2597. output.PutVS32(Statistics.Count);
  2598. foreach (KeyValuePair<uint, UnitStatisticData> e in Statistics)
  2599. {
  2600. output.PutU32(e.Key);
  2601. output.PutExt(e.Value);
  2602. }
  2603. }
  2604. public override void ReadExternal(IInputStream input)
  2605. {
  2606. base.ReadExternal(input);
  2607. this.MessageID = input.GetS32();
  2608. int count = input.GetVS32();
  2609. for (int i = 0; i < count; i++)
  2610. {
  2611. var key = input.GetU32();
  2612. var data = input.GetExtAny() as UnitStatisticData;
  2613. Statistics.Put(key, data);
  2614. }
  2615. }
  2616. }
  2617. /// <summary>
  2618. /// 设置子动做
  2619. /// </summary>
  2620. [MessageType(0x8212)]
  2621. public class UnitSetSubStateAction : ObjectAction
  2622. {
  2623. public byte UnitSubState;
  2624. public UnitSetSubStateAction() { }
  2625. public UnitSetSubStateAction(uint objID, byte state)
  2626. : base(objID)
  2627. {
  2628. this.UnitSubState = state;
  2629. }
  2630. public override void WriteExternal(IOutputStream output)
  2631. {
  2632. base.WriteExternal(output);
  2633. output.PutU8(UnitSubState);
  2634. }
  2635. public override void ReadExternal(IInputStream input)
  2636. {
  2637. base.ReadExternal(input);
  2638. this.UnitSubState = input.GetU8();
  2639. }
  2640. }
  2641. /// <summary>
  2642. /// 单位准备完毕
  2643. /// </summary>
  2644. [MessageType(0x8213)]
  2645. public class UnitReadAction : ObjectAction
  2646. {
  2647. public UnitReadAction() { }
  2648. public UnitReadAction(uint objID)
  2649. : base(objID)
  2650. {
  2651. }
  2652. public override void WriteExternal(IOutputStream output)
  2653. {
  2654. base.WriteExternal(output);
  2655. }
  2656. public override void ReadExternal(IInputStream input)
  2657. {
  2658. base.ReadExternal(input);
  2659. }
  2660. }
  2661. #endregion
  2662. //--------------------------------------------------------------------------
  2663. //--------------------------------------------------------------------------------------------------------------
  2664. #region CLIENT_EVENTS_0x8300
  2665. public abstract class ClientEvent : ZoneEvent
  2666. {
  2667. }
  2668. /// <summary>
  2669. /// 显示箭头
  2670. /// </summary>
  2671. [MessageType(0x8300)]
  2672. public class LookAtEvent : ClientEvent
  2673. {
  2674. public string target;
  2675. public float x;
  2676. public float y;
  2677. public LookAtEvent() { }
  2678. public LookAtEvent(string target, float x, float y)
  2679. {
  2680. this.target = target;
  2681. this.x = x;
  2682. this.y = y;
  2683. }
  2684. override public void WriteExternal(IOutputStream output)
  2685. {
  2686. output.PutUTF(target);
  2687. output.PutF32(x);
  2688. output.PutF32(y);
  2689. }
  2690. override public void ReadExternal(IInputStream input)
  2691. {
  2692. this.target = input.GetUTF();
  2693. this.x = input.GetF32();
  2694. this.y = input.GetF32();
  2695. }
  2696. }
  2697. /// <summary>
  2698. /// 改变游戏运行速度
  2699. /// </summary>
  2700. [MessageType(0x8301)]
  2701. public class ChangeTimeScaleEvent : ClientEvent
  2702. {
  2703. /// <summary>
  2704. /// 时间尺度百分比
  2705. /// </summary>
  2706. public float TimeScalePct = 100f;
  2707. public ChangeTimeScaleEvent() { }
  2708. public ChangeTimeScaleEvent(float pct)
  2709. {
  2710. this.TimeScalePct = pct;
  2711. }
  2712. override public void WriteExternal(IOutputStream output)
  2713. {
  2714. output.PutF32(TimeScalePct);
  2715. }
  2716. override public void ReadExternal(IInputStream input)
  2717. {
  2718. this.TimeScalePct = input.GetF32();
  2719. }
  2720. }
  2721. /// <summary>
  2722. /// 暂停游戏
  2723. /// </summary>
  2724. [MessageType(0x8302)]
  2725. public class GamePauseEvent : ClientEvent
  2726. {
  2727. /// <summary>
  2728. /// 暂停多少秒,如果为0,则无限暂停
  2729. /// </summary>
  2730. public float Seconds = 0f;
  2731. public GamePauseEvent() { }
  2732. public GamePauseEvent(float sec)
  2733. {
  2734. this.Seconds = sec;
  2735. }
  2736. override public void WriteExternal(IOutputStream output)
  2737. {
  2738. output.PutF32(Seconds);
  2739. }
  2740. override public void ReadExternal(IInputStream input)
  2741. {
  2742. this.Seconds = input.GetF32();
  2743. }
  2744. }
  2745. /// <summary>
  2746. /// 继续游戏
  2747. /// </summary>
  2748. [MessageType(0x8303)]
  2749. public class GameResumeEvent : ClientEvent
  2750. {
  2751. public GameResumeEvent() { }
  2752. public override void WriteExternal(IOutputStream output)
  2753. {
  2754. }
  2755. public override void ReadExternal(IInputStream input)
  2756. {
  2757. }
  2758. }
  2759. /// <summary>
  2760. /// 移动镜头到
  2761. /// </summary>
  2762. [MessageType(0x8304)]
  2763. public class CameraMoveToEvent : ClientEvent
  2764. {
  2765. /// <summary>
  2766. /// 镜头移动速度(每秒距离)
  2767. /// </summary>
  2768. public float MoveSpeedSec = 1f;
  2769. /// <summary>
  2770. /// 移动过去的总时间,如果为0,则按速度计算
  2771. /// </summary>
  2772. public int TimeMS = 0;
  2773. public float x;
  2774. public float y;
  2775. public CameraMoveToEvent() { }
  2776. public CameraMoveToEvent(float x, float y, float speed, int timeMS)
  2777. {
  2778. this.x = x;
  2779. this.y = y;
  2780. this.MoveSpeedSec = speed;
  2781. this.TimeMS = timeMS;
  2782. }
  2783. override public void WriteExternal(IOutputStream output)
  2784. {
  2785. output.PutF32(x);
  2786. output.PutF32(y);
  2787. output.PutF32(MoveSpeedSec);
  2788. output.PutS32(TimeMS);
  2789. }
  2790. override public void ReadExternal(IInputStream input)
  2791. {
  2792. this.x = input.GetF32();
  2793. this.y = input.GetF32();
  2794. this.MoveSpeedSec = input.GetF32();
  2795. this.TimeMS = input.GetS32();
  2796. }
  2797. }
  2798. /// <summary>
  2799. /// 锁定镜头到单位
  2800. /// </summary>
  2801. [MessageType(0x8305)]
  2802. public class CameraFocusUnitEvent : ClientEvent
  2803. {
  2804. public uint ObjectID;
  2805. public CameraFocusUnitEvent() { }
  2806. public CameraFocusUnitEvent(uint oid)
  2807. {
  2808. this.ObjectID = oid;
  2809. }
  2810. override public void WriteExternal(IOutputStream output)
  2811. {
  2812. output.PutU32(ObjectID);
  2813. }
  2814. override public void ReadExternal(IInputStream input)
  2815. {
  2816. this.ObjectID = input.GetU32();
  2817. }
  2818. }
  2819. /// <summary>
  2820. /// 拉近镜头
  2821. /// </summary>
  2822. [MessageType(0x8306)]
  2823. public class CameraZoomToEvent : ClientEvent
  2824. {
  2825. /// <summary>
  2826. /// 镜头拉近距离
  2827. /// </summary>
  2828. public float ZoomDistance = 10f;
  2829. /// <summary>
  2830. /// 镜头拉近速度(每秒距离)
  2831. /// </summary>
  2832. public float ZoomSpeedSec = 1f;
  2833. public CameraZoomToEvent() { }
  2834. public CameraZoomToEvent(float distance, float speed)
  2835. {
  2836. this.ZoomDistance = distance;
  2837. this.ZoomSpeedSec = speed;
  2838. }
  2839. override public void WriteExternal(IOutputStream output)
  2840. {
  2841. output.PutF32(ZoomDistance);
  2842. output.PutF32(ZoomSpeedSec);
  2843. }
  2844. override public void ReadExternal(IInputStream input)
  2845. {
  2846. this.ZoomDistance = input.GetF32();
  2847. this.ZoomSpeedSec = input.GetF32();
  2848. }
  2849. }
  2850. /// <summary>
  2851. /// 旋转镜头
  2852. /// </summary>
  2853. [MessageType(0x8307)]
  2854. public class CameraRotateToEvent : ClientEvent
  2855. {
  2856. /// <summary>
  2857. /// 镜头旋转角度(0~360)
  2858. /// </summary>
  2859. public float RotateAngle = 10f;
  2860. /// <summary>
  2861. /// 镜头旋转速度(每秒角度)
  2862. /// </summary>
  2863. public float RotateSpeedSec = 1f;
  2864. public CameraRotateToEvent() { }
  2865. public CameraRotateToEvent(float angle, float speed)
  2866. {
  2867. this.RotateAngle = angle;
  2868. this.RotateSpeedSec = speed;
  2869. }
  2870. override public void WriteExternal(IOutputStream output)
  2871. {
  2872. output.PutF32(RotateAngle);
  2873. output.PutF32(RotateSpeedSec);
  2874. }
  2875. override public void ReadExternal(IInputStream input)
  2876. {
  2877. this.RotateAngle = input.GetF32();
  2878. this.RotateSpeedSec = input.GetF32();
  2879. }
  2880. }
  2881. /// <summary>
  2882. /// 重置镜头
  2883. /// </summary>
  2884. [MessageType(0x8308)]
  2885. public class CameraResetEvent : ClientEvent
  2886. {
  2887. public override void WriteExternal(IOutputStream output)
  2888. {
  2889. }
  2890. public override void ReadExternal(IInputStream input)
  2891. {
  2892. }
  2893. }
  2894. /// <summary>
  2895. /// 客户端动作序列
  2896. /// </summary>
  2897. [MessageType(0x8309)]
  2898. public class ClientEventQueue : ClientEvent
  2899. {
  2900. public List<ClientEvent> EventQueue = new List<ClientEvent>();
  2901. override public void WriteExternal(IOutputStream output)
  2902. {
  2903. output.PutU8((byte)EventQueue.Count);
  2904. foreach (ClientEvent e in EventQueue)
  2905. {
  2906. output.PutExt(e);
  2907. }
  2908. }
  2909. override public void ReadExternal(IInputStream input)
  2910. {
  2911. int count = input.GetU8();
  2912. for (int i = 0; i < count; i++)
  2913. {
  2914. EventQueue.Add(input.GetExtAny() as ClientEvent);
  2915. }
  2916. }
  2917. }
  2918. /// <summary>
  2919. /// 移动锁定一段时间
  2920. /// </summary>
  2921. [MessageType(0x830B)]
  2922. public class CameraHoldEvent : ClientEvent
  2923. {
  2924. public float x;
  2925. public float y;
  2926. public int TimeMS;
  2927. public CameraHoldEvent() { }
  2928. public CameraHoldEvent(float x, float y, int timeMS)
  2929. {
  2930. this.x = x;
  2931. this.y = y;
  2932. this.TimeMS = timeMS;
  2933. }
  2934. override public void WriteExternal(IOutputStream output)
  2935. {
  2936. output.PutF32(x);
  2937. output.PutF32(y);
  2938. output.PutS32(TimeMS);
  2939. }
  2940. override public void ReadExternal(IInputStream input)
  2941. {
  2942. this.x = input.GetF32();
  2943. this.y = input.GetF32();
  2944. this.TimeMS = input.GetS32();
  2945. }
  2946. }
  2947. #endregion
  2948. //--------------------------------------------------------------------------
  2949. #region PLAYER_EVENTS_0x8400
  2950. public abstract class PlayerEvent : ObjectEvent
  2951. {
  2952. public PlayerEvent() { }
  2953. public PlayerEvent(uint objID) : base(objID) { }
  2954. }
  2955. [MessageType(0x8400)]
  2956. public class PlayerCDEvent : PlayerEvent
  2957. {
  2958. private byte mask = 0;
  2959. public bool is_all
  2960. {
  2961. get { return BitMask.BitGetMask(mask, 0); }
  2962. set { BitMask.BitSetMask(ref mask, 0, value); }
  2963. }
  2964. public bool is_decrease_time
  2965. {
  2966. get { return BitMask.BitGetMask(mask, 1); }
  2967. set { BitMask.BitSetMask(ref mask, 1, value); }
  2968. }
  2969. public bool is_decrease_pct
  2970. {
  2971. get { return BitMask.BitGetMask(mask, 2); }
  2972. set { BitMask.BitSetMask(ref mask, 2, value); }
  2973. }
  2974. public bool is_clear
  2975. {
  2976. get { return BitMask.BitGetMask(mask, 3); }
  2977. set { BitMask.BitSetMask(ref mask, 3, value); }
  2978. }
  2979. public int decrease_timeMS;
  2980. public float decrease_pct;
  2981. public int skill_template_id;
  2982. public PlayerCDEvent() { }
  2983. public PlayerCDEvent(uint unit_id) : base(unit_id) { }
  2984. override public void WriteExternal(IOutputStream output)
  2985. {
  2986. base.WriteExternal(output);
  2987. output.PutU8(mask);
  2988. if (is_all)
  2989. {
  2990. if (is_decrease_pct)
  2991. output.PutF32(decrease_pct);
  2992. if (is_decrease_time)
  2993. output.PutVS32(decrease_timeMS);
  2994. }
  2995. else
  2996. {
  2997. output.PutS32(skill_template_id);
  2998. if (is_decrease_pct)
  2999. output.PutF32(decrease_pct);
  3000. if (is_decrease_time)
  3001. output.PutVS32(decrease_timeMS);
  3002. }
  3003. }
  3004. override public void ReadExternal(IInputStream input)
  3005. {
  3006. base.ReadExternal(input);
  3007. this.mask = input.GetU8();
  3008. if (is_all)
  3009. {
  3010. if (is_decrease_pct)
  3011. decrease_pct = input.GetF32();
  3012. if (is_decrease_time)
  3013. decrease_timeMS = input.GetVS32();
  3014. }
  3015. else
  3016. {
  3017. skill_template_id = input.GetS32();
  3018. if (is_decrease_pct)
  3019. decrease_pct = input.GetF32();
  3020. if (is_decrease_time)
  3021. decrease_timeMS = input.GetVS32();
  3022. }
  3023. }
  3024. }
  3025. [MessageType(0x8401)]
  3026. public class PlayerSkillChangedEvent : PlayerEvent
  3027. {
  3028. public SkillTemplate baseSkill;
  3029. public List<SkillTemplate> skills = new List<SkillTemplate>();
  3030. public float unitFastCastRate;
  3031. public PlayerSkillChangedEvent() { }
  3032. public PlayerSkillChangedEvent(uint unit_id) : base(unit_id) { }
  3033. override public void WriteExternal(IOutputStream output)
  3034. {
  3035. base.WriteExternal(output);
  3036. output.PutF32(this.unitFastCastRate);
  3037. output.PutExt(this.baseSkill);
  3038. output.PutList<SkillTemplate>(this.skills, output.PutExt);
  3039. }
  3040. override public void ReadExternal(IInputStream input)
  3041. {
  3042. base.ReadExternal(input);
  3043. this.unitFastCastRate = input.GetF32();
  3044. this.baseSkill = input.GetExt<SkillTemplate>();
  3045. this.skills = input.GetList<SkillTemplate>(input.GetExt<SkillTemplate>);
  3046. }
  3047. }
  3048. [MessageType(0x8402)]
  3049. public class PlayerSyncEnvironmentVarEvent : PlayerEvent
  3050. {
  3051. public string Key;
  3052. public object Value;
  3053. public PlayerSyncEnvironmentVarEvent() { }
  3054. public PlayerSyncEnvironmentVarEvent(uint unit_id, string key, object value)
  3055. : base(unit_id)
  3056. {
  3057. this.Key = key;
  3058. this.Value = value;
  3059. }
  3060. override public void WriteExternal(IOutputStream output)
  3061. {
  3062. base.WriteExternal(output);
  3063. output.PutUTF(Key);
  3064. output.PutData(Value);
  3065. }
  3066. override public void ReadExternal(IInputStream input)
  3067. {
  3068. base.ReadExternal(input);
  3069. DataType dtype;
  3070. this.Key = input.GetUTF();
  3071. this.Value = input.GetData(out dtype);
  3072. }
  3073. }
  3074. [MessageType(0x8403)]
  3075. public class PlayerSkillStopEvent : PlayerEvent
  3076. {
  3077. public int SkillID;
  3078. public PlayerSkillStopEvent() { }
  3079. public PlayerSkillStopEvent(uint unit_id, int skillID)
  3080. : base(unit_id)
  3081. {
  3082. this.SkillID = skillID;
  3083. }
  3084. override public void WriteExternal(IOutputStream output)
  3085. {
  3086. base.WriteExternal(output);
  3087. output.PutS32(SkillID);
  3088. }
  3089. override public void ReadExternal(IInputStream input)
  3090. {
  3091. base.ReadExternal(input);
  3092. this.SkillID = input.GetS32();
  3093. }
  3094. }
  3095. [MessageType(0x8404)]
  3096. public class PlayerSkillAddedEvent : PlayerEvent
  3097. {
  3098. public SkillTemplate Skill;
  3099. public bool IsDefault;
  3100. public PlayerSkillAddedEvent() { }
  3101. public PlayerSkillAddedEvent(uint unit_id, SkillTemplate sk, bool isDefault)
  3102. : base(unit_id)
  3103. {
  3104. this.Skill = sk;
  3105. this.IsDefault = isDefault;
  3106. }
  3107. override public void WriteExternal(IOutputStream output)
  3108. {
  3109. base.WriteExternal(output);
  3110. output.PutExt(this.Skill);
  3111. output.PutBool(this.IsDefault);
  3112. }
  3113. override public void ReadExternal(IInputStream input)
  3114. {
  3115. base.ReadExternal(input);
  3116. this.Skill = input.GetExt<SkillTemplate>();
  3117. this.IsDefault = input.GetBool();
  3118. }
  3119. }
  3120. [MessageType(0x8405)]
  3121. public class PlayerSkillRemovedEvent : PlayerEvent
  3122. {
  3123. public int SkillID;
  3124. public PlayerSkillRemovedEvent() { }
  3125. public PlayerSkillRemovedEvent(uint unit_id, int skillID)
  3126. : base(unit_id)
  3127. {
  3128. this.SkillID = skillID;
  3129. }
  3130. override public void WriteExternal(IOutputStream output)
  3131. {
  3132. base.WriteExternal(output);
  3133. output.PutS32(this.SkillID);
  3134. }
  3135. override public void ReadExternal(IInputStream input)
  3136. {
  3137. base.ReadExternal(input);
  3138. this.SkillID = input.GetS32();
  3139. }
  3140. }
  3141. /// <summary>
  3142. /// 脚本系统指令
  3143. /// </summary>
  3144. [MessageType(0x8406)]
  3145. public class PlayerScriptCommandEvent : PlayerEvent
  3146. {
  3147. public string message;
  3148. public PlayerScriptCommandEvent() { }
  3149. public PlayerScriptCommandEvent(uint unit_id, string msg)
  3150. : base(unit_id)
  3151. {
  3152. this.message = msg;
  3153. }
  3154. override public void WriteExternal(IOutputStream output)
  3155. {
  3156. base.WriteExternal(output);
  3157. output.PutUTF(message);
  3158. }
  3159. override public void ReadExternal(IInputStream input)
  3160. {
  3161. base.ReadExternal(input);
  3162. this.message = input.GetUTF();
  3163. }
  3164. }
  3165. /// <summary>
  3166. /// 技能可用性发生变化
  3167. /// </summary>
  3168. [MessageType(0x8407)]
  3169. public class PlayerSkillActiveChangedEvent : PlayerEvent
  3170. {
  3171. public struct State
  3172. {
  3173. public int SkillTemplateID;
  3174. public SkillActiveState ST;
  3175. public bool IsActive { get { return ST == SkillActiveState.Active; } }
  3176. public bool IsPauseOnDeactive { get { return ST == SkillActiveState.DeactiveAndPause; } }
  3177. }
  3178. public List<State> Skills;
  3179. public PlayerSkillActiveChangedEvent() { this.Skills = new List<State>(); }
  3180. public PlayerSkillActiveChangedEvent(uint unit_id, int skillCount) : base(unit_id)
  3181. {
  3182. this.Skills = new List<State>(skillCount);
  3183. }
  3184. override public void WriteExternal(IOutputStream output)
  3185. {
  3186. base.WriteExternal(output);
  3187. output.PutVS32(Skills.Count);
  3188. for (int i = 0; i < Skills.Count; i++)
  3189. {
  3190. State sat = Skills[i];
  3191. output.PutS32(sat.SkillTemplateID);
  3192. output.PutEnum8(sat.ST);
  3193. }
  3194. }
  3195. override public void ReadExternal(IInputStream input)
  3196. {
  3197. base.ReadExternal(input);
  3198. int count = input.GetVS32();
  3199. this.Skills.Capacity = count;
  3200. for (int i = 0; i < count; i++)
  3201. {
  3202. State sat = new State();
  3203. sat.SkillTemplateID = input.GetS32();
  3204. sat.ST = input.GetEnum8<SkillActiveState>();
  3205. this.Skills.Add(sat);
  3206. }
  3207. }
  3208. }
  3209. [MessageType(0x8408)]
  3210. public class PlayerSkillTimeChangedEvent : PlayerEvent
  3211. {
  3212. public int SkillTemplateID;
  3213. public int SkillPassTimeMS;
  3214. public int SkillTotalTimeMS;
  3215. public PlayerSkillTimeChangedEvent() { }
  3216. public PlayerSkillTimeChangedEvent(uint unit_id, int skillID, int passTimeMS, int totalTimeMS)
  3217. : base(unit_id)
  3218. {
  3219. this.SkillTemplateID = skillID;
  3220. this.SkillPassTimeMS = passTimeMS;
  3221. this.SkillTotalTimeMS = totalTimeMS;
  3222. }
  3223. override public void WriteExternal(IOutputStream output)
  3224. {
  3225. base.WriteExternal(output);
  3226. output.PutS32(this.SkillTemplateID);
  3227. output.PutVS32(this.SkillPassTimeMS);
  3228. output.PutVS32(this.SkillTotalTimeMS);
  3229. }
  3230. override public void ReadExternal(IInputStream input)
  3231. {
  3232. base.ReadExternal(input);
  3233. this.SkillTemplateID = input.GetS32();
  3234. this.SkillPassTimeMS = input.GetVS32();
  3235. this.SkillTotalTimeMS = input.GetVS32();
  3236. }
  3237. }
  3238. /// <summary>
  3239. /// 锁定目标
  3240. /// </summary>
  3241. [MessageType(0x8409)]
  3242. public class PlayerFocuseTargetEvent : PlayerEvent
  3243. {
  3244. public uint targetUnitID;
  3245. public SkillTemplate.CastTarget expectTarget;
  3246. public PlayerFocuseTargetEvent() { }
  3247. public PlayerFocuseTargetEvent(uint unit_id, uint target_id, SkillTemplate.CastTarget expect)
  3248. : base(unit_id)
  3249. {
  3250. this.targetUnitID = target_id;
  3251. this.expectTarget = expect;
  3252. }
  3253. override public void WriteExternal(IOutputStream output)
  3254. {
  3255. base.WriteExternal(output);
  3256. output.PutU32(targetUnitID);
  3257. output.PutEnum8(expectTarget);
  3258. }
  3259. override public void ReadExternal(IInputStream input)
  3260. {
  3261. base.ReadExternal(input);
  3262. this.targetUnitID = input.GetU32();
  3263. this.expectTarget = input.GetEnum8<SkillTemplate.CastTarget>();
  3264. }
  3265. }
  3266. #endregion
  3267. //--------------------------------------------------------------------------
  3268. #region TEXT_0x8500
  3269. public enum ChatMessageType : byte
  3270. {
  3271. SystemToAll,
  3272. SystemToForce,
  3273. SystemToPlayer,
  3274. PlayerToAll,
  3275. PlayerToForce,
  3276. PlayerToPlayer,
  3277. }
  3278. [MessageType(0x8500)]
  3279. public class ChatAction : ObjectAction
  3280. {
  3281. public string Message;
  3282. public ChatMessageType To = ChatMessageType.SystemToAll;
  3283. public string TargetPlayerUUID;
  3284. public override void WriteExternal(IOutputStream output)
  3285. {
  3286. base.WriteExternal(output);
  3287. output.PutU8((byte)this.To);
  3288. output.PutUTF(this.Message);
  3289. output.PutUTF(this.TargetPlayerUUID);
  3290. }
  3291. public override void ReadExternal(IInputStream input)
  3292. {
  3293. base.ReadExternal(input);
  3294. this.To = (ChatMessageType)input.GetU8();
  3295. this.Message = input.GetUTF();
  3296. this.TargetPlayerUUID = input.GetUTF();
  3297. }
  3298. }
  3299. [MessageType(0x8501)]
  3300. public class ChatEvent : ZoneEvent
  3301. {
  3302. public ChatMessageType To = ChatMessageType.SystemToAll;
  3303. public int Force;
  3304. public string FromPlayerUUID;
  3305. public string ToPlayerUUID;
  3306. public string Message;
  3307. public uint KeepTimeMS;
  3308. public ChatEvent() { }
  3309. public ChatEvent(ChatMessageType to, uint timeMS = 2000)
  3310. {
  3311. this.To = to;
  3312. KeepTimeMS = timeMS;
  3313. }
  3314. public override void WriteExternal(IOutputStream output)
  3315. {
  3316. output.PutU8((byte)this.To);
  3317. output.PutVS32((int)KeepTimeMS);
  3318. output.PutUTF(this.Message);
  3319. switch (To)
  3320. {
  3321. case ChatMessageType.PlayerToAll:
  3322. output.PutUTF(this.FromPlayerUUID);
  3323. break;
  3324. case ChatMessageType.PlayerToForce:
  3325. output.PutUTF(this.FromPlayerUUID);
  3326. output.PutVS32(this.Force);
  3327. break;
  3328. case ChatMessageType.PlayerToPlayer:
  3329. output.PutUTF(this.FromPlayerUUID);
  3330. output.PutUTF(this.ToPlayerUUID);
  3331. break;
  3332. case ChatMessageType.SystemToAll:
  3333. break;
  3334. case ChatMessageType.SystemToForce:
  3335. output.PutVS32(this.Force);
  3336. break;
  3337. case ChatMessageType.SystemToPlayer:
  3338. output.PutUTF(this.ToPlayerUUID);
  3339. break;
  3340. }
  3341. }
  3342. public override void ReadExternal(IInputStream input)
  3343. {
  3344. this.To = (ChatMessageType)input.GetU8();
  3345. this.KeepTimeMS = (uint)input.GetVS32();
  3346. this.Message = input.GetUTF();
  3347. switch (To)
  3348. {
  3349. case ChatMessageType.PlayerToAll:
  3350. this.FromPlayerUUID = input.GetUTF();
  3351. break;
  3352. case ChatMessageType.PlayerToForce:
  3353. this.FromPlayerUUID = input.GetUTF();
  3354. this.Force = input.GetVS32();
  3355. break;
  3356. case ChatMessageType.PlayerToPlayer:
  3357. this.FromPlayerUUID = input.GetUTF();
  3358. this.ToPlayerUUID = input.GetUTF();
  3359. break;
  3360. case ChatMessageType.SystemToAll:
  3361. break;
  3362. case ChatMessageType.SystemToForce:
  3363. this.Force = input.GetVS32();
  3364. break;
  3365. case ChatMessageType.SystemToPlayer:
  3366. this.ToPlayerUUID = input.GetUTF();
  3367. break;
  3368. }
  3369. }
  3370. }
  3371. [MessageType(0x8502)]
  3372. public class BubbleTalkEvent : ZoneEvent
  3373. {
  3374. public bool PauseBattle;
  3375. public List<TalkInfo> TalkInfos = new List<TalkInfo>();
  3376. public BubbleTalkEvent() { }
  3377. override public void WriteExternal(IOutputStream output)
  3378. {
  3379. output.PutBool(PauseBattle);
  3380. output.PutExtList<TalkInfo>(this.TalkInfos);
  3381. }
  3382. override public void ReadExternal(IInputStream input)
  3383. {
  3384. this.PauseBattle = input.GetBool();
  3385. this.TalkInfos = input.GetExtList<TalkInfo>();
  3386. }
  3387. public class TalkInfo : IExternalizable
  3388. {
  3389. public uint TalkUnit;
  3390. public string TalkContent;
  3391. public string TalkActionType;
  3392. public int TalkDelayTimeMS;
  3393. public int TalkKeepTimeMS;
  3394. public TalkInfo() { }
  3395. public TalkInfo(uint TalkUnit, string TalkContent, string TalkActionType, int TalkDelayTimeMS, int TalkKeepTimeMS)
  3396. {
  3397. this.TalkUnit = TalkUnit;
  3398. this.TalkContent = TalkContent;
  3399. this.TalkActionType = TalkActionType;
  3400. this.TalkDelayTimeMS = TalkDelayTimeMS;
  3401. this.TalkKeepTimeMS = TalkKeepTimeMS;
  3402. }
  3403. public void WriteExternal(IOutputStream output)
  3404. {
  3405. output.PutVU32(TalkUnit);
  3406. output.PutUTF(TalkContent);
  3407. output.PutUTF(TalkActionType);
  3408. output.PutVS32(TalkDelayTimeMS);
  3409. output.PutVS32(TalkKeepTimeMS);
  3410. }
  3411. public void ReadExternal(IInputStream input)
  3412. {
  3413. this.TalkUnit = input.GetVU32();
  3414. this.TalkContent = input.GetUTF();
  3415. this.TalkActionType = input.GetUTF();
  3416. this.TalkDelayTimeMS = input.GetVS32();
  3417. this.TalkKeepTimeMS = input.GetVS32();
  3418. }
  3419. }
  3420. }
  3421. [MessageType(0x8503)]
  3422. public class PlayerSkillUseTimeChangedEvent : PlayerEvent
  3423. {
  3424. public int SkillTemplateID;
  3425. public byte useTimes;
  3426. public byte hasNext; //0-不用继续叠层,1-继续增加叠层
  3427. public PlayerSkillUseTimeChangedEvent() { }
  3428. public PlayerSkillUseTimeChangedEvent(uint unit_id, int skillID, byte useTimes)
  3429. : base(unit_id)
  3430. {
  3431. this.SkillTemplateID = skillID;
  3432. this.useTimes = useTimes;
  3433. }
  3434. override public void WriteExternal(IOutputStream output)
  3435. {
  3436. base.WriteExternal(output);
  3437. output.PutS32(this.SkillTemplateID);
  3438. output.PutU8(this.useTimes);
  3439. output.PutU8(this.hasNext);
  3440. }
  3441. override public void ReadExternal(IInputStream input)
  3442. {
  3443. base.ReadExternal(input);
  3444. this.SkillTemplateID = input.GetS32();
  3445. this.useTimes = input.GetU8();
  3446. this.hasNext = input.GetU8();
  3447. }
  3448. }
  3449. /// <summary>
  3450. /// 单位中BUFF
  3451. /// </summary>
  3452. [MessageType(0x8504)]
  3453. public class SyncUnitBuffState : ObjectEvent
  3454. {
  3455. public int buffTemplateID;
  3456. public byte overlayLevel;
  3457. public int buffExtData; //buff的扩展字段,
  3458. public SyncUnitBuffState() { }
  3459. public SyncUnitBuffState(uint unit_id, int buffID, byte overlayLevel, int extData)
  3460. : base(unit_id)
  3461. {
  3462. this.buffTemplateID = buffID;
  3463. this.overlayLevel = overlayLevel;
  3464. this.buffExtData = extData;
  3465. }
  3466. override public void WriteExternal(IOutputStream output)
  3467. {
  3468. base.WriteExternal(output);
  3469. output.PutVS32(buffTemplateID);
  3470. output.PutU8(overlayLevel);
  3471. output.PutVS32(buffExtData);
  3472. }
  3473. override public void ReadExternal(IInputStream input)
  3474. {
  3475. base.ReadExternal(input);
  3476. this.buffTemplateID = input.GetVS32();
  3477. this.overlayLevel = input.GetU8();
  3478. this.buffExtData = input.GetVS32();
  3479. }
  3480. }
  3481. /// <summary>
  3482. /// 单位触发能力
  3483. /// </summary>
  3484. [MessageType(0x8505)]
  3485. public class UnitTriggerAblity : ObjectEvent
  3486. {
  3487. public int ablityID;
  3488. public UnitTriggerAblity() { }
  3489. public UnitTriggerAblity(uint unit_id, int id)
  3490. : base(unit_id)
  3491. {
  3492. this.ablityID = id;
  3493. }
  3494. override public void WriteExternal(IOutputStream output)
  3495. {
  3496. base.WriteExternal(output);
  3497. output.PutVS32(ablityID);
  3498. }
  3499. override public void ReadExternal(IInputStream input)
  3500. {
  3501. base.ReadExternal(input);
  3502. this.ablityID = input.GetVS32();
  3503. }
  3504. }
  3505. /// <summary>
  3506. /// 单位触发破碎效果
  3507. /// </summary>
  3508. [MessageType(0x8506)]
  3509. public class UnitHitBreak : ObjectEvent
  3510. {
  3511. public UnitHitBreak() { }
  3512. public UnitHitBreak(uint unit_id)
  3513. : base(unit_id)
  3514. {
  3515. }
  3516. override public void WriteExternal(IOutputStream output)
  3517. {
  3518. base.WriteExternal(output);
  3519. //output.PutVS32(ablityID);
  3520. }
  3521. override public void ReadExternal(IInputStream input)
  3522. {
  3523. base.ReadExternal(input);
  3524. //this.ablityID = input.GetVS32();
  3525. }
  3526. }
  3527. /// <summary>
  3528. /// 单位触发隐身效果
  3529. /// </summary>
  3530. [MessageType(0x8507)]
  3531. public class UnitStealthInfo : ObjectEvent
  3532. {
  3533. public byte stealth;
  3534. public short flag;
  3535. public UnitStealthInfo() { }
  3536. public UnitStealthInfo(uint unit_id, byte stealth, short flag)
  3537. : base(unit_id)
  3538. {
  3539. this.stealth = stealth;
  3540. this.flag = flag;
  3541. }
  3542. override public void WriteExternal(IOutputStream output)
  3543. {
  3544. base.WriteExternal(output);
  3545. output.PutU8(this.stealth);
  3546. output.PutS16(this.flag);
  3547. //Console.WriteLine("UnitStealthInfo: " + this.stealth + ", " + flag);
  3548. }
  3549. override public void ReadExternal(IInputStream input)
  3550. {
  3551. base.ReadExternal(input);
  3552. this.stealth = input.GetU8();
  3553. this.flag = input.GetS16();
  3554. }
  3555. }
  3556. /// <summary>
  3557. /// buff数据推送:针对单一buff事件内的信息变更
  3558. /// </summary>
  3559. [MessageType(0x8508)]
  3560. public class BuffDataNotify : ObjectEvent
  3561. {
  3562. public int buffId;
  3563. public uint senderId;
  3564. public byte overlayLevel;
  3565. public BuffDataNotify() { }
  3566. public BuffDataNotify(uint unit_id, int buffId, uint senderId, int layer)
  3567. : base(unit_id)
  3568. {
  3569. this.buffId = buffId;
  3570. this.senderId = senderId;
  3571. this.overlayLevel = (byte)layer;
  3572. }
  3573. override public void WriteExternal(IOutputStream output)
  3574. {
  3575. base.WriteExternal(output);
  3576. output.PutS32(this.buffId);
  3577. output.PutU32(this.senderId);
  3578. output.PutU8(this.overlayLevel);
  3579. //System.Console.WriteLine("-----BuffDataNotify: " + buffId + ", " + this.object_id + ", " + overlayLevel);
  3580. }
  3581. override public void ReadExternal(IInputStream input)
  3582. {
  3583. base.ReadExternal(input);
  3584. this.buffId = input.GetS32();
  3585. this.senderId = input.GetU32();
  3586. this.overlayLevel = input.GetU8();
  3587. }
  3588. }
  3589. #endregion
  3590. //--------------------------------------------------------------------------
  3591. #region SYSTEM_0x8600
  3592. [MessageType(0x8600)]
  3593. public class Ping : Action, SystemMessage
  3594. {
  3595. public uint DayOfMS;
  3596. public Ping()
  3597. {
  3598. DayOfMS = (uint)CUtils.CurrentTimeMS;
  3599. }
  3600. public void Begin()
  3601. {
  3602. DayOfMS = (uint)CUtils.CurrentTimeMS;
  3603. }
  3604. public override void WriteExternal(IOutputStream output)
  3605. {
  3606. output.PutU32(DayOfMS);
  3607. }
  3608. public override void ReadExternal(IInputStream input)
  3609. {
  3610. DayOfMS = input.GetU32();
  3611. }
  3612. }
  3613. [MessageType(0x8601)]
  3614. public class Pong : Event, SystemMessage
  3615. {
  3616. public uint ClientTimeDayOfMS;
  3617. public Pong() { }
  3618. public Pong(Ping ping) { this.ClientTimeDayOfMS = ping.DayOfMS; }
  3619. public override void WriteExternal(IOutputStream output)
  3620. {
  3621. output.PutU32(ClientTimeDayOfMS);
  3622. }
  3623. public override void ReadExternal(IInputStream input)
  3624. {
  3625. ClientTimeDayOfMS = input.GetU32();
  3626. }
  3627. }
  3628. /// <summary>
  3629. /// 打包一组消息,一次性发出
  3630. /// </summary>
  3631. [MessageType(0x8602)]
  3632. public class PackEvent : Event, SystemMessage
  3633. {
  3634. protected static readonly Logger log = LoggerFactory.GetDefLogger();
  3635. public int sequenceNo;
  3636. public List<IMessage> events = new List<IMessage>();
  3637. public override string ToString()
  3638. {
  3639. var sb = new StringBuilder("PackEvent: no=").Append(sequenceNo).AppendLine();
  3640. foreach (IMessage e in events)
  3641. {
  3642. sb.AppendLine(e.ToString());
  3643. }
  3644. return sb.ToString();
  3645. }
  3646. public override void WriteExternal(IOutputStream output)
  3647. {
  3648. output.PutVS32(sequenceNo);
  3649. output.PutVS32(events.Count);
  3650. #if JSGProfile
  3651. long startSize = output.GetBuffPos();
  3652. #endif
  3653. foreach (IMessage e in events)
  3654. {
  3655. //if (!e.ToString().EndsWith("Pong") && !e.ToString().EndsWith("SyncPosEvent"))
  3656. //{
  3657. // Console.WriteLine("PackEvent: " + e);
  3658. //}
  3659. output.PutExt(e);
  3660. #if JSGProfile
  3661. long tempSize = output.GetBuffPos();
  3662. JSGServerProfile.RecordSend(output.GetTypeID(e), tempSize - startSize);
  3663. startSize = tempSize;
  3664. #endif
  3665. }
  3666. }
  3667. public override void ReadExternal(IInputStream input)
  3668. {
  3669. this.sequenceNo = input.GetVS32();
  3670. int count = input.GetVS32();
  3671. events.Clear();
  3672. events.Capacity = count;
  3673. for (int i = 0; i < count; i++)
  3674. {
  3675. try
  3676. {
  3677. IMessage e = (IMessage)input.GetExtAny();
  3678. events.Add(e);
  3679. }
  3680. catch (Exception err)
  3681. {
  3682. log.Error("PackEvent readExt catch:" + err);
  3683. }
  3684. }
  3685. }
  3686. public override void BeforeWrite(TemplateManager templates)
  3687. {
  3688. foreach (IMessage e in events)
  3689. {
  3690. if (e is BattleMessage)
  3691. {
  3692. (e as BattleMessage).BeforeWrite(templates);
  3693. }
  3694. }
  3695. }
  3696. public override void EndRead(TemplateManager templates)
  3697. {
  3698. foreach (IMessage e in events)
  3699. {
  3700. if (e is BattleMessage)
  3701. {
  3702. (e as BattleMessage).EndRead(templates);
  3703. }
  3704. }
  3705. }
  3706. }
  3707. /// <summary>
  3708. /// 系统消息框,测试用
  3709. /// </summary>
  3710. [MessageType(0x8603)]
  3711. public class TestMessageBox : Event, SystemMessage
  3712. {
  3713. public string msg;
  3714. public TestMessageBox() { }
  3715. public TestMessageBox(string msg)
  3716. {
  3717. this.msg = msg;
  3718. }
  3719. public override void WriteExternal(IOutputStream output)
  3720. {
  3721. output.PutUTF(this.msg);
  3722. }
  3723. public override void ReadExternal(IInputStream input)
  3724. {
  3725. this.msg = input.GetUTF();
  3726. }
  3727. }
  3728. /// <summary>
  3729. /// 通知客户端服务器运行状态
  3730. /// </summary>
  3731. [MessageType(0x8604)]
  3732. public class ServerStatusB2C : Event, SystemMessage
  3733. {
  3734. public int PID;
  3735. public long PrivateMemorySize64;
  3736. public int ActiveGameObjectCount;
  3737. public int ActiveInstanceZoneCount;
  3738. public int AllocGameObjectCount;
  3739. public int AllocInstanceZoneCount;
  3740. public ServerStatusB2C() { }
  3741. public void Update(System.Diagnostics.Process p)
  3742. {
  3743. this.PID = p.Id;
  3744. this.PrivateMemorySize64 = p.PrivateMemorySize64;
  3745. this.ActiveGameObjectCount = InstanceZoneObject.ActiveObjectCount;
  3746. this.ActiveInstanceZoneCount = InstanceZone.ActiveZoneCount;
  3747. this.AllocGameObjectCount = InstanceZoneObject.AllocObjectCount;
  3748. this.AllocInstanceZoneCount = InstanceZone.AllocZoneCount;
  3749. }
  3750. public override void WriteExternal(IOutputStream output)
  3751. {
  3752. output.PutVS32(this.PID);
  3753. output.PutVS64(this.PrivateMemorySize64);
  3754. output.PutVS32(this.ActiveGameObjectCount);
  3755. output.PutVS32(this.ActiveInstanceZoneCount);
  3756. output.PutVS32(this.AllocGameObjectCount);
  3757. output.PutVS32(this.AllocInstanceZoneCount);
  3758. }
  3759. public override void ReadExternal(IInputStream input)
  3760. {
  3761. this.PID = input.GetVS32();
  3762. this.PrivateMemorySize64 = input.GetVS64();
  3763. this.ActiveGameObjectCount = input.GetVS32();
  3764. this.ActiveInstanceZoneCount = input.GetVS32();
  3765. this.AllocGameObjectCount = input.GetVS32();
  3766. this.AllocInstanceZoneCount = input.GetVS32();
  3767. }
  3768. }
  3769. /// <summary>
  3770. /// 通知客户端服务器报错
  3771. /// </summary>
  3772. [MessageType(0x8605)]
  3773. public class ServerExceptionB2C : Event, SystemMessage
  3774. {
  3775. public string Message;
  3776. public string StackTrace;
  3777. public ServerExceptionB2C() { }
  3778. public ServerExceptionB2C(string message, string stackTrace)
  3779. {
  3780. this.Message = message;
  3781. this.StackTrace = stackTrace;
  3782. }
  3783. public override void WriteExternal(IOutputStream output)
  3784. {
  3785. output.PutUTF(this.Message);
  3786. output.PutUTF(this.StackTrace);
  3787. }
  3788. public override void ReadExternal(IInputStream input)
  3789. {
  3790. this.Message = input.GetUTF();
  3791. this.StackTrace = input.GetUTF();
  3792. }
  3793. }
  3794. [MessageType(0x8606)]
  3795. public class UnitFollowAction : ObjectAction
  3796. {
  3797. public bool follow = false;
  3798. public string reason = null;
  3799. public UnitFollowAction() { }
  3800. public UnitFollowAction(uint unit_id, bool guard)
  3801. : base(unit_id)
  3802. {
  3803. this.follow = guard;
  3804. }
  3805. public UnitFollowAction(uint unit_id, bool guard, string reason)
  3806. : base(unit_id)
  3807. {
  3808. this.follow = guard;
  3809. this.reason = reason;
  3810. }
  3811. override public void WriteExternal(IOutputStream output)
  3812. {
  3813. base.WriteExternal(output);
  3814. output.PutBool(follow);
  3815. output.PutUTF(reason);
  3816. }
  3817. override public void ReadExternal(IInputStream input)
  3818. {
  3819. base.ReadExternal(input);
  3820. this.follow = input.GetBool();
  3821. this.reason = input.GetUTF();
  3822. }
  3823. }
  3824. #endregion
  3825. //--------------------------------------------------------------------------
  3826. /// <summary>
  3827. /// 新增技能移动的协议
  3828. /// </summary>
  3829. [MessageType(0x8700)]
  3830. public class SkillMove : ObjectAction
  3831. {
  3832. public int SkillID;
  3833. public Vector2 SkillPos;
  3834. public SkillMove() { }
  3835. public SkillMove(uint unit_id, int skill_id, Vector2 vec):base(unit_id)
  3836. {
  3837. this.SkillID = skill_id;
  3838. this.SkillPos = vec;
  3839. }
  3840. override public void WriteExternal(IOutputStream output)
  3841. {
  3842. base.WriteExternal(output);
  3843. output.PutS32(SkillID);
  3844. output.PutF32(SkillPos.X);
  3845. output.PutF32(SkillPos.Y);
  3846. }
  3847. override public void ReadExternal(IInputStream input)
  3848. {
  3849. base.ReadExternal(input);
  3850. this.SkillID = input.GetS32();
  3851. this.SkillPos = new Vector2();
  3852. this.SkillPos.SetX(input.GetF32());
  3853. this.SkillPos.SetY(input.GetF32());
  3854. }
  3855. }
  3856. /// <summary>
  3857. /// 法术Dispose后,在播放一个过渡特效
  3858. /// </summary>
  3859. [MessageType(0x8701)]
  3860. public class PlayDestoryEffect : ZoneEvent
  3861. {
  3862. public string EffectName;
  3863. public float X;
  3864. public float Y;
  3865. public float Z;
  3866. //rotation
  3867. public float Direction;
  3868. public PlayDestoryEffect() { }
  3869. public PlayDestoryEffect(string effectName, float x, float y, float z, float direction)
  3870. {
  3871. EffectName = effectName;
  3872. X = x;
  3873. Y = y;
  3874. Z = z;
  3875. Direction = direction;
  3876. }
  3877. override public void WriteExternal(IOutputStream output)
  3878. {
  3879. output.PutUTF(EffectName);
  3880. output.PutF32(X);
  3881. output.PutF32(Y);
  3882. output.PutF32(Z);
  3883. output.PutF32(Direction);
  3884. }
  3885. override public void ReadExternal(IInputStream input)
  3886. {
  3887. this.EffectName = input.GetUTF();
  3888. this.X = input.GetF32();
  3889. this.Y = input.GetF32();
  3890. this.Z = input.GetF32();
  3891. this.Direction = input.GetF32();
  3892. }
  3893. }
  3894. /// <summary>
  3895. /// 随从瞬移
  3896. /// </summary>
  3897. [MessageType(0x8702)]
  3898. public class PlayPetTeleportAction : ObjectAction
  3899. {
  3900. public PlayPetTeleportAction() { }
  3901. override public void WriteExternal(IOutputStream output)
  3902. {
  3903. }
  3904. override public void ReadExternal(IInputStream input)
  3905. {
  3906. }
  3907. }
  3908. /// <summary>
  3909. /// 刷新玩家天赋相关信息
  3910. ///
  3911. /// </summary>
  3912. [MessageType(0x8703)]
  3913. public class RefreshTalnetInfo: PlayerSingleMsg
  3914. {
  3915. //根据不同职业,不同解读
  3916. //战士:value:怒气值,lv:无
  3917. //法师:value: 剑气值,lv:剑气层数
  3918. public short value; //天赋值,每秒降低,服务器刷新
  3919. public byte lv;
  3920. public int lvUpdateTime; //等级最后刷新时间,变化不频繁,需要根据本地时间自己做进度效果(lv=0无)
  3921. public RefreshTalnetInfo() { }
  3922. public RefreshTalnetInfo(short value, byte lv = 0, int updateTime = 0)
  3923. {
  3924. this.value = value;
  3925. this.lv = lv;
  3926. this.lvUpdateTime = updateTime;
  3927. }
  3928. override public void WriteExternal(IOutputStream output)
  3929. {
  3930. output.PutS16(this.value);
  3931. output.PutU8(this.lv);
  3932. if(this.lv > 0)
  3933. {
  3934. output.PutS32(this.lvUpdateTime);
  3935. }
  3936. }
  3937. override public void ReadExternal(IInputStream input)
  3938. {
  3939. this.value = input.GetS16();
  3940. this.lv = input.GetU8();
  3941. if(this.lv > 0)
  3942. {
  3943. this.lvUpdateTime = input.GetS32();
  3944. }
  3945. //System.Console.WriteLine("RefreshTalnetInfo: " + this.value + ", " + this.lv + ", " + this.lvUpdateTime);
  3946. }
  3947. }
  3948. /// <summary>
  3949. /// 刷新玩家卡牌珠相关信息
  3950. /// </summary>
  3951. [MessageType(0x8704)]
  3952. public class RefreshCardInfo : PlayerSingleMsg
  3953. {
  3954. public byte[] cardData = new byte[(int)CardType.Max]; //0-3代表有
  3955. public RefreshCardInfo()
  3956. {
  3957. for(int i = 0; i < (int)CardType.Max; i++)
  3958. {
  3959. cardData[i] = (byte)CardType.Max;
  3960. }
  3961. }
  3962. override public void WriteExternal(IOutputStream output)
  3963. {
  3964. for(int i = 0; i < (int)CardType.Max; i++)
  3965. {
  3966. output.PutU8(cardData[i]);
  3967. }
  3968. //System.Console.WriteLine("--------RefreshCardInfo: " + cardData[0] + ", " + cardData[1] + ", " + cardData[2] + ", " + cardData[3]);
  3969. }
  3970. override public void ReadExternal(IInputStream input)
  3971. {
  3972. //System.Console.WriteLine("--------RefreshCardInfo");
  3973. for (int i = 0; i < (int)CardType.Max; i++)
  3974. {
  3975. cardData[i] = input.GetU8();
  3976. }
  3977. //System.Console.WriteLine("--------RefreshCardInfo: " + cardData[0] + ", " + cardData[1] + ", " + cardData[2] + ", " + cardData[3]);
  3978. }
  3979. }
  3980. /// <summary>
  3981. /// 玩家卡牌释放逻辑
  3982. /// </summary>
  3983. [MessageType(0x8705)]
  3984. public class PlayerLaunchCardSkill : PlayerSingleMsg
  3985. {
  3986. public int cardSkill;
  3987. public CardType type;
  3988. public byte layer;
  3989. public byte[] cardData = new byte[(int)CardType.Max]; //0-3代表有
  3990. public PlayerLaunchCardSkill() { }
  3991. override public void WriteExternal(IOutputStream output)
  3992. {
  3993. output.PutS32(this.cardSkill);
  3994. output.PutEnum8(type);
  3995. output.PutU8(this.layer);
  3996. for (int i = 0; i < (int)CardType.Max; i++)
  3997. {
  3998. output.PutU8(cardData[i]);
  3999. }
  4000. //System.Console.WriteLine("--------PlayerLaunchCardSkill: " + cardSkill + ", " + this.type);
  4001. }
  4002. override public void ReadExternal(IInputStream input)
  4003. {
  4004. //
  4005. this.cardSkill = input.GetS32();
  4006. this.type = input.GetEnum8<CardType>();
  4007. this.layer = input.GetU8();
  4008. for (int i = 0; i < (int)CardType.Max; i++)
  4009. {
  4010. cardData[i] = input.GetU8();
  4011. }
  4012. //System.Console.WriteLine("--------PlayerLaunchCardSkill: " + cardSkill + ", " + this.type);
  4013. }
  4014. }
  4015. /// <summary>
  4016. /// 刷新Boss卡牌珠相关信息
  4017. /// </summary>
  4018. [MessageType(0x8706)]
  4019. public class RefreshBossCardInfo : ObjectEvent
  4020. {
  4021. public byte[] cardData = new byte[(int)CardType.Max]; //0-3代表有
  4022. public RefreshBossCardInfo()
  4023. {
  4024. this.init();
  4025. }
  4026. public RefreshBossCardInfo(uint objId) : base(objId)
  4027. {
  4028. this.init();
  4029. }
  4030. private void init()
  4031. {
  4032. for (int i = 0; i < (int)CardType.Max; i++)
  4033. {
  4034. cardData[i] = (byte)CardType.Max;
  4035. }
  4036. }
  4037. override public void WriteExternal(IOutputStream output)
  4038. {
  4039. base.WriteExternal(output);
  4040. for (int i = 0; i < (int)CardType.Max; i++)
  4041. {
  4042. output.PutU8(cardData[i]);
  4043. }
  4044. //System.Console.WriteLine("RefreshBossCardInfo: " + this.object_id +", " + cardData[0] + ", " + cardData[1] + ", " + cardData[2] + ", " + cardData[3]);
  4045. }
  4046. override public void ReadExternal(IInputStream input)
  4047. {
  4048. base.ReadExternal(input);
  4049. for (int i = 0; i < (int)CardType.Max; i++)
  4050. {
  4051. cardData[i] = input.GetU8();
  4052. }
  4053. //System.Console.WriteLine("objectID: " + this.object_id);
  4054. //System.Console.WriteLine("--------RefreshBossCardInfo: " + this.object_id + ", " + cardData[0] + ", " + cardData[1] + ", " + cardData[2] + ", " + cardData[3]);
  4055. }
  4056. }
  4057. /// <summary>
  4058. /// 玩家卡牌释放逻辑
  4059. /// </summary>
  4060. [MessageType(0x8707)]
  4061. public class BossTriggerCardSkill : ObjectEvent
  4062. {
  4063. public int cardSkill;
  4064. public CardType type;
  4065. public byte layer;
  4066. public byte[] cardData = new byte[(int)CardType.Max]; //0-3代表有
  4067. public BossTriggerCardSkill() { }
  4068. public BossTriggerCardSkill(uint objId) : base(objId){ }
  4069. override public void WriteExternal(IOutputStream output)
  4070. {
  4071. base.WriteExternal(output);
  4072. output.PutS32(this.cardSkill);
  4073. output.PutEnum8(type);
  4074. output.PutU8(this.layer);
  4075. for (int i = 0; i < (int)CardType.Max; i++)
  4076. {
  4077. output.PutU8(cardData[i]);
  4078. }
  4079. //System.Console.WriteLine("BossTriggerCardSkill: " + this.object_id + ", " + cardData[0] + ", " + cardData[1] + ", " + cardData[2] + ", " + cardData[3]);
  4080. }
  4081. override public void ReadExternal(IInputStream input)
  4082. {
  4083. base.ReadExternal(input);
  4084. this.cardSkill = input.GetS32();
  4085. this.type = input.GetEnum8<CardType>();
  4086. this.layer = input.GetU8();
  4087. for (int i = 0; i < (int)CardType.Max; i++)
  4088. {
  4089. cardData[i] = input.GetU8();
  4090. }
  4091. //System.Console.WriteLine("BossTriggerCardSkill: " + this.object_id + ", " + cardData[0] + ", " + cardData[1] + ", " + cardData[2] + ", " + cardData[3]);
  4092. }
  4093. }
  4094. /// <summary>
  4095. /// 单位PK模式改变通知.
  4096. /// </summary>
  4097. [MessageType(0x8708)]
  4098. public class PlayerPKModeChangeEventB2C : ObjectEvent
  4099. {
  4100. public PKMode CurMode = PKMode.Peace;
  4101. public PlayerPKModeChangeEventB2C() { }
  4102. public PlayerPKModeChangeEventB2C(uint objId, PKMode mode) : base(objId)
  4103. {
  4104. this.CurMode = mode;
  4105. }
  4106. public override void WriteExternal(IOutputStream output)
  4107. {
  4108. base.WriteExternal(output);
  4109. output.PutEnum8(CurMode);
  4110. }
  4111. public override void ReadExternal(IInputStream input)
  4112. {
  4113. base.ReadExternal(input);
  4114. CurMode = input.GetEnum8<PKMode>();
  4115. }
  4116. }
  4117. }