Messages.cs 131 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520
  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 float height;
  2776. public CameraMoveToEvent() { }
  2777. public CameraMoveToEvent(float x, float y, float height, float speed, int timeMS)
  2778. {
  2779. this.x = x;
  2780. this.y = y;
  2781. this.height = height;
  2782. this.MoveSpeedSec = speed;
  2783. this.TimeMS = timeMS;
  2784. }
  2785. override public void WriteExternal(IOutputStream output)
  2786. {
  2787. output.PutF32(x);
  2788. output.PutF32(y);
  2789. output.PutF32(height);
  2790. output.PutF32(MoveSpeedSec);
  2791. output.PutS32(TimeMS);
  2792. }
  2793. override public void ReadExternal(IInputStream input)
  2794. {
  2795. this.x = input.GetF32();
  2796. this.y = input.GetF32();
  2797. this.height = input.GetF32();
  2798. this.MoveSpeedSec = input.GetF32();
  2799. this.TimeMS = input.GetS32();
  2800. }
  2801. }
  2802. /// <summary>
  2803. /// 锁定镜头到单位
  2804. /// </summary>
  2805. [MessageType(0x8305)]
  2806. public class CameraFocusUnitEvent : ClientEvent
  2807. {
  2808. public uint ObjectID;
  2809. public CameraFocusUnitEvent() { }
  2810. public CameraFocusUnitEvent(uint oid)
  2811. {
  2812. this.ObjectID = oid;
  2813. }
  2814. override public void WriteExternal(IOutputStream output)
  2815. {
  2816. output.PutU32(ObjectID);
  2817. }
  2818. override public void ReadExternal(IInputStream input)
  2819. {
  2820. this.ObjectID = input.GetU32();
  2821. }
  2822. }
  2823. /// <summary>
  2824. /// 拉近镜头
  2825. /// </summary>
  2826. [MessageType(0x8306)]
  2827. public class CameraZoomToEvent : ClientEvent
  2828. {
  2829. /// <summary>
  2830. /// 镜头拉近距离
  2831. /// </summary>
  2832. public float ZoomDistance = 10f;
  2833. /// <summary>
  2834. /// 镜头拉近速度(每秒距离)
  2835. /// </summary>
  2836. public float ZoomSpeedSec = 1f;
  2837. public CameraZoomToEvent() { }
  2838. public CameraZoomToEvent(float distance, float speed)
  2839. {
  2840. this.ZoomDistance = distance;
  2841. this.ZoomSpeedSec = speed;
  2842. }
  2843. override public void WriteExternal(IOutputStream output)
  2844. {
  2845. output.PutF32(ZoomDistance);
  2846. output.PutF32(ZoomSpeedSec);
  2847. }
  2848. override public void ReadExternal(IInputStream input)
  2849. {
  2850. this.ZoomDistance = input.GetF32();
  2851. this.ZoomSpeedSec = input.GetF32();
  2852. }
  2853. }
  2854. /// <summary>
  2855. /// 旋转镜头
  2856. /// </summary>
  2857. [MessageType(0x8307)]
  2858. public class CameraRotateToEvent : ClientEvent
  2859. {
  2860. /// <summary>
  2861. /// 镜头旋转角度(0~360)
  2862. /// </summary>
  2863. public float RotateAngle = 10f;
  2864. /// <summary>
  2865. /// 镜头旋转速度(每秒角度)
  2866. /// </summary>
  2867. public float RotateSpeedSec = 1f;
  2868. public CameraRotateToEvent() { }
  2869. public CameraRotateToEvent(float angle, float speed)
  2870. {
  2871. this.RotateAngle = angle;
  2872. this.RotateSpeedSec = speed;
  2873. }
  2874. override public void WriteExternal(IOutputStream output)
  2875. {
  2876. output.PutF32(RotateAngle);
  2877. output.PutF32(RotateSpeedSec);
  2878. }
  2879. override public void ReadExternal(IInputStream input)
  2880. {
  2881. this.RotateAngle = input.GetF32();
  2882. this.RotateSpeedSec = input.GetF32();
  2883. }
  2884. }
  2885. /// <summary>
  2886. /// 重置镜头
  2887. /// </summary>
  2888. [MessageType(0x8308)]
  2889. public class CameraResetEvent : ClientEvent
  2890. {
  2891. public override void WriteExternal(IOutputStream output)
  2892. {
  2893. }
  2894. public override void ReadExternal(IInputStream input)
  2895. {
  2896. }
  2897. }
  2898. /// <summary>
  2899. /// 客户端动作序列
  2900. /// </summary>
  2901. [MessageType(0x8309)]
  2902. public class ClientEventQueue : ClientEvent
  2903. {
  2904. public List<ClientEvent> EventQueue = new List<ClientEvent>();
  2905. override public void WriteExternal(IOutputStream output)
  2906. {
  2907. output.PutU8((byte)EventQueue.Count);
  2908. foreach (ClientEvent e in EventQueue)
  2909. {
  2910. output.PutExt(e);
  2911. }
  2912. }
  2913. override public void ReadExternal(IInputStream input)
  2914. {
  2915. int count = input.GetU8();
  2916. for (int i = 0; i < count; i++)
  2917. {
  2918. EventQueue.Add(input.GetExtAny() as ClientEvent);
  2919. }
  2920. }
  2921. }
  2922. /// <summary>
  2923. /// 移动锁定一段时间
  2924. /// </summary>
  2925. [MessageType(0x830B)]
  2926. public class CameraHoldEvent : ClientEvent
  2927. {
  2928. public float x;
  2929. public float y;
  2930. public int TimeMS;
  2931. public CameraHoldEvent() { }
  2932. public CameraHoldEvent(float x, float y, int timeMS)
  2933. {
  2934. this.x = x;
  2935. this.y = y;
  2936. this.TimeMS = timeMS;
  2937. }
  2938. override public void WriteExternal(IOutputStream output)
  2939. {
  2940. output.PutF32(x);
  2941. output.PutF32(y);
  2942. output.PutS32(TimeMS);
  2943. }
  2944. override public void ReadExternal(IInputStream input)
  2945. {
  2946. this.x = input.GetF32();
  2947. this.y = input.GetF32();
  2948. this.TimeMS = input.GetS32();
  2949. }
  2950. }
  2951. /// <summary>
  2952. /// 战斗服通知客户端string消息
  2953. /// </summary>
  2954. [MessageType(0x830C)]
  2955. public class ClientMsgEvent : ClientEvent
  2956. {
  2957. public string Message;
  2958. public ClientMsgEvent() { }
  2959. public ClientMsgEvent(string msg)
  2960. {
  2961. this.Message = msg;
  2962. }
  2963. override public void WriteExternal(IOutputStream output)
  2964. {
  2965. output.PutUTF(Message);
  2966. }
  2967. override public void ReadExternal(IInputStream input)
  2968. {
  2969. this.Message = input.GetUTF();
  2970. }
  2971. }
  2972. #endregion
  2973. //--------------------------------------------------------------------------
  2974. #region PLAYER_EVENTS_0x8400
  2975. public abstract class PlayerEvent : ObjectEvent
  2976. {
  2977. public PlayerEvent() { }
  2978. public PlayerEvent(uint objID) : base(objID) { }
  2979. }
  2980. [MessageType(0x8400)]
  2981. public class PlayerCDEvent : PlayerEvent
  2982. {
  2983. private byte mask = 0;
  2984. public bool is_all
  2985. {
  2986. get { return BitMask.BitGetMask(mask, 0); }
  2987. set { BitMask.BitSetMask(ref mask, 0, value); }
  2988. }
  2989. public bool is_decrease_time
  2990. {
  2991. get { return BitMask.BitGetMask(mask, 1); }
  2992. set { BitMask.BitSetMask(ref mask, 1, value); }
  2993. }
  2994. public bool is_decrease_pct
  2995. {
  2996. get { return BitMask.BitGetMask(mask, 2); }
  2997. set { BitMask.BitSetMask(ref mask, 2, value); }
  2998. }
  2999. public bool is_clear
  3000. {
  3001. get { return BitMask.BitGetMask(mask, 3); }
  3002. set { BitMask.BitSetMask(ref mask, 3, value); }
  3003. }
  3004. public int decrease_timeMS;
  3005. public float decrease_pct;
  3006. public int skill_template_id;
  3007. public PlayerCDEvent() { }
  3008. public PlayerCDEvent(uint unit_id) : base(unit_id) { }
  3009. override public void WriteExternal(IOutputStream output)
  3010. {
  3011. base.WriteExternal(output);
  3012. output.PutU8(mask);
  3013. if (is_all)
  3014. {
  3015. if (is_decrease_pct)
  3016. output.PutF32(decrease_pct);
  3017. if (is_decrease_time)
  3018. output.PutVS32(decrease_timeMS);
  3019. }
  3020. else
  3021. {
  3022. output.PutS32(skill_template_id);
  3023. if (is_decrease_pct)
  3024. output.PutF32(decrease_pct);
  3025. if (is_decrease_time)
  3026. output.PutVS32(decrease_timeMS);
  3027. }
  3028. }
  3029. override public void ReadExternal(IInputStream input)
  3030. {
  3031. base.ReadExternal(input);
  3032. this.mask = input.GetU8();
  3033. if (is_all)
  3034. {
  3035. if (is_decrease_pct)
  3036. decrease_pct = input.GetF32();
  3037. if (is_decrease_time)
  3038. decrease_timeMS = input.GetVS32();
  3039. }
  3040. else
  3041. {
  3042. skill_template_id = input.GetS32();
  3043. if (is_decrease_pct)
  3044. decrease_pct = input.GetF32();
  3045. if (is_decrease_time)
  3046. decrease_timeMS = input.GetVS32();
  3047. }
  3048. }
  3049. }
  3050. [MessageType(0x8401)]
  3051. public class PlayerSkillChangedEvent : PlayerEvent
  3052. {
  3053. public SkillTemplate baseSkill;
  3054. public List<SkillTemplate> skills = new List<SkillTemplate>();
  3055. public float unitFastCastRate;
  3056. public PlayerSkillChangedEvent() { }
  3057. public PlayerSkillChangedEvent(uint unit_id) : base(unit_id) { }
  3058. override public void WriteExternal(IOutputStream output)
  3059. {
  3060. base.WriteExternal(output);
  3061. output.PutF32(this.unitFastCastRate);
  3062. output.PutExt(this.baseSkill);
  3063. output.PutList<SkillTemplate>(this.skills, output.PutExt);
  3064. }
  3065. override public void ReadExternal(IInputStream input)
  3066. {
  3067. base.ReadExternal(input);
  3068. this.unitFastCastRate = input.GetF32();
  3069. this.baseSkill = input.GetExt<SkillTemplate>();
  3070. this.skills = input.GetList<SkillTemplate>(input.GetExt<SkillTemplate>);
  3071. }
  3072. }
  3073. [MessageType(0x8402)]
  3074. public class PlayerSyncEnvironmentVarEvent : PlayerEvent
  3075. {
  3076. public string Key;
  3077. public object Value;
  3078. public PlayerSyncEnvironmentVarEvent() { }
  3079. public PlayerSyncEnvironmentVarEvent(uint unit_id, string key, object value)
  3080. : base(unit_id)
  3081. {
  3082. this.Key = key;
  3083. this.Value = value;
  3084. }
  3085. override public void WriteExternal(IOutputStream output)
  3086. {
  3087. base.WriteExternal(output);
  3088. output.PutUTF(Key);
  3089. output.PutData(Value);
  3090. }
  3091. override public void ReadExternal(IInputStream input)
  3092. {
  3093. base.ReadExternal(input);
  3094. DataType dtype;
  3095. this.Key = input.GetUTF();
  3096. this.Value = input.GetData(out dtype);
  3097. }
  3098. }
  3099. [MessageType(0x8403)]
  3100. public class PlayerSkillStopEvent : PlayerEvent
  3101. {
  3102. public int SkillID;
  3103. public PlayerSkillStopEvent() { }
  3104. public PlayerSkillStopEvent(uint unit_id, int skillID)
  3105. : base(unit_id)
  3106. {
  3107. this.SkillID = skillID;
  3108. }
  3109. override public void WriteExternal(IOutputStream output)
  3110. {
  3111. base.WriteExternal(output);
  3112. output.PutS32(SkillID);
  3113. }
  3114. override public void ReadExternal(IInputStream input)
  3115. {
  3116. base.ReadExternal(input);
  3117. this.SkillID = input.GetS32();
  3118. }
  3119. }
  3120. [MessageType(0x8404)]
  3121. public class PlayerSkillAddedEvent : PlayerEvent
  3122. {
  3123. public SkillTemplate Skill;
  3124. public bool IsDefault;
  3125. public PlayerSkillAddedEvent() { }
  3126. public PlayerSkillAddedEvent(uint unit_id, SkillTemplate sk, bool isDefault)
  3127. : base(unit_id)
  3128. {
  3129. this.Skill = sk;
  3130. this.IsDefault = isDefault;
  3131. }
  3132. override public void WriteExternal(IOutputStream output)
  3133. {
  3134. base.WriteExternal(output);
  3135. output.PutExt(this.Skill);
  3136. output.PutBool(this.IsDefault);
  3137. }
  3138. override public void ReadExternal(IInputStream input)
  3139. {
  3140. base.ReadExternal(input);
  3141. this.Skill = input.GetExt<SkillTemplate>();
  3142. this.IsDefault = input.GetBool();
  3143. }
  3144. }
  3145. [MessageType(0x8405)]
  3146. public class PlayerSkillRemovedEvent : PlayerEvent
  3147. {
  3148. public int SkillID;
  3149. public PlayerSkillRemovedEvent() { }
  3150. public PlayerSkillRemovedEvent(uint unit_id, int skillID)
  3151. : base(unit_id)
  3152. {
  3153. this.SkillID = skillID;
  3154. }
  3155. override public void WriteExternal(IOutputStream output)
  3156. {
  3157. base.WriteExternal(output);
  3158. output.PutS32(this.SkillID);
  3159. }
  3160. override public void ReadExternal(IInputStream input)
  3161. {
  3162. base.ReadExternal(input);
  3163. this.SkillID = input.GetS32();
  3164. }
  3165. }
  3166. /// <summary>
  3167. /// 脚本系统指令
  3168. /// </summary>
  3169. [MessageType(0x8406)]
  3170. public class PlayerScriptCommandEvent : PlayerEvent
  3171. {
  3172. public string message;
  3173. public PlayerScriptCommandEvent() { }
  3174. public PlayerScriptCommandEvent(uint unit_id, string msg)
  3175. : base(unit_id)
  3176. {
  3177. this.message = msg;
  3178. }
  3179. override public void WriteExternal(IOutputStream output)
  3180. {
  3181. base.WriteExternal(output);
  3182. output.PutUTF(message);
  3183. }
  3184. override public void ReadExternal(IInputStream input)
  3185. {
  3186. base.ReadExternal(input);
  3187. this.message = input.GetUTF();
  3188. }
  3189. }
  3190. /// <summary>
  3191. /// 技能可用性发生变化
  3192. /// </summary>
  3193. [MessageType(0x8407)]
  3194. public class PlayerSkillActiveChangedEvent : PlayerEvent
  3195. {
  3196. public struct State
  3197. {
  3198. public int SkillTemplateID;
  3199. public SkillActiveState ST;
  3200. public bool IsActive { get { return ST == SkillActiveState.Active; } }
  3201. public bool IsPauseOnDeactive { get { return ST == SkillActiveState.DeactiveAndPause; } }
  3202. }
  3203. public List<State> Skills;
  3204. public PlayerSkillActiveChangedEvent() { this.Skills = new List<State>(); }
  3205. public PlayerSkillActiveChangedEvent(uint unit_id, int skillCount) : base(unit_id)
  3206. {
  3207. this.Skills = new List<State>(skillCount);
  3208. }
  3209. override public void WriteExternal(IOutputStream output)
  3210. {
  3211. base.WriteExternal(output);
  3212. output.PutVS32(Skills.Count);
  3213. for (int i = 0; i < Skills.Count; i++)
  3214. {
  3215. State sat = Skills[i];
  3216. output.PutS32(sat.SkillTemplateID);
  3217. output.PutEnum8(sat.ST);
  3218. }
  3219. }
  3220. override public void ReadExternal(IInputStream input)
  3221. {
  3222. base.ReadExternal(input);
  3223. int count = input.GetVS32();
  3224. this.Skills.Capacity = count;
  3225. for (int i = 0; i < count; i++)
  3226. {
  3227. State sat = new State();
  3228. sat.SkillTemplateID = input.GetS32();
  3229. sat.ST = input.GetEnum8<SkillActiveState>();
  3230. this.Skills.Add(sat);
  3231. }
  3232. }
  3233. }
  3234. [MessageType(0x8408)]
  3235. public class PlayerSkillTimeChangedEvent : PlayerEvent
  3236. {
  3237. public int SkillTemplateID;
  3238. public int SkillPassTimeMS;
  3239. public int SkillTotalTimeMS;
  3240. public PlayerSkillTimeChangedEvent() { }
  3241. public PlayerSkillTimeChangedEvent(uint unit_id, int skillID, int passTimeMS, int totalTimeMS)
  3242. : base(unit_id)
  3243. {
  3244. this.SkillTemplateID = skillID;
  3245. this.SkillPassTimeMS = passTimeMS;
  3246. this.SkillTotalTimeMS = totalTimeMS;
  3247. }
  3248. override public void WriteExternal(IOutputStream output)
  3249. {
  3250. base.WriteExternal(output);
  3251. output.PutS32(this.SkillTemplateID);
  3252. output.PutVS32(this.SkillPassTimeMS);
  3253. output.PutVS32(this.SkillTotalTimeMS);
  3254. }
  3255. override public void ReadExternal(IInputStream input)
  3256. {
  3257. base.ReadExternal(input);
  3258. this.SkillTemplateID = input.GetS32();
  3259. this.SkillPassTimeMS = input.GetVS32();
  3260. this.SkillTotalTimeMS = input.GetVS32();
  3261. }
  3262. }
  3263. /// <summary>
  3264. /// 锁定目标
  3265. /// </summary>
  3266. [MessageType(0x8409)]
  3267. public class PlayerFocuseTargetEvent : PlayerEvent
  3268. {
  3269. public uint targetUnitID;
  3270. public SkillTemplate.CastTarget expectTarget;
  3271. public PlayerFocuseTargetEvent() { }
  3272. public PlayerFocuseTargetEvent(uint unit_id, uint target_id, SkillTemplate.CastTarget expect)
  3273. : base(unit_id)
  3274. {
  3275. this.targetUnitID = target_id;
  3276. this.expectTarget = expect;
  3277. }
  3278. override public void WriteExternal(IOutputStream output)
  3279. {
  3280. base.WriteExternal(output);
  3281. output.PutU32(targetUnitID);
  3282. output.PutEnum8(expectTarget);
  3283. }
  3284. override public void ReadExternal(IInputStream input)
  3285. {
  3286. base.ReadExternal(input);
  3287. this.targetUnitID = input.GetU32();
  3288. this.expectTarget = input.GetEnum8<SkillTemplate.CastTarget>();
  3289. }
  3290. }
  3291. #endregion
  3292. //--------------------------------------------------------------------------
  3293. #region TEXT_0x8500
  3294. public enum ChatMessageType : byte
  3295. {
  3296. SystemToAll,
  3297. SystemToForce,
  3298. SystemToPlayer,
  3299. PlayerToAll,
  3300. PlayerToForce,
  3301. PlayerToPlayer,
  3302. }
  3303. [MessageType(0x8500)]
  3304. public class ChatAction : ObjectAction
  3305. {
  3306. public string Message;
  3307. public ChatMessageType To = ChatMessageType.SystemToAll;
  3308. public string TargetPlayerUUID;
  3309. public override void WriteExternal(IOutputStream output)
  3310. {
  3311. base.WriteExternal(output);
  3312. output.PutU8((byte)this.To);
  3313. output.PutUTF(this.Message);
  3314. output.PutUTF(this.TargetPlayerUUID);
  3315. }
  3316. public override void ReadExternal(IInputStream input)
  3317. {
  3318. base.ReadExternal(input);
  3319. this.To = (ChatMessageType)input.GetU8();
  3320. this.Message = input.GetUTF();
  3321. this.TargetPlayerUUID = input.GetUTF();
  3322. }
  3323. }
  3324. [MessageType(0x8501)]
  3325. public class ChatEvent : ZoneEvent
  3326. {
  3327. public ChatMessageType To = ChatMessageType.SystemToAll;
  3328. public int Force;
  3329. public string FromPlayerUUID;
  3330. public string ToPlayerUUID;
  3331. public string Message;
  3332. public uint KeepTimeMS;
  3333. public ChatEvent() { }
  3334. public ChatEvent(ChatMessageType to, uint timeMS = 2000)
  3335. {
  3336. this.To = to;
  3337. KeepTimeMS = timeMS;
  3338. }
  3339. public override void WriteExternal(IOutputStream output)
  3340. {
  3341. output.PutU8((byte)this.To);
  3342. output.PutVS32((int)KeepTimeMS);
  3343. output.PutUTF(this.Message);
  3344. switch (To)
  3345. {
  3346. case ChatMessageType.PlayerToAll:
  3347. output.PutUTF(this.FromPlayerUUID);
  3348. break;
  3349. case ChatMessageType.PlayerToForce:
  3350. output.PutUTF(this.FromPlayerUUID);
  3351. output.PutVS32(this.Force);
  3352. break;
  3353. case ChatMessageType.PlayerToPlayer:
  3354. output.PutUTF(this.FromPlayerUUID);
  3355. output.PutUTF(this.ToPlayerUUID);
  3356. break;
  3357. case ChatMessageType.SystemToAll:
  3358. break;
  3359. case ChatMessageType.SystemToForce:
  3360. output.PutVS32(this.Force);
  3361. break;
  3362. case ChatMessageType.SystemToPlayer:
  3363. output.PutUTF(this.ToPlayerUUID);
  3364. break;
  3365. }
  3366. }
  3367. public override void ReadExternal(IInputStream input)
  3368. {
  3369. this.To = (ChatMessageType)input.GetU8();
  3370. this.KeepTimeMS = (uint)input.GetVS32();
  3371. this.Message = input.GetUTF();
  3372. switch (To)
  3373. {
  3374. case ChatMessageType.PlayerToAll:
  3375. this.FromPlayerUUID = input.GetUTF();
  3376. break;
  3377. case ChatMessageType.PlayerToForce:
  3378. this.FromPlayerUUID = input.GetUTF();
  3379. this.Force = input.GetVS32();
  3380. break;
  3381. case ChatMessageType.PlayerToPlayer:
  3382. this.FromPlayerUUID = input.GetUTF();
  3383. this.ToPlayerUUID = input.GetUTF();
  3384. break;
  3385. case ChatMessageType.SystemToAll:
  3386. break;
  3387. case ChatMessageType.SystemToForce:
  3388. this.Force = input.GetVS32();
  3389. break;
  3390. case ChatMessageType.SystemToPlayer:
  3391. this.ToPlayerUUID = input.GetUTF();
  3392. break;
  3393. }
  3394. }
  3395. }
  3396. [MessageType(0x8502)]
  3397. public class BubbleTalkEvent : ZoneEvent
  3398. {
  3399. public bool PauseBattle;
  3400. public List<TalkInfo> TalkInfos = new List<TalkInfo>();
  3401. public BubbleTalkEvent() { }
  3402. override public void WriteExternal(IOutputStream output)
  3403. {
  3404. output.PutBool(PauseBattle);
  3405. output.PutExtList<TalkInfo>(this.TalkInfos);
  3406. }
  3407. override public void ReadExternal(IInputStream input)
  3408. {
  3409. this.PauseBattle = input.GetBool();
  3410. this.TalkInfos = input.GetExtList<TalkInfo>();
  3411. }
  3412. public class TalkInfo : IExternalizable
  3413. {
  3414. public uint TalkUnit;
  3415. public string TalkContent;
  3416. public string TalkActionType;
  3417. public int TalkDelayTimeMS;
  3418. public int TalkKeepTimeMS;
  3419. public TalkInfo() { }
  3420. public TalkInfo(uint TalkUnit, string TalkContent, string TalkActionType, int TalkDelayTimeMS, int TalkKeepTimeMS)
  3421. {
  3422. this.TalkUnit = TalkUnit;
  3423. this.TalkContent = TalkContent;
  3424. this.TalkActionType = TalkActionType;
  3425. this.TalkDelayTimeMS = TalkDelayTimeMS;
  3426. this.TalkKeepTimeMS = TalkKeepTimeMS;
  3427. }
  3428. public void WriteExternal(IOutputStream output)
  3429. {
  3430. output.PutVU32(TalkUnit);
  3431. output.PutUTF(TalkContent);
  3432. output.PutUTF(TalkActionType);
  3433. output.PutVS32(TalkDelayTimeMS);
  3434. output.PutVS32(TalkKeepTimeMS);
  3435. }
  3436. public void ReadExternal(IInputStream input)
  3437. {
  3438. this.TalkUnit = input.GetVU32();
  3439. this.TalkContent = input.GetUTF();
  3440. this.TalkActionType = input.GetUTF();
  3441. this.TalkDelayTimeMS = input.GetVS32();
  3442. this.TalkKeepTimeMS = input.GetVS32();
  3443. }
  3444. }
  3445. }
  3446. [MessageType(0x8503)]
  3447. public class PlayerSkillUseTimeChangedEvent : PlayerEvent
  3448. {
  3449. public int SkillTemplateID;
  3450. public byte useTimes;
  3451. public byte hasNext; //0-不用继续叠层,1-继续增加叠层
  3452. public PlayerSkillUseTimeChangedEvent() { }
  3453. public PlayerSkillUseTimeChangedEvent(uint unit_id, int skillID, byte useTimes)
  3454. : base(unit_id)
  3455. {
  3456. this.SkillTemplateID = skillID;
  3457. this.useTimes = useTimes;
  3458. }
  3459. override public void WriteExternal(IOutputStream output)
  3460. {
  3461. base.WriteExternal(output);
  3462. output.PutS32(this.SkillTemplateID);
  3463. output.PutU8(this.useTimes);
  3464. output.PutU8(this.hasNext);
  3465. }
  3466. override public void ReadExternal(IInputStream input)
  3467. {
  3468. base.ReadExternal(input);
  3469. this.SkillTemplateID = input.GetS32();
  3470. this.useTimes = input.GetU8();
  3471. this.hasNext = input.GetU8();
  3472. }
  3473. }
  3474. /// <summary>
  3475. /// 单位中BUFF
  3476. /// </summary>
  3477. [MessageType(0x8504)]
  3478. public class SyncUnitBuffState : ObjectEvent
  3479. {
  3480. public int buffTemplateID;
  3481. public byte overlayLevel;
  3482. public int buffExtData; //buff的扩展字段,
  3483. public SyncUnitBuffState() { }
  3484. public SyncUnitBuffState(uint unit_id, int buffID, byte overlayLevel, int extData)
  3485. : base(unit_id)
  3486. {
  3487. this.buffTemplateID = buffID;
  3488. this.overlayLevel = overlayLevel;
  3489. this.buffExtData = extData;
  3490. }
  3491. override public void WriteExternal(IOutputStream output)
  3492. {
  3493. base.WriteExternal(output);
  3494. output.PutVS32(buffTemplateID);
  3495. output.PutU8(overlayLevel);
  3496. output.PutVS32(buffExtData);
  3497. }
  3498. override public void ReadExternal(IInputStream input)
  3499. {
  3500. base.ReadExternal(input);
  3501. this.buffTemplateID = input.GetVS32();
  3502. this.overlayLevel = input.GetU8();
  3503. this.buffExtData = input.GetVS32();
  3504. }
  3505. }
  3506. /// <summary>
  3507. /// 单位触发能力
  3508. /// </summary>
  3509. [MessageType(0x8505)]
  3510. public class UnitTriggerAblity : ObjectEvent
  3511. {
  3512. public int ablityID;
  3513. public UnitTriggerAblity() { }
  3514. public UnitTriggerAblity(uint unit_id, int id)
  3515. : base(unit_id)
  3516. {
  3517. this.ablityID = id;
  3518. }
  3519. override public void WriteExternal(IOutputStream output)
  3520. {
  3521. base.WriteExternal(output);
  3522. output.PutVS32(ablityID);
  3523. }
  3524. override public void ReadExternal(IInputStream input)
  3525. {
  3526. base.ReadExternal(input);
  3527. this.ablityID = input.GetVS32();
  3528. }
  3529. }
  3530. /// <summary>
  3531. /// 单位触发破碎效果
  3532. /// </summary>
  3533. [MessageType(0x8506)]
  3534. public class UnitHitBreak : ObjectEvent
  3535. {
  3536. public UnitHitBreak() { }
  3537. public UnitHitBreak(uint unit_id)
  3538. : base(unit_id)
  3539. {
  3540. }
  3541. override public void WriteExternal(IOutputStream output)
  3542. {
  3543. base.WriteExternal(output);
  3544. //output.PutVS32(ablityID);
  3545. }
  3546. override public void ReadExternal(IInputStream input)
  3547. {
  3548. base.ReadExternal(input);
  3549. //this.ablityID = input.GetVS32();
  3550. }
  3551. }
  3552. /// <summary>
  3553. /// 单位触发隐身效果
  3554. /// </summary>
  3555. [MessageType(0x8507)]
  3556. public class UnitStealthInfo : ObjectEvent
  3557. {
  3558. public byte stealth;
  3559. public short flag;
  3560. public UnitStealthInfo() { }
  3561. public UnitStealthInfo(uint unit_id, byte stealth, short flag)
  3562. : base(unit_id)
  3563. {
  3564. this.stealth = stealth;
  3565. this.flag = flag;
  3566. }
  3567. override public void WriteExternal(IOutputStream output)
  3568. {
  3569. base.WriteExternal(output);
  3570. output.PutU8(this.stealth);
  3571. output.PutS16(this.flag);
  3572. //Console.WriteLine("UnitStealthInfo: " + this.stealth + ", " + flag);
  3573. }
  3574. override public void ReadExternal(IInputStream input)
  3575. {
  3576. base.ReadExternal(input);
  3577. this.stealth = input.GetU8();
  3578. this.flag = input.GetS16();
  3579. }
  3580. }
  3581. /// <summary>
  3582. /// buff数据推送:针对单一buff事件内的信息变更
  3583. /// </summary>
  3584. [MessageType(0x8508)]
  3585. public class BuffDataNotify : ObjectEvent
  3586. {
  3587. public int buffId;
  3588. public uint senderId;
  3589. public byte overlayLevel;
  3590. public BuffDataNotify() { }
  3591. public BuffDataNotify(uint unit_id, int buffId, uint senderId, int layer)
  3592. : base(unit_id)
  3593. {
  3594. this.buffId = buffId;
  3595. this.senderId = senderId;
  3596. this.overlayLevel = (byte)layer;
  3597. }
  3598. override public void WriteExternal(IOutputStream output)
  3599. {
  3600. base.WriteExternal(output);
  3601. output.PutS32(this.buffId);
  3602. output.PutU32(this.senderId);
  3603. output.PutU8(this.overlayLevel);
  3604. //System.Console.WriteLine("-----BuffDataNotify: " + buffId + ", " + this.object_id + ", " + overlayLevel);
  3605. }
  3606. override public void ReadExternal(IInputStream input)
  3607. {
  3608. base.ReadExternal(input);
  3609. this.buffId = input.GetS32();
  3610. this.senderId = input.GetU32();
  3611. this.overlayLevel = input.GetU8();
  3612. }
  3613. }
  3614. #endregion
  3615. //--------------------------------------------------------------------------
  3616. #region SYSTEM_0x8600
  3617. [MessageType(0x8600)]
  3618. public class Ping : Action, SystemMessage
  3619. {
  3620. public uint DayOfMS;
  3621. public Ping()
  3622. {
  3623. DayOfMS = (uint)CUtils.CurrentTimeMS;
  3624. }
  3625. public void Begin()
  3626. {
  3627. DayOfMS = (uint)CUtils.CurrentTimeMS;
  3628. }
  3629. public override void WriteExternal(IOutputStream output)
  3630. {
  3631. output.PutU32(DayOfMS);
  3632. }
  3633. public override void ReadExternal(IInputStream input)
  3634. {
  3635. DayOfMS = input.GetU32();
  3636. }
  3637. }
  3638. [MessageType(0x8601)]
  3639. public class Pong : Event, SystemMessage
  3640. {
  3641. public uint ClientTimeDayOfMS;
  3642. public Pong() { }
  3643. public Pong(Ping ping) { this.ClientTimeDayOfMS = ping.DayOfMS; }
  3644. public override void WriteExternal(IOutputStream output)
  3645. {
  3646. output.PutU32(ClientTimeDayOfMS);
  3647. }
  3648. public override void ReadExternal(IInputStream input)
  3649. {
  3650. ClientTimeDayOfMS = input.GetU32();
  3651. }
  3652. }
  3653. /// <summary>
  3654. /// 打包一组消息,一次性发出
  3655. /// </summary>
  3656. [MessageType(0x8602)]
  3657. public class PackEvent : Event, SystemMessage
  3658. {
  3659. protected static readonly Logger log = LoggerFactory.GetDefLogger();
  3660. public int sequenceNo;
  3661. public List<IMessage> events = new List<IMessage>();
  3662. public override string ToString()
  3663. {
  3664. var sb = new StringBuilder("PackEvent: no=").Append(sequenceNo).AppendLine();
  3665. foreach (IMessage e in events)
  3666. {
  3667. sb.AppendLine(e.ToString());
  3668. }
  3669. return sb.ToString();
  3670. }
  3671. public override void WriteExternal(IOutputStream output)
  3672. {
  3673. output.PutVS32(sequenceNo);
  3674. output.PutVS32(events.Count);
  3675. #if JSGProfile
  3676. long startSize = output.GetBuffPos();
  3677. #endif
  3678. foreach (IMessage e in events)
  3679. {
  3680. //if (!e.ToString().EndsWith("Pong") && !e.ToString().EndsWith("SyncPosEvent"))
  3681. //{
  3682. // Console.WriteLine("PackEvent: " + e);
  3683. //}
  3684. output.PutExt(e);
  3685. #if JSGProfile
  3686. long tempSize = output.GetBuffPos();
  3687. JSGServerProfile.RecordSend(output.GetTypeID(e), tempSize - startSize);
  3688. startSize = tempSize;
  3689. #endif
  3690. }
  3691. }
  3692. public override void ReadExternal(IInputStream input)
  3693. {
  3694. this.sequenceNo = input.GetVS32();
  3695. int count = input.GetVS32();
  3696. events.Clear();
  3697. events.Capacity = count;
  3698. for (int i = 0; i < count; i++)
  3699. {
  3700. try
  3701. {
  3702. IMessage e = (IMessage)input.GetExtAny();
  3703. events.Add(e);
  3704. }
  3705. catch (Exception err)
  3706. {
  3707. log.Error("PackEvent readExt catch:" + err);
  3708. }
  3709. }
  3710. }
  3711. public override void BeforeWrite(TemplateManager templates)
  3712. {
  3713. foreach (IMessage e in events)
  3714. {
  3715. if (e is BattleMessage)
  3716. {
  3717. (e as BattleMessage).BeforeWrite(templates);
  3718. }
  3719. }
  3720. }
  3721. public override void EndRead(TemplateManager templates)
  3722. {
  3723. foreach (IMessage e in events)
  3724. {
  3725. if (e is BattleMessage)
  3726. {
  3727. (e as BattleMessage).EndRead(templates);
  3728. }
  3729. }
  3730. }
  3731. }
  3732. /// <summary>
  3733. /// 系统消息框,测试用
  3734. /// </summary>
  3735. [MessageType(0x8603)]
  3736. public class TestMessageBox : Event, SystemMessage
  3737. {
  3738. public string msg;
  3739. public TestMessageBox() { }
  3740. public TestMessageBox(string msg)
  3741. {
  3742. this.msg = msg;
  3743. }
  3744. public override void WriteExternal(IOutputStream output)
  3745. {
  3746. output.PutUTF(this.msg);
  3747. }
  3748. public override void ReadExternal(IInputStream input)
  3749. {
  3750. this.msg = input.GetUTF();
  3751. }
  3752. }
  3753. /// <summary>
  3754. /// 通知客户端服务器运行状态
  3755. /// </summary>
  3756. [MessageType(0x8604)]
  3757. public class ServerStatusB2C : Event, SystemMessage
  3758. {
  3759. public int PID;
  3760. public long PrivateMemorySize64;
  3761. public int ActiveGameObjectCount;
  3762. public int ActiveInstanceZoneCount;
  3763. public int AllocGameObjectCount;
  3764. public int AllocInstanceZoneCount;
  3765. public ServerStatusB2C() { }
  3766. public void Update(System.Diagnostics.Process p)
  3767. {
  3768. this.PID = p.Id;
  3769. this.PrivateMemorySize64 = p.PrivateMemorySize64;
  3770. this.ActiveGameObjectCount = InstanceZoneObject.ActiveObjectCount;
  3771. this.ActiveInstanceZoneCount = InstanceZone.ActiveZoneCount;
  3772. this.AllocGameObjectCount = InstanceZoneObject.AllocObjectCount;
  3773. this.AllocInstanceZoneCount = InstanceZone.AllocZoneCount;
  3774. }
  3775. public override void WriteExternal(IOutputStream output)
  3776. {
  3777. output.PutVS32(this.PID);
  3778. output.PutVS64(this.PrivateMemorySize64);
  3779. output.PutVS32(this.ActiveGameObjectCount);
  3780. output.PutVS32(this.ActiveInstanceZoneCount);
  3781. output.PutVS32(this.AllocGameObjectCount);
  3782. output.PutVS32(this.AllocInstanceZoneCount);
  3783. }
  3784. public override void ReadExternal(IInputStream input)
  3785. {
  3786. this.PID = input.GetVS32();
  3787. this.PrivateMemorySize64 = input.GetVS64();
  3788. this.ActiveGameObjectCount = input.GetVS32();
  3789. this.ActiveInstanceZoneCount = input.GetVS32();
  3790. this.AllocGameObjectCount = input.GetVS32();
  3791. this.AllocInstanceZoneCount = input.GetVS32();
  3792. }
  3793. }
  3794. /// <summary>
  3795. /// 通知客户端服务器报错
  3796. /// </summary>
  3797. [MessageType(0x8605)]
  3798. public class ServerExceptionB2C : Event, SystemMessage
  3799. {
  3800. public string Message;
  3801. public string StackTrace;
  3802. public ServerExceptionB2C() { }
  3803. public ServerExceptionB2C(string message, string stackTrace)
  3804. {
  3805. this.Message = message;
  3806. this.StackTrace = stackTrace;
  3807. }
  3808. public override void WriteExternal(IOutputStream output)
  3809. {
  3810. output.PutUTF(this.Message);
  3811. output.PutUTF(this.StackTrace);
  3812. }
  3813. public override void ReadExternal(IInputStream input)
  3814. {
  3815. this.Message = input.GetUTF();
  3816. this.StackTrace = input.GetUTF();
  3817. }
  3818. }
  3819. [MessageType(0x8606)]
  3820. public class UnitFollowAction : ObjectAction
  3821. {
  3822. public bool follow = false;
  3823. public string reason = null;
  3824. public UnitFollowAction() { }
  3825. public UnitFollowAction(uint unit_id, bool guard)
  3826. : base(unit_id)
  3827. {
  3828. this.follow = guard;
  3829. }
  3830. public UnitFollowAction(uint unit_id, bool guard, string reason)
  3831. : base(unit_id)
  3832. {
  3833. this.follow = guard;
  3834. this.reason = reason;
  3835. }
  3836. override public void WriteExternal(IOutputStream output)
  3837. {
  3838. base.WriteExternal(output);
  3839. output.PutBool(follow);
  3840. output.PutUTF(reason);
  3841. }
  3842. override public void ReadExternal(IInputStream input)
  3843. {
  3844. base.ReadExternal(input);
  3845. this.follow = input.GetBool();
  3846. this.reason = input.GetUTF();
  3847. }
  3848. }
  3849. #endregion
  3850. //--------------------------------------------------------------------------
  3851. /// <summary>
  3852. /// 新增技能移动的协议
  3853. /// </summary>
  3854. [MessageType(0x8700)]
  3855. public class SkillMove : ObjectAction
  3856. {
  3857. public int SkillID;
  3858. public Vector2 SkillPos;
  3859. public SkillMove() { }
  3860. public SkillMove(uint unit_id, int skill_id, Vector2 vec):base(unit_id)
  3861. {
  3862. this.SkillID = skill_id;
  3863. this.SkillPos = vec;
  3864. }
  3865. override public void WriteExternal(IOutputStream output)
  3866. {
  3867. base.WriteExternal(output);
  3868. output.PutS32(SkillID);
  3869. output.PutF32(SkillPos.X);
  3870. output.PutF32(SkillPos.Y);
  3871. }
  3872. override public void ReadExternal(IInputStream input)
  3873. {
  3874. base.ReadExternal(input);
  3875. this.SkillID = input.GetS32();
  3876. this.SkillPos = new Vector2();
  3877. this.SkillPos.SetX(input.GetF32());
  3878. this.SkillPos.SetY(input.GetF32());
  3879. }
  3880. }
  3881. /// <summary>
  3882. /// 法术Dispose后,在播放一个过渡特效
  3883. /// </summary>
  3884. [MessageType(0x8701)]
  3885. public class PlayDestoryEffect : ZoneEvent
  3886. {
  3887. public string EffectName;
  3888. public float X;
  3889. public float Y;
  3890. public float Z;
  3891. //rotation
  3892. public float Direction;
  3893. public PlayDestoryEffect() { }
  3894. public PlayDestoryEffect(string effectName, float x, float y, float z, float direction)
  3895. {
  3896. EffectName = effectName;
  3897. X = x;
  3898. Y = y;
  3899. Z = z;
  3900. Direction = direction;
  3901. }
  3902. override public void WriteExternal(IOutputStream output)
  3903. {
  3904. output.PutUTF(EffectName);
  3905. output.PutF32(X);
  3906. output.PutF32(Y);
  3907. output.PutF32(Z);
  3908. output.PutF32(Direction);
  3909. }
  3910. override public void ReadExternal(IInputStream input)
  3911. {
  3912. this.EffectName = input.GetUTF();
  3913. this.X = input.GetF32();
  3914. this.Y = input.GetF32();
  3915. this.Z = input.GetF32();
  3916. this.Direction = input.GetF32();
  3917. }
  3918. }
  3919. /// <summary>
  3920. /// 随从瞬移
  3921. /// </summary>
  3922. [MessageType(0x8702)]
  3923. public class PlayPetTeleportAction : ObjectAction
  3924. {
  3925. public PlayPetTeleportAction() { }
  3926. override public void WriteExternal(IOutputStream output)
  3927. {
  3928. }
  3929. override public void ReadExternal(IInputStream input)
  3930. {
  3931. }
  3932. }
  3933. /// <summary>
  3934. /// 刷新玩家天赋相关信息
  3935. ///
  3936. /// </summary>
  3937. [MessageType(0x8703)]
  3938. public class RefreshTalnetInfo: PlayerSingleMsg
  3939. {
  3940. //根据不同职业,不同解读
  3941. //战士:value:怒气值,lv:无
  3942. //法师:value: 剑气值,lv:剑气层数
  3943. public short value; //天赋值,每秒降低,服务器刷新
  3944. public byte lv;
  3945. public int lvUpdateTime; //等级最后刷新时间,变化不频繁,需要根据本地时间自己做进度效果(lv=0无)
  3946. public RefreshTalnetInfo() { }
  3947. public RefreshTalnetInfo(short value, byte lv = 0, int updateTime = 0)
  3948. {
  3949. this.value = value;
  3950. this.lv = lv;
  3951. this.lvUpdateTime = updateTime;
  3952. }
  3953. override public void WriteExternal(IOutputStream output)
  3954. {
  3955. output.PutS16(this.value);
  3956. output.PutU8(this.lv);
  3957. if(this.lv > 0)
  3958. {
  3959. output.PutS32(this.lvUpdateTime);
  3960. }
  3961. }
  3962. override public void ReadExternal(IInputStream input)
  3963. {
  3964. this.value = input.GetS16();
  3965. this.lv = input.GetU8();
  3966. if(this.lv > 0)
  3967. {
  3968. this.lvUpdateTime = input.GetS32();
  3969. }
  3970. //System.Console.WriteLine("RefreshTalnetInfo: " + this.value + ", " + this.lv + ", " + this.lvUpdateTime);
  3971. }
  3972. }
  3973. /// <summary>
  3974. /// 刷新玩家卡牌珠相关信息
  3975. /// </summary>
  3976. [MessageType(0x8704)]
  3977. public class RefreshCardInfo : PlayerSingleMsg
  3978. {
  3979. public byte[] cardData = new byte[(int)CardType.Max]; //0-3代表有
  3980. public RefreshCardInfo()
  3981. {
  3982. for(int i = 0; i < (int)CardType.Max; i++)
  3983. {
  3984. cardData[i] = (byte)CardType.Max;
  3985. }
  3986. }
  3987. override public void WriteExternal(IOutputStream output)
  3988. {
  3989. for(int i = 0; i < (int)CardType.Max; i++)
  3990. {
  3991. output.PutU8(cardData[i]);
  3992. }
  3993. //System.Console.WriteLine("--------RefreshCardInfo: " + cardData[0] + ", " + cardData[1] + ", " + cardData[2] + ", " + cardData[3]);
  3994. }
  3995. override public void ReadExternal(IInputStream input)
  3996. {
  3997. //System.Console.WriteLine("--------RefreshCardInfo");
  3998. for (int i = 0; i < (int)CardType.Max; i++)
  3999. {
  4000. cardData[i] = input.GetU8();
  4001. }
  4002. //System.Console.WriteLine("--------RefreshCardInfo: " + cardData[0] + ", " + cardData[1] + ", " + cardData[2] + ", " + cardData[3]);
  4003. }
  4004. }
  4005. /// <summary>
  4006. /// 玩家卡牌释放逻辑
  4007. /// </summary>
  4008. [MessageType(0x8705)]
  4009. public class PlayerLaunchCardSkill : PlayerSingleMsg
  4010. {
  4011. public int cardSkill;
  4012. public CardType type;
  4013. public byte layer;
  4014. public byte[] cardData = new byte[(int)CardType.Max]; //0-3代表有
  4015. public PlayerLaunchCardSkill() { }
  4016. override public void WriteExternal(IOutputStream output)
  4017. {
  4018. output.PutS32(this.cardSkill);
  4019. output.PutEnum8(type);
  4020. output.PutU8(this.layer);
  4021. for (int i = 0; i < (int)CardType.Max; i++)
  4022. {
  4023. output.PutU8(cardData[i]);
  4024. }
  4025. //System.Console.WriteLine("--------PlayerLaunchCardSkill: " + cardSkill + ", " + this.type);
  4026. }
  4027. override public void ReadExternal(IInputStream input)
  4028. {
  4029. //
  4030. this.cardSkill = input.GetS32();
  4031. this.type = input.GetEnum8<CardType>();
  4032. this.layer = input.GetU8();
  4033. for (int i = 0; i < (int)CardType.Max; i++)
  4034. {
  4035. cardData[i] = input.GetU8();
  4036. }
  4037. //System.Console.WriteLine("--------PlayerLaunchCardSkill: " + cardSkill + ", " + this.type);
  4038. }
  4039. }
  4040. /// <summary>
  4041. /// 刷新Boss卡牌珠相关信息
  4042. /// </summary>
  4043. [MessageType(0x8706)]
  4044. public class RefreshBossCardInfo : ObjectEvent
  4045. {
  4046. public byte[] cardData = new byte[(int)CardType.Max]; //0-3代表有
  4047. public RefreshBossCardInfo()
  4048. {
  4049. this.init();
  4050. }
  4051. public RefreshBossCardInfo(uint objId) : base(objId)
  4052. {
  4053. this.init();
  4054. }
  4055. private void init()
  4056. {
  4057. for (int i = 0; i < (int)CardType.Max; i++)
  4058. {
  4059. cardData[i] = (byte)CardType.Max;
  4060. }
  4061. }
  4062. override public void WriteExternal(IOutputStream output)
  4063. {
  4064. base.WriteExternal(output);
  4065. for (int i = 0; i < (int)CardType.Max; i++)
  4066. {
  4067. output.PutU8(cardData[i]);
  4068. }
  4069. //System.Console.WriteLine("RefreshBossCardInfo: " + this.object_id +", " + cardData[0] + ", " + cardData[1] + ", " + cardData[2] + ", " + cardData[3]);
  4070. }
  4071. override public void ReadExternal(IInputStream input)
  4072. {
  4073. base.ReadExternal(input);
  4074. for (int i = 0; i < (int)CardType.Max; i++)
  4075. {
  4076. cardData[i] = input.GetU8();
  4077. }
  4078. //System.Console.WriteLine("objectID: " + this.object_id);
  4079. //System.Console.WriteLine("--------RefreshBossCardInfo: " + this.object_id + ", " + cardData[0] + ", " + cardData[1] + ", " + cardData[2] + ", " + cardData[3]);
  4080. }
  4081. }
  4082. /// <summary>
  4083. /// 玩家卡牌释放逻辑
  4084. /// </summary>
  4085. [MessageType(0x8707)]
  4086. public class BossTriggerCardSkill : ObjectEvent
  4087. {
  4088. public int cardSkill;
  4089. public CardType type;
  4090. public byte layer;
  4091. public byte[] cardData = new byte[(int)CardType.Max]; //0-3代表有
  4092. public BossTriggerCardSkill() { }
  4093. public BossTriggerCardSkill(uint objId) : base(objId){ }
  4094. override public void WriteExternal(IOutputStream output)
  4095. {
  4096. base.WriteExternal(output);
  4097. output.PutS32(this.cardSkill);
  4098. output.PutEnum8(type);
  4099. output.PutU8(this.layer);
  4100. for (int i = 0; i < (int)CardType.Max; i++)
  4101. {
  4102. output.PutU8(cardData[i]);
  4103. }
  4104. //System.Console.WriteLine("BossTriggerCardSkill: " + this.object_id + ", " + cardData[0] + ", " + cardData[1] + ", " + cardData[2] + ", " + cardData[3]);
  4105. }
  4106. override public void ReadExternal(IInputStream input)
  4107. {
  4108. base.ReadExternal(input);
  4109. this.cardSkill = input.GetS32();
  4110. this.type = input.GetEnum8<CardType>();
  4111. this.layer = input.GetU8();
  4112. for (int i = 0; i < (int)CardType.Max; i++)
  4113. {
  4114. cardData[i] = input.GetU8();
  4115. }
  4116. //System.Console.WriteLine("BossTriggerCardSkill: " + this.object_id + ", " + cardData[0] + ", " + cardData[1] + ", " + cardData[2] + ", " + cardData[3]);
  4117. }
  4118. }
  4119. /// <summary>
  4120. /// 单位PK模式改变通知.
  4121. /// </summary>
  4122. [MessageType(0x8708)]
  4123. public class PlayerPKModeChangeEventB2C : ObjectEvent
  4124. {
  4125. public PKMode CurMode = PKMode.Peace;
  4126. public PlayerPKModeChangeEventB2C() { }
  4127. public PlayerPKModeChangeEventB2C(uint objId, PKMode mode) : base(objId)
  4128. {
  4129. this.CurMode = mode;
  4130. }
  4131. public override void WriteExternal(IOutputStream output)
  4132. {
  4133. base.WriteExternal(output);
  4134. output.PutEnum8(CurMode);
  4135. }
  4136. public override void ReadExternal(IInputStream input)
  4137. {
  4138. base.ReadExternal(input);
  4139. CurMode = input.GetEnum8<PKMode>();
  4140. }
  4141. }
  4142. }