bundle.js 257 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775
  1. var laya = (function (exports) {
  2. 'use strict';
  3. class ResDic {
  4. constructor() {
  5. this._container = {};
  6. this._length = 0;
  7. }
  8. get container() {
  9. return this._container;
  10. }
  11. get size() {
  12. return this._length;
  13. }
  14. set(key, value) {
  15. if (!this._container.hasOwnProperty(key)) {
  16. this._length++;
  17. }
  18. this._container[key] = value;
  19. }
  20. has(key) {
  21. return this._container.hasOwnProperty(key) ? true : false;
  22. }
  23. get(key) {
  24. if (this._container.hasOwnProperty(key)) {
  25. return this._container[key];
  26. }
  27. else {
  28. return undefined;
  29. }
  30. }
  31. delete(key) {
  32. if (this._container.hasOwnProperty(key)) {
  33. delete this._container[key];
  34. this._length--;
  35. }
  36. }
  37. clear() {
  38. this._container = {};
  39. this._length = 0;
  40. }
  41. }
  42. var EventState;
  43. (function (EventState) {
  44. EventState[EventState["LoadComplete"] = 0] = "LoadComplete";
  45. EventState[EventState["SceneInit"] = 1] = "SceneInit";
  46. EventState[EventState["StageInit"] = 2] = "StageInit";
  47. EventState[EventState["StageCreateComplete"] = 3] = "StageCreateComplete";
  48. EventState[EventState["AnimatorEnd"] = 4] = "AnimatorEnd";
  49. EventState[EventState["Select"] = 5] = "Select";
  50. })(EventState || (EventState = {}));
  51. var StageState;
  52. (function (StageState) {
  53. StageState[StageState["Win"] = 0] = "Win";
  54. StageState[StageState["Lose"] = 1] = "Lose";
  55. StageState[StageState["Start"] = 2] = "Start";
  56. StageState[StageState["StageCreateComPlete"] = 3] = "StageCreateComPlete";
  57. StageState[StageState["Over"] = 4] = "Over";
  58. StageState[StageState["Shoot"] = 5] = "Shoot";
  59. StageState[StageState["CreatArrow"] = 6] = "CreatArrow";
  60. StageState[StageState["Revive"] = 7] = "Revive";
  61. StageState[StageState["Restart"] = 8] = "Restart";
  62. StageState[StageState["Press"] = 9] = "Press";
  63. StageState[StageState["UnPress"] = 10] = "UnPress";
  64. })(StageState || (StageState = {}));
  65. class EventManager {
  66. static EventOn(_mode, caller, fun, args = []) {
  67. EventManager.instance.on(EventState[_mode], caller, fun, args);
  68. }
  69. static EventOff(_mode, caller, fun, args = []) {
  70. EventManager.instance.off(EventState[_mode], caller, fun);
  71. }
  72. static EventTrigger(_mode, args = []) {
  73. EventManager.instance.event(EventState[_mode], args);
  74. }
  75. static StageOn(_mode, caller, fun, args = []) {
  76. EventManager.instance.on(StageState[_mode], caller, fun, args);
  77. }
  78. static StageOff(_mode, caller, fun, args = []) {
  79. EventManager.instance.off(StageState[_mode], caller, fun);
  80. }
  81. static StageTrigger(_mode, args = []) {
  82. EventManager.instance.event(StageState[_mode], args);
  83. }
  84. }
  85. EventManager.instance = new Laya.EventDispatcher();
  86. class AssetManager {
  87. constructor() {
  88. this.Boss = new ResDic();
  89. this.Player = new ResDic();
  90. this.Horse = new ResDic();
  91. this.Cap = new ResDic();
  92. this.Prop = new ResDic();
  93. this.Plane = new ResDic();
  94. this.Stone = new ResDic();
  95. this.Tree = new ResDic();
  96. this.Small_Fence = new ResDic();
  97. AssetManager.ins = this;
  98. EventManager.EventOn(EventState.LoadComplete, this, this.Init);
  99. }
  100. static get Instance() {
  101. if (AssetManager.ins) {
  102. return AssetManager.ins;
  103. }
  104. else {
  105. return new AssetManager();
  106. }
  107. }
  108. Init() {
  109. this.maincamera = this.mainscene.getChildByName("Main Camera");
  110. this.maincamera.transform.position = new Laya.Vector3(0, 10, -12);
  111. this.maincamera.transform.rotationEuler = new Laya.Vector3(-35.7, 180, 0);
  112. this.maincamera.enableHDR = false;
  113. this.Light = this.mainscene.getChildByName("Directional light");
  114. this.Light.intensity = 0.7;
  115. EventManager.EventTrigger(EventState.SceneInit);
  116. }
  117. }
  118. class ResourcesPath {
  119. }
  120. ResourcesPath.MainScene = "Game/res/MainScene/LayaScene_Mainscene/Conventional/Mainscene.ls";
  121. ResourcesPath.Boss = [
  122. "Game/res/Role/LayaScene_Role/Conventional/boss.lh"
  123. ];
  124. ResourcesPath.Player = [
  125. "Game/res/Role/LayaScene_Role/Conventional/player.lh"
  126. ];
  127. ResourcesPath.Horse = [
  128. "Game/res/Horse/LayaScene_Horse/Conventional/horse1.lh",
  129. "Game/res/Horse/LayaScene_Horse/Conventional/horse2.lh",
  130. "Game/res/Horse/LayaScene_Horse/Conventional/horse3.lh",
  131. "Game/res/Horse/LayaScene_Horse/Conventional/horse4.lh",
  132. "Game/res/Horse/LayaScene_Horse/Conventional/horse5.lh"
  133. ];
  134. ResourcesPath.Cap = [
  135. "Game/res/Cap/LayaScene_Cap/Conventional/cap1.lh",
  136. "Game/res/Cap/LayaScene_Cap/Conventional/cap2.lh",
  137. "Game/res/Cap/LayaScene_Cap/Conventional/cap3.lh",
  138. "Game/res/Cap/LayaScene_Cap/Conventional/cap4.lh",
  139. "Game/res/Cap/LayaScene_Cap/Conventional/cap5.lh"
  140. ];
  141. ResourcesPath.Prop = "Game/res/Prop/LayaScene_Prop/Conventional/Prop.lh";
  142. var Sprite3D = Laya.Sprite3D;
  143. var Vector3 = Laya.Vector3;
  144. class modelConfig {
  145. constructor(model) {
  146. this.modelcur = model;
  147. this.modelPos = model.transform.position.clone();
  148. this.modelRot = model.transform.rotation.clone();
  149. this.modelSca = model.transform.scale.clone();
  150. }
  151. }
  152. class GamePool {
  153. constructor() {
  154. this.modelpool = {};
  155. this.maxAcount = 30;
  156. GamePool.Ins = this;
  157. }
  158. static get Instance() {
  159. if (GamePool.Ins) {
  160. return GamePool.Ins;
  161. }
  162. else {
  163. return new GamePool();
  164. }
  165. }
  166. GetModel(_model, title) {
  167. var poolname = title + _model.name;
  168. if (this.modelpool[poolname] != null && this.modelpool[poolname] != undefined) {
  169. if (this.modelpool[poolname].length > 0) {
  170. var model1 = this.modelpool[poolname][0];
  171. this.modelpool[poolname].splice(0, 1);
  172. if (model1.modelcur.destroyed) {
  173. model1.modelcur = Sprite3D.instantiate(_model);
  174. if (!model1.modelcur.active) {
  175. model1.modelcur.active = true;
  176. }
  177. }
  178. model1.modelcur.active = true;
  179. model1.modelcur.transform.position = _model.transform.position.clone();
  180. model1.modelcur.transform.rotation = _model.transform.rotation.clone();
  181. model1.modelcur.transform.scale = _model.transform.scale.clone();
  182. return model1.modelcur;
  183. }
  184. else {
  185. var model = Sprite3D.instantiate(_model);
  186. model.active = true;
  187. return model;
  188. }
  189. }
  190. else {
  191. var model = Sprite3D.instantiate(_model);
  192. model.active = true;
  193. return model;
  194. }
  195. }
  196. RecoveryModel(model, title = "", modelstate = false) {
  197. if (model.destroyed) {
  198. return;
  199. }
  200. if (!modelstate && model.active == false) {
  201. return;
  202. }
  203. var poolname = title + model.name;
  204. if (this.modelpool[poolname] != null && this.modelpool[poolname] != undefined) {
  205. var modelnum = this.modelpool[poolname];
  206. if (modelnum.length > this.maxAcount) {
  207. model.destroy();
  208. return;
  209. }
  210. else {
  211. modelnum.push(new modelConfig(model));
  212. }
  213. }
  214. else {
  215. modelnum = [];
  216. modelnum.push(new modelConfig(model));
  217. this.modelpool[poolname] = modelnum;
  218. }
  219. model.transform.position = new Vector3(0, 0, -10000);
  220. model.removeSelf();
  221. model.active = false;
  222. }
  223. ResetsModelPool() {
  224. for (var Key in this.modelpool) {
  225. var model = this.modelpool[Key];
  226. for (var i = 0; i < model.length; i++) {
  227. model[i].modelcur.destroy();
  228. }
  229. }
  230. this.modelpool = {};
  231. }
  232. }
  233. var Vector3$1 = Laya.Vector3;
  234. class Transform3DHelper {
  235. static getForward(transform) {
  236. let forward = new Vector3$1();
  237. transform.getForward(forward);
  238. Laya.Vector3.scale(forward, -1, forward);
  239. Laya.Vector3.normalize(forward, forward);
  240. return forward;
  241. }
  242. }
  243. class GameTools {
  244. constructor() {
  245. GameTools.ins = this;
  246. }
  247. static get Instance() {
  248. if (GameTools.ins) {
  249. return GameTools.ins;
  250. }
  251. else {
  252. return new GameTools();
  253. }
  254. }
  255. lerp(form, to, t) {
  256. if (t <= 0) {
  257. return form;
  258. }
  259. else if (t >= 1) {
  260. return to;
  261. }
  262. var a = t * to + (1 - t) * form;
  263. return a;
  264. }
  265. SetCollider(setNode, CollisionGroup) {
  266. var numchild = setNode.numChildren;
  267. for (var i = 0; i < setNode.numChildren; i++) {
  268. var numchild2 = setNode.getChildAt(i).numChildren;
  269. if (numchild2 > 1) {
  270. this.SetCollider(setNode.getChildAt(i), CollisionGroup);
  271. }
  272. var physicsCollider = setNode.getChildAt(i).getComponent(Laya.PhysicsCollider);
  273. if (physicsCollider) {
  274. physicsCollider.collisionGroup = CollisionGroup;
  275. }
  276. }
  277. }
  278. EnemySetCollider(setNode, collisionGroup) {
  279. var collider = setNode.getChildByName("npcfrontcollider");
  280. var collider2 = setNode.getChildByName("npcrearcollider");
  281. var physicsCollider = collider.getComponent(Laya.PhysicsCollider);
  282. var physicsCollider2 = collider2.getComponent(Laya.PhysicsCollider);
  283. if (physicsCollider) {
  284. physicsCollider.collisionGroup = collisionGroup;
  285. }
  286. if (physicsCollider2) {
  287. physicsCollider2.collisionGroup = collisionGroup;
  288. }
  289. }
  290. PlayerSetCollider(setNode, collisionGroup) {
  291. var collider = setNode.getChildByName("playercollider");
  292. var physicsCollider = collider.getComponent(Laya.PhysicsCollider);
  293. if (physicsCollider) {
  294. physicsCollider.collisionGroup = collisionGroup;
  295. }
  296. }
  297. HostageSetCollider(setNode, collisionGroup) {
  298. var collider = setNode.getChildByName("hostagecollider");
  299. var physicsCollider = collider.getComponent(Laya.PhysicsCollider);
  300. if (physicsCollider) {
  301. physicsCollider.collisionGroup = collisionGroup;
  302. }
  303. }
  304. static RandomNumber(from, to) {
  305. if (from >= to) {
  306. return 0;
  307. }
  308. var size = to - from;
  309. var curNumber = Math.random() * size + from;
  310. return curNumber;
  311. }
  312. static RandomANumber(from, to) {
  313. if (from >= to) {
  314. return 0;
  315. }
  316. var size = to - from;
  317. var curNumber = Math.random() * size + from;
  318. return Math.floor(curNumber);
  319. }
  320. static GetMoney(_num, _pos = null, _completeHandle = null) {
  321. if (_num == 0)
  322. return;
  323. var fafaafsfa = new Laya.Box;
  324. fafaafsfa.width = 400;
  325. fafaafsfa.height = 100;
  326. fafaafsfa.pivotX = fafaafsfa.width / 2;
  327. fafaafsfa.pivotY = fafaafsfa.height / 2;
  328. if (_pos == null) {
  329. _pos = new Laya.Vector2(Laya.stage.width / 2, Laya.stage.height / 2);
  330. }
  331. fafaafsfa.pos(_pos.x, _pos.y);
  332. var aafafaffa = new Laya.Image;
  333. aafafaffa.skin = "game/qiandao_1_7.png";
  334. aafafaffa.width = 60;
  335. aafafaffa.height = 60;
  336. aafafaffa.left = 50;
  337. aafafaffa.y = 10;
  338. fafaafsfa.addChild(aafafaffa);
  339. var faasfafsafs = new Laya.Text;
  340. faasfafsafs.width = 300;
  341. faasfafsafs.height = 50;
  342. faasfafsafs.align = "center";
  343. faasfafsafs.valign = "middle";
  344. faasfafsafs.font = "Microsoft YaHei";
  345. faasfafsafs.fontSize = 40;
  346. faasfafsafs.color = "#FFFFFF";
  347. faasfafsafs.bold = true;
  348. faasfafsafs.font = "Microsoft YaHei";
  349. faasfafsafs.text = "金币 +" + _num;
  350. faasfafsafs.x = 60;
  351. faasfafsafs.y = 10;
  352. fafaafsfa.addChild(faasfafsafs);
  353. Laya.stage.addChild(fafaafsfa);
  354. var faasfsaf = Laya.Tween.to(fafaafsfa, { y: fafaafsfa.y - 200 }, 1500, Laya.Ease.expoInOut, Laya.Handler.create(this, () => {
  355. faasfsaf.clear();
  356. fafaafsfa.destroy();
  357. if (_completeHandle) {
  358. _completeHandle.run();
  359. }
  360. }), 100);
  361. }
  362. static TweenText(faafssfafsa, _hight, _completeHandle = null, hide = true, _duration = 500) {
  363. var afasafsafsfa = new Laya.Text();
  364. afasafsafsfa.width = faafssfafsa.size.x;
  365. afasafsafsfa.height = faafssfafsa.size.y;
  366. afasafsafsfa.align = "center";
  367. afasafsafsfa.valign = "middle";
  368. afasafsafsfa.font = "Microsoft YaHei";
  369. afasafsafsfa.fontSize = faafssfafsa.fontSize;
  370. afasafsafsfa.pivotX = afasafsafsfa.width / 2;
  371. afasafsafsfa.pivotY = afasafsafsfa.height / 2;
  372. afasafsafsfa.color = "#5ad122";
  373. afasafsafsfa.bold = true;
  374. afasafsafsfa.stroke = 5;
  375. afasafsafsfa.strokeColor = "#ffffff";
  376. if (faafssfafsa.color) {
  377. faafssfafsa.color = faafssfafsa.color;
  378. }
  379. afasafsafsfa.text = faafssfafsa.message;
  380. afasafsafsfa.zOrder = 1;
  381. Laya.stage.addChildAt(afasafsafsfa, Laya.stage.numChildren - 1);
  382. afasafsafsfa.pos(faafssfafsa.pos.x, faafssfafsa.pos.y);
  383. var tween = Laya.Tween.to(afasafsafsfa, { y: afasafsafsfa.y - _hight, update: new Laya.Handler(this, function () {
  384. }) }, _duration, Laya.Ease.expoInOut, Laya.Handler.create(this, function () {
  385. tween.clear();
  386. if (hide) {
  387. afasafsafsfa.destroy();
  388. }
  389. if (_completeHandle) {
  390. _completeHandle.run();
  391. }
  392. }));
  393. if (hide) {
  394. Laya.Tween.to(afasafsafsfa, { alpha: 0.4 }, 500);
  395. }
  396. return afasafsafsfa;
  397. }
  398. static StationTweenText(faafssfafsa, _hight, _completeHandle = null, hide = true, _duration = 500) {
  399. var afasafsafsfa = new Laya.Text();
  400. afasafsafsfa.width = faafssfafsa.size.x;
  401. afasafsafsfa.height = faafssfafsa.size.y;
  402. afasafsafsfa.align = "center";
  403. afasafsafsfa.valign = "middle";
  404. afasafsafsfa.font = "Microsoft YaHei";
  405. afasafsafsfa.fontSize = 50;
  406. afasafsafsfa.pivotX = afasafsafsfa.width / 2;
  407. afasafsafsfa.pivotY = afasafsafsfa.height / 2;
  408. afasafsafsfa.color = "#5ad122";
  409. afasafsafsfa.bold = true;
  410. afasafsafsfa.stroke = 5;
  411. afasafsafsfa.strokeColor = "#ffffff";
  412. if (faafssfafsa.color) {
  413. faafssfafsa.color = faafssfafsa.color;
  414. }
  415. afasafsafsfa.text = faafssfafsa.message;
  416. afasafsafsfa.zOrder = 1;
  417. Laya.stage.addChildAt(afasafsafsfa, Laya.stage.numChildren - 1);
  418. afasafsafsfa.pos(faafssfafsa.pos.x, faafssfafsa.pos.y);
  419. var tween = Laya.Tween.to(afasafsafsfa, { y: afasafsafsfa.y - _hight, update: new Laya.Handler(this, function () {
  420. }) }, _duration, Laya.Ease.expoInOut, Laya.Handler.create(this, function () {
  421. tween.clear();
  422. if (hide) {
  423. afasafsafsfa.destroy();
  424. }
  425. if (_completeHandle) {
  426. _completeHandle.run();
  427. }
  428. }));
  429. if (hide) {
  430. Laya.Tween.to(afasafsafsfa, { alpha: 0.4 }, 10000);
  431. }
  432. return afasafsafsfa;
  433. }
  434. static tweenMove(transform, targPos, delay, ease, complete) {
  435. let curPos = transform.position.clone();
  436. return Laya.Tween.to(curPos, {
  437. x: targPos.x,
  438. y: targPos.y,
  439. z: targPos.z,
  440. update: new Laya.Handler(this, () => {
  441. transform.position = curPos.clone();
  442. })
  443. }, delay, ease, complete);
  444. }
  445. static tweenRotate(transform, targEuler, delay, ease, complete) {
  446. let curEuler = transform.rotationEuler.clone();
  447. return Laya.Tween.to(curEuler, {
  448. x: targEuler.x,
  449. y: targEuler.y,
  450. z: targEuler.z,
  451. update: new Laya.Handler(this, () => {
  452. transform.rotationEuler = curEuler.clone();
  453. })
  454. }, delay, ease, complete);
  455. }
  456. }
  457. var AccountUser;
  458. (function (AccountUser) {
  459. AccountUser[AccountUser["buyed_kun"] = 0] = "buyed_kun";
  460. AccountUser[AccountUser["diamond"] = 1] = "diamond";
  461. AccountUser[AccountUser["equip_themes"] = 2] = "equip_themes";
  462. AccountUser[AccountUser["favorite_times"] = 3] = "favorite_times";
  463. AccountUser[AccountUser["game_times"] = 4] = "game_times";
  464. AccountUser[AccountUser["get_themes"] = 5] = "get_themes";
  465. AccountUser[AccountUser["list_kun"] = 6] = "list_kun";
  466. AccountUser[AccountUser["moeny"] = 7] = "moeny";
  467. AccountUser[AccountUser["progress_themes"] = 8] = "progress_themes";
  468. AccountUser[AccountUser["revival"] = 9] = "revival";
  469. AccountUser[AccountUser["stage"] = 10] = "stage";
  470. })(AccountUser || (AccountUser = {}));
  471. class PlayerData {
  472. constructor(_token, _config, _appSetting, _user, _userbase, _useInvite, _user_stage = null, _user_sign, _user_achievement, lottery) {
  473. this.openid = "";
  474. this.userId = "";
  475. this.zhengshu = _token;
  476. this.netzheshe = _appSetting;
  477. this.account = _user;
  478. this.accountssss = _userbase;
  479. this.qiandao = _user_sign;
  480. this.renwu = _user_achievement;
  481. this.userId = this.account["user_id"];
  482. this.openid = this.accountssss["openid"];
  483. this.m_invite = _useInvite;
  484. this.lottery = lottery;
  485. console.log("user_id:" + this.userId);
  486. }
  487. GainCollocation(_type) {
  488. return this.peizhis[_type];
  489. }
  490. GainAccount(_type) {
  491. return this.account[_type];
  492. }
  493. get fenxiang() {
  494. return this.netzheshe["share"] == "1";
  495. }
  496. get Invincible() {
  497. return Number(this.netzheshe["Invincible"]);
  498. }
  499. get CheckScene() {
  500. return this.netzheshe["checkscene"] == "1";
  501. }
  502. get Cheat() {
  503. return this.netzheshe["cheat"] == "1";
  504. }
  505. get Banner() {
  506. return this.netzheshe["Banner"] == "1";
  507. }
  508. get wudaoshijian() {
  509. return Number(this.netzheshe["wudaoshijian"]);
  510. }
  511. GetUser(_type) {
  512. var type = AccountUser[_type];
  513. return this.account[type];
  514. }
  515. get NpcRunDistance() {
  516. return Number(this.netzheshe["NpcRunDistance"]);
  517. }
  518. get NpcAtkDistance() {
  519. return Number(this.netzheshe["NpcAtkDistance"]);
  520. }
  521. get NpcChaseDistance() {
  522. return Number(this.netzheshe["NpcChaseDistance"]);
  523. }
  524. get NpcRushDistance() {
  525. return Number(this.netzheshe["NpcRushDistance"]);
  526. }
  527. get BossAtkInterval() {
  528. return Number(this.netzheshe["BossAtkInterval"]);
  529. }
  530. get NpcSpeed() {
  531. return Number(this.netzheshe["NpcSpeed"]);
  532. }
  533. get HostageSpeed() {
  534. return Number(this.netzheshe["HostageSpeed"]);
  535. }
  536. get ArrowSpeed() {
  537. return Number(this.netzheshe["ArrowSpeed"]);
  538. }
  539. get BossDistance() {
  540. return Number(this.netzheshe["ArrowSpeed"]);
  541. }
  542. get BossSpeed() {
  543. return Number(this.netzheshe["BossSpeed"]);
  544. }
  545. get PlayerDamage() {
  546. return Number(this.netzheshe["PlayerDamage"]);
  547. }
  548. get MaxBossDistance() {
  549. return Number(this.netzheshe["MaxBossDistance"]);
  550. }
  551. get MinBossDistance() {
  552. return Number(this.netzheshe["MinBossDistance"]);
  553. }
  554. get ShareContent() {
  555. return this.netzheshe["sharecontent"];
  556. }
  557. get DirRoatationLerp() {
  558. return Number(this.netzheshe["DirRoatationLerp"]);
  559. }
  560. get DirMoveLerp() {
  561. return Number(this.netzheshe["DirMoveLerp"]);
  562. }
  563. get CurTouchsmoothness() {
  564. return Number(this.netzheshe["curtouchsmoothness"]);
  565. }
  566. get CurTouchsize() {
  567. return Number(this.netzheshe["curtouchsize"]);
  568. }
  569. get NPCRushSpeed() {
  570. return Number(this.netzheshe["NPCRushSpeed"]);
  571. }
  572. get Range() {
  573. return Number(this.netzheshe["Range"]);
  574. }
  575. get CanStageShake() {
  576. return this.netzheshe["canstageshake"] == "1";
  577. }
  578. GlobalData(_key) {
  579. var dataarray = [];
  580. var _global = this.GainCollocation("global");
  581. for (var key in _global) {
  582. dataarray.push(_global[key]);
  583. }
  584. for (let i = 0; i < dataarray.length; i++) {
  585. if (_key == dataarray[i].key) {
  586. return Number(dataarray[i].value);
  587. }
  588. }
  589. }
  590. HasEquip(_id) {
  591. var data = this.GainAccount("get_themes");
  592. for (var i = 0; i < data.length; i++) {
  593. var hd = data[i];
  594. if (_id == hd) {
  595. return true;
  596. }
  597. }
  598. return false;
  599. }
  600. GetProgress(_id) {
  601. var config = this.account["progress_themes"];
  602. var progress = config[_id] ? config[_id] : 0;
  603. return progress;
  604. }
  605. }
  606. class CheckMain {
  607. }
  608. CheckMain.Creat = false;
  609. CheckMain.ZSSdkCreat = false;
  610. class FengXiang {
  611. constructor() {
  612. FengXiang.instance = this;
  613. }
  614. static get Instance() {
  615. if (FengXiang.instance == null) {
  616. FengXiang.instance = new FengXiang();
  617. }
  618. return FengXiang.instance;
  619. }
  620. ;
  621. kaishifengxiang(callBack) {
  622. FengXiang.kaishifengxiangshijian = new Date().getTime();
  623. FengXiang.fengxiangzhong = true;
  624. FengXiang.callback = callBack;
  625. }
  626. RegFenxiang() {
  627. if (Laya.Browser.window.wx == null) {
  628. return;
  629. }
  630. Laya.Browser.window.wx.onShow(function (option) {
  631. if (FengXiang.fengxiangzhong) {
  632. FengXiang.fengxiangzhong = false;
  633. let time = new Date().getTime();
  634. let wait = (time - FengXiang.kaishifengxiangshijian) / 1000;
  635. let shareSuccess = false;
  636. if (wait >= 4) {
  637. if (wait < 6) {
  638. shareSuccess = (Math.random() > 0.7) ? false : true;
  639. }
  640. else {
  641. shareSuccess = true;
  642. }
  643. }
  644. else {
  645. shareSuccess = false;
  646. }
  647. if (shareSuccess == false) {
  648. Laya.Browser.window.wx.showToast({ title: "请重试一次" });
  649. FengXiang.callback(false);
  650. }
  651. else {
  652. Laya.Browser.window.wx.showToast({ title: "分享成功" });
  653. FengXiang.callback(true);
  654. }
  655. }
  656. });
  657. }
  658. }
  659. FengXiang.fengxiangchenggongshijian = 0;
  660. FengXiang.fengxiangzhong = false;
  661. class WXSDK {
  662. constructor() {
  663. WXSDK.ins = this;
  664. }
  665. static get Instance() {
  666. if (WXSDK.ins) {
  667. return WXSDK.ins;
  668. }
  669. else {
  670. return new WXSDK();
  671. }
  672. }
  673. static Init() {
  674. }
  675. static DengLu(_complete) {
  676. var that = this;
  677. Laya.Browser.window.wx.login({
  678. success: function (res) {
  679. if (res.code) {
  680. FengXiang.Instance.RegFenxiang();
  681. console.log("微信登陆成功----");
  682. that.codeValue = res.code;
  683. console.log("shareid:" + WXSDK.shareOpenId);
  684. new AccountManager(res.code, "", "", "", 0, "", "", "", "", WXSDK.shareOpenId, WXSDK.shareOpenId, Main.Ver);
  685. _complete(res);
  686. }
  687. else {
  688. WXSDK.DengLu(WXSDK.DengLu);
  689. console.log('wx no code' + res.errMsg);
  690. }
  691. },
  692. fail: function (res) { console.log("wx.login: failed, res=" + res); }
  693. });
  694. }
  695. static ShowTxt(text) {
  696. if (Laya.Browser.onWeiXin) {
  697. Laya.Browser.window.wx.showToast({ title: text });
  698. }
  699. else {
  700. console.log(text);
  701. }
  702. }
  703. static OnShow(cb) {
  704. if (!Laya.Browser.onWeiXin)
  705. return;
  706. Laya.Browser.window.wx.onShow(cb);
  707. }
  708. static OffShow(cb) {
  709. if (!Laya.Browser.onWeiXin)
  710. return;
  711. Laya.Browser.window.wx.offShow(cb);
  712. }
  713. static ShortShake() {
  714. Laya.Browser.window.wx.vibrateShort({});
  715. }
  716. static LongShake() {
  717. Laya.Browser.window.wx.vibrateLong({});
  718. }
  719. static Shake(_short = true) {
  720. if (Laya.Browser.onWeiXin && WXSDK.shake) {
  721. if (_short) {
  722. this.ShortShake();
  723. }
  724. else {
  725. this.LongShake();
  726. }
  727. }
  728. }
  729. static LoadSubPackage(name, _complete) {
  730. if (Laya.Browser.onWeiXin) {
  731. const loadTask = Laya.Browser.window.wx.loadSubpackage({
  732. name: 'Game',
  733. success: function (res) {
  734. _complete && _complete(true);
  735. console.log("分包加载成功");
  736. },
  737. fail: function (res) {
  738. _complete && _complete(false);
  739. console.log("分包加载失败");
  740. }
  741. });
  742. }
  743. else {
  744. console.log("未进行分包加载");
  745. _complete && _complete(true);
  746. }
  747. }
  748. static stageShake(callBack = null, speed = 32) {
  749. if (this.isShake || !this.canshakestage)
  750. return;
  751. this.isShake = true;
  752. var point = new Laya.Vector2(Laya.stage.x, Laya.stage.y);
  753. Laya.stage.timerLoop(speed, this, this.shakeObject, [point, callBack]);
  754. }
  755. static shakeObject(_point, _callBack) {
  756. var count = (this.num++) % 4;
  757. this.offsetArr[this.num % 2] = count < 2 ? 0 : this.offset;
  758. Laya.stage.x = this.offsetArr[0] + _point.x;
  759. Laya.stage.y = this.offsetArr[1] + _point.y;
  760. if (this.num > (this.times * 4 + 1)) {
  761. Laya.stage.clearTimer(this, this.shakeObject);
  762. Laya.stage.pos(0, 0);
  763. this.num = 0;
  764. this.isShake = false;
  765. if (_callBack != null) {
  766. _callBack();
  767. }
  768. }
  769. }
  770. static UpdateGuide(ShowGuide = 0) {
  771. var kvDataList = new Array();
  772. let date = new Date().getTime();
  773. var myValue = JSON.stringify({
  774. "guide": {
  775. "ShowGuide": ShowGuide,
  776. "update_time": date.toString()
  777. }
  778. });
  779. kvDataList.push({ key: "ShowGuide", value: myValue });
  780. if (Laya.Browser.window.wx) {
  781. Laya.Browser.window.wx.setUserCloudStorage({
  782. KVDataList: kvDataList,
  783. success: r => {
  784. console.log("KVDATALIST---", kvDataList);
  785. console.log("上传新手指引成功:" + ShowGuide);
  786. }
  787. });
  788. }
  789. }
  790. static UpdateScore(max_score) {
  791. var kvDataList = new Array();
  792. let date = new Date().getTime();
  793. var myValue = JSON.stringify({
  794. "wxgame": {
  795. "max_score": max_score,
  796. "update_time": date.toString(),
  797. }
  798. });
  799. kvDataList.push({ key: "max_score", value: myValue });
  800. if (Laya.Browser.window.wx) {
  801. Laya.Browser.window.wx.setUserCloudStorage({
  802. KVDataList: kvDataList,
  803. success: r => {
  804. console.log("KVDATALIST---", kvDataList);
  805. console.log("上传分数成功:" + max_score);
  806. }
  807. });
  808. }
  809. }
  810. static fengxiangtupian(callback) {
  811. if (Laya.Browser.window.wx == null) {
  812. return;
  813. }
  814. var _title = "有人@你,一起骑马仗箭走天涯";
  815. var t = AccountManager.Instance.ServerTime;
  816. Laya.Browser.window.wx.aldShareAppMessage({
  817. title: _title,
  818. imageUrl: "Game/res/textrue/share.jpg",
  819. query: "userId=" + AccountManager.Instance.curplayerData.userId + "_" + t + "_" + Math.floor(9999 * Math.random()).toString()
  820. });
  821. }
  822. static ShareContent() {
  823. return AccountManager.Instance.curplayerData.ShareContent;
  824. }
  825. static AldEvent(eventName, key = "用户id", value = "") {
  826. if (!Laya.Browser.onWeiXin)
  827. return;
  828. Laya.Browser.window.wx.aldSendEvent(eventName, { key: value });
  829. }
  830. static AldStart(stageId) {
  831. if (!Laya.Browser.onWeiXin)
  832. return;
  833. Laya.Browser.window.wx.aldStage.onStart({
  834. stageId: stageId,
  835. stageName: "第" + stageId + "关",
  836. });
  837. }
  838. static AldEnd(stageId, isComplete) {
  839. if (!Laya.Browser.onWeiXin)
  840. return;
  841. let event = isComplete ? "complete" : "fail";
  842. let desc = isComplete ? "关卡完成" : "关卡失败";
  843. Laya.Browser.window.wx.aldStage.onEnd({
  844. stageId: stageId,
  845. stageName: "第" + stageId + "关",
  846. event: event,
  847. params: {
  848. desc: desc
  849. }
  850. });
  851. }
  852. }
  853. WXSDK.codeValue = "";
  854. WXSDK.shareOpenId = "";
  855. WXSDK.openId = 0;
  856. WXSDK.shareScene = "";
  857. WXSDK.uid = "123";
  858. WXSDK.querychannel = "";
  859. WXSDK.referrerInfoappId = "";
  860. WXSDK.shake = true;
  861. WXSDK.times = 1.3;
  862. WXSDK.num = 0;
  863. WXSDK.offsetArr = [0, 0];
  864. WXSDK.offset = 14;
  865. WXSDK.canshakestage = false;
  866. var REG = Laya.ClassUtils.regClass;
  867. var ui;
  868. (function (ui) {
  869. class CompleteViewUI extends Laya.Scene {
  870. constructor() { super(); }
  871. createChildren() {
  872. super.createChildren();
  873. this.createView(CompleteViewUI.uiView);
  874. }
  875. }
  876. CompleteViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Image", "props": { "top": 0, "skin": "Main/chunhei.png", "sizeGrid": "12,14,15,10", "right": 0, "name": "BG", "left": 0, "bottom": 0 }, "compId": 14 }, { "type": "Image", "props": { "y": 156, "x": 360, "width": 193, "var": "winimage", "skin": "Main/shenglijiemian-1-1.png", "pivotY": 114, "pivotX": 97, "height": 227 }, "compId": 4 }, { "type": "Image", "props": { "y": 156, "x": 360, "width": 191, "var": "loseimage", "skin": "Main/shibai-1-1.png", "pivotY": 114, "pivotX": 96, "height": 227 }, "compId": 5 }, { "type": "Image", "props": { "y": 220, "x": 360, "width": 152, "var": "reviveimage", "skin": "Main/fuhuo-1-1.png", "pivotY": 37, "pivotX": 76, "height": 74 }, "compId": 7 }, { "type": "Box", "props": { "y": 327, "x": 360, "width": 249, "pivotY": 43, "pivotX": 125, "height": 85 }, "compId": 12, "child": [{ "type": "Image", "props": { "y": 11.5, "x": 0, "skin": "Main/zhujiemian-1-8.png" }, "compId": 11 }, { "type": "Text", "props": { "y": 41, "x": 156, "width": 201, "var": "goldnum", "valign": "middle", "text": "999", "pivotY": 31, "pivotX": 101, "height": 62, "fontSize": 50, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 13 }] }, { "type": "Box", "props": { "y": 591, "x": 360, "width": 623, "visible": true, "height": 440, "anchorY": 0.5, "anchorX": 0.5 }, "compId": 16, "child": [{ "type": "Image", "props": { "top": 0, "skin": "Main/chunhei.png", "sizeGrid": "13,13,14,12", "right": 0, "name": "BG", "left": 0, "bottom": 0 }, "compId": 17 }, { "type": "List", "props": { "y": 220, "x": 312, "width": 534, "var": "PushList", "spaceY": 40, "spaceX": 40, "pivotY": 221, "pivotX": 267, "height": 441 }, "compId": 18, "child": [{ "type": "Box", "props": { "y": 14, "x": 0, "width": 150, "renderType": "render", "height": 185 }, "compId": 19, "child": [{ "type": "Image", "props": { "y": 75, "x": 75, "width": 150, "pivotY": 75, "pivotX": 75, "name": "icon", "height": 150 }, "compId": 20 }, { "type": "Image", "props": { "y": 149, "x": 0, "width": 151, "name": "bottom", "height": 35 }, "compId": 23 }, { "type": "Text", "props": { "y": 166, "x": 76, "width": 151, "valign": "middle", "text": "冲冲冲冲冲冲", "pivotY": 18, "pivotX": 76, "name": "name", "height": 36, "fontSize": 25, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 21 }, { "type": "Button", "props": { "y": 90, "x": 76, "width": 151, "pivotY": 90, "pivotX": 76, "name": "btn", "height": 184 }, "compId": 22 }, { "type": "Image", "props": { "y": -8, "x": 76, "skin": "Push/icon-hot.png", "name": "remen" }, "compId": 24 }, { "type": "Script", "props": { "runtime": "Tools/ListItem.ts" }, "compId": 27 }] }] }] }, { "type": "Box", "props": { "x": 363, "width": 330, "var": "BtnBox", "pivotY": 124, "pivotX": 165, "height": 222, "bottom": 350 }, "compId": 28, "child": [{ "type": "Button", "props": { "y": 84, "x": 162, "width": 313, "var": "NextLevelBtn", "stateNum": 1, "skin": "Main/shenglijiemian-1-2.png", "pivotY": 58, "pivotX": 157, "height": 116 }, "compId": 8 }, { "type": "Button", "props": { "y": 84, "x": 165, "width": 313, "var": "ReviveBtn", "stateNum": 1, "skin": "Main/fuhuo-1-2.png", "pivotY": 58, "pivotX": 157, "height": 116 }, "compId": 9 }, { "type": "Button", "props": { "y": 84, "x": 165, "width": 313, "var": "TryAgainBtn", "stateNum": 1, "skin": "Main/shibai-1-2.png", "pivotY": 58, "pivotX": 157, "height": 116 }, "compId": 10 }, { "type": "Button", "props": { "y": 181, "x": 162, "var": "NoBtn", "stateNum": 1, "skin": "Main/no.png", "anchorY": 0.5, "anchorX": 0.5 }, "compId": 15 }] }], "loadList": ["Main/chunhei.png", "Main/shenglijiemian-1-1.png", "Main/shibai-1-1.png", "Main/fuhuo-1-1.png", "Main/zhujiemian-1-8.png", "Push/icon-hot.png", "Main/shenglijiemian-1-2.png", "Main/fuhuo-1-2.png", "Main/shibai-1-2.png", "Main/no.png"], "loadList3D": [] };
  877. ui.CompleteViewUI = CompleteViewUI;
  878. REG("ui.CompleteViewUI", CompleteViewUI);
  879. class ExportViewUI extends Laya.Scene {
  880. constructor() { super(); }
  881. createChildren() {
  882. super.createChildren();
  883. this.createView(ExportViewUI.uiView);
  884. }
  885. }
  886. ExportViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Image", "props": { "top": 0, "skin": "Main/chunhei2.png", "sizeGrid": "25,16,29,14", "right": 0, "name": "BG", "left": 0, "bottom": 0 }, "compId": 3 }, { "type": "Box", "props": { "y": 223, "right": 25, "name": "HBox", "left": 25, "height": 150, "anchorY": 0.5, "anchorX": 0.5 }, "compId": 4, "child": [{ "type": "Image", "props": { "y": 0, "skin": "Push/bg-box.png", "sizeGrid": "33,35,44,42", "right": 0, "left": 0, "height": 149 }, "compId": 11 }, { "type": "Image", "props": { "y": -32, "x": 335, "width": 230, "skin": "Push/title-friend.png", "pivotY": 16, "pivotX": 115, "height": 32 }, "compId": 5 }, { "type": "List", "props": { "var": "HList", "spaceX": 16, "right": 0, "repeatY": 1, "left": 0, "height": 150 }, "compId": 6, "child": [{ "type": "Box", "props": { "width": 120, "renderType": "render", "height": 150 }, "compId": 7, "child": [{ "type": "Image", "props": { "width": 120, "name": "icon", "height": 120 }, "compId": 8 }, { "type": "Text", "props": { "y": 135, "x": 60, "width": 121, "valign": "middle", "text": "冲冲冲冲冲冲", "pivotY": 15, "pivotX": 61, "name": "name", "height": 30, "fontSize": 20, "font": "Microsoft YaHei", "align": "center", "runtime": "laya.display.Text" }, "compId": 9 }, { "type": "Button", "props": { "y": 0, "x": 0, "width": 120, "name": "btn", "height": 141 }, "compId": 10 }, { "type": "Script", "props": { "y": 0, "x": 0, "runtime": "Tools/ListItem.ts" }, "compId": 26 }] }] }] }, { "type": "Box", "props": { "top": 400, "right": 25, "name": "VBox", "left": 25, "bottom": 0, "anchorY": 0.5, "anchorX": 0.5 }, "compId": 12, "child": [{ "type": "Image", "props": { "y": -32, "x": 335, "width": 230, "skin": "Push/title-recommend.png", "pivotY": 16, "pivotX": 115, "height": 32 }, "compId": 13 }, { "type": "List", "props": { "var": "VList", "top": 0, "spaceY": 40, "spaceX": 30, "right": 0, "left": 0, "bottom": 0 }, "compId": 14, "child": [{ "type": "Box", "props": { "y": 10, "x": 0, "width": 200, "renderType": "render", "height": 240 }, "compId": 15, "child": [{ "type": "Image", "props": { "top": 0, "skin": "Push/bg-box.png", "sizeGrid": "24,27,42,16", "right": 0, "left": 0, "bottom": 0 }, "compId": 16 }, { "type": "Image", "props": { "y": 221, "x": 100, "width": 200, "pivotY": 21, "pivotX": 100, "name": "bottom", "height": 41 }, "compId": 20 }, { "type": "Image", "props": { "y": 90, "x": 90, "width": 200, "pivotY": 90, "pivotX": 90, "name": "icon", "height": 200 }, "compId": 17 }, { "type": "Text", "props": { "y": 220, "x": 101, "width": 199, "valign": "middle", "text": "冲冲冲冲冲冲", "pivotY": 20, "pivotX": 100, "name": "name", "height": 40, "fontSize": 25, "font": "Microsoft YaHei", "align": "center", "runtime": "laya.display.Text" }, "compId": 18 }, { "type": "Button", "props": { "y": 121, "x": 100, "width": 200, "pivotY": 121, "pivotX": 100, "name": "btn", "height": 241 }, "compId": 19 }, { "type": "Image", "props": { "y": 17, "x": 170.5, "width": 82, "skin": "Push/icon-hot.png", "pivotY": 24, "pivotX": 41, "name": "remen", "height": 47 }, "compId": 21 }, { "type": "Script", "props": { "runtime": "Tools/ListItem.ts" }, "compId": 25 }] }] }] }, { "type": "Button", "props": { "x": 371, "width": 349, "var": "CloseExportBtn", "stateNum": 1, "skin": "Push/btn-continue-new.png", "pivotY": 80, "pivotX": 175, "height": 160, "bottom": 200 }, "compId": 22 }], "loadList": ["Main/chunhei2.png", "Push/bg-box.png", "Push/title-friend.png", "Push/title-recommend.png", "Push/icon-hot.png", "Push/btn-continue-new.png"], "loadList3D": [] };
  887. ui.ExportViewUI = ExportViewUI;
  888. REG("ui.ExportViewUI", ExportViewUI);
  889. class InGameViewUI extends Laya.Scene {
  890. constructor() { super(); }
  891. createChildren() {
  892. super.createChildren();
  893. this.createView(InGameViewUI.uiView);
  894. }
  895. }
  896. InGameViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "ProgressBar", "props": { "y": 107, "x": 47, "var": "GoalProgress", "skin": "Main/zhujiemian-1-4.png" }, "compId": 7, "child": [{ "type": "Text", "props": { "y": 0, "x": 0, "width": 120, "valign": "middle", "text": "0", "strokeColor": "#050404", "stroke": 2, "name": "goal", "height": 46, "fontSize": 36, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 10 }, { "type": "Image", "props": { "y": 0, "x": -18, "skin": "Main/zhujiemian-1-10.png" }, "compId": 11 }] }, { "type": "Box", "props": { "y": 137, "x": 620, "width": 201, "pivotY": 25, "pivotX": 101, "height": 50 }, "compId": 9, "child": [{ "type": "Image", "props": { "y": 23, "x": 121, "width": 160, "skin": "Main/zhujiemian-1-9.png", "pivotY": 23, "pivotX": 80, "height": 46 }, "compId": 14 }, { "type": "Image", "props": { "y": -4, "x": 12, "skin": "Main/zhujiemian-1-8.png" }, "compId": 15 }, { "type": "Text", "props": { "y": 0, "x": 65, "width": 137, "var": "GoldNum", "valign": "middle", "text": "9999", "height": 46, "fontSize": 30, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 16 }] }, { "type": "Box", "props": { "x": 360, "width": 568, "var": "Guide1", "height": 282, "bottom": 350, "anchorY": 0.5, "anchorX": 0.5 }, "compId": 17, "child": [{ "type": "Image", "props": { "y": 141, "x": 284, "width": 506, "skin": "Main/-2.png", "pivotY": 9, "pivotX": 253, "height": 18 }, "compId": 19 }, { "type": "Image", "props": { "y": 208, "x": 55, "width": 348, "skin": "Main/Hand.png", "scaleY": 0.3, "scaleX": 0.3, "pivotY": 258, "pivotX": 174, "height": 485 }, "compId": 18 }, { "type": "Text", "props": { "y": 65, "x": 284, "width": 416, "valign": "middle", "text": "左右滑动控制人物移动", "strokeColor": "01361e", "stroke": 3, "pivotY": 51, "pivotX": 208, "height": 102, "fontSize": 40, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 20 }] }, { "type": "Box", "props": { "x": 360, "width": 510, "var": "Guide2", "pivotY": 96, "pivotX": 255, "height": 192, "bottom": 341 }, "compId": 21, "child": [{ "type": "Text", "props": { "y": 118, "x": 255, "wordWrap": true, "width": 279, "valign": "middle", "text": "左右移动瞄准松开手指射箭", "strokeColor": "01361e", "stroke": 3, "pivotY": 74, "pivotX": 140, "overflow": "hidden", "leading": 15, "height": 148, "fontSize": 45, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 24 }] }, { "type": "Box", "props": { "x": 360, "width": 510, "var": "Guide3", "pivotY": 96, "pivotX": 255, "height": 192, "bottom": 350 }, "compId": 27, "child": [{ "type": "Text", "props": { "y": 127, "x": 255, "wordWrap": true, "width": 297, "valign": "middle", "text": "射箭击倒栅栏可以继续前进", "strokeColor": "01361e", "stroke": 3, "pivotY": 74, "pivotX": 149, "overflow": "hidden", "leading": 15, "height": 148, "fontSize": 45, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 28 }] }, { "type": "Box", "props": { "x": 360, "width": 510, "var": "Guide4", "pivotY": 96, "pivotX": 255, "height": 192, "bottom": 350 }, "compId": 30, "child": [{ "type": "Text", "props": { "y": 127, "x": 255, "wordWrap": true, "width": 297, "valign": "middle", "text": "保护蓝色友方射击黄色敌人", "strokeColor": "01361e", "stroke": 3, "pivotY": 74, "pivotX": 149, "overflow": "hidden", "leading": 15, "height": 148, "fontSize": 45, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 31 }] }, { "type": "Box", "props": { "y": 0, "x": 0, "width": 720, "visible": true, "right": 0, "name": "BottomBox", "left": 0, "height": 177, "bottom": 0 }, "compId": 32, "child": [{ "type": "Image", "props": { "width": 720, "top": 0, "skin": "Main/chunhei.png", "sizeGrid": "12,11,13,10", "right": 0, "name": "BG", "left": 0, "height": 183, "bottom": 0 }, "compId": 33 }, { "type": "List", "props": { "width": 720, "var": "BottomList", "spaceX": 30, "right": 0, "repeatY": 1, "left": 0, "height": 176, "bottom": 0 }, "compId": 34, "child": [{ "type": "Box", "props": { "y": 8, "x": 18, "width": 130, "renderType": "render", "height": 160 }, "compId": 35, "child": [{ "type": "Image", "props": { "y": 0, "x": 0, "width": 129, "skin": "Push/bg-box.png", "sizeGrid": "27,27,37,20", "name": "BG", "height": 159 }, "compId": 36 }, { "type": "Image", "props": { "y": 0, "x": 0, "width": 130, "name": "icon", "height": 130 }, "compId": 37 }, { "type": "Text", "props": { "y": 130, "x": 0, "width": 126, "valign": "middle", "text": "冲冲冲冲冲冲", "name": "name", "height": 29, "fontSize": 20, "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 38 }, { "type": "Button", "props": { "y": 0, "x": 0, "width": 130, "name": "btn", "height": 160 }, "compId": 39 }, { "type": "Script", "props": { "runtime": "Tools/ListItem.ts" }, "compId": 40 }] }] }] }], "animations": [{ "nodes": [{ "target": 18, "keyframes": { "y": [{ "value": 208, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "y", "index": 0 }, { "value": 209, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "y", "index": 5 }, { "value": 210, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "y", "index": 10 }, { "value": 209, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "y", "index": 15 }, { "value": 210, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "y", "index": 25 }, { "value": 209, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "y", "index": 30 }, { "value": 210, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "y", "index": 35 }], "x": [{ "value": 55, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "x", "index": 0 }, { "value": 144, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "x", "index": 5 }, { "value": 272, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "x", "index": 10 }, { "value": 394, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "x", "index": 15 }, { "value": 537, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "x", "index": 20 }, { "value": 453, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "x", "index": 25 }, { "value": 344, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "x", "index": 30 }, { "value": 212, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "x", "index": 35 }, { "value": 55, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "x", "index": 40 }] } }], "name": "ani1", "id": 1, "frameRate": 24, "action": 0 }], "loadList": ["Main/zhujiemian-1-4.png", "Main/zhujiemian-1-10.png", "Main/zhujiemian-1-9.png", "Main/zhujiemian-1-8.png", "Main/-2.png", "Main/Hand.png", "Main/chunhei.png", "Push/bg-box.png"], "loadList3D": [] };
  897. ui.InGameViewUI = InGameViewUI;
  898. REG("ui.InGameViewUI", InGameViewUI);
  899. class LoadViewUI extends Laya.Scene {
  900. constructor() { super(); }
  901. createChildren() {
  902. super.createChildren();
  903. this.createView(LoadViewUI.uiView);
  904. }
  905. }
  906. LoadViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Image", "props": { "top": 0, "skin": "Load/jiazai-1-4.png", "sizeGrid": "13,13,15,13", "right": 0, "name": "BG", "left": 0, "bottom": 0 }, "compId": 3 }, { "type": "Image", "props": { "y": 357, "x": 360, "width": 445, "skin": "Load/jiazai-1-1.png", "pivotY": 74, "pivotX": 223, "name": "title", "height": 147 }, "compId": 5 }, { "type": "ProgressBar", "props": { "y": 842, "x": 360, "width": 506, "var": "LoadProgress", "value": 0, "skin": "Load/jiazai-1-3.png", "pivotY": 9, "pivotX": 253, "height": 18 }, "compId": 6 }], "loadList": ["Load/jiazai-1-4.png", "Load/jiazai-1-1.png", "Load/jiazai-1-3.png"], "loadList3D": [] };
  907. ui.LoadViewUI = LoadViewUI;
  908. REG("ui.LoadViewUI", LoadViewUI);
  909. class MainGameViewUI extends Laya.Scene {
  910. constructor() { super(); }
  911. createChildren() {
  912. super.createChildren();
  913. this.createView(MainGameViewUI.uiView);
  914. }
  915. }
  916. MainGameViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Button", "props": { "y": 839, "x": 370, "width": 313, "visible": true, "var": "StartBtn", "stateNum": 1, "skin": "Main/zhujiemian-1-3.png", "pivotY": 58, "pivotX": 157, "height": 116 }, "compId": 7 }, { "type": "Button", "props": { "y": 821, "width": 156, "var": "SkinBtn", "stateNum": 1, "skin": "Main/zhujiemian-1-2.png", "right": 0, "pivotY": 77, "pivotX": 78, "height": 153 }, "compId": 9 }, { "type": "Button", "props": { "y": 828, "width": 140, "var": "MoreFunBtn", "stateNum": 1, "skin": "Main/zhujiemian-1-1.png", "pivotY": 70, "pivotX": 70, "left": 0, "height": 139 }, "compId": 10 }, { "type": "ProgressBar", "props": { "y": 107, "x": 47, "var": "GoalProgress", "value": 0, "skin": "Main/zhujiemian-1-4.png" }, "compId": 11, "child": [{ "type": "Text", "props": { "y": 0, "x": 0, "width": 120, "valign": "middle", "text": "5", "strokeColor": "#050404", "stroke": 2, "name": "goal", "height": 46, "fontSize": 36, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 12 }, { "type": "Image", "props": { "y": 0, "x": -18, "skin": "Main/zhujiemian-1-10.png" }, "compId": 13 }] }, { "type": "Box", "props": { "y": 229.5, "x": 70, "width": 100, "var": "SoundBox", "pivotY": 50, "pivotX": 50, "height": 100 }, "compId": 16, "child": [{ "type": "Image", "props": { "y": 50, "x": 50, "width": 83, "visible": false, "skin": "Main/zhujiemian-1-6.png", "pivotY": 42, "pivotX": 42, "name": "shake", "height": 83 }, "compId": 17 }, { "type": "Image", "props": { "y": 50, "x": 50, "width": 83, "skin": "Main/zhujiemian-1-7.png", "pivotY": 42, "pivotX": 42, "name": "sound", "height": 83 }, "compId": 18 }] }, { "type": "Box", "props": { "y": 137, "x": 620, "width": 201, "pivotY": 25, "pivotX": 101, "height": 50 }, "compId": 19, "child": [{ "type": "Image", "props": { "y": 23, "x": 121, "width": 160, "skin": "Main/zhujiemian-1-9.png", "pivotY": 23, "pivotX": 80, "height": 46 }, "compId": 20 }, { "type": "Image", "props": { "y": -4, "x": 12, "skin": "Main/zhujiemian-1-8.png" }, "compId": 21 }, { "type": "Text", "props": { "y": 0, "x": 65, "width": 137, "var": "GoldNum", "valign": "middle", "text": "9999", "height": 46, "fontSize": 30, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 22 }] }, { "type": "Box", "props": { "y": 129.5, "x": 360, "width": 208, "pivotY": 50, "pivotX": 104, "height": 100 }, "compId": 23, "child": [{ "type": "Text", "props": { "y": 50, "x": 108, "width": 190, "valign": "middle", "text": "第 关", "strokeColor": "033f22", "stroke": 4, "pivotY": 33, "pivotX": 95, "height": 66, "fontSize": 50, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 24 }, { "type": "Text", "props": { "y": 46, "x": 107, "width": 69, "var": "LevelNum", "valign": "middle", "text": "99", "strokeColor": "033f22", "stroke": 4, "pivotY": 21, "pivotX": 35, "height": 42, "fontSize": 50, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 25 }] }, { "type": "Box", "props": { "width": 720, "visible": true, "right": 0, "name": "BottomBox", "left": 0, "height": 177, "bottom": 0 }, "compId": 27, "child": [{ "type": "Image", "props": { "width": 720, "top": 0, "skin": "Main/chunhei.png", "sizeGrid": "12,11,13,10", "right": 0, "name": "BG", "left": 0, "height": 183, "bottom": 0 }, "compId": 28 }, { "type": "List", "props": { "width": 720, "var": "BottomList", "spaceX": 30, "right": 0, "repeatY": 1, "left": 0, "height": 176, "bottom": 0 }, "compId": 26, "child": [{ "type": "Box", "props": { "y": 8, "x": 18, "width": 130, "renderType": "render", "height": 160 }, "compId": 30, "child": [{ "type": "Image", "props": { "y": 0, "x": 0, "width": 129, "skin": "Push/bg-box.png", "sizeGrid": "27,27,37,20", "name": "BG", "height": 159 }, "compId": 32 }, { "type": "Image", "props": { "y": 0, "x": 0, "width": 130, "name": "icon", "height": 130 }, "compId": 31 }, { "type": "Text", "props": { "y": 130, "x": 0, "width": 126, "valign": "middle", "text": "冲冲冲冲冲冲", "name": "name", "height": 29, "fontSize": 20, "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 33 }, { "type": "Button", "props": { "y": 0, "x": 0, "width": 130, "name": "btn", "height": 160 }, "compId": 34 }, { "type": "Script", "props": { "runtime": "Tools/ListItem.ts" }, "compId": 50 }] }] }] }, { "type": "Button", "props": { "y": 640, "width": 140, "var": "LeftPushIcon", "skin": "Main/white.png", "sizeGrid": "5,16,5,11", "pivotY": 88, "pivotX": 70, "left": 20, "height": 175 }, "compId": 53, "child": [{ "type": "Image", "props": { "width": 140, "name": "icon", "height": 140 }, "compId": 54 }, { "type": "Text", "props": { "y": 159, "x": 70, "width": 140, "valign": "middle", "text": "冲冲冲冲冲冲", "pivotY": 19, "pivotX": 70, "name": "name", "height": 37, "fontSize": 22, "font": "Microsoft YaHei", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 55 }] }, { "type": "Button", "props": { "y": 640, "width": 140, "var": "RightPushIcon", "skin": "Main/white.png", "sizeGrid": "5,16,5,11", "right": 20, "pivotY": 88, "pivotX": 70, "height": 175 }, "compId": 56, "child": [{ "type": "Image", "props": { "width": 140, "name": "icon", "height": 140 }, "compId": 57 }, { "type": "Text", "props": { "y": 159, "x": 70, "width": 140, "valign": "middle", "text": "冲冲冲冲冲冲", "pivotY": 19, "pivotX": 70, "name": "name", "height": 37, "fontSize": 22, "font": "Microsoft YaHei", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 58 }] }, { "type": "Image", "props": { "y": 640, "x": 360, "visible": false, "var": "BaoKuan", "top": 0, "skin": "Main/chunhei.png", "sizeGrid": "10,12,16,9", "right": 0, "left": 0, "bottom": 0, "anchorY": 0.5, "anchorX": 0.5 }, "compId": 38, "child": [{ "type": "Image", "props": { "y": 560, "x": -267.5, "width": 535, "skin": "Push/index-box.png", "sizeGrid": "28,33,48,26", "height": 573, "anchorY": 0.5, "anchorX": 0.5 }, "compId": 35, "child": [{ "type": "Image", "props": { "y": 40, "x": 267.5, "width": 228, "skin": "Push/index-hot.png", "pivotY": 22, "pivotX": 114, "height": 44 }, "compId": 36 }, { "type": "Button", "props": { "y": 40, "x": 477.5, "width": 36, "var": "CloseBaoKuan", "stateNum": 1, "skin": "Push/index-close.png", "pivotY": 18, "pivotX": 18, "height": 36 }, "compId": 37 }, { "type": "List", "props": { "y": 313, "x": 267.5, "width": 493, "var": "BaoKuanList", "spaceY": 8, "spaceX": 35, "height": 469, "anchorY": 0.5, "anchorX": 0.5 }, "compId": 39, "child": [{ "type": "Box", "props": { "y": 0, "x": 23, "width": 126, "renderType": "render", "height": 150 }, "compId": 40, "child": [{ "type": "Image", "props": { "width": 125, "name": "icon", "height": 125 }, "compId": 41 }, { "type": "Text", "props": { "y": 138, "x": 64, "width": 142, "valign": "middle", "text": "冲冲冲冲冲冲", "pivotY": 15, "pivotX": 71, "name": "name", "height": 34, "fontSize": 20, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 42 }, { "type": "Button", "props": { "y": 84, "x": 71, "width": 141, "pivotY": 84, "pivotX": 71, "name": "btn", "height": 167 }, "compId": 43 }, { "type": "Script", "props": { "runtime": "Tools/ListItem.ts" }, "compId": 49 }] }] }] }] }, { "type": "Button", "props": { "y": 338, "x": 0, "visible": true, "var": "BaoKuanBtn", "stateNum": 1, "skin": "Push/img_cover_slide_ad_btn.png", "left": 0 }, "compId": 44 }], "animations": [{ "nodes": [{ "target": 35, "keyframes": { "y": [{ "value": 560, "tweenMethod": "linearNone", "tween": true, "target": 35, "key": "y", "index": 0 }], "x": [{ "value": -267.5, "tweenMethod": "linearNone", "tween": true, "target": 35, "key": "x", "index": 0 }, { "value": 360, "tweenMethod": "linearNone", "tween": true, "target": 35, "key": "x", "index": 15 }] } }], "name": "chouti", "id": 1, "frameRate": 24, "action": 0 }, { "nodes": [{ "target": 53, "keyframes": { "rotation": [{ "value": 0, "tweenMethod": "linearNone", "tween": true, "target": 53, "key": "rotation", "index": 0 }, { "value": 15, "tweenMethod": "linearNone", "tween": true, "target": 53, "key": "rotation", "index": 5 }, { "value": -15, "tweenMethod": "linearNone", "tween": true, "target": 53, "key": "rotation", "index": 10 }, { "value": 15, "tweenMethod": "linearNone", "tween": true, "target": 53, "key": "rotation", "index": 15 }, { "value": 0, "tweenMethod": "linearNone", "tween": true, "target": 53, "key": "rotation", "index": 20 }] } }], "name": "lefticon", "id": 2, "frameRate": 24, "action": 0 }, { "nodes": [{ "target": 56, "keyframes": { "rotation": [{ "value": 0, "tweenMethod": "linearNone", "tween": true, "target": 56, "key": "rotation", "index": 0 }, { "value": 15, "tweenMethod": "linearNone", "tween": true, "target": 56, "key": "rotation", "index": 5 }, { "value": -15, "tweenMethod": "linearNone", "tween": true, "target": 56, "key": "rotation", "index": 10 }, { "value": 15, "tweenMethod": "linearNone", "tween": true, "target": 56, "key": "rotation", "index": 15 }, { "value": 0, "tweenMethod": "linearNone", "tween": true, "target": 56, "key": "rotation", "index": 20 }] } }], "name": "righticon", "id": 3, "frameRate": 24, "action": 0 }], "loadList": ["Main/zhujiemian-1-3.png", "Main/zhujiemian-1-2.png", "Main/zhujiemian-1-1.png", "Main/zhujiemian-1-4.png", "Main/zhujiemian-1-10.png", "Main/zhujiemian-1-6.png", "Main/zhujiemian-1-7.png", "Main/zhujiemian-1-9.png", "Main/zhujiemian-1-8.png", "Main/chunhei.png", "Push/bg-box.png", "Main/white.png", "Push/index-box.png", "Push/index-hot.png", "Push/index-close.png", "Push/img_cover_slide_ad_btn.png"], "loadList3D": [] };
  917. ui.MainGameViewUI = MainGameViewUI;
  918. REG("ui.MainGameViewUI", MainGameViewUI);
  919. class SkinViewUI extends Laya.Scene {
  920. constructor() { super(); }
  921. createChildren() {
  922. super.createChildren();
  923. this.createView(SkinViewUI.uiView);
  924. }
  925. }
  926. SkinViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Image", "props": { "y": 0, "x": 0, "top": 0, "skin": "Main/chunhei.png", "sizeGrid": "10,13,13,9", "right": 0, "name": "BG", "left": 0, "bottom": 0 }, "compId": 22 }, { "type": "Image", "props": { "y": 875, "x": 362, "width": 658, "skin": "Main/pifu-1-1.png", "sizeGrid": "63,62,62,55", "height": 765, "anchorY": 0.5, "anchorX": 0.5 }, "compId": 4, "child": [{ "type": "Image", "props": { "y": 64, "x": 24, "width": 615, "skin": "Main/pifu-1-2.png", "sizeGrid": "42,33,67,30", "height": 675 }, "compId": 5 }, { "type": "Button", "props": { "y": 3, "x": 148.5, "width": 183, "var": "CharacterBtn", "height": 61 }, "compId": 7, "child": [{ "type": "Image", "props": { "y": 1, "x": 0, "skin": "Main/pifu-1-4.png", "name": "grey" }, "compId": 10 }, { "type": "Image", "props": { "y": 1, "x": 0, "skin": "Main/pifu-1-3.png", "name": "light" }, "compId": 9 }, { "type": "Text", "props": { "y": 0, "x": 0, "width": 182, "valign": "middle", "text": "帽子", "strokeColor": "#060606", "stroke": 2, "height": 63, "fontSize": 40, "font": "Microsoft YaHei", "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 15 }] }, { "type": "Button", "props": { "y": 3, "x": 332, "width": 181, "var": "HorseBtn", "height": 60 }, "compId": 8, "child": [{ "type": "Image", "props": { "y": 1, "x": 0, "skin": "Main/pifu-1-4.png", "name": "grey" }, "compId": 14 }, { "type": "Image", "props": { "y": 1, "x": 0, "visible": false, "skin": "Main/pifu-1-3.png", "name": "light" }, "compId": 13 }, { "type": "Text", "props": { "y": 0, "x": 0, "width": 182, "valign": "middle", "text": "马", "strokeColor": "#060606", "stroke": 2, "height": 63, "fontSize": 40, "font": "Microsoft YaHei", "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 16 }] }] }, { "type": "List", "props": { "y": 800, "x": 362, "width": 532, "var": "ItemList", "spaceY": 10, "spaceX": 12, "repeatY": 2, "repeatX": 3, "height": 415, "anchorY": 0.5, "anchorX": 0.5 }, "compId": 17, "child": [{ "type": "Box", "props": { "y": 0, "x": 0, "width": 167, "renderType": "render", "height": 199 }, "compId": 18, "child": [{ "type": "Image", "props": { "y": 0, "x": 2, "width": 165, "skin": "Main/pifu-1-6.png", "sizeGrid": "37,27,50,28", "height": 197 }, "compId": 19 }, { "type": "Image", "props": { "y": 0, "x": 0, "width": 170, "skin": "Main/pifu-1-5.png", "sizeGrid": "39,33,41,36", "name": "choose", "height": 198 }, "compId": 20 }, { "type": "Image", "props": { "y": 78, "x": 83.5, "width": 127, "pivotY": 61, "pivotX": 64, "name": "icon", "height": 121 }, "compId": 47 }, { "type": "Button", "props": { "y": 0, "x": 0, "width": 169, "name": "btn", "height": 197 }, "compId": 43 }, { "type": "Image", "props": { "y": 154, "x": 51, "skin": "Main/pifu-1-10.png", "name": "used" }, "compId": 45 }, { "type": "Script", "props": { "runtime": "Tools/ShopItem.ts" }, "compId": 46 }] }] }, { "type": "Button", "props": { "y": 114, "x": 46, "var": "BackBtn", "stateNum": 1, "skin": "Main/pifu-1-7.png" }, "compId": 21 }, { "type": "Button", "props": { "y": 1144, "x": 498, "width": 243, "var": "VideoGetCoinBtn", "stateNum": 1, "skin": "Main/pifu-1-9.png", "pivotY": 46, "pivotX": 122, "height": 92 }, "compId": 23, "child": [{ "type": "Text", "props": { "y": 46, "x": 180, "width": 102, "valign": "middle", "text": "200", "stroke": 2, "pivotY": 33, "pivotX": 51, "name": "CoinNum", "height": 65, "fontSize": 45, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 24 }] }, { "type": "Button", "props": { "y": 1144, "x": 218, "var": "GetBtn", "stateNum": 1, "skin": "Main/pifu-1-8.png", "anchorY": 0.5, "anchorX": 0.5 }, "compId": 25, "child": [{ "type": "Image", "props": { "y": 45, "x": 122, "width": 235, "name": "GetByCoin", "height": 84, "anchorY": 0.5, "anchorX": 0.5 }, "compId": 26, "child": [{ "type": "Image", "props": { "y": 13, "x": 22, "skin": "Main/zhujiemian-1-8.png" }, "compId": 27 }, { "type": "Text", "props": { "y": 42, "x": 150, "width": 142, "valign": "middle", "text": "99999", "strokeColor": "#030303", "stroke": 2, "pivotY": 26, "pivotX": 71, "name": "CoinNum", "height": 51, "fontSize": 45, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 28 }] }, { "type": "Image", "props": { "y": 45, "x": 122, "width": 235, "name": "GetByVideo", "height": 84, "anchorY": 0.5, "anchorX": 0.5 }, "compId": 30, "child": [{ "type": "Image", "props": { "y": 21.5, "x": 56, "skin": "Main/pifu-1-11.png" }, "compId": 31 }, { "type": "Text", "props": { "y": 42, "x": 150, "width": 142, "valign": "middle", "text": "1/3", "strokeColor": "#030303", "stroke": 2, "pivotY": 26, "pivotX": 71, "name": "VideoNum", "height": 51, "fontSize": 45, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 32 }] }, { "type": "Image", "props": { "y": 46, "x": 122, "width": 243, "name": "GetByActive", "height": 91, "anchorY": 0.5, "anchorX": 0.5 }, "compId": 33, "child": [{ "type": "Text", "props": { "y": 42, "x": 117, "width": 232, "valign": "middle", "text": "活动领取", "strokeColor": "#030303", "stroke": 2, "pivotY": 33, "pivotX": 116, "name": "ByActive", "height": 76, "fontSize": 45, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 35 }] }, { "type": "Image", "props": { "y": 45, "x": 122, "width": 235, "name": "Geted", "height": 84, "anchorY": 0.5, "anchorX": 0.5 }, "compId": 39, "child": [{ "type": "Text", "props": { "y": 42, "x": 117, "width": 232, "valign": "middle", "text": "使用", "strokeColor": "#030303", "stroke": 2, "pivotY": 33, "pivotX": 116, "name": "Get", "height": 76, "fontSize": 45, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 40 }] }, { "type": "Text", "props": { "y": 51, "x": 122, "width": 232, "valign": "middle", "text": "已装备", "strokeColor": "#030303", "stroke": 2, "pivotY": 43, "pivotX": 116, "name": "Using", "height": 80, "fontSize": 45, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 42 }] }], "loadList": ["Main/chunhei.png", "Main/pifu-1-1.png", "Main/pifu-1-2.png", "Main/pifu-1-4.png", "Main/pifu-1-3.png", "Main/pifu-1-6.png", "Main/pifu-1-5.png", "Main/pifu-1-10.png", "Main/pifu-1-7.png", "Main/pifu-1-9.png", "Main/pifu-1-8.png", "Main/zhujiemian-1-8.png", "Main/pifu-1-11.png"], "loadList3D": [] };
  927. ui.SkinViewUI = SkinViewUI;
  928. REG("ui.SkinViewUI", SkinViewUI);
  929. class TrialViewUI extends Laya.Scene {
  930. constructor() { super(); }
  931. createChildren() {
  932. super.createChildren();
  933. this.createView(TrialViewUI.uiView);
  934. }
  935. }
  936. TrialViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Image", "props": { "top": 0, "skin": "Main/chunhei.png", "sizeGrid": "9,17,14,11", "right": 0, "name": "BG", "left": 0, "bottom": 0 }, "compId": 4 }, { "type": "Image", "props": { "y": 213, "x": 108.5, "skin": "Main/shiyong-1-3.png" }, "compId": 5, "child": [{ "type": "Image", "props": { "y": -58.5, "x": 40, "skin": "Main/shiyong-1-1.png" }, "compId": 6 }] }, { "type": "Button", "props": { "y": 672, "x": 219, "var": "TrialBtn", "stateNum": 1, "skin": "Main/shiyong-1-2.png" }, "compId": 7 }, { "type": "Button", "props": { "y": 824, "x": 309, "var": "NoTrialBtn", "stateNum": 1, "skin": "Main/shiyong-1-4.png" }, "compId": 8 }, { "type": "Image", "props": { "y": 276, "x": 161, "width": 398, "var": "SceneViewPort", "height": 383 }, "compId": 9 }], "loadList": ["Main/chunhei.png", "Main/shiyong-1-3.png", "Main/shiyong-1-1.png", "Main/shiyong-1-2.png", "Main/shiyong-1-4.png"], "loadList3D": [] };
  937. ui.TrialViewUI = TrialViewUI;
  938. REG("ui.TrialViewUI", TrialViewUI);
  939. })(ui || (ui = {}));
  940. var MusicType;
  941. (function (MusicType) {
  942. MusicType[MusicType["click"] = 0] = "click";
  943. MusicType[MusicType["hit"] = 1] = "hit";
  944. MusicType[MusicType["shoot"] = 2] = "shoot";
  945. MusicType[MusicType["OpenView"] = 3] = "OpenView";
  946. MusicType[MusicType["Lose"] = 4] = "Lose";
  947. MusicType[MusicType["Win"] = 5] = "Win";
  948. MusicType[MusicType["die"] = 6] = "die";
  949. })(MusicType || (MusicType = {}));
  950. var BGMType;
  951. (function (BGMType) {
  952. BGMType[BGMType["BGM"] = 0] = "BGM";
  953. })(BGMType || (BGMType = {}));
  954. class AudioManager {
  955. constructor() { }
  956. static musicres(_type) {
  957. return "Game/res/music/" + MusicType[_type] + ".mp3";
  958. }
  959. static bgmres(_type) {
  960. return "Game/res/music/" + BGMType[_type] + ".mp3";
  961. }
  962. static playMusic(_type) {
  963. if (!this.open)
  964. return;
  965. Laya.SoundManager.playSound(this.musicres(_type));
  966. }
  967. static StopMusic() {
  968. Laya.SoundManager.stopMusic();
  969. }
  970. static PlayBGM(_type) {
  971. if (!this.open)
  972. return;
  973. Laya.SoundManager.playMusic(this.bgmres(_type), 0);
  974. }
  975. }
  976. AudioManager.open = true;
  977. class MainGameView extends ui.MainGameViewUI {
  978. constructor() {
  979. super();
  980. MainGameView.ins = this;
  981. }
  982. static get Instance() {
  983. if (MainGameView.ins) {
  984. return MainGameView.ins;
  985. }
  986. else {
  987. return new MainGameView();
  988. }
  989. }
  990. Show() {
  991. WXSDK.AldEvent("打开主界面");
  992. AudioManager.PlayBGM(BGMType.BGM);
  993. this.BaoKuan.visible = false;
  994. this.StartBtn.clickHandler = Laya.Handler.create(this, this.ClickStart);
  995. this.SkinBtn.clickHandler = Laya.Handler.create(this, this.ClickSkin);
  996. this.MoreFunBtn.clickHandler = new Laya.Handler(this, this.ClickMoreFun);
  997. this.BaoKuanBtn.clickHandler = new Laya.Handler(this, this.OpenChouTi);
  998. this.goaltext = this.GoalProgress.getChildByName("goal");
  999. this.goaltext.text = GameManager.Instance.KillNum.toString();
  1000. this.GoldNum.text = AccountManager.Instance.curplayerData.GainAccount("money");
  1001. this.LevelNum.text = AccountManager.Instance.curplayerData.GainAccount("stage");
  1002. this.SoundBox.on(Laya.Event.CLICK, this, this.ClickSound);
  1003. this.sound = this.SoundBox.getChildByName("sound");
  1004. this.shake = this.SoundBox.getChildByName("shake");
  1005. this.sound.visible = AudioManager.open;
  1006. this.shake.visible = WXSDK.shake;
  1007. this.SetData();
  1008. this.SetTopAd();
  1009. this.height = Laya.stage.height;
  1010. Laya.stage.on(Laya.Event.RESIZE, this, () => {
  1011. this.height = Laya.stage.height;
  1012. });
  1013. }
  1014. Close() {
  1015. Laya.stage.off(Laya.Event.MOUSE_DOWN, this, this.ClickStart);
  1016. }
  1017. ClickStart() {
  1018. let stage = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
  1019. if (stage > 2) {
  1020. AudioManager.playMusic(MusicType.click);
  1021. ViewManager.Instance.ShowView(ViewType.TrialView);
  1022. }
  1023. else {
  1024. var agrs = [{ "t": AccountManager.Instance.ServerTime.toString() }];
  1025. ServerManager.Instance.SendHttp(ArcherWorrior.KaiShi, agrs, Laya.Handler.create(this, this.GameStart), null);
  1026. }
  1027. }
  1028. ClickSkin() {
  1029. AudioManager.playMusic(MusicType.click);
  1030. ViewManager.Instance.ShowView(ViewType.ShopView);
  1031. }
  1032. ClickMoreFun() {
  1033. ViewManager.Instance.OpenPopView(ViewType.ExportView);
  1034. }
  1035. ClickSound() {
  1036. if (this.sound.visible) {
  1037. this.sound.visible = false;
  1038. this.shake.visible = true;
  1039. AudioManager.open = false;
  1040. WXSDK.shake = true;
  1041. AudioManager.StopMusic();
  1042. console.log("关闭声音,打开震动---");
  1043. }
  1044. else {
  1045. this.sound.visible = true;
  1046. this.shake.visible = false;
  1047. AudioManager.open = true;
  1048. WXSDK.shake = true;
  1049. AudioManager.PlayBGM(BGMType.BGM);
  1050. console.log("打开声音,关闭震动");
  1051. }
  1052. }
  1053. GameStart(_data) {
  1054. let stage = AccountManager.Instance.curplayerData.GainAccount("stage");
  1055. WXSDK.AldStart(stage);
  1056. AudioManager.playMusic(MusicType.click);
  1057. this.play_id = _data.play_id;
  1058. EventManager.StageTrigger(StageState.Start);
  1059. ViewManager.Instance.ShowView(ViewType.IngameView);
  1060. }
  1061. OpenChouTi() {
  1062. this.BaoKuanBtn.visible = false;
  1063. this.BaoKuan.visible = true;
  1064. this.CloseBaoKuan.clickHandler = Laya.Handler.create(this, this.CloseChouTi);
  1065. this.chouti.play(null, false);
  1066. this.InitAd();
  1067. }
  1068. CloseChouTi() {
  1069. this.BaoKuan.visible = false;
  1070. this.BaoKuanBtn.visible = true;
  1071. this.CloseBaoKuan.clickHandler = null;
  1072. }
  1073. InitAd() {
  1074. SDKZS.SetHuTuiList(this.BaoKuanList, 1, "");
  1075. this.GunGun2();
  1076. }
  1077. GunGun2() {
  1078. this.BaoKuanList.scrollBar.value = 0;
  1079. var maxTop = this.BaoKuanList.scrollBar.max;
  1080. var tempTop = 1;
  1081. Laya.timer.frameLoop(1, this, () => {
  1082. this.BaoKuanList.scrollBar.value += tempTop;
  1083. if (this.BaoKuanList.scrollBar.value >= maxTop || this.BaoKuanList.scrollBar.value <= 0) {
  1084. tempTop = -tempTop;
  1085. }
  1086. });
  1087. }
  1088. SetData() {
  1089. SDKZS.SetHuTuiList(this.BottomList, 2, "");
  1090. this.GunGun();
  1091. }
  1092. GunGun() {
  1093. var maxBtm;
  1094. try {
  1095. this.BottomList.scrollBar.value = 0;
  1096. maxBtm = this.BottomList.scrollBar.max;
  1097. }
  1098. catch (error) {
  1099. console.error(error);
  1100. return;
  1101. }
  1102. var tempBtm = 1;
  1103. Laya.timer.frameLoop(1, this, () => {
  1104. this.BottomList.scrollBar.value += tempBtm;
  1105. if (this.BottomList.scrollBar.value >= maxBtm || this.BottomList.scrollBar.value <= 0) {
  1106. tempBtm = -tempBtm;
  1107. }
  1108. });
  1109. }
  1110. SetTopAd() {
  1111. this.topAdData = SDKZS.data.promotion || [];
  1112. this.LeftPushIcon.visible = this.RightPushIcon.visible = this.topAdData.length >= 2;
  1113. if (this.topAdData.length < 2)
  1114. return;
  1115. this.topLeftAdIndex = { index: 0 };
  1116. this.topRightAdIndex = { index: 1 };
  1117. this._setTopAd(this.LeftPushIcon, this.topLeftAdIndex);
  1118. this._setTopAd(this.RightPushIcon, this.topRightAdIndex);
  1119. }
  1120. _setTopAd(topAd, adIndex) {
  1121. let _icon = topAd.getChildByName("icon");
  1122. let _name = topAd.getChildByName("name");
  1123. topAd.clickHandler = new Laya.Handler(this, () => {
  1124. SDKZS.navigate2Mini(this.topAdData[adIndex.index]);
  1125. });
  1126. this._setIcon(_icon, _name, adIndex);
  1127. Laya.timer.loop(5000, this, () => {
  1128. this._setIcon(_icon, _name, adIndex);
  1129. this.lefticon.play(null, false);
  1130. this.righticon.play(null, false);
  1131. });
  1132. }
  1133. _setIcon(_icon, _name, adIndex) {
  1134. adIndex.index = (adIndex.index + 2) % this.topAdData.length;
  1135. _icon.skin = this.topAdData[adIndex.index].app_icon;
  1136. _name.text = this.topAdData[adIndex.index].app_title;
  1137. }
  1138. }
  1139. class DataManager {
  1140. constructor() {
  1141. DataManager.ins = this;
  1142. }
  1143. static get Instance() {
  1144. if (DataManager.ins) {
  1145. return DataManager.ins;
  1146. }
  1147. else {
  1148. return new DataManager();
  1149. }
  1150. }
  1151. }
  1152. DataManager.DoorArray = [];
  1153. var Sprite3D$1 = Laya.Sprite3D;
  1154. var Vector3$2 = Laya.Vector3;
  1155. class Prop {
  1156. constructor(_id) {
  1157. this.id = _id;
  1158. }
  1159. }
  1160. class Plane {
  1161. constructor(_index, _id, pos, data, proppos, propoffest) {
  1162. this.things = [];
  1163. this.thinghight = 0;
  1164. this.thingwight = 0;
  1165. this.index = _index;
  1166. this.planeid = _id;
  1167. this.position = pos;
  1168. this.GetProp(data, proppos, propoffest);
  1169. }
  1170. GetProp(data, pos, offset) {
  1171. var config = AccountManager.Instance.curplayerData.GainCollocation("things");
  1172. var datas = data.split(";");
  1173. var poss = pos.split(";");
  1174. var offestX = offset.split(";");
  1175. for (var i = 0; i < datas.length; i++) {
  1176. if (datas[i] == "0")
  1177. continue;
  1178. var prop = new Prop(Number(datas[i]));
  1179. var configid = prop.id - 1;
  1180. var curconfig = config[configid.toString()];
  1181. var ps = (i <= poss.length - 1) ? Number(poss[i]) : this.long;
  1182. var hs = (i <= poss.length - 1) ? Number(offestX[i]) : this.long;
  1183. prop.pos = new Vector3$2(this.position.x, this.position.y, this.position.z + ps);
  1184. prop.type = Number(curconfig.type);
  1185. this.things.push(prop);
  1186. }
  1187. }
  1188. }
  1189. class Grade {
  1190. constructor(_index, _id) {
  1191. this.startpoint = new Vector3$2(0, 0, 0);
  1192. this.planes = [];
  1193. this.scencerys = [];
  1194. this.MaxLength = 0;
  1195. this.MaxHight = 0;
  1196. this.fencearray = [];
  1197. this.fencepos = 0;
  1198. this.fencepos2 = 0;
  1199. this.fencenum = 0;
  1200. this.fenceleftpos = 0;
  1201. this.fencerightpos = 0;
  1202. this.creat = false;
  1203. this.floorarray = [];
  1204. this.floornum = 0;
  1205. this.floorpos = 0;
  1206. this.treenum = 0;
  1207. this.treepos = 0;
  1208. this.treepos2 = 0;
  1209. this.creatnum = 0;
  1210. this.index = _index;
  1211. this.gradeid = _id;
  1212. }
  1213. Init() {
  1214. this.GetPlane();
  1215. this.endpointpoint = new Vector3$2(0, this.MaxHight, this.MaxLength);
  1216. }
  1217. GetPlane() {
  1218. var config = AccountManager.Instance.curplayerData.GainCollocation("road");
  1219. for (var key in config) {
  1220. if (Number(config[key].road_id) == this.gradeid) {
  1221. var planedata = config[key];
  1222. var long = Number(planedata.long);
  1223. var posz = this.startpoint.z;
  1224. var roadid = Number(planedata.street);
  1225. var planepos = new Vector3$2(9 - (roadid * 1.65), 0, posz);
  1226. var plane = new Plane(Number(planedata.street), Number(planedata.road_id), planepos, planedata.things, planedata.position, planedata.offset);
  1227. plane.long = Number(planedata.long);
  1228. this.MaxHight = (plane.thinghight) < this.MaxHight ? plane.thinghight : this.MaxHight;
  1229. if (long != 0) {
  1230. this.MaxLength = posz + long > this.MaxLength ? posz + long : this.MaxLength;
  1231. }
  1232. this.planes.push(plane);
  1233. }
  1234. }
  1235. }
  1236. Clear() {
  1237. for (var j = 0; j < this.planes.length; j++) {
  1238. var model = this.planes[j].model;
  1239. if (model && model.active && !model.destroyed) {
  1240. GamePool.Instance.RecoveryModel(model);
  1241. }
  1242. this.planes[j].model = null;
  1243. var things = this.planes[j].things;
  1244. for (var k = 0; k < things.length; k++) {
  1245. model = things[k].model;
  1246. if (model && model.active && !model.destroyed)
  1247. GamePool.Instance.RecoveryModel(model);
  1248. things[k].model = null;
  1249. }
  1250. }
  1251. for (var i = 0; i < this.scencerys.length; i++) {
  1252. var scencery = this.scencerys[i];
  1253. if (scencery && scencery.active && !scencery.destroyed)
  1254. GamePool.Instance.RecoveryModel(scencery);
  1255. this.scencerys[i] = null;
  1256. }
  1257. this.scencerys.splice(0, this.scencerys.length);
  1258. for (let k = 0; k < this.fencearray.length; k++) {
  1259. var _fence = this.fencearray[k];
  1260. if (_fence && _fence.active && !_fence.destroyed)
  1261. GamePool.Instance.RecoveryModel(_fence);
  1262. this.fencearray[k] = null;
  1263. }
  1264. this.fencearray.splice(0, this.fencearray.length);
  1265. if (this.spr)
  1266. this.spr.destroy();
  1267. }
  1268. Creat(_stage = null, _id) {
  1269. if (_stage == null)
  1270. _stage = StageControl.Instance.curstage;
  1271. this.spr = new Sprite3D$1();
  1272. for (var j = 0; j < this.planes.length; j++) {
  1273. var plane = this.planes[j];
  1274. if (plane.long > 0) {
  1275. var res = AssetManager.Instance.Plane.get(1);
  1276. plane.model = GamePool.Instance.GetModel(res, "");
  1277. this.spr.addChild(plane.model);
  1278. plane.model.transform.position = plane.position;
  1279. plane.model.transform.scale = new Laya.Vector3(plane.model.transform.scale.x, plane.model.transform.scale.y, plane.long);
  1280. GameTools.Instance.SetCollider(plane.model, 100);
  1281. var things = plane.things;
  1282. for (var k = 0; k < things.length; k++) {
  1283. var thingdata = things[k];
  1284. var tre = AssetManager.Instance.Prop.get(thingdata.id);
  1285. thingdata.model = GamePool.Instance.GetModel(tre, "");
  1286. if (thingdata.id == 1) {
  1287. DataManager.DoorArray.push(thingdata.model);
  1288. }
  1289. if (thingdata.id == 13) {
  1290. GameManager.Instance.CreatEnemy(thingdata.model);
  1291. }
  1292. else if (thingdata.id == 14) {
  1293. GameManager.Instance.CreatChaseCharacter(thingdata.model);
  1294. }
  1295. else {
  1296. GameTools.Instance.SetCollider(thingdata.model, 100);
  1297. }
  1298. this.spr.addChild(thingdata.model);
  1299. thingdata.model.transform.position = thingdata.pos;
  1300. }
  1301. }
  1302. else {
  1303. if (plane.things.length > 0) {
  1304. for (var k = 0; k < plane.things.length; k++) {
  1305. var thingdata = plane.things[k];
  1306. var tre = AssetManager.Instance.Prop.get(thingdata.id);
  1307. thingdata.model = GamePool.Instance.GetModel(tre, "");
  1308. GameTools.Instance.SetCollider(thingdata.model, 100);
  1309. this.spr.addChild(thingdata.model);
  1310. thingdata.model.transform.position = thingdata.pos;
  1311. }
  1312. }
  1313. }
  1314. AssetManager.Instance.mainscene.addChild(this.spr);
  1315. }
  1316. }
  1317. }
  1318. class GK {
  1319. constructor(_id) {
  1320. this.curgrades = [];
  1321. this.ChooseGrade = [];
  1322. this.Id = Number(_id);
  1323. this.scenery = GameTools.RandomANumber(1, 5);
  1324. this.GetGrade();
  1325. }
  1326. GetGrade() {
  1327. var config = AccountManager.Instance.curplayerData.GainCollocation("mission");
  1328. var gradedatas = config[this.Id - 1].roads.split(";");
  1329. var roadnum = Number(config[this.Id - 1].road_num);
  1330. this.mainrolespeed = Number(config[this.Id - 1].PlayerSpeed);
  1331. this.npcspeed = Number(config[this.Id - 1].NpcSpeed);
  1332. this.hostspeed = Number(config[this.Id - 1].HostageSpeed);
  1333. this.BossHp = Number(config[this.Id - 1].boss_HP);
  1334. this.Goal = Number(config[this.Id - 1].goal);
  1335. this.Modulus = Number(config[this.Id - 1].modulus);
  1336. this.isboss = Number(config[this.Id - 1].boss);
  1337. let GradeArray = [];
  1338. let num = 0;
  1339. if (this.Id > 2) {
  1340. while (num == 0) {
  1341. var random = GameTools.RandomANumber(0, gradedatas.length);
  1342. var value = Number(gradedatas[random]);
  1343. gradedatas.splice(random, 1);
  1344. GradeArray.push(value);
  1345. if (GradeArray.length == roadnum) {
  1346. num = 1;
  1347. }
  1348. }
  1349. var endpos = new Vector3$2();
  1350. for (var i = 0; i < GradeArray.length; i++) {
  1351. var gradeid = Number(GradeArray[i]);
  1352. var grade = new Grade(i, gradeid);
  1353. if (i > 0)
  1354. grade.startpoint = endpos;
  1355. grade.Init();
  1356. endpos = grade.endpointpoint;
  1357. this.curgrades.push(grade);
  1358. }
  1359. this.endposition = endpos;
  1360. this.ChooseGrade = GradeArray;
  1361. }
  1362. else {
  1363. var endpos = new Vector3$2();
  1364. for (var i = 0; i < gradedatas.length; i++) {
  1365. var gradeid = Number(gradedatas[i]);
  1366. var grade = new Grade(i, gradeid);
  1367. if (i > 0)
  1368. grade.startpoint = endpos;
  1369. grade.Init();
  1370. endpos = grade.endpointpoint;
  1371. this.curgrades.push(grade);
  1372. }
  1373. this.endposition = endpos;
  1374. }
  1375. console.log("GradeArray -- ", GradeArray.length);
  1376. }
  1377. }
  1378. var Vector3$3 = Laya.Vector3;
  1379. class StageControl {
  1380. constructor() {
  1381. this.floorarray = [];
  1382. this.treearray = [];
  1383. this.fencearray = [];
  1384. this.num = 1;
  1385. this.curstagedic = {};
  1386. StageControl.ins = this;
  1387. EventManager.EventOn(EventState.SceneInit, this, this.StageInit);
  1388. EventManager.StageOn(StageState.Restart, this, this.RessetStage);
  1389. }
  1390. static get Instance() {
  1391. if (StageControl.ins) {
  1392. return StageControl.ins;
  1393. }
  1394. else {
  1395. return new StageControl();
  1396. }
  1397. }
  1398. StageInit() {
  1399. var config = AccountManager.Instance.curplayerData.GainCollocation("mission");
  1400. for (var index in config) {
  1401. var data = config[index];
  1402. var gk = new GK(data.id);
  1403. this.curstagedic[gk.Id] = gk;
  1404. }
  1405. EventManager.EventTrigger(EventState.StageInit);
  1406. }
  1407. RessetStage() {
  1408. GameManager.Instance.KillNum = 0;
  1409. GameManager.Instance.ReviveNum = 1;
  1410. GameManager.Instance.fenceleftpos = 0;
  1411. GameManager.Instance.fencerightpos = 0;
  1412. GameManager.Instance.treeleftpos = 0;
  1413. GameManager.Instance.treerightpos = 0;
  1414. GameManager.Instance.GuideKill = 0;
  1415. if (this.curstage)
  1416. this.ClearStageResources();
  1417. var level = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
  1418. this.curstage = this.CreatStage(level);
  1419. console.log("本关卡为---", this.curstage.Id);
  1420. for (let i = 0; i < this.curstage.ChooseGrade.length; i++) {
  1421. console.log("选中路段为---", this.curstage.ChooseGrade[i]);
  1422. }
  1423. EventManager.EventTrigger(EventState.StageCreateComplete);
  1424. }
  1425. ClearStageResources() {
  1426. var stage = this.curstage;
  1427. console.log("舞台id为:--------", this.curstage.Id);
  1428. for (let j = 0; j < this.floorarray.length; j++) {
  1429. let floor = this.floorarray[j];
  1430. if (floor && floor.active && !floor.destroyed) {
  1431. GamePool.Instance.RecoveryModel(floor);
  1432. }
  1433. this.floorarray[j] = null;
  1434. }
  1435. this.floorarray.slice(0, this.floorarray.length);
  1436. for (let k = 0; k < this.treearray.length; k++) {
  1437. let tree = this.treearray[k];
  1438. if (tree && tree.active && !tree.destroyed) {
  1439. GamePool.Instance.RecoveryModel(tree);
  1440. }
  1441. this.treearray[k] = null;
  1442. }
  1443. this.treearray.splice(0, this.treearray.length);
  1444. for (let l = 0; l < this.fencearray.length; l++) {
  1445. let fence = this.fencearray[l];
  1446. if (fence && fence.active && !fence.destroyed) {
  1447. GamePool.Instance.RecoveryModel(fence);
  1448. }
  1449. this.fencearray[l] = null;
  1450. }
  1451. this.fencearray.splice(0, this.fencearray.length);
  1452. for (var i = 0; i < stage.curgrades.length; i++) {
  1453. stage.curgrades[i].Clear();
  1454. }
  1455. GameManager.Instance.RecoveryCharacter();
  1456. }
  1457. CreatStage(_id) {
  1458. var stage = this.curstagedic[_id];
  1459. if (!stage) {
  1460. var config = AccountManager.Instance.curplayerData.GainCollocation("road");
  1461. var from = Math.floor(config.length * 0.8);
  1462. stage = this.curstagedic[GameTools.RandomANumber(from, config.length - 1)];
  1463. stage.Id = _id;
  1464. }
  1465. this.CreatStageResources(stage, _id);
  1466. return stage;
  1467. }
  1468. CreatStageResources(_stage, _id) {
  1469. for (var i = 0; i < _stage.curgrades.length; i++) {
  1470. _stage.curgrades[i].Creat(_stage, _id);
  1471. }
  1472. let stage = StageControl.Instance.curstagedic[_id];
  1473. let floornum = Math.floor(stage.endposition.z * 1.65 / 8.23) + 13;
  1474. let floorpos = -8.24;
  1475. for (let i = 0; i < floornum; i++) {
  1476. var _floor = GamePool.Instance.GetModel(AssetManager.Instance.Prop.get(19), "");
  1477. if (i > 0) {
  1478. _floor.transform.position = new Vector3$3(0, -0.5, floorpos);
  1479. floorpos += 8.24;
  1480. }
  1481. else {
  1482. _floor.transform.position = new Vector3$3(0, -0.5, -16.48);
  1483. }
  1484. AssetManager.Instance.mainscene.addChild(_floor);
  1485. this.floorarray.push(_floor);
  1486. this.LastGround = _floor.transform.position.z;
  1487. }
  1488. let planearray = [];
  1489. for (let i = 0; i < StageControl.Instance.curstagedic[_id].curgrades[0].planes.length; i++) {
  1490. if (StageControl.Instance.curstagedic[_id].curgrades[0].planes[i].long > 0) {
  1491. planearray.push(StageControl.Instance.curstagedic[_id].curgrades[0].planes[i]);
  1492. }
  1493. }
  1494. let first_plane = planearray[0].index;
  1495. let last_plane = planearray[planearray.length - 1].index;
  1496. let fenceLeft = (9 - (first_plane * 1.65)) + 1;
  1497. GameManager.Instance.fenceleftpos = fenceLeft;
  1498. let fenceRight = (9 - (last_plane * 1.65)) - 1;
  1499. GameManager.Instance.fencerightpos = fenceRight;
  1500. let treeLeft = (9 - (first_plane * 1.65)) + 5;
  1501. GameManager.Instance.treeleftpos = treeLeft;
  1502. let treeRight = (9 - (last_plane * 1.65)) - 4;
  1503. GameManager.Instance.treerightpos = treeRight;
  1504. let fencepos = -13.35;
  1505. let fencenum = _stage.endposition.z + 60;
  1506. for (let i = 0; i < fencenum; i++) {
  1507. var _fence = GamePool.Instance.GetModel(AssetManager.Instance.Small_Fence.get(1), "");
  1508. if (i > 0) {
  1509. _fence.transform.position = new Vector3$3(fenceLeft, 0, fencepos);
  1510. }
  1511. else {
  1512. _fence.transform.position = new Vector3$3(fenceLeft, 0, -15);
  1513. }
  1514. _fence.transform.rotationEuler = new Vector3$3(0, -90, 0);
  1515. AssetManager.Instance.mainscene.addChild(_fence);
  1516. GameTools.Instance.SetCollider(_fence, 100);
  1517. this.fencearray.push(_fence);
  1518. var _fence2 = GamePool.Instance.GetModel(AssetManager.Instance.Small_Fence.get(1), "");
  1519. if (i > 0) {
  1520. _fence2.transform.position = new Vector3$3(fenceRight, 0, fencepos);
  1521. }
  1522. else {
  1523. _fence2.transform.position = new Vector3$3(fenceRight, 0, -15);
  1524. }
  1525. _fence2.transform.rotationEuler = new Vector3$3(fenceRight, 90, 0);
  1526. fencepos += 1.65;
  1527. AssetManager.Instance.mainscene.addChild(_fence2);
  1528. GameTools.Instance.SetCollider(_fence2, 100);
  1529. this.fencearray.push(_fence2);
  1530. }
  1531. let treepos = 0;
  1532. let treenum = _stage.endposition.z * 1.65 / 5 + 65;
  1533. for (let i = 0; i < treenum; i++) {
  1534. var _random = GameTools.RandomANumber(1, 5);
  1535. var tree = GamePool.Instance.GetModel(AssetManager.Instance.Tree.get(_random), "");
  1536. if (i > 0) {
  1537. tree.transform.position = new Vector3$3(treeLeft, 0, treepos);
  1538. }
  1539. else {
  1540. tree.transform.position = new Vector3$3(treeLeft, 0, -20);
  1541. }
  1542. AssetManager.Instance.mainscene.addChild(tree);
  1543. this.treearray.push(tree);
  1544. var _random2 = GameTools.RandomANumber(1, 5);
  1545. var tree2 = GamePool.Instance.GetModel(AssetManager.Instance.Tree.get(_random2), "");
  1546. if (i > 0) {
  1547. tree2.transform.position = new Vector3$3(treeRight, 0, treepos);
  1548. }
  1549. else {
  1550. tree2.transform.position = new Vector3$3(treeRight, 0, -20);
  1551. }
  1552. AssetManager.Instance.mainscene.addChild(tree2);
  1553. this.treearray.push(tree2);
  1554. treepos += 3;
  1555. }
  1556. let STAGE = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
  1557. let boss = _stage.isboss == 1 ? true : false;
  1558. if (boss) {
  1559. let EndZ = _stage.curgrades[_stage.curgrades.length - 1].endpointpoint.z * 1.2;
  1560. let EndX = GameTools.RandomANumber(-2, 2);
  1561. GameManager.Instance.CreatBoss(new Vector3$3(EndX, 0, EndZ));
  1562. }
  1563. }
  1564. CreatGround(num) {
  1565. var startZ = this.LastGround;
  1566. var floorarr = [];
  1567. for (let i = 0; i < num; i++) {
  1568. var floor = GamePool.Instance.GetModel(AssetManager.Instance.Prop.get(19), "");
  1569. if (i > 0) {
  1570. floor.transform.position = new Vector3$3(0, -0.5, startZ);
  1571. }
  1572. else {
  1573. floor.transform.position = new Vector3$3(0, -0.5, startZ);
  1574. }
  1575. AssetManager.Instance.mainscene.addChild(floor);
  1576. this.floorarray.push(floor);
  1577. floorarr.push(floor);
  1578. startZ += 8.24;
  1579. }
  1580. this.LastGround = startZ;
  1581. var first = floorarr[0].transform.position.z;
  1582. var last = floorarr[floorarr.length - 1].transform.position.z;
  1583. this.CreatFence(first, last);
  1584. this.CreatTree(first, last);
  1585. }
  1586. CreatFence(_start, _end) {
  1587. var Fir = _start;
  1588. var End_Fence = this.curstage.curgrades[this.curstage.curgrades.length - 1].fencearray;
  1589. let fencenum = Math.floor((_end - _start) / 1.65) + 8;
  1590. for (let i = 0; i < fencenum; i++) {
  1591. var _fence = GamePool.Instance.GetModel(AssetManager.Instance.Small_Fence.get(1), "");
  1592. if (i > 0) {
  1593. _fence.transform.position = new Vector3$3(GameManager.Instance.fenceleftpos, 0, Fir);
  1594. }
  1595. else {
  1596. _fence.transform.position = new Vector3$3(GameManager.Instance.fenceleftpos, 0, Fir - 8.3);
  1597. }
  1598. AssetManager.Instance.mainscene.addChild(_fence);
  1599. End_Fence.push(_fence);
  1600. var _fence2 = GamePool.Instance.GetModel(AssetManager.Instance.Small_Fence.get(1), "");
  1601. if (i > 0) {
  1602. _fence2.transform.position = new Vector3$3(GameManager.Instance.fencerightpos, 0, Fir);
  1603. }
  1604. else {
  1605. _fence2.transform.position = new Vector3$3(GameManager.Instance.fencerightpos, 0, Fir - 8.3);
  1606. }
  1607. AssetManager.Instance.mainscene.addChild(_fence2);
  1608. End_Fence.push(_fence2);
  1609. Fir += 1.65;
  1610. }
  1611. }
  1612. CreatTree(_start, _end) {
  1613. var End_Fence = this.curstage.curgrades[this.curstage.curgrades.length - 1].scencerys;
  1614. let treenum = Math.floor((_end - _start) / 3) + 1;
  1615. for (let i = 0; i < treenum; i++) {
  1616. let _random = GameTools.RandomANumber(1, 5);
  1617. var _tree = GamePool.Instance.GetModel(AssetManager.Instance.Tree.get(_random), "");
  1618. _tree.transform.position = new Vector3$3(GameManager.Instance.treeleftpos, 0, _start);
  1619. AssetManager.Instance.mainscene.addChild(_tree);
  1620. End_Fence.push(_tree);
  1621. var _tree2 = GamePool.Instance.GetModel(AssetManager.Instance.Tree.get(_random), "");
  1622. _tree2.transform.position = new Vector3$3(GameManager.Instance.treerightpos, 0, _start);
  1623. AssetManager.Instance.mainscene.addChild(_tree2);
  1624. End_Fence.push(_tree2);
  1625. _start += 3;
  1626. }
  1627. }
  1628. }
  1629. class InGameView extends ui.InGameViewUI {
  1630. constructor() {
  1631. super();
  1632. InGameView.ins = this;
  1633. }
  1634. static get Instance() {
  1635. if (InGameView.ins) {
  1636. return InGameView.ins;
  1637. }
  1638. else {
  1639. return new InGameView();
  1640. }
  1641. }
  1642. Show() {
  1643. WXSDK.AldEvent("进入游戏内界面");
  1644. let stage = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
  1645. if (stage == 1) {
  1646. this.Guide1.visible = true;
  1647. this.ani1.play(0, true);
  1648. this.Guide2.visible = false;
  1649. this.Guide3.visible = false;
  1650. this.Guide4.visible = false;
  1651. }
  1652. else if (stage == 2) {
  1653. this.Guide1.visible = false;
  1654. this.Guide2.visible = false;
  1655. this.Guide3.visible = false;
  1656. this.Guide4.visible = false;
  1657. }
  1658. else {
  1659. this.Guide1.visible = false;
  1660. this.Guide2.visible = false;
  1661. this.Guide3.visible = false;
  1662. this.Guide4.visible = false;
  1663. }
  1664. this.GoldNum.text = AccountManager.Instance.curplayerData.GainAccount("money");
  1665. this.goaltext = this.GoalProgress.getChildByName("goal");
  1666. this.SetData();
  1667. this.InitUI();
  1668. this.height = Laya.stage.height;
  1669. Laya.stage.on(Laya.Event.RESIZE, this, () => {
  1670. this.height = Laya.stage.height;
  1671. });
  1672. }
  1673. Close() {
  1674. }
  1675. InitUI() {
  1676. this.goaltext.text = GameManager.Instance.KillNum.toString();
  1677. this.GoalProgress.value = GameManager.Instance.KillNum / StageControl.Instance.curstage.Goal;
  1678. }
  1679. SetData() {
  1680. SDKZS.SetHuTuiList(this.BottomList, 2, "");
  1681. this.GunGun();
  1682. }
  1683. GunGun() {
  1684. var maxBtm;
  1685. try {
  1686. this.BottomList.scrollBar.value = 0;
  1687. maxBtm = this.BottomList.scrollBar.max;
  1688. }
  1689. catch (error) {
  1690. console.error(error);
  1691. return;
  1692. }
  1693. var tempBtm = 1;
  1694. Laya.timer.frameLoop(1, this, () => {
  1695. this.BottomList.scrollBar.value += tempBtm;
  1696. if (this.BottomList.scrollBar.value >= maxBtm || this.BottomList.scrollBar.value <= 0) {
  1697. tempBtm = -tempBtm;
  1698. }
  1699. });
  1700. }
  1701. }
  1702. class GuangGao {
  1703. constructor() {
  1704. this.isVideoLoadCom = false;
  1705. GuangGao.ins = this;
  1706. }
  1707. static get Instance() {
  1708. if (GuangGao.ins) {
  1709. return GuangGao.ins;
  1710. }
  1711. else {
  1712. return new GuangGao();
  1713. }
  1714. }
  1715. static InitId() {
  1716. }
  1717. static JiaZaiShiPin() {
  1718. if (this.afsfsaafsfsa)
  1719. return;
  1720. if (!Laya.Browser.onWeiXin)
  1721. return;
  1722. this.fsaasfafssfa = Laya.Browser.window.wx.createRewardedVideoAd({ adUnitId: this.videlAdUnitId });
  1723. this.fsaasfafssfa.onLoad(() => {
  1724. console.log('激励视频 广告加载成功');
  1725. this.asfasfsaffsa = true;
  1726. });
  1727. this.fsaasfafssfa.onError(err => {
  1728. console.log("激励视屏加载失败:" + err);
  1729. this.asfasfsaffsa = false;
  1730. });
  1731. this.afsfasfasasf = 0;
  1732. this.afsfsaafsfsa = true;
  1733. }
  1734. static fassfafasafs(callback) {
  1735. this.fsaasfafssfa.offClose();
  1736. this.fsaasfafssfa.onClose(res => {
  1737. console.log("激励视频关闭:" + res.isEnded);
  1738. if (res && res.isEnded || res === undefined) {
  1739. callback && callback(true);
  1740. }
  1741. else {
  1742. callback && callback(false);
  1743. }
  1744. this.fsaasfafssfa.offClose();
  1745. });
  1746. }
  1747. showBanner(success = null, fail = null) {
  1748. if (!Laya.Browser.onWeiXin)
  1749. return;
  1750. let ad = GuangGao.bannerAdUnitId;
  1751. let bannerAd = Laya.Browser.window.wx.createBannerAd({
  1752. adUnitId: ad,
  1753. style: {
  1754. left: 0,
  1755. top: 0,
  1756. width: 460
  1757. }
  1758. });
  1759. bannerAd.onLoad(() => {
  1760. console.log("[LOG] Banner广告加载成功");
  1761. this.hideBanner();
  1762. this._bannerAd = bannerAd;
  1763. let info = Laya.Browser.window.wx.getSystemInfoSync();
  1764. this._bannerAd.style.width = info.windowWidth;
  1765. this._bannerAd.style.top = info.windowHeight - this._bannerAd.style.realHeight - 20;
  1766. this._bannerAd.show();
  1767. success && success(this._bannerAd);
  1768. });
  1769. bannerAd.onError(err => {
  1770. console.log("[LOG] Banner广告加载失败");
  1771. console.log(err);
  1772. fail && fail();
  1773. });
  1774. }
  1775. hideBanner() {
  1776. if (!Laya.Browser.onWeiXin)
  1777. return;
  1778. if (this._bannerAd) {
  1779. this._bannerAd.hide();
  1780. this._bannerAd.destroy();
  1781. this._bannerAd = null;
  1782. }
  1783. }
  1784. static OpenBanner(gap = 0, callVack = null, iswait = false) {
  1785. if (!Laya.Browser.onWeiXin)
  1786. return;
  1787. if (this.afsfasfasasf >= 10000) {
  1788. var hh = this.gasagsgasgsa(gap);
  1789. if (iswait) {
  1790. this.asgagassga.hide();
  1791. Laya.timer.once(AccountManager.Instance.curplayerData.wudaoshijian * 1000, this, () => {
  1792. if (callVack != null) {
  1793. callVack(hh);
  1794. }
  1795. this.asgagassga.show();
  1796. });
  1797. }
  1798. else {
  1799. if (callVack != null) {
  1800. callVack(hh);
  1801. }
  1802. this.asgagassga.show();
  1803. }
  1804. }
  1805. else {
  1806. var idd = this.bannerAdUnitId;
  1807. console.log("adUnitId:" + idd);
  1808. let newBanner = Laya.Browser.window.wx.createBannerAd({
  1809. adUnitId: idd,
  1810. style: {
  1811. left: 0,
  1812. top: 0,
  1813. width: 460
  1814. }
  1815. });
  1816. newBanner.onError(err => {
  1817. console.log("没有拉到banner--");
  1818. console.log(err);
  1819. newBanner = Laya.Browser.window.wx.createBannerAd({
  1820. adUnitId: idd,
  1821. style: {
  1822. left: 0,
  1823. top: 0,
  1824. width: 460
  1825. }
  1826. });
  1827. this.gasagsgasgsa(gap);
  1828. });
  1829. newBanner.onLoad(() => {
  1830. this.afsfasfasasf++;
  1831. if (this.asgagassga)
  1832. this.asgagassga.destroy();
  1833. this.asgagassga = newBanner;
  1834. var hight = this.gasagsgasgsa(gap);
  1835. if (iswait) {
  1836. this.asgagassga.hide();
  1837. Laya.timer.once(AccountManager.Instance.curplayerData.wudaoshijian * 1000, this, () => {
  1838. if (callVack != null) {
  1839. callVack(hight);
  1840. }
  1841. this.asgagassga.show();
  1842. });
  1843. }
  1844. else {
  1845. if (callVack != null) {
  1846. callVack(hight);
  1847. }
  1848. this.asgagassga.show();
  1849. }
  1850. });
  1851. }
  1852. }
  1853. static gasagsgasgsa(gap) {
  1854. if (this.asgagassga) {
  1855. let info = Laya.Browser.window.wx.getSystemInfoSync();
  1856. this.asgagassga.style.width = info.windowWidth;
  1857. this.asgagassga.style.top = info.windowHeight - this.asgagassga.style.realHeight - gap - 20;
  1858. return Laya.stage.height / info.windowHeight * this.asgagassga.style.realHeight;
  1859. }
  1860. }
  1861. static Clear() {
  1862. Laya.timer.clearAll(this);
  1863. if (!Laya.Browser.onWeiXin)
  1864. return;
  1865. if (this.asgagassga)
  1866. this.asgagassga.hide();
  1867. }
  1868. static agagsagags() {
  1869. if (!Laya.Browser.onWeiXin)
  1870. return;
  1871. if (this.asgagassga)
  1872. this.asgagassga.hide();
  1873. }
  1874. static gasagsasg() {
  1875. if (!Laya.Browser.onWeiXin)
  1876. return;
  1877. if (this.asgagassga)
  1878. this.asgagassga.show();
  1879. }
  1880. static get keyiwudao() {
  1881. var wudao = AccountManager.Instance.curplayerData.Cheat;
  1882. if (wudao == false) {
  1883. console.log("cheat:" + wudao);
  1884. return false;
  1885. }
  1886. if (Main.SceneNum == "1037" || Main.SceneNum == "1058"
  1887. || Main.SceneNum == "1067" || Main.SceneNum == "1095") {
  1888. console.log("cheat:true-> " + Main.SceneNum);
  1889. return true;
  1890. }
  1891. else {
  1892. var checkscence = AccountManager.Instance.curplayerData.CheckScene;
  1893. if (checkscence == false) {
  1894. console.log("cheat:true->checkscence: " + checkscence);
  1895. return true;
  1896. }
  1897. }
  1898. console.log("cheat:false-> " + Main.SceneNum);
  1899. return false;
  1900. }
  1901. static WudaoAnNiu(btn, ShowBanner = true, complete = null, gap = 0) {
  1902. if (AccountManager.Instance.curplayerData.Banner) {
  1903. GuangGao.agagsagags();
  1904. if (GuangGao.keyiwudao == false) {
  1905. btn.bottom = 350;
  1906. GuangGao.OpenBanner();
  1907. }
  1908. else {
  1909. if (ShowBanner) {
  1910. btn.bottom = 100;
  1911. btn.mouseEnabled = false;
  1912. console.log("bottom:100");
  1913. GuangGao.OpenBanner(gap, (height) => {
  1914. if (height == null) {
  1915. console.log("展示互推位");
  1916. var end = Laya.stage.height - height - btn.height;
  1917. btn.y = end;
  1918. btn.bottom = NaN;
  1919. }
  1920. else {
  1921. var end = Laya.stage.height - height - btn.height;
  1922. btn.y = end - 100;
  1923. btn.bottom = NaN;
  1924. console.log("y:" + end);
  1925. }
  1926. }, true);
  1927. Laya.timer.once(AccountManager.Instance.curplayerData.wudaoshijian * 1000, this, () => {
  1928. btn.mouseEnabled = true;
  1929. if (complete != null) {
  1930. complete();
  1931. }
  1932. });
  1933. }
  1934. else {
  1935. if (complete != null) {
  1936. complete();
  1937. }
  1938. }
  1939. }
  1940. }
  1941. }
  1942. loadVideo(cb) {
  1943. if (!Laya.Browser.onWeiXin) {
  1944. if (cb)
  1945. cb(true);
  1946. return;
  1947. }
  1948. this._onLoadVideo = cb;
  1949. if (!this._rewardedVideoAd) {
  1950. let index = GuangGao.videlAdUnitId;
  1951. this._rewardedVideoAd = Laya.Browser.window.wx.createRewardedVideoAd({ adUnitId: index });
  1952. var isc = false;
  1953. this._rewardedVideoAd.onLoad(() => {
  1954. console.log("[LOG] 激励视频广告加载成功");
  1955. this.isVideoLoadCom = true;
  1956. if (isc)
  1957. return;
  1958. isc = true;
  1959. this._onLoadVideo && this._onLoadVideo(true);
  1960. this._onLoadVideo = null;
  1961. });
  1962. this._rewardedVideoAd.onError(err => {
  1963. console.log("[LOG] 激励视频广告加载失败");
  1964. console.log(err);
  1965. this.isVideoLoadCom = false;
  1966. this._onLoadVideo && this._onLoadVideo(false);
  1967. this._onLoadVideo = null;
  1968. });
  1969. this._rewardedVideoAd.onClose(res => {
  1970. if (!res || res.isEnded) {
  1971. this._onVideoClose && this._onVideoClose(true);
  1972. this._onVideoClose = null;
  1973. }
  1974. else {
  1975. this._onVideoClose && this._onVideoClose(false);
  1976. this._onVideoClose = null;
  1977. }
  1978. });
  1979. }
  1980. else {
  1981. if (this.isVideoLoadCom) {
  1982. this._onLoadVideo && this._onLoadVideo(true);
  1983. this._onLoadVideo = null;
  1984. }
  1985. else {
  1986. this._onLoadVideo && this._onLoadVideo(false);
  1987. this._onLoadVideo = null;
  1988. }
  1989. }
  1990. }
  1991. showVideo(cb) {
  1992. if (!Laya.Browser.onWeiXin) {
  1993. if (cb)
  1994. cb(true);
  1995. return;
  1996. }
  1997. this._onVideoClose = cb;
  1998. this._rewardedVideoAd.show().catch(err => {
  1999. this._rewardedVideoAd.load().then(() => {
  2000. this._rewardedVideoAd.show();
  2001. });
  2002. });
  2003. }
  2004. }
  2005. GuangGao.videlAdUnitId = "adunit-40ac03a5538e8de0";
  2006. GuangGao.bannerAdUnitId = "adunit-dc3e1cfa3ac69be3";
  2007. GuangGao.afsfsaafsfsa = false;
  2008. GuangGao.asfasfsaffsa = false;
  2009. GuangGao.afsfasfasasf = 0;
  2010. class ShopItem extends Laya.Script {
  2011. constructor() {
  2012. super();
  2013. this.use = false;
  2014. ShopItem.ins = this;
  2015. }
  2016. static get Instance() {
  2017. if (ShopItem.ins) {
  2018. return ShopItem.ins;
  2019. }
  2020. else {
  2021. return new ShopItem();
  2022. }
  2023. }
  2024. onAwake() {
  2025. this.selfobj = this.owner;
  2026. this._select = this.selfobj.getChildByName("choose");
  2027. this._skin = this.selfobj.getChildByName("icon");
  2028. this.using = this.selfobj.getChildByName("used");
  2029. this.click1_btn = this.selfobj.getChildByName("btn");
  2030. this.click1_btn.clickHandler = new Laya.Handler(this, this._ClickHander);
  2031. EventManager.EventOn(EventState.Select, this, this.ShowSelect);
  2032. }
  2033. RefreshItem(any, comeType) {
  2034. this.comeType = comeType;
  2035. if (any)
  2036. this.instance = any;
  2037. else
  2038. this.instance = ShopView.Instance;
  2039. this._data = (this.selfobj.dataSource);
  2040. var _id = this._data.id;
  2041. var usingId = AccountManager.Instance.curplayerData.GetUser(AccountUser.equip_themes)["1"];
  2042. var usingId2 = AccountManager.Instance.curplayerData.GetUser(AccountUser.equip_themes)["2"];
  2043. var hasequip = AccountManager.Instance.curplayerData.HasEquip(_id);
  2044. var require_type = this._data.require_type;
  2045. this._skin.skin = "Game/res/Skin/" + this._data.icon + ".png";
  2046. this._skin.rotation = 0;
  2047. if (usingId == _id || usingId2 == _id) {
  2048. this.skinGetForType = SkinGetForType.Using;
  2049. this.showui();
  2050. return;
  2051. }
  2052. if (hasequip) {
  2053. this.skinGetForType = SkinGetForType.Geted;
  2054. this.showui();
  2055. return;
  2056. }
  2057. if (require_type == 2) {
  2058. this.skinGetForType = SkinGetForType.Bycoin;
  2059. this.showui();
  2060. return;
  2061. }
  2062. if (require_type == 4) {
  2063. this.skinGetForType = SkinGetForType.GetByActivity;
  2064. this.showui();
  2065. return;
  2066. }
  2067. if (require_type == 3) {
  2068. this.skinGetForType = SkinGetForType.GetByVideo;
  2069. this.showui();
  2070. return;
  2071. }
  2072. }
  2073. showui() {
  2074. var type = this.skinGetForType;
  2075. if (this._data.id == 1 || this._data.id == 50) {
  2076. this._select.visible = true;
  2077. }
  2078. else {
  2079. this._select.visible = false;
  2080. }
  2081. if (this.skinGetForType == SkinGetForType.Using) {
  2082. this.using.visible = true;
  2083. }
  2084. else {
  2085. this.using.visible = false;
  2086. }
  2087. }
  2088. ShowUi() {
  2089. var type = this.skinGetForType;
  2090. this._select.visible = type == SkinGetForType.Using;
  2091. if (this.skinGetForType == SkinGetForType.Using) {
  2092. this.using.visible = true;
  2093. }
  2094. else {
  2095. this.using.visible = false;
  2096. }
  2097. }
  2098. _ClickHander() {
  2099. this.instance._data = this._data;
  2100. ShopView.Instance.RefreshButton(this.skinGetForType);
  2101. this.instance.showroleId = this._data.id;
  2102. this.ShowUi();
  2103. this.ShowModel();
  2104. }
  2105. ShowModel() {
  2106. EventManager.EventTrigger(EventState.Select);
  2107. }
  2108. ShowSelect() {
  2109. if (!this._data) {
  2110. return;
  2111. }
  2112. this._select.visible = this.instance.showroleId == this._data.id;
  2113. }
  2114. }
  2115. var SkinGetForType;
  2116. (function (SkinGetForType) {
  2117. SkinGetForType[SkinGetForType["Geted"] = 1] = "Geted";
  2118. SkinGetForType[SkinGetForType["Bycoin"] = 2] = "Bycoin";
  2119. SkinGetForType[SkinGetForType["GetByVideo"] = 3] = "GetByVideo";
  2120. SkinGetForType[SkinGetForType["GetByActivity"] = 4] = "GetByActivity";
  2121. SkinGetForType[SkinGetForType["Using"] = -1] = "Using";
  2122. })(SkinGetForType || (SkinGetForType = {}));
  2123. class ShopView extends ui.SkinViewUI {
  2124. constructor() {
  2125. super();
  2126. this.firstopen = true;
  2127. this.showroleId = 0;
  2128. this.uiArr = [];
  2129. this.CapArray = [];
  2130. this.HorseArray = [];
  2131. ShopView.ins = this;
  2132. }
  2133. static get Instance() {
  2134. if (ShopView.ins == null) {
  2135. console.log("new shopview");
  2136. return new ShopView();
  2137. }
  2138. return ShopView.ins;
  2139. }
  2140. Show() {
  2141. WXSDK.AldEvent("打开皮肤商店界面");
  2142. let data = AccountManager.Instance.curplayerData.GainCollocation("theme");
  2143. for (let i = 0; i < data.length; i++) {
  2144. if (i < 5) {
  2145. this.CapArray.push(data[i]);
  2146. }
  2147. else {
  2148. this.HorseArray.push(data[i]);
  2149. }
  2150. }
  2151. this.BackBtn.clickHandler = new Laya.Handler(this, this.ClickClose);
  2152. this.CharacterBtn.clickHandler = new Laya.Handler(this, this.ClickCap);
  2153. this.HorseBtn.clickHandler = new Laya.Handler(this, this.ClickHorse);
  2154. this.GetBtn.clickHandler = new Laya.Handler(this, this.ClickGet);
  2155. this.VideoGetCoinBtn.clickHandler = new Laya.Handler(this, this.VideoGet);
  2156. this.CharacterLightImage = this.CharacterBtn.getChildByName("light");
  2157. this.HorseLightImage = this.HorseBtn.getChildByName("light");
  2158. this.GetByCoin = this.GetBtn.getChildByName("GetByCoin");
  2159. this.RequireCoinNum = this.GetByCoin.getChildByName("CoinNum");
  2160. this.GetByVideo = this.GetBtn.getChildByName("GetByVideo");
  2161. this.RequireVideoNum = this.GetByVideo.getChildByName("VideoNum");
  2162. this.GetByActive = this.GetBtn.getChildByName("GetByActive");
  2163. this.Geted = this.GetBtn.getChildByName("Geted");
  2164. this.Using = this.GetBtn.getChildByName("Using");
  2165. this.uiArr.push(this.Using);
  2166. this.uiArr.push(this.Geted);
  2167. this.uiArr.push(this.GetByCoin);
  2168. this.uiArr.push(this.GetByVideo);
  2169. this.uiArr.push(this.GetByActive);
  2170. this.equip_Horse = AccountManager.Instance.curplayerData.GetUser(AccountUser.equip_themes)["2"];
  2171. this.equip_Cap = AccountManager.Instance.curplayerData.GetUser(AccountUser.equip_themes)["1"];
  2172. this.showroleId = 1;
  2173. this.ItemList.selectEnable = false;
  2174. this.ItemList.vScrollBarSkin = "";
  2175. this.ItemList.renderHandler = Laya.Handler.create(this, this.UpdateItem, null, false);
  2176. this.ItemList.array = this.CapArray;
  2177. this.ItemList.refresh();
  2178. this.ShowButton(1);
  2179. this.height = Laya.stage.height;
  2180. Laya.stage.on(Laya.Event.RESIZE, this, () => {
  2181. this.height = Laya.stage.height;
  2182. });
  2183. }
  2184. Close() {
  2185. WXSDK.AldEvent("关闭皮肤商城界面");
  2186. }
  2187. ClickClose() {
  2188. var equiphorseid = Number(AccountManager.Instance.curplayerData.GetUser(AccountUser.equip_themes)["2"]);
  2189. var equipcap = Number(AccountManager.Instance.curplayerData.GetUser(AccountUser.equip_themes)["1"]);
  2190. if (equipcap) {
  2191. if (equipcap != this.equip_Cap) {
  2192. GameManager.Instance.SetCap(equipcap);
  2193. }
  2194. }
  2195. if (equiphorseid != this.equip_Horse) {
  2196. GameManager.Instance.SetHorse(equiphorseid);
  2197. }
  2198. ViewManager.Instance.ShowView(ViewType.MainView);
  2199. }
  2200. UpdateItem(cell, index) {
  2201. let item = cell.getComponent(ShopItem);
  2202. item.RefreshItem();
  2203. }
  2204. RefreshItem() {
  2205. this.ItemList.refresh();
  2206. }
  2207. ClickCap() {
  2208. this.firstopen = true;
  2209. if (this.equip_Cap) {
  2210. this.showroleId = this.equip_Cap;
  2211. }
  2212. else {
  2213. this.showroleId = 1;
  2214. }
  2215. this.ShowButton(1);
  2216. this.CharacterLightImage.visible = true;
  2217. this.HorseLightImage.visible = false;
  2218. this.ItemList.vScrollBarSkin = "";
  2219. this.ItemList.array = this.CapArray;
  2220. this.ItemList.renderHandler = Laya.Handler.create(this, this.UpdateItem, null, false);
  2221. }
  2222. ClickHorse() {
  2223. this.firstopen = true;
  2224. this.showroleId = this.equip_Horse;
  2225. this.ShowButton(2);
  2226. this.CharacterLightImage.visible = false;
  2227. this.HorseLightImage.visible = true;
  2228. this.ItemList.vScrollBarSkin = "";
  2229. this.ItemList.array = this.HorseArray;
  2230. this.ItemList.renderHandler = Laya.Handler.create(this, this.UpdateItem, null, false);
  2231. }
  2232. RefreshButton(_skinGetForType) {
  2233. this.skinGetForType = _skinGetForType;
  2234. this.ShowUI(this.skinGetForType);
  2235. }
  2236. ShowButton(type) {
  2237. if (type == 1) {
  2238. var equipcap = Number(AccountManager.Instance.curplayerData.GetUser(AccountUser.equip_themes)["1"]);
  2239. var usingId = equipcap;
  2240. let item = this.CapArray[0].require_type;
  2241. this._data = this.CapArray[0];
  2242. var _id = this._data.id;
  2243. var hasequip = AccountManager.Instance.curplayerData.HasEquip(_id);
  2244. var require_type = item;
  2245. if (usingId == _id) {
  2246. this.skinGetForType = SkinGetForType.Using;
  2247. this.RefreshButton(this.skinGetForType);
  2248. return;
  2249. }
  2250. if (hasequip) {
  2251. this.skinGetForType = SkinGetForType.Geted;
  2252. this.RefreshButton(this.skinGetForType);
  2253. return;
  2254. }
  2255. if (require_type == 2) {
  2256. this.skinGetForType = SkinGetForType.Bycoin;
  2257. this.RefreshButton(this.skinGetForType);
  2258. return;
  2259. }
  2260. if (require_type == 4) {
  2261. this.skinGetForType = SkinGetForType.GetByActivity;
  2262. this.RefreshButton(this.skinGetForType);
  2263. return;
  2264. }
  2265. if (require_type == 3) {
  2266. this.skinGetForType = SkinGetForType.GetByVideo;
  2267. this.RefreshButton(this.skinGetForType);
  2268. return;
  2269. }
  2270. }
  2271. else {
  2272. var equiphorse = Number(AccountManager.Instance.curplayerData.GetUser(AccountUser.equip_themes)["2"]);
  2273. var usingId = equiphorse;
  2274. let item = this.HorseArray[0].require_type;
  2275. this._data = this.HorseArray[0];
  2276. var _id = this._data.id;
  2277. var hasequip = AccountManager.Instance.curplayerData.HasEquip(_id);
  2278. var require_type = item;
  2279. if (usingId == _id) {
  2280. this.skinGetForType = SkinGetForType.Using;
  2281. this.RefreshButton(this.skinGetForType);
  2282. return;
  2283. }
  2284. if (hasequip) {
  2285. this.skinGetForType = SkinGetForType.Geted;
  2286. this.RefreshButton(this.skinGetForType);
  2287. return;
  2288. }
  2289. if (require_type == 2) {
  2290. this.skinGetForType = SkinGetForType.Bycoin;
  2291. this.RefreshButton(this.skinGetForType);
  2292. return;
  2293. }
  2294. if (require_type == 4) {
  2295. this.skinGetForType = SkinGetForType.GetByActivity;
  2296. this.RefreshButton(this.skinGetForType);
  2297. return;
  2298. }
  2299. if (require_type == 3) {
  2300. this.skinGetForType = SkinGetForType.GetByVideo;
  2301. this.RefreshButton(this.skinGetForType);
  2302. return;
  2303. }
  2304. }
  2305. }
  2306. ClickGet() {
  2307. switch (this.skinGetForType) {
  2308. case SkinGetForType.Bycoin:
  2309. var money = Number(AccountManager.Instance.curplayerData.GainAccount("money"));
  2310. if (money < Number(this._data.require_num)) {
  2311. WXSDK.ShowTxt("金币不足--");
  2312. }
  2313. else {
  2314. this.Buy();
  2315. }
  2316. console.log("金币--");
  2317. break;
  2318. case SkinGetForType.GetByActivity:
  2319. WXSDK.ShowTxt("暂未开放!");
  2320. console.log("活动获取--");
  2321. break;
  2322. case SkinGetForType.GetByVideo:
  2323. console.log("视频获取--");
  2324. this.VideoGet();
  2325. break;
  2326. case SkinGetForType.Geted:
  2327. this.Use();
  2328. break;
  2329. }
  2330. }
  2331. ShowUI(_type) {
  2332. console.log("所需类型--", _type);
  2333. if (_type == SkinGetForType.Using) {
  2334. for (let index = 0; index < this.uiArr.length; index++) {
  2335. if (index == 0) {
  2336. this.uiArr[index].visible = true;
  2337. }
  2338. else {
  2339. this.uiArr[index].visible = false;
  2340. }
  2341. }
  2342. return;
  2343. }
  2344. this.Using.visible = false;
  2345. for (let index = 1; index < this.uiArr.length; index++) {
  2346. if (index == _type) {
  2347. this.uiArr[index].visible = true;
  2348. }
  2349. else {
  2350. this.uiArr[index].visible = false;
  2351. }
  2352. }
  2353. switch (_type) {
  2354. case SkinGetForType.Bycoin:
  2355. this.RequireCoinNum.text = this._data.require_num.toString();
  2356. break;
  2357. case SkinGetForType.GetByVideo:
  2358. this.RequireVideoNum.text = AccountManager.Instance.curplayerData.GetProgress(this._data.id) + "/" + this._data.require_num.toString();
  2359. break;
  2360. }
  2361. }
  2362. VideoGet() {
  2363. GuangGao.Instance.loadVideo(isLoaded => {
  2364. if (isLoaded) {
  2365. GuangGao.Instance.showVideo(isOk => {
  2366. if (isOk) {
  2367. WXSDK.AldEvent("皮肤界面看视频得金币成功");
  2368. var getkey = ArcherWorrior.vd;
  2369. let param = [{ "reward_item": "1000" }, { "reward_num": "200" }, { "t": AccountManager.Instance.ServerTime.toString() }];
  2370. ServerManager.Instance.SendHttp(getkey, param, Laya.Handler.create(this, this.VideoGetSuccess), Laya.Handler.create(this, this.VideoGetFail));
  2371. }
  2372. });
  2373. }
  2374. else {
  2375. WXSDK.fengxiangtupian(isOk => {
  2376. if (isOk) {
  2377. WXSDK.AldEvent("皮肤界面看视频得金币成功");
  2378. var getkey = ArcherWorrior.vd;
  2379. let param = [{ "reward_item": "1000" }, { "reward_num": "200" }, { "t": AccountManager.Instance.ServerTime.toString() }];
  2380. ServerManager.Instance.SendHttp(getkey, param, Laya.Handler.create(this, this.VideoGetSuccess), Laya.Handler.create(this, this.VideoGetFail));
  2381. }
  2382. });
  2383. }
  2384. });
  2385. }
  2386. VideoGetSuccess(_data) {
  2387. this.RefreshItem();
  2388. console.log("LookVideo->suc:" + JSON.stringify(_data));
  2389. }
  2390. VideoGetFail(_data) {
  2391. console.log("LookVideo->fail:" + JSON.stringify(_data));
  2392. }
  2393. Use() {
  2394. var agrs = [{ "id": this._data.id }];
  2395. ServerManager.Instance.SendHttp(ArcherWorrior.WearEquip, agrs, Laya.Handler.create(this, this.UseSuccess), Laya.Handler.create(this, this.UseFail));
  2396. }
  2397. UseSuccess(data) {
  2398. this.RefreshItem();
  2399. this.RefreshButton(SkinGetForType.Using);
  2400. WXSDK.ShowTxt("装备成功!");
  2401. console.log("装备suc:" + JSON.stringify(data));
  2402. }
  2403. UseFail(data) {
  2404. console.log(data);
  2405. }
  2406. Buy() {
  2407. var agrs = [{ "id": this._data.id.toString() }];
  2408. ServerManager.Instance.SendHttp(ArcherWorrior.BuyEquip, agrs, Laya.Handler.create(this, this.BuySuccess), Laya.Handler.create(this, this.BuyFail));
  2409. }
  2410. BuySuccess(data) {
  2411. WXSDK.AldEvent("购买" + this._data.name + "成功");
  2412. this.RefreshItem();
  2413. this.RefreshButton(SkinGetForType.Using);
  2414. console.log("购买suc:" + JSON.stringify(data));
  2415. }
  2416. BuyFail(data) {
  2417. console.log("购买fail:" + JSON.stringify(data));
  2418. }
  2419. }
  2420. class ShopScene {
  2421. constructor() {
  2422. this.first = true;
  2423. this.motordic = new ResDic();
  2424. ShopScene.ins = this;
  2425. }
  2426. static get Instance() {
  2427. if (ShopScene.ins) {
  2428. return ShopScene.ins;
  2429. }
  2430. else {
  2431. return new ShopScene();
  2432. }
  2433. }
  2434. CreateMoto(_motorindex, _image, trial = null) {
  2435. if (!this._shopscene || this._shopscene.destroyed || this._shopscene == null) {
  2436. this.first = true;
  2437. this._shopscene = new Laya.Scene3D();
  2438. this._camera = new Laya.Camera();
  2439. if (trial) {
  2440. this._camera.transform.position = new Laya.Vector3(0, 0.7, 3);
  2441. this._camera.clearFlag = 2;
  2442. this._camera.fieldOfView = 40;
  2443. }
  2444. else {
  2445. this._camera.transform.position = new Laya.Vector3(0, 0.6, 3.5);
  2446. this._camera.clearFlag = 2;
  2447. this._camera.fieldOfView = 30;
  2448. }
  2449. this._shopscene.addChild(this._camera);
  2450. let _light = new Laya.DirectionLight();
  2451. _light.intensity = 0.5;
  2452. this._shopscene.addChild(_light);
  2453. var player = GamePool.Instance.GetModel(AssetManager.Instance.Horse.get(_motorindex), "");
  2454. this._shopscene.addChild(player);
  2455. _image.addChild(this._shopscene);
  2456. player.transform.position = new Laya.Vector3(0, 0, -2);
  2457. this._position = new Laya.Vector3(0, 0.01, 0);
  2458. }
  2459. if (_image) {
  2460. this._camera.viewport = new Laya.Viewport(_image.x, _image.y, _image.width, _image.height);
  2461. }
  2462. if (this._motor) {
  2463. this._motor.active = false;
  2464. this._motor.removeSelf();
  2465. this._motor = null;
  2466. }
  2467. if (!this.first)
  2468. return;
  2469. this.first = false;
  2470. Laya.timer.frameLoop(1, this, this.Rotation, [player]);
  2471. }
  2472. Rotation(model) {
  2473. model.transform.rotate(this._position);
  2474. }
  2475. CloseShop() {
  2476. Laya.timer.clear(this, this.Rotation);
  2477. if (this._motor) {
  2478. this._motor.active = false;
  2479. this._motor.removeSelf();
  2480. }
  2481. if (this._player) {
  2482. this._player.active = false;
  2483. this._player.removeSelf();
  2484. }
  2485. if (this._shopscene) {
  2486. this._shopscene.destroy(true);
  2487. }
  2488. this._shopscene = null;
  2489. this._motor = null;
  2490. this._sprite = null;
  2491. this._player = null;
  2492. this.first = true;
  2493. }
  2494. }
  2495. class TrialView extends ui.TrialViewUI {
  2496. constructor() {
  2497. super();
  2498. }
  2499. static get Instance() {
  2500. if (TrialView.ins) {
  2501. return TrialView.ins;
  2502. }
  2503. else {
  2504. return new TrialView();
  2505. }
  2506. }
  2507. Show() {
  2508. WXSDK.AldEvent("打开皮肤试用界面");
  2509. GuangGao.OpenBanner();
  2510. this.Init();
  2511. this.TrialBtn.clickHandler = Laya.Handler.create(this, this.Trial);
  2512. this.NoTrialBtn.visible = false;
  2513. Laya.timer.once(2000, this, () => {
  2514. this.NoTrialBtn.visible = true;
  2515. this.NoTrialBtn.clickHandler = Laya.Handler.create(this, this.ClickClose);
  2516. });
  2517. this.height = Laya.stage.height;
  2518. Laya.stage.on(Laya.Event.RESIZE, this, () => {
  2519. this.height = Laya.stage.height;
  2520. });
  2521. }
  2522. Close() {
  2523. WXSDK.AldEvent("关闭皮肤试用界面");
  2524. }
  2525. ClickClose() {
  2526. var agrs = [{ "t": AccountManager.Instance.ServerTime.toString() }];
  2527. ServerManager.Instance.SendHttp(ArcherWorrior.KaiShi, agrs, Laya.Handler.create(this, this.Complete), null);
  2528. }
  2529. Trial() {
  2530. GuangGao.Instance.loadVideo(isLoaded => {
  2531. if (isLoaded) {
  2532. GuangGao.Instance.showVideo(isOk => {
  2533. if (isOk) {
  2534. WXSDK.AldEvent("观看视频试用皮肤成功");
  2535. var agrs = [{ "t": AccountManager.Instance.ServerTime.toString() }];
  2536. ServerManager.Instance.SendHttp(ArcherWorrior.KaiShi, agrs, Laya.Handler.create(this, this.Complete), null);
  2537. GameManager.Instance.SetHorse(this.arr.id);
  2538. }
  2539. else {
  2540. WXSDK.AldEvent("观看视频试用皮肤失败");
  2541. var agrs = [{ "t": AccountManager.Instance.ServerTime.toString() }];
  2542. ServerManager.Instance.SendHttp(ArcherWorrior.KaiShi, agrs, Laya.Handler.create(this, this.Complete), null);
  2543. }
  2544. });
  2545. }
  2546. else {
  2547. WXSDK.fengxiangtupian(isOk => {
  2548. if (isOk) {
  2549. WXSDK.AldEvent("分享好友试用皮肤成功");
  2550. var agrs = [{ "t": AccountManager.Instance.ServerTime.toString() }];
  2551. ServerManager.Instance.SendHttp(ArcherWorrior.KaiShi, agrs, Laya.Handler.create(this, this.Complete), null);
  2552. GameManager.Instance.SetHorse(this.arr.id);
  2553. }
  2554. else {
  2555. WXSDK.AldEvent("分享好友试用皮肤失败");
  2556. var agrs = [{ "t": AccountManager.Instance.ServerTime.toString() }];
  2557. ServerManager.Instance.SendHttp(ArcherWorrior.KaiShi, agrs, Laya.Handler.create(this, this.Complete), null);
  2558. }
  2559. });
  2560. }
  2561. });
  2562. }
  2563. Complete(_data) {
  2564. ShopScene.Instance.CloseShop();
  2565. ViewManager.Instance.ShowView(ViewType.IngameView);
  2566. let stage = AccountManager.Instance.curplayerData.GainAccount("stage");
  2567. WXSDK.AldStart(stage);
  2568. AudioManager.playMusic(MusicType.click);
  2569. MainGameView.Instance.play_id = _data.play_id;
  2570. EventManager.StageTrigger(StageState.Start);
  2571. ViewManager.Instance.ShowView(ViewType.IngameView);
  2572. }
  2573. Init() {
  2574. this.data = this.GetTryOutTheme();
  2575. this.count = this.data.length;
  2576. if (this.count == 1) {
  2577. this.arr = this.data[0];
  2578. }
  2579. else {
  2580. let index = GameTools.RandomANumber(0, this.count);
  2581. this.arr = this.data[index];
  2582. }
  2583. ShopScene.Instance.CreateMoto(this.arr.id, this.SceneViewPort, 1);
  2584. }
  2585. GetTryOutTheme() {
  2586. let arr = [];
  2587. let themeCfg = AccountManager.Instance.curplayerData.GainCollocation("theme");
  2588. let temp;
  2589. if (themeCfg) {
  2590. for (let index = 5; index < themeCfg.length; index++) {
  2591. const element = themeCfg[index];
  2592. let _id = element.id;
  2593. if (!AccountManager.Instance.curplayerData.HasEquip(_id)) {
  2594. arr.push(element);
  2595. }
  2596. if (index == themeCfg.length - 2) {
  2597. temp = element;
  2598. }
  2599. }
  2600. }
  2601. if (arr.length == 0)
  2602. arr.push(temp);
  2603. return arr;
  2604. }
  2605. }
  2606. class CompleteView extends ui.CompleteViewUI {
  2607. constructor() {
  2608. super();
  2609. this.win = true;
  2610. }
  2611. static get Instance() {
  2612. if (CompleteView.ins) {
  2613. return CompleteView.ins;
  2614. }
  2615. else {
  2616. return new CompleteView();
  2617. }
  2618. }
  2619. Show(_data) {
  2620. this.Init(_data);
  2621. GuangGao.WudaoAnNiu(this.BtnBox);
  2622. let gold = this.DealData(GameManager.Instance.KillNum);
  2623. this.goldnum.text = Math.floor(gold).toString();
  2624. this.SetData();
  2625. this.height = Laya.stage.height;
  2626. Laya.stage.on(Laya.Event.RESIZE, this, () => {
  2627. this.height = Laya.stage.height;
  2628. });
  2629. }
  2630. Close() {
  2631. }
  2632. Init(_data) {
  2633. switch (_data) {
  2634. case 1:
  2635. WXSDK.AldEvent("打开胜利界面");
  2636. this.loseimage.visible = false;
  2637. this.reviveimage.visible = false;
  2638. this.NoBtn.visible = false;
  2639. this.TryAgainBtn.visible = false;
  2640. this.ReviveBtn.visible = false;
  2641. this.NextLevelBtn.clickHandler = Laya.Handler.create(this, this.NextLevel, [true]);
  2642. break;
  2643. case 2:
  2644. WXSDK.AldEvent("打开失败界面");
  2645. this.winimage.visible = false;
  2646. this.reviveimage.visible = false;
  2647. this.NoBtn.visible = false;
  2648. this.NextLevelBtn.visible = false;
  2649. this.ReviveBtn.visible = false;
  2650. this.TryAgainBtn.clickHandler = Laya.Handler.create(this, this.TryAgain, [false]);
  2651. break;
  2652. case 3:
  2653. WXSDK.AldEvent("打开结算界面");
  2654. this.winimage.visible = false;
  2655. this.loseimage.visible = false;
  2656. this.NextLevelBtn.visible = false;
  2657. this.TryAgainBtn.visible = false;
  2658. this.NoBtn.clickHandler = Laya.Handler.create(this, this.NoRevive);
  2659. this.ReviveBtn.clickHandler = Laya.Handler.create(this, this.Revive);
  2660. }
  2661. }
  2662. NextLevel(_win) {
  2663. let stage = AccountManager.Instance.curplayerData.GainAccount("stage");
  2664. WXSDK.AldEnd(stage, true);
  2665. AudioManager.playMusic(MusicType.click);
  2666. this.win = _win;
  2667. var iswin = _win ? "1" : "0";
  2668. var coinnum = this.goldnum.text;
  2669. var args = [{ "t": AccountManager.Instance.ServerTime.toString() }, { "play_id": MainGameView.Instance.play_id }, { "win": iswin }, { "money": coinnum }];
  2670. ServerManager.Instance.SendHttp(ArcherWorrior.JieShu, args, Laya.Handler.create(this, this.Success), null);
  2671. }
  2672. Revive() {
  2673. AudioManager.playMusic(MusicType.click);
  2674. GuangGao.Instance.loadVideo(isLoaded => {
  2675. if (isLoaded) {
  2676. GuangGao.Instance.showVideo(isOk => {
  2677. if (isOk) {
  2678. WXSDK.AldEvent("观看视频复活成功");
  2679. GameManager.Instance.ReviveNum -= 1;
  2680. GameManager.Instance.Revive();
  2681. }
  2682. });
  2683. }
  2684. else {
  2685. WXSDK.fengxiangtupian(isOk => {
  2686. if (isOk) {
  2687. WXSDK.AldEvent("分享复活成功");
  2688. GameManager.Instance.ReviveNum -= 1;
  2689. GameManager.Instance.Revive();
  2690. }
  2691. else {
  2692. EventManager.StageTrigger(StageState.Lose);
  2693. }
  2694. });
  2695. }
  2696. });
  2697. }
  2698. NoRevive() {
  2699. GameManager.Instance.ReviveNum -= 1;
  2700. ViewManager.Instance.ShowView(ViewType.CompleteView, 2);
  2701. }
  2702. TryAgain(_win) {
  2703. let stage = AccountManager.Instance.curplayerData.GainAccount("stage");
  2704. WXSDK.AldEnd(stage, false);
  2705. AudioManager.playMusic(MusicType.click);
  2706. this.win = _win;
  2707. var iswin = _win ? "1" : "0";
  2708. var coinnum = this.goldnum.text;
  2709. var args = [{ "t": AccountManager.Instance.ServerTime.toString() }, { "play_id": MainGameView.Instance.play_id }, { "win": iswin }, { "money": coinnum }];
  2710. ServerManager.Instance.SendHttp(ArcherWorrior.JieShu, args, Laya.Handler.create(this, this.Success), null);
  2711. }
  2712. Success() {
  2713. EventManager.StageTrigger(StageState.Restart);
  2714. ViewManager.Instance.OpenPopView(ViewType.ExportView);
  2715. }
  2716. DealData(_num) {
  2717. if (_num > StageControl.Instance.curstage.Goal) {
  2718. _num = StageControl.Instance.curstage.Goal;
  2719. }
  2720. var _reward = AccountManager.Instance.curplayerData.GlobalData("mission_reward");
  2721. var gold = _reward * StageControl.Instance.curstage.Modulus * (_num / StageControl.Instance.curstage.Goal);
  2722. return gold;
  2723. }
  2724. SetData() {
  2725. SDKZS.SetHuTuiList(this.PushList, 1, "");
  2726. this.GunGun();
  2727. }
  2728. GunGun() {
  2729. var maxBtm;
  2730. try {
  2731. this.PushList.scrollBar.value = 0;
  2732. maxBtm = this.PushList.scrollBar.max;
  2733. }
  2734. catch (error) {
  2735. console.error(error);
  2736. return;
  2737. }
  2738. let tempBtm = 1;
  2739. Laya.timer.frameLoop(1, this, () => {
  2740. this.PushList.scrollBar.value += tempBtm;
  2741. if (this.PushList.scrollBar.value >= maxBtm || this.PushList.scrollBar.value <= 0) {
  2742. tempBtm = -tempBtm;
  2743. }
  2744. });
  2745. }
  2746. }
  2747. class ExportView extends ui.ExportViewUI {
  2748. OnOpen(data) {
  2749. WXSDK.AldEvent("打开全屏幕导出界面");
  2750. this.CloseExportBtn.clickHandler = Laya.Handler.create(this, this.ClickClose, [data]);
  2751. this.SetData();
  2752. this.height = Laya.stage.height;
  2753. Laya.stage.on(Laya.Event.RESIZE, this, () => {
  2754. this.height = Laya.stage.height;
  2755. });
  2756. }
  2757. OnHide() {
  2758. Laya.timer.clearAll(this);
  2759. WXSDK.AldEvent("关闭全屏导出界面");
  2760. }
  2761. ClickClose(data) {
  2762. ViewManager.Instance.ClosePopView(ViewType.ExportView);
  2763. }
  2764. SetData() {
  2765. SDKZS.SetHuTuiList(this.HList, 2, "");
  2766. SDKZS.SetHuTuiList(this.VList, 1, "");
  2767. this.GunGun();
  2768. }
  2769. GunGun() {
  2770. var maxTop;
  2771. var maxBtm;
  2772. try {
  2773. this.VList.scrollBar.value = 0;
  2774. this.HList.scrollBar.value = 0;
  2775. maxTop = this.HList.scrollBar.max;
  2776. maxBtm = this.VList.scrollBar.max;
  2777. }
  2778. catch (error) {
  2779. console.error(error);
  2780. return;
  2781. }
  2782. var tempTop = 1;
  2783. var tempBtm = 1;
  2784. Laya.timer.frameLoop(1, this, () => {
  2785. this.HList.scrollBar.value += tempTop;
  2786. if (this.HList.scrollBar.value >= maxTop || this.HList.scrollBar.value <= 0) {
  2787. tempTop = -tempTop;
  2788. }
  2789. this.VList.scrollBar.value += tempBtm;
  2790. if (this.VList.scrollBar.value >= maxBtm || this.VList.scrollBar.value <= 0) {
  2791. tempBtm = -tempBtm;
  2792. }
  2793. });
  2794. }
  2795. }
  2796. var ViewType;
  2797. (function (ViewType) {
  2798. ViewType[ViewType["MainView"] = 0] = "MainView";
  2799. ViewType[ViewType["IngameView"] = 1] = "IngameView";
  2800. ViewType[ViewType["ShopView"] = 2] = "ShopView";
  2801. ViewType[ViewType["TrialView"] = 3] = "TrialView";
  2802. ViewType[ViewType["CompleteView"] = 4] = "CompleteView";
  2803. ViewType[ViewType["ExportView"] = 5] = "ExportView";
  2804. })(ViewType || (ViewType = {}));
  2805. class ViewManager {
  2806. constructor() {
  2807. this.showexportview = 0;
  2808. this.popViewDic = [];
  2809. this.ViewSprite = new Laya.Sprite();
  2810. this.OtherViewSprite = new Laya.Sprite();
  2811. ViewManager.ins = this;
  2812. Laya.stage.addChild(this.ViewSprite);
  2813. Laya.stage.addChild(this.OtherViewSprite);
  2814. }
  2815. static get Instance() {
  2816. if (ViewManager.ins) {
  2817. return ViewManager.ins;
  2818. }
  2819. else {
  2820. return new ViewManager();
  2821. }
  2822. }
  2823. ShowView(_viewtype, data = null) {
  2824. if (this.curView != null) {
  2825. this.curView.Close();
  2826. this.curView.destroy();
  2827. this.curView.removeSelf();
  2828. }
  2829. GuangGao.Clear();
  2830. this.curView = this.CreateView(_viewtype);
  2831. this.curView.name = ViewType[_viewtype];
  2832. this.ViewSprite.addChild(this.curView);
  2833. this.curView.Show(data);
  2834. }
  2835. CloseView() {
  2836. if (this.curView != null) {
  2837. this.curView.Close();
  2838. this.curView.destroy();
  2839. this.curView.removeSelf();
  2840. }
  2841. }
  2842. OpenPopView(viewType, data = null) {
  2843. GuangGao.Clear();
  2844. var popView;
  2845. if (this.popViewDic[viewType]) {
  2846. popView = this.popViewDic[viewType];
  2847. this.OtherViewSprite.setChildIndex(popView, this.OtherViewSprite.numChildren - 1);
  2848. popView.visible = true;
  2849. }
  2850. else {
  2851. popView = this.CreateView(viewType);
  2852. this.OtherViewSprite.addChild(popView);
  2853. this.popViewDic[viewType] = popView;
  2854. }
  2855. this.showexportview = 1;
  2856. popView.OnOpen(data);
  2857. }
  2858. ClosePopView(viewType) {
  2859. var popView = this.popViewDic[viewType];
  2860. if (popView == null) {
  2861. return;
  2862. }
  2863. GuangGao.Clear();
  2864. popView.OnHide();
  2865. popView.visible = false;
  2866. this.showexportview = 0;
  2867. }
  2868. ClearPopViews() {
  2869. GuangGao.Clear();
  2870. }
  2871. CreateView(_viewtype) {
  2872. switch (_viewtype) {
  2873. case ViewType.MainView:
  2874. return new MainGameView();
  2875. case ViewType.IngameView:
  2876. return new InGameView();
  2877. case ViewType.TrialView:
  2878. return new TrialView();
  2879. case ViewType.CompleteView:
  2880. return new CompleteView();
  2881. case ViewType.ExportView:
  2882. return new ExportView();
  2883. case ViewType.ShopView:
  2884. return new ShopView();
  2885. }
  2886. return null;
  2887. }
  2888. }
  2889. class SDKZS {
  2890. static SetHuTuiList(list, scrol = 1, type = "") {
  2891. console.log("互推数据--", SDKZS.data);
  2892. console.log("互推数据准备状态---", SDKZS.isReady);
  2893. let arr = SDKZS.data.promotion;
  2894. if (!arr || arr.length == 0)
  2895. return;
  2896. list.selectEnable = false;
  2897. scrol == 1 ? list.vScrollBarSkin = "" : list.hScrollBarSkin = "";
  2898. list.renderHandler = Laya.Handler.create(this, SDKZS.updateItem, [type], false);
  2899. list.array = arr;
  2900. list.refresh();
  2901. }
  2902. static updateItem(type, cell, index) {
  2903. var aditem = cell.getComponent(ListItem);
  2904. aditem.Refresh(type);
  2905. }
  2906. static loadData() {
  2907. zs.sdk.loadAd((res) => {
  2908. console.log("[LOG]互推数据");
  2909. console.log(res);
  2910. SDKZS.data = res;
  2911. console.log("拉取互推数据--", SDKZS.data);
  2912. SDKZS.isReady = true;
  2913. });
  2914. }
  2915. static navigate2Mini(data) {
  2916. zs.sdk.navigate2Mini(data, AccountManager.Instance.curplayerData.openid, () => {
  2917. WXSDK.AldEvent("成功跳转到" + data.app_title);
  2918. }, () => {
  2919. WXSDK.AldEvent("跳转" + data.app_title + "失败");
  2920. if (ViewManager.Instance.showexportview == 0) {
  2921. ViewManager.Instance.OpenPopView(ViewType.ExportView);
  2922. }
  2923. }, () => {
  2924. });
  2925. }
  2926. static get CanCheat() {
  2927. var checkscence = AccountManager.Instance.curplayerData.CheckScene;
  2928. if (checkscence == false) {
  2929. return true;
  2930. }
  2931. if (Main.SceneNum == "1037" || Main.SceneNum == "1058"
  2932. || Main.SceneNum == "1067" || Main.SceneNum == "1095") {
  2933. return true;
  2934. }
  2935. return false;
  2936. }
  2937. }
  2938. SDKZS.isReady = false;
  2939. class ListItem extends Laya.Script {
  2940. constructor() { super(); }
  2941. onAwake() {
  2942. this.self = this.owner;
  2943. this.icon = this.self.getChildByName("icon");
  2944. this.btn = this.self.getChildByName("btn");
  2945. this.name = this.self.getChildByName("name");
  2946. this._tip = this.self.getChildByName("tip");
  2947. this.bottom = this.self.getChildByName("bottom");
  2948. this.remen = this.self.getChildByName("remen");
  2949. this.diandian = this.icon.getChildAt(0);
  2950. this.btn.clickHandler = new Laya.Handler(this, this.clickAd);
  2951. }
  2952. Refresh(type) {
  2953. this.data = this.self.dataSource;
  2954. this.type = type;
  2955. if (this.name) {
  2956. this.name.text = this.data.app_title;
  2957. }
  2958. if (this._tip) {
  2959. this._tip.visible = true;
  2960. let rnd = GameTools.RandomANumber(1, 200000);
  2961. let text = rnd.toString() + "人玩过";
  2962. if (rnd > 9999) {
  2963. text = Math.floor(rnd / 10000) + "W人玩过";
  2964. }
  2965. this._tip.text = text;
  2966. }
  2967. if (this.diandian) {
  2968. this.diandian.visible = false;
  2969. }
  2970. if (this.bottom) {
  2971. let num = GameTools.RandomANumber(1, 10);
  2972. this.bottom.skin = "Game/res/bottom/" + num + ".png";
  2973. }
  2974. if (this.remen) {
  2975. this.remen.visible = Math.random() < 0.2 ? true : false;
  2976. }
  2977. this.icon.skin = this.data.app_icon;
  2978. }
  2979. clickAd() {
  2980. SDKZS.navigate2Mini(this.data);
  2981. }
  2982. onDestroy() {
  2983. this.btn.clickHandler = null;
  2984. }
  2985. }
  2986. class GameConfig {
  2987. constructor() { }
  2988. static init() {
  2989. var reg = Laya.ClassUtils.regClass;
  2990. reg("Tools/ListItem.ts", ListItem);
  2991. reg("Tools/ShopItem.ts", ShopItem);
  2992. }
  2993. }
  2994. GameConfig.width = 720;
  2995. GameConfig.height = 1280;
  2996. GameConfig.scaleMode = "fixedwidth";
  2997. GameConfig.screenMode = "none";
  2998. GameConfig.alignV = "top";
  2999. GameConfig.alignH = "left";
  3000. GameConfig.startScene = "LoadView.scene";
  3001. GameConfig.sceneRoot = "";
  3002. GameConfig.debug = false;
  3003. GameConfig.stat = false;
  3004. GameConfig.physicsDebug = false;
  3005. GameConfig.exportSceneToJson = true;
  3006. GameConfig.init();
  3007. class Main {
  3008. constructor() {
  3009. if (CheckMain.Creat)
  3010. return;
  3011. CheckMain.Creat = true;
  3012. if (window["Laya3D"])
  3013. Laya3D.init(GameConfig.width, GameConfig.height);
  3014. else
  3015. Laya.init(GameConfig.width, GameConfig.height, Laya["WebGL"]);
  3016. Laya["Physics"] && Laya["Physics"].enable();
  3017. Laya["DebugPanel"] && Laya["DebugPanel"].enable();
  3018. Laya.stage.scaleMode = GameConfig.scaleMode;
  3019. Laya.stage.screenMode = GameConfig.screenMode;
  3020. Laya.stage.alignV = GameConfig.alignV;
  3021. Laya.stage.alignH = GameConfig.alignH;
  3022. Laya.URL.exportSceneToJson = GameConfig.exportSceneToJson;
  3023. if (GameConfig.debug || Laya.Utils.getQueryString("debug") == "true")
  3024. Laya.enableDebugPanel();
  3025. if (GameConfig.physicsDebug && Laya["PhysicsDebugDraw"])
  3026. Laya["PhysicsDebugDraw"].enable();
  3027. if (GameConfig.stat)
  3028. Laya.Stat.show();
  3029. Laya.alertGlobalError = true;
  3030. if (Laya.Browser.onWeiXin) {
  3031. Laya.Browser.window.wx.showShareMenu({
  3032. withShareTicket: true
  3033. });
  3034. Laya.Browser.window.wx.onShareAppMessage(function () {
  3035. return {
  3036. title: "有人@你,一起骑马仗箭走天涯",
  3037. imageUrl: "Game/res/textrue/share.jpg",
  3038. };
  3039. });
  3040. Laya.Browser.window.wx.onShow((option) => {
  3041. var shareTicket = option.shareTicket;
  3042. var userId = option.query.userId;
  3043. var shareTitle = option.query.shareTitle;
  3044. var scenevalue = Laya.LocalStorage.getItem("SceneValue");
  3045. if (scenevalue) {
  3046. Main.SceneNum = scenevalue;
  3047. }
  3048. else {
  3049. Laya.LocalStorage.setItem("SceneValue", option.scene);
  3050. Main.SceneNum = option.scene;
  3051. }
  3052. WXSDK.querychannel = option.query.channel;
  3053. WXSDK.shareOpenId = option.query.userId;
  3054. console.log("scene:", option.scene);
  3055. if (WXSDK.querychannel != null) {
  3056. console.log("onShow channel is:", WXSDK.querychannel);
  3057. }
  3058. if (option.referrerInfo) {
  3059. WXSDK.referrerInfoappId = option.referrerInfo.appId;
  3060. console.log("onShow appId is:", option.referrerInfo.appId);
  3061. }
  3062. });
  3063. if (!Laya.Browser.onWeiXin)
  3064. return;
  3065. const updateManager = Laya.Browser.window.wx.getUpdateManager();
  3066. updateManager.onCheckForUpdate(function (res) {
  3067. console.log("最新版本:" + res.hasUpdate);
  3068. });
  3069. updateManager.onUpdateReady(function () {
  3070. Laya.Browser.window.wx.showModal({
  3071. showCancel: false,
  3072. title: '更新提示',
  3073. content: '新版本已经准备好,是否重启应用?',
  3074. success(res) {
  3075. updateManager.applyUpdate();
  3076. },
  3077. fail(res) {
  3078. updateManager.applyUpdate();
  3079. }
  3080. });
  3081. });
  3082. }
  3083. Laya.ResourceVersion.enable("version.json", Laya.Handler.create(this, this.onVersionLoaded), Laya.ResourceVersion.FILENAME_VERSION);
  3084. }
  3085. onVersionLoaded() {
  3086. Laya.AtlasInfoManager.enable("fileconfig.json", Laya.Handler.create(this, this.onConfigLoaded));
  3087. }
  3088. onConfigLoaded() {
  3089. new LoadView();
  3090. }
  3091. }
  3092. Main.Ver = "1.0.0";
  3093. Main.CFG = "123";
  3094. new Main();
  3095. var HttpRequest = Laya.HttpRequest;
  3096. var Event = Laya.Event;
  3097. const ArcherWorriorApiUrl = "https://archerworriorapi.xwxgame.com/";
  3098. class ArcherWorrior {
  3099. }
  3100. ArcherWorrior.DengLu = "user/login";
  3101. ArcherWorrior.KaiShi = "game/start";
  3102. ArcherWorrior.JieShu = "game/play";
  3103. ArcherWorrior.QianDao = "sign/sign";
  3104. ArcherWorrior.Chengjiu = "achievement/getRewards";
  3105. ArcherWorrior.Config = "config/table";
  3106. ArcherWorrior.FenXiang = "fission/share";
  3107. ArcherWorrior.LiXian = "fission/offline";
  3108. ArcherWorrior.vd = "fission/vd";
  3109. ArcherWorrior.FuHuo = "game/revival";
  3110. ArcherWorrior.gadagdag = "treasure/click";
  3111. ArcherWorrior.Invite = "invite/getRewards";
  3112. ArcherWorrior.Lottery = "lottery/lottery";
  3113. ArcherWorrior.ShareGetSkin = "theme/fission";
  3114. ArcherWorrior.WearEquip = "theme/equip";
  3115. ArcherWorrior.BuyEquip = "theme/buy";
  3116. ArcherWorrior.ShouQuan = "user/auth";
  3117. ArcherWorrior.JinBi = "user/sync";
  3118. class ServerManager {
  3119. constructor() { }
  3120. static get Instance() {
  3121. if (ServerManager.ins) {
  3122. return ServerManager.ins;
  3123. }
  3124. else {
  3125. return new ServerManager();
  3126. }
  3127. }
  3128. Login(progresscb, completecb, errorcb) {
  3129. var Account = AccountManager.Instance;
  3130. var ver = Main.Ver;
  3131. let Data = `code=${Account.code}&nickname=${Account.nickName}&avatar=${Account.avatarUrl}&gender=${Account.gender}&country=${Account.country}&province=${Account.province}&city=${Account.city}& device=${Account.device}$&share_id=${Account.share_id}&scene=${Account.scene}&v=${ver}`;
  3132. let httpRequest = new HttpRequest();
  3133. httpRequest.once(Event.PROGRESS, this, this.Progress, [progresscb, httpRequest]);
  3134. httpRequest.once(Event.COMPLETE, this, this.Complete, [completecb, httpRequest]);
  3135. httpRequest.once(Event.ERROR, this, this.Errorcb, [errorcb, httpRequest]);
  3136. httpRequest.send(ArcherWorriorApiUrl + ArcherWorrior.DengLu, Data, "post", "text");
  3137. }
  3138. Progress(_progresscb, _httpreq) {
  3139. if (_progresscb) {
  3140. _progresscb.run();
  3141. }
  3142. }
  3143. Complete(_completecb, _httpreq) {
  3144. let data = JSON.parse(_httpreq.data);
  3145. console.log(data);
  3146. if (data["code"] != "0") {
  3147. console.log("登录异常错误!错误信息sssssssss:", _httpreq.data["code"]);
  3148. return;
  3149. }
  3150. console.log("-----------sss", data["t"]);
  3151. AccountManager.Instance.SFSFSF = data["t"];
  3152. this.RessetConfig(data, _completecb);
  3153. }
  3154. RessetConfig(data, completecb) {
  3155. AccountManager.Instance.ReSetting(data, (flag) => {
  3156. if (flag) {
  3157. completecb.runWith(data);
  3158. }
  3159. else {
  3160. this.RessetConfig(data, completecb);
  3161. }
  3162. });
  3163. }
  3164. Errorcb(_errorcb, _httpreq) {
  3165. if (_errorcb != null) {
  3166. _errorcb.runWith(_httpreq);
  3167. }
  3168. }
  3169. SendHttp(protocol, param, completecb, errorcb, hasToken = true) {
  3170. let sfaasfsfa = "";
  3171. let daadsads = ArcherWorriorApiUrl + protocol;
  3172. if (hasToken == true) {
  3173. sfaasfsfa = `token=${AccountManager.Instance.curplayerData.zhengshu}&`;
  3174. }
  3175. if (protocol == ArcherWorrior.KaiShi || protocol == ArcherWorrior.JieShu || protocol == ArcherWorrior.vd || protocol == ArcherWorrior.Lottery) {
  3176. let asddsa = "abcdefghijkimnopqrstuvwxyz0123456789";
  3177. let adsassda = "{";
  3178. let saafsafs = "";
  3179. for (let i = 0; i < 4; i++) {
  3180. saafsafs += asddsa[Math.floor(Math.random() * 100) % asddsa.length];
  3181. }
  3182. for (let i = 0; i < param.length; i++) {
  3183. for (let key in param[i]) {
  3184. adsassda += `\"${key}\":\"${param[i][key]}\"`;
  3185. }
  3186. if (i < param.length - 1) {
  3187. adsassda += ",";
  3188. }
  3189. else {
  3190. adsassda += "}";
  3191. }
  3192. }
  3193. sfaasfsfa += "_r=" + saafsafs + this.SFGSGSG(adsassda);
  3194. }
  3195. else {
  3196. if (param != null) {
  3197. for (let i = 0; i < param.length; i++) {
  3198. for (let key in param[i]) {
  3199. let val = param[i][key];
  3200. sfaasfsfa += `${key}=${val}`;
  3201. if (i < param.length - 1) {
  3202. sfaasfsfa += "&";
  3203. }
  3204. }
  3205. }
  3206. }
  3207. }
  3208. let httpRequest = new HttpRequest();
  3209. httpRequest.once(Event.COMPLETE, this, this.onHttpRequestComplete, [completecb, errorcb, httpRequest]);
  3210. httpRequest.once(Event.ERROR, this, this.Errorcb, [errorcb, httpRequest]);
  3211. httpRequest.send(daadsads, sfaasfsfa, "post", "text");
  3212. }
  3213. onHttpRequestComplete(succeedcb, failurecb, httpRequest) {
  3214. let data = JSON.parse(httpRequest.data);
  3215. if (data["code"] == 0) {
  3216. AccountManager.Instance.ReSetting(data);
  3217. if (succeedcb != null) {
  3218. succeedcb.runWith(data);
  3219. }
  3220. }
  3221. else {
  3222. if (failurecb != null) {
  3223. failurecb.runWith(data);
  3224. }
  3225. console.log("Error! Http request complete error, code: " + data["code"] + " message: " + data["message"]);
  3226. }
  3227. }
  3228. SFGSGSG(str) {
  3229. var c1, c2, c3;
  3230. var SFSFFSFSFSFS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  3231. var i = 0, len = str.length, SFFSSFFS = '';
  3232. while (i < len) {
  3233. c1 = str.charCodeAt(i++) & 0xff;
  3234. if (i == len) {
  3235. SFFSSFFS += SFSFFSFSFSFS.charAt(c1 >> 2);
  3236. SFFSSFFS += SFSFFSFSFSFS.charAt((c1 & 0x3) << 4);
  3237. SFFSSFFS += "==";
  3238. break;
  3239. }
  3240. c2 = str.charCodeAt(i++);
  3241. if (i == len) {
  3242. SFFSSFFS += SFSFFSFSFSFS.charAt(c1 >> 2);
  3243. SFFSSFFS += SFSFFSFSFSFS.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
  3244. SFFSSFFS += SFSFFSFSFSFS.charAt((c2 & 0xF) << 2);
  3245. SFFSSFFS += "=";
  3246. break;
  3247. }
  3248. c3 = str.charCodeAt(i++);
  3249. SFFSSFFS += SFSFFSFSFSFS.charAt(c1 >> 2);
  3250. SFFSSFFS += SFSFFSFSFSFS.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
  3251. SFFSSFFS += SFSFFSFSFSFS.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6));
  3252. SFFSSFFS += SFSFFSFSFSFS.charAt(c3 & 0x3F);
  3253. }
  3254. return SFFSSFFS;
  3255. }
  3256. }
  3257. class AccountManager {
  3258. constructor(_code, _userinfo, _nickname, _avatarurl, _gender, _province, _city, _country, _device, _shareid, _scene, _v) {
  3259. this.createTime = Laya.timer.currTimer;
  3260. AccountManager.ins = this;
  3261. this.code = _code;
  3262. this.userInfo = _userinfo;
  3263. this.nickName = _nickname;
  3264. this.avatarUrl = _avatarurl;
  3265. this.gender = _gender;
  3266. this.province = _province;
  3267. this.city = _city;
  3268. this.country = _country;
  3269. this.device = _device;
  3270. this.share_id = _shareid;
  3271. this.scene = _scene;
  3272. this.v = _v;
  3273. }
  3274. static get Instance() {
  3275. if (AccountManager.ins == null) {
  3276. new AccountManager("222222", "你找谁?", "1233", "123", 1, "中国", "上海", "上海", "iphone6s", "123", "123", "123");
  3277. }
  3278. return AccountManager.ins;
  3279. }
  3280. ReSetting(data, cb = null) {
  3281. var zhengshu = data["token"];
  3282. var netset = data["app_setting"];
  3283. var user = data["user"];
  3284. var jichu = data["user_base"];
  3285. var qiandao = data["user_sign"];
  3286. var chengjiu = data["user_achievement"];
  3287. var invite = data["user_invite"];
  3288. var lottery = data["user_lottery"];
  3289. if (this.curplayerData == null) {
  3290. this.curplayerData = new PlayerData(zhengshu, null, netset, user, jichu, invite, null, qiandao, chengjiu, lottery);
  3291. this.JundgCfg(data.table_version, cb);
  3292. }
  3293. else {
  3294. if (netset) {
  3295. this.curplayerData.netzheshe = netset;
  3296. }
  3297. if (user) {
  3298. this.curplayerData.account = user;
  3299. }
  3300. if (jichu) {
  3301. this.curplayerData.accountssss = jichu;
  3302. }
  3303. if (qiandao) {
  3304. this.curplayerData.qiandao = qiandao;
  3305. }
  3306. if (chengjiu) {
  3307. this.curplayerData.renwu = chengjiu;
  3308. }
  3309. }
  3310. }
  3311. JundgCfg(ver, callball) {
  3312. var cfg = Laya.LocalStorage.getJSON(Main.CFG);
  3313. if (cfg) {
  3314. if (cfg.VER == ver) {
  3315. console.log("已经拥有,不用更新");
  3316. this.SetCfg(cfg);
  3317. if (callball)
  3318. callball(true);
  3319. }
  3320. else {
  3321. console.log("cfg存在但是过期了");
  3322. Laya.LocalStorage.removeItem(Main.CFG);
  3323. ServerManager.Instance.SendHttp(ArcherWorrior.Config, null, Laya.Handler.create(this, (data) => {
  3324. data.configs.VER = ver;
  3325. Laya.LocalStorage.setJSON(Main.CFG, data.configs);
  3326. this.SetCfg(data.configs);
  3327. if (callball)
  3328. callball(true);
  3329. }), Laya.Handler.create(this, (data) => {
  3330. console.log("配置获取失败" + data);
  3331. if (callball)
  3332. callball(false);
  3333. return;
  3334. }));
  3335. }
  3336. }
  3337. else {
  3338. console.log("本地没有cfg");
  3339. ServerManager.Instance.SendHttp(ArcherWorrior.Config, null, Laya.Handler.create(this, (data) => {
  3340. data.configs.VER = ver;
  3341. Laya.LocalStorage.setJSON(Main.CFG, data.configs);
  3342. this.SetCfg(data.configs);
  3343. if (callball)
  3344. callball(true);
  3345. }), Laya.Handler.create(this, (data) => {
  3346. console.log("配置获取失败" + data);
  3347. }));
  3348. }
  3349. }
  3350. SetCfg(data) {
  3351. this.curplayerData.peizhis = data;
  3352. }
  3353. RessetConfig() {
  3354. ServerManager.Instance.SendHttp(ArcherWorrior.Config, null, Laya.Handler.create(this, (data) => {
  3355. this.curplayerData.peizhis = data["configs"];
  3356. }), null);
  3357. }
  3358. get ServerTime() {
  3359. let time = Laya.timer.currTimer;
  3360. let stime = this.SFSFSF + Math.ceil((time - this.createTime) / 1000);
  3361. return stime;
  3362. }
  3363. }
  3364. var Vector3$4 = Laya.Vector3;
  3365. var NpcState;
  3366. (function (NpcState) {
  3367. NpcState[NpcState["Attack"] = 0] = "Attack";
  3368. NpcState[NpcState["Idle"] = 1] = "Idle";
  3369. NpcState[NpcState["Win"] = 2] = "Win";
  3370. NpcState[NpcState["Pursue"] = 3] = "Pursue";
  3371. NpcState[NpcState["Run"] = 4] = "Run";
  3372. NpcState[NpcState["Die"] = 5] = "Die";
  3373. })(NpcState || (NpcState = {}));
  3374. class NpcRunner extends Laya.Script {
  3375. constructor() {
  3376. super();
  3377. this.m_distance = 20;
  3378. this.m_distanceatk = 5;
  3379. this.DIE = false;
  3380. this.m_npcspeed = 0;
  3381. this.atked = false;
  3382. this.wined = false;
  3383. this.begin = false;
  3384. this.frontdie = false;
  3385. this.reardie = false;
  3386. this.canmove = false;
  3387. this.dir = new Vector3$4();
  3388. this.currotV = new Vector3$4();
  3389. this.currot = new Laya.Quaternion;
  3390. this.CurrectRotate = new Laya.Quaternion();
  3391. this.curspeed = 0;
  3392. this.offest = new Vector3$4();
  3393. this.curpos = new Vector3$4();
  3394. this.die = false;
  3395. NpcRunner.ins = this;
  3396. EventManager.StageOn(StageState.Start, this, this.Begin);
  3397. EventManager.StageOn(StageState.Lose, this, this.GameOver);
  3398. EventManager.StageOn(StageState.Win, this, this.GameOver);
  3399. EventManager.StageOn(StageState.Press, this, this.AddSpeed);
  3400. EventManager.StageOn(StageState.UnPress, this, this.SlowSpeed);
  3401. }
  3402. static get Instance() {
  3403. if (NpcRunner.ins) {
  3404. return NpcRunner.ins;
  3405. }
  3406. else {
  3407. return new NpcRunner();
  3408. }
  3409. }
  3410. onAwake() {
  3411. this.m_npcmodel = this.owner;
  3412. this.m_npcanimator = this.owner.getComponent(Laya.Animator);
  3413. this.player = PlayerControl.Instance.Player;
  3414. this.m_distance = AccountManager.Instance.curplayerData.NpcRunDistance * 1.65;
  3415. this.m_distanceatk = AccountManager.Instance.curplayerData.NpcAtkDistance * 1.65;
  3416. let stage = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
  3417. if (stage == 1) {
  3418. this.m_npcspeed = 0.1;
  3419. }
  3420. else {
  3421. this.m_npcspeed = StageControl.Instance.curstage.npcspeed;
  3422. }
  3423. }
  3424. Begin() {
  3425. this.ChangeState(NpcState.Idle);
  3426. this.begin = true;
  3427. }
  3428. onUpdate() {
  3429. if (!this.begin)
  3430. return;
  3431. if (this.npc_state == NpcState.Die)
  3432. return;
  3433. if (this.frontdie || this.reardie) {
  3434. this.ChangeState(NpcState.Die);
  3435. return;
  3436. }
  3437. let stage = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
  3438. var distance = Vector3$4.distance(this.player.transform.position, this.m_npcmodel.transform.position);
  3439. if (distance < this.m_distance && distance > this.m_distanceatk && !this.atked && stage > 2) {
  3440. Vector3$4.subtract(this.player.transform.position, this.m_npcmodel.transform.position, this.currotV);
  3441. Vector3$4.normalize(this.currotV, this.currotV);
  3442. this.m_npcmodel.transform.lookAt(new Vector3$4(this.m_npcmodel.transform.position.x - this.currotV.x, this.m_npcmodel.transform.position.y, this.m_npcmodel.transform.position.z - this.currotV.z), new Vector3$4(0, 1, 0));
  3443. this.NPCMoveDir = this.currotV;
  3444. this.canmove = true;
  3445. this.ChangeState(NpcState.Run);
  3446. }
  3447. else if (distance <= this.m_distanceatk && !this.atked && stage > 2) {
  3448. Vector3$4.subtract(this.player.transform.position, this.m_npcmodel.transform.position, this.currotV);
  3449. Vector3$4.normalize(this.currotV, this.currotV);
  3450. this.m_npcmodel.transform.lookAt(new Vector3$4(this.m_npcmodel.transform.position.x - this.currotV.x, this.m_npcmodel.transform.position.y, this.m_npcmodel.transform.position.z - this.currotV.z), new Vector3$4(0, 1, 0));
  3451. this.NPCMoveDir = this.currotV;
  3452. this.atked = true;
  3453. this.ChangeState(NpcState.Attack);
  3454. }
  3455. this.Move(this.NPCMoveDir, this.m_npcspeed);
  3456. this.RayCheck();
  3457. }
  3458. Move(_dir, _speed) {
  3459. if (this.canmove) {
  3460. var sp = GameTools.Instance.lerp(this.curspeed, _speed, 0.1);
  3461. this.curspeed = sp;
  3462. Vector3$4.scale(_dir, this.curspeed, this.offest);
  3463. Vector3$4.add(this.m_npcmodel.transform.position, this.offest, this.curpos);
  3464. Vector3$4.lerp(this.m_npcmodel.transform.position, this.curpos, 0.15, this.curpos);
  3465. this.curpos = new Vector3$4(this.curpos.x, this.curpos.y, this.curpos.z);
  3466. this.m_npcmodel.transform.position = this.curpos;
  3467. }
  3468. }
  3469. AddSpeed() {
  3470. this.m_npcspeed = StageControl.Instance.curstage.npcspeed;
  3471. }
  3472. SlowSpeed() {
  3473. this.m_npcspeed = StageControl.Instance.curstage.npcspeed / 2;
  3474. }
  3475. GameOver() {
  3476. EventManager.StageOff(StageState.Press, this, this.AddSpeed);
  3477. EventManager.StageOff(StageState.UnPress, this, this.SlowSpeed);
  3478. EventManager.StageOff(StageState.Start, this, this.Begin);
  3479. }
  3480. ChangeState(_state) {
  3481. if (this.npc_state == _state)
  3482. return;
  3483. this.npc_state = _state;
  3484. switch (this.npc_state) {
  3485. case NpcState.Attack:
  3486. this.Attack();
  3487. break;
  3488. case NpcState.Pursue:
  3489. this.Pursue();
  3490. break;
  3491. case NpcState.Win:
  3492. this.Win();
  3493. break;
  3494. case NpcState.Idle:
  3495. this.Idle();
  3496. break;
  3497. case NpcState.Run:
  3498. this.Run();
  3499. break;
  3500. case NpcState.Die:
  3501. this.Die();
  3502. break;
  3503. }
  3504. }
  3505. Idle() {
  3506. this.m_npcanimator.play("idle");
  3507. }
  3508. Attack() {
  3509. this.m_npcanimator.play("atk");
  3510. Laya.timer.once(500, this, () => {
  3511. this.canmove = false;
  3512. });
  3513. }
  3514. Win() {
  3515. this.m_npcanimator.play("win");
  3516. }
  3517. Pursue() {
  3518. }
  3519. Run() {
  3520. this.m_npcanimator.play("run");
  3521. }
  3522. Die() {
  3523. if (this.die)
  3524. return;
  3525. this.die = true;
  3526. AudioManager.playMusic(MusicType.die);
  3527. this.PiaoZi();
  3528. EventManager.StageOff(StageState.Start, this, this.Begin);
  3529. Laya.timer.once(500, this, () => {
  3530. GamePool.Instance.RecoveryModel(this.m_npcmodel);
  3531. });
  3532. if (this.frontdie) {
  3533. this.m_npcanimator.play("diefront");
  3534. }
  3535. else if (this.reardie) {
  3536. this.m_npcanimator.play("dierear");
  3537. }
  3538. this.canmove = false;
  3539. }
  3540. PiaoZi() {
  3541. let headshoot = new Laya.Image();
  3542. headshoot.skin = "Game/res/textrue/headshoot.png";
  3543. headshoot.scaleX = 0.5;
  3544. headshoot.scaleY = 0.5;
  3545. headshoot.anchorX = 0.5;
  3546. headshoot.anchorY = 0.5;
  3547. Laya.stage.addChild(headshoot);
  3548. Laya.timer.once(1000, this, () => {
  3549. headshoot.visible = false;
  3550. });
  3551. GameManager.Instance.UIArray.push(headshoot);
  3552. let UIPos = this.m_npcmodel.getChildByName("UIPos");
  3553. let screenpos1 = new Vector3$4();
  3554. Laya.timer.frameLoop(1, this, this.UIFollow, [UIPos, headshoot, screenpos1]);
  3555. }
  3556. UIFollow(UIPos, UI, POS) {
  3557. AssetManager.Instance.maincamera.worldToViewportPoint(UIPos.transform.position, POS);
  3558. UI.pos(POS.x, POS.y);
  3559. }
  3560. RayCheck() {
  3561. if (this.wined)
  3562. return;
  3563. let startpos = new Vector3$4(this.m_npcmodel.transform.position.x, this.m_npcmodel.transform.position.y + 1.5, this.m_npcmodel.transform.position.z);
  3564. let dir = Transform3DHelper.getForward(this.m_npcmodel.transform);
  3565. let ray = new Laya.Ray(startpos, dir);
  3566. let hitres = new Laya.HitResult();
  3567. let isHit = AssetManager.Instance.mainscene.physicsSimulation.rayCast(ray, hitres, 1, 200);
  3568. if (isHit) {
  3569. let target = hitres.collider.owner.parent;
  3570. if (target.name == "player") {
  3571. let runner = target.getComponent(Runner);
  3572. let ani = target.getComponent(Laya.Animator);
  3573. if (!runner.Invincible) {
  3574. Laya.timer.once(150, this, () => {
  3575. runner.isdead = true;
  3576. this.wined = true;
  3577. });
  3578. }
  3579. }
  3580. else if (target.name == "bonfire") {
  3581. this.ChangeState(NpcState.Die);
  3582. this.wined = true;
  3583. }
  3584. else if (target.name == "stone") ;
  3585. else if (target.name == "") ;
  3586. }
  3587. }
  3588. }
  3589. var Vector3$5 = Laya.Vector3;
  3590. var HostageState;
  3591. (function (HostageState) {
  3592. HostageState[HostageState["Run"] = 0] = "Run";
  3593. HostageState[HostageState["Rescue"] = 1] = "Rescue";
  3594. HostageState[HostageState["Arrest"] = 2] = "Arrest";
  3595. HostageState[HostageState["Die"] = 3] = "Die";
  3596. })(HostageState || (HostageState = {}));
  3597. class Hostage extends Laya.Script {
  3598. constructor() {
  3599. super();
  3600. this._hostagespeed = 0;
  3601. this.begin = false;
  3602. this.isbarrier = false;
  3603. this.canmove = false;
  3604. this.isdead = false;
  3605. this.DownHit = new Laya.HitResult();
  3606. this.FowardHit = new Laya.HitResult();
  3607. this.currotV = new Vector3$5();
  3608. this.hostagedir = new Vector3$5();
  3609. this.offest = new Vector3$5();
  3610. this.curpos = new Vector3$5();
  3611. this.curspeed = 0;
  3612. Hostage.ins = this;
  3613. EventManager.StageOn(StageState.Start, this, this.Begin);
  3614. EventManager.StageOn(StageState.Lose, this, this.GameOver);
  3615. EventManager.StageOn(StageState.Win, this, this.GameOver);
  3616. EventManager.StageOn(StageState.Press, this, this.AddSpeed);
  3617. EventManager.StageOn(StageState.UnPress, this, this.SlowSpeed);
  3618. }
  3619. static get Instance() {
  3620. if (Hostage.ins) {
  3621. return Hostage.ins;
  3622. }
  3623. else {
  3624. return new Hostage();
  3625. }
  3626. }
  3627. onAwake() {
  3628. this.m_hostagemodel = this.owner;
  3629. this.m_hostageanimator = this.m_hostagemodel.getComponent(Laya.Animator);
  3630. this.enemy = this.owner.parent.parent.getChildByName("enemy").getChildAt(0);
  3631. this._hostagespeed = StageControl.Instance.curstage.hostspeed;
  3632. }
  3633. Begin() {
  3634. this.ChangeState(HostageState.Run);
  3635. this.begin = true;
  3636. }
  3637. onUpdate() {
  3638. if (!this.begin)
  3639. return;
  3640. if (this.isdead) {
  3641. this.ChangeState(HostageState.Die);
  3642. return;
  3643. }
  3644. let npc = this.enemy.getComponent(ChaseNpc);
  3645. if (npc.isdead || this.enemy == null || this.enemy.destroyed) {
  3646. this.canmove = false;
  3647. this.ChangeState(HostageState.Rescue);
  3648. return;
  3649. }
  3650. this.RayCheck();
  3651. let target = this.LookforRoad();
  3652. if (this.canmove) {
  3653. if (target) {
  3654. Vector3$5.subtract(target.transform.position, this.m_hostagemodel.transform.position, this.currotV);
  3655. Vector3$5.normalize(this.currotV, this.currotV);
  3656. this.m_hostagemodel.transform.lookAt(new Vector3$5(this.m_hostagemodel.transform.position.x - this.currotV.x, this.m_hostagemodel.transform.position.y, this.m_hostagemodel.transform.position.z - this.currotV.z), new Vector3$5(0, 1, 0));
  3657. this.hostagedir = this.currotV;
  3658. if (!this.isbarrier) {
  3659. this.Move(this.currotV, this._hostagespeed);
  3660. }
  3661. }
  3662. else {
  3663. if (!this.isbarrier) {
  3664. this.Move(new Vector3$5(0, 0, 1), this._hostagespeed);
  3665. }
  3666. }
  3667. }
  3668. }
  3669. LookforRoad() {
  3670. var doorarr = [];
  3671. for (let i = 0; i < DataManager.DoorArray.length; i++) {
  3672. let _door = DataManager.DoorArray[i];
  3673. if (this.m_hostagemodel.transform.position.z < _door.transform.position.z) {
  3674. doorarr.push(_door);
  3675. }
  3676. }
  3677. for (let i = 0; i < doorarr.length; i++) {
  3678. for (let j = 0; j < doorarr.length - i - 1; j++) {
  3679. var _dis = Vector3$5.distance(doorarr[i].transform.position, this.m_hostagemodel.transform.position);
  3680. var _dis2 = Vector3$5.distance(doorarr[i + 1].transform.position, this.m_hostagemodel.transform.position);
  3681. if (_dis > _dis2) {
  3682. let door1 = doorarr[i];
  3683. doorarr[i] = doorarr[i + 1];
  3684. doorarr[i + 1] = door1;
  3685. }
  3686. }
  3687. }
  3688. return doorarr[0];
  3689. }
  3690. Move(_dir, _speed) {
  3691. let stage = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
  3692. if (stage == 1)
  3693. return;
  3694. if (this.canmove) {
  3695. var sp = GameTools.Instance.lerp(this.curspeed, _speed, 0.1);
  3696. this.curspeed = sp;
  3697. Vector3$5.scale(_dir, this.curspeed, this.offest);
  3698. Vector3$5.add(this.m_hostagemodel.transform.position, this.offest, this.curpos);
  3699. Vector3$5.lerp(this.m_hostagemodel.transform.position, this.curpos, 0.15, this.curpos);
  3700. this.curpos = new Vector3$5(this.curpos.x, this.curpos.y, this.curpos.z);
  3701. this.m_hostagemodel.transform.position = this.curpos;
  3702. }
  3703. }
  3704. AddSpeed() {
  3705. this._hostagespeed = StageControl.Instance.curstage.hostspeed;
  3706. }
  3707. SlowSpeed() {
  3708. this._hostagespeed = StageControl.Instance.curstage.hostspeed / 2;
  3709. }
  3710. GameOver() {
  3711. EventManager.StageOff(StageState.Press, this, this.AddSpeed);
  3712. EventManager.StageOff(StageState.UnPress, this, this.SlowSpeed);
  3713. EventManager.StageOff(StageState.Start, this, this.Begin);
  3714. Laya.timer.clearAll(this);
  3715. this.canmove = false;
  3716. }
  3717. ChangeState(_state) {
  3718. if (this.m_hostagestate == _state)
  3719. return;
  3720. this.m_hostagestate = _state;
  3721. switch (this.m_hostagestate) {
  3722. case HostageState.Run:
  3723. this.Run();
  3724. break;
  3725. case HostageState.Arrest:
  3726. this.Arrest();
  3727. break;
  3728. case HostageState.Rescue:
  3729. this.Rescue();
  3730. break;
  3731. case HostageState.Die:
  3732. this.Die();
  3733. break;
  3734. }
  3735. }
  3736. Run() {
  3737. this.m_hostageanimator.play("run");
  3738. }
  3739. Rescue() {
  3740. this.m_hostageanimator.play("thank");
  3741. this.PiaoZi();
  3742. }
  3743. Arrest() {
  3744. this.m_hostageanimator.play("dierear");
  3745. this.canmove = false;
  3746. }
  3747. Die() {
  3748. WXSDK.Shake(true);
  3749. this.m_hostageanimator.play("dierear");
  3750. this.canmove = false;
  3751. EventManager.StageOff(StageState.Start, this, this.Begin);
  3752. Laya.timer.clearAll(this);
  3753. EventManager.StageTrigger(StageState.Lose);
  3754. }
  3755. RayCheck() {
  3756. if (this.FowardRayCheck) {
  3757. this.CrashBarrier();
  3758. this.isbarrier = true;
  3759. }
  3760. else {
  3761. this.isbarrier = false;
  3762. }
  3763. }
  3764. PiaoZi() {
  3765. let smile = new Laya.Image();
  3766. smile.skin = "Game/res/textrue/happy.png";
  3767. smile.scaleX = 0.05;
  3768. smile.scaleY = 0.05;
  3769. smile.anchorX = 0.5;
  3770. smile.anchorY = 0.5;
  3771. Laya.stage.addChild(smile);
  3772. Laya.timer.once(1000, this, () => {
  3773. smile.visible = false;
  3774. Laya.timer.clear(this, this.UIFollow);
  3775. });
  3776. GameManager.Instance.UIArray.push(smile);
  3777. let UIPos = this.m_hostagemodel.getChildByName("UIPos");
  3778. let screenpos = new Vector3$5();
  3779. Laya.timer.frameLoop(1, this, this.UIFollow, [UIPos, smile, screenpos]);
  3780. }
  3781. UIFollow(UIPos, UI, POS) {
  3782. AssetManager.Instance.maincamera.worldToViewportPoint(UIPos.transform.position, POS);
  3783. UI.pos(POS.x, POS.y);
  3784. }
  3785. CrashBarrier() {
  3786. var target = this.FowardHit.collider.owner.parent;
  3787. if (target.name == "stone") {
  3788. this._hostagespeed = 0;
  3789. }
  3790. else if (target.name == "bonfire") ;
  3791. else if (target.name == "big_fence") {
  3792. this._hostagespeed = 0;
  3793. }
  3794. else if (target.name == "wood_Cylinder") {
  3795. this._hostagespeed = 0;
  3796. }
  3797. }
  3798. get FowardRayCheck() {
  3799. var isFowardHit = false;
  3800. var startPos = new Vector3$5(this.m_hostagemodel.transform.position.x, this.m_hostagemodel.transform.position.y + 1, this.m_hostagemodel.transform.position.z + 0.5);
  3801. var direction = new Vector3$5(0, 0, 1);
  3802. var DownRay = new Laya.Ray(startPos, direction);
  3803. if (AssetManager.Instance.mainscene.physicsSimulation.rayCast(DownRay, this.FowardHit, 1)) {
  3804. if (this.FowardHit.collider.collisionGroup == 100) {
  3805. isFowardHit = true;
  3806. }
  3807. }
  3808. return isFowardHit;
  3809. }
  3810. }
  3811. var Vector3$6 = Laya.Vector3;
  3812. var ChaseNpcState;
  3813. (function (ChaseNpcState) {
  3814. ChaseNpcState[ChaseNpcState["Idle"] = 0] = "Idle";
  3815. ChaseNpcState[ChaseNpcState["Run"] = 1] = "Run";
  3816. ChaseNpcState[ChaseNpcState["Die"] = 2] = "Die";
  3817. ChaseNpcState[ChaseNpcState["Atk"] = 3] = "Atk";
  3818. })(ChaseNpcState || (ChaseNpcState = {}));
  3819. class ChaseNpc extends Laya.Script {
  3820. constructor() {
  3821. super();
  3822. this.frontdie = false;
  3823. this.reardie = false;
  3824. this.canmove = false;
  3825. this.isdead = false;
  3826. this.atked = false;
  3827. this.begin = false;
  3828. this.m_chasenpcspeed = 0;
  3829. this.pursuediatance = 0;
  3830. this.atkdistance = 10;
  3831. this.NPCRushSpeed = 0;
  3832. this.Distance = 0;
  3833. this.ChaseDistance = 0;
  3834. this.NpcStartPos = new Vector3$6();
  3835. this.dir = new Vector3$6();
  3836. this.currotV = new Vector3$6();
  3837. this.currot = new Laya.Quaternion;
  3838. this.CurrectRotate = new Laya.Quaternion();
  3839. this.curspeed = 0;
  3840. this.offest = new Vector3$6();
  3841. this.curpos = new Vector3$6();
  3842. this.die = false;
  3843. ChaseNpc.ins = this;
  3844. EventManager.StageOn(StageState.Start, this, this.Begin);
  3845. EventManager.StageOn(StageState.Lose, this, this.GameOver);
  3846. EventManager.StageOn(StageState.Win, this, this.GameOver);
  3847. EventManager.StageOn(StageState.Press, this, this.AddSpeed);
  3848. EventManager.StageOn(StageState.UnPress, this, this.SlowSpeed);
  3849. }
  3850. static get Instance() {
  3851. if (ChaseNpc.ins) {
  3852. return ChaseNpc.ins;
  3853. }
  3854. else {
  3855. return new ChaseNpc();
  3856. }
  3857. }
  3858. onAwake() {
  3859. this.m_chasenpcmodel = this.owner;
  3860. }
  3861. onStart() {
  3862. this.m_chasenpcanimator = this.m_chasenpcmodel.getComponent(Laya.Animator);
  3863. this.m_hostage = this.owner.parent.parent.getChildByName("player").getChildAt(0);
  3864. this.NpcStartPos = this.m_chasenpcmodel.transform.position.clone();
  3865. this.m_chasenpcspeed = StageControl.Instance.curstage.npcspeed;
  3866. this.Distance = AccountManager.Instance.curplayerData.NpcChaseDistance * 1.65;
  3867. this.ChaseDistance = AccountManager.Instance.curplayerData.NpcRushDistance * 1.65;
  3868. this.NPCRushSpeed = AccountManager.Instance.curplayerData.NPCRushSpeed;
  3869. }
  3870. Begin() {
  3871. this.ChangeState(ChaseNpcState.Run);
  3872. this.begin = true;
  3873. }
  3874. onUpdate() {
  3875. if (!this.begin)
  3876. return;
  3877. if (this.isdead)
  3878. return;
  3879. let _host = this.m_hostage.getComponent(Hostage);
  3880. if (_host.isdead) {
  3881. this.ChangeState(ChaseNpcState.Idle);
  3882. return;
  3883. }
  3884. if (this.frontdie || this.reardie) {
  3885. this.ChangeState(ChaseNpcState.Die);
  3886. return;
  3887. }
  3888. var distance = Vector3$6.distance(PlayerControl.Instance.Player.transform.position, this.m_chasenpcmodel.transform.position);
  3889. if (distance < this.Distance && !this.atked) {
  3890. Vector3$6.subtract(this.m_hostage.transform.position, this.m_chasenpcmodel.transform.position, this.currotV);
  3891. Vector3$6.normalize(this.currotV, this.currotV);
  3892. this.m_chasenpcmodel.transform.lookAt(new Vector3$6(this.m_chasenpcmodel.transform.position.x - this.currotV.x, this.m_chasenpcmodel.transform.position.y, this.m_chasenpcmodel.transform.position.z - this.currotV.z), new Vector3$6(0, 1, 0));
  3893. this.NPCMoveDir = this.currotV;
  3894. this.canmove = true;
  3895. _host.canmove = true;
  3896. let _dis = this.m_chasenpcmodel.transform.position.z - this.NpcStartPos.z;
  3897. if (_dis >= this.ChaseDistance) {
  3898. this.atked = true;
  3899. this.m_chasenpcspeed = this.NPCRushSpeed;
  3900. this.ChangeState(ChaseNpcState.Atk);
  3901. }
  3902. }
  3903. this.Move(this.NPCMoveDir, this.m_chasenpcspeed);
  3904. this.RayCheck();
  3905. }
  3906. Move(_dir, _speed) {
  3907. let stage = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
  3908. if (stage <= 2)
  3909. return;
  3910. if (this.canmove) {
  3911. var sp = GameTools.Instance.lerp(this.curspeed, _speed, 0.1);
  3912. this.curspeed = sp;
  3913. Vector3$6.scale(_dir, this.curspeed, this.offest);
  3914. Vector3$6.add(this.m_chasenpcmodel.transform.position, this.offest, this.curpos);
  3915. Vector3$6.lerp(this.m_chasenpcmodel.transform.position, this.curpos, 0.15, this.curpos);
  3916. this.curpos = new Vector3$6(this.curpos.x, this.curpos.y, this.curpos.z);
  3917. this.m_chasenpcmodel.transform.position = this.curpos;
  3918. }
  3919. }
  3920. AddSpeed() {
  3921. this.m_chasenpcspeed = StageControl.Instance.curstage.npcspeed;
  3922. }
  3923. SlowSpeed() {
  3924. this.m_chasenpcspeed = StageControl.Instance.curstage.npcspeed / 2;
  3925. }
  3926. GameOver() {
  3927. EventManager.StageOff(StageState.Press, this, this.AddSpeed);
  3928. EventManager.StageOff(StageState.UnPress, this, this.SlowSpeed);
  3929. EventManager.StageOff(StageState.Start, this, this.Begin);
  3930. EventManager.StageOff(StageState.Lose, this, this.GameOver);
  3931. EventManager.StageOff(StageState.Win, this, this.GameOver);
  3932. }
  3933. ChangeState(_state) {
  3934. if (this.m_chasenpcstate == _state)
  3935. return;
  3936. this.m_chasenpcstate = _state;
  3937. switch (this.m_chasenpcstate) {
  3938. case ChaseNpcState.Atk:
  3939. this.Attack();
  3940. break;
  3941. case ChaseNpcState.Idle:
  3942. this.Idle();
  3943. break;
  3944. case ChaseNpcState.Run:
  3945. this.Run();
  3946. break;
  3947. case ChaseNpcState.Die:
  3948. this.Die();
  3949. break;
  3950. }
  3951. }
  3952. Idle() {
  3953. this.m_chasenpcanimator.play("idle");
  3954. }
  3955. Attack() {
  3956. this.m_chasenpcanimator.play("atk");
  3957. Laya.timer.once(500, this, () => {
  3958. this.canmove = false;
  3959. });
  3960. }
  3961. Win() {
  3962. this.m_chasenpcanimator.play("win");
  3963. }
  3964. Run() {
  3965. this.m_chasenpcanimator.play("run");
  3966. }
  3967. Die() {
  3968. if (this.die)
  3969. return;
  3970. this.die = true;
  3971. AudioManager.playMusic(MusicType.die);
  3972. this.PiaoZi();
  3973. this.isdead = true;
  3974. EventManager.StageOff(StageState.Start, this, this.Begin);
  3975. if (this.frontdie) {
  3976. this.m_chasenpcanimator.play("diefront");
  3977. }
  3978. if (this.reardie) {
  3979. this.m_chasenpcanimator.play("dierear");
  3980. }
  3981. this.m_chasenpcanimator.play("diefront");
  3982. this.canmove = false;
  3983. }
  3984. PiaoZi() {
  3985. let headshoot = new Laya.Image();
  3986. headshoot.skin = "Game/res/textrue/headshoot.png";
  3987. headshoot.scaleX = 0.5;
  3988. headshoot.scaleY = 0.5;
  3989. headshoot.anchorX = 0.5;
  3990. headshoot.anchorY = 0.5;
  3991. Laya.stage.addChild(headshoot);
  3992. Laya.timer.once(1000, this, () => {
  3993. headshoot.visible = false;
  3994. Laya.timer.clear(this, this.UIFollow);
  3995. });
  3996. GameManager.Instance.UIArray.push(headshoot);
  3997. let UIPos = this.m_chasenpcmodel.getChildByName("UIPos");
  3998. let screenpos2 = new Vector3$6();
  3999. Laya.timer.frameLoop(1, this, this.UIFollow, [UIPos, headshoot, screenpos2]);
  4000. }
  4001. UIFollow(UIPos, UI, POS) {
  4002. AssetManager.Instance.maincamera.worldToViewportPoint(UIPos.transform.position, POS);
  4003. UI.pos(POS.x, POS.y);
  4004. }
  4005. RayCheck() {
  4006. let startpos = new Vector3$6(this.m_chasenpcmodel.transform.position.x, this.m_chasenpcmodel.transform.position.y + 0.5, this.m_chasenpcmodel.transform.position.z);
  4007. let dir = Transform3DHelper.getForward(this.m_chasenpcmodel.transform);
  4008. let ray = new Laya.Ray(startpos, dir);
  4009. let hitres = new Laya.HitResult();
  4010. let isHit = AssetManager.Instance.mainscene.physicsSimulation.rayCast(ray, hitres, 3, 200);
  4011. if (isHit) {
  4012. let target = hitres.collider.owner.parent;
  4013. if (target.name == "hostage") {
  4014. let _hostage = target.getComponent(Hostage);
  4015. _hostage.isdead = true;
  4016. }
  4017. else if (target.name == "bonfire") {
  4018. this.ChangeState(ChaseNpcState.Die);
  4019. }
  4020. else if (target.name == "stone") {
  4021. this.m_chasenpcspeed = 0;
  4022. }
  4023. else if (target.name == "") ;
  4024. }
  4025. }
  4026. }
  4027. class Dictionary {
  4028. constructor() {
  4029. this.keys = new Array();
  4030. this.values = new Array();
  4031. }
  4032. get count() {
  4033. return this.keys.length;
  4034. }
  4035. add(key, value) {
  4036. let index = this.keys.indexOf(key);
  4037. if (index == -1) {
  4038. this.keys.push(key);
  4039. this.values.push(value);
  4040. }
  4041. else {
  4042. this.values[index] = value;
  4043. }
  4044. }
  4045. remove(key) {
  4046. let index = this.keys.indexOf(key);
  4047. if (index != -1) {
  4048. this.keys.splice(index, 1);
  4049. this.values.splice(index, 1);
  4050. }
  4051. }
  4052. getValue(key) {
  4053. let index = this.keys.indexOf(key);
  4054. if (index != -1) {
  4055. return this.values[index];
  4056. }
  4057. return null;
  4058. }
  4059. containKey(key) {
  4060. let index = this.keys.indexOf(key);
  4061. if (index != -1) {
  4062. return true;
  4063. }
  4064. return false;
  4065. }
  4066. containValue(value) {
  4067. let index = this.values.indexOf(value);
  4068. if (index != -1) {
  4069. return true;
  4070. }
  4071. return false;
  4072. }
  4073. clear() {
  4074. this.keys.length = 0;
  4075. this.values.length = 0;
  4076. }
  4077. }
  4078. var Vector3$7 = Laya.Vector3;
  4079. var BossState;
  4080. (function (BossState) {
  4081. BossState[BossState["Idle"] = 0] = "Idle";
  4082. BossState[BossState["Run"] = 1] = "Run";
  4083. BossState[BossState["Die"] = 2] = "Die";
  4084. BossState[BossState["Walk"] = 3] = "Walk";
  4085. })(BossState || (BossState = {}));
  4086. class Boss extends Laya.Script {
  4087. constructor() {
  4088. super();
  4089. this.canmove = false;
  4090. this.FowardHit = new Laya.HitResult();
  4091. this.isfence = false;
  4092. this.arrowarray = [];
  4093. this.m_arrowspeed = 0;
  4094. this.AtkInterval = 0;
  4095. this.BossSpeed = 1;
  4096. this.CreatGround = false;
  4097. this.randomdir = false;
  4098. this.ArrowList = new Dictionary();
  4099. this.currotV = new Vector3$7();
  4100. this.currot = new Laya.Quaternion;
  4101. this.NormalizeSpeed = new Vector3$7();
  4102. this.curpos = new Vector3$7();
  4103. this.offest = new Vector3$7();
  4104. this.offestx = 0;
  4105. this.atk = false;
  4106. this.run = false;
  4107. this.curspeed = 0;
  4108. this.BossMoveDir = new Vector3$7(0, 0, 1);
  4109. this.CurrectRotate = new Laya.Quaternion();
  4110. this.recover = false;
  4111. this.speed = 0;
  4112. this.arrowoffset = new Vector3$7();
  4113. this.arrowcurpos = new Vector3$7();
  4114. EventManager.StageOn(StageState.Press, this, this.AddSpeed);
  4115. EventManager.StageOn(StageState.UnPress, this, this.SlowSpeed);
  4116. EventManager.StageOn(StageState.Win, this, this.GameOver);
  4117. EventManager.StageOn(StageState.Lose, this, this.GameOver);
  4118. }
  4119. static get Instance() {
  4120. if (Boss.ins) {
  4121. return Boss.ins;
  4122. }
  4123. else {
  4124. return new Boss();
  4125. }
  4126. }
  4127. onAwake() {
  4128. this.m_bossmodel = this.owner;
  4129. this.m_horsemodel = this.m_bossmodel.parent;
  4130. this.m_bossanimator = this.m_bossmodel.getComponent(Laya.Animator);
  4131. this.m_horseanimator = this.m_horsemodel.getComponent(Laya.Animator);
  4132. this.arrowpos = this.m_bossmodel.getChildByName("arrowpos");
  4133. this.archerpos = this.m_bossmodel.getChildByName("archerpos");
  4134. this.raypos = this.m_bossmodel.getChildByName("raypos");
  4135. this.CreatRay(this.raypos.transform.position.clone(), this.raypos.transform.rotationEuler.clone(), this.raypos);
  4136. this.CreatArcher(this.archerpos.transform.position.clone(), this.archerpos.transform.rotationEuler.clone(), this.archerpos);
  4137. this.Player = PlayerControl.Instance.Player;
  4138. let stage = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
  4139. this.BossHp = Number(StageControl.Instance.curstagedic[stage].BossHp);
  4140. this.NowBossHp = this.BossHp;
  4141. this.AddHpUI();
  4142. this.BossDistance = AccountManager.Instance.curplayerData.BossDistance * 1.65;
  4143. this.level = AccountManager.Instance.curplayerData.GainAccount("stage");
  4144. this.AtkInterval = AccountManager.Instance.curplayerData.BossAtkInterval - (this.level - 1) * 0.5;
  4145. this.m_arrowspeed = AccountManager.Instance.curplayerData.ArrowSpeed;
  4146. }
  4147. onUpdate() {
  4148. if (this.isdead)
  4149. return;
  4150. var dis = Vector3$7.distance(this.Player.transform.position, this.m_bossmodel.transform.position);
  4151. if (dis <= this.BossDistance && !this.run) {
  4152. this.run = true;
  4153. WXSDK.Shake();
  4154. this.ChangeState(BossState.Run);
  4155. }
  4156. if (dis >= AccountManager.Instance.curplayerData.MaxBossDistance * 1.65 && this.run) {
  4157. this.canmove = false;
  4158. }
  4159. else if (dis > AccountManager.Instance.curplayerData.MinBossDistance * 1.65 && dis < AccountManager.Instance.curplayerData.MaxBossDistance * 1.65 && this.run) {
  4160. this.ChangeState(BossState.Run);
  4161. this.canmove = true;
  4162. this.BossSpeed = StageControl.Instance.curstage.mainrolespeed;
  4163. }
  4164. if (!this.canmove)
  4165. return;
  4166. this.Move(this.BossMoveDir, this.BossSpeed);
  4167. if (!this.atk) {
  4168. this.atk = true;
  4169. Laya.timer.once(this.AtkInterval * 1000, this, this.Atk);
  4170. }
  4171. if (!this.CreatGround && this.m_bossmodel.transform.position.z > StageControl.Instance.LastGround - 50) {
  4172. StageControl.Instance.CreatGround(5);
  4173. }
  4174. if (!this.randomdir) {
  4175. this.randomdir = true;
  4176. Laya.timer.once(2000, this, this.RandomDir);
  4177. }
  4178. this.RayCheck();
  4179. if (this.ArrowList != null) {
  4180. var keys = this.ArrowList.keys;
  4181. for (var i = 0; i < keys.length; i++) {
  4182. var key = keys[i];
  4183. if (keys[i] != null) {
  4184. var value = this.ArrowList.getValue(keys[i]);
  4185. this.ArrowMove(key, (this.ArrowList.getValue(key))[0], (this.ArrowList.getValue(key))[1]);
  4186. }
  4187. }
  4188. }
  4189. }
  4190. TurnDir(_dir) {
  4191. if (_dir.x != 0) {
  4192. Vector3$7.lerp(this.currotV, _dir, 0.35, _dir);
  4193. this.currotV = _dir;
  4194. Laya.Quaternion.rotationLookAt(_dir, new Vector3$7(0, 1, 0), this.currot);
  4195. Laya.Quaternion.slerp(this.m_horsemodel.transform.rotation, this.currot, 0.025, this.currot);
  4196. this.currot = new Laya.Quaternion(0, this.currot.y, 0);
  4197. this.m_horsemodel.transform.rotation = this.currot;
  4198. }
  4199. }
  4200. MoveX(_speed) {
  4201. if (this.m_horsemodel.transform.position.x < 0 && _speed < 0 && this.isfence) {
  4202. return;
  4203. }
  4204. else if (this.m_horsemodel.transform.position.x > 0 && _speed > 0 && this.isfence) {
  4205. return;
  4206. }
  4207. else if (this.m_horsemodel.transform.position.x >= GameManager.Instance.fenceleftpos && _speed > 0) {
  4208. return;
  4209. }
  4210. else if (this.m_horsemodel.transform.position.x <= GameManager.Instance.fencerightpos && _speed < 0) {
  4211. return;
  4212. }
  4213. _speed *= 0.07;
  4214. this.m_horsemodel.transform.translate(new Vector3$7(_speed, 0, 0));
  4215. }
  4216. RandomDir() {
  4217. let _dir = Math.random() > 0.5 ? -0.5 : 0.5;
  4218. this.BossMoveDir = new Vector3$7(_dir, 0, 1);
  4219. Laya.timer.once(200, this, () => {
  4220. this.BossMoveDir = new Vector3$7(0, 0, 1);
  4221. this.randomdir = false;
  4222. });
  4223. }
  4224. Move(_dir, _speed) {
  4225. var sp = GameTools.Instance.lerp(this.curspeed, _speed, 0.1);
  4226. this.curspeed = sp;
  4227. Vector3$7.scale(_dir, this.curspeed, this.offest);
  4228. Vector3$7.add(this.m_horsemodel.transform.position, this.offest, this.curpos);
  4229. Vector3$7.lerp(this.m_horsemodel.transform.position, this.curpos, 0.15, this.curpos);
  4230. this.m_horsemodel.transform.position = this.curpos;
  4231. this.m_horsemodel.transform.position = this.m_horsemodel.transform.position.x < GameManager.Instance.fencerightpos + 0.5 ? new Vector3$7(GameManager.Instance.fencerightpos + 0.5, this.m_horsemodel.transform.position.y, this.m_horsemodel.transform.position.z) : this.m_horsemodel.transform.position;
  4232. this.m_horsemodel.transform.position = this.m_horsemodel.transform.position.x > GameManager.Instance.fenceleftpos - 0.5 ? new Vector3$7(GameManager.Instance.fenceleftpos - 0.5, this.m_horsemodel.transform.position.y, this.m_horsemodel.transform.position.z) : this.m_horsemodel.transform.position;
  4233. }
  4234. Atk() {
  4235. Laya.timer.frameLoop(1, this, this.RotationMove);
  4236. }
  4237. SlowSpeed() {
  4238. if (this.run) {
  4239. this.ChangeState(BossState.Walk);
  4240. this.BossSpeed = AccountManager.Instance.curplayerData.BossSpeed / 2;
  4241. }
  4242. }
  4243. AddSpeed() {
  4244. if (this.run) {
  4245. this.ChangeState(BossState.Run);
  4246. this.BossSpeed = AccountManager.Instance.curplayerData.BossSpeed;
  4247. }
  4248. }
  4249. GameOver() {
  4250. EventManager.StageOff(StageState.Press, this, this.AddSpeed);
  4251. EventManager.StageOff(StageState.UnPress, this, this.SlowSpeed);
  4252. }
  4253. RotationMove() {
  4254. Vector3$7.subtract(this.Player.transform.position, this.m_bossmodel.transform.position, this.currotV);
  4255. Vector3$7.normalize(this.currotV, this.currotV);
  4256. var curdir = new Vector3$7(-this.currotV.x, -this.currotV.y, -this.currotV.z);
  4257. Laya.Quaternion.rotationLookAt(curdir, new Vector3$7(0, 10, 0), this.CurrectRotate);
  4258. this.CurrectRotate.invert(this.CurrectRotate);
  4259. Laya.Quaternion.slerp(this.m_bossmodel.transform.rotation, this.CurrectRotate, 0.05, this.CurrectRotate);
  4260. this.m_bossmodel.transform.rotation = this.CurrectRotate;
  4261. var bossfoward = Transform3DHelper.getForward(this.m_bossmodel.transform);
  4262. let _angle = this.JupdeAngle(bossfoward, this.currotV);
  4263. if (_angle > 0.995) {
  4264. Laya.timer.clear(this, this.RotationMove);
  4265. this.Shoot();
  4266. let rotation2 = GameTools.tweenRotate(this.m_bossmodel.transform, new Vector3$7(0, 0, 0), 700, Laya.Ease.linearInOut, Laya.Handler.create(this, () => {
  4267. rotation2.clear();
  4268. this.atk = false;
  4269. }));
  4270. }
  4271. }
  4272. JupdeAngle(dir1, dir2) {
  4273. let Dir1 = new Vector3$7(dir1.x, 0, dir1.z);
  4274. let Dir2 = new Vector3$7(dir2.x, 0, dir2.z);
  4275. Vector3$7.normalize(Dir1, Dir1);
  4276. Vector3$7.normalize(Dir2, Dir2);
  4277. var dot = Vector3$7.dot(Dir1, Dir2);
  4278. return dot;
  4279. }
  4280. Shoot() {
  4281. this.CreatArrow();
  4282. var currect = this.m_arrow;
  4283. this.m_arrow = null;
  4284. let ray = this.owner.getChildByName("raypos").getChildAt(0);
  4285. let forw = Transform3DHelper.getForward(ray.transform);
  4286. let raypos = this.owner.getChildByName("raypos");
  4287. let trans = raypos.transform;
  4288. let testRay = new Laya.Ray(new Vector3$7(trans.position.x, trans.position.y - 1, trans.position.z), forw);
  4289. let hitRes = new Laya.HitResult();
  4290. this.m_bossanimator.play("shoot");
  4291. if (AssetManager.Instance.mainscene.physicsSimulation.rayCast(testRay, hitRes)) {
  4292. let target = hitRes.collider.owner.parent;
  4293. this.ArrowList.add(currect, [forw, target]);
  4294. }
  4295. else {
  4296. this.ArrowList.add(currect, [forw, null]);
  4297. }
  4298. }
  4299. ArrowMove(arrow, _dir, target) {
  4300. if (target) {
  4301. if (arrow.destroyed)
  4302. return;
  4303. if (arrow.transform.position.z <= target.transform.position.z) {
  4304. if (target.name == "player") {
  4305. let _runner = target.getComponent(Runner);
  4306. _runner.isdead = true;
  4307. this.BossProgress.visible = false;
  4308. }
  4309. if (this.ArrowList.containKey(arrow)) {
  4310. this.ArrowList.remove(arrow);
  4311. }
  4312. GamePool.Instance.RecoveryModel(arrow);
  4313. }
  4314. else {
  4315. var sp = GameTools.Instance.lerp(this.speed, this.m_arrowspeed, 0.1);
  4316. this.speed = sp;
  4317. Vector3$7.scale(_dir, this.speed, this.arrowoffset);
  4318. Vector3$7.add(arrow.transform.position, this.arrowoffset, this.arrowcurpos);
  4319. Vector3$7.lerp(arrow.transform.position, this.arrowcurpos, 0.15, this.arrowcurpos);
  4320. arrow.transform.position = this.arrowcurpos;
  4321. }
  4322. }
  4323. else {
  4324. var sp = GameTools.Instance.lerp(this.speed, this.m_arrowspeed, 0.1);
  4325. this.speed = sp;
  4326. Vector3$7.scale(_dir, this.speed, this.arrowoffset);
  4327. Vector3$7.add(arrow.transform.position, this.arrowoffset, this.arrowcurpos);
  4328. Vector3$7.lerp(arrow.transform.position, this.arrowcurpos, 0.15, this.arrowcurpos);
  4329. arrow.transform.position = this.arrowcurpos;
  4330. if (!this.recover) {
  4331. this.recover = true;
  4332. Laya.timer.once(1000, this, () => {
  4333. if (this.ArrowList.containKey(arrow)) {
  4334. this.ArrowList.remove(arrow);
  4335. }
  4336. GamePool.Instance.RecoveryModel(arrow);
  4337. this.recover = false;
  4338. });
  4339. }
  4340. }
  4341. }
  4342. ChangeState(_state) {
  4343. if (this._bossstate == _state)
  4344. return;
  4345. this._bossstate = _state;
  4346. switch (this._bossstate) {
  4347. case BossState.Idle:
  4348. this.Idle();
  4349. break;
  4350. case BossState.Run:
  4351. this.Run();
  4352. break;
  4353. case BossState.Die:
  4354. this.Die();
  4355. break;
  4356. case BossState.Walk:
  4357. this.Walk();
  4358. break;
  4359. }
  4360. }
  4361. Idle() {
  4362. this.m_bossanimator.play("idle");
  4363. this.m_horseanimator.play("idle");
  4364. }
  4365. Walk() {
  4366. this.m_horseanimator.play("walk");
  4367. this.m_bossanimator.play("down");
  4368. }
  4369. Run() {
  4370. this.canmove = true;
  4371. this.m_bossanimator.play("down");
  4372. this.m_horseanimator.play("run");
  4373. }
  4374. Die() {
  4375. this.BossProgress.visible = false;
  4376. this.isdead = true;
  4377. Laya.timer.clearAll(this);
  4378. this.m_horseanimator.play("idle");
  4379. this.m_bossanimator.play("die");
  4380. EventManager.StageTrigger(StageState.Win);
  4381. }
  4382. RayCheck() {
  4383. if (this.FowardRayCheck) {
  4384. this.CrashBarrier();
  4385. }
  4386. else {
  4387. this.isfence = false;
  4388. }
  4389. }
  4390. CrashBarrier() {
  4391. var target = this.FowardHit.collider.owner.parent;
  4392. if (target.name == "small_fence") {
  4393. this.isfence = true;
  4394. }
  4395. }
  4396. get FowardRayCheck() {
  4397. var isFowardHit = false;
  4398. var startPos = new Vector3$7(this.m_bossmodel.transform.position.x, this.m_bossmodel.transform.position.y + 0.5, this.m_bossmodel.transform.position.z + 2);
  4399. let dir = Transform3DHelper.getForward(this.m_bossmodel.transform);
  4400. var DownRay = new Laya.Ray(startPos, dir);
  4401. if (AssetManager.Instance.mainscene.physicsSimulation.rayCast(DownRay, this.FowardHit, 1)) {
  4402. if (this.FowardHit.collider.collisionGroup == 100) {
  4403. isFowardHit = true;
  4404. }
  4405. }
  4406. return isFowardHit;
  4407. }
  4408. CreatRay(pos, euler, raypos) {
  4409. var ray = this.CreatRayPrefab();
  4410. raypos.addChild(ray);
  4411. ray.transform.position = pos;
  4412. ray.transform.rotationEuler = euler;
  4413. }
  4414. CreatRayPrefab() {
  4415. var ray = GamePool.Instance.GetModel(AssetManager.Instance.Prop.get(18), "");
  4416. return ray;
  4417. }
  4418. CreatArcher(_pos, _euler, archerpos) {
  4419. var archer = GamePool.Instance.GetModel(AssetManager.Instance.Prop.get(16), "");
  4420. archerpos.addChild(archer);
  4421. archer.transform.position = _pos;
  4422. archer.transform.rotationEuler = _euler;
  4423. var scale = archer.transform.scale.clone();
  4424. scale.x = 0.3;
  4425. scale.y = 0.3;
  4426. scale.z = 0.6;
  4427. archer.transform.scale = scale;
  4428. }
  4429. CreatArrow() {
  4430. var arrow = GamePool.Instance.GetModel(AssetManager.Instance.Prop.get(17), "");
  4431. AssetManager.Instance.mainscene.addChild(arrow);
  4432. this.arrowarray.push(arrow);
  4433. arrow.transform.position = this.arrowpos.transform.position.clone();
  4434. var euler = this.arrowpos.transform.rotationEuler.clone();
  4435. arrow.transform.rotationEuler = euler;
  4436. let scale = arrow.transform.scale.clone();
  4437. scale.z = 0.5;
  4438. scale.x = 0.5;
  4439. scale.y = 0.5;
  4440. arrow.transform.scale = scale;
  4441. this.m_arrow = arrow;
  4442. }
  4443. AddHpUI() {
  4444. this.BossProgress = new Laya.ProgressBar();
  4445. this.BossProgress.skin = "Game/res/textrue/healthbar1.png";
  4446. this.BossProgress.scaleX = 0.4;
  4447. this.BossProgress.scaleY = 0.4;
  4448. this.BossProgress.anchorX = 0.5;
  4449. this.BossProgress.anchorY = 0.5;
  4450. Laya.stage.addChild(this.BossProgress);
  4451. GameManager.Instance.UIArray.push(this.BossProgress);
  4452. let UIPos = this.m_bossmodel.getChildByName("UIPos");
  4453. this.InitHpUI();
  4454. Laya.timer.frameLoop(1, this, () => {
  4455. let ScreenPos = new Vector3$7();
  4456. AssetManager.Instance.maincamera.worldToViewportPoint(UIPos.transform.position, ScreenPos);
  4457. this.BossProgress.pos(ScreenPos.x, ScreenPos.y);
  4458. });
  4459. }
  4460. InitHpUI() {
  4461. this.BossProgress.value = this.NowBossHp / this.BossHp;
  4462. }
  4463. LoseHp(_damage) {
  4464. GameManager.Instance.KillNum++;
  4465. InGameView.Instance.InitUI();
  4466. if (this.NowBossHp >= _damage) {
  4467. this.NowBossHp = this.NowBossHp -= _damage;
  4468. }
  4469. else if (this.NowBossHp < _damage && this.NowBossHp > 0) {
  4470. this.NowBossHp = 0;
  4471. }
  4472. if (this.NowBossHp == 0) {
  4473. this.ChangeState(BossState.Die);
  4474. this.BossProgress.destroy();
  4475. }
  4476. else {
  4477. this.InitHpUI();
  4478. }
  4479. }
  4480. }
  4481. var Vector3$8 = Laya.Vector3;
  4482. var CharacterState;
  4483. (function (CharacterState) {
  4484. CharacterState[CharacterState["Run"] = 0] = "Run";
  4485. CharacterState[CharacterState["Idle"] = 1] = "Idle";
  4486. CharacterState[CharacterState["Die"] = 2] = "Die";
  4487. CharacterState[CharacterState["Win"] = 3] = "Win";
  4488. CharacterState[CharacterState["Shoot"] = 4] = "Shoot";
  4489. CharacterState[CharacterState["Walk"] = 5] = "Walk";
  4490. CharacterState[CharacterState["Revive"] = 6] = "Revive";
  4491. })(CharacterState || (CharacterState = {}));
  4492. class Runner extends Laya.Script3D {
  4493. constructor() {
  4494. super();
  4495. this.Invincible = false;
  4496. this.started = false;
  4497. this.shoot = false;
  4498. this.isbarrier = false;
  4499. this.isfence = false;
  4500. this.arrowarray = [];
  4501. this.isdead = false;
  4502. this.canmove = false;
  4503. this._speed = 0;
  4504. this._press = false;
  4505. this.RayDir = new Vector3$8();
  4506. this.DownHit = new Laya.HitResult();
  4507. this.FowardHit = new Laya.HitResult();
  4508. this.curspeed = 0;
  4509. this.currotV = new Vector3$8();
  4510. this.currot = new Laya.Quaternion;
  4511. this.NormalizeSpeed = new Vector3$8();
  4512. this.curpos = new Vector3$8();
  4513. this.offest = new Vector3$8();
  4514. this.ArrowList = new Dictionary();
  4515. this.arrowspeed = 0;
  4516. this.speed = 0;
  4517. this.arrowoffset = new Vector3$8();
  4518. this.arrowcurpos = new Vector3$8();
  4519. this.recover = false;
  4520. this.hitfence = false;
  4521. EventManager.StageOn(StageState.Start, this, this.Begin);
  4522. EventManager.StageOn(StageState.Lose, this, this.GameOver);
  4523. EventManager.StageOn(StageState.Win, this, this.GameOver);
  4524. }
  4525. static get Instance() {
  4526. if (Runner.ins) {
  4527. return Runner.ins;
  4528. }
  4529. else {
  4530. return new Runner();
  4531. }
  4532. }
  4533. onAwake() {
  4534. this.m_player = this.owner;
  4535. this.m_animator = this.owner.getComponent(Laya.Animator);
  4536. this.m_arrowpos = this.owner.getChildByName("arrowpos");
  4537. this.m_raypos = this.owner.getChildByName("raypos");
  4538. this.m_archerpos = this.owner.getChildByName("archerpos");
  4539. this.m_horseanimator = this.owner.getChildAt(this.owner.numChildren - 1).getComponent(Laya.Animator);
  4540. this._speed = StageControl.Instance.curstage.mainrolespeed;
  4541. this.m_PlayerDamage = AccountManager.Instance.curplayerData.PlayerDamage;
  4542. this.stage = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
  4543. this.ChangeState(CharacterState.Idle);
  4544. this.DirRoatationLerp = AccountManager.Instance.curplayerData.DirRoatationLerp;
  4545. this.DirMoveLerp = AccountManager.Instance.curplayerData.DirMoveLerp;
  4546. this.arrowspeed = AccountManager.Instance.curplayerData.ArrowSpeed;
  4547. this.m_range = AccountManager.Instance.curplayerData.Range;
  4548. }
  4549. Begin() {
  4550. this.canmove = true;
  4551. this.CreatArrow();
  4552. this.ChangeState(CharacterState.Walk);
  4553. }
  4554. onUpdate() {
  4555. if (this.isdead) {
  4556. this.ChangeState(CharacterState.Die);
  4557. return;
  4558. }
  4559. if (this.canmove && this.started) {
  4560. var speed;
  4561. if (!this.isbarrier) {
  4562. if (this._press) {
  4563. speed = StageControl.Instance.curstage.mainrolespeed;
  4564. }
  4565. else {
  4566. speed = StageControl.Instance.curstage.mainrolespeed / 2;
  4567. }
  4568. let foward = Transform3DHelper.getForward(this.m_player.transform);
  4569. this.Move(foward, speed);
  4570. }
  4571. }
  4572. this.RayCheck();
  4573. if (this.ArrowList != null) {
  4574. var keys = this.ArrowList.keys;
  4575. for (var i = 0; i < keys.length; i++) {
  4576. var key = keys[i];
  4577. if (keys[i] != null) {
  4578. var value = this.ArrowList.getValue(keys[i]);
  4579. this.ArrowMove(key, (this.ArrowList.getValue(key))[0], (this.ArrowList.getValue(key))[1]);
  4580. }
  4581. }
  4582. }
  4583. }
  4584. MoveX(_speed) {
  4585. if (this.m_player.transform.position.x < 0 && _speed < 0 && this.isfence) {
  4586. return;
  4587. }
  4588. else if (this.m_player.transform.position.x > 0 && _speed > 0 && this.isfence) {
  4589. return;
  4590. }
  4591. else if (this.m_player.transform.position.x >= GameManager.Instance.fenceleftpos && _speed > 0) {
  4592. return;
  4593. }
  4594. else if (this.m_player.transform.position.x <= GameManager.Instance.fencerightpos && _speed < 0) {
  4595. return;
  4596. }
  4597. _speed *= this.DirMoveLerp;
  4598. if (this.canmove && this.started) {
  4599. this.m_player.transform.translate(new Vector3$8(_speed, 0, 0));
  4600. }
  4601. }
  4602. TurnDir(_dir) {
  4603. if (_dir.x != 0) {
  4604. Vector3$8.lerp(this.currotV, _dir, 0.35, _dir);
  4605. this.currotV = _dir;
  4606. Laya.Quaternion.rotationLookAt(_dir, new Vector3$8(0, 1, 0), this.currot);
  4607. Laya.Quaternion.slerp(this.m_player.transform.rotation, this.currot, this.DirRoatationLerp, this.currot);
  4608. this.currot = new Laya.Quaternion(0, this.currot.y, 0);
  4609. this.m_player.transform.rotation = this.currot;
  4610. }
  4611. }
  4612. Move(_dir, _speed) {
  4613. var sp = GameTools.Instance.lerp(this.curspeed, _speed, 0.1);
  4614. this.curspeed = sp;
  4615. Vector3$8.scale(_dir, this.curspeed, this.offest);
  4616. Vector3$8.add(this.m_player.transform.position, this.offest, this.curpos);
  4617. Vector3$8.lerp(this.m_player.transform.position, this.curpos, 0.15, this.curpos);
  4618. this.curpos = new Vector3$8(this.curpos.x, this.curpos.y, this.curpos.z);
  4619. this.m_player.transform.position = this.curpos;
  4620. this.m_player.transform.position = this.m_player.transform.position.x < GameManager.Instance.fencerightpos + 0.5 ? new Vector3$8(GameManager.Instance.fencerightpos + 0.5, this.m_player.transform.position.y, this.m_player.transform.position.z) : this.m_player.transform.position;
  4621. this.m_player.transform.position = this.m_player.transform.position.x > GameManager.Instance.fenceleftpos - 0.5 ? new Vector3$8(GameManager.Instance.fenceleftpos - 0.5, this.m_player.transform.position.y, this.m_player.transform.position.z) : this.m_player.transform.position;
  4622. }
  4623. ChangeState(_state) {
  4624. if (this.m_characterstate == _state)
  4625. return;
  4626. this.m_characterstate = _state;
  4627. switch (this.m_characterstate) {
  4628. case CharacterState.Idle:
  4629. this.Idle();
  4630. break;
  4631. case CharacterState.Run:
  4632. this.Run();
  4633. break;
  4634. case CharacterState.Die:
  4635. this.Die();
  4636. break;
  4637. case CharacterState.Shoot:
  4638. this.Shoot();
  4639. break;
  4640. case CharacterState.Walk:
  4641. this.Walk();
  4642. break;
  4643. }
  4644. }
  4645. Idle() {
  4646. this.m_animator.play("idle");
  4647. this.m_horseanimator.play("idle");
  4648. }
  4649. Run() {
  4650. this.m_animator.play("down");
  4651. this.m_horseanimator.play("run");
  4652. }
  4653. ReviveState() {
  4654. this.m_horseanimator.play("walk");
  4655. this.m_animator.play("down");
  4656. }
  4657. Die() {
  4658. WXSDK.Shake(true);
  4659. this.canmove = false;
  4660. this.m_animator.play("die");
  4661. this.m_horseanimator.play("idle");
  4662. EventManager.StageTrigger(StageState.Lose);
  4663. }
  4664. GameOver() {
  4665. Laya.timer.clear(this, this.AnimatorState);
  4666. EventManager.StageOff(StageState.Start, this, this.Begin);
  4667. }
  4668. Walk() {
  4669. this.m_horseanimator.play("walk");
  4670. }
  4671. Shoot() {
  4672. this.m_animator.play("shoot");
  4673. }
  4674. RayCheck() {
  4675. if (this.FowardRayCheck) {
  4676. this.CrashBarrier();
  4677. }
  4678. else {
  4679. this.isbarrier = false;
  4680. this.isfence = false;
  4681. }
  4682. }
  4683. CrashBarrier() {
  4684. var target = this.FowardHit.collider.owner.parent;
  4685. if (target.name == "stone") {
  4686. this.isbarrier = true;
  4687. }
  4688. else if (target.name == "bonfire") {
  4689. this.ChangeState(CharacterState.Die);
  4690. }
  4691. else if (target.name == "big_fence") {
  4692. this.isbarrier = true;
  4693. }
  4694. else if (target.name == "wood_Cylinder") {
  4695. this.isbarrier = true;
  4696. }
  4697. else if (target.name == "small_fence") {
  4698. this.isfence = true;
  4699. }
  4700. }
  4701. get FowardRayCheck() {
  4702. var isFowardHit = false;
  4703. var startPos = new Vector3$8(this.m_player.transform.position.x, this.m_player.transform.position.y + 0.5, this.m_player.transform.position.z);
  4704. let dir = Transform3DHelper.getForward(this.m_player.transform);
  4705. var DownRay = new Laya.Ray(startPos, dir);
  4706. if (AssetManager.Instance.mainscene.physicsSimulation.rayCast(DownRay, this.FowardHit, 1)) {
  4707. if (this.FowardHit.collider.collisionGroup == 100) {
  4708. isFowardHit = true;
  4709. }
  4710. }
  4711. return isFowardHit;
  4712. }
  4713. Archery() {
  4714. var currect = this.m_arrow;
  4715. this.m_arrow = null;
  4716. AudioManager.playMusic(MusicType.shoot);
  4717. Laya.timer.clear(this, this.ArrowFollow);
  4718. Laya.timer.clear(this, this.AnimatorState);
  4719. let ray = this.owner.getChildByName("raypos").getChildAt(0);
  4720. let forw = Transform3DHelper.getForward(ray.transform);
  4721. let raypos = this.owner.getChildByName("raypos");
  4722. let trans = raypos.transform;
  4723. let testRay = new Laya.Ray(new Vector3$8(trans.position.x, trans.position.y - 0.5, trans.position.z), forw);
  4724. let hitRes = new Laya.HitResult();
  4725. this.m_animator.play("shoot");
  4726. Laya.timer.frameLoop(1, this, this.AnimatorState);
  4727. if (this.stage <= 2) {
  4728. if (AssetManager.Instance.mainscene.physicsSimulation.rayCast(testRay, hitRes, this.m_range)) {
  4729. let target = hitRes.collider.owner;
  4730. this.ArrowList.add(currect, [forw, target]);
  4731. }
  4732. else {
  4733. this.ArrowList.add(currect, [forw, null]);
  4734. }
  4735. }
  4736. else {
  4737. if (AssetManager.Instance.mainscene.physicsSimulation.rayCast(testRay, hitRes)) {
  4738. let target = hitRes.collider.owner;
  4739. this.ArrowList.add(currect, [forw, target]);
  4740. }
  4741. else {
  4742. this.ArrowList.add(currect, [forw, null]);
  4743. }
  4744. }
  4745. }
  4746. ArrowMove(arrow, _dir, target) {
  4747. if (target) {
  4748. if (arrow.destroyed)
  4749. return;
  4750. let parent = target.parent;
  4751. if (arrow.transform.position.z >= parent.transform.position.z) {
  4752. if (parent.name == "npc") {
  4753. AudioManager.playMusic(MusicType.hit);
  4754. if (this.stage == 1) {
  4755. if (InGameView.Instance.Guide2.visible) {
  4756. if (GameManager.Instance.GuideKill < 2) {
  4757. GameManager.Instance.GuideKill += 1;
  4758. }
  4759. if (GameManager.Instance.GuideKill == 1) {
  4760. this.started = true;
  4761. InGameView.Instance.Guide2.visible = false;
  4762. Laya.timer.once(2500, this, () => {
  4763. this.started = false;
  4764. InGameView.Instance.Guide3.visible = true;
  4765. this.m_range = 100;
  4766. });
  4767. }
  4768. }
  4769. }
  4770. else if (this.stage == 2) {
  4771. if (InGameView.Instance.Guide2.visible) {
  4772. GameManager.Instance.GuideKill += 1;
  4773. if (GameManager.Instance.GuideKill >= 1) {
  4774. this.started = true;
  4775. InGameView.Instance.Guide2.visible = false;
  4776. Laya.timer.once(2000, this, () => {
  4777. this.started = false;
  4778. InGameView.Instance.Guide4.visible = true;
  4779. this.m_range = 100;
  4780. });
  4781. }
  4782. }
  4783. }
  4784. let _npcrunner = parent.getComponent(NpcRunner);
  4785. let _chaseNpc = parent.getComponent(ChaseNpc);
  4786. if (_npcrunner) {
  4787. let stage = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
  4788. if (stage == 1) {
  4789. if (GameManager.Instance.GuideKill == 1) {
  4790. if (target.name == "npcfrontcollider") {
  4791. _npcrunner.frontdie = true;
  4792. }
  4793. else if (target.name == "npcrearcollider") {
  4794. _npcrunner.reardie = true;
  4795. }
  4796. GameManager.Instance.KillNum++;
  4797. InGameView.Instance.InitUI();
  4798. }
  4799. }
  4800. else if (stage == 2) {
  4801. if (InGameView.Instance.Guide2.visible || GameManager.Instance.GuideKill == 1) {
  4802. if (target.name == "npcfrontcollider") {
  4803. _npcrunner.frontdie = true;
  4804. }
  4805. else if (target.name == "npcrearcollider") {
  4806. _npcrunner.reardie = true;
  4807. }
  4808. }
  4809. GameManager.Instance.KillNum++;
  4810. InGameView.Instance.InitUI();
  4811. }
  4812. else if (stage > 2) {
  4813. if (target.name == "npcfrontcollider") {
  4814. _npcrunner.frontdie = true;
  4815. }
  4816. else if (target.name == "npcrearcollider") {
  4817. _npcrunner.reardie = true;
  4818. }
  4819. GameManager.Instance.KillNum++;
  4820. InGameView.Instance.InitUI();
  4821. }
  4822. WXSDK.Shake(true);
  4823. WXSDK.stageShake();
  4824. }
  4825. else if (_chaseNpc) {
  4826. if (this.stage == 2) {
  4827. if (InGameView.Instance.Guide4.visible && GameManager.Instance.GuideKill >= 1) {
  4828. InGameView.Instance.Guide4.visible = false;
  4829. WXSDK.AldEvent("完成第四阶段引导");
  4830. this.started = true;
  4831. Laya.timer.once(3000, this, () => {
  4832. EventManager.StageTrigger(StageState.Win);
  4833. });
  4834. if (target.name == "npcfrontcollider") {
  4835. _chaseNpc.frontdie = true;
  4836. }
  4837. else if (target.name == "npcrearcollider") {
  4838. _chaseNpc.reardie = true;
  4839. }
  4840. GameManager.Instance.KillNum++;
  4841. InGameView.Instance.InitUI();
  4842. }
  4843. }
  4844. else {
  4845. if (target.name == "npcfrontcollider") {
  4846. _chaseNpc.frontdie = true;
  4847. }
  4848. else if (target.name == "npcrearcollider") {
  4849. _chaseNpc.reardie = true;
  4850. }
  4851. GameManager.Instance.KillNum++;
  4852. InGameView.Instance.InitUI();
  4853. }
  4854. WXSDK.Shake(true);
  4855. WXSDK.stageShake();
  4856. }
  4857. }
  4858. else if (parent.name == "big_fence") {
  4859. AudioManager.playMusic(MusicType.hit);
  4860. WXSDK.Shake(true);
  4861. if (this.stage == 1) {
  4862. if (GameManager.Instance.GuideKill >= 1) {
  4863. InGameView.Instance.Guide3.visible = false;
  4864. if (!this.hitfence) {
  4865. Laya.timer.once(5000, this, () => {
  4866. EventManager.StageTrigger(StageState.Win);
  4867. });
  4868. WXSDK.AldEvent("完成第三阶段引导");
  4869. this.started = true;
  4870. this.hitfence = true;
  4871. }
  4872. let tweenpos = GameTools.tweenMove(parent.transform, new Vector3$8(parent.transform.position.x, parent.transform.position.y, parent.transform.position.z + 5), 200, Laya.Ease.linearInOut, Laya.Handler.create(this, () => {
  4873. tweenpos.clear();
  4874. }));
  4875. let tweenrot = GameTools.tweenRotate(parent.transform, new Vector3$8(90, 0, 0), 500, Laya.Ease.linearInOut, Laya.Handler.create(this, () => {
  4876. tweenrot.clear();
  4877. }));
  4878. Laya.timer.once(500, this, () => {
  4879. GamePool.Instance.RecoveryModel(parent);
  4880. });
  4881. }
  4882. }
  4883. else {
  4884. let tweenpos = GameTools.tweenMove(parent.transform, new Vector3$8(parent.transform.position.x, parent.transform.position.y, parent.transform.position.z + 5), 200, Laya.Ease.linearInOut, Laya.Handler.create(this, () => {
  4885. tweenpos.clear();
  4886. }));
  4887. let tweenrot = GameTools.tweenRotate(parent.transform, new Vector3$8(90, 0, 0), 500, Laya.Ease.linearInOut, Laya.Handler.create(this, () => {
  4888. tweenrot.clear();
  4889. }));
  4890. Laya.timer.once(1000, this, () => {
  4891. GamePool.Instance.RecoveryModel(parent);
  4892. });
  4893. }
  4894. }
  4895. else if (parent.name == "hostage") {
  4896. if (this.stage > 1) {
  4897. AudioManager.playMusic(MusicType.hit);
  4898. let _host = parent.getComponent(Hostage);
  4899. _host.isdead = true;
  4900. }
  4901. }
  4902. else if (parent.name == "boss") {
  4903. AudioManager.playMusic(MusicType.hit);
  4904. let _boss = parent.getComponent(Boss);
  4905. _boss.LoseHp(this.m_PlayerDamage);
  4906. }
  4907. if (this.ArrowList.containKey(arrow)) {
  4908. this.ArrowList.remove(arrow);
  4909. }
  4910. GamePool.Instance.RecoveryModel(arrow);
  4911. }
  4912. else {
  4913. var sp = GameTools.Instance.lerp(this.speed, this.arrowspeed, 0.1);
  4914. this.speed = sp;
  4915. Vector3$8.scale(_dir, this.speed, this.arrowoffset);
  4916. Vector3$8.add(arrow.transform.position, this.arrowoffset, this.arrowcurpos);
  4917. Vector3$8.lerp(arrow.transform.position, this.arrowcurpos, 0.15, this.arrowcurpos);
  4918. arrow.transform.position = this.arrowcurpos;
  4919. }
  4920. }
  4921. else {
  4922. var sp = GameTools.Instance.lerp(this.speed, this.arrowspeed, 0.1);
  4923. this.speed = sp;
  4924. Vector3$8.scale(_dir, this.speed, this.arrowoffset);
  4925. Vector3$8.add(arrow.transform.position, this.arrowoffset, this.arrowcurpos);
  4926. Vector3$8.lerp(arrow.transform.position, this.arrowcurpos, 0.15, this.arrowcurpos);
  4927. arrow.transform.position = this.arrowcurpos;
  4928. if (!this.recover) {
  4929. this.recover = true;
  4930. Laya.timer.once(500, this, () => {
  4931. if (this.ArrowList.containKey(arrow)) {
  4932. this.ArrowList.remove(arrow);
  4933. }
  4934. GamePool.Instance.RecoveryModel(arrow);
  4935. this.recover = false;
  4936. });
  4937. }
  4938. }
  4939. }
  4940. AnimatorState() {
  4941. if (this.m_animator.getCurrentAnimatorPlayState(0).normalizedTime >= 1) {
  4942. Laya.timer.clear(this, this.AnimatorState);
  4943. if (!this.m_arrowpos.destroyed) {
  4944. this.CreatArrow();
  4945. this.shoot = false;
  4946. }
  4947. }
  4948. }
  4949. CreatArrow() {
  4950. var arrow = GamePool.Instance.GetModel(AssetManager.Instance.Prop.get(17), "");
  4951. AssetManager.Instance.mainscene.addChild(arrow);
  4952. this.arrowarray.push(arrow);
  4953. arrow.transform.position = this.m_arrowpos.transform.position.clone();
  4954. var euler = this.m_arrowpos.transform.rotationEuler.clone();
  4955. arrow.transform.rotationEuler = euler;
  4956. let scale = arrow.transform.scale.clone();
  4957. scale.z = 0.5;
  4958. scale.x = 0.8;
  4959. scale.y = 0.5;
  4960. arrow.transform.scale = scale;
  4961. this.m_arrow = arrow;
  4962. Laya.timer.frameLoop(1, this, this.ArrowFollow, [arrow, this.m_arrowpos]);
  4963. }
  4964. ArrowFollow(arrow, arrowpos) {
  4965. if (!arrowpos.destroyed) {
  4966. arrow.transform.position = arrowpos.transform.position.clone();
  4967. arrow.transform.rotationEuler = arrowpos.transform.rotationEuler.clone();
  4968. }
  4969. else {
  4970. Laya.timer.clear(this, this.ArrowFollow);
  4971. }
  4972. }
  4973. Revive() {
  4974. this.Invincible = true;
  4975. Laya.timer.once(AccountManager.Instance.curplayerData.Invincible, this, () => {
  4976. this.Invincible = false;
  4977. });
  4978. this.ReviveState();
  4979. this.m_player.transform.position = new Vector3$8(this.m_player.transform.position.x, this.m_player.transform.position.y, this.m_player.transform.position.z - 15);
  4980. this.canmove = true;
  4981. this.ChangeState(CharacterState.Walk);
  4982. }
  4983. }
  4984. var Vector3$9 = Laya.Vector3;
  4985. class PlayerControl {
  4986. constructor() {
  4987. this.DownHit = new Laya.HitResult();
  4988. this.speed = 1;
  4989. this.press = false;
  4990. this.win = false;
  4991. this.offset = new Vector3$9(0, 0, 0);
  4992. this.offestx = 0;
  4993. this.first = false;
  4994. this.poschazhi = new Vector3$9();
  4995. this.gengsuipos = new Vector3$9();
  4996. this.lllpos = new Vector3$9();
  4997. this.hights = 0;
  4998. this.wights = 0;
  4999. PlayerControl.ins = this;
  5000. EventManager.StageOn(StageState.Lose, this, this.GameOver);
  5001. EventManager.StageOn(StageState.Win, this, this.GameOver);
  5002. }
  5003. static get Instance() {
  5004. if (PlayerControl.ins) {
  5005. return PlayerControl.ins;
  5006. }
  5007. else {
  5008. return new PlayerControl();
  5009. }
  5010. }
  5011. Init(_player) {
  5012. this.win = false;
  5013. this.Player = _player;
  5014. this.arrowpos = _player.getChildByName("arrowpos");
  5015. let runner = this.Player.getComponent(Runner);
  5016. if (runner) {
  5017. runner.destroy();
  5018. }
  5019. this._runner = this.Player.addComponent(Runner);
  5020. this.Camera = AssetManager.Instance.maincamera;
  5021. this.Camera.transform.position = new Laya.Vector3(0, 10, -19);
  5022. this.Camera.transform.rotationEuler = new Laya.Vector3(-35.7, 180, 0);
  5023. Laya.stage.on(Laya.Event.MOUSE_DOWN, this, this.onMouseDown);
  5024. this.CameraFollow();
  5025. Laya.timer.frameLoop(1, this, this.CheckWin);
  5026. this.stage = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
  5027. this.curtouchsmoothness = AccountManager.Instance.curplayerData.CurTouchsmoothness;
  5028. this.curtouchsize = AccountManager.Instance.curplayerData.CurTouchsize;
  5029. }
  5030. CheckWin() {
  5031. if (this.stage == 1) {
  5032. if (this.Player.transform.position.z >= StageControl.Instance.curstage.endposition.z * 1.65 && !this.win) {
  5033. this.win = true;
  5034. EventManager.StageTrigger(StageState.Win);
  5035. Laya.timer.clear(this, this.CheckWin);
  5036. }
  5037. }
  5038. else if (this.stage > 2 && StageControl.Instance.curstage.isboss == 0) {
  5039. if (this.Player.transform.position.z >= StageControl.Instance.curstage.endposition.z * 1.2 && !this.win) {
  5040. this.win = true;
  5041. EventManager.StageTrigger(StageState.Win);
  5042. Laya.timer.clear(this, this.CheckWin);
  5043. }
  5044. }
  5045. }
  5046. onMouseDown(e) {
  5047. if (!this._runner.canmove)
  5048. return;
  5049. if (this.stage > 2) {
  5050. this._runner.started = true;
  5051. }
  5052. else if (this.stage == 2 && !this.first) {
  5053. this._runner.started = true;
  5054. }
  5055. if (this.stage == 2 && !this.first) {
  5056. this.first = true;
  5057. Laya.timer.once(1500, this, () => {
  5058. this._runner.started = false;
  5059. InGameView.Instance.Guide2.visible = true;
  5060. });
  5061. }
  5062. if (InGameView.Instance.Guide1.visible) {
  5063. InGameView.Instance.Guide1.visible = false;
  5064. WXSDK.AldEvent("完成第一阶段引导");
  5065. InGameView.Instance.ani1.stop();
  5066. this._runner.started = true;
  5067. Laya.timer.once(2000, this, () => {
  5068. this._runner.started = false;
  5069. InGameView.Instance.Guide2.visible = true;
  5070. });
  5071. }
  5072. this._runner._press = true;
  5073. this.curMousePos = new Laya.Vector2(Laya.MouseManager.instance.mouseX, Laya.MouseManager.instance.mouseY);
  5074. Laya.timer.frameLoop(1, this, this.onMouseMove);
  5075. Laya.stage.on(Laya.Event.MOUSE_UP, this, this.onMouseUp);
  5076. Laya.stage.on(Laya.Event.MOUSE_OUT, this, this.onMouseUp);
  5077. this._runner.ChangeState(CharacterState.Run);
  5078. EventManager.StageTrigger(StageState.Press);
  5079. }
  5080. onMouseMove() {
  5081. if (this.stage != 1) {
  5082. if (!this._runner.canmove) {
  5083. Laya.timer.clear(this, this.onMouseMove);
  5084. return;
  5085. }
  5086. }
  5087. var MousePos = new Laya.Vector2(Laya.MouseManager.instance.mouseX, Laya.MouseManager.instance.mouseY);
  5088. var offestX = MousePos.x - this.curMousePos.x;
  5089. offestX = offestX > 50 ? 50 : offestX;
  5090. offestX = offestX < -50 ? -50 : offestX;
  5091. this.offestx = GameTools.Instance.lerp(this.offestx, offestX, this.curtouchsmoothness);
  5092. var dir = new Vector3$9(-offestX * this.curtouchsize, 0, 0);
  5093. this._runner.TurnDir(dir);
  5094. this.curMousePos = MousePos;
  5095. }
  5096. onMouseUp() {
  5097. if (!this._runner.canmove)
  5098. return;
  5099. this.offestx = 0;
  5100. Laya.timer.clear(this, this.onMouseMove);
  5101. this._runner._press = false;
  5102. Laya.stage.off(Laya.Event.MOUSE_MOVE, this, this.onMouseMove);
  5103. Laya.stage.off(Laya.Event.MOUSE_UP, this, this.onMouseUp);
  5104. Laya.stage.off(Laya.Event.MOUSE_OUT, this, this.onMouseUp);
  5105. if (!this._runner.shoot) {
  5106. this._runner.shoot = true;
  5107. this._runner.Archery();
  5108. }
  5109. this._runner.ChangeState(CharacterState.Walk);
  5110. EventManager.StageTrigger(StageState.UnPress);
  5111. }
  5112. GameOver() {
  5113. this._runner.canmove = false;
  5114. this._runner._press = false;
  5115. this.CameraCancelFollow();
  5116. Laya.timer.clear(this, this.CheckWin);
  5117. Laya.stage.off(Laya.Event.MOUSE_MOVE, this, this.onMouseMove);
  5118. Laya.stage.off(Laya.Event.MOUSE_UP, this, this.onMouseUp);
  5119. Laya.stage.off(Laya.Event.MOUSE_OUT, this, this.onMouseUp);
  5120. Laya.stage.off(Laya.Event.MOUSE_DOWN, this, this.onMouseDown);
  5121. }
  5122. Revive() {
  5123. this.Camera.transform.position = new Vector3$9(this.Camera.transform.position.x, this.Camera.transform.position.y, this.Camera.transform.position.z - 15);
  5124. this._runner.Revive();
  5125. this.CameraFollow();
  5126. Laya.stage.on(Laya.Event.MOUSE_DOWN, this, this.onMouseDown);
  5127. }
  5128. CameraFollow() {
  5129. this.hights = 0;
  5130. this.wights = 0;
  5131. Vector3$9.subtract(this.Player.transform.position, this.Camera.transform.position, this.poschazhi);
  5132. Laya.timer.frameLoop(1, this, this.GenSui);
  5133. }
  5134. GenSui() {
  5135. Vector3$9.subtract(this.Player.transform.position, this.poschazhi, this.gengsuipos);
  5136. this.hights = GameTools.Instance.lerp(this.hights, 1, 0.03);
  5137. this.wights = GameTools.Instance.lerp(this.wights, 0.8, 0.02);
  5138. this.gengsuipos = new Vector3$9(this.gengsuipos.x, this.gengsuipos.y, this.gengsuipos.z - this.wights);
  5139. Vector3$9.lerp(this.Camera.transform.position, this.gengsuipos, 0.25, this.lllpos);
  5140. this.lllpos = new Vector3$9(this.gengsuipos.x, this.lllpos.y, this.lllpos.z);
  5141. this.Camera.transform.position = this.lllpos;
  5142. var qqqwe = new Laya.Quaternion();
  5143. var eyePos = new Vector3$9(this.gengsuipos.x, this.gengsuipos.y - 0.8, this.gengsuipos.z);
  5144. Laya.Quaternion.lookAt(eyePos, this.Player.transform.position, new Vector3$9(0, 1, 0), qqqwe);
  5145. qqqwe.invert(qqqwe);
  5146. Laya.Quaternion.slerp(this.Camera.transform.rotation, qqqwe, 0.1, qqqwe);
  5147. this.Camera.transform.rotation = qqqwe;
  5148. }
  5149. CameraCancelFollow() {
  5150. Laya.timer.clear(this, this.GenSui);
  5151. }
  5152. }
  5153. class NpcControl {
  5154. constructor() {
  5155. NpcControl.ins = this;
  5156. }
  5157. static get Instance() {
  5158. if (NpcControl.ins) {
  5159. return NpcControl.ins;
  5160. }
  5161. else {
  5162. return new NpcControl();
  5163. }
  5164. }
  5165. Init(_npc) {
  5166. this.m_npcmodel = _npc;
  5167. let npcrunner = this.m_npcmodel.getComponent(NpcRunner);
  5168. if (npcrunner) {
  5169. npcrunner.destroy();
  5170. }
  5171. this.m_npcrunner = this.m_npcmodel.addComponent(NpcRunner);
  5172. }
  5173. }
  5174. class GameManager {
  5175. constructor() {
  5176. this.started = false;
  5177. this.GuideKill = 0;
  5178. this.KillNum = 0;
  5179. this.ReviveNum = 1;
  5180. this.CharacterArray = [];
  5181. this.UIArray = [];
  5182. this.fenceleftpos = 0;
  5183. this.fencerightpos = 0;
  5184. this.treeleftpos = 0;
  5185. this.treerightpos = 0;
  5186. GameManager.ins = this;
  5187. EventManager.EventOn(EventState.StageInit, this, this.CreatStage);
  5188. EventManager.EventOn(EventState.StageCreateComplete, this, this.Init);
  5189. }
  5190. static get Instance() {
  5191. if (GameManager.ins) {
  5192. return GameManager.ins;
  5193. }
  5194. else {
  5195. return new GameManager();
  5196. }
  5197. }
  5198. Init() {
  5199. this.CreatCharacter();
  5200. this.mainscene = AssetManager.Instance.mainscene;
  5201. Laya.stage.addChildAt(this.mainscene, 0);
  5202. ViewManager.Instance.ShowView(ViewType.MainView);
  5203. }
  5204. CreatStage() {
  5205. StageControl.Instance.RessetStage();
  5206. }
  5207. CreatCharacter() {
  5208. this.CreatPlayer();
  5209. }
  5210. CreatPlayer() {
  5211. var equiphorseid = Number(AccountManager.Instance.curplayerData.GetUser(AccountUser.equip_themes)["2"]);
  5212. var equipcap = Number(AccountManager.Instance.curplayerData.GetUser(AccountUser.equip_themes)["1"]);
  5213. var playermodel = GamePool.Instance.GetModel(AssetManager.Instance.Player.get(1), "");
  5214. var horsemodel = GamePool.Instance.GetModel(AssetManager.Instance.Horse.get(equiphorseid), "");
  5215. playermodel.addChild(horsemodel);
  5216. playermodel.transform.position = new Laya.Vector3(0, 0, -9);
  5217. horsemodel.transform.localScale = new Laya.Vector3(1, 1, 1);
  5218. horsemodel.transform.localPosition = new Laya.Vector3(0, 0, 0);
  5219. this.raypos = playermodel.getChildByName("raypos");
  5220. this.archerpos = playermodel.getChildByName("archerpos");
  5221. this.arrowpos = playermodel.getChildByName("arrowpos");
  5222. this.cappos = playermodel.getChildByName("cappos");
  5223. if (equipcap) {
  5224. var capmodel = GamePool.Instance.GetModel(AssetManager.Instance.Cap.get(equipcap), "");
  5225. this.cappos.addChild(capmodel);
  5226. capmodel.transform.localScale = new Laya.Vector3(0.5, 0.5, 0.5);
  5227. capmodel.transform.localPosition = new Laya.Vector3(0, 0, 0);
  5228. capmodel.transform.localRotationEuler = new Laya.Vector3(-90, 0, 0);
  5229. }
  5230. let ray = this.raypos.getChildAt(0);
  5231. if (!ray) {
  5232. this.CreatRay(this.raypos.transform.position.clone(), this.raypos.transform.rotationEuler.clone(), this.raypos);
  5233. }
  5234. let archer = this.archerpos.getChildAt(0);
  5235. if (!archer) {
  5236. this.CreatArcher(this.archerpos.transform.position.clone(), this.archerpos.transform.rotationEuler.clone(), this.archerpos);
  5237. }
  5238. PlayerControl.Instance.Init(playermodel);
  5239. AssetManager.Instance.mainscene.addChild(playermodel);
  5240. this.CharacterArray.push(playermodel);
  5241. GameTools.Instance.PlayerSetCollider(playermodel, 200);
  5242. }
  5243. CreatEnemy(enemy) {
  5244. enemy.transform.rotationEuler = new Laya.Vector3(0, 180, 0);
  5245. NpcControl.Instance.Init(enemy);
  5246. GameTools.Instance.EnemySetCollider(enemy, 100);
  5247. this.CharacterArray.push(enemy);
  5248. }
  5249. CreatChaseCharacter(_node) {
  5250. let enemy = _node.getChildByName("enemy").getChildAt(0);
  5251. let hostage = _node.getChildByName("player").getChildAt(0);
  5252. hostage.transform.localPosition = new Laya.Vector3(0, 0, 0);
  5253. hostage.transform.localRotationEuler = new Laya.Vector3(0, 0, 0);
  5254. enemy.transform.localPosition = new Laya.Vector3(0, 0, -2);
  5255. enemy.transform.localRotationEuler = new Laya.Vector3(0, 0, 0);
  5256. GameTools.Instance.EnemySetCollider(enemy, 100);
  5257. GameTools.Instance.HostageSetCollider(hostage, 200);
  5258. let chase = enemy.getComponent(ChaseNpc);
  5259. if (chase) {
  5260. chase.destroy();
  5261. }
  5262. else {
  5263. let _ChaseNpc = enemy.addComponent(ChaseNpc);
  5264. }
  5265. let host = hostage.getComponent(Hostage);
  5266. if (host) {
  5267. host.destroy();
  5268. }
  5269. else {
  5270. let _Hostage = hostage.addComponent(Hostage);
  5271. }
  5272. this.CharacterArray.push(_node);
  5273. }
  5274. CreatBoss(_pos) {
  5275. var bossmodel = GamePool.Instance.GetModel(AssetManager.Instance.Boss.get(1), "");
  5276. var horsemodel = GamePool.Instance.GetModel(AssetManager.Instance.Horse.get(50), "");
  5277. let bos = bossmodel.getComponent(Boss);
  5278. if (bos) ;
  5279. else {
  5280. let _boss = bossmodel.addComponent(Boss);
  5281. }
  5282. horsemodel.addChild(bossmodel);
  5283. bossmodel.transform.localPosition = new Laya.Vector3(0, 0, 0);
  5284. bossmodel.transform.localScale = new Laya.Vector3(1, 1, 1);
  5285. horsemodel.transform.position = _pos.clone();
  5286. AssetManager.Instance.mainscene.addChild(horsemodel);
  5287. this.CharacterArray.push(horsemodel);
  5288. }
  5289. RecoveryCharacter() {
  5290. for (let i = 0; i < this.CharacterArray.length; i++) {
  5291. let model = this.CharacterArray[i];
  5292. switch (model.name) {
  5293. case "npc":
  5294. let npcrunner = model.getComponent(NpcRunner);
  5295. if (npcrunner)
  5296. npcrunner.destroy();
  5297. break;
  5298. case "pursue":
  5299. let hostage = model.getChildByName("player").getChildAt(0).getComponent(Hostage);
  5300. let chasenpc = model.getChildByName("enemy").getChildAt(0).getComponent(ChaseNpc);
  5301. if (hostage)
  5302. hostage.destroy();
  5303. if (chasenpc)
  5304. chasenpc.destroy();
  5305. break;
  5306. case "horse1":
  5307. let boss = model.getChildByName("boss");
  5308. boss.active = false;
  5309. boss.removeSelf();
  5310. GamePool.Instance.RecoveryModel(boss);
  5311. let _bs = boss.getComponent(Boss);
  5312. if (_bs) {
  5313. for (let i = 0; i < _bs.arrowarray.length; i++) {
  5314. let arrow = _bs.arrowarray[i];
  5315. GamePool.Instance.RecoveryModel(arrow);
  5316. _bs.arrowarray[i] = null;
  5317. }
  5318. _bs.arrowarray.splice(0, _bs.arrowarray.length);
  5319. _bs.destroy();
  5320. }
  5321. break;
  5322. case "player":
  5323. let runner = model.getComponent(Runner);
  5324. let horse = model.getChildAt(model.numChildren - 1);
  5325. let cap = model.getChildByName("cappos").getChildAt(0);
  5326. if (cap) {
  5327. cap.removeSelf();
  5328. GamePool.Instance.RecoveryModel(cap);
  5329. }
  5330. horse.active = false;
  5331. horse.removeSelf();
  5332. GamePool.Instance.RecoveryModel(horse);
  5333. if (runner) {
  5334. for (let i = 0; i < runner.arrowarray.length; i++) {
  5335. let arrow = runner.arrowarray[i];
  5336. GamePool.Instance.RecoveryModel(arrow);
  5337. runner.arrowarray[i] = null;
  5338. }
  5339. runner.arrowarray.splice(0, runner.arrowarray.length);
  5340. runner.destroy();
  5341. }
  5342. break;
  5343. }
  5344. GamePool.Instance.RecoveryModel(model);
  5345. this.CharacterArray[i] = null;
  5346. }
  5347. this.CharacterArray.splice(0, this.CharacterArray.length);
  5348. for (let i = 0; i < this.UIArray.length; i++) {
  5349. let UI = this.UIArray[i];
  5350. UI.removeSelf();
  5351. UI.destroy();
  5352. }
  5353. this.UIArray.splice(0, this.UIArray.length);
  5354. }
  5355. CreatRay(pos, euler, raypos) {
  5356. var ray = this.CreatRayPrefab();
  5357. raypos.addChild(ray);
  5358. ray.transform.position = pos;
  5359. ray.transform.rotationEuler = euler;
  5360. }
  5361. CreatRayPrefab() {
  5362. var ray = GamePool.Instance.GetModel(AssetManager.Instance.Prop.get(18), "");
  5363. return ray;
  5364. }
  5365. CreatArcher(_pos, _euler, archerpos) {
  5366. var archer = GamePool.Instance.GetModel(AssetManager.Instance.Prop.get(16), "");
  5367. archerpos.addChild(archer);
  5368. archer.transform.position = _pos;
  5369. archer.transform.rotationEuler = _euler;
  5370. var scale = archer.transform.scale.clone();
  5371. scale.x = 0.3;
  5372. scale.y = 0.3;
  5373. scale.z = 0.6;
  5374. archer.transform.scale = scale;
  5375. }
  5376. Revive() {
  5377. PlayerControl.Instance.Revive();
  5378. ViewManager.Instance.ShowView(ViewType.IngameView);
  5379. }
  5380. SetHorse(_id) {
  5381. let horsemodel = PlayerControl.Instance.Player.getChildAt(PlayerControl.Instance.Player.numChildren - 1);
  5382. horsemodel.removeSelf();
  5383. GamePool.Instance.RecoveryModel(horsemodel);
  5384. var newhorsemodel = GamePool.Instance.GetModel(AssetManager.Instance.Horse.get(_id), "");
  5385. PlayerControl.Instance.Player.addChild(newhorsemodel);
  5386. newhorsemodel.transform.localScale = new Laya.Vector3(1, 1, 1);
  5387. newhorsemodel.transform.localPosition = new Laya.Vector3(0, 0, 0);
  5388. PlayerControl.Instance._runner.m_horseanimator = newhorsemodel.getComponent(Laya.Animator);
  5389. }
  5390. SetCap(_id) {
  5391. let cappos = PlayerControl.Instance._runner.m_player.getChildByName("cappos");
  5392. let cap = cappos.getChildAt(0);
  5393. if (cap) {
  5394. cap.removeSelf();
  5395. GamePool.Instance.RecoveryModel(cap);
  5396. }
  5397. let newcap = GamePool.Instance.GetModel(AssetManager.Instance.Cap.get(_id), "");
  5398. cappos.addChild(newcap);
  5399. newcap.transform.localPosition = new Laya.Vector3(0, 0, 0);
  5400. newcap.transform.localScale = new Laya.Vector3(0.5, 0.5, 0.5);
  5401. newcap.transform.localRotationEuler = new Laya.Vector3(-90, 0, 0);
  5402. }
  5403. }
  5404. class MainGame {
  5405. constructor() {
  5406. MainGame.ins = this;
  5407. EventManager.StageOn(StageState.Lose, this, this.GameFailure);
  5408. EventManager.StageOn(StageState.Win, this, this.GameWin);
  5409. }
  5410. static get Instance() {
  5411. if (MainGame.ins) {
  5412. return MainGame.ins;
  5413. }
  5414. else {
  5415. return new MainGame();
  5416. }
  5417. }
  5418. GameFailure() {
  5419. if (GameManager.Instance.ReviveNum > 0) {
  5420. ViewManager.Instance.ShowView(ViewType.CompleteView, 3);
  5421. }
  5422. else {
  5423. AudioManager.StopMusic();
  5424. AudioManager.playMusic(MusicType.Lose);
  5425. ViewManager.Instance.ShowView(ViewType.CompleteView, 2);
  5426. }
  5427. }
  5428. GameWin() {
  5429. AudioManager.StopMusic();
  5430. AudioManager.playMusic(MusicType.Win);
  5431. ViewManager.Instance.ShowView(ViewType.CompleteView, 1);
  5432. }
  5433. Revive() {
  5434. ViewManager.Instance.ShowView(ViewType.CompleteView, 3);
  5435. }
  5436. }
  5437. class LoadView extends ui.LoadViewUI {
  5438. constructor() {
  5439. super();
  5440. this.progressnum = 0;
  5441. this.fast = 0.07;
  5442. this.slow = 0.001;
  5443. this.End = false;
  5444. this.EndProgress = false;
  5445. Laya.stage.addChild(this);
  5446. LoadView.ins = this;
  5447. this.height = Laya.stage.height;
  5448. Laya.stage.on(Laya.Event.RESIZE, this, () => {
  5449. this.height = Laya.stage.height;
  5450. });
  5451. this.Init();
  5452. }
  5453. static get Instance() {
  5454. if (LoadView.ins) {
  5455. return LoadView.ins;
  5456. }
  5457. else {
  5458. return new LoadView();
  5459. }
  5460. }
  5461. Init() {
  5462. console.log("load界面构造函数");
  5463. new GameManager();
  5464. new StageControl();
  5465. new MainGame();
  5466. this.Login();
  5467. Laya.timer.frameLoop(1, this, this.UpdateProgress);
  5468. }
  5469. UpdateProgress() {
  5470. if (this.progressnum <= 0.7) {
  5471. this.progressnum += this.fast;
  5472. }
  5473. else if (this.progressnum > 0.7 && this.progressnum < 0.99) {
  5474. this.progressnum += this.slow;
  5475. }
  5476. else {
  5477. if (this.End) {
  5478. this.progressnum += this.slow;
  5479. }
  5480. }
  5481. if (!this.EndProgress && this.progressnum >= 1) {
  5482. this.EndProgress = true;
  5483. this.progressnum = 1;
  5484. Laya.timer.clear(this, this.UpdateProgress);
  5485. this.LoadComplete();
  5486. }
  5487. this.LoadProgress.value = this.progressnum;
  5488. }
  5489. complete() {
  5490. this.End = true;
  5491. this.slow = this.fast;
  5492. }
  5493. Login() {
  5494. WXSDK.AldEvent("开始加载");
  5495. if (Laya.Browser.onWeiXin) {
  5496. this.WXLogin();
  5497. }
  5498. else {
  5499. this.LocalLogin();
  5500. }
  5501. }
  5502. WXLogin() {
  5503. if (Laya.Browser.onWeiXin) {
  5504. WXSDK.DengLu((res) => {
  5505. if (res != "error") {
  5506. WXSDK.AldEvent("微信登陆成功");
  5507. console.log("1微信登录成功:" + res);
  5508. this.LocalLogin();
  5509. }
  5510. else {
  5511. this.WXLogin();
  5512. }
  5513. });
  5514. }
  5515. else {
  5516. this.LocalLogin();
  5517. }
  5518. }
  5519. LocalLogin() {
  5520. ServerManager.Instance.Login(null, Laya.Handler.create(this, this.LoginComplete), Laya.Handler.create(this, this.LoginFail));
  5521. }
  5522. LoginComplete() {
  5523. WXSDK.canshakestage = AccountManager.Instance.curplayerData.CanStageShake;
  5524. SDKZS.loadData();
  5525. WXSDK.AldEvent("本地服务器登陆成功");
  5526. console.log("本地服务器登陆成功");
  5527. this.LoadSubPackage();
  5528. }
  5529. LoginFail() {
  5530. console.log("本地服务器登陆失败");
  5531. }
  5532. LoadComplete() {
  5533. this.destroy();
  5534. EventManager.EventTrigger(EventState.LoadComplete);
  5535. WXSDK.AldEvent("资源加载完毕,开始进入主界面");
  5536. console.log("加载完毕--");
  5537. }
  5538. LoadSubPackage() {
  5539. WXSDK.LoadSubPackage("Game", callback => {
  5540. if (callback) {
  5541. WXSDK.AldEvent("分包加载成功");
  5542. this.LoadScene();
  5543. }
  5544. });
  5545. }
  5546. LoadScene() {
  5547. Laya.Scene3D.load(ResourcesPath.MainScene, Laya.Handler.create(this, (scene) => {
  5548. this.mainscene = scene;
  5549. AssetManager.Instance.mainscene = this.mainscene;
  5550. console.log("场景资源加载完毕---");
  5551. this.LoadPlayer();
  5552. }));
  5553. }
  5554. LoadPlayer() {
  5555. var path = [];
  5556. for (let i = 0; i < ResourcesPath.Player.length; i++) {
  5557. path.push(ResourcesPath.Player[i]);
  5558. }
  5559. Laya.loader.create(path, Laya.Handler.create(this, () => {
  5560. for (let i = 0; i < ResourcesPath.Player.length; i++) {
  5561. var model = Laya.loader.getRes(ResourcesPath.Player[i]);
  5562. AssetManager.Instance.Player.set(i + 1, model);
  5563. Laya.loader.clearRes(ResourcesPath.Player[i]);
  5564. }
  5565. console.log("玩家模型资源加载完毕---");
  5566. this.LoadHorse();
  5567. }));
  5568. }
  5569. LoadHorse() {
  5570. var path = [];
  5571. for (let i = 0; i < ResourcesPath.Horse.length; i++) {
  5572. path.push(ResourcesPath.Horse[i]);
  5573. }
  5574. Laya.loader.create(path, Laya.Handler.create(this, () => {
  5575. for (let i = 0; i < ResourcesPath.Horse.length; i++) {
  5576. var model = Laya.loader.getRes(ResourcesPath.Horse[i]);
  5577. AssetManager.Instance.Horse.set(i + 50, model);
  5578. Laya.loader.clearRes(ResourcesPath.Horse[i]);
  5579. }
  5580. console.log("马模型资源加载完毕---");
  5581. this.LoadBoss();
  5582. }));
  5583. }
  5584. LoadBoss() {
  5585. var path = [];
  5586. for (let i = 0; i < ResourcesPath.Boss.length; i++) {
  5587. path.push(ResourcesPath.Boss[i]);
  5588. }
  5589. Laya.loader.create(path, Laya.Handler.create(this, () => {
  5590. for (let i = 0; i < ResourcesPath.Boss.length; i++) {
  5591. var model = Laya.loader.getRes(ResourcesPath.Boss[i]);
  5592. AssetManager.Instance.Boss.set(i + 1, model);
  5593. Laya.loader.clearRes(ResourcesPath.Boss[i]);
  5594. }
  5595. console.log("boss模型资源加载完毕---");
  5596. this.LoadCap();
  5597. }));
  5598. }
  5599. LoadCap() {
  5600. var path = [];
  5601. for (let i = 0; i < ResourcesPath.Cap.length; i++) {
  5602. path.push(ResourcesPath.Cap[i]);
  5603. }
  5604. Laya.loader.create(path, Laya.Handler.create(this, () => {
  5605. for (let i = 0; i < ResourcesPath.Cap.length; i++) {
  5606. var model = Laya.loader.getRes(ResourcesPath.Cap[i]);
  5607. AssetManager.Instance.Cap.set(i + 1, model);
  5608. Laya.loader.clearRes(ResourcesPath.Cap[i]);
  5609. }
  5610. console.log("帽子模型资源加载完毕---");
  5611. this.LoadProp();
  5612. }));
  5613. }
  5614. LoadProp() {
  5615. Laya.loader.create(ResourcesPath.Prop, Laya.Handler.create(this, this.LoadResources));
  5616. }
  5617. LoadResources(_prop) {
  5618. var Prop = _prop.getChildByName("Prop");
  5619. for (let i = 0; i < Prop.numChildren; i++) {
  5620. var model = Prop.getChildAt(i);
  5621. model.active = false;
  5622. AssetManager.Instance.Prop.set(i + 1, model);
  5623. }
  5624. var Plane = _prop.getChildByName("plane");
  5625. AssetManager.Instance.Plane.set(1, Plane);
  5626. var smallfence = _prop.getChildByName("small_fence");
  5627. AssetManager.Instance.Small_Fence.set(1, smallfence);
  5628. var Tree = _prop.getChildByName("Tree");
  5629. for (let i = 0; i < Tree.numChildren; i++) {
  5630. var tree = Tree.getChildAt(i);
  5631. tree.active = false;
  5632. AssetManager.Instance.Tree.set(i + 1, tree);
  5633. }
  5634. Laya.loader.clearRes(ResourcesPath.Prop);
  5635. console.log("道具资源加载完毕---");
  5636. this.complete();
  5637. }
  5638. }
  5639. class Main$1 {
  5640. constructor() {
  5641. if (CheckMain.Creat)
  5642. return;
  5643. CheckMain.Creat = true;
  5644. if (window["Laya3D"])
  5645. Laya3D.init(GameConfig.width, GameConfig.height);
  5646. else
  5647. Laya.init(GameConfig.width, GameConfig.height, Laya["WebGL"]);
  5648. Laya["Physics"] && Laya["Physics"].enable();
  5649. Laya["DebugPanel"] && Laya["DebugPanel"].enable();
  5650. Laya.stage.scaleMode = GameConfig.scaleMode;
  5651. Laya.stage.screenMode = GameConfig.screenMode;
  5652. Laya.stage.alignV = GameConfig.alignV;
  5653. Laya.stage.alignH = GameConfig.alignH;
  5654. Laya.URL.exportSceneToJson = GameConfig.exportSceneToJson;
  5655. if (GameConfig.debug || Laya.Utils.getQueryString("debug") == "true")
  5656. Laya.enableDebugPanel();
  5657. if (GameConfig.physicsDebug && Laya["PhysicsDebugDraw"])
  5658. Laya["PhysicsDebugDraw"].enable();
  5659. if (GameConfig.stat)
  5660. Laya.Stat.show();
  5661. Laya.alertGlobalError = true;
  5662. if (Laya.Browser.onWeiXin) {
  5663. Laya.Browser.window.wx.showShareMenu({
  5664. withShareTicket: true
  5665. });
  5666. Laya.Browser.window.wx.onShareAppMessage(function () {
  5667. return {
  5668. title: "有人@你,一起骑马仗箭走天涯",
  5669. imageUrl: "Game/res/textrue/share.jpg",
  5670. };
  5671. });
  5672. Laya.Browser.window.wx.onShow((option) => {
  5673. var shareTicket = option.shareTicket;
  5674. var userId = option.query.userId;
  5675. var shareTitle = option.query.shareTitle;
  5676. var scenevalue = Laya.LocalStorage.getItem("SceneValue");
  5677. if (scenevalue) {
  5678. Main$1.SceneNum = scenevalue;
  5679. }
  5680. else {
  5681. Laya.LocalStorage.setItem("SceneValue", option.scene);
  5682. Main$1.SceneNum = option.scene;
  5683. }
  5684. WXSDK.querychannel = option.query.channel;
  5685. WXSDK.shareOpenId = option.query.userId;
  5686. console.log("scene:", option.scene);
  5687. if (WXSDK.querychannel != null) {
  5688. console.log("onShow channel is:", WXSDK.querychannel);
  5689. }
  5690. if (option.referrerInfo) {
  5691. WXSDK.referrerInfoappId = option.referrerInfo.appId;
  5692. console.log("onShow appId is:", option.referrerInfo.appId);
  5693. }
  5694. });
  5695. if (!Laya.Browser.onWeiXin)
  5696. return;
  5697. const updateManager = Laya.Browser.window.wx.getUpdateManager();
  5698. updateManager.onCheckForUpdate(function (res) {
  5699. console.log("最新版本:" + res.hasUpdate);
  5700. });
  5701. updateManager.onUpdateReady(function () {
  5702. Laya.Browser.window.wx.showModal({
  5703. showCancel: false,
  5704. title: '更新提示',
  5705. content: '新版本已经准备好,是否重启应用?',
  5706. success(res) {
  5707. updateManager.applyUpdate();
  5708. },
  5709. fail(res) {
  5710. updateManager.applyUpdate();
  5711. }
  5712. });
  5713. });
  5714. }
  5715. Laya.ResourceVersion.enable("version.json", Laya.Handler.create(this, this.onVersionLoaded), Laya.ResourceVersion.FILENAME_VERSION);
  5716. }
  5717. onVersionLoaded() {
  5718. Laya.AtlasInfoManager.enable("fileconfig.json", Laya.Handler.create(this, this.onConfigLoaded));
  5719. }
  5720. onConfigLoaded() {
  5721. new LoadView();
  5722. }
  5723. }
  5724. Main$1.Ver = "1.0.0";
  5725. Main$1.CFG = "123";
  5726. new Main$1();
  5727. exports.Main = Main$1;
  5728. return exports;
  5729. }({}));
  5730. //# sourceMappingURL=bundle.js.map