Messages.cs 129 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451
  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 uint senderMasterId; //如果sender为召唤物,这个存放主人id(用来广播判断,非网络字段)
  1262. public int hp;
  1263. public byte client_state;
  1264. private byte bitMask = 0;
  1265. private LaunchEffect biteffect;
  1266. private uint biteffect_sn;
  1267. private AttackProp sourceAttack;
  1268. private uint sourceAttack_sn;
  1269. // 伤害来源,非def才需要额外处理
  1270. public DamageSource dmgSrc;
  1271. //针对特殊伤害的特殊处理
  1272. public bool InViewForceSend = false;
  1273. public LaunchEffect effect
  1274. {
  1275. get { return biteffect; }
  1276. set
  1277. {
  1278. this.biteffect = value;
  1279. this.HasEffect = (value != null);
  1280. }
  1281. }
  1282. public AttackProp SourceAttack
  1283. {
  1284. get { return sourceAttack; }
  1285. set
  1286. {
  1287. this.sourceAttack = value;
  1288. this.HasSourceAttack = (value != null);
  1289. }
  1290. }
  1291. public UnitHitEvent() { }
  1292. public UnitHitEvent(uint unit_id)
  1293. : base(unit_id)
  1294. {
  1295. }
  1296. override public void WriteExternal(IOutputStream output)
  1297. {
  1298. base.WriteExternal(output);
  1299. output.PutVU32(senderId);
  1300. output.PutVS32(hp);
  1301. output.PutU8(client_state);
  1302. output.PutU8(bitMask);
  1303. if (HasEffect)
  1304. {
  1305. output.PutVU32(biteffect_sn);
  1306. }
  1307. if (HasSourceAttack)
  1308. {
  1309. output.PutVU32(sourceAttack_sn);
  1310. }
  1311. if(isSpecialHit)
  1312. {
  1313. output.PutEnum8(dmgSrc);
  1314. }
  1315. //Console.WriteLine("WWW.object_id: " + object_id + ", senderId: " + senderId + ", hp: " + this.hp + ", mask : " + this.bitMask);
  1316. }
  1317. override public void ReadExternal(IInputStream input)
  1318. {
  1319. base.ReadExternal(input);
  1320. this.senderId = input.GetVU32();
  1321. this.hp = input.GetVS32();
  1322. this.client_state = input.GetU8();
  1323. this.bitMask = input.GetU8();
  1324. if (HasEffect)
  1325. {
  1326. this.biteffect_sn = input.GetVU32();
  1327. }
  1328. if (HasSourceAttack)
  1329. {
  1330. this.sourceAttack_sn = input.GetVU32();
  1331. }
  1332. if(isSpecialHit)
  1333. {
  1334. this.dmgSrc = input.GetEnum8<DamageSource>();
  1335. }
  1336. //System.Console.WriteLine("sdfasdf: " + isSpecialHit + ", " + this.dmgSrc);
  1337. //UnityEngine.Debug.LogError("RRR.object_id: " + object_id + ", senderId: " + senderId + ", hp: " + this.hp + ", mask : " + this.bitMask);
  1338. }
  1339. public override void BeforeWrite(TemplateManager templates)
  1340. {
  1341. if (HasEffect)
  1342. {
  1343. this.biteffect_sn = biteffect.SerialNumber;
  1344. }
  1345. if (HasSourceAttack)
  1346. {
  1347. this.sourceAttack_sn = sourceAttack.SerialNumber;
  1348. }
  1349. }
  1350. public override void EndRead(TemplateManager templates)
  1351. {
  1352. if (HasEffect)
  1353. {
  1354. this.biteffect = templates.GetSnData<LaunchEffect>(biteffect_sn);
  1355. }
  1356. if (HasSourceAttack)
  1357. {
  1358. this.sourceAttack = templates.GetSnData<AttackProp>(sourceAttack_sn);
  1359. }
  1360. }
  1361. }
  1362. /// <summary>
  1363. /// 单位被击中
  1364. /// </summary>
  1365. [MessageType(0x8111)]
  1366. public class UnitDeadEvent : ObjectEvent
  1367. {
  1368. public bool Crushed;
  1369. public uint attacker_id;
  1370. public int RebirthTimeMS;
  1371. public UnitDeadEvent() { }
  1372. public UnitDeadEvent(uint unit_id, uint attacker_id, bool crushed, int rebirthTimeMS)
  1373. : base(unit_id)
  1374. {
  1375. this.Crushed = crushed;
  1376. this.attacker_id = attacker_id;
  1377. this.RebirthTimeMS = rebirthTimeMS;
  1378. }
  1379. override public void WriteExternal(IOutputStream output)
  1380. {
  1381. base.WriteExternal(output);
  1382. output.PutBool(Crushed);
  1383. output.PutVU32(attacker_id);
  1384. output.PutVS32(RebirthTimeMS);
  1385. }
  1386. override public void ReadExternal(IInputStream input)
  1387. {
  1388. base.ReadExternal(input);
  1389. this.Crushed = input.GetBool();
  1390. this.attacker_id = input.GetVU32();
  1391. this.RebirthTimeMS = input.GetVS32();
  1392. }
  1393. }
  1394. /// <summary>
  1395. /// 单位中BUFF
  1396. /// </summary>
  1397. [MessageType(0x8112)]
  1398. public class UnitLaunchBuffEvent : ObjectEvent
  1399. {
  1400. public bool IsEquip
  1401. {
  1402. get { return BitMask.BitGetMask(bitMask, 0); }
  1403. set { BitMask.BitSetMask(ref bitMask, 0, value); }
  1404. }
  1405. public bool IsOverlayLevel
  1406. {
  1407. get { return BitMask.BitGetMask(bitMask, 1); }
  1408. set { BitMask.BitSetMask(ref bitMask, 1, value); }
  1409. }
  1410. public bool IsHasExtData
  1411. {
  1412. get { return BitMask.BitGetMask(bitMask, 2); }
  1413. set { BitMask.BitSetMask(ref bitMask, 2, value); }
  1414. }
  1415. private byte bitMask = 0;
  1416. public int buffTemplateID;
  1417. public int buffTimeMS;
  1418. public byte overlayLevel;
  1419. public uint senderID;
  1420. public int buffExtData; //buff的扩展字段,
  1421. public UnitLaunchBuffEvent() { }
  1422. public UnitLaunchBuffEvent(uint unit_id, int buffID, uint senderID, int timeMS, bool equip, byte overlayLevel, int extData)
  1423. : base(unit_id)
  1424. {
  1425. this.buffTemplateID = buffID;
  1426. this.buffTimeMS = timeMS;
  1427. this.senderID = senderID;
  1428. this.IsEquip = equip;
  1429. if (overlayLevel > 0)
  1430. {
  1431. this.IsOverlayLevel = true;
  1432. this.overlayLevel = overlayLevel;
  1433. }
  1434. if(extData > 0)
  1435. {
  1436. this.IsHasExtData = true;
  1437. this.buffExtData = extData;
  1438. }
  1439. }
  1440. override public void WriteExternal(IOutputStream output)
  1441. {
  1442. base.WriteExternal(output);
  1443. output.PutU8(bitMask);
  1444. output.PutS32(buffTemplateID);
  1445. output.PutVU32(senderID);
  1446. if (!IsEquip)
  1447. {
  1448. output.PutVS32(buffTimeMS);
  1449. }
  1450. if (IsOverlayLevel)
  1451. {
  1452. output.PutU8(overlayLevel);
  1453. }
  1454. if (IsHasExtData)
  1455. {
  1456. output.PutVS32(buffExtData);
  1457. }
  1458. //System.Console.WriteLine("UnitLaunchBuffEvent: " + buffTemplateID + ", " + buffTimeMS);
  1459. }
  1460. override public void ReadExternal(IInputStream input)
  1461. {
  1462. base.ReadExternal(input);
  1463. this.bitMask = input.GetU8();
  1464. this.buffTemplateID = input.GetS32();
  1465. this.senderID = input.GetVU32();
  1466. if (!IsEquip)
  1467. {
  1468. this.buffTimeMS = input.GetVS32();
  1469. }
  1470. if (IsOverlayLevel)
  1471. {
  1472. this.overlayLevel = input.GetU8();
  1473. }
  1474. if (IsHasExtData)
  1475. {
  1476. this.buffExtData = input.GetVS32();
  1477. }
  1478. }
  1479. }
  1480. /// <summary>
  1481. /// 单位停止BUFF
  1482. /// </summary>
  1483. [MessageType(0x8113)]
  1484. public class UnitStopBuffEvent : ObjectEvent
  1485. {
  1486. public int buffTemplateID;
  1487. public uint senderID;
  1488. public UnitStopBuffEvent() { }
  1489. public UnitStopBuffEvent(uint unit_id, int buffID, uint senderID)
  1490. : base(unit_id)
  1491. {
  1492. this.buffTemplateID = buffID;
  1493. this.senderID = senderID;
  1494. }
  1495. override public void WriteExternal(IOutputStream output)
  1496. {
  1497. base.WriteExternal(output);
  1498. output.PutS32(buffTemplateID);
  1499. output.PutVU32(senderID);
  1500. }
  1501. override public void ReadExternal(IInputStream input)
  1502. {
  1503. base.ReadExternal(input);
  1504. this.buffTemplateID = input.GetS32();
  1505. this.senderID = input.GetVU32();
  1506. }
  1507. }
  1508. /// <summary>
  1509. /// 单位同步【库存道具】
  1510. /// </summary>
  1511. [MessageType(0x8114)]
  1512. public class UnitSyncInventoryItemEvent : ObjectEvent, ActorMessage
  1513. {
  1514. public int ItemTemplateID;
  1515. public int Index;
  1516. public int Count;
  1517. public UnitSyncInventoryItemEvent() { }
  1518. public UnitSyncInventoryItemEvent(uint unit_id, int itemID, int index, int count)
  1519. : base(unit_id)
  1520. {
  1521. this.ItemTemplateID = itemID;
  1522. this.Index = index;
  1523. this.Count = count;
  1524. }
  1525. override public void WriteExternal(IOutputStream output)
  1526. {
  1527. base.WriteExternal(output);
  1528. output.PutS32(ItemTemplateID);
  1529. output.PutVS32(Index);
  1530. output.PutVS32(Count);
  1531. }
  1532. override public void ReadExternal(IInputStream input)
  1533. {
  1534. base.ReadExternal(input);
  1535. this.ItemTemplateID = input.GetS32();
  1536. this.Index = input.GetVS32();
  1537. this.Count = input.GetVS32();
  1538. }
  1539. }
  1540. /// <summary>
  1541. /// 单位使用道具
  1542. /// </summary>
  1543. [MessageType(0x8115)]
  1544. public class UnitUseItemEvent : ObjectEvent, ActorMessage
  1545. {
  1546. public int ItemTemplateID;
  1547. public UnitUseItemEvent() { }
  1548. public UnitUseItemEvent(uint unit_id, int itemID)
  1549. : base(unit_id)
  1550. {
  1551. this.ItemTemplateID = itemID;
  1552. }
  1553. override public void WriteExternal(IOutputStream output)
  1554. {
  1555. base.WriteExternal(output);
  1556. output.PutS32(ItemTemplateID);
  1557. }
  1558. override public void ReadExternal(IInputStream input)
  1559. {
  1560. base.ReadExternal(input);
  1561. this.ItemTemplateID = input.GetS32();
  1562. }
  1563. }
  1564. [MessageType(0x8116)]
  1565. public class UnitSyncMultiTimeLine : ObjectEvent
  1566. {
  1567. public List<bool> timelines;
  1568. public UnitSyncMultiTimeLine() { }
  1569. public UnitSyncMultiTimeLine(uint unit_id) : base(unit_id) { }
  1570. public bool Update(List<MultiTimeLine> tlines)
  1571. {
  1572. bool ret = false;
  1573. if (timelines == null)
  1574. {
  1575. timelines = new List<bool>(tlines.Count);
  1576. }
  1577. if (timelines.Count != tlines.Count)
  1578. {
  1579. CUtils.SetListSize<bool>(timelines, tlines.Count);
  1580. ret = true;
  1581. }
  1582. for (int i = tlines.Count - 1; i >= 0; --i)
  1583. {
  1584. if (timelines[i] != tlines[i].Enable)
  1585. {
  1586. timelines[i] = tlines[i].Enable;
  1587. ret = true;
  1588. }
  1589. }
  1590. return ret;
  1591. }
  1592. override public void WriteExternal(IOutputStream output)
  1593. {
  1594. base.WriteExternal(output);
  1595. output.PutList(timelines, output.PutBool);
  1596. }
  1597. override public void ReadExternal(IInputStream input)
  1598. {
  1599. base.ReadExternal(input);
  1600. this.timelines = input.GetList<bool>(input.GetBool);
  1601. }
  1602. }
  1603. /// <summary>
  1604. /// 单位复活
  1605. /// </summary>
  1606. [MessageType(0x8117)]
  1607. public class UnitRebirthEvent : ObjectEvent
  1608. {
  1609. public UnitRebirthEvent() { }
  1610. public UnitRebirthEvent(uint unit_id) : base(unit_id) { }
  1611. }
  1612. /// <summary>
  1613. /// 用户连斩数
  1614. /// </summary>
  1615. [MessageType(0x8118)]
  1616. public class UnitContinueKillValue : ObjectEvent
  1617. {
  1618. public short continuekills;
  1619. public UnitContinueKillValue() { }
  1620. public UnitContinueKillValue(uint unit_id, short continuekills)
  1621. : base(unit_id)
  1622. {
  1623. this.continuekills = continuekills;
  1624. }
  1625. override public void WriteExternal(IOutputStream output)
  1626. {
  1627. base.WriteExternal(output);
  1628. output.PutS16(continuekills);
  1629. }
  1630. override public void ReadExternal(IInputStream input)
  1631. {
  1632. base.ReadExternal(input);
  1633. continuekills = input.GetS16();
  1634. }
  1635. }
  1636. /// <summary>
  1637. /// 单位受攻击
  1638. /// </summary>
  1639. [MessageType(0x8119)]
  1640. public class UnitDamageEvent : ObjectEvent
  1641. {
  1642. public bool HasDamageTime
  1643. {
  1644. get { return mask.Get(0); }
  1645. private set { mask.Set(0, value); }
  1646. }
  1647. public bool HasFly
  1648. {
  1649. get { return mask.Get(1); }
  1650. private set { mask.Set(1, value); }
  1651. }
  1652. public bool HasZLimit
  1653. {
  1654. get { return mask.Get(2); }
  1655. private set { mask.Set(2, value); }
  1656. }
  1657. public bool HasKnockDown
  1658. {
  1659. get { return mask.Get(3); }
  1660. private set { mask.Set(3, value); }
  1661. }
  1662. public bool HasZGravity
  1663. {
  1664. get { return mask.Get(4); }
  1665. private set { mask.Set(4, value); }
  1666. }
  1667. public bool HasMoveTime
  1668. {
  1669. get { return mask.Get(5); }
  1670. private set { mask.Set(5, value); }
  1671. }
  1672. public AttackProp Source { get; private set; }
  1673. /// <summary>
  1674. /// 总共受击时间(位移时间+受击时间)
  1675. /// </summary>
  1676. public int TotalTimeMS
  1677. {
  1678. get { return MoveTimeMS + DamageTimeMS; }
  1679. }
  1680. /// <summary>
  1681. /// 特殊受击动作
  1682. /// </summary>
  1683. public string DamageActionName
  1684. {
  1685. get { return Source.DamageActionName; }
  1686. }
  1687. /// <summary>
  1688. /// 受击的特殊动作
  1689. /// </summary>
  1690. public bool HasDamageAction
  1691. {
  1692. get { return !string.IsNullOrEmpty(Source.DamageActionName); }
  1693. }
  1694. private BitSet8 mask = new BitSet8();
  1695. private uint source_sn = 0;
  1696. public int DamageTimeMS = 0;
  1697. public int MoveTimeMS = 0;
  1698. public float ZSpeedSEC = 0;
  1699. public float ZLimit = 0;
  1700. public float ZGravity = 0;
  1701. public UnitDamageEvent() { }
  1702. public UnitDamageEvent(uint unit_id, int damageTimeMS, int moveTimeMS, float zspeed, float zgravity, float zlimit, bool knockDown, AttackProp source)
  1703. : base(unit_id)
  1704. {
  1705. this.Source = source;
  1706. this.DamageTimeMS = damageTimeMS;
  1707. this.MoveTimeMS = moveTimeMS;
  1708. this.ZSpeedSEC = zspeed;
  1709. this.ZLimit = zlimit;
  1710. this.ZGravity = zgravity;
  1711. this.HasDamageTime = (DamageTimeMS != 0);
  1712. this.HasMoveTime = (MoveTimeMS != 0);
  1713. this.HasFly = (zspeed != 0);
  1714. this.HasZGravity = (zgravity != 0);
  1715. this.HasZLimit = (zlimit > 0);
  1716. this.HasKnockDown = knockDown;
  1717. }
  1718. override public void WriteExternal(IOutputStream output)
  1719. {
  1720. base.WriteExternal(output);
  1721. output.PutU8(mask.Mask);
  1722. output.PutVU32(source_sn);
  1723. if (HasDamageTime)
  1724. {
  1725. output.PutVS32(DamageTimeMS);
  1726. }
  1727. if (HasMoveTime)
  1728. {
  1729. output.PutVS32(MoveTimeMS);
  1730. }
  1731. if (HasFly)
  1732. {
  1733. output.PutF32(ZSpeedSEC);
  1734. }
  1735. if (HasZLimit)
  1736. {
  1737. output.PutF32(ZLimit);
  1738. }
  1739. if (HasZGravity)
  1740. {
  1741. output.PutF32(ZGravity);
  1742. }
  1743. }
  1744. override public void ReadExternal(IInputStream input)
  1745. {
  1746. base.ReadExternal(input);
  1747. this.mask.Mask = input.GetU8();
  1748. this.source_sn = input.GetVU32();
  1749. if (HasDamageTime)
  1750. {
  1751. this.DamageTimeMS = input.GetVS32();
  1752. }
  1753. if (HasMoveTime)
  1754. {
  1755. this.MoveTimeMS = input.GetVS32();
  1756. }
  1757. if (HasFly)
  1758. {
  1759. this.ZSpeedSEC = input.GetF32();
  1760. }
  1761. if (HasZLimit)
  1762. {
  1763. this.ZLimit = input.GetF32();
  1764. }
  1765. if (HasZGravity)
  1766. {
  1767. this.ZGravity = input.GetF32();
  1768. }
  1769. }
  1770. public override void BeforeWrite(TemplateManager templates)
  1771. {
  1772. if (Source != null)
  1773. {
  1774. this.source_sn = Source.SerialNumber;
  1775. }
  1776. }
  1777. public override void EndRead(TemplateManager templates)
  1778. {
  1779. if (source_sn != 0)
  1780. {
  1781. this.Source = templates.GetSnData<AttackProp>(source_sn);
  1782. }
  1783. }
  1784. }
  1785. /// <summary>
  1786. /// 技能动作序列被意外取消
  1787. /// </summary>
  1788. [MessageType(0x811A)]
  1789. public class UnitSkillActionChangeEvent : ObjectEvent
  1790. {
  1791. public byte ActionIndex;
  1792. public UnitSkillActionChangeEvent() { }
  1793. public UnitSkillActionChangeEvent(uint unit_id, byte index)
  1794. : base(unit_id)
  1795. {
  1796. this.ActionIndex = index;
  1797. }
  1798. override public void WriteExternal(IOutputStream output)
  1799. {
  1800. base.WriteExternal(output);
  1801. output.PutU8(ActionIndex);
  1802. }
  1803. override public void ReadExternal(IInputStream input)
  1804. {
  1805. base.ReadExternal(input);
  1806. this.ActionIndex = input.GetU8();
  1807. }
  1808. }
  1809. /// <summary>
  1810. /// 单位开始检取道具读条
  1811. /// </summary>
  1812. [MessageType(0x811B)]
  1813. public class UnitStartPickObjectEvent : ObjectEvent
  1814. {
  1815. public int PickTimeMS;
  1816. public uint PickObjectID;
  1817. public string PickStatus;
  1818. public UnitStartPickObjectEvent() { }
  1819. public UnitStartPickObjectEvent(uint unit_id, int pickTimeMS, uint pickObjID, string status)
  1820. : base(unit_id)
  1821. {
  1822. this.PickTimeMS = pickTimeMS;
  1823. this.PickObjectID = pickObjID;
  1824. this.PickStatus = status;
  1825. }
  1826. override public void WriteExternal(IOutputStream output)
  1827. {
  1828. base.WriteExternal(output);
  1829. output.PutVS32(PickTimeMS);
  1830. output.PutVU32(PickObjectID);
  1831. output.PutUTF(PickStatus);
  1832. }
  1833. override public void ReadExternal(IInputStream input)
  1834. {
  1835. base.ReadExternal(input);
  1836. this.PickTimeMS = input.GetVS32();
  1837. this.PickObjectID = input.GetVU32();
  1838. this.PickStatus = input.GetUTF();
  1839. }
  1840. }
  1841. [MessageType(0x811C)]
  1842. public class UnitStopPickObjectEvent : ObjectEvent
  1843. {
  1844. public string StopReason;
  1845. public UnitStopPickObjectEvent() { }
  1846. public UnitStopPickObjectEvent(uint unit_id, string reason)
  1847. : base(unit_id)
  1848. {
  1849. this.StopReason = reason;
  1850. }
  1851. override public void WriteExternal(IOutputStream output)
  1852. {
  1853. base.WriteExternal(output);
  1854. output.PutUTF(StopReason);
  1855. }
  1856. override public void ReadExternal(IInputStream input)
  1857. {
  1858. base.ReadExternal(input);
  1859. this.StopReason = input.GetUTF();
  1860. }
  1861. }
  1862. /// <summary>
  1863. /// 单位从场景中获得道具
  1864. /// </summary>
  1865. [MessageType(0x811D)]
  1866. public class UnitGotInstanceItemEvent : ObjectEvent, ActorMessage
  1867. {
  1868. public uint ItemObjectID;
  1869. public byte flag; //0-后续可以继续采集,1-后续不可继续采集
  1870. public UnitGotInstanceItemEvent() { }
  1871. public UnitGotInstanceItemEvent(uint unit_id, uint pickObjID, byte flag = 0)
  1872. : base(unit_id)
  1873. {
  1874. this.ItemObjectID = pickObjID;
  1875. this.flag = flag;
  1876. }
  1877. override public void WriteExternal(IOutputStream output)
  1878. {
  1879. base.WriteExternal(output);
  1880. output.PutU32(ItemObjectID);
  1881. }
  1882. override public void ReadExternal(IInputStream input)
  1883. {
  1884. base.ReadExternal(input);
  1885. this.ItemObjectID = input.GetU32();
  1886. }
  1887. }
  1888. /// <summary>
  1889. /// 别的单位释放技能跳起
  1890. /// </summary>
  1891. [MessageType(0x811E)]
  1892. public class UnitJumpEvent : ObjectEvent
  1893. {
  1894. public float ZSpeed;
  1895. public float ZLimit;
  1896. public float ZGravity;
  1897. public UnitJumpEvent() { }
  1898. public UnitJumpEvent(uint unit_id, float zspeed, float zgravity, float zlimit)
  1899. : base(unit_id)
  1900. {
  1901. this.ZSpeed = zspeed;
  1902. this.ZLimit = zlimit;
  1903. this.ZGravity = zgravity;
  1904. }
  1905. override public void WriteExternal(IOutputStream output)
  1906. {
  1907. base.WriteExternal(output);
  1908. output.PutF32(ZSpeed);
  1909. output.PutF32(ZLimit);
  1910. output.PutF32(ZGravity);
  1911. }
  1912. override public void ReadExternal(IInputStream input)
  1913. {
  1914. base.ReadExternal(input);
  1915. this.ZSpeed = input.GetF32();
  1916. this.ZLimit = input.GetF32();
  1917. this.ZGravity = input.GetF32();
  1918. }
  1919. }
  1920. /// <summary>
  1921. /// 立即同步客户端坐标,比如单位传送之类,用于MoveByClient的模式
  1922. /// </summary>
  1923. [MessageType(0x811F)]
  1924. public class UnitForceSyncPosEvent : ObjectEvent
  1925. {
  1926. public float X;
  1927. public float Y;
  1928. public float Direction;
  1929. public byte UnitMainState;
  1930. public byte UnitSubState;
  1931. public UnitForceSyncPosEvent() { }
  1932. public UnitForceSyncPosEvent(uint unit_id, float x, float y, float d, byte state, byte sub_state)
  1933. : base(unit_id)
  1934. {
  1935. this.X = x;
  1936. this.Y = y;
  1937. this.Direction = d;
  1938. this.UnitMainState = state;
  1939. this.UnitSubState = sub_state;
  1940. }
  1941. override public void WriteExternal(IOutputStream output)
  1942. {
  1943. base.WriteExternal(output);
  1944. output.PutF32(this.X);
  1945. output.PutF32(this.Y);
  1946. output.PutF32(this.Direction);
  1947. output.PutU8(this.UnitMainState);
  1948. output.PutU8(this.UnitSubState);
  1949. //if (this.object_id == 2649)
  1950. //{
  1951. // Console.WriteLine("ForceSync-" + this.object_id + ", X: " + this.X + ", \t Y: " + this.Y + ", " + this.UnitMainState + ", " + this.UnitSubState);
  1952. //}
  1953. }
  1954. override public void ReadExternal(IInputStream input)
  1955. {
  1956. base.ReadExternal(input);
  1957. this.X = input.GetF32();
  1958. this.Y = input.GetF32();
  1959. this.Direction = input.GetF32();
  1960. this.UnitMainState = input.GetU8();
  1961. this.UnitSubState = input.GetU8();
  1962. }
  1963. }
  1964. /// <summary>
  1965. /// 立即同步客户端坐标,比如单位传送之类,用于MoveByClient的模式
  1966. /// </summary>
  1967. [MessageType(0x8120)]
  1968. public class ObjectForceSyncPosEvent : ObjectEvent
  1969. {
  1970. public float X;
  1971. public float Y;
  1972. public float Direction;
  1973. public ObjectForceSyncPosEvent() { }
  1974. public ObjectForceSyncPosEvent(uint unit_id, float x, float y, float d)
  1975. : base(unit_id)
  1976. {
  1977. this.X = x;
  1978. this.Y = y;
  1979. this.Direction = d;
  1980. }
  1981. override public void WriteExternal(IOutputStream output)
  1982. {
  1983. base.WriteExternal(output);
  1984. output.PutF32(this.X);
  1985. output.PutF32(this.Y);
  1986. output.PutF32(this.Direction);
  1987. }
  1988. override public void ReadExternal(IInputStream input)
  1989. {
  1990. base.ReadExternal(input);
  1991. this.X = input.GetF32();
  1992. this.Y = input.GetF32();
  1993. this.Direction = input.GetF32();
  1994. }
  1995. }
  1996. /// <summary>
  1997. /// Missile类法术,锁定单位时触发
  1998. /// </summary>
  1999. [MessageType(0x8130)]
  2000. public class SpellLockTargetEvent : ObjectEvent, PositionMessage
  2001. {
  2002. public uint target_obj_id;
  2003. private float x;
  2004. private float y;
  2005. public SpellLockTargetEvent() { }
  2006. public SpellLockTargetEvent(uint spell_id, uint target_obj_id, float x, float y)
  2007. : base(spell_id)
  2008. {
  2009. this.target_obj_id = target_obj_id;
  2010. this.x = x;
  2011. this.y = y;
  2012. }
  2013. override public void WriteExternal(IOutputStream output)
  2014. {
  2015. base.WriteExternal(output);
  2016. output.PutVU32(target_obj_id);
  2017. }
  2018. override public void ReadExternal(IInputStream input)
  2019. {
  2020. base.ReadExternal(input);
  2021. this.target_obj_id = input.GetVU32();
  2022. }
  2023. public float X { get { return x; } }
  2024. public float Y { get { return y; } }
  2025. }
  2026. #endregion
  2027. //--------------------------------------------------------------------------
  2028. #region CONTROL_0x8200
  2029. /// <summary>
  2030. /// 单位待机
  2031. /// </summary>
  2032. [MessageType(0x8200)]
  2033. public class UnitGuardAction : ObjectAction
  2034. {
  2035. public bool guard = false;
  2036. public string reason = null;
  2037. public bool forceNotify = false;
  2038. public UnitGuardAction() { }
  2039. public UnitGuardAction(uint unit_id, bool guard)
  2040. : base(unit_id)
  2041. {
  2042. this.guard = guard;
  2043. }
  2044. public UnitGuardAction(uint unit_id, bool guard, string reason)
  2045. : base(unit_id)
  2046. {
  2047. this.guard = guard;
  2048. this.reason = reason;
  2049. }
  2050. override public void WriteExternal(IOutputStream output)
  2051. {
  2052. base.WriteExternal(output);
  2053. output.PutBool(guard);
  2054. output.PutUTF(reason);
  2055. }
  2056. override public void ReadExternal(IInputStream input)
  2057. {
  2058. base.ReadExternal(input);
  2059. this.guard = input.GetBool();
  2060. this.reason = input.GetUTF();
  2061. }
  2062. }
  2063. /// <summary>
  2064. /// A过去
  2065. /// </summary>
  2066. [MessageType(0x8206)]
  2067. public class UnitAttackToAction : ObjectAction
  2068. {
  2069. public float targetX;
  2070. public float targetY;
  2071. public bool attack;
  2072. public UnitAttackToAction() { }
  2073. public UnitAttackToAction(uint unit_id, float x, float y, bool attack)
  2074. : base(unit_id)
  2075. {
  2076. this.targetX = x;
  2077. this.targetY = y;
  2078. this.attack = attack;
  2079. }
  2080. override public void WriteExternal(IOutputStream output)
  2081. {
  2082. base.WriteExternal(output);
  2083. output.PutF32(targetX);
  2084. output.PutF32(targetY);
  2085. output.PutBool(attack);
  2086. }
  2087. override public void ReadExternal(IInputStream input)
  2088. {
  2089. base.ReadExternal(input);
  2090. this.targetX = input.GetF32();
  2091. this.targetY = input.GetF32();
  2092. this.attack = input.GetBool();
  2093. }
  2094. }
  2095. /// <summary>
  2096. /// 单位移动
  2097. /// </summary>
  2098. [MessageType(0x8201)]
  2099. public class UnitMoveAction : ObjectAction
  2100. {
  2101. public float x;
  2102. public float y;
  2103. public UnitMoveAction() { }
  2104. public UnitMoveAction(uint unit_id, float x, float y)
  2105. : base(unit_id)
  2106. {
  2107. this.x = x;
  2108. this.y = y;
  2109. }
  2110. override public void WriteExternal(IOutputStream output)
  2111. {
  2112. base.WriteExternal(output);
  2113. output.PutF32(x);
  2114. output.PutF32(y);
  2115. }
  2116. override public void ReadExternal(IInputStream input)
  2117. {
  2118. base.ReadExternal(input);
  2119. this.x = input.GetF32();
  2120. this.y = input.GetF32();
  2121. }
  2122. }
  2123. /// <summary>
  2124. /// 玩家选择朝向
  2125. /// </summary>
  2126. [MessageType(0x8202)]
  2127. public class UnitFaceToAction : ObjectAction
  2128. {
  2129. public float Direction;
  2130. public UnitFaceToAction() { }
  2131. public UnitFaceToAction(uint unit_id, float d)
  2132. : base(unit_id)
  2133. {
  2134. this.Direction = d;
  2135. }
  2136. override public void WriteExternal(IOutputStream output)
  2137. {
  2138. base.WriteExternal(output);
  2139. output.PutF32(Direction);
  2140. }
  2141. override public void ReadExternal(IInputStream input)
  2142. {
  2143. base.ReadExternal(input);
  2144. this.Direction = input.GetF32();
  2145. }
  2146. }
  2147. /// <summary>
  2148. /// 单位移动
  2149. /// </summary>
  2150. [MessageType(0x8203)]
  2151. public class UnitSlipAction : ObjectAction
  2152. {
  2153. public float x;
  2154. public float y;
  2155. public UnitSlipAction() { }
  2156. public UnitSlipAction(uint unit_id, float x, float y)
  2157. : base(unit_id)
  2158. {
  2159. this.x = x;
  2160. this.y = y;
  2161. }
  2162. override public void WriteExternal(IOutputStream output)
  2163. {
  2164. base.WriteExternal(output);
  2165. output.PutF32(x);
  2166. output.PutF32(y);
  2167. }
  2168. override public void ReadExternal(IInputStream input)
  2169. {
  2170. base.ReadExternal(input);
  2171. this.x = input.GetF32();
  2172. this.y = input.GetF32();
  2173. }
  2174. }
  2175. /// <summary>
  2176. /// 锁定目标
  2177. /// </summary>
  2178. [MessageType(0x8204)]
  2179. public class UnitFocuseTargetAction : ObjectAction
  2180. {
  2181. public uint targetUnitID;
  2182. public UnitFocuseTargetAction() { }
  2183. public UnitFocuseTargetAction(uint unit_id, uint target_id)
  2184. : base(unit_id)
  2185. {
  2186. this.targetUnitID = target_id;
  2187. }
  2188. override public void WriteExternal(IOutputStream output)
  2189. {
  2190. base.WriteExternal(output);
  2191. output.PutU32(targetUnitID);
  2192. }
  2193. override public void ReadExternal(IInputStream input)
  2194. {
  2195. base.ReadExternal(input);
  2196. this.targetUnitID = input.GetU32();
  2197. }
  2198. }
  2199. /// <summary>
  2200. /// 单位技能动作
  2201. /// </summary>
  2202. [MessageType(0x8205)]
  2203. public class UnitLaunchSkillAction : ObjectAction
  2204. {
  2205. private BitSet8 mask = new BitSet8();
  2206. public bool IsAutoFocusNearTarget
  2207. {
  2208. get { return mask.Get(0); }
  2209. set { mask.Set(0, value); }
  2210. }
  2211. private bool IsTargetID
  2212. {
  2213. get { return mask.Get(1); }
  2214. set { mask.Set(1, value); }
  2215. }
  2216. private bool IsTargetPos
  2217. {
  2218. get { return mask.Get(2); }
  2219. set { mask.Set(2, value); }
  2220. }
  2221. public bool SyncDirection
  2222. {
  2223. get { return mask.Get(3); }
  2224. set { mask.Set(3, value); }
  2225. }
  2226. public int SkillID;
  2227. public uint TargetObjID = 0;
  2228. public Vector2 SpellTargetPos = null;
  2229. public float Direction = 0;
  2230. public UnitLaunchSkillAction() { }
  2231. public UnitLaunchSkillAction(uint unit_id, int skill_id, bool autoFocuseTarget = false, uint targetObjID = 0, Vector2 spellTargetPos = null, float direction = 0.0f)
  2232. : base(unit_id)
  2233. {
  2234. this.SkillID = skill_id;
  2235. this.TargetObjID = targetObjID;
  2236. this.SpellTargetPos = spellTargetPos;
  2237. this.IsAutoFocusNearTarget = autoFocuseTarget;
  2238. this.Direction = direction;
  2239. }
  2240. override public void WriteExternal(IOutputStream output)
  2241. {
  2242. this.IsTargetID = (TargetObjID != 0);
  2243. this.IsTargetPos = (SpellTargetPos != null);
  2244. base.WriteExternal(output);
  2245. mask.WriteExternal(output);
  2246. output.PutS32(SkillID);
  2247. if (SyncDirection)
  2248. {
  2249. output.PutF32(Direction);
  2250. }
  2251. if (IsTargetID)
  2252. {
  2253. output.PutU32(TargetObjID);
  2254. }
  2255. if (IsTargetPos)
  2256. {
  2257. output.PutF32(SpellTargetPos.X);
  2258. output.PutF32(SpellTargetPos.Y);
  2259. }
  2260. }
  2261. override public void ReadExternal(IInputStream input)
  2262. {
  2263. base.ReadExternal(input);
  2264. mask.ReadExternal(input);
  2265. this.SkillID = input.GetS32();
  2266. if (SyncDirection)
  2267. {
  2268. this.Direction = input.GetF32();
  2269. }
  2270. if (IsTargetID)
  2271. {
  2272. this.TargetObjID = input.GetU32();
  2273. }
  2274. if (IsTargetPos)
  2275. {
  2276. this.SpellTargetPos = new Vector2();
  2277. this.SpellTargetPos.SetX(input.GetF32());
  2278. this.SpellTargetPos.SetY(input.GetF32());
  2279. }
  2280. }
  2281. }
  2282. /// <summary>
  2283. /// 客户端手动控制同步包
  2284. /// </summary>
  2285. [MessageType(0x8207)]
  2286. public class UnitAxisAction : ObjectAction
  2287. {
  2288. public bool IsZero { get { return dx == 0 && dy == 0; } }
  2289. public float dx;
  2290. public float dy;
  2291. public UnitAxisAction() { }
  2292. public UnitAxisAction(uint unit_id)
  2293. : base(unit_id)
  2294. {
  2295. }
  2296. override public void WriteExternal(IOutputStream output)
  2297. {
  2298. base.WriteExternal(output);
  2299. float angle = (float)Math.Atan2(dy, dx);
  2300. output.PutS8((sbyte)(Math.Cos(angle) * 100f));
  2301. output.PutS8((sbyte)(Math.Sin(angle) * 100f));
  2302. }
  2303. override public void ReadExternal(IInputStream input)
  2304. {
  2305. base.ReadExternal(input);
  2306. this.dx = input.GetS8() / 100f;
  2307. this.dy = input.GetS8() / 100f;
  2308. }
  2309. public bool AxisEquals(UnitAxisAction obj)
  2310. {
  2311. if (obj == null) return false;
  2312. return (obj.dx == this.dx) && (obj.dy == this.dy);
  2313. }
  2314. }
  2315. /// <summary>
  2316. /// 客户端手动控制同步包
  2317. /// </summary>
  2318. [MessageType(0x8208)]
  2319. public class UnitStopMoveAction : ObjectAction
  2320. {
  2321. public UnitStopMoveAction() { }
  2322. public UnitStopMoveAction(uint unit_id)
  2323. : base(unit_id)
  2324. {
  2325. }
  2326. override public void WriteExternal(IOutputStream output)
  2327. {
  2328. base.WriteExternal(output);
  2329. }
  2330. override public void ReadExternal(IInputStream input)
  2331. {
  2332. base.ReadExternal(input);
  2333. }
  2334. }
  2335. /// <summary>
  2336. /// 单位使用道具
  2337. /// </summary>
  2338. [MessageType(0x8209)]
  2339. public class UnitUseItemAction : ObjectAction
  2340. {
  2341. public int Index;
  2342. public int Count;
  2343. public UnitUseItemAction() { }
  2344. public UnitUseItemAction(uint unit_id, int index, int count = 1)
  2345. : base(unit_id)
  2346. {
  2347. this.Index = index;
  2348. this.Count = count;
  2349. }
  2350. override public void WriteExternal(IOutputStream output)
  2351. {
  2352. base.WriteExternal(output);
  2353. output.PutVS32(this.Index);
  2354. output.PutVS32(this.Count);
  2355. }
  2356. override public void ReadExternal(IInputStream input)
  2357. {
  2358. base.ReadExternal(input);
  2359. this.Index = input.GetVS32();
  2360. this.Count = input.GetVS32();
  2361. }
  2362. }
  2363. /// <summary>
  2364. /// 单位手动检取场景道具
  2365. /// </summary>
  2366. [MessageType(0x820A)]
  2367. public class UnitPickObjectAction : ObjectAction
  2368. {
  2369. public uint PickableObjectID;
  2370. public UnitPickObjectAction() { }
  2371. public UnitPickObjectAction(uint unit_id, uint item_obj_id)
  2372. : base(unit_id)
  2373. {
  2374. this.PickableObjectID = item_obj_id;
  2375. }
  2376. override public void WriteExternal(IOutputStream output)
  2377. {
  2378. base.WriteExternal(output);
  2379. output.PutVU32(this.PickableObjectID);
  2380. }
  2381. override public void ReadExternal(IInputStream input)
  2382. {
  2383. base.ReadExternal(input);
  2384. this.PickableObjectID = input.GetVU32();
  2385. }
  2386. }
  2387. /// <summary>
  2388. /// 单位移动
  2389. /// </summary>
  2390. [MessageType(0x820B)]
  2391. public class UnitUpdatePosAction : ObjectAction
  2392. {
  2393. public bool isHalf;
  2394. public float x;
  2395. public float y;
  2396. public float d;
  2397. public UnitActionStatus st;
  2398. public UnitUpdatePosAction() { }
  2399. public UnitUpdatePosAction(uint unit_id, bool isHalf, float x, float y, float d, UnitActionStatus s)
  2400. : base(unit_id)
  2401. {
  2402. this.isHalf = isHalf;
  2403. this.x = x;
  2404. this.y = y;
  2405. this.d = d;
  2406. this.st = s;
  2407. }
  2408. override public void WriteExternal(IOutputStream output)
  2409. {
  2410. base.WriteExternal(output);
  2411. output.PutBool(isHalf);
  2412. if (isHalf)
  2413. {
  2414. output.PutU16(MoveHelper.ToPos16(x));
  2415. output.PutU16(MoveHelper.ToPos16(y));
  2416. output.PutU8(MoveHelper.ToDirectionD8(d));
  2417. }
  2418. else
  2419. {
  2420. output.PutF32(x);
  2421. output.PutF32(y);
  2422. output.PutF32(d);
  2423. }
  2424. output.PutEnum8(st);
  2425. }
  2426. override public void ReadExternal(IInputStream input)
  2427. {
  2428. base.ReadExternal(input);
  2429. this.isHalf = input.GetBool();
  2430. if (isHalf)
  2431. {
  2432. this.x = MoveHelper.ToPosF32(input.GetU16());
  2433. this.y = MoveHelper.ToPosF32(input.GetU16());
  2434. this.d = MoveHelper.ToDirectionF32(input.GetU8());
  2435. }
  2436. else
  2437. {
  2438. this.x = input.GetF32();
  2439. this.y = input.GetF32();
  2440. this.d = input.GetF32();
  2441. }
  2442. this.st = input.GetEnum8<UnitActionStatus>();
  2443. //Console.WriteLine("-------------------UnitUpdatePosAction : " + TimeUtil.GetTimestampMS() + this.x + ", " + this.y + " \t \t" + this.st);
  2444. }
  2445. public bool DataEquals(UnitUpdatePosAction o)
  2446. {
  2447. if (o == null) return false;
  2448. return o.x == this.x && o.y == this.y && o.d == this.d && o.st == this.st;
  2449. }
  2450. public void Set(UnitUpdatePosAction other)
  2451. {
  2452. this.object_id = other.object_id;
  2453. this.isHalf = other.isHalf;
  2454. this.x = other.x;
  2455. this.y = other.y;
  2456. this.d = other.d;
  2457. this.st = other.st;
  2458. }
  2459. }
  2460. [MessageType(0x820C)]
  2461. public class UnitSetSyncModeAction : ObjectAction
  2462. {
  2463. public SyncMode Mode;
  2464. public UnitSetSyncModeAction() { }
  2465. public UnitSetSyncModeAction(uint unit_id, SyncMode mode)
  2466. : base(unit_id)
  2467. {
  2468. this.Mode = mode;
  2469. }
  2470. override public void WriteExternal(IOutputStream output)
  2471. {
  2472. base.WriteExternal(output);
  2473. output.PutEnum8(Mode);
  2474. }
  2475. override public void ReadExternal(IInputStream input)
  2476. {
  2477. base.ReadExternal(input);
  2478. this.Mode = input.GetEnum8<SyncMode>();
  2479. }
  2480. }
  2481. [MessageType(0x820D)]
  2482. public class UnitCancelBuffAction : ObjectAction
  2483. {
  2484. public int BuffID;
  2485. public UnitCancelBuffAction() { }
  2486. public UnitCancelBuffAction(uint unit_id, int buffID)
  2487. : base(unit_id)
  2488. {
  2489. this.BuffID = buffID;
  2490. }
  2491. override public void WriteExternal(IOutputStream output)
  2492. {
  2493. base.WriteExternal(output);
  2494. output.PutS32(BuffID);
  2495. }
  2496. override public void ReadExternal(IInputStream input)
  2497. {
  2498. base.ReadExternal(input);
  2499. this.BuffID = input.GetS32();
  2500. }
  2501. }
  2502. /// <summary>
  2503. /// 单位统计数据
  2504. /// </summary>
  2505. public class UnitStatisticData : IExternalizable
  2506. {
  2507. public uint ObjectID;
  2508. /// <summary>
  2509. /// 死亡次数
  2510. /// </summary>
  2511. public int DeadCount;
  2512. /// <summary>
  2513. /// 总共杀死单位数量
  2514. /// </summary>
  2515. public int KillUnitCount;
  2516. /// <summary>
  2517. /// 总共杀死玩家数量
  2518. /// </summary>
  2519. public int KillPlayerCount;
  2520. /// <summary>
  2521. /// 承受伤害
  2522. /// </summary>
  2523. public long SelfDamage;
  2524. /// <summary>
  2525. /// 对所有单位造成的总伤害
  2526. /// </summary>
  2527. public long TotalDamage;
  2528. /// <summary>
  2529. /// 对玩家造成的总伤害
  2530. /// </summary>
  2531. public long PlayerDamage;
  2532. /// <summary>
  2533. /// 对所有单位输出的总治疗量
  2534. /// </summary>
  2535. public long TotalHealing;
  2536. /// <summary>
  2537. /// 对玩家输出的总治疗量
  2538. /// </summary>
  2539. public long PlayerHealing;
  2540. public virtual void WriteExternal(IOutputStream output)
  2541. {
  2542. output.PutVU32(ObjectID);
  2543. output.PutVS32(DeadCount);
  2544. output.PutVS32(KillUnitCount);
  2545. output.PutVS32(KillPlayerCount);
  2546. output.PutVS64(SelfDamage);
  2547. output.PutVS64(TotalDamage);
  2548. output.PutVS64(PlayerDamage);
  2549. output.PutVS64(TotalHealing);
  2550. output.PutVS64(PlayerHealing);
  2551. }
  2552. public virtual void ReadExternal(IInputStream input)
  2553. {
  2554. ObjectID = input.GetVU32();
  2555. DeadCount = input.GetVS32();
  2556. KillUnitCount = input.GetVS32();
  2557. KillPlayerCount = input.GetVS32();
  2558. SelfDamage = input.GetVS64();
  2559. TotalDamage = input.GetVS64();
  2560. PlayerDamage = input.GetVS64();
  2561. TotalHealing = input.GetVS64();
  2562. PlayerHealing = input.GetVS64();
  2563. }
  2564. }
  2565. [MessageType(0x8210)]
  2566. public class UnitGetStatisticRequest : ActorRequest
  2567. {
  2568. public uint[] RequestObjectsID;
  2569. public UnitGetStatisticRequest() { }
  2570. public UnitGetStatisticRequest(uint objID, params uint[] objectsID) : base(objID)
  2571. {
  2572. this.RequestObjectsID = objectsID;
  2573. }
  2574. public override void WriteExternal(IOutputStream output)
  2575. {
  2576. base.WriteExternal(output);
  2577. output.PutS32(MessageID);
  2578. output.PutArray(RequestObjectsID, output.PutU32);
  2579. }
  2580. public override void ReadExternal(IInputStream input)
  2581. {
  2582. base.ReadExternal(input);
  2583. this.MessageID = input.GetS32();
  2584. this.RequestObjectsID = input.GetArray<uint>(input.GetU32);
  2585. }
  2586. }
  2587. [MessageType(0x8211)]
  2588. public class UnitGetStatisticResponse : ActorResponse
  2589. {
  2590. public HashMap<uint, UnitStatisticData> Statistics = new HashMap<uint, UnitStatisticData>();
  2591. public override void WriteExternal(IOutputStream output)
  2592. {
  2593. base.WriteExternal(output);
  2594. output.PutS32(MessageID);
  2595. output.PutVS32(Statistics.Count);
  2596. foreach (KeyValuePair<uint, UnitStatisticData> e in Statistics)
  2597. {
  2598. output.PutU32(e.Key);
  2599. output.PutExt(e.Value);
  2600. }
  2601. }
  2602. public override void ReadExternal(IInputStream input)
  2603. {
  2604. base.ReadExternal(input);
  2605. this.MessageID = input.GetS32();
  2606. int count = input.GetVS32();
  2607. for (int i = 0; i < count; i++)
  2608. {
  2609. var key = input.GetU32();
  2610. var data = input.GetExtAny() as UnitStatisticData;
  2611. Statistics.Put(key, data);
  2612. }
  2613. }
  2614. }
  2615. /// <summary>
  2616. /// 设置子动做
  2617. /// </summary>
  2618. [MessageType(0x8212)]
  2619. public class UnitSetSubStateAction : ObjectAction
  2620. {
  2621. public byte UnitSubState;
  2622. public UnitSetSubStateAction() { }
  2623. public UnitSetSubStateAction(uint objID, byte state)
  2624. : base(objID)
  2625. {
  2626. this.UnitSubState = state;
  2627. }
  2628. public override void WriteExternal(IOutputStream output)
  2629. {
  2630. base.WriteExternal(output);
  2631. output.PutU8(UnitSubState);
  2632. }
  2633. public override void ReadExternal(IInputStream input)
  2634. {
  2635. base.ReadExternal(input);
  2636. this.UnitSubState = input.GetU8();
  2637. }
  2638. }
  2639. /// <summary>
  2640. /// 单位准备完毕
  2641. /// </summary>
  2642. [MessageType(0x8213)]
  2643. public class UnitReadAction : ObjectAction
  2644. {
  2645. public UnitReadAction() { }
  2646. public UnitReadAction(uint objID)
  2647. : base(objID)
  2648. {
  2649. }
  2650. public override void WriteExternal(IOutputStream output)
  2651. {
  2652. base.WriteExternal(output);
  2653. }
  2654. public override void ReadExternal(IInputStream input)
  2655. {
  2656. base.ReadExternal(input);
  2657. }
  2658. }
  2659. #endregion
  2660. //--------------------------------------------------------------------------
  2661. //--------------------------------------------------------------------------------------------------------------
  2662. #region CLIENT_EVENTS_0x8300
  2663. public abstract class ClientEvent : ZoneEvent
  2664. {
  2665. }
  2666. /// <summary>
  2667. /// 显示箭头
  2668. /// </summary>
  2669. [MessageType(0x8300)]
  2670. public class LookAtEvent : ClientEvent
  2671. {
  2672. public string target;
  2673. public float x;
  2674. public float y;
  2675. public LookAtEvent() { }
  2676. public LookAtEvent(string target, float x, float y)
  2677. {
  2678. this.target = target;
  2679. this.x = x;
  2680. this.y = y;
  2681. }
  2682. override public void WriteExternal(IOutputStream output)
  2683. {
  2684. output.PutUTF(target);
  2685. output.PutF32(x);
  2686. output.PutF32(y);
  2687. }
  2688. override public void ReadExternal(IInputStream input)
  2689. {
  2690. this.target = input.GetUTF();
  2691. this.x = input.GetF32();
  2692. this.y = input.GetF32();
  2693. }
  2694. }
  2695. /// <summary>
  2696. /// 改变游戏运行速度
  2697. /// </summary>
  2698. [MessageType(0x8301)]
  2699. public class ChangeTimeScaleEvent : ClientEvent
  2700. {
  2701. /// <summary>
  2702. /// 时间尺度百分比
  2703. /// </summary>
  2704. public float TimeScalePct = 100f;
  2705. public ChangeTimeScaleEvent() { }
  2706. public ChangeTimeScaleEvent(float pct)
  2707. {
  2708. this.TimeScalePct = pct;
  2709. }
  2710. override public void WriteExternal(IOutputStream output)
  2711. {
  2712. output.PutF32(TimeScalePct);
  2713. }
  2714. override public void ReadExternal(IInputStream input)
  2715. {
  2716. this.TimeScalePct = input.GetF32();
  2717. }
  2718. }
  2719. /// <summary>
  2720. /// 暂停游戏
  2721. /// </summary>
  2722. [MessageType(0x8302)]
  2723. public class GamePauseEvent : ClientEvent
  2724. {
  2725. /// <summary>
  2726. /// 暂停多少秒,如果为0,则无限暂停
  2727. /// </summary>
  2728. public float Seconds = 0f;
  2729. public GamePauseEvent() { }
  2730. public GamePauseEvent(float sec)
  2731. {
  2732. this.Seconds = sec;
  2733. }
  2734. override public void WriteExternal(IOutputStream output)
  2735. {
  2736. output.PutF32(Seconds);
  2737. }
  2738. override public void ReadExternal(IInputStream input)
  2739. {
  2740. this.Seconds = input.GetF32();
  2741. }
  2742. }
  2743. /// <summary>
  2744. /// 继续游戏
  2745. /// </summary>
  2746. [MessageType(0x8303)]
  2747. public class GameResumeEvent : ClientEvent
  2748. {
  2749. public GameResumeEvent() { }
  2750. public override void WriteExternal(IOutputStream output)
  2751. {
  2752. }
  2753. public override void ReadExternal(IInputStream input)
  2754. {
  2755. }
  2756. }
  2757. /// <summary>
  2758. /// 移动镜头到
  2759. /// </summary>
  2760. [MessageType(0x8304)]
  2761. public class CameraMoveToEvent : ClientEvent
  2762. {
  2763. /// <summary>
  2764. /// 镜头移动速度(每秒距离)
  2765. /// </summary>
  2766. public float MoveSpeedSec = 1f;
  2767. /// <summary>
  2768. /// 移动过去的总时间,如果为0,则按速度计算
  2769. /// </summary>
  2770. public int TimeMS = 0;
  2771. public float x;
  2772. public float y;
  2773. public CameraMoveToEvent() { }
  2774. public CameraMoveToEvent(float x, float y, float speed, int timeMS)
  2775. {
  2776. this.x = x;
  2777. this.y = y;
  2778. this.MoveSpeedSec = speed;
  2779. this.TimeMS = timeMS;
  2780. }
  2781. override public void WriteExternal(IOutputStream output)
  2782. {
  2783. output.PutF32(x);
  2784. output.PutF32(y);
  2785. output.PutF32(MoveSpeedSec);
  2786. output.PutS32(TimeMS);
  2787. }
  2788. override public void ReadExternal(IInputStream input)
  2789. {
  2790. this.x = input.GetF32();
  2791. this.y = input.GetF32();
  2792. this.MoveSpeedSec = input.GetF32();
  2793. this.TimeMS = input.GetS32();
  2794. }
  2795. }
  2796. /// <summary>
  2797. /// 锁定镜头到单位
  2798. /// </summary>
  2799. [MessageType(0x8305)]
  2800. public class CameraFocusUnitEvent : ClientEvent
  2801. {
  2802. public uint ObjectID;
  2803. public CameraFocusUnitEvent() { }
  2804. public CameraFocusUnitEvent(uint oid)
  2805. {
  2806. this.ObjectID = oid;
  2807. }
  2808. override public void WriteExternal(IOutputStream output)
  2809. {
  2810. output.PutU32(ObjectID);
  2811. }
  2812. override public void ReadExternal(IInputStream input)
  2813. {
  2814. this.ObjectID = input.GetU32();
  2815. }
  2816. }
  2817. /// <summary>
  2818. /// 拉近镜头
  2819. /// </summary>
  2820. [MessageType(0x8306)]
  2821. public class CameraZoomToEvent : ClientEvent
  2822. {
  2823. /// <summary>
  2824. /// 镜头拉近距离
  2825. /// </summary>
  2826. public float ZoomDistance = 10f;
  2827. /// <summary>
  2828. /// 镜头拉近速度(每秒距离)
  2829. /// </summary>
  2830. public float ZoomSpeedSec = 1f;
  2831. public CameraZoomToEvent() { }
  2832. public CameraZoomToEvent(float distance, float speed)
  2833. {
  2834. this.ZoomDistance = distance;
  2835. this.ZoomSpeedSec = speed;
  2836. }
  2837. override public void WriteExternal(IOutputStream output)
  2838. {
  2839. output.PutF32(ZoomDistance);
  2840. output.PutF32(ZoomSpeedSec);
  2841. }
  2842. override public void ReadExternal(IInputStream input)
  2843. {
  2844. this.ZoomDistance = input.GetF32();
  2845. this.ZoomSpeedSec = input.GetF32();
  2846. }
  2847. }
  2848. /// <summary>
  2849. /// 旋转镜头
  2850. /// </summary>
  2851. [MessageType(0x8307)]
  2852. public class CameraRotateToEvent : ClientEvent
  2853. {
  2854. /// <summary>
  2855. /// 镜头旋转角度(0~360)
  2856. /// </summary>
  2857. public float RotateAngle = 10f;
  2858. /// <summary>
  2859. /// 镜头旋转速度(每秒角度)
  2860. /// </summary>
  2861. public float RotateSpeedSec = 1f;
  2862. public CameraRotateToEvent() { }
  2863. public CameraRotateToEvent(float angle, float speed)
  2864. {
  2865. this.RotateAngle = angle;
  2866. this.RotateSpeedSec = speed;
  2867. }
  2868. override public void WriteExternal(IOutputStream output)
  2869. {
  2870. output.PutF32(RotateAngle);
  2871. output.PutF32(RotateSpeedSec);
  2872. }
  2873. override public void ReadExternal(IInputStream input)
  2874. {
  2875. this.RotateAngle = input.GetF32();
  2876. this.RotateSpeedSec = input.GetF32();
  2877. }
  2878. }
  2879. /// <summary>
  2880. /// 重置镜头
  2881. /// </summary>
  2882. [MessageType(0x8308)]
  2883. public class CameraResetEvent : ClientEvent
  2884. {
  2885. public override void WriteExternal(IOutputStream output)
  2886. {
  2887. }
  2888. public override void ReadExternal(IInputStream input)
  2889. {
  2890. }
  2891. }
  2892. /// <summary>
  2893. /// 客户端动作序列
  2894. /// </summary>
  2895. [MessageType(0x8309)]
  2896. public class ClientEventQueue : ClientEvent
  2897. {
  2898. public List<ClientEvent> EventQueue = new List<ClientEvent>();
  2899. override public void WriteExternal(IOutputStream output)
  2900. {
  2901. output.PutU8((byte)EventQueue.Count);
  2902. foreach (ClientEvent e in EventQueue)
  2903. {
  2904. output.PutExt(e);
  2905. }
  2906. }
  2907. override public void ReadExternal(IInputStream input)
  2908. {
  2909. int count = input.GetU8();
  2910. for (int i = 0; i < count; i++)
  2911. {
  2912. EventQueue.Add(input.GetExtAny() as ClientEvent);
  2913. }
  2914. }
  2915. }
  2916. /// <summary>
  2917. /// 移动锁定一段时间
  2918. /// </summary>
  2919. [MessageType(0x830B)]
  2920. public class CameraHoldEvent : ClientEvent
  2921. {
  2922. public float x;
  2923. public float y;
  2924. public int TimeMS;
  2925. public CameraHoldEvent() { }
  2926. public CameraHoldEvent(float x, float y, int timeMS)
  2927. {
  2928. this.x = x;
  2929. this.y = y;
  2930. this.TimeMS = timeMS;
  2931. }
  2932. override public void WriteExternal(IOutputStream output)
  2933. {
  2934. output.PutF32(x);
  2935. output.PutF32(y);
  2936. output.PutS32(TimeMS);
  2937. }
  2938. override public void ReadExternal(IInputStream input)
  2939. {
  2940. this.x = input.GetF32();
  2941. this.y = input.GetF32();
  2942. this.TimeMS = input.GetS32();
  2943. }
  2944. }
  2945. #endregion
  2946. //--------------------------------------------------------------------------
  2947. #region PLAYER_EVENTS_0x8400
  2948. public abstract class PlayerEvent : ObjectEvent
  2949. {
  2950. public PlayerEvent() { }
  2951. public PlayerEvent(uint objID) : base(objID) { }
  2952. }
  2953. [MessageType(0x8400)]
  2954. public class PlayerCDEvent : PlayerEvent
  2955. {
  2956. private byte mask = 0;
  2957. public bool is_all
  2958. {
  2959. get { return BitMask.BitGetMask(mask, 0); }
  2960. set { BitMask.BitSetMask(ref mask, 0, value); }
  2961. }
  2962. public bool is_decrease_time
  2963. {
  2964. get { return BitMask.BitGetMask(mask, 1); }
  2965. set { BitMask.BitSetMask(ref mask, 1, value); }
  2966. }
  2967. public bool is_decrease_pct
  2968. {
  2969. get { return BitMask.BitGetMask(mask, 2); }
  2970. set { BitMask.BitSetMask(ref mask, 2, value); }
  2971. }
  2972. public bool is_clear
  2973. {
  2974. get { return BitMask.BitGetMask(mask, 3); }
  2975. set { BitMask.BitSetMask(ref mask, 3, value); }
  2976. }
  2977. public int decrease_timeMS;
  2978. public float decrease_pct;
  2979. public int skill_template_id;
  2980. public PlayerCDEvent() { }
  2981. public PlayerCDEvent(uint unit_id) : base(unit_id) { }
  2982. override public void WriteExternal(IOutputStream output)
  2983. {
  2984. base.WriteExternal(output);
  2985. output.PutU8(mask);
  2986. if (is_all)
  2987. {
  2988. if (is_decrease_pct)
  2989. output.PutF32(decrease_pct);
  2990. if (is_decrease_time)
  2991. output.PutVS32(decrease_timeMS);
  2992. }
  2993. else
  2994. {
  2995. output.PutS32(skill_template_id);
  2996. if (is_decrease_pct)
  2997. output.PutF32(decrease_pct);
  2998. if (is_decrease_time)
  2999. output.PutVS32(decrease_timeMS);
  3000. }
  3001. }
  3002. override public void ReadExternal(IInputStream input)
  3003. {
  3004. base.ReadExternal(input);
  3005. this.mask = input.GetU8();
  3006. if (is_all)
  3007. {
  3008. if (is_decrease_pct)
  3009. decrease_pct = input.GetF32();
  3010. if (is_decrease_time)
  3011. decrease_timeMS = input.GetVS32();
  3012. }
  3013. else
  3014. {
  3015. skill_template_id = input.GetS32();
  3016. if (is_decrease_pct)
  3017. decrease_pct = input.GetF32();
  3018. if (is_decrease_time)
  3019. decrease_timeMS = input.GetVS32();
  3020. }
  3021. }
  3022. }
  3023. [MessageType(0x8401)]
  3024. public class PlayerSkillChangedEvent : PlayerEvent
  3025. {
  3026. public SkillTemplate baseSkill;
  3027. public List<SkillTemplate> skills = new List<SkillTemplate>();
  3028. public float unitFastCastRate;
  3029. public PlayerSkillChangedEvent() { }
  3030. public PlayerSkillChangedEvent(uint unit_id) : base(unit_id) { }
  3031. override public void WriteExternal(IOutputStream output)
  3032. {
  3033. base.WriteExternal(output);
  3034. output.PutF32(this.unitFastCastRate);
  3035. output.PutExt(this.baseSkill);
  3036. output.PutList<SkillTemplate>(this.skills, output.PutExt);
  3037. }
  3038. override public void ReadExternal(IInputStream input)
  3039. {
  3040. base.ReadExternal(input);
  3041. this.unitFastCastRate = input.GetF32();
  3042. this.baseSkill = input.GetExt<SkillTemplate>();
  3043. this.skills = input.GetList<SkillTemplate>(input.GetExt<SkillTemplate>);
  3044. }
  3045. }
  3046. [MessageType(0x8402)]
  3047. public class PlayerSyncEnvironmentVarEvent : PlayerEvent
  3048. {
  3049. public string Key;
  3050. public object Value;
  3051. public PlayerSyncEnvironmentVarEvent() { }
  3052. public PlayerSyncEnvironmentVarEvent(uint unit_id, string key, object value)
  3053. : base(unit_id)
  3054. {
  3055. this.Key = key;
  3056. this.Value = value;
  3057. }
  3058. override public void WriteExternal(IOutputStream output)
  3059. {
  3060. base.WriteExternal(output);
  3061. output.PutUTF(Key);
  3062. output.PutData(Value);
  3063. }
  3064. override public void ReadExternal(IInputStream input)
  3065. {
  3066. base.ReadExternal(input);
  3067. DataType dtype;
  3068. this.Key = input.GetUTF();
  3069. this.Value = input.GetData(out dtype);
  3070. }
  3071. }
  3072. [MessageType(0x8403)]
  3073. public class PlayerSkillStopEvent : PlayerEvent
  3074. {
  3075. public int SkillID;
  3076. public PlayerSkillStopEvent() { }
  3077. public PlayerSkillStopEvent(uint unit_id, int skillID)
  3078. : base(unit_id)
  3079. {
  3080. this.SkillID = skillID;
  3081. }
  3082. override public void WriteExternal(IOutputStream output)
  3083. {
  3084. base.WriteExternal(output);
  3085. output.PutS32(SkillID);
  3086. }
  3087. override public void ReadExternal(IInputStream input)
  3088. {
  3089. base.ReadExternal(input);
  3090. this.SkillID = input.GetS32();
  3091. }
  3092. }
  3093. [MessageType(0x8404)]
  3094. public class PlayerSkillAddedEvent : PlayerEvent
  3095. {
  3096. public SkillTemplate Skill;
  3097. public bool IsDefault;
  3098. public PlayerSkillAddedEvent() { }
  3099. public PlayerSkillAddedEvent(uint unit_id, SkillTemplate sk, bool isDefault)
  3100. : base(unit_id)
  3101. {
  3102. this.Skill = sk;
  3103. this.IsDefault = isDefault;
  3104. }
  3105. override public void WriteExternal(IOutputStream output)
  3106. {
  3107. base.WriteExternal(output);
  3108. output.PutExt(this.Skill);
  3109. output.PutBool(this.IsDefault);
  3110. }
  3111. override public void ReadExternal(IInputStream input)
  3112. {
  3113. base.ReadExternal(input);
  3114. this.Skill = input.GetExt<SkillTemplate>();
  3115. this.IsDefault = input.GetBool();
  3116. }
  3117. }
  3118. [MessageType(0x8405)]
  3119. public class PlayerSkillRemovedEvent : PlayerEvent
  3120. {
  3121. public int SkillID;
  3122. public PlayerSkillRemovedEvent() { }
  3123. public PlayerSkillRemovedEvent(uint unit_id, int skillID)
  3124. : base(unit_id)
  3125. {
  3126. this.SkillID = skillID;
  3127. }
  3128. override public void WriteExternal(IOutputStream output)
  3129. {
  3130. base.WriteExternal(output);
  3131. output.PutS32(this.SkillID);
  3132. }
  3133. override public void ReadExternal(IInputStream input)
  3134. {
  3135. base.ReadExternal(input);
  3136. this.SkillID = input.GetS32();
  3137. }
  3138. }
  3139. /// <summary>
  3140. /// 脚本系统指令
  3141. /// </summary>
  3142. [MessageType(0x8406)]
  3143. public class PlayerScriptCommandEvent : PlayerEvent
  3144. {
  3145. public string message;
  3146. public PlayerScriptCommandEvent() { }
  3147. public PlayerScriptCommandEvent(uint unit_id, string msg)
  3148. : base(unit_id)
  3149. {
  3150. this.message = msg;
  3151. }
  3152. override public void WriteExternal(IOutputStream output)
  3153. {
  3154. base.WriteExternal(output);
  3155. output.PutUTF(message);
  3156. }
  3157. override public void ReadExternal(IInputStream input)
  3158. {
  3159. base.ReadExternal(input);
  3160. this.message = input.GetUTF();
  3161. }
  3162. }
  3163. /// <summary>
  3164. /// 技能可用性发生变化
  3165. /// </summary>
  3166. [MessageType(0x8407)]
  3167. public class PlayerSkillActiveChangedEvent : PlayerEvent
  3168. {
  3169. public struct State
  3170. {
  3171. public int SkillTemplateID;
  3172. public SkillActiveState ST;
  3173. public bool IsActive { get { return ST == SkillActiveState.Active; } }
  3174. public bool IsPauseOnDeactive { get { return ST == SkillActiveState.DeactiveAndPause; } }
  3175. }
  3176. public List<State> Skills;
  3177. public PlayerSkillActiveChangedEvent() { this.Skills = new List<State>(); }
  3178. public PlayerSkillActiveChangedEvent(uint unit_id, int skillCount) : base(unit_id)
  3179. {
  3180. this.Skills = new List<State>(skillCount);
  3181. }
  3182. override public void WriteExternal(IOutputStream output)
  3183. {
  3184. base.WriteExternal(output);
  3185. output.PutVS32(Skills.Count);
  3186. for (int i = 0; i < Skills.Count; i++)
  3187. {
  3188. State sat = Skills[i];
  3189. output.PutS32(sat.SkillTemplateID);
  3190. output.PutEnum8(sat.ST);
  3191. }
  3192. }
  3193. override public void ReadExternal(IInputStream input)
  3194. {
  3195. base.ReadExternal(input);
  3196. int count = input.GetVS32();
  3197. this.Skills.Capacity = count;
  3198. for (int i = 0; i < count; i++)
  3199. {
  3200. State sat = new State();
  3201. sat.SkillTemplateID = input.GetS32();
  3202. sat.ST = input.GetEnum8<SkillActiveState>();
  3203. this.Skills.Add(sat);
  3204. }
  3205. }
  3206. }
  3207. [MessageType(0x8408)]
  3208. public class PlayerSkillTimeChangedEvent : PlayerEvent
  3209. {
  3210. public int SkillTemplateID;
  3211. public int SkillPassTimeMS;
  3212. public int SkillTotalTimeMS;
  3213. public PlayerSkillTimeChangedEvent() { }
  3214. public PlayerSkillTimeChangedEvent(uint unit_id, int skillID, int passTimeMS, int totalTimeMS)
  3215. : base(unit_id)
  3216. {
  3217. this.SkillTemplateID = skillID;
  3218. this.SkillPassTimeMS = passTimeMS;
  3219. this.SkillTotalTimeMS = totalTimeMS;
  3220. }
  3221. override public void WriteExternal(IOutputStream output)
  3222. {
  3223. base.WriteExternal(output);
  3224. output.PutS32(this.SkillTemplateID);
  3225. output.PutVS32(this.SkillPassTimeMS);
  3226. output.PutVS32(this.SkillTotalTimeMS);
  3227. }
  3228. override public void ReadExternal(IInputStream input)
  3229. {
  3230. base.ReadExternal(input);
  3231. this.SkillTemplateID = input.GetS32();
  3232. this.SkillPassTimeMS = input.GetVS32();
  3233. this.SkillTotalTimeMS = input.GetVS32();
  3234. }
  3235. }
  3236. /// <summary>
  3237. /// 锁定目标
  3238. /// </summary>
  3239. [MessageType(0x8409)]
  3240. public class PlayerFocuseTargetEvent : PlayerEvent
  3241. {
  3242. public uint targetUnitID;
  3243. public SkillTemplate.CastTarget expectTarget;
  3244. public PlayerFocuseTargetEvent() { }
  3245. public PlayerFocuseTargetEvent(uint unit_id, uint target_id, SkillTemplate.CastTarget expect)
  3246. : base(unit_id)
  3247. {
  3248. this.targetUnitID = target_id;
  3249. this.expectTarget = expect;
  3250. }
  3251. override public void WriteExternal(IOutputStream output)
  3252. {
  3253. base.WriteExternal(output);
  3254. output.PutU32(targetUnitID);
  3255. output.PutEnum8(expectTarget);
  3256. }
  3257. override public void ReadExternal(IInputStream input)
  3258. {
  3259. base.ReadExternal(input);
  3260. this.targetUnitID = input.GetU32();
  3261. this.expectTarget = input.GetEnum8<SkillTemplate.CastTarget>();
  3262. }
  3263. }
  3264. #endregion
  3265. //--------------------------------------------------------------------------
  3266. #region TEXT_0x8500
  3267. public enum ChatMessageType : byte
  3268. {
  3269. SystemToAll,
  3270. SystemToForce,
  3271. SystemToPlayer,
  3272. PlayerToAll,
  3273. PlayerToForce,
  3274. PlayerToPlayer,
  3275. }
  3276. [MessageType(0x8500)]
  3277. public class ChatAction : ObjectAction
  3278. {
  3279. public string Message;
  3280. public ChatMessageType To = ChatMessageType.SystemToAll;
  3281. public string TargetPlayerUUID;
  3282. public override void WriteExternal(IOutputStream output)
  3283. {
  3284. base.WriteExternal(output);
  3285. output.PutU8((byte)this.To);
  3286. output.PutUTF(this.Message);
  3287. output.PutUTF(this.TargetPlayerUUID);
  3288. }
  3289. public override void ReadExternal(IInputStream input)
  3290. {
  3291. base.ReadExternal(input);
  3292. this.To = (ChatMessageType)input.GetU8();
  3293. this.Message = input.GetUTF();
  3294. this.TargetPlayerUUID = input.GetUTF();
  3295. }
  3296. }
  3297. [MessageType(0x8501)]
  3298. public class ChatEvent : ZoneEvent
  3299. {
  3300. public ChatMessageType To = ChatMessageType.SystemToAll;
  3301. public int Force;
  3302. public string FromPlayerUUID;
  3303. public string ToPlayerUUID;
  3304. public string Message;
  3305. public uint KeepTimeMS;
  3306. public ChatEvent() { }
  3307. public ChatEvent(ChatMessageType to, uint timeMS = 2000)
  3308. {
  3309. this.To = to;
  3310. KeepTimeMS = timeMS;
  3311. }
  3312. public override void WriteExternal(IOutputStream output)
  3313. {
  3314. output.PutU8((byte)this.To);
  3315. output.PutVS32((int)KeepTimeMS);
  3316. output.PutUTF(this.Message);
  3317. switch (To)
  3318. {
  3319. case ChatMessageType.PlayerToAll:
  3320. output.PutUTF(this.FromPlayerUUID);
  3321. break;
  3322. case ChatMessageType.PlayerToForce:
  3323. output.PutUTF(this.FromPlayerUUID);
  3324. output.PutVS32(this.Force);
  3325. break;
  3326. case ChatMessageType.PlayerToPlayer:
  3327. output.PutUTF(this.FromPlayerUUID);
  3328. output.PutUTF(this.ToPlayerUUID);
  3329. break;
  3330. case ChatMessageType.SystemToAll:
  3331. break;
  3332. case ChatMessageType.SystemToForce:
  3333. output.PutVS32(this.Force);
  3334. break;
  3335. case ChatMessageType.SystemToPlayer:
  3336. output.PutUTF(this.ToPlayerUUID);
  3337. break;
  3338. }
  3339. }
  3340. public override void ReadExternal(IInputStream input)
  3341. {
  3342. this.To = (ChatMessageType)input.GetU8();
  3343. this.KeepTimeMS = (uint)input.GetVS32();
  3344. this.Message = input.GetUTF();
  3345. switch (To)
  3346. {
  3347. case ChatMessageType.PlayerToAll:
  3348. this.FromPlayerUUID = input.GetUTF();
  3349. break;
  3350. case ChatMessageType.PlayerToForce:
  3351. this.FromPlayerUUID = input.GetUTF();
  3352. this.Force = input.GetVS32();
  3353. break;
  3354. case ChatMessageType.PlayerToPlayer:
  3355. this.FromPlayerUUID = input.GetUTF();
  3356. this.ToPlayerUUID = input.GetUTF();
  3357. break;
  3358. case ChatMessageType.SystemToAll:
  3359. break;
  3360. case ChatMessageType.SystemToForce:
  3361. this.Force = input.GetVS32();
  3362. break;
  3363. case ChatMessageType.SystemToPlayer:
  3364. this.ToPlayerUUID = input.GetUTF();
  3365. break;
  3366. }
  3367. }
  3368. }
  3369. [MessageType(0x8502)]
  3370. public class BubbleTalkEvent : ZoneEvent
  3371. {
  3372. public bool PauseBattle;
  3373. public List<TalkInfo> TalkInfos = new List<TalkInfo>();
  3374. public BubbleTalkEvent() { }
  3375. override public void WriteExternal(IOutputStream output)
  3376. {
  3377. output.PutBool(PauseBattle);
  3378. output.PutExtList<TalkInfo>(this.TalkInfos);
  3379. }
  3380. override public void ReadExternal(IInputStream input)
  3381. {
  3382. this.PauseBattle = input.GetBool();
  3383. this.TalkInfos = input.GetExtList<TalkInfo>();
  3384. }
  3385. public class TalkInfo : IExternalizable
  3386. {
  3387. public uint TalkUnit;
  3388. public string TalkContent;
  3389. public string TalkActionType;
  3390. public int TalkDelayTimeMS;
  3391. public int TalkKeepTimeMS;
  3392. public TalkInfo() { }
  3393. public TalkInfo(uint TalkUnit, string TalkContent, string TalkActionType, int TalkDelayTimeMS, int TalkKeepTimeMS)
  3394. {
  3395. this.TalkUnit = TalkUnit;
  3396. this.TalkContent = TalkContent;
  3397. this.TalkActionType = TalkActionType;
  3398. this.TalkDelayTimeMS = TalkDelayTimeMS;
  3399. this.TalkKeepTimeMS = TalkKeepTimeMS;
  3400. }
  3401. public void WriteExternal(IOutputStream output)
  3402. {
  3403. output.PutVU32(TalkUnit);
  3404. output.PutUTF(TalkContent);
  3405. output.PutUTF(TalkActionType);
  3406. output.PutVS32(TalkDelayTimeMS);
  3407. output.PutVS32(TalkKeepTimeMS);
  3408. }
  3409. public void ReadExternal(IInputStream input)
  3410. {
  3411. this.TalkUnit = input.GetVU32();
  3412. this.TalkContent = input.GetUTF();
  3413. this.TalkActionType = input.GetUTF();
  3414. this.TalkDelayTimeMS = input.GetVS32();
  3415. this.TalkKeepTimeMS = input.GetVS32();
  3416. }
  3417. }
  3418. }
  3419. [MessageType(0x8503)]
  3420. public class PlayerSkillUseTimeChangedEvent : PlayerEvent
  3421. {
  3422. public int SkillTemplateID;
  3423. public byte useTimes;
  3424. public byte hasNext; //0-不用继续叠层,1-继续增加叠层
  3425. public PlayerSkillUseTimeChangedEvent() { }
  3426. public PlayerSkillUseTimeChangedEvent(uint unit_id, int skillID, byte useTimes)
  3427. : base(unit_id)
  3428. {
  3429. this.SkillTemplateID = skillID;
  3430. this.useTimes = useTimes;
  3431. }
  3432. override public void WriteExternal(IOutputStream output)
  3433. {
  3434. base.WriteExternal(output);
  3435. output.PutS32(this.SkillTemplateID);
  3436. output.PutU8(this.useTimes);
  3437. output.PutU8(this.hasNext);
  3438. }
  3439. override public void ReadExternal(IInputStream input)
  3440. {
  3441. base.ReadExternal(input);
  3442. this.SkillTemplateID = input.GetS32();
  3443. this.useTimes = input.GetU8();
  3444. this.hasNext = input.GetU8();
  3445. }
  3446. }
  3447. /// <summary>
  3448. /// 单位中BUFF
  3449. /// </summary>
  3450. [MessageType(0x8504)]
  3451. public class SyncUnitBuffState : ObjectEvent
  3452. {
  3453. public int buffTemplateID;
  3454. public byte overlayLevel;
  3455. public int buffExtData; //buff的扩展字段,
  3456. public SyncUnitBuffState() { }
  3457. public SyncUnitBuffState(uint unit_id, int buffID, byte overlayLevel, int extData)
  3458. : base(unit_id)
  3459. {
  3460. this.buffTemplateID = buffID;
  3461. this.overlayLevel = overlayLevel;
  3462. this.buffExtData = extData;
  3463. }
  3464. override public void WriteExternal(IOutputStream output)
  3465. {
  3466. base.WriteExternal(output);
  3467. output.PutVS32(buffTemplateID);
  3468. output.PutU8(overlayLevel);
  3469. output.PutVS32(buffExtData);
  3470. }
  3471. override public void ReadExternal(IInputStream input)
  3472. {
  3473. base.ReadExternal(input);
  3474. this.buffTemplateID = input.GetVS32();
  3475. this.overlayLevel = input.GetU8();
  3476. this.buffExtData = input.GetVS32();
  3477. }
  3478. }
  3479. /// <summary>
  3480. /// 单位触发能力
  3481. /// </summary>
  3482. [MessageType(0x8505)]
  3483. public class UnitTriggerAblity : ObjectEvent
  3484. {
  3485. public int ablityID;
  3486. public UnitTriggerAblity() { }
  3487. public UnitTriggerAblity(uint unit_id, int id)
  3488. : base(unit_id)
  3489. {
  3490. this.ablityID = id;
  3491. }
  3492. override public void WriteExternal(IOutputStream output)
  3493. {
  3494. base.WriteExternal(output);
  3495. output.PutVS32(ablityID);
  3496. }
  3497. override public void ReadExternal(IInputStream input)
  3498. {
  3499. base.ReadExternal(input);
  3500. this.ablityID = input.GetVS32();
  3501. }
  3502. }
  3503. /// <summary>
  3504. /// 单位触发破碎效果
  3505. /// </summary>
  3506. [MessageType(0x8506)]
  3507. public class UnitHitBreak : ObjectEvent
  3508. {
  3509. public UnitHitBreak() { }
  3510. public UnitHitBreak(uint unit_id)
  3511. : base(unit_id)
  3512. {
  3513. }
  3514. override public void WriteExternal(IOutputStream output)
  3515. {
  3516. base.WriteExternal(output);
  3517. //output.PutVS32(ablityID);
  3518. }
  3519. override public void ReadExternal(IInputStream input)
  3520. {
  3521. base.ReadExternal(input);
  3522. //this.ablityID = input.GetVS32();
  3523. }
  3524. }
  3525. /// <summary>
  3526. /// 单位触发隐身效果
  3527. /// </summary>
  3528. [MessageType(0x8507)]
  3529. public class UnitStealthInfo : ObjectEvent
  3530. {
  3531. public byte stealth;
  3532. public short flag;
  3533. public UnitStealthInfo() { }
  3534. public UnitStealthInfo(uint unit_id, byte stealth, short flag)
  3535. : base(unit_id)
  3536. {
  3537. this.stealth = stealth;
  3538. this.flag = flag;
  3539. }
  3540. override public void WriteExternal(IOutputStream output)
  3541. {
  3542. base.WriteExternal(output);
  3543. output.PutU8(this.stealth);
  3544. output.PutS16(this.flag);
  3545. //Console.WriteLine("UnitStealthInfo: " + this.stealth + ", " + flag);
  3546. }
  3547. override public void ReadExternal(IInputStream input)
  3548. {
  3549. base.ReadExternal(input);
  3550. this.stealth = input.GetU8();
  3551. this.flag = input.GetS16();
  3552. }
  3553. }
  3554. /// <summary>
  3555. /// buff数据推送:针对单一buff事件内的信息变更
  3556. /// </summary>
  3557. [MessageType(0x8508)]
  3558. public class BuffDataNotify : ObjectEvent
  3559. {
  3560. public int buffId;
  3561. public uint senderId;
  3562. public byte overlayLevel;
  3563. public BuffDataNotify() { }
  3564. public BuffDataNotify(uint unit_id, int buffId, uint senderId, int layer)
  3565. : base(unit_id)
  3566. {
  3567. this.buffId = buffId;
  3568. this.senderId = senderId;
  3569. this.overlayLevel = (byte)layer;
  3570. }
  3571. override public void WriteExternal(IOutputStream output)
  3572. {
  3573. base.WriteExternal(output);
  3574. output.PutS32(this.buffId);
  3575. output.PutU32(this.senderId);
  3576. output.PutU8(this.overlayLevel);
  3577. //System.Console.WriteLine("-----BuffDataNotify: " + buffId + ", " + this.object_id + ", " + overlayLevel);
  3578. }
  3579. override public void ReadExternal(IInputStream input)
  3580. {
  3581. base.ReadExternal(input);
  3582. this.buffId = input.GetS32();
  3583. this.senderId = input.GetU32();
  3584. this.overlayLevel = input.GetU8();
  3585. }
  3586. }
  3587. #endregion
  3588. //--------------------------------------------------------------------------
  3589. #region SYSTEM_0x8600
  3590. [MessageType(0x8600)]
  3591. public class Ping : Action, SystemMessage
  3592. {
  3593. public uint DayOfMS;
  3594. public Ping()
  3595. {
  3596. DayOfMS = (uint)CUtils.CurrentTimeMS;
  3597. }
  3598. public void Begin()
  3599. {
  3600. DayOfMS = (uint)CUtils.CurrentTimeMS;
  3601. }
  3602. public override void WriteExternal(IOutputStream output)
  3603. {
  3604. output.PutU32(DayOfMS);
  3605. }
  3606. public override void ReadExternal(IInputStream input)
  3607. {
  3608. DayOfMS = input.GetU32();
  3609. }
  3610. }
  3611. [MessageType(0x8601)]
  3612. public class Pong : Event, SystemMessage
  3613. {
  3614. public uint ClientTimeDayOfMS;
  3615. public Pong() { }
  3616. public Pong(Ping ping) { this.ClientTimeDayOfMS = ping.DayOfMS; }
  3617. public override void WriteExternal(IOutputStream output)
  3618. {
  3619. output.PutU32(ClientTimeDayOfMS);
  3620. }
  3621. public override void ReadExternal(IInputStream input)
  3622. {
  3623. ClientTimeDayOfMS = input.GetU32();
  3624. }
  3625. }
  3626. /// <summary>
  3627. /// 打包一组消息,一次性发出
  3628. /// </summary>
  3629. [MessageType(0x8602)]
  3630. public class PackEvent : Event, SystemMessage
  3631. {
  3632. protected static readonly Logger log = LoggerFactory.GetDefLogger();
  3633. public int sequenceNo;
  3634. public List<IMessage> events = new List<IMessage>();
  3635. public override string ToString()
  3636. {
  3637. var sb = new StringBuilder("PackEvent: no=").Append(sequenceNo).AppendLine();
  3638. foreach (IMessage e in events)
  3639. {
  3640. sb.AppendLine(e.ToString());
  3641. }
  3642. return sb.ToString();
  3643. }
  3644. public override void WriteExternal(IOutputStream output)
  3645. {
  3646. output.PutVS32(sequenceNo);
  3647. output.PutVS32(events.Count);
  3648. #if JSGProfile
  3649. long startSize = output.GetBuffPos();
  3650. #endif
  3651. foreach (IMessage e in events)
  3652. {
  3653. //if (!e.ToString().EndsWith("Pong") && !e.ToString().EndsWith("SyncPosEvent"))
  3654. //{
  3655. // Console.WriteLine("PackEvent: " + e);
  3656. //}
  3657. output.PutExt(e);
  3658. #if JSGProfile
  3659. long tempSize = output.GetBuffPos();
  3660. JSGServerProfile.RecordSend(output.GetTypeID(e), tempSize - startSize);
  3661. startSize = tempSize;
  3662. #endif
  3663. }
  3664. }
  3665. public override void ReadExternal(IInputStream input)
  3666. {
  3667. this.sequenceNo = input.GetVS32();
  3668. int count = input.GetVS32();
  3669. events.Clear();
  3670. events.Capacity = count;
  3671. for (int i = 0; i < count; i++)
  3672. {
  3673. try
  3674. {
  3675. IMessage e = (IMessage)input.GetExtAny();
  3676. events.Add(e);
  3677. }
  3678. catch (Exception err)
  3679. {
  3680. log.Error("PackEvent readExt catch:" + err);
  3681. }
  3682. }
  3683. }
  3684. public override void BeforeWrite(TemplateManager templates)
  3685. {
  3686. foreach (IMessage e in events)
  3687. {
  3688. if (e is BattleMessage)
  3689. {
  3690. (e as BattleMessage).BeforeWrite(templates);
  3691. }
  3692. }
  3693. }
  3694. public override void EndRead(TemplateManager templates)
  3695. {
  3696. foreach (IMessage e in events)
  3697. {
  3698. if (e is BattleMessage)
  3699. {
  3700. (e as BattleMessage).EndRead(templates);
  3701. }
  3702. }
  3703. }
  3704. }
  3705. /// <summary>
  3706. /// 系统消息框,测试用
  3707. /// </summary>
  3708. [MessageType(0x8603)]
  3709. public class TestMessageBox : Event, SystemMessage
  3710. {
  3711. public string msg;
  3712. public TestMessageBox() { }
  3713. public TestMessageBox(string msg)
  3714. {
  3715. this.msg = msg;
  3716. }
  3717. public override void WriteExternal(IOutputStream output)
  3718. {
  3719. output.PutUTF(this.msg);
  3720. }
  3721. public override void ReadExternal(IInputStream input)
  3722. {
  3723. this.msg = input.GetUTF();
  3724. }
  3725. }
  3726. /// <summary>
  3727. /// 通知客户端服务器运行状态
  3728. /// </summary>
  3729. [MessageType(0x8604)]
  3730. public class ServerStatusB2C : Event, SystemMessage
  3731. {
  3732. public int PID;
  3733. public long PrivateMemorySize64;
  3734. public int ActiveGameObjectCount;
  3735. public int ActiveInstanceZoneCount;
  3736. public int AllocGameObjectCount;
  3737. public int AllocInstanceZoneCount;
  3738. public ServerStatusB2C() { }
  3739. public void Update(System.Diagnostics.Process p)
  3740. {
  3741. this.PID = p.Id;
  3742. this.PrivateMemorySize64 = p.PrivateMemorySize64;
  3743. this.ActiveGameObjectCount = InstanceZoneObject.ActiveObjectCount;
  3744. this.ActiveInstanceZoneCount = InstanceZone.ActiveZoneCount;
  3745. this.AllocGameObjectCount = InstanceZoneObject.AllocObjectCount;
  3746. this.AllocInstanceZoneCount = InstanceZone.AllocZoneCount;
  3747. }
  3748. public override void WriteExternal(IOutputStream output)
  3749. {
  3750. output.PutVS32(this.PID);
  3751. output.PutVS64(this.PrivateMemorySize64);
  3752. output.PutVS32(this.ActiveGameObjectCount);
  3753. output.PutVS32(this.ActiveInstanceZoneCount);
  3754. output.PutVS32(this.AllocGameObjectCount);
  3755. output.PutVS32(this.AllocInstanceZoneCount);
  3756. }
  3757. public override void ReadExternal(IInputStream input)
  3758. {
  3759. this.PID = input.GetVS32();
  3760. this.PrivateMemorySize64 = input.GetVS64();
  3761. this.ActiveGameObjectCount = input.GetVS32();
  3762. this.ActiveInstanceZoneCount = input.GetVS32();
  3763. this.AllocGameObjectCount = input.GetVS32();
  3764. this.AllocInstanceZoneCount = input.GetVS32();
  3765. }
  3766. }
  3767. /// <summary>
  3768. /// 通知客户端服务器报错
  3769. /// </summary>
  3770. [MessageType(0x8605)]
  3771. public class ServerExceptionB2C : Event, SystemMessage
  3772. {
  3773. public string Message;
  3774. public string StackTrace;
  3775. public ServerExceptionB2C() { }
  3776. public ServerExceptionB2C(string message, string stackTrace)
  3777. {
  3778. this.Message = message;
  3779. this.StackTrace = stackTrace;
  3780. }
  3781. public override void WriteExternal(IOutputStream output)
  3782. {
  3783. output.PutUTF(this.Message);
  3784. output.PutUTF(this.StackTrace);
  3785. }
  3786. public override void ReadExternal(IInputStream input)
  3787. {
  3788. this.Message = input.GetUTF();
  3789. this.StackTrace = input.GetUTF();
  3790. }
  3791. }
  3792. [MessageType(0x8606)]
  3793. public class UnitFollowAction : ObjectAction
  3794. {
  3795. public bool follow = false;
  3796. public string reason = null;
  3797. public UnitFollowAction() { }
  3798. public UnitFollowAction(uint unit_id, bool guard)
  3799. : base(unit_id)
  3800. {
  3801. this.follow = guard;
  3802. }
  3803. public UnitFollowAction(uint unit_id, bool guard, string reason)
  3804. : base(unit_id)
  3805. {
  3806. this.follow = guard;
  3807. this.reason = reason;
  3808. }
  3809. override public void WriteExternal(IOutputStream output)
  3810. {
  3811. base.WriteExternal(output);
  3812. output.PutBool(follow);
  3813. output.PutUTF(reason);
  3814. }
  3815. override public void ReadExternal(IInputStream input)
  3816. {
  3817. base.ReadExternal(input);
  3818. this.follow = input.GetBool();
  3819. this.reason = input.GetUTF();
  3820. }
  3821. }
  3822. #endregion
  3823. //--------------------------------------------------------------------------
  3824. /// <summary>
  3825. /// 新增技能移动的协议
  3826. /// </summary>
  3827. [MessageType(0x8700)]
  3828. public class SkillMove : ObjectAction
  3829. {
  3830. public int SkillID;
  3831. public Vector2 SkillPos;
  3832. public SkillMove() { }
  3833. public SkillMove(uint unit_id, int skill_id, Vector2 vec):base(unit_id)
  3834. {
  3835. this.SkillID = skill_id;
  3836. this.SkillPos = vec;
  3837. }
  3838. override public void WriteExternal(IOutputStream output)
  3839. {
  3840. base.WriteExternal(output);
  3841. output.PutS32(SkillID);
  3842. output.PutF32(SkillPos.X);
  3843. output.PutF32(SkillPos.Y);
  3844. }
  3845. override public void ReadExternal(IInputStream input)
  3846. {
  3847. base.ReadExternal(input);
  3848. this.SkillID = input.GetS32();
  3849. this.SkillPos = new Vector2();
  3850. this.SkillPos.SetX(input.GetF32());
  3851. this.SkillPos.SetY(input.GetF32());
  3852. }
  3853. }
  3854. /// <summary>
  3855. /// 法术Dispose后,在播放一个过渡特效
  3856. /// </summary>
  3857. [MessageType(0x8701)]
  3858. public class PlayDestoryEffect : ZoneEvent
  3859. {
  3860. public string EffectName;
  3861. public float X;
  3862. public float Y;
  3863. public float Z;
  3864. //rotation
  3865. public float Direction;
  3866. public PlayDestoryEffect() { }
  3867. public PlayDestoryEffect(string effectName, float x, float y, float z, float direction)
  3868. {
  3869. EffectName = effectName;
  3870. X = x;
  3871. Y = y;
  3872. Z = z;
  3873. Direction = direction;
  3874. }
  3875. override public void WriteExternal(IOutputStream output)
  3876. {
  3877. output.PutUTF(EffectName);
  3878. output.PutF32(X);
  3879. output.PutF32(Y);
  3880. output.PutF32(Z);
  3881. output.PutF32(Direction);
  3882. }
  3883. override public void ReadExternal(IInputStream input)
  3884. {
  3885. this.EffectName = input.GetUTF();
  3886. this.X = input.GetF32();
  3887. this.Y = input.GetF32();
  3888. this.Z = input.GetF32();
  3889. this.Direction = input.GetF32();
  3890. }
  3891. }
  3892. /// <summary>
  3893. /// 随从瞬移
  3894. /// </summary>
  3895. [MessageType(0x8702)]
  3896. public class PlayPetTeleportAction : ObjectAction
  3897. {
  3898. public PlayPetTeleportAction() { }
  3899. override public void WriteExternal(IOutputStream output)
  3900. {
  3901. }
  3902. override public void ReadExternal(IInputStream input)
  3903. {
  3904. }
  3905. }
  3906. /// <summary>
  3907. /// 刷新玩家天赋相关信息
  3908. ///
  3909. /// </summary>
  3910. [MessageType(0x8703)]
  3911. public class RefreshTalnetInfo: PlayerSingleMsg
  3912. {
  3913. //根据不同职业,不同解读
  3914. //战士:value:怒气值,lv:无
  3915. //法师:value: 剑气值,lv:剑气层数
  3916. public short value; //天赋值,每秒降低,服务器刷新
  3917. public byte lv;
  3918. public int lvUpdateTime; //等级最后刷新时间,变化不频繁,需要根据本地时间自己做进度效果(lv=0无)
  3919. public RefreshTalnetInfo() { }
  3920. public RefreshTalnetInfo(short value, byte lv = 0, int updateTime = 0)
  3921. {
  3922. this.value = value;
  3923. this.lv = lv;
  3924. this.lvUpdateTime = updateTime;
  3925. }
  3926. override public void WriteExternal(IOutputStream output)
  3927. {
  3928. output.PutS16(this.value);
  3929. output.PutU8(this.lv);
  3930. if(this.lv > 0)
  3931. {
  3932. output.PutS32(this.lvUpdateTime);
  3933. }
  3934. }
  3935. override public void ReadExternal(IInputStream input)
  3936. {
  3937. this.value = input.GetS16();
  3938. this.lv = input.GetU8();
  3939. if(this.lv > 0)
  3940. {
  3941. this.lvUpdateTime = input.GetS32();
  3942. }
  3943. //System.Console.WriteLine("RefreshTalnetInfo: " + this.value + ", " + this.lv + ", " + this.lvUpdateTime);
  3944. }
  3945. }
  3946. /// <summary>
  3947. /// 刷新玩家卡牌珠相关信息
  3948. /// </summary>
  3949. [MessageType(0x8704)]
  3950. public class RefreshCardInfo : PlayerSingleMsg
  3951. {
  3952. public byte[] cardData = new byte[(int)CardType.Max]; //0-3代表有
  3953. public RefreshCardInfo()
  3954. {
  3955. for(int i = 0; i < (int)CardType.Max; i++)
  3956. {
  3957. cardData[i] = (byte)CardType.Max;
  3958. }
  3959. }
  3960. override public void WriteExternal(IOutputStream output)
  3961. {
  3962. for(int i = 0; i < (int)CardType.Max; i++)
  3963. {
  3964. output.PutU8(cardData[i]);
  3965. }
  3966. //System.Console.WriteLine("--------RefreshCardInfo: " + cardData[0] + ", " + cardData[1] + ", " + cardData[2] + ", " + cardData[3]);
  3967. }
  3968. override public void ReadExternal(IInputStream input)
  3969. {
  3970. //System.Console.WriteLine("--------RefreshCardInfo");
  3971. for (int i = 0; i < (int)CardType.Max; i++)
  3972. {
  3973. cardData[i] = input.GetU8();
  3974. }
  3975. //System.Console.WriteLine("--------RefreshCardInfo: " + cardData[0] + ", " + cardData[1] + ", " + cardData[2] + ", " + cardData[3]);
  3976. }
  3977. }
  3978. /// <summary>
  3979. /// 玩家卡牌释放逻辑
  3980. /// </summary>
  3981. [MessageType(0x8705)]
  3982. public class PlayerLaunchCardSkill : PlayerSingleMsg
  3983. {
  3984. public int cardSkill;
  3985. public CardType type;
  3986. public byte layer;
  3987. public byte[] cardData = new byte[(int)CardType.Max]; //0-3代表有
  3988. public PlayerLaunchCardSkill() { }
  3989. override public void WriteExternal(IOutputStream output)
  3990. {
  3991. output.PutS32(this.cardSkill);
  3992. output.PutEnum8(type);
  3993. output.PutU8(this.layer);
  3994. for (int i = 0; i < (int)CardType.Max; i++)
  3995. {
  3996. output.PutU8(cardData[i]);
  3997. }
  3998. //System.Console.WriteLine("--------PlayerLaunchCardSkill: " + cardSkill + ", " + this.type);
  3999. }
  4000. override public void ReadExternal(IInputStream input)
  4001. {
  4002. //
  4003. this.cardSkill = input.GetS32();
  4004. this.type = input.GetEnum8<CardType>();
  4005. this.layer = input.GetU8();
  4006. for (int i = 0; i < (int)CardType.Max; i++)
  4007. {
  4008. cardData[i] = input.GetU8();
  4009. }
  4010. //System.Console.WriteLine("--------PlayerLaunchCardSkill: " + cardSkill + ", " + this.type);
  4011. }
  4012. }
  4013. /// <summary>
  4014. /// 刷新Boss卡牌珠相关信息
  4015. /// </summary>
  4016. [MessageType(0x8706)]
  4017. public class RefreshBossCardInfo : ObjectEvent
  4018. {
  4019. public byte[] cardData = new byte[(int)CardType.Max]; //0-3代表有
  4020. public RefreshBossCardInfo()
  4021. {
  4022. for (int i = 0; i < (int)CardType.Max; i++)
  4023. {
  4024. cardData[i] = (byte)CardType.Max;
  4025. }
  4026. }
  4027. override public void WriteExternal(IOutputStream output)
  4028. {
  4029. base.WriteExternal(output);
  4030. for (int i = 0; i < (int)CardType.Max; i++)
  4031. {
  4032. output.PutU8(cardData[i]);
  4033. }
  4034. //System.Console.WriteLine("RefreshBossCardInfo: " + this.object_id +", " + cardData[0] + ", " + cardData[1] + ", " + cardData[2] + ", " + cardData[3]);
  4035. }
  4036. override public void ReadExternal(IInputStream input)
  4037. {
  4038. base.ReadExternal(input);
  4039. for (int i = 0; i < (int)CardType.Max; i++)
  4040. {
  4041. cardData[i] = input.GetU8();
  4042. }
  4043. //System.Console.WriteLine("objectID: " + this.object_id);
  4044. //System.Console.WriteLine("--------RefreshBossCardInfo: " + this.object_id + ", " + cardData[0] + ", " + cardData[1] + ", " + cardData[2] + ", " + cardData[3]);
  4045. }
  4046. }
  4047. /// <summary>
  4048. /// 玩家卡牌释放逻辑
  4049. /// </summary>
  4050. [MessageType(0x8707)]
  4051. public class BossTriggerCardSkill : ObjectEvent
  4052. {
  4053. public int cardSkill;
  4054. public CardType type;
  4055. public byte layer;
  4056. public byte[] cardData = new byte[(int)CardType.Max]; //0-3代表有
  4057. public BossTriggerCardSkill() { }
  4058. override public void WriteExternal(IOutputStream output)
  4059. {
  4060. base.WriteExternal(output);
  4061. output.PutS32(this.cardSkill);
  4062. output.PutEnum8(type);
  4063. output.PutU8(this.layer);
  4064. for (int i = 0; i < (int)CardType.Max; i++)
  4065. {
  4066. output.PutU8(cardData[i]);
  4067. }
  4068. //System.Console.WriteLine("BossTriggerCardSkill: " + this.object_id + ", " + cardData[0] + ", " + cardData[1] + ", " + cardData[2] + ", " + cardData[3]);
  4069. }
  4070. override public void ReadExternal(IInputStream input)
  4071. {
  4072. base.ReadExternal(input);
  4073. this.cardSkill = input.GetS32();
  4074. this.type = input.GetEnum8<CardType>();
  4075. this.layer = input.GetU8();
  4076. for (int i = 0; i < (int)CardType.Max; i++)
  4077. {
  4078. cardData[i] = input.GetU8();
  4079. }
  4080. //System.Console.WriteLine("BossTriggerCardSkill: " + this.object_id + ", " + cardData[0] + ", " + cardData[1] + ", " + cardData[2] + ", " + cardData[3]);
  4081. }
  4082. }
  4083. }