Messages.cs 129 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453
  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. for (int i = 0; i < (int)CardType.Max; i++)
  4025. {
  4026. cardData[i] = (byte)CardType.Max;
  4027. }
  4028. }
  4029. override public void WriteExternal(IOutputStream output)
  4030. {
  4031. base.WriteExternal(output);
  4032. for (int i = 0; i < (int)CardType.Max; i++)
  4033. {
  4034. output.PutU8(cardData[i]);
  4035. }
  4036. //System.Console.WriteLine("RefreshBossCardInfo: " + this.object_id +", " + cardData[0] + ", " + cardData[1] + ", " + cardData[2] + ", " + cardData[3]);
  4037. }
  4038. override public void ReadExternal(IInputStream input)
  4039. {
  4040. base.ReadExternal(input);
  4041. for (int i = 0; i < (int)CardType.Max; i++)
  4042. {
  4043. cardData[i] = input.GetU8();
  4044. }
  4045. //System.Console.WriteLine("objectID: " + this.object_id);
  4046. //System.Console.WriteLine("--------RefreshBossCardInfo: " + this.object_id + ", " + cardData[0] + ", " + cardData[1] + ", " + cardData[2] + ", " + cardData[3]);
  4047. }
  4048. }
  4049. /// <summary>
  4050. /// 玩家卡牌释放逻辑
  4051. /// </summary>
  4052. [MessageType(0x8707)]
  4053. public class BossTriggerCardSkill : ObjectEvent
  4054. {
  4055. public int cardSkill;
  4056. public CardType type;
  4057. public byte layer;
  4058. public byte[] cardData = new byte[(int)CardType.Max]; //0-3代表有
  4059. public BossTriggerCardSkill() { }
  4060. override public void WriteExternal(IOutputStream output)
  4061. {
  4062. base.WriteExternal(output);
  4063. output.PutS32(this.cardSkill);
  4064. output.PutEnum8(type);
  4065. output.PutU8(this.layer);
  4066. for (int i = 0; i < (int)CardType.Max; i++)
  4067. {
  4068. output.PutU8(cardData[i]);
  4069. }
  4070. //System.Console.WriteLine("BossTriggerCardSkill: " + this.object_id + ", " + cardData[0] + ", " + cardData[1] + ", " + cardData[2] + ", " + cardData[3]);
  4071. }
  4072. override public void ReadExternal(IInputStream input)
  4073. {
  4074. base.ReadExternal(input);
  4075. this.cardSkill = input.GetS32();
  4076. this.type = input.GetEnum8<CardType>();
  4077. this.layer = input.GetU8();
  4078. for (int i = 0; i < (int)CardType.Max; i++)
  4079. {
  4080. cardData[i] = input.GetU8();
  4081. }
  4082. //System.Console.WriteLine("BossTriggerCardSkill: " + this.object_id + ", " + cardData[0] + ", " + cardData[1] + ", " + cardData[2] + ", " + cardData[3]);
  4083. }
  4084. }
  4085. }