123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494 |
- using System;
- using System.IO;
- using System.Collections.Generic;
- using System.Text;
- using CommonAI.RTS;
- using CommonLang.Vector;
- using CommonLang.IO;
- using CommonLang.ByteOrder;
- using CommonLang.IO.Attribute;
- using CommonLang;
- using CommonLang.Protocol;
- using CommonAI.Zone.Helper;
- using CommonAI.ZoneClient;
- using CommonAI.Zone.Instance;
- using CommonLang.Log;
- using CommonAI.ZoneServer.JSGModule;
- using CommonAI.Data;
- namespace CommonAI.Zone
- {
- #region ABSTRACT
- /// <summary>
- /// 向服务器端发送的指令
- /// </summary>
- abstract public class Action : IMessage, BattleMessage
- {
- //private static int Inxexer = 0;
- public GameEntity sender;
- public int MessageID { get; set; }
- public Action() { }
- abstract public void WriteExternal(IOutputStream output);
- abstract public void ReadExternal(IInputStream input);
- virtual public void BeforeWrite(TemplateManager templates) { }
- virtual public void EndRead(TemplateManager templates) { }
- }
- /// <summary>
- /// 客户端接收到的消息
- /// </summary>
- abstract public class Event : IMessage, BattleMessage
- {
- public GameEntity sender;
- public int MessageID { get; set; }
- abstract public void WriteExternal(IOutputStream output);
- abstract public void ReadExternal(IInputStream input);
- virtual public void BeforeWrite(TemplateManager templates) { }
- virtual public void EndRead(TemplateManager templates) { }
- }
- public interface BattleMessage
- {
- void BeforeWrite(TemplateManager templates);
- void EndRead(TemplateManager templates);
- }
- /// <summary>
- /// 某个位置上的事件
- /// </summary>
- public interface PositionMessage
- {
- float X { get; }
- float Y { get; }
- }
- /// <summary>
- /// 主角的事件
- /// </summary>
- public interface ActorMessage
- {
- uint ObjectID { get; }
- }
- /** 单人事件 */
- public abstract class PlayerSingleMsg : ObjectEvent
- {
- }
- /// <summary>
- /// 系统消息
- /// </summary>
- public interface SystemMessage
- {
- }
- //--------------------------------------------------------------------------
- /// <summary>
- /// 向服务器端某个单位发送的指令
- /// </summary>
- abstract public class ObjectAction : Action
- {
- /// <summary>
- /// 不需要传输object_id, 使用sender对象来绑定Session和InstanceUnit的关联//
- /// </summary>
- public uint object_id;
- protected ObjectAction() { }
- protected ObjectAction(uint obj_id)
- {
- this.object_id = obj_id;
- }
- override public void WriteExternal(IOutputStream output)
- {
- // 不需要传输object_id, 使用sender对象来绑定Session和InstanceUnit//
- }
- override public void ReadExternal(IInputStream input)
- {
- // 不需要传输object_id, 使用sender对象来绑定Session和InstanceUnit//
- }
- }
- /// <summary>
- /// 某个单位的事件消息
- /// </summary>
- abstract public class ObjectEvent : Event
- {
- public uint object_id;
- public uint ObjectID { get { return object_id; } }
- protected ObjectEvent() { }
- protected ObjectEvent(uint obj_id)
- {
- this.object_id = obj_id;
- }
- override public void WriteExternal(IOutputStream output)
- {
- output.PutVU32(object_id);
- }
- override public void ReadExternal(IInputStream input)
- {
- this.object_id = input.GetVU32();
- }
- }
- //--------------------------------------------------------------------------
- /// <summary>
- /// 向服务器端某个单位发送的请求
- /// </summary>
- abstract public class ActorRequest : ObjectAction
- {
- protected ActorRequest() { }
- protected ActorRequest(uint obj_id)
- : base(obj_id)
- {
- }
- }
- /// <summary>
- /// 向服务器端某个单位发送请求对应的回馈
- /// </summary>
- abstract public class ActorResponse : ObjectEvent, ActorMessage
- {
- protected ActorResponse() { }
- protected ActorResponse(uint obj_id)
- : base(obj_id)
- {
- }
- }
- #endregion
- //--------------------------------------------------------------------------
- #region ZONE_EVENTS_0x8000
- public abstract class ZoneEvent : Event
- {
- }
- /// <summary>
- /// 添加单位事件
- /// </summary>
- [MessageType(0x8001)]
- public class AddUnitEvent : ZoneEvent
- {
- public SyncUnitInfo Sync;
- public string ErrorMessage;
- public byte flag; //标记:0:正常生成,1:归属某个服务器
- public uint unit_id
- {
- get
- {
- if (Sync != null)
- {
- return Sync.ObjectID;
- }
- return 0;
- }
- }
- public AddUnitEvent() { }
- public AddUnitEvent(SyncUnitInfo sync)
- {
- this.Sync = sync;
- }
- override public void WriteExternal(IOutputStream output)
- {
- output.PutExt(Sync);
- output.PutUTF(ErrorMessage);
- output.PutU8(flag);
- }
- override public void ReadExternal(IInputStream input)
- {
- this.Sync = input.GetExt<SyncUnitInfo>();
- this.ErrorMessage = input.GetUTF();
- this.flag = input.GetU8();
- }
- }
- /// <summary>
- /// 添加法术/飞行道具效果事件
- /// </summary>
- [MessageType(0x8002)]
- public class AddSpellEvent : ZoneEvent
- {
- private BitSet8 mask = new BitSet8();
- public bool IsLauncherSender
- {
- get { return mask.Get(0); }
- private set { mask.Set(0, value); }
- }
- public bool IsTargetPos
- {
- get { return mask.Get(1); }
- private set { mask.Set(1, value); }
- }
- public bool IsTargetObject
- {
- get { return mask.Get(2); }
- private set { mask.Set(2, value); }
- }
- public bool IsHeight
- {
- get { return mask.Get(3); }
- private set { mask.Set(3, value); }
- }
- public bool IsSyncPos
- {
- get { return mask.Get(4); }
- private set { mask.Set(4, value); }
- }
- public bool IsHalf
- {
- get { return mask.Get(7); }
- private set { mask.Set(7, value); }
- }
- public int spell_template_id
- {
- get { return (launch_data != null) ? launch_data.SpellID : 0; }
- }
- public LaunchSpell LaunchData
- {
- get { return launch_data; }
- }
- private LaunchSpell launch_data;
- private uint launch_data_sn = 0;
- public uint spell_id;
- public uint launcher_unit_id;
- public uint sender_unit_id;
- public uint target_obj_id;
- public Vector2 target_pos;
- public float x;
- public float y;
- public float direction;
- public float height;
- public int SpellID;
- public AddSpellEvent() { }
- public AddSpellEvent(InstanceSpell spell)
- {
- this.launch_data = spell.LaunchData;
- this.spell_id = spell.ID;
- this.sender_unit_id = spell.SenderID;
- this.launcher_unit_id = spell.LauncherID;
- this.target_obj_id = spell.TargetID;
- this.target_pos = spell.TargetPos;
- this.x = spell.X;
- this.y = spell.Y;
- this.direction = spell.Direction;
- this.height = spell.Z;
- //mask//
- this.IsLauncherSender = (launcher_unit_id == sender_unit_id);
- this.IsTargetPos = (spell.Info.MType == SpellTemplate.MotionType.Cannon || spell.Info.MType == SpellTemplate.MotionType.CurveMissile) && (target_pos != null);
- this.IsTargetObject = (target_obj_id != 0);
- this.IsHeight = (height != 0);
- this.IsHalf = spell.Parent.IsHalfSync;
- this.IsSyncPos = spell.Info.IsLaunchSpellEventSyncPos;
- this.SpellID = this.launch_data.SpellID;
- }
- public override void BeforeWrite(TemplateManager templates)
- {
- base.BeforeWrite(templates);
- if (launch_data != null)
- {
- this.launch_data_sn = this.LaunchData.IsCodeCreate() ? uint.MaxValue: launch_data.SerialNumber;
- }
- }
- public override void EndRead(TemplateManager templates)
- {
- base.EndRead(templates);
- if(this.launch_data_sn == uint.MaxValue)
- {
- this.launch_data = JSGGlobalData.GetUnConfigSpellByID((int)this.SpellID);
- //System.Console.WriteLine("123123123: " + this.launch_data.SpellID + ", " + this.launch_data.FromUnitBody);
- }
- else
- {
- this.launch_data = templates.GetSnData<LaunchSpell>(launch_data_sn);
- }
- }
- override public void WriteExternal(IOutputStream output)
- {
- output.PutU8(mask.Mask);
- output.PutVU32(spell_id);
- output.PutVU32(launch_data_sn);
- if (this.IsLauncherSender)
- {
- output.PutVU32(launcher_unit_id);
- }
- else
- {
- output.PutVU32(sender_unit_id);
- output.PutVU32(launcher_unit_id);
- }
- if (this.IsTargetObject)
- {
- output.PutVU32(target_obj_id);
- }
- if (this.IsTargetPos)
- {
- MoveHelper.WritePos(IsHalf, target_pos.X, target_pos.Y, output);
- }
- if (this.IsSyncPos)
- {
- MoveHelper.WritePosAndDirection(IsHalf, x, y, direction, output);
- }
- if (this.IsHeight)
- {
- MoveHelper.WritePos(IsHalf, height, output);
- }
- if (this.LaunchData.IsCodeCreate())
- {
- output.PutS32(this.SpellID);
- }
- //System.Console.WriteLine("AddSpell: " + this.launch_data.SpellID + ", ID: " + spell_id + ", XY:" + this.x + ", " + this.y + ", d:" + this.direction);
- }
- override public void ReadExternal(IInputStream input)
- {
- this.mask.Mask = input.GetU8();
- this.spell_id = input.GetVU32();
- this.launch_data_sn = input.GetVU32();
- if (this.IsLauncherSender)
- {
- this.launcher_unit_id = this.sender_unit_id = input.GetVU32();
- }
- else
- {
- this.sender_unit_id = input.GetVU32();
- this.launcher_unit_id = input.GetVU32();
- }
- if (this.IsTargetObject)
- {
- this.target_obj_id = input.GetVU32();
- }
- if (this.IsTargetPos)
- {
- this.target_pos = new Vector2();
- MoveHelper.ReadPos(IsHalf, ref target_pos, input);
- }
- if (this.IsSyncPos)
- {
- MoveHelper.ReadPosAndDirection(IsHalf, out x, out y, out direction, input);
- }
- if (this.IsHeight)
- {
- MoveHelper.ReadPos(IsHalf, out height, input);
- }
- if(this.launch_data_sn == uint.MaxValue)
- {
- this.SpellID = input.GetS32();
- }
- }
- }
- /// <summary>
- /// 单位动作中击中别的单位
- /// </summary>
- [MessageType(0x8003)]
- public class AddEffectEvent : ZoneEvent, PositionMessage
- {
- public uint hostId = 0;
- public float x;
- public float y;
- public float direction;
- private uint effect_sn = 0;
- public LaunchEffect effect { get; set; }
- public AddEffectEvent() { }
- public AddEffectEvent(uint hostId , float x, float y, float dir, LaunchEffect effect)
- {
- this.hostId = hostId;
- this.x = x;
- this.y = y;
- this.direction = dir;
- this.effect = effect;
- }
- override public void WriteExternal(IOutputStream output)
- {
- output.PutVU32(hostId);
- output.PutF32(x);
- output.PutF32(y);
- output.PutF32(direction);
- output.PutVU32(effect_sn);
- }
- override public void ReadExternal(IInputStream input)
- {
- this.hostId = input.GetVU32();
- this.x = input.GetF32();
- this.y = input.GetF32();
- this.direction = input.GetF32();
- this.effect_sn = input.GetVU32();
- }
- public override void BeforeWrite(TemplateManager templates)
- {
- if (effect != null)
- {
- this.effect_sn = effect.SerialNumber;
- }
- }
- public override void EndRead(TemplateManager templates)
- {
- this.effect = templates.GetSnData<LaunchEffect>(effect_sn);
- }
- public float X { get { return x; } }
- public float Y { get { return y; } }
- }
- /// <summary>
- /// 添加道具事件
- /// </summary>
- [MessageType(0x8004)]
- public class AddItemEvent : ZoneEvent
- {
- public SyncItemInfo Sync;
- public string ErrorMessage;
- public uint unit_id
- {
- get { if (Sync != null) { return Sync.ObjectID; } return 0; }
- }
- public AddItemEvent() { }
- public AddItemEvent(SyncItemInfo sync)
- {
- this.Sync = sync;
- }
- override public void WriteExternal(IOutputStream output)
- {
- output.PutExt(Sync);
- output.PutUTF(ErrorMessage);
- }
- override public void ReadExternal(IInputStream input)
- {
- this.Sync = input.GetExt<SyncItemInfo>();
- this.ErrorMessage = input.GetUTF();
- }
- }
- /// <summary>
- /// 某个对象从场景中移除
- /// </summary>
- [MessageType(0x8005)]
- public class RemoveObjectEvent : ZoneEvent
- {
- public uint object_id;
- public RemoveObjectEvent() { }
- public RemoveObjectEvent(uint oid)
- {
- this.object_id = oid;
- }
- override public void WriteExternal(IOutputStream output)
- {
- //Console.WriteLine(" - RemoveObjectEvent - " + this.object_id);
- output.PutVU32(object_id);
- }
- override public void ReadExternal(IInputStream input)
- {
- this.object_id = input.GetVU32();
- }
- }
- /// <summary>
- /// 同步场景中移动单位的坐标
- /// </summary>
- [MessageType(0x8006)]
- public class SyncPosEvent : ZoneEvent
- {
- public struct UnitPos : IVector2
- {
- private uint m_ID;
- private float m_X;
- private float m_Y;
- private float m_Z;
- private float m_Direction;
- public uint ID { get { return m_ID; } }
- public float Direction { get { return m_Direction; } set { m_Direction = value; } }
- public float X { get { return m_X; } set { m_X = value; } }
- public float Y { get { return m_Y; } set { m_Y = value; } }
- public float Z { get { return m_Z; } set { m_Z = value; } }
- public void SetObject(InstanceZoneObject obj)
- {
- this.m_ID = obj.ID;
- this.m_X = obj.X;
- this.m_Y = obj.Y;
- this.m_Z = obj.Z;
- this.m_Direction = obj.Direction;
- }
- internal void Write(IOutputStream output, bool half, bool sync_z)
- {
- output.PutVU32(m_ID);
- if (half)
- {
- output.PutU16(MoveHelper.ToPos16(m_X));
- output.PutU16(MoveHelper.ToPos16(m_Y));
- if (sync_z) output.PutU16(MoveHelper.ToPos16(m_Z));
- }
- else
- {
- output.PutF32(m_X);
- output.PutF32(m_Y);
- if (sync_z) output.PutF32(m_Z);
- }
-
- output.PutU8(MoveHelper.ToDirectionD8(m_Direction));
- //if (m_ID == 2649)
- //{
- // Console.WriteLine("SyncPos, " + TimeUtil.GetTimestampMS() + ", X: " + this.m_X + ",Y: " + this.m_Y);
- //}
- }
- internal void Read(IInputStream input, bool half, bool sync_z)
- {
- m_ID = input.GetVU32();
- if (half)
- {
- m_X = MoveHelper.ToPosF32(input.GetU16());
- m_Y = MoveHelper.ToPosF32(input.GetU16());
- if (sync_z) m_Z = MoveHelper.ToPosF32(input.GetU16());
- }
- else
- {
- m_X = input.GetF32();
- m_Y = input.GetF32();
- if (sync_z) m_Z = input.GetF32();
- }
- m_Direction = MoveHelper.ToDirectionF32(input.GetU8());
- }
- public void SetX(float value)
- {
- //throw new NotImplementedException();
- }
- public void SetY(float value)
- {
- //throw new NotImplementedException();
- }
- public void AddX(float value)
- {
- //throw new NotImplementedException();
- }
- public void AddY(float value)
- {
- //throw new NotImplementedException();
- }
- }
- public struct UnitState
- {
- private uint m_ID;
- private byte m_UnitMainState;
- private byte m_UnitSubState;
- public uint ID { get { return m_ID; } }
- public UnitActionStatus UnitMainState
- {
- get { return (UnitActionStatus)m_UnitMainState; }
- set { m_UnitMainState = (byte)value; }
- }
- public byte UnitSubState
- {
- get { return m_UnitSubState; }
- set { m_UnitSubState = value; }
- }
- public void SetObject(InstanceUnit obj)
- {
- this.m_ID = obj.ID;
- this.m_UnitMainState = (byte)obj.CurrentActionStatus;
- this.m_UnitSubState = (byte)obj.CurrentActionSubstate;
- }
- internal void Write(IOutputStream output)
- {
- output.PutVU32(m_ID);
- output.PutU8(m_UnitMainState);
- output.PutU8(m_UnitSubState);
- //if (m_ID == 2649)
- //{
- // Console.WriteLine("SyncPos - " + this.ID + ", m_UnitMainState = " + m_UnitMainState + ", m_UnitSubState = " + m_UnitSubState);
- //}
- }
- internal void Read(IInputStream input)
- {
- m_ID = input.GetVU32();
- m_UnitMainState = input.GetU8();
- m_UnitSubState = input.GetU8();
- }
- }
- private BitSet8 mask = new BitSet8();
- private long pass_time_ms;
- public UnitPos[] units_pos;
- public UnitState[] units_st;
- public bool IsHalf
- {
- get { return mask.Get(0); }
- private set { mask.Set(0, value); }
- }
- public bool IsSyncZ
- {
- get { return mask.Get(1); }
- private set { mask.Set(1, value); }
- }
- public long PassTimeMS { get { return pass_time_ms; } }
- public bool IsEmpty { get { return (units_pos == null || units_pos.Length == 0) && (units_st == null || units_st.Length == 0); } }
- public SyncPosEvent() { }
- public SyncPosEvent(bool half, bool sync_z, long passtime)
- {
- this.IsHalf = half;
- this.IsSyncZ = sync_z;
- this.pass_time_ms = passtime;
- }
- override public void WriteExternal(IOutputStream output)
- {
- output.PutU8(mask.Mask);
- output.PutVS64(pass_time_ms);
- bool syncz = IsSyncZ;
- bool half = IsHalf;
- if (units_pos != null)
- {
- output.PutVS32(units_pos.Length);
- for (int i = 0; i < units_pos.Length; i++)
- {
- units_pos[i].Write(output, half, syncz);
- }
- }
- else
- {
- output.PutVS32(0);
- }
- if (units_st != null)
- {
- output.PutVS32(units_st.Length);
- for (int i = 0; i < units_st.Length; i++)
- {
- units_st[i].Write(output);
- }
- }
- else
- {
- output.PutVS32(0);
- }
- }
- override public void ReadExternal(IInputStream input)
- {
- this.mask.Mask = input.GetU8();
- this.pass_time_ms = input.GetVS64();
- bool syncz = IsSyncZ;
- bool half = IsHalf;
- this.units_pos = new UnitPos[input.GetVS32()];
- for (int i = 0; i < units_pos.Length; i++)
- {
- units_pos[i].Read(input, half, syncz);
- }
- this.units_st = new UnitState[input.GetVS32()];
- for (int i = 0; i < units_st.Length; i++)
- {
- //UnityEngine.Debug.Log("m_ID = "+units_st[i].ID + " UnitMainState = " +units_st[i].UnitMainState);
- units_st[i].Read(input);
- }
- }
- }
- /// <summary>
- /// 服务端通知客户端执行一段脚本
- /// </summary>
- [MessageType(0x8007)]
- public class DoScriptEvent : ZoneEvent
- {
- public string ScriptFileName;
- public DoScriptEvent() { }
- public DoScriptEvent(string filename)
- {
- this.ScriptFileName = filename;
- }
- override public void WriteExternal(IOutputStream output)
- {
- output.PutUTF(ScriptFileName);
- }
- override public void ReadExternal(IInputStream input)
- {
- this.ScriptFileName = input.GetUTF();
- }
- }
- /// <summary>
- /// 脚本系统指令
- /// </summary>
- [MessageType(0x8008)]
- public class ScriptCommandEvent : ZoneEvent
- {
- public string message;
- public ScriptCommandEvent() { }
- public ScriptCommandEvent(string msg)
- {
- this.message = msg;
- }
- override public void WriteExternal(IOutputStream output)
- {
- output.PutUTF(message);
- }
- override public void ReadExternal(IInputStream input)
- {
- this.message = input.GetUTF();
- }
- }
- /// <summary>
- /// 游戏结束指令
- /// </summary>
- [MessageType(0x8009)]
- public class GameOverEvent : ZoneEvent
- {
- public string message;
- public int WinForce;
- public GameOverEvent() { }
- public GameOverEvent(int force, string msg)
- {
- this.WinForce = force;
- this.message = msg;
- }
- override public void WriteExternal(IOutputStream output)
- {
- output.PutUTF(message);
- output.PutS32(WinForce);
- }
- override public void ReadExternal(IInputStream input)
- {
- this.message = input.GetUTF();
- this.WinForce = input.GetS32();
- }
- }
- [MessageType(0x800A)]
- public class DecorationChangedEvent : ZoneEvent
- {
- public string Name;
- public bool Enable;
- public DecorationChangedEvent() { }
- public DecorationChangedEvent(string name, bool enable)
- {
- this.Name = name;
- this.Enable = enable;
- }
- override public void WriteExternal(IOutputStream output)
- {
- output.PutUTF(Name);
- output.PutBool(Enable);
- }
- override public void ReadExternal(IInputStream input)
- {
- this.Name = input.GetUTF();
- this.Enable = input.GetBool();
- }
- }
- [MessageType(0x800B)]
- public class SyncEnvironmentVarEvent : ZoneEvent
- {
- public string Key;
- public object Value;
- public SyncEnvironmentVarEvent() { }
- public SyncEnvironmentVarEvent(string key, object value)
- {
- this.Key = key;
- this.Value = value;
- }
- override public void WriteExternal(IOutputStream output)
- {
- output.PutUTF(Key);
- output.PutData(Value);
- }
- override public void ReadExternal(IInputStream input)
- {
- DataType dtype;
- this.Key = input.GetUTF();
- this.Value = input.GetData(out dtype);
- }
- }
- [MessageType(0x800C)]
- public class ChangeBGMEvent : ZoneEvent
- {
- public string FileName;
- public ChangeBGMEvent() { }
- public ChangeBGMEvent(string file)
- {
- this.FileName = file;
- }
- override public void WriteExternal(IOutputStream output)
- {
- output.PutUTF(FileName);
- }
- override public void ReadExternal(IInputStream input)
- {
- this.FileName = input.GetUTF();
- }
- }
- [MessageType(0x800D)]
- public class FlagTagChangedEvent : ZoneEvent
- {
- public string Name;
- public string Tag;
- public FlagTagChangedEvent() { }
- public FlagTagChangedEvent(string name, string tag = null)
- {
- this.Name = name;
- this.Tag = tag;
- }
- override public void WriteExternal(IOutputStream output)
- {
- output.PutUTF(Name);
- output.PutUTF(Tag);
- }
- override public void ReadExternal(IInputStream input)
- {
- this.Name = input.GetUTF();
- this.Tag = input.GetUTF();
- }
- }
- #endregion
- //--------------------------------------------------------------------------
- #region OBJECT_EVENTS_0x8100
- /// <summary>
- /// 同步单位数据,频繁需要改变的数据
- /// </summary>
- [MessageType(0x8100)]
- public class UnitFieldChangedEvent : ObjectEvent
- {
- public const uint MASK_ALL = 0xFFFF;
- public const uint MASK_HP = 1;
- public const uint MASK_MP = 1 << 1;
- public const uint MASK_MAX_HP = 1 << 2;
- public const uint MASK_MAX_MP = 1 << 3;
- public const uint MASK_SPEED = 1 << 4;
- public const uint MASK_SP = 1 << 5;
- public const uint MASK_MAX_SP = 1 << 6;
- public const uint MASK_FCR = 1 << 7;
- public const uint MASK_MONEY = 1 << 8;
- public const uint MASK_LEVEL = 1 << 9;
- public const uint MASK_DUMMY_0 = 1 << 10;
- public const uint MASK_DUMMY_1 = 1 << 11;
- public const uint MASK_DUMMY_2 = 1 << 12;
- public const uint MASK_DUMMY_3 = 1 << 13;
- public const uint MASK_DUMMY_4 = 1 << 14;
- public const uint MASK_DUMMY_5 = 1 << 15;
- //-- NEW Property
- public const uint MASK_SKILL_CD_ACC = 1 << 16;
- public const uint MASK_CONTROLED_ACC = 1 << 17;
-
- public uint mask = 0;
- public int currentHP;
- public int currentMP;
- public int maxHP;
- public int maxMP;
- public int currentSP;
- public int maxSP;
- public float currentSpeed;
- public float currentFCR;
- public int currentMoney;
- public int level;
- public int dummy_0;
- public int dummy_1;
- public int dummy_2;
- public int dummy_3;
- public int dummy_4;
- public int dummy_5;
- //-- NEW Property
- public int skill_cd_acc;
- public int controled_acc;
- public UnitFieldChangedEvent() { }
- public UnitFieldChangedEvent(uint unit_id, ushort mask)
- : base(unit_id)
- {
- this.mask = mask;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutVU32(mask);
- if ((mask & MASK_HP) != 0) output.PutS32(currentHP);
- if ((mask & MASK_MP) != 0) output.PutS32(currentMP);
- if ((mask & MASK_MAX_HP) != 0) output.PutS32(maxHP);
- if ((mask & MASK_MAX_MP) != 0) output.PutS32(maxMP);
- if ((mask & MASK_SP) != 0) output.PutS32(currentSP);
- if ((mask & MASK_MAX_SP) != 0) output.PutS32(maxSP);
- if ((mask & MASK_SPEED) != 0) output.PutF32(currentSpeed);
- if ((mask & MASK_FCR) != 0) output.PutF32(currentFCR);
- if ((mask & MASK_MONEY) != 0) output.PutS32(currentMoney);
- if ((mask & MASK_LEVEL) != 0) output.PutS32(level);
- if ((mask & MASK_DUMMY_0) != 0) output.PutS32(dummy_0);
- if ((mask & MASK_DUMMY_1) != 0) output.PutS32(dummy_1);
- if ((mask & MASK_DUMMY_2) != 0) output.PutS32(dummy_2);
- if ((mask & MASK_DUMMY_3) != 0) output.PutS32(dummy_3);
- if ((mask & MASK_DUMMY_4) != 0) output.PutS32(dummy_4);
- if ((mask & MASK_DUMMY_5) != 0) output.PutS32(dummy_5);
- //-- NEW Property
- if ((mask & MASK_SKILL_CD_ACC) != 0) output.PutS32(skill_cd_acc);
- if ((mask & MASK_CONTROLED_ACC) != 0) output.PutS32(controled_acc);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.mask = input.GetVU32();
- if ((mask & MASK_HP) != 0) this.currentHP = input.GetS32();
- if ((mask & MASK_MP) != 0) this.currentMP = input.GetS32();
- if ((mask & MASK_MAX_HP) != 0) this.maxHP = input.GetS32();
- if ((mask & MASK_MAX_MP) != 0) this.maxMP = input.GetS32();
- if ((mask & MASK_SP) != 0) this.currentSP = input.GetS32();
- if ((mask & MASK_MAX_SP) != 0) this.maxSP = input.GetS32();
- if ((mask & MASK_SPEED) != 0) this.currentSpeed = input.GetF32();
- if ((mask & MASK_FCR) != 0) this.currentFCR = input.GetF32();
- if ((mask & MASK_MONEY) != 0) this.currentMoney = input.GetS32();
- if ((mask & MASK_LEVEL) != 0) this.level = input.GetS32();
- if ((mask & MASK_DUMMY_0) != 0) this.dummy_0 = input.GetS32();
- if ((mask & MASK_DUMMY_1) != 0) this.dummy_1 = input.GetS32();
- if ((mask & MASK_DUMMY_2) != 0) this.dummy_2 = input.GetS32();
- if ((mask & MASK_DUMMY_3) != 0) this.dummy_3 = input.GetS32();
- if ((mask & MASK_DUMMY_4) != 0) this.dummy_4 = input.GetS32();
- if ((mask & MASK_DUMMY_5) != 0) this.dummy_5 = input.GetS32();
- //-- NEW Property
- if ((mask & MASK_SKILL_CD_ACC) != 0) this.skill_cd_acc = input.GetS32();
- if ((mask & MASK_CONTROLED_ACC) != 0) this.controled_acc = input.GetS32();
- }
- }
- /// <summary>
- /// 单位进入吟唱状态
- /// </summary>
- [MessageType(0x810a)]
- public class UnitChantSkillEvent : ObjectEvent
- {
- public int skill_id;
- public int chant_ms;
- public UnitChantSkillEvent() { }
- public UnitChantSkillEvent(uint unit_id, SkillTemplate sk)
- : base(unit_id)
- {
- this.skill_id = sk.TemplateID;
- this.chant_ms = sk.ChantTimeMS;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutS32(skill_id);
- output.PutVS32(chant_ms);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.skill_id = input.GetS32();
- this.chant_ms = input.GetVS32();
- }
- }
- /// <summary>
- /// 单位进入技能状态
- /// </summary>
- [MessageType(0x810b)]
- public class UnitLaunchSkillEvent : ObjectEvent
- {
- public int skill_id { get; private set; }
- /// <summary>
- /// 如果是单一动作,则标识是哪一段攻击
- /// </summary>
- public byte action_index { get; private set; }
- /// <summary>
- /// 技能每段动作的时间,单一动作的话(SkillTemplate.IsSingleAction),长度为1
- /// </summary>
- public int[] action_time_array { get; private set; }
- public int TotalCDTimeMS { get; private set; }
- public float action_speed { get; private set; }
- public Vector2 spell_target_pos { get; private set; }
- public uint target_object_id { get; private set; }
- //节点动作加速(加法)
- public float [] action_speed_add { get; private set; }
- private BitSet8 bitMask = new BitSet8();
- public bool IsSingleAction
- {
- get { return bitMask.Get(0); }
- private set { bitMask.Set(0, value); }
- }
- public bool ActionSpeedAddition
- {
- get { return bitMask.Get(1); }
- private set { bitMask.Set(1, value); }
- }
- public bool IsActionSpeedUP
- {
- get { return bitMask.Get(2); }
- private set { bitMask.Set(2, value); }
- }
- public bool IsActionTimeChanged
- {
- get { return bitMask.Get(3); }
- private set { bitMask.Set(3, value); }
- }
- public bool IsAutoFocusNearTarget
- {
- get { return bitMask.Get(4); }
- private set { bitMask.Set(4, value); }
- }
- public bool IsSpellTargetPos
- {
- get { return bitMask.Get(5); }
- private set { bitMask.Set(5, value); }
- }
- public bool IsTargetObject
- {
- get { return bitMask.Get(6); }
- private set { bitMask.Set(6, value); }
- }
- public bool IsChangeTotalCDTime
- {
- get { return bitMask.Get(7); }
- private set { bitMask.Set(7, value); }
- }
-
- public int TotalActionTimeMS
- {
- get
- {
- int total = 0;
- if (action_time_array != null)
- {
- foreach (int timeMS in action_time_array)
- {
- total += timeMS;
- }
- }
- return total;
- }
- }
- public UnitLaunchSkillEvent() { }
- public UnitLaunchSkillEvent(
- uint unit_id,
- SkillTemplate sk,
- byte actionIndex,
- float actionSpeed,
- int totalCDTimeMS,
- bool isAutoFaceToTarget,
- Vector2 spellTargetPos,
- uint targetObjectID,
- int lockActionStep)
- : base(unit_id)
- {
- this.skill_id = sk.TemplateID;
- this.action_speed = actionSpeed;
- this.TotalCDTimeMS = totalCDTimeMS;
- this.spell_target_pos = spellTargetPos;
- this.target_object_id = targetObjectID;
- this.IsAutoFocusNearTarget = isAutoFaceToTarget;
- this.IsSingleAction = sk.IsSingleAction;
- this.IsActionSpeedUP = (actionSpeed != 1f);
- this.IsTargetObject = (targetObjectID != 0);
- this.IsSpellTargetPos = spellTargetPos != null;
- this.IsChangeTotalCDTime = totalCDTimeMS != sk.CoolDownMS;
-
- this.action_speed_add = new float[sk.ActionQueue.Count];
- for(int i = 0; i < sk.ActionQueue.Count; i++)
- {
- if(sk.ActionQueue[i].ActionSpeedRate != 0.0f)
- {
- this.action_speed_add[i] = sk.ActionQueue[i].ActionSpeedRate;
- this.ActionSpeedAddition = true;
- }
- }
- if (sk.IsSingleAction || lockActionStep >= 0)
- {
- this.action_index = actionIndex;
- this.action_time_array = new int[] { sk.ActionQueue[actionIndex].TotalTimeMS };
- }
- else
- {
- this.action_index = 0;
- this.action_time_array = sk.ActionQueueTimeArray;
- }
- }
- public override void BeforeWrite(TemplateManager templates)
- {
- base.BeforeWrite(templates);
- var orgin_temp = templates.getSkill(skill_id);
- if (this.action_time_array == null)
- {
- this.IsActionTimeChanged = false;
- }
- else if (this.IsSingleAction)
- {
- this.IsActionTimeChanged = (this.action_time_array[0] != orgin_temp.ActionQueue[action_index].TotalTimeMS);
- }
- else
- {
- this.IsActionTimeChanged = !CUtils.ArraysEqual<int>(this.action_time_array, orgin_temp.ActionQueueTimeArray);
- }
- }
- public override void EndRead(TemplateManager templates)
- {
- base.EndRead(templates);
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutS32(skill_id);
- output.PutU8(bitMask.Mask);
- if (IsSingleAction)
- {
- output.PutU8(action_index);
- if (IsActionTimeChanged) output.PutS32(action_time_array[0]);
- }
- else
- {
- if (IsActionTimeChanged) output.PutArray<int>(action_time_array, output.PutS32);
- }
- if (IsActionSpeedUP)
- {
- output.PutF32(action_speed);
- }
- if (IsChangeTotalCDTime)
- {
- output.PutVS32(TotalCDTimeMS);
- }
- if (IsTargetObject)
- {
- output.PutU32(this.target_object_id);
- }
- if (IsSpellTargetPos)
- {
- output.PutF32(spell_target_pos.X);
- output.PutF32(spell_target_pos.Y);
- }
- if(ActionSpeedAddition)
- {
- output.PutArray<float>(this.action_speed_add, output.PutF32);
- }
- //System.Console.WriteLine("释放技能:" + this.skill_id + ", " + this.action_index);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.skill_id = input.GetS32();
- this.bitMask.Mask = input.GetU8();
- if (IsSingleAction)
- {
- this.action_index = input.GetU8();
- if (IsActionTimeChanged) this.action_time_array = new int[] { input.GetS32() };
- }
- else
- {
- if (IsActionTimeChanged) this.action_time_array = input.GetArray<int>(input.GetS32);
- }
- if (IsActionSpeedUP)
- {
- this.action_speed = input.GetF32();
- }
- else
- {
- this.action_speed = 1f;
- }
- if (IsChangeTotalCDTime)
- {
- this.TotalCDTimeMS = input.GetVS32();
- }
- if (IsTargetObject)
- {
- this.target_object_id = input.GetU32();
- }
- if (IsSpellTargetPos)
- {
- spell_target_pos = new Vector2();
- spell_target_pos.SetX(input.GetF32());
- spell_target_pos.SetY(input.GetF32());
- }
- if (ActionSpeedAddition)
- {
- this.action_speed_add = input.GetArray<float>(input.GetF32);
- }
- }
- public override string ToString()
- {
- return string.Format("LaunchSkill: {0}@{1}", skill_id, action_index);
- }
- }
- /// <summary>
- /// 单位动作中击中别的单位
- /// </summary>
- [MessageType(0x810d)]
- public class UnitEffectEvent : ObjectEvent
- {
- private uint effect_sn = 0;
- /// <summary>
- /// 特效名字
- /// </summary>
- public LaunchEffect effect { get; set; }
- public UnitEffectEvent() { }
- public UnitEffectEvent(uint unit_id, LaunchEffect effect)
- : base(unit_id)
- {
- this.effect = effect;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutVU32(effect_sn);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.effect_sn = input.GetVU32();
- }
- public override void BeforeWrite(TemplateManager templates)
- {
- if (effect != null)
- {
- this.effect_sn = effect.SerialNumber;
- }
- }
- public override void EndRead(TemplateManager templates)
- {
- this.effect = templates.GetSnData<LaunchEffect>(effect_sn);
- }
- }
- /// <summary>
- /// 单位仅做一个动作
- /// </summary>
- [MessageType(0x810e)]
- public class UnitDoActionEvent : ObjectEvent
- {
- public string ActionName;
- public UnitDoActionEvent() { }
- public UnitDoActionEvent(uint unit_id, string actionName)
- : base(unit_id)
- {
- this.ActionName = actionName;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutUTF(ActionName);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- ActionName = input.GetUTF();
- }
- }
- /// <summary>
- /// 单位被击中
- /// </summary>
- [MessageType(0x810f)]
- public class UnitHitEvent : ObjectEvent
- {
- public bool isDead
- {
- get { return BitMask.BitGetMask(bitMask, 0); }
- set { BitMask.BitSetMask(ref bitMask, 0, value); }
- }
- //特殊来源的伤害
- public bool isSpecialHit
- {
- get { return BitMask.BitGetMask(bitMask, 1); }
- set { BitMask.BitSetMask(ref bitMask, 1, value); }
- }
- public bool isCritical
- {
- get { return BitMask.BitGetMask(bitMask, 2); }
- set { BitMask.BitSetMask(ref bitMask, 2, value); }
- }
- public bool HasEffect
- {
- get { return BitMask.BitGetMask(bitMask, 3); }
- private set { BitMask.BitSetMask(ref bitMask, 3, value); }
- }
- public bool HasSourceAttack
- {
- get { return BitMask.BitGetMask(bitMask, 6); }
- private set { BitMask.BitSetMask(ref bitMask, 6, value); }
- }
- public uint senderId;
- public int hp;
- public byte client_state;
- private byte bitMask = 0;
- private LaunchEffect biteffect;
- private uint biteffect_sn;
- private AttackProp sourceAttack;
- private uint sourceAttack_sn;
- // 伤害来源,非def才需要额外处理
- public DamageSource dmgSrc;
- //内部字段
- //针对特殊伤害的特殊处理
- public bool InViewForceSend = false;
- public uint senderMasterId; //如果sender为召唤物,这个存放主人id(用来广播判断,非网络字段)
- public uint hitMasterId; //单位的masterid
- public LaunchEffect effect
- {
- get { return biteffect; }
- set
- {
- this.biteffect = value;
- this.HasEffect = (value != null);
- }
- }
- public AttackProp SourceAttack
- {
- get { return sourceAttack; }
- set
- {
- this.sourceAttack = value;
- this.HasSourceAttack = (value != null);
- }
- }
- public UnitHitEvent() { }
- public UnitHitEvent(uint unit_id)
- : base(unit_id)
- {
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutVU32(senderId);
- output.PutVS32(hp);
- output.PutU8(client_state);
- output.PutU8(bitMask);
- if (HasEffect)
- {
- output.PutVU32(biteffect_sn);
- }
- if (HasSourceAttack)
- {
- output.PutVU32(sourceAttack_sn);
- }
- if(isSpecialHit)
- {
- output.PutEnum8(dmgSrc);
- }
- //Console.WriteLine("WWW.object_id: " + object_id + ", senderId: " + senderId + ", hp: " + this.hp + ", mask : " + this.bitMask);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.senderId = input.GetVU32();
- this.hp = input.GetVS32();
- this.client_state = input.GetU8();
- this.bitMask = input.GetU8();
- if (HasEffect)
- {
- this.biteffect_sn = input.GetVU32();
- }
- if (HasSourceAttack)
- {
- this.sourceAttack_sn = input.GetVU32();
- }
- if(isSpecialHit)
- {
- this.dmgSrc = input.GetEnum8<DamageSource>();
- }
- //System.Console.WriteLine("sdfasdf: " + isSpecialHit + ", " + this.dmgSrc);
- //UnityEngine.Debug.LogError("RRR.object_id: " + object_id + ", senderId: " + senderId + ", hp: " + this.hp + ", mask : " + this.bitMask);
- }
- public override void BeforeWrite(TemplateManager templates)
- {
- if (HasEffect)
- {
- this.biteffect_sn = biteffect.SerialNumber;
- }
- if (HasSourceAttack)
- {
- this.sourceAttack_sn = sourceAttack.SerialNumber;
- }
- }
- public override void EndRead(TemplateManager templates)
- {
- if (HasEffect)
- {
- this.biteffect = templates.GetSnData<LaunchEffect>(biteffect_sn);
- }
- if (HasSourceAttack)
- {
- this.sourceAttack = templates.GetSnData<AttackProp>(sourceAttack_sn);
- }
- }
- }
- /// <summary>
- /// 单位被击中
- /// </summary>
- [MessageType(0x8111)]
- public class UnitDeadEvent : ObjectEvent
- {
- public bool Crushed;
- public uint attacker_id;
- public int RebirthTimeMS;
- public UnitDeadEvent() { }
- public UnitDeadEvent(uint unit_id, uint attacker_id, bool crushed, int rebirthTimeMS)
- : base(unit_id)
- {
- this.Crushed = crushed;
- this.attacker_id = attacker_id;
- this.RebirthTimeMS = rebirthTimeMS;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutBool(Crushed);
- output.PutVU32(attacker_id);
- output.PutVS32(RebirthTimeMS);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.Crushed = input.GetBool();
- this.attacker_id = input.GetVU32();
- this.RebirthTimeMS = input.GetVS32();
- }
- }
- /// <summary>
- /// 单位中BUFF
- /// </summary>
- [MessageType(0x8112)]
- public class UnitLaunchBuffEvent : ObjectEvent
- {
- public bool IsEquip
- {
- get { return BitMask.BitGetMask(bitMask, 0); }
- set { BitMask.BitSetMask(ref bitMask, 0, value); }
- }
- public bool IsOverlayLevel
- {
- get { return BitMask.BitGetMask(bitMask, 1); }
- set { BitMask.BitSetMask(ref bitMask, 1, value); }
- }
- public bool IsHasExtData
- {
- get { return BitMask.BitGetMask(bitMask, 2); }
- set { BitMask.BitSetMask(ref bitMask, 2, value); }
- }
- private byte bitMask = 0;
- public int buffTemplateID;
- public int buffTimeMS;
- public byte overlayLevel;
- public uint senderID;
- public int buffExtData; //buff的扩展字段,
- public UnitLaunchBuffEvent() { }
- public UnitLaunchBuffEvent(uint unit_id, int buffID, uint senderID, int timeMS, bool equip, byte overlayLevel, int extData)
- : base(unit_id)
- {
- this.buffTemplateID = buffID;
- this.buffTimeMS = timeMS;
- this.senderID = senderID;
- this.IsEquip = equip;
- if (overlayLevel > 0)
- {
- this.IsOverlayLevel = true;
- this.overlayLevel = overlayLevel;
- }
- if(extData > 0)
- {
- this.IsHasExtData = true;
- this.buffExtData = extData;
- }
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutU8(bitMask);
- output.PutS32(buffTemplateID);
- output.PutVU32(senderID);
- if (!IsEquip)
- {
- output.PutVS32(buffTimeMS);
- }
- if (IsOverlayLevel)
- {
- output.PutU8(overlayLevel);
- }
- if (IsHasExtData)
- {
- output.PutVS32(buffExtData);
- }
- //System.Console.WriteLine("UnitLaunchBuffEvent: " + buffTemplateID + ", " + buffTimeMS);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.bitMask = input.GetU8();
- this.buffTemplateID = input.GetS32();
- this.senderID = input.GetVU32();
- if (!IsEquip)
- {
- this.buffTimeMS = input.GetVS32();
- }
- if (IsOverlayLevel)
- {
- this.overlayLevel = input.GetU8();
- }
- if (IsHasExtData)
- {
- this.buffExtData = input.GetVS32();
- }
- }
- }
- /// <summary>
- /// 单位停止BUFF
- /// </summary>
- [MessageType(0x8113)]
- public class UnitStopBuffEvent : ObjectEvent
- {
- public int buffTemplateID;
- public uint senderID;
- public UnitStopBuffEvent() { }
- public UnitStopBuffEvent(uint unit_id, int buffID, uint senderID)
- : base(unit_id)
- {
- this.buffTemplateID = buffID;
- this.senderID = senderID;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutS32(buffTemplateID);
- output.PutVU32(senderID);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.buffTemplateID = input.GetS32();
- this.senderID = input.GetVU32();
- }
- }
- /// <summary>
- /// 单位同步【库存道具】
- /// </summary>
- [MessageType(0x8114)]
- public class UnitSyncInventoryItemEvent : ObjectEvent, ActorMessage
- {
- public int ItemTemplateID;
- public int Index;
- public int Count;
- public UnitSyncInventoryItemEvent() { }
- public UnitSyncInventoryItemEvent(uint unit_id, int itemID, int index, int count)
- : base(unit_id)
- {
- this.ItemTemplateID = itemID;
- this.Index = index;
- this.Count = count;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutS32(ItemTemplateID);
- output.PutVS32(Index);
- output.PutVS32(Count);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.ItemTemplateID = input.GetS32();
- this.Index = input.GetVS32();
- this.Count = input.GetVS32();
- }
- }
- /// <summary>
- /// 单位使用道具
- /// </summary>
- [MessageType(0x8115)]
- public class UnitUseItemEvent : ObjectEvent, ActorMessage
- {
- public int ItemTemplateID;
- public UnitUseItemEvent() { }
- public UnitUseItemEvent(uint unit_id, int itemID)
- : base(unit_id)
- {
- this.ItemTemplateID = itemID;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutS32(ItemTemplateID);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.ItemTemplateID = input.GetS32();
- }
- }
- [MessageType(0x8116)]
- public class UnitSyncMultiTimeLine : ObjectEvent
- {
- public List<bool> timelines;
- public UnitSyncMultiTimeLine() { }
- public UnitSyncMultiTimeLine(uint unit_id) : base(unit_id) { }
- public bool Update(List<MultiTimeLine> tlines)
- {
- bool ret = false;
- if (timelines == null)
- {
- timelines = new List<bool>(tlines.Count);
- }
- if (timelines.Count != tlines.Count)
- {
- CUtils.SetListSize<bool>(timelines, tlines.Count);
- ret = true;
- }
- for (int i = tlines.Count - 1; i >= 0; --i)
- {
- if (timelines[i] != tlines[i].Enable)
- {
- timelines[i] = tlines[i].Enable;
- ret = true;
- }
- }
- return ret;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutList(timelines, output.PutBool);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.timelines = input.GetList<bool>(input.GetBool);
- }
- }
- /// <summary>
- /// 单位复活
- /// </summary>
- [MessageType(0x8117)]
- public class UnitRebirthEvent : ObjectEvent
- {
- public UnitRebirthEvent() { }
- public UnitRebirthEvent(uint unit_id) : base(unit_id) { }
- }
- /// <summary>
- /// 用户连斩数
- /// </summary>
- [MessageType(0x8118)]
- public class UnitContinueKillValue : ObjectEvent
- {
- public short continuekills;
- public UnitContinueKillValue() { }
- public UnitContinueKillValue(uint unit_id, short continuekills)
- : base(unit_id)
- {
- this.continuekills = continuekills;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutS16(continuekills);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- continuekills = input.GetS16();
- }
- }
- /// <summary>
- /// 单位受攻击
- /// </summary>
- [MessageType(0x8119)]
- public class UnitDamageEvent : ObjectEvent
- {
- public bool HasDamageTime
- {
- get { return mask.Get(0); }
- private set { mask.Set(0, value); }
- }
- public bool HasFly
- {
- get { return mask.Get(1); }
- private set { mask.Set(1, value); }
- }
- public bool HasZLimit
- {
- get { return mask.Get(2); }
- private set { mask.Set(2, value); }
- }
- public bool HasKnockDown
- {
- get { return mask.Get(3); }
- private set { mask.Set(3, value); }
- }
- public bool HasZGravity
- {
- get { return mask.Get(4); }
- private set { mask.Set(4, value); }
- }
- public bool HasMoveTime
- {
- get { return mask.Get(5); }
- private set { mask.Set(5, value); }
- }
- public AttackProp Source { get; private set; }
- /// <summary>
- /// 总共受击时间(位移时间+受击时间)
- /// </summary>
- public int TotalTimeMS
- {
- get { return MoveTimeMS + DamageTimeMS; }
- }
- /// <summary>
- /// 特殊受击动作
- /// </summary>
- public string DamageActionName
- {
- get { return Source.DamageActionName; }
- }
- /// <summary>
- /// 受击的特殊动作
- /// </summary>
- public bool HasDamageAction
- {
- get { return !string.IsNullOrEmpty(Source.DamageActionName); }
- }
- private BitSet8 mask = new BitSet8();
- private uint source_sn = 0;
- public int DamageTimeMS = 0;
- public int MoveTimeMS = 0;
- public float ZSpeedSEC = 0;
- public float ZLimit = 0;
- public float ZGravity = 0;
- public UnitDamageEvent() { }
- public UnitDamageEvent(uint unit_id, int damageTimeMS, int moveTimeMS, float zspeed, float zgravity, float zlimit, bool knockDown, AttackProp source)
- : base(unit_id)
- {
- this.Source = source;
- this.DamageTimeMS = damageTimeMS;
- this.MoveTimeMS = moveTimeMS;
- this.ZSpeedSEC = zspeed;
- this.ZLimit = zlimit;
- this.ZGravity = zgravity;
- this.HasDamageTime = (DamageTimeMS != 0);
- this.HasMoveTime = (MoveTimeMS != 0);
- this.HasFly = (zspeed != 0);
- this.HasZGravity = (zgravity != 0);
- this.HasZLimit = (zlimit > 0);
- this.HasKnockDown = knockDown;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutU8(mask.Mask);
- output.PutVU32(source_sn);
- if (HasDamageTime)
- {
- output.PutVS32(DamageTimeMS);
- }
- if (HasMoveTime)
- {
- output.PutVS32(MoveTimeMS);
- }
- if (HasFly)
- {
- output.PutF32(ZSpeedSEC);
- }
- if (HasZLimit)
- {
- output.PutF32(ZLimit);
- }
- if (HasZGravity)
- {
- output.PutF32(ZGravity);
- }
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.mask.Mask = input.GetU8();
- this.source_sn = input.GetVU32();
- if (HasDamageTime)
- {
- this.DamageTimeMS = input.GetVS32();
- }
- if (HasMoveTime)
- {
- this.MoveTimeMS = input.GetVS32();
- }
- if (HasFly)
- {
- this.ZSpeedSEC = input.GetF32();
- }
- if (HasZLimit)
- {
- this.ZLimit = input.GetF32();
- }
- if (HasZGravity)
- {
- this.ZGravity = input.GetF32();
- }
- }
- public override void BeforeWrite(TemplateManager templates)
- {
- if (Source != null)
- {
- this.source_sn = Source.SerialNumber;
- }
- }
- public override void EndRead(TemplateManager templates)
- {
- if (source_sn != 0)
- {
- this.Source = templates.GetSnData<AttackProp>(source_sn);
- }
- }
- }
- /// <summary>
- /// 技能动作序列被意外取消
- /// </summary>
- [MessageType(0x811A)]
- public class UnitSkillActionChangeEvent : ObjectEvent
- {
- public byte ActionIndex;
- public UnitSkillActionChangeEvent() { }
- public UnitSkillActionChangeEvent(uint unit_id, byte index)
- : base(unit_id)
- {
- this.ActionIndex = index;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutU8(ActionIndex);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.ActionIndex = input.GetU8();
- }
- }
- /// <summary>
- /// 单位开始检取道具读条
- /// </summary>
- [MessageType(0x811B)]
- public class UnitStartPickObjectEvent : ObjectEvent
- {
- public int PickTimeMS;
- public uint PickObjectID;
- public string PickStatus;
- public UnitStartPickObjectEvent() { }
- public UnitStartPickObjectEvent(uint unit_id, int pickTimeMS, uint pickObjID, string status)
- : base(unit_id)
- {
- this.PickTimeMS = pickTimeMS;
- this.PickObjectID = pickObjID;
- this.PickStatus = status;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutVS32(PickTimeMS);
- output.PutVU32(PickObjectID);
- output.PutUTF(PickStatus);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.PickTimeMS = input.GetVS32();
- this.PickObjectID = input.GetVU32();
- this.PickStatus = input.GetUTF();
- }
- }
- [MessageType(0x811C)]
- public class UnitStopPickObjectEvent : ObjectEvent
- {
- public string StopReason;
- public UnitStopPickObjectEvent() { }
- public UnitStopPickObjectEvent(uint unit_id, string reason)
- : base(unit_id)
- {
- this.StopReason = reason;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutUTF(StopReason);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.StopReason = input.GetUTF();
- }
- }
- /// <summary>
- /// 单位从场景中获得道具
- /// </summary>
- [MessageType(0x811D)]
- public class UnitGotInstanceItemEvent : ObjectEvent, ActorMessage
- {
- public uint ItemObjectID;
- public byte flag; //0-后续可以继续采集,1-后续不可继续采集
- public UnitGotInstanceItemEvent() { }
- public UnitGotInstanceItemEvent(uint unit_id, uint pickObjID, byte flag = 0)
- : base(unit_id)
- {
- this.ItemObjectID = pickObjID;
- this.flag = flag;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutU32(ItemObjectID);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.ItemObjectID = input.GetU32();
- }
- }
- /// <summary>
- /// 别的单位释放技能跳起
- /// </summary>
- [MessageType(0x811E)]
- public class UnitJumpEvent : ObjectEvent
- {
- public float ZSpeed;
- public float ZLimit;
- public float ZGravity;
- public UnitJumpEvent() { }
- public UnitJumpEvent(uint unit_id, float zspeed, float zgravity, float zlimit)
- : base(unit_id)
- {
- this.ZSpeed = zspeed;
- this.ZLimit = zlimit;
- this.ZGravity = zgravity;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutF32(ZSpeed);
- output.PutF32(ZLimit);
- output.PutF32(ZGravity);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.ZSpeed = input.GetF32();
- this.ZLimit = input.GetF32();
- this.ZGravity = input.GetF32();
- }
- }
- /// <summary>
- /// 立即同步客户端坐标,比如单位传送之类,用于MoveByClient的模式
- /// </summary>
- [MessageType(0x811F)]
- public class UnitForceSyncPosEvent : ObjectEvent
- {
- public float X;
- public float Y;
- public float Direction;
- public byte UnitMainState;
- public byte UnitSubState;
- public UnitForceSyncPosEvent() { }
- public UnitForceSyncPosEvent(uint unit_id, float x, float y, float d, byte state, byte sub_state)
- : base(unit_id)
- {
- this.X = x;
- this.Y = y;
- this.Direction = d;
- this.UnitMainState = state;
- this.UnitSubState = sub_state;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutF32(this.X);
- output.PutF32(this.Y);
- output.PutF32(this.Direction);
- output.PutU8(this.UnitMainState);
- output.PutU8(this.UnitSubState);
- //if (this.object_id == 2649)
- //{
- // Console.WriteLine("ForceSync-" + this.object_id + ", X: " + this.X + ", \t Y: " + this.Y + ", " + this.UnitMainState + ", " + this.UnitSubState);
- //}
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.X = input.GetF32();
- this.Y = input.GetF32();
- this.Direction = input.GetF32();
- this.UnitMainState = input.GetU8();
- this.UnitSubState = input.GetU8();
- }
- }
- /// <summary>
- /// 立即同步客户端坐标,比如单位传送之类,用于MoveByClient的模式
- /// </summary>
- [MessageType(0x8120)]
- public class ObjectForceSyncPosEvent : ObjectEvent
- {
- public float X;
- public float Y;
- public float Direction;
- public ObjectForceSyncPosEvent() { }
- public ObjectForceSyncPosEvent(uint unit_id, float x, float y, float d)
- : base(unit_id)
- {
- this.X = x;
- this.Y = y;
- this.Direction = d;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutF32(this.X);
- output.PutF32(this.Y);
- output.PutF32(this.Direction);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.X = input.GetF32();
- this.Y = input.GetF32();
- this.Direction = input.GetF32();
- }
- }
- /// <summary>
- /// Missile类法术,锁定单位时触发
- /// </summary>
- [MessageType(0x8130)]
- public class SpellLockTargetEvent : ObjectEvent, PositionMessage
- {
- public uint target_obj_id;
- private float x;
- private float y;
- public SpellLockTargetEvent() { }
- public SpellLockTargetEvent(uint spell_id, uint target_obj_id, float x, float y)
- : base(spell_id)
- {
- this.target_obj_id = target_obj_id;
- this.x = x;
- this.y = y;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutVU32(target_obj_id);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.target_obj_id = input.GetVU32();
- }
- public float X { get { return x; } }
- public float Y { get { return y; } }
- }
- #endregion
- //--------------------------------------------------------------------------
- #region CONTROL_0x8200
- /// <summary>
- /// 单位待机
- /// </summary>
- [MessageType(0x8200)]
- public class UnitGuardAction : ObjectAction
- {
- public bool guard = false;
- public string reason = null;
- public bool forceNotify = false;
- public UnitGuardAction() { }
- public UnitGuardAction(uint unit_id, bool guard)
- : base(unit_id)
- {
- this.guard = guard;
- }
- public UnitGuardAction(uint unit_id, bool guard, string reason)
- : base(unit_id)
- {
- this.guard = guard;
- this.reason = reason;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutBool(guard);
- output.PutUTF(reason);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.guard = input.GetBool();
- this.reason = input.GetUTF();
- }
- }
- /// <summary>
- /// A过去
- /// </summary>
- [MessageType(0x8206)]
- public class UnitAttackToAction : ObjectAction
- {
- public float targetX;
- public float targetY;
- public bool attack;
- public UnitAttackToAction() { }
- public UnitAttackToAction(uint unit_id, float x, float y, bool attack)
- : base(unit_id)
- {
- this.targetX = x;
- this.targetY = y;
- this.attack = attack;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutF32(targetX);
- output.PutF32(targetY);
- output.PutBool(attack);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.targetX = input.GetF32();
- this.targetY = input.GetF32();
- this.attack = input.GetBool();
- }
- }
- /// <summary>
- /// 单位移动
- /// </summary>
- [MessageType(0x8201)]
- public class UnitMoveAction : ObjectAction
- {
- public float x;
- public float y;
- public UnitMoveAction() { }
- public UnitMoveAction(uint unit_id, float x, float y)
- : base(unit_id)
- {
- this.x = x;
- this.y = y;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutF32(x);
- output.PutF32(y);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.x = input.GetF32();
- this.y = input.GetF32();
- }
- }
- /// <summary>
- /// 玩家选择朝向
- /// </summary>
- [MessageType(0x8202)]
- public class UnitFaceToAction : ObjectAction
- {
- public float Direction;
- public UnitFaceToAction() { }
- public UnitFaceToAction(uint unit_id, float d)
- : base(unit_id)
- {
- this.Direction = d;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutF32(Direction);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.Direction = input.GetF32();
- }
- }
- /// <summary>
- /// 单位移动
- /// </summary>
- [MessageType(0x8203)]
- public class UnitSlipAction : ObjectAction
- {
- public float x;
- public float y;
- public UnitSlipAction() { }
- public UnitSlipAction(uint unit_id, float x, float y)
- : base(unit_id)
- {
- this.x = x;
- this.y = y;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutF32(x);
- output.PutF32(y);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.x = input.GetF32();
- this.y = input.GetF32();
- }
- }
- /// <summary>
- /// 锁定目标
- /// </summary>
- [MessageType(0x8204)]
- public class UnitFocuseTargetAction : ObjectAction
- {
- public uint targetUnitID;
- public UnitFocuseTargetAction() { }
- public UnitFocuseTargetAction(uint unit_id, uint target_id)
- : base(unit_id)
- {
- this.targetUnitID = target_id;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutU32(targetUnitID);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.targetUnitID = input.GetU32();
- }
- }
- /// <summary>
- /// 单位技能动作
- /// </summary>
- [MessageType(0x8205)]
- public class UnitLaunchSkillAction : ObjectAction
- {
- private BitSet8 mask = new BitSet8();
- public bool IsAutoFocusNearTarget
- {
- get { return mask.Get(0); }
- set { mask.Set(0, value); }
- }
- private bool IsTargetID
- {
- get { return mask.Get(1); }
- set { mask.Set(1, value); }
- }
- private bool IsTargetPos
- {
- get { return mask.Get(2); }
- set { mask.Set(2, value); }
- }
- public bool SyncDirection
- {
- get { return mask.Get(3); }
- set { mask.Set(3, value); }
- }
- public int SkillID;
- public uint TargetObjID = 0;
- public Vector2 SpellTargetPos = null;
- public float Direction = 0;
- public UnitLaunchSkillAction() { }
- public UnitLaunchSkillAction(uint unit_id, int skill_id, bool autoFocuseTarget = false, uint targetObjID = 0, Vector2 spellTargetPos = null, float direction = 0.0f)
- : base(unit_id)
- {
- this.SkillID = skill_id;
- this.TargetObjID = targetObjID;
- this.SpellTargetPos = spellTargetPos;
- this.IsAutoFocusNearTarget = autoFocuseTarget;
- this.Direction = direction;
- }
- override public void WriteExternal(IOutputStream output)
- {
- this.IsTargetID = (TargetObjID != 0);
- this.IsTargetPos = (SpellTargetPos != null);
- base.WriteExternal(output);
- mask.WriteExternal(output);
- output.PutS32(SkillID);
- if (SyncDirection)
- {
- output.PutF32(Direction);
- }
-
- if (IsTargetID)
- {
- output.PutU32(TargetObjID);
- }
- if (IsTargetPos)
- {
- output.PutF32(SpellTargetPos.X);
- output.PutF32(SpellTargetPos.Y);
- }
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- mask.ReadExternal(input);
- this.SkillID = input.GetS32();
- if (SyncDirection)
- {
- this.Direction = input.GetF32();
- }
- if (IsTargetID)
- {
- this.TargetObjID = input.GetU32();
- }
- if (IsTargetPos)
- {
- this.SpellTargetPos = new Vector2();
- this.SpellTargetPos.SetX(input.GetF32());
- this.SpellTargetPos.SetY(input.GetF32());
- }
- }
- }
- /// <summary>
- /// 客户端手动控制同步包
- /// </summary>
- [MessageType(0x8207)]
- public class UnitAxisAction : ObjectAction
- {
- public bool IsZero { get { return dx == 0 && dy == 0; } }
- public float dx;
- public float dy;
- public UnitAxisAction() { }
- public UnitAxisAction(uint unit_id)
- : base(unit_id)
- {
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- float angle = (float)Math.Atan2(dy, dx);
- output.PutS8((sbyte)(Math.Cos(angle) * 100f));
- output.PutS8((sbyte)(Math.Sin(angle) * 100f));
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.dx = input.GetS8() / 100f;
- this.dy = input.GetS8() / 100f;
- }
- public bool AxisEquals(UnitAxisAction obj)
- {
- if (obj == null) return false;
- return (obj.dx == this.dx) && (obj.dy == this.dy);
- }
- }
- /// <summary>
- /// 客户端手动控制同步包
- /// </summary>
- [MessageType(0x8208)]
- public class UnitStopMoveAction : ObjectAction
- {
- public UnitStopMoveAction() { }
- public UnitStopMoveAction(uint unit_id)
- : base(unit_id)
- {
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- }
- }
- /// <summary>
- /// 单位使用道具
- /// </summary>
- [MessageType(0x8209)]
- public class UnitUseItemAction : ObjectAction
- {
- public int Index;
- public int Count;
- public UnitUseItemAction() { }
- public UnitUseItemAction(uint unit_id, int index, int count = 1)
- : base(unit_id)
- {
- this.Index = index;
- this.Count = count;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutVS32(this.Index);
- output.PutVS32(this.Count);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.Index = input.GetVS32();
- this.Count = input.GetVS32();
- }
- }
- /// <summary>
- /// 单位手动检取场景道具
- /// </summary>
- [MessageType(0x820A)]
- public class UnitPickObjectAction : ObjectAction
- {
- public uint PickableObjectID;
- public UnitPickObjectAction() { }
- public UnitPickObjectAction(uint unit_id, uint item_obj_id)
- : base(unit_id)
- {
- this.PickableObjectID = item_obj_id;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutVU32(this.PickableObjectID);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.PickableObjectID = input.GetVU32();
- }
- }
- /// <summary>
- /// 单位移动
- /// </summary>
- [MessageType(0x820B)]
- public class UnitUpdatePosAction : ObjectAction
- {
- public bool isHalf;
- public float x;
- public float y;
- public float d;
- public UnitActionStatus st;
- public UnitUpdatePosAction() { }
- public UnitUpdatePosAction(uint unit_id, bool isHalf, float x, float y, float d, UnitActionStatus s)
- : base(unit_id)
- {
- this.isHalf = isHalf;
- this.x = x;
- this.y = y;
- this.d = d;
- this.st = s;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutBool(isHalf);
- if (isHalf)
- {
- output.PutU16(MoveHelper.ToPos16(x));
- output.PutU16(MoveHelper.ToPos16(y));
- output.PutU8(MoveHelper.ToDirectionD8(d));
- }
- else
- {
- output.PutF32(x);
- output.PutF32(y);
- output.PutF32(d);
- }
- output.PutEnum8(st);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.isHalf = input.GetBool();
- if (isHalf)
- {
- this.x = MoveHelper.ToPosF32(input.GetU16());
- this.y = MoveHelper.ToPosF32(input.GetU16());
- this.d = MoveHelper.ToDirectionF32(input.GetU8());
- }
- else
- {
- this.x = input.GetF32();
- this.y = input.GetF32();
- this.d = input.GetF32();
- }
- this.st = input.GetEnum8<UnitActionStatus>();
- //Console.WriteLine("-------------------UnitUpdatePosAction : " + TimeUtil.GetTimestampMS() + this.x + ", " + this.y + " \t \t" + this.st);
- }
- public bool DataEquals(UnitUpdatePosAction o)
- {
- if (o == null) return false;
- return o.x == this.x && o.y == this.y && o.d == this.d && o.st == this.st;
- }
- public void Set(UnitUpdatePosAction other)
- {
- this.object_id = other.object_id;
- this.isHalf = other.isHalf;
- this.x = other.x;
- this.y = other.y;
- this.d = other.d;
- this.st = other.st;
- }
- }
- [MessageType(0x820C)]
- public class UnitSetSyncModeAction : ObjectAction
- {
- public SyncMode Mode;
- public UnitSetSyncModeAction() { }
- public UnitSetSyncModeAction(uint unit_id, SyncMode mode)
- : base(unit_id)
- {
- this.Mode = mode;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutEnum8(Mode);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.Mode = input.GetEnum8<SyncMode>();
- }
- }
- [MessageType(0x820D)]
- public class UnitCancelBuffAction : ObjectAction
- {
- public int BuffID;
- public UnitCancelBuffAction() { }
- public UnitCancelBuffAction(uint unit_id, int buffID)
- : base(unit_id)
- {
- this.BuffID = buffID;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutS32(BuffID);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.BuffID = input.GetS32();
- }
- }
- /// <summary>
- /// 单位统计数据
- /// </summary>
- public class UnitStatisticData : IExternalizable
- {
- public uint ObjectID;
- /// <summary>
- /// 死亡次数
- /// </summary>
- public int DeadCount;
- /// <summary>
- /// 总共杀死单位数量
- /// </summary>
- public int KillUnitCount;
- /// <summary>
- /// 总共杀死玩家数量
- /// </summary>
- public int KillPlayerCount;
- /// <summary>
- /// 承受伤害
- /// </summary>
- public long SelfDamage;
- /// <summary>
- /// 对所有单位造成的总伤害
- /// </summary>
- public long TotalDamage;
- /// <summary>
- /// 对玩家造成的总伤害
- /// </summary>
- public long PlayerDamage;
- /// <summary>
- /// 对所有单位输出的总治疗量
- /// </summary>
- public long TotalHealing;
- /// <summary>
- /// 对玩家输出的总治疗量
- /// </summary>
- public long PlayerHealing;
- public virtual void WriteExternal(IOutputStream output)
- {
- output.PutVU32(ObjectID);
- output.PutVS32(DeadCount);
- output.PutVS32(KillUnitCount);
- output.PutVS32(KillPlayerCount);
- output.PutVS64(SelfDamage);
- output.PutVS64(TotalDamage);
- output.PutVS64(PlayerDamage);
- output.PutVS64(TotalHealing);
- output.PutVS64(PlayerHealing);
- }
- public virtual void ReadExternal(IInputStream input)
- {
- ObjectID = input.GetVU32();
- DeadCount = input.GetVS32();
- KillUnitCount = input.GetVS32();
- KillPlayerCount = input.GetVS32();
- SelfDamage = input.GetVS64();
- TotalDamage = input.GetVS64();
- PlayerDamage = input.GetVS64();
- TotalHealing = input.GetVS64();
- PlayerHealing = input.GetVS64();
- }
- }
- [MessageType(0x8210)]
- public class UnitGetStatisticRequest : ActorRequest
- {
- public uint[] RequestObjectsID;
- public UnitGetStatisticRequest() { }
- public UnitGetStatisticRequest(uint objID, params uint[] objectsID) : base(objID)
- {
- this.RequestObjectsID = objectsID;
- }
- public override void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutS32(MessageID);
- output.PutArray(RequestObjectsID, output.PutU32);
- }
- public override void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.MessageID = input.GetS32();
- this.RequestObjectsID = input.GetArray<uint>(input.GetU32);
- }
- }
- [MessageType(0x8211)]
- public class UnitGetStatisticResponse : ActorResponse
- {
- public HashMap<uint, UnitStatisticData> Statistics = new HashMap<uint, UnitStatisticData>();
- public override void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutS32(MessageID);
- output.PutVS32(Statistics.Count);
- foreach (KeyValuePair<uint, UnitStatisticData> e in Statistics)
- {
- output.PutU32(e.Key);
- output.PutExt(e.Value);
- }
- }
- public override void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.MessageID = input.GetS32();
- int count = input.GetVS32();
- for (int i = 0; i < count; i++)
- {
- var key = input.GetU32();
- var data = input.GetExtAny() as UnitStatisticData;
- Statistics.Put(key, data);
- }
- }
- }
- /// <summary>
- /// 设置子动做
- /// </summary>
- [MessageType(0x8212)]
- public class UnitSetSubStateAction : ObjectAction
- {
- public byte UnitSubState;
- public UnitSetSubStateAction() { }
- public UnitSetSubStateAction(uint objID, byte state)
- : base(objID)
- {
- this.UnitSubState = state;
- }
- public override void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutU8(UnitSubState);
- }
- public override void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.UnitSubState = input.GetU8();
- }
- }
- /// <summary>
- /// 单位准备完毕
- /// </summary>
- [MessageType(0x8213)]
- public class UnitReadAction : ObjectAction
- {
- public UnitReadAction() { }
- public UnitReadAction(uint objID)
- : base(objID)
- {
- }
- public override void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- }
- public override void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- }
- }
- #endregion
- //--------------------------------------------------------------------------
- //--------------------------------------------------------------------------------------------------------------
- #region CLIENT_EVENTS_0x8300
- public abstract class ClientEvent : ZoneEvent
- {
- }
- /// <summary>
- /// 显示箭头
- /// </summary>
- [MessageType(0x8300)]
- public class LookAtEvent : ClientEvent
- {
- public string target;
- public float x;
- public float y;
- public LookAtEvent() { }
- public LookAtEvent(string target, float x, float y)
- {
- this.target = target;
- this.x = x;
- this.y = y;
- }
- override public void WriteExternal(IOutputStream output)
- {
- output.PutUTF(target);
- output.PutF32(x);
- output.PutF32(y);
- }
- override public void ReadExternal(IInputStream input)
- {
- this.target = input.GetUTF();
- this.x = input.GetF32();
- this.y = input.GetF32();
- }
- }
- /// <summary>
- /// 改变游戏运行速度
- /// </summary>
- [MessageType(0x8301)]
- public class ChangeTimeScaleEvent : ClientEvent
- {
- /// <summary>
- /// 时间尺度百分比
- /// </summary>
- public float TimeScalePct = 100f;
- public ChangeTimeScaleEvent() { }
- public ChangeTimeScaleEvent(float pct)
- {
- this.TimeScalePct = pct;
- }
- override public void WriteExternal(IOutputStream output)
- {
- output.PutF32(TimeScalePct);
- }
- override public void ReadExternal(IInputStream input)
- {
- this.TimeScalePct = input.GetF32();
- }
- }
- /// <summary>
- /// 暂停游戏
- /// </summary>
- [MessageType(0x8302)]
- public class GamePauseEvent : ClientEvent
- {
- /// <summary>
- /// 暂停多少秒,如果为0,则无限暂停
- /// </summary>
- public float Seconds = 0f;
- public GamePauseEvent() { }
- public GamePauseEvent(float sec)
- {
- this.Seconds = sec;
- }
- override public void WriteExternal(IOutputStream output)
- {
- output.PutF32(Seconds);
- }
- override public void ReadExternal(IInputStream input)
- {
- this.Seconds = input.GetF32();
- }
- }
- /// <summary>
- /// 继续游戏
- /// </summary>
- [MessageType(0x8303)]
- public class GameResumeEvent : ClientEvent
- {
- public GameResumeEvent() { }
- public override void WriteExternal(IOutputStream output)
- {
- }
- public override void ReadExternal(IInputStream input)
- {
- }
- }
- /// <summary>
- /// 移动镜头到
- /// </summary>
- [MessageType(0x8304)]
- public class CameraMoveToEvent : ClientEvent
- {
- /// <summary>
- /// 镜头移动速度(每秒距离)
- /// </summary>
- public float MoveSpeedSec = 1f;
- /// <summary>
- /// 移动过去的总时间,如果为0,则按速度计算
- /// </summary>
- public int TimeMS = 0;
- public float x;
- public float y;
- public CameraMoveToEvent() { }
- public CameraMoveToEvent(float x, float y, float speed, int timeMS)
- {
- this.x = x;
- this.y = y;
- this.MoveSpeedSec = speed;
- this.TimeMS = timeMS;
- }
- override public void WriteExternal(IOutputStream output)
- {
- output.PutF32(x);
- output.PutF32(y);
- output.PutF32(MoveSpeedSec);
- output.PutS32(TimeMS);
- }
- override public void ReadExternal(IInputStream input)
- {
- this.x = input.GetF32();
- this.y = input.GetF32();
- this.MoveSpeedSec = input.GetF32();
- this.TimeMS = input.GetS32();
- }
- }
- /// <summary>
- /// 锁定镜头到单位
- /// </summary>
- [MessageType(0x8305)]
- public class CameraFocusUnitEvent : ClientEvent
- {
- public uint ObjectID;
- public CameraFocusUnitEvent() { }
- public CameraFocusUnitEvent(uint oid)
- {
- this.ObjectID = oid;
- }
- override public void WriteExternal(IOutputStream output)
- {
- output.PutU32(ObjectID);
- }
- override public void ReadExternal(IInputStream input)
- {
- this.ObjectID = input.GetU32();
- }
- }
- /// <summary>
- /// 拉近镜头
- /// </summary>
- [MessageType(0x8306)]
- public class CameraZoomToEvent : ClientEvent
- {
- /// <summary>
- /// 镜头拉近距离
- /// </summary>
- public float ZoomDistance = 10f;
- /// <summary>
- /// 镜头拉近速度(每秒距离)
- /// </summary>
- public float ZoomSpeedSec = 1f;
- public CameraZoomToEvent() { }
- public CameraZoomToEvent(float distance, float speed)
- {
- this.ZoomDistance = distance;
- this.ZoomSpeedSec = speed;
- }
- override public void WriteExternal(IOutputStream output)
- {
- output.PutF32(ZoomDistance);
- output.PutF32(ZoomSpeedSec);
- }
- override public void ReadExternal(IInputStream input)
- {
- this.ZoomDistance = input.GetF32();
- this.ZoomSpeedSec = input.GetF32();
- }
- }
- /// <summary>
- /// 旋转镜头
- /// </summary>
- [MessageType(0x8307)]
- public class CameraRotateToEvent : ClientEvent
- {
- /// <summary>
- /// 镜头旋转角度(0~360)
- /// </summary>
- public float RotateAngle = 10f;
- /// <summary>
- /// 镜头旋转速度(每秒角度)
- /// </summary>
- public float RotateSpeedSec = 1f;
- public CameraRotateToEvent() { }
- public CameraRotateToEvent(float angle, float speed)
- {
- this.RotateAngle = angle;
- this.RotateSpeedSec = speed;
- }
- override public void WriteExternal(IOutputStream output)
- {
- output.PutF32(RotateAngle);
- output.PutF32(RotateSpeedSec);
- }
- override public void ReadExternal(IInputStream input)
- {
- this.RotateAngle = input.GetF32();
- this.RotateSpeedSec = input.GetF32();
- }
- }
- /// <summary>
- /// 重置镜头
- /// </summary>
- [MessageType(0x8308)]
- public class CameraResetEvent : ClientEvent
- {
- public override void WriteExternal(IOutputStream output)
- {
- }
- public override void ReadExternal(IInputStream input)
- {
- }
- }
- /// <summary>
- /// 客户端动作序列
- /// </summary>
- [MessageType(0x8309)]
- public class ClientEventQueue : ClientEvent
- {
- public List<ClientEvent> EventQueue = new List<ClientEvent>();
- override public void WriteExternal(IOutputStream output)
- {
- output.PutU8((byte)EventQueue.Count);
- foreach (ClientEvent e in EventQueue)
- {
- output.PutExt(e);
- }
- }
- override public void ReadExternal(IInputStream input)
- {
- int count = input.GetU8();
- for (int i = 0; i < count; i++)
- {
- EventQueue.Add(input.GetExtAny() as ClientEvent);
- }
- }
- }
- /// <summary>
- /// 移动锁定一段时间
- /// </summary>
- [MessageType(0x830B)]
- public class CameraHoldEvent : ClientEvent
- {
- public float x;
- public float y;
- public int TimeMS;
- public CameraHoldEvent() { }
- public CameraHoldEvent(float x, float y, int timeMS)
- {
- this.x = x;
- this.y = y;
- this.TimeMS = timeMS;
- }
- override public void WriteExternal(IOutputStream output)
- {
- output.PutF32(x);
- output.PutF32(y);
- output.PutS32(TimeMS);
- }
- override public void ReadExternal(IInputStream input)
- {
- this.x = input.GetF32();
- this.y = input.GetF32();
- this.TimeMS = input.GetS32();
- }
- }
- #endregion
- //--------------------------------------------------------------------------
- #region PLAYER_EVENTS_0x8400
- public abstract class PlayerEvent : ObjectEvent
- {
- public PlayerEvent() { }
- public PlayerEvent(uint objID) : base(objID) { }
- }
- [MessageType(0x8400)]
- public class PlayerCDEvent : PlayerEvent
- {
- private byte mask = 0;
- public bool is_all
- {
- get { return BitMask.BitGetMask(mask, 0); }
- set { BitMask.BitSetMask(ref mask, 0, value); }
- }
- public bool is_decrease_time
- {
- get { return BitMask.BitGetMask(mask, 1); }
- set { BitMask.BitSetMask(ref mask, 1, value); }
- }
- public bool is_decrease_pct
- {
- get { return BitMask.BitGetMask(mask, 2); }
- set { BitMask.BitSetMask(ref mask, 2, value); }
- }
- public bool is_clear
- {
- get { return BitMask.BitGetMask(mask, 3); }
- set { BitMask.BitSetMask(ref mask, 3, value); }
- }
- public int decrease_timeMS;
- public float decrease_pct;
- public int skill_template_id;
- public PlayerCDEvent() { }
- public PlayerCDEvent(uint unit_id) : base(unit_id) { }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutU8(mask);
- if (is_all)
- {
- if (is_decrease_pct)
- output.PutF32(decrease_pct);
- if (is_decrease_time)
- output.PutVS32(decrease_timeMS);
- }
- else
- {
- output.PutS32(skill_template_id);
- if (is_decrease_pct)
- output.PutF32(decrease_pct);
- if (is_decrease_time)
- output.PutVS32(decrease_timeMS);
- }
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.mask = input.GetU8();
- if (is_all)
- {
- if (is_decrease_pct)
- decrease_pct = input.GetF32();
- if (is_decrease_time)
- decrease_timeMS = input.GetVS32();
- }
- else
- {
- skill_template_id = input.GetS32();
- if (is_decrease_pct)
- decrease_pct = input.GetF32();
- if (is_decrease_time)
- decrease_timeMS = input.GetVS32();
- }
- }
- }
- [MessageType(0x8401)]
- public class PlayerSkillChangedEvent : PlayerEvent
- {
- public SkillTemplate baseSkill;
- public List<SkillTemplate> skills = new List<SkillTemplate>();
- public float unitFastCastRate;
- public PlayerSkillChangedEvent() { }
- public PlayerSkillChangedEvent(uint unit_id) : base(unit_id) { }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutF32(this.unitFastCastRate);
- output.PutExt(this.baseSkill);
- output.PutList<SkillTemplate>(this.skills, output.PutExt);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.unitFastCastRate = input.GetF32();
- this.baseSkill = input.GetExt<SkillTemplate>();
- this.skills = input.GetList<SkillTemplate>(input.GetExt<SkillTemplate>);
- }
- }
- [MessageType(0x8402)]
- public class PlayerSyncEnvironmentVarEvent : PlayerEvent
- {
- public string Key;
- public object Value;
- public PlayerSyncEnvironmentVarEvent() { }
- public PlayerSyncEnvironmentVarEvent(uint unit_id, string key, object value)
- : base(unit_id)
- {
- this.Key = key;
- this.Value = value;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutUTF(Key);
- output.PutData(Value);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- DataType dtype;
- this.Key = input.GetUTF();
- this.Value = input.GetData(out dtype);
- }
- }
- [MessageType(0x8403)]
- public class PlayerSkillStopEvent : PlayerEvent
- {
- public int SkillID;
- public PlayerSkillStopEvent() { }
- public PlayerSkillStopEvent(uint unit_id, int skillID)
- : base(unit_id)
- {
- this.SkillID = skillID;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutS32(SkillID);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.SkillID = input.GetS32();
- }
- }
- [MessageType(0x8404)]
- public class PlayerSkillAddedEvent : PlayerEvent
- {
- public SkillTemplate Skill;
- public bool IsDefault;
- public PlayerSkillAddedEvent() { }
- public PlayerSkillAddedEvent(uint unit_id, SkillTemplate sk, bool isDefault)
- : base(unit_id)
- {
- this.Skill = sk;
- this.IsDefault = isDefault;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutExt(this.Skill);
- output.PutBool(this.IsDefault);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.Skill = input.GetExt<SkillTemplate>();
- this.IsDefault = input.GetBool();
- }
- }
- [MessageType(0x8405)]
- public class PlayerSkillRemovedEvent : PlayerEvent
- {
- public int SkillID;
- public PlayerSkillRemovedEvent() { }
- public PlayerSkillRemovedEvent(uint unit_id, int skillID)
- : base(unit_id)
- {
- this.SkillID = skillID;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutS32(this.SkillID);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.SkillID = input.GetS32();
- }
- }
- /// <summary>
- /// 脚本系统指令
- /// </summary>
- [MessageType(0x8406)]
- public class PlayerScriptCommandEvent : PlayerEvent
- {
- public string message;
- public PlayerScriptCommandEvent() { }
- public PlayerScriptCommandEvent(uint unit_id, string msg)
- : base(unit_id)
- {
- this.message = msg;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutUTF(message);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.message = input.GetUTF();
- }
- }
- /// <summary>
- /// 技能可用性发生变化
- /// </summary>
- [MessageType(0x8407)]
- public class PlayerSkillActiveChangedEvent : PlayerEvent
- {
- public struct State
- {
- public int SkillTemplateID;
- public SkillActiveState ST;
- public bool IsActive { get { return ST == SkillActiveState.Active; } }
- public bool IsPauseOnDeactive { get { return ST == SkillActiveState.DeactiveAndPause; } }
- }
- public List<State> Skills;
- public PlayerSkillActiveChangedEvent() { this.Skills = new List<State>(); }
- public PlayerSkillActiveChangedEvent(uint unit_id, int skillCount) : base(unit_id)
- {
- this.Skills = new List<State>(skillCount);
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutVS32(Skills.Count);
- for (int i = 0; i < Skills.Count; i++)
- {
- State sat = Skills[i];
- output.PutS32(sat.SkillTemplateID);
- output.PutEnum8(sat.ST);
- }
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- int count = input.GetVS32();
- this.Skills.Capacity = count;
- for (int i = 0; i < count; i++)
- {
- State sat = new State();
- sat.SkillTemplateID = input.GetS32();
- sat.ST = input.GetEnum8<SkillActiveState>();
- this.Skills.Add(sat);
- }
- }
- }
- [MessageType(0x8408)]
- public class PlayerSkillTimeChangedEvent : PlayerEvent
- {
- public int SkillTemplateID;
- public int SkillPassTimeMS;
- public int SkillTotalTimeMS;
- public PlayerSkillTimeChangedEvent() { }
- public PlayerSkillTimeChangedEvent(uint unit_id, int skillID, int passTimeMS, int totalTimeMS)
- : base(unit_id)
- {
- this.SkillTemplateID = skillID;
- this.SkillPassTimeMS = passTimeMS;
- this.SkillTotalTimeMS = totalTimeMS;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutS32(this.SkillTemplateID);
- output.PutVS32(this.SkillPassTimeMS);
- output.PutVS32(this.SkillTotalTimeMS);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.SkillTemplateID = input.GetS32();
- this.SkillPassTimeMS = input.GetVS32();
- this.SkillTotalTimeMS = input.GetVS32();
- }
- }
- /// <summary>
- /// 锁定目标
- /// </summary>
- [MessageType(0x8409)]
- public class PlayerFocuseTargetEvent : PlayerEvent
- {
- public uint targetUnitID;
- public SkillTemplate.CastTarget expectTarget;
- public PlayerFocuseTargetEvent() { }
- public PlayerFocuseTargetEvent(uint unit_id, uint target_id, SkillTemplate.CastTarget expect)
- : base(unit_id)
- {
- this.targetUnitID = target_id;
- this.expectTarget = expect;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutU32(targetUnitID);
- output.PutEnum8(expectTarget);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.targetUnitID = input.GetU32();
- this.expectTarget = input.GetEnum8<SkillTemplate.CastTarget>();
- }
- }
- #endregion
- //--------------------------------------------------------------------------
- #region TEXT_0x8500
- public enum ChatMessageType : byte
- {
- SystemToAll,
- SystemToForce,
- SystemToPlayer,
- PlayerToAll,
- PlayerToForce,
- PlayerToPlayer,
- }
- [MessageType(0x8500)]
- public class ChatAction : ObjectAction
- {
- public string Message;
- public ChatMessageType To = ChatMessageType.SystemToAll;
- public string TargetPlayerUUID;
- public override void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutU8((byte)this.To);
- output.PutUTF(this.Message);
- output.PutUTF(this.TargetPlayerUUID);
- }
- public override void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.To = (ChatMessageType)input.GetU8();
- this.Message = input.GetUTF();
- this.TargetPlayerUUID = input.GetUTF();
- }
- }
- [MessageType(0x8501)]
- public class ChatEvent : ZoneEvent
- {
- public ChatMessageType To = ChatMessageType.SystemToAll;
- public int Force;
- public string FromPlayerUUID;
- public string ToPlayerUUID;
- public string Message;
- public uint KeepTimeMS;
- public ChatEvent() { }
- public ChatEvent(ChatMessageType to, uint timeMS = 2000)
- {
- this.To = to;
- KeepTimeMS = timeMS;
- }
- public override void WriteExternal(IOutputStream output)
- {
- output.PutU8((byte)this.To);
- output.PutVS32((int)KeepTimeMS);
- output.PutUTF(this.Message);
- switch (To)
- {
- case ChatMessageType.PlayerToAll:
- output.PutUTF(this.FromPlayerUUID);
- break;
- case ChatMessageType.PlayerToForce:
- output.PutUTF(this.FromPlayerUUID);
- output.PutVS32(this.Force);
- break;
- case ChatMessageType.PlayerToPlayer:
- output.PutUTF(this.FromPlayerUUID);
- output.PutUTF(this.ToPlayerUUID);
- break;
- case ChatMessageType.SystemToAll:
- break;
- case ChatMessageType.SystemToForce:
- output.PutVS32(this.Force);
- break;
- case ChatMessageType.SystemToPlayer:
- output.PutUTF(this.ToPlayerUUID);
- break;
- }
- }
- public override void ReadExternal(IInputStream input)
- {
- this.To = (ChatMessageType)input.GetU8();
- this.KeepTimeMS = (uint)input.GetVS32();
- this.Message = input.GetUTF();
- switch (To)
- {
- case ChatMessageType.PlayerToAll:
- this.FromPlayerUUID = input.GetUTF();
- break;
- case ChatMessageType.PlayerToForce:
- this.FromPlayerUUID = input.GetUTF();
- this.Force = input.GetVS32();
- break;
- case ChatMessageType.PlayerToPlayer:
- this.FromPlayerUUID = input.GetUTF();
- this.ToPlayerUUID = input.GetUTF();
- break;
- case ChatMessageType.SystemToAll:
- break;
- case ChatMessageType.SystemToForce:
- this.Force = input.GetVS32();
- break;
- case ChatMessageType.SystemToPlayer:
- this.ToPlayerUUID = input.GetUTF();
- break;
- }
- }
- }
- [MessageType(0x8502)]
- public class BubbleTalkEvent : ZoneEvent
- {
- public bool PauseBattle;
- public List<TalkInfo> TalkInfos = new List<TalkInfo>();
- public BubbleTalkEvent() { }
- override public void WriteExternal(IOutputStream output)
- {
- output.PutBool(PauseBattle);
- output.PutExtList<TalkInfo>(this.TalkInfos);
- }
- override public void ReadExternal(IInputStream input)
- {
- this.PauseBattle = input.GetBool();
- this.TalkInfos = input.GetExtList<TalkInfo>();
- }
- public class TalkInfo : IExternalizable
- {
- public uint TalkUnit;
- public string TalkContent;
- public string TalkActionType;
- public int TalkDelayTimeMS;
- public int TalkKeepTimeMS;
- public TalkInfo() { }
- public TalkInfo(uint TalkUnit, string TalkContent, string TalkActionType, int TalkDelayTimeMS, int TalkKeepTimeMS)
- {
- this.TalkUnit = TalkUnit;
- this.TalkContent = TalkContent;
- this.TalkActionType = TalkActionType;
- this.TalkDelayTimeMS = TalkDelayTimeMS;
- this.TalkKeepTimeMS = TalkKeepTimeMS;
- }
- public void WriteExternal(IOutputStream output)
- {
- output.PutVU32(TalkUnit);
- output.PutUTF(TalkContent);
- output.PutUTF(TalkActionType);
- output.PutVS32(TalkDelayTimeMS);
- output.PutVS32(TalkKeepTimeMS);
- }
- public void ReadExternal(IInputStream input)
- {
- this.TalkUnit = input.GetVU32();
- this.TalkContent = input.GetUTF();
- this.TalkActionType = input.GetUTF();
- this.TalkDelayTimeMS = input.GetVS32();
- this.TalkKeepTimeMS = input.GetVS32();
- }
- }
- }
- [MessageType(0x8503)]
- public class PlayerSkillUseTimeChangedEvent : PlayerEvent
- {
- public int SkillTemplateID;
- public byte useTimes;
- public byte hasNext; //0-不用继续叠层,1-继续增加叠层
- public PlayerSkillUseTimeChangedEvent() { }
- public PlayerSkillUseTimeChangedEvent(uint unit_id, int skillID, byte useTimes)
- : base(unit_id)
- {
- this.SkillTemplateID = skillID;
- this.useTimes = useTimes;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutS32(this.SkillTemplateID);
- output.PutU8(this.useTimes);
- output.PutU8(this.hasNext);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.SkillTemplateID = input.GetS32();
- this.useTimes = input.GetU8();
- this.hasNext = input.GetU8();
- }
- }
- /// <summary>
- /// 单位中BUFF
- /// </summary>
- [MessageType(0x8504)]
- public class SyncUnitBuffState : ObjectEvent
- {
- public int buffTemplateID;
- public byte overlayLevel;
- public int buffExtData; //buff的扩展字段,
- public SyncUnitBuffState() { }
- public SyncUnitBuffState(uint unit_id, int buffID, byte overlayLevel, int extData)
- : base(unit_id)
- {
- this.buffTemplateID = buffID;
- this.overlayLevel = overlayLevel;
- this.buffExtData = extData;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutVS32(buffTemplateID);
- output.PutU8(overlayLevel);
- output.PutVS32(buffExtData);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.buffTemplateID = input.GetVS32();
- this.overlayLevel = input.GetU8();
- this.buffExtData = input.GetVS32();
- }
- }
- /// <summary>
- /// 单位触发能力
- /// </summary>
- [MessageType(0x8505)]
- public class UnitTriggerAblity : ObjectEvent
- {
- public int ablityID;
- public UnitTriggerAblity() { }
- public UnitTriggerAblity(uint unit_id, int id)
- : base(unit_id)
- {
- this.ablityID = id;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutVS32(ablityID);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.ablityID = input.GetVS32();
- }
- }
- /// <summary>
- /// 单位触发破碎效果
- /// </summary>
- [MessageType(0x8506)]
- public class UnitHitBreak : ObjectEvent
- {
- public UnitHitBreak() { }
- public UnitHitBreak(uint unit_id)
- : base(unit_id)
- {
-
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- //output.PutVS32(ablityID);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- //this.ablityID = input.GetVS32();
- }
- }
- /// <summary>
- /// 单位触发隐身效果
- /// </summary>
- [MessageType(0x8507)]
- public class UnitStealthInfo : ObjectEvent
- {
- public byte stealth;
- public short flag;
- public UnitStealthInfo() { }
- public UnitStealthInfo(uint unit_id, byte stealth, short flag)
- : base(unit_id)
- {
- this.stealth = stealth;
- this.flag = flag;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutU8(this.stealth);
- output.PutS16(this.flag);
- //Console.WriteLine("UnitStealthInfo: " + this.stealth + ", " + flag);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.stealth = input.GetU8();
- this.flag = input.GetS16();
- }
- }
- /// <summary>
- /// buff数据推送:针对单一buff事件内的信息变更
- /// </summary>
- [MessageType(0x8508)]
- public class BuffDataNotify : ObjectEvent
- {
- public int buffId;
- public uint senderId;
- public byte overlayLevel;
- public BuffDataNotify() { }
- public BuffDataNotify(uint unit_id, int buffId, uint senderId, int layer)
- : base(unit_id)
- {
- this.buffId = buffId;
- this.senderId = senderId;
- this.overlayLevel = (byte)layer;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutS32(this.buffId);
- output.PutU32(this.senderId);
- output.PutU8(this.overlayLevel);
- //System.Console.WriteLine("-----BuffDataNotify: " + buffId + ", " + this.object_id + ", " + overlayLevel);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.buffId = input.GetS32();
- this.senderId = input.GetU32();
- this.overlayLevel = input.GetU8();
- }
- }
- #endregion
- //--------------------------------------------------------------------------
- #region SYSTEM_0x8600
- [MessageType(0x8600)]
- public class Ping : Action, SystemMessage
- {
- public uint DayOfMS;
- public Ping()
- {
- DayOfMS = (uint)CUtils.CurrentTimeMS;
- }
- public void Begin()
- {
- DayOfMS = (uint)CUtils.CurrentTimeMS;
- }
- public override void WriteExternal(IOutputStream output)
- {
- output.PutU32(DayOfMS);
- }
- public override void ReadExternal(IInputStream input)
- {
- DayOfMS = input.GetU32();
- }
- }
- [MessageType(0x8601)]
- public class Pong : Event, SystemMessage
- {
- public uint ClientTimeDayOfMS;
- public Pong() { }
- public Pong(Ping ping) { this.ClientTimeDayOfMS = ping.DayOfMS; }
- public override void WriteExternal(IOutputStream output)
- {
- output.PutU32(ClientTimeDayOfMS);
- }
- public override void ReadExternal(IInputStream input)
- {
- ClientTimeDayOfMS = input.GetU32();
- }
- }
- /// <summary>
- /// 打包一组消息,一次性发出
- /// </summary>
- [MessageType(0x8602)]
- public class PackEvent : Event, SystemMessage
- {
- protected static readonly Logger log = LoggerFactory.GetDefLogger();
- public int sequenceNo;
- public List<IMessage> events = new List<IMessage>();
- public override string ToString()
- {
- var sb = new StringBuilder("PackEvent: no=").Append(sequenceNo).AppendLine();
- foreach (IMessage e in events)
- {
- sb.AppendLine(e.ToString());
- }
- return sb.ToString();
- }
- public override void WriteExternal(IOutputStream output)
- {
- output.PutVS32(sequenceNo);
- output.PutVS32(events.Count);
- #if JSGProfile
- long startSize = output.GetBuffPos();
- #endif
- foreach (IMessage e in events)
- {
- //if (!e.ToString().EndsWith("Pong") && !e.ToString().EndsWith("SyncPosEvent"))
- //{
- // Console.WriteLine("PackEvent: " + e);
- //}
- output.PutExt(e);
- #if JSGProfile
- long tempSize = output.GetBuffPos();
- JSGServerProfile.RecordSend(output.GetTypeID(e), tempSize - startSize);
- startSize = tempSize;
- #endif
- }
- }
- public override void ReadExternal(IInputStream input)
- {
- this.sequenceNo = input.GetVS32();
- int count = input.GetVS32();
- events.Clear();
- events.Capacity = count;
- for (int i = 0; i < count; i++)
- {
- try
- {
- IMessage e = (IMessage)input.GetExtAny();
- events.Add(e);
- }
- catch (Exception err)
- {
- log.Error("PackEvent readExt catch:" + err);
- }
- }
- }
- public override void BeforeWrite(TemplateManager templates)
- {
- foreach (IMessage e in events)
- {
- if (e is BattleMessage)
- {
- (e as BattleMessage).BeforeWrite(templates);
- }
- }
- }
- public override void EndRead(TemplateManager templates)
- {
- foreach (IMessage e in events)
- {
- if (e is BattleMessage)
- {
- (e as BattleMessage).EndRead(templates);
- }
- }
- }
- }
- /// <summary>
- /// 系统消息框,测试用
- /// </summary>
- [MessageType(0x8603)]
- public class TestMessageBox : Event, SystemMessage
- {
- public string msg;
- public TestMessageBox() { }
- public TestMessageBox(string msg)
- {
- this.msg = msg;
- }
- public override void WriteExternal(IOutputStream output)
- {
- output.PutUTF(this.msg);
- }
- public override void ReadExternal(IInputStream input)
- {
- this.msg = input.GetUTF();
- }
- }
- /// <summary>
- /// 通知客户端服务器运行状态
- /// </summary>
- [MessageType(0x8604)]
- public class ServerStatusB2C : Event, SystemMessage
- {
- public int PID;
- public long PrivateMemorySize64;
- public int ActiveGameObjectCount;
- public int ActiveInstanceZoneCount;
- public int AllocGameObjectCount;
- public int AllocInstanceZoneCount;
- public ServerStatusB2C() { }
- public void Update(System.Diagnostics.Process p)
- {
- this.PID = p.Id;
- this.PrivateMemorySize64 = p.PrivateMemorySize64;
- this.ActiveGameObjectCount = InstanceZoneObject.ActiveObjectCount;
- this.ActiveInstanceZoneCount = InstanceZone.ActiveZoneCount;
- this.AllocGameObjectCount = InstanceZoneObject.AllocObjectCount;
- this.AllocInstanceZoneCount = InstanceZone.AllocZoneCount;
- }
- public override void WriteExternal(IOutputStream output)
- {
- output.PutVS32(this.PID);
- output.PutVS64(this.PrivateMemorySize64);
- output.PutVS32(this.ActiveGameObjectCount);
- output.PutVS32(this.ActiveInstanceZoneCount);
- output.PutVS32(this.AllocGameObjectCount);
- output.PutVS32(this.AllocInstanceZoneCount);
- }
- public override void ReadExternal(IInputStream input)
- {
- this.PID = input.GetVS32();
- this.PrivateMemorySize64 = input.GetVS64();
- this.ActiveGameObjectCount = input.GetVS32();
- this.ActiveInstanceZoneCount = input.GetVS32();
- this.AllocGameObjectCount = input.GetVS32();
- this.AllocInstanceZoneCount = input.GetVS32();
- }
- }
- /// <summary>
- /// 通知客户端服务器报错
- /// </summary>
- [MessageType(0x8605)]
- public class ServerExceptionB2C : Event, SystemMessage
- {
- public string Message;
- public string StackTrace;
- public ServerExceptionB2C() { }
- public ServerExceptionB2C(string message, string stackTrace)
- {
- this.Message = message;
- this.StackTrace = stackTrace;
- }
- public override void WriteExternal(IOutputStream output)
- {
- output.PutUTF(this.Message);
- output.PutUTF(this.StackTrace);
- }
- public override void ReadExternal(IInputStream input)
- {
- this.Message = input.GetUTF();
- this.StackTrace = input.GetUTF();
- }
- }
- [MessageType(0x8606)]
- public class UnitFollowAction : ObjectAction
- {
- public bool follow = false;
- public string reason = null;
- public UnitFollowAction() { }
- public UnitFollowAction(uint unit_id, bool guard)
- : base(unit_id)
- {
- this.follow = guard;
- }
- public UnitFollowAction(uint unit_id, bool guard, string reason)
- : base(unit_id)
- {
- this.follow = guard;
- this.reason = reason;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutBool(follow);
- output.PutUTF(reason);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.follow = input.GetBool();
- this.reason = input.GetUTF();
- }
- }
- #endregion
- //--------------------------------------------------------------------------
- /// <summary>
- /// 新增技能移动的协议
- /// </summary>
- [MessageType(0x8700)]
- public class SkillMove : ObjectAction
- {
- public int SkillID;
- public Vector2 SkillPos;
- public SkillMove() { }
- public SkillMove(uint unit_id, int skill_id, Vector2 vec):base(unit_id)
- {
- this.SkillID = skill_id;
- this.SkillPos = vec;
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutS32(SkillID);
- output.PutF32(SkillPos.X);
- output.PutF32(SkillPos.Y);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- this.SkillID = input.GetS32();
- this.SkillPos = new Vector2();
- this.SkillPos.SetX(input.GetF32());
- this.SkillPos.SetY(input.GetF32());
- }
- }
- /// <summary>
- /// 法术Dispose后,在播放一个过渡特效
- /// </summary>
- [MessageType(0x8701)]
- public class PlayDestoryEffect : ZoneEvent
- {
- public string EffectName;
- public float X;
- public float Y;
- public float Z;
- //rotation
- public float Direction;
- public PlayDestoryEffect() { }
- public PlayDestoryEffect(string effectName, float x, float y, float z, float direction)
- {
- EffectName = effectName;
- X = x;
- Y = y;
- Z = z;
- Direction = direction;
- }
- override public void WriteExternal(IOutputStream output)
- {
- output.PutUTF(EffectName);
- output.PutF32(X);
- output.PutF32(Y);
- output.PutF32(Z);
- output.PutF32(Direction);
- }
- override public void ReadExternal(IInputStream input)
- {
- this.EffectName = input.GetUTF();
- this.X = input.GetF32();
- this.Y = input.GetF32();
- this.Z = input.GetF32();
- this.Direction = input.GetF32();
- }
- }
-
- /// <summary>
- /// 随从瞬移
- /// </summary>
- [MessageType(0x8702)]
- public class PlayPetTeleportAction : ObjectAction
- {
- public PlayPetTeleportAction() { }
- override public void WriteExternal(IOutputStream output)
- {
- }
- override public void ReadExternal(IInputStream input)
- {
- }
- }
- /// <summary>
- /// 刷新玩家天赋相关信息
- ///
- /// </summary>
- [MessageType(0x8703)]
- public class RefreshTalnetInfo: PlayerSingleMsg
- {
- //根据不同职业,不同解读
- //战士:value:怒气值,lv:无
- //法师:value: 剑气值,lv:剑气层数
- public short value; //天赋值,每秒降低,服务器刷新
- public byte lv;
- public int lvUpdateTime; //等级最后刷新时间,变化不频繁,需要根据本地时间自己做进度效果(lv=0无)
- public RefreshTalnetInfo() { }
- public RefreshTalnetInfo(short value, byte lv = 0, int updateTime = 0)
- {
- this.value = value;
- this.lv = lv;
- this.lvUpdateTime = updateTime;
- }
- override public void WriteExternal(IOutputStream output)
- {
- output.PutS16(this.value);
- output.PutU8(this.lv);
- if(this.lv > 0)
- {
- output.PutS32(this.lvUpdateTime);
- }
- }
- override public void ReadExternal(IInputStream input)
- {
- this.value = input.GetS16();
- this.lv = input.GetU8();
- if(this.lv > 0)
- {
- this.lvUpdateTime = input.GetS32();
- }
- //System.Console.WriteLine("RefreshTalnetInfo: " + this.value + ", " + this.lv + ", " + this.lvUpdateTime);
- }
- }
- /// <summary>
- /// 刷新玩家卡牌珠相关信息
- /// </summary>
- [MessageType(0x8704)]
- public class RefreshCardInfo : PlayerSingleMsg
- {
- public byte[] cardData = new byte[(int)CardType.Max]; //0-3代表有
- public RefreshCardInfo()
- {
- for(int i = 0; i < (int)CardType.Max; i++)
- {
- cardData[i] = (byte)CardType.Max;
- }
- }
- override public void WriteExternal(IOutputStream output)
- {
- for(int i = 0; i < (int)CardType.Max; i++)
- {
- output.PutU8(cardData[i]);
- }
- //System.Console.WriteLine("--------RefreshCardInfo: " + cardData[0] + ", " + cardData[1] + ", " + cardData[2] + ", " + cardData[3]);
- }
- override public void ReadExternal(IInputStream input)
- {
- //System.Console.WriteLine("--------RefreshCardInfo");
- for (int i = 0; i < (int)CardType.Max; i++)
- {
- cardData[i] = input.GetU8();
- }
- //System.Console.WriteLine("--------RefreshCardInfo: " + cardData[0] + ", " + cardData[1] + ", " + cardData[2] + ", " + cardData[3]);
- }
- }
- /// <summary>
- /// 玩家卡牌释放逻辑
- /// </summary>
- [MessageType(0x8705)]
- public class PlayerLaunchCardSkill : PlayerSingleMsg
- {
- public int cardSkill;
- public CardType type;
- public byte layer;
- public byte[] cardData = new byte[(int)CardType.Max]; //0-3代表有
- public PlayerLaunchCardSkill() { }
- override public void WriteExternal(IOutputStream output)
- {
- output.PutS32(this.cardSkill);
- output.PutEnum8(type);
- output.PutU8(this.layer);
- for (int i = 0; i < (int)CardType.Max; i++)
- {
- output.PutU8(cardData[i]);
- }
- //System.Console.WriteLine("--------PlayerLaunchCardSkill: " + cardSkill + ", " + this.type);
- }
- override public void ReadExternal(IInputStream input)
- {
- //
- this.cardSkill = input.GetS32();
- this.type = input.GetEnum8<CardType>();
- this.layer = input.GetU8();
- for (int i = 0; i < (int)CardType.Max; i++)
- {
- cardData[i] = input.GetU8();
- }
- //System.Console.WriteLine("--------PlayerLaunchCardSkill: " + cardSkill + ", " + this.type);
- }
- }
- /// <summary>
- /// 刷新Boss卡牌珠相关信息
- /// </summary>
- [MessageType(0x8706)]
- public class RefreshBossCardInfo : ObjectEvent
- {
- public byte[] cardData = new byte[(int)CardType.Max]; //0-3代表有
- public RefreshBossCardInfo()
- {
- this.init();
- }
- public RefreshBossCardInfo(uint objId) : base(objId)
- {
- this.init();
- }
- private void init()
- {
- for (int i = 0; i < (int)CardType.Max; i++)
- {
- cardData[i] = (byte)CardType.Max;
- }
- }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- for (int i = 0; i < (int)CardType.Max; i++)
- {
- output.PutU8(cardData[i]);
- }
- //System.Console.WriteLine("RefreshBossCardInfo: " + this.object_id +", " + cardData[0] + ", " + cardData[1] + ", " + cardData[2] + ", " + cardData[3]);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- for (int i = 0; i < (int)CardType.Max; i++)
- {
- cardData[i] = input.GetU8();
- }
- //System.Console.WriteLine("objectID: " + this.object_id);
- //System.Console.WriteLine("--------RefreshBossCardInfo: " + this.object_id + ", " + cardData[0] + ", " + cardData[1] + ", " + cardData[2] + ", " + cardData[3]);
- }
- }
- /// <summary>
- /// 玩家卡牌释放逻辑
- /// </summary>
- [MessageType(0x8707)]
- public class BossTriggerCardSkill : ObjectEvent
- {
- public int cardSkill;
- public CardType type;
- public byte layer;
- public byte[] cardData = new byte[(int)CardType.Max]; //0-3代表有
- public BossTriggerCardSkill() { }
- public BossTriggerCardSkill(uint objId) : base(objId){ }
- override public void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutS32(this.cardSkill);
- output.PutEnum8(type);
- output.PutU8(this.layer);
- for (int i = 0; i < (int)CardType.Max; i++)
- {
- output.PutU8(cardData[i]);
- }
- //System.Console.WriteLine("BossTriggerCardSkill: " + this.object_id + ", " + cardData[0] + ", " + cardData[1] + ", " + cardData[2] + ", " + cardData[3]);
- }
- override public void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
-
- this.cardSkill = input.GetS32();
- this.type = input.GetEnum8<CardType>();
- this.layer = input.GetU8();
- for (int i = 0; i < (int)CardType.Max; i++)
- {
- cardData[i] = input.GetU8();
- }
- //System.Console.WriteLine("BossTriggerCardSkill: " + this.object_id + ", " + cardData[0] + ", " + cardData[1] + ", " + cardData[2] + ", " + cardData[3]);
- }
- }
- /// <summary>
- /// 单位PK模式改变通知.
- /// </summary>
- [MessageType(0x8708)]
- public class PlayerPKModeChangeEventB2C : ObjectEvent
- {
- public PKMode CurMode = PKMode.Peace;
- public PlayerPKModeChangeEventB2C() { }
- public PlayerPKModeChangeEventB2C(uint objId, PKMode mode) : base(objId)
- {
- this.CurMode = mode;
- }
- public override void WriteExternal(IOutputStream output)
- {
- base.WriteExternal(output);
- output.PutEnum8(CurMode);
- }
- public override void ReadExternal(IInputStream input)
- {
- base.ReadExternal(input);
- CurMode = input.GetEnum8<PKMode>();
- }
- }
- }
|