123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775 |
- var laya = (function (exports) {
- 'use strict';
- class ResDic {
- constructor() {
- this._container = {};
- this._length = 0;
- }
- get container() {
- return this._container;
- }
- get size() {
- return this._length;
- }
- set(key, value) {
- if (!this._container.hasOwnProperty(key)) {
- this._length++;
- }
- this._container[key] = value;
- }
- has(key) {
- return this._container.hasOwnProperty(key) ? true : false;
- }
- get(key) {
- if (this._container.hasOwnProperty(key)) {
- return this._container[key];
- }
- else {
- return undefined;
- }
- }
- delete(key) {
- if (this._container.hasOwnProperty(key)) {
- delete this._container[key];
- this._length--;
- }
- }
- clear() {
- this._container = {};
- this._length = 0;
- }
- }
- var EventState;
- (function (EventState) {
- EventState[EventState["LoadComplete"] = 0] = "LoadComplete";
- EventState[EventState["SceneInit"] = 1] = "SceneInit";
- EventState[EventState["StageInit"] = 2] = "StageInit";
- EventState[EventState["StageCreateComplete"] = 3] = "StageCreateComplete";
- EventState[EventState["AnimatorEnd"] = 4] = "AnimatorEnd";
- EventState[EventState["Select"] = 5] = "Select";
- })(EventState || (EventState = {}));
- var StageState;
- (function (StageState) {
- StageState[StageState["Win"] = 0] = "Win";
- StageState[StageState["Lose"] = 1] = "Lose";
- StageState[StageState["Start"] = 2] = "Start";
- StageState[StageState["StageCreateComPlete"] = 3] = "StageCreateComPlete";
- StageState[StageState["Over"] = 4] = "Over";
- StageState[StageState["Shoot"] = 5] = "Shoot";
- StageState[StageState["CreatArrow"] = 6] = "CreatArrow";
- StageState[StageState["Revive"] = 7] = "Revive";
- StageState[StageState["Restart"] = 8] = "Restart";
- StageState[StageState["Press"] = 9] = "Press";
- StageState[StageState["UnPress"] = 10] = "UnPress";
- })(StageState || (StageState = {}));
- class EventManager {
- static EventOn(_mode, caller, fun, args = []) {
- EventManager.instance.on(EventState[_mode], caller, fun, args);
- }
- static EventOff(_mode, caller, fun, args = []) {
- EventManager.instance.off(EventState[_mode], caller, fun);
- }
- static EventTrigger(_mode, args = []) {
- EventManager.instance.event(EventState[_mode], args);
- }
- static StageOn(_mode, caller, fun, args = []) {
- EventManager.instance.on(StageState[_mode], caller, fun, args);
- }
- static StageOff(_mode, caller, fun, args = []) {
- EventManager.instance.off(StageState[_mode], caller, fun);
- }
- static StageTrigger(_mode, args = []) {
- EventManager.instance.event(StageState[_mode], args);
- }
- }
- EventManager.instance = new Laya.EventDispatcher();
- class AssetManager {
- constructor() {
- this.Boss = new ResDic();
- this.Player = new ResDic();
- this.Horse = new ResDic();
- this.Cap = new ResDic();
- this.Prop = new ResDic();
- this.Plane = new ResDic();
- this.Stone = new ResDic();
- this.Tree = new ResDic();
- this.Small_Fence = new ResDic();
- AssetManager.ins = this;
- EventManager.EventOn(EventState.LoadComplete, this, this.Init);
- }
- static get Instance() {
- if (AssetManager.ins) {
- return AssetManager.ins;
- }
- else {
- return new AssetManager();
- }
- }
- Init() {
- this.maincamera = this.mainscene.getChildByName("Main Camera");
- this.maincamera.transform.position = new Laya.Vector3(0, 10, -12);
- this.maincamera.transform.rotationEuler = new Laya.Vector3(-35.7, 180, 0);
- this.maincamera.enableHDR = false;
- this.Light = this.mainscene.getChildByName("Directional light");
- this.Light.intensity = 0.7;
- EventManager.EventTrigger(EventState.SceneInit);
- }
- }
- class ResourcesPath {
- }
- ResourcesPath.MainScene = "Game/res/MainScene/LayaScene_Mainscene/Conventional/Mainscene.ls";
- ResourcesPath.Boss = [
- "Game/res/Role/LayaScene_Role/Conventional/boss.lh"
- ];
- ResourcesPath.Player = [
- "Game/res/Role/LayaScene_Role/Conventional/player.lh"
- ];
- ResourcesPath.Horse = [
- "Game/res/Horse/LayaScene_Horse/Conventional/horse1.lh",
- "Game/res/Horse/LayaScene_Horse/Conventional/horse2.lh",
- "Game/res/Horse/LayaScene_Horse/Conventional/horse3.lh",
- "Game/res/Horse/LayaScene_Horse/Conventional/horse4.lh",
- "Game/res/Horse/LayaScene_Horse/Conventional/horse5.lh"
- ];
- ResourcesPath.Cap = [
- "Game/res/Cap/LayaScene_Cap/Conventional/cap1.lh",
- "Game/res/Cap/LayaScene_Cap/Conventional/cap2.lh",
- "Game/res/Cap/LayaScene_Cap/Conventional/cap3.lh",
- "Game/res/Cap/LayaScene_Cap/Conventional/cap4.lh",
- "Game/res/Cap/LayaScene_Cap/Conventional/cap5.lh"
- ];
- ResourcesPath.Prop = "Game/res/Prop/LayaScene_Prop/Conventional/Prop.lh";
- var Sprite3D = Laya.Sprite3D;
- var Vector3 = Laya.Vector3;
- class modelConfig {
- constructor(model) {
- this.modelcur = model;
- this.modelPos = model.transform.position.clone();
- this.modelRot = model.transform.rotation.clone();
- this.modelSca = model.transform.scale.clone();
- }
- }
- class GamePool {
- constructor() {
- this.modelpool = {};
- this.maxAcount = 30;
- GamePool.Ins = this;
- }
- static get Instance() {
- if (GamePool.Ins) {
- return GamePool.Ins;
- }
- else {
- return new GamePool();
- }
- }
- GetModel(_model, title) {
- var poolname = title + _model.name;
- if (this.modelpool[poolname] != null && this.modelpool[poolname] != undefined) {
- if (this.modelpool[poolname].length > 0) {
- var model1 = this.modelpool[poolname][0];
- this.modelpool[poolname].splice(0, 1);
- if (model1.modelcur.destroyed) {
- model1.modelcur = Sprite3D.instantiate(_model);
- if (!model1.modelcur.active) {
- model1.modelcur.active = true;
- }
- }
- model1.modelcur.active = true;
- model1.modelcur.transform.position = _model.transform.position.clone();
- model1.modelcur.transform.rotation = _model.transform.rotation.clone();
- model1.modelcur.transform.scale = _model.transform.scale.clone();
- return model1.modelcur;
- }
- else {
- var model = Sprite3D.instantiate(_model);
- model.active = true;
- return model;
- }
- }
- else {
- var model = Sprite3D.instantiate(_model);
- model.active = true;
- return model;
- }
- }
- RecoveryModel(model, title = "", modelstate = false) {
- if (model.destroyed) {
- return;
- }
- if (!modelstate && model.active == false) {
- return;
- }
- var poolname = title + model.name;
- if (this.modelpool[poolname] != null && this.modelpool[poolname] != undefined) {
- var modelnum = this.modelpool[poolname];
- if (modelnum.length > this.maxAcount) {
- model.destroy();
- return;
- }
- else {
- modelnum.push(new modelConfig(model));
- }
- }
- else {
- modelnum = [];
- modelnum.push(new modelConfig(model));
- this.modelpool[poolname] = modelnum;
- }
- model.transform.position = new Vector3(0, 0, -10000);
- model.removeSelf();
- model.active = false;
- }
- ResetsModelPool() {
- for (var Key in this.modelpool) {
- var model = this.modelpool[Key];
- for (var i = 0; i < model.length; i++) {
- model[i].modelcur.destroy();
- }
- }
- this.modelpool = {};
- }
- }
- var Vector3$1 = Laya.Vector3;
- class Transform3DHelper {
- static getForward(transform) {
- let forward = new Vector3$1();
- transform.getForward(forward);
- Laya.Vector3.scale(forward, -1, forward);
- Laya.Vector3.normalize(forward, forward);
- return forward;
- }
- }
- class GameTools {
- constructor() {
- GameTools.ins = this;
- }
- static get Instance() {
- if (GameTools.ins) {
- return GameTools.ins;
- }
- else {
- return new GameTools();
- }
- }
- lerp(form, to, t) {
- if (t <= 0) {
- return form;
- }
- else if (t >= 1) {
- return to;
- }
- var a = t * to + (1 - t) * form;
- return a;
- }
- SetCollider(setNode, CollisionGroup) {
- var numchild = setNode.numChildren;
- for (var i = 0; i < setNode.numChildren; i++) {
- var numchild2 = setNode.getChildAt(i).numChildren;
- if (numchild2 > 1) {
- this.SetCollider(setNode.getChildAt(i), CollisionGroup);
- }
- var physicsCollider = setNode.getChildAt(i).getComponent(Laya.PhysicsCollider);
- if (physicsCollider) {
- physicsCollider.collisionGroup = CollisionGroup;
- }
- }
- }
- EnemySetCollider(setNode, collisionGroup) {
- var collider = setNode.getChildByName("npcfrontcollider");
- var collider2 = setNode.getChildByName("npcrearcollider");
- var physicsCollider = collider.getComponent(Laya.PhysicsCollider);
- var physicsCollider2 = collider2.getComponent(Laya.PhysicsCollider);
- if (physicsCollider) {
- physicsCollider.collisionGroup = collisionGroup;
- }
- if (physicsCollider2) {
- physicsCollider2.collisionGroup = collisionGroup;
- }
- }
- PlayerSetCollider(setNode, collisionGroup) {
- var collider = setNode.getChildByName("playercollider");
- var physicsCollider = collider.getComponent(Laya.PhysicsCollider);
- if (physicsCollider) {
- physicsCollider.collisionGroup = collisionGroup;
- }
- }
- HostageSetCollider(setNode, collisionGroup) {
- var collider = setNode.getChildByName("hostagecollider");
- var physicsCollider = collider.getComponent(Laya.PhysicsCollider);
- if (physicsCollider) {
- physicsCollider.collisionGroup = collisionGroup;
- }
- }
- static RandomNumber(from, to) {
- if (from >= to) {
- return 0;
- }
- var size = to - from;
- var curNumber = Math.random() * size + from;
- return curNumber;
- }
- static RandomANumber(from, to) {
- if (from >= to) {
- return 0;
- }
- var size = to - from;
- var curNumber = Math.random() * size + from;
- return Math.floor(curNumber);
- }
- static GetMoney(_num, _pos = null, _completeHandle = null) {
- if (_num == 0)
- return;
- var fafaafsfa = new Laya.Box;
- fafaafsfa.width = 400;
- fafaafsfa.height = 100;
- fafaafsfa.pivotX = fafaafsfa.width / 2;
- fafaafsfa.pivotY = fafaafsfa.height / 2;
- if (_pos == null) {
- _pos = new Laya.Vector2(Laya.stage.width / 2, Laya.stage.height / 2);
- }
- fafaafsfa.pos(_pos.x, _pos.y);
- var aafafaffa = new Laya.Image;
- aafafaffa.skin = "game/qiandao_1_7.png";
- aafafaffa.width = 60;
- aafafaffa.height = 60;
- aafafaffa.left = 50;
- aafafaffa.y = 10;
- fafaafsfa.addChild(aafafaffa);
- var faasfafsafs = new Laya.Text;
- faasfafsafs.width = 300;
- faasfafsafs.height = 50;
- faasfafsafs.align = "center";
- faasfafsafs.valign = "middle";
- faasfafsafs.font = "Microsoft YaHei";
- faasfafsafs.fontSize = 40;
- faasfafsafs.color = "#FFFFFF";
- faasfafsafs.bold = true;
- faasfafsafs.font = "Microsoft YaHei";
- faasfafsafs.text = "金币 +" + _num;
- faasfafsafs.x = 60;
- faasfafsafs.y = 10;
- fafaafsfa.addChild(faasfafsafs);
- Laya.stage.addChild(fafaafsfa);
- var faasfsaf = Laya.Tween.to(fafaafsfa, { y: fafaafsfa.y - 200 }, 1500, Laya.Ease.expoInOut, Laya.Handler.create(this, () => {
- faasfsaf.clear();
- fafaafsfa.destroy();
- if (_completeHandle) {
- _completeHandle.run();
- }
- }), 100);
- }
- static TweenText(faafssfafsa, _hight, _completeHandle = null, hide = true, _duration = 500) {
- var afasafsafsfa = new Laya.Text();
- afasafsafsfa.width = faafssfafsa.size.x;
- afasafsafsfa.height = faafssfafsa.size.y;
- afasafsafsfa.align = "center";
- afasafsafsfa.valign = "middle";
- afasafsafsfa.font = "Microsoft YaHei";
- afasafsafsfa.fontSize = faafssfafsa.fontSize;
- afasafsafsfa.pivotX = afasafsafsfa.width / 2;
- afasafsafsfa.pivotY = afasafsafsfa.height / 2;
- afasafsafsfa.color = "#5ad122";
- afasafsafsfa.bold = true;
- afasafsafsfa.stroke = 5;
- afasafsafsfa.strokeColor = "#ffffff";
- if (faafssfafsa.color) {
- faafssfafsa.color = faafssfafsa.color;
- }
- afasafsafsfa.text = faafssfafsa.message;
- afasafsafsfa.zOrder = 1;
- Laya.stage.addChildAt(afasafsafsfa, Laya.stage.numChildren - 1);
- afasafsafsfa.pos(faafssfafsa.pos.x, faafssfafsa.pos.y);
- var tween = Laya.Tween.to(afasafsafsfa, { y: afasafsafsfa.y - _hight, update: new Laya.Handler(this, function () {
- }) }, _duration, Laya.Ease.expoInOut, Laya.Handler.create(this, function () {
- tween.clear();
- if (hide) {
- afasafsafsfa.destroy();
- }
- if (_completeHandle) {
- _completeHandle.run();
- }
- }));
- if (hide) {
- Laya.Tween.to(afasafsafsfa, { alpha: 0.4 }, 500);
- }
- return afasafsafsfa;
- }
- static StationTweenText(faafssfafsa, _hight, _completeHandle = null, hide = true, _duration = 500) {
- var afasafsafsfa = new Laya.Text();
- afasafsafsfa.width = faafssfafsa.size.x;
- afasafsafsfa.height = faafssfafsa.size.y;
- afasafsafsfa.align = "center";
- afasafsafsfa.valign = "middle";
- afasafsafsfa.font = "Microsoft YaHei";
- afasafsafsfa.fontSize = 50;
- afasafsafsfa.pivotX = afasafsafsfa.width / 2;
- afasafsafsfa.pivotY = afasafsafsfa.height / 2;
- afasafsafsfa.color = "#5ad122";
- afasafsafsfa.bold = true;
- afasafsafsfa.stroke = 5;
- afasafsafsfa.strokeColor = "#ffffff";
- if (faafssfafsa.color) {
- faafssfafsa.color = faafssfafsa.color;
- }
- afasafsafsfa.text = faafssfafsa.message;
- afasafsafsfa.zOrder = 1;
- Laya.stage.addChildAt(afasafsafsfa, Laya.stage.numChildren - 1);
- afasafsafsfa.pos(faafssfafsa.pos.x, faafssfafsa.pos.y);
- var tween = Laya.Tween.to(afasafsafsfa, { y: afasafsafsfa.y - _hight, update: new Laya.Handler(this, function () {
- }) }, _duration, Laya.Ease.expoInOut, Laya.Handler.create(this, function () {
- tween.clear();
- if (hide) {
- afasafsafsfa.destroy();
- }
- if (_completeHandle) {
- _completeHandle.run();
- }
- }));
- if (hide) {
- Laya.Tween.to(afasafsafsfa, { alpha: 0.4 }, 10000);
- }
- return afasafsafsfa;
- }
- static tweenMove(transform, targPos, delay, ease, complete) {
- let curPos = transform.position.clone();
- return Laya.Tween.to(curPos, {
- x: targPos.x,
- y: targPos.y,
- z: targPos.z,
- update: new Laya.Handler(this, () => {
- transform.position = curPos.clone();
- })
- }, delay, ease, complete);
- }
- static tweenRotate(transform, targEuler, delay, ease, complete) {
- let curEuler = transform.rotationEuler.clone();
- return Laya.Tween.to(curEuler, {
- x: targEuler.x,
- y: targEuler.y,
- z: targEuler.z,
- update: new Laya.Handler(this, () => {
- transform.rotationEuler = curEuler.clone();
- })
- }, delay, ease, complete);
- }
- }
- var AccountUser;
- (function (AccountUser) {
- AccountUser[AccountUser["buyed_kun"] = 0] = "buyed_kun";
- AccountUser[AccountUser["diamond"] = 1] = "diamond";
- AccountUser[AccountUser["equip_themes"] = 2] = "equip_themes";
- AccountUser[AccountUser["favorite_times"] = 3] = "favorite_times";
- AccountUser[AccountUser["game_times"] = 4] = "game_times";
- AccountUser[AccountUser["get_themes"] = 5] = "get_themes";
- AccountUser[AccountUser["list_kun"] = 6] = "list_kun";
- AccountUser[AccountUser["moeny"] = 7] = "moeny";
- AccountUser[AccountUser["progress_themes"] = 8] = "progress_themes";
- AccountUser[AccountUser["revival"] = 9] = "revival";
- AccountUser[AccountUser["stage"] = 10] = "stage";
- })(AccountUser || (AccountUser = {}));
- class PlayerData {
- constructor(_token, _config, _appSetting, _user, _userbase, _useInvite, _user_stage = null, _user_sign, _user_achievement, lottery) {
- this.openid = "";
- this.userId = "";
- this.zhengshu = _token;
- this.netzheshe = _appSetting;
- this.account = _user;
- this.accountssss = _userbase;
- this.qiandao = _user_sign;
- this.renwu = _user_achievement;
- this.userId = this.account["user_id"];
- this.openid = this.accountssss["openid"];
- this.m_invite = _useInvite;
- this.lottery = lottery;
- console.log("user_id:" + this.userId);
- }
- GainCollocation(_type) {
- return this.peizhis[_type];
- }
- GainAccount(_type) {
- return this.account[_type];
- }
- get fenxiang() {
- return this.netzheshe["share"] == "1";
- }
- get Invincible() {
- return Number(this.netzheshe["Invincible"]);
- }
- get CheckScene() {
- return this.netzheshe["checkscene"] == "1";
- }
- get Cheat() {
- return this.netzheshe["cheat"] == "1";
- }
- get Banner() {
- return this.netzheshe["Banner"] == "1";
- }
- get wudaoshijian() {
- return Number(this.netzheshe["wudaoshijian"]);
- }
- GetUser(_type) {
- var type = AccountUser[_type];
- return this.account[type];
- }
- get NpcRunDistance() {
- return Number(this.netzheshe["NpcRunDistance"]);
- }
- get NpcAtkDistance() {
- return Number(this.netzheshe["NpcAtkDistance"]);
- }
- get NpcChaseDistance() {
- return Number(this.netzheshe["NpcChaseDistance"]);
- }
- get NpcRushDistance() {
- return Number(this.netzheshe["NpcRushDistance"]);
- }
- get BossAtkInterval() {
- return Number(this.netzheshe["BossAtkInterval"]);
- }
- get NpcSpeed() {
- return Number(this.netzheshe["NpcSpeed"]);
- }
- get HostageSpeed() {
- return Number(this.netzheshe["HostageSpeed"]);
- }
- get ArrowSpeed() {
- return Number(this.netzheshe["ArrowSpeed"]);
- }
- get BossDistance() {
- return Number(this.netzheshe["ArrowSpeed"]);
- }
- get BossSpeed() {
- return Number(this.netzheshe["BossSpeed"]);
- }
- get PlayerDamage() {
- return Number(this.netzheshe["PlayerDamage"]);
- }
- get MaxBossDistance() {
- return Number(this.netzheshe["MaxBossDistance"]);
- }
- get MinBossDistance() {
- return Number(this.netzheshe["MinBossDistance"]);
- }
- get ShareContent() {
- return this.netzheshe["sharecontent"];
- }
- get DirRoatationLerp() {
- return Number(this.netzheshe["DirRoatationLerp"]);
- }
- get DirMoveLerp() {
- return Number(this.netzheshe["DirMoveLerp"]);
- }
- get CurTouchsmoothness() {
- return Number(this.netzheshe["curtouchsmoothness"]);
- }
- get CurTouchsize() {
- return Number(this.netzheshe["curtouchsize"]);
- }
- get NPCRushSpeed() {
- return Number(this.netzheshe["NPCRushSpeed"]);
- }
- get Range() {
- return Number(this.netzheshe["Range"]);
- }
- get CanStageShake() {
- return this.netzheshe["canstageshake"] == "1";
- }
- GlobalData(_key) {
- var dataarray = [];
- var _global = this.GainCollocation("global");
- for (var key in _global) {
- dataarray.push(_global[key]);
- }
- for (let i = 0; i < dataarray.length; i++) {
- if (_key == dataarray[i].key) {
- return Number(dataarray[i].value);
- }
- }
- }
- HasEquip(_id) {
- var data = this.GainAccount("get_themes");
- for (var i = 0; i < data.length; i++) {
- var hd = data[i];
- if (_id == hd) {
- return true;
- }
- }
- return false;
- }
- GetProgress(_id) {
- var config = this.account["progress_themes"];
- var progress = config[_id] ? config[_id] : 0;
- return progress;
- }
- }
- class CheckMain {
- }
- CheckMain.Creat = false;
- CheckMain.ZSSdkCreat = false;
- class FengXiang {
- constructor() {
- FengXiang.instance = this;
- }
- static get Instance() {
- if (FengXiang.instance == null) {
- FengXiang.instance = new FengXiang();
- }
- return FengXiang.instance;
- }
- ;
- kaishifengxiang(callBack) {
- FengXiang.kaishifengxiangshijian = new Date().getTime();
- FengXiang.fengxiangzhong = true;
- FengXiang.callback = callBack;
- }
- RegFenxiang() {
- if (Laya.Browser.window.wx == null) {
- return;
- }
- Laya.Browser.window.wx.onShow(function (option) {
- if (FengXiang.fengxiangzhong) {
- FengXiang.fengxiangzhong = false;
- let time = new Date().getTime();
- let wait = (time - FengXiang.kaishifengxiangshijian) / 1000;
- let shareSuccess = false;
- if (wait >= 4) {
- if (wait < 6) {
- shareSuccess = (Math.random() > 0.7) ? false : true;
- }
- else {
- shareSuccess = true;
- }
- }
- else {
- shareSuccess = false;
- }
- if (shareSuccess == false) {
- Laya.Browser.window.wx.showToast({ title: "请重试一次" });
- FengXiang.callback(false);
- }
- else {
- Laya.Browser.window.wx.showToast({ title: "分享成功" });
- FengXiang.callback(true);
- }
- }
- });
- }
- }
- FengXiang.fengxiangchenggongshijian = 0;
- FengXiang.fengxiangzhong = false;
- class WXSDK {
- constructor() {
- WXSDK.ins = this;
- }
- static get Instance() {
- if (WXSDK.ins) {
- return WXSDK.ins;
- }
- else {
- return new WXSDK();
- }
- }
- static Init() {
- }
- static DengLu(_complete) {
- var that = this;
- Laya.Browser.window.wx.login({
- success: function (res) {
- if (res.code) {
- FengXiang.Instance.RegFenxiang();
- console.log("微信登陆成功----");
- that.codeValue = res.code;
- console.log("shareid:" + WXSDK.shareOpenId);
- new AccountManager(res.code, "", "", "", 0, "", "", "", "", WXSDK.shareOpenId, WXSDK.shareOpenId, Main.Ver);
- _complete(res);
- }
- else {
- WXSDK.DengLu(WXSDK.DengLu);
- console.log('wx no code' + res.errMsg);
- }
- },
- fail: function (res) { console.log("wx.login: failed, res=" + res); }
- });
- }
- static ShowTxt(text) {
- if (Laya.Browser.onWeiXin) {
- Laya.Browser.window.wx.showToast({ title: text });
- }
- else {
- console.log(text);
- }
- }
- static OnShow(cb) {
- if (!Laya.Browser.onWeiXin)
- return;
- Laya.Browser.window.wx.onShow(cb);
- }
- static OffShow(cb) {
- if (!Laya.Browser.onWeiXin)
- return;
- Laya.Browser.window.wx.offShow(cb);
- }
- static ShortShake() {
- Laya.Browser.window.wx.vibrateShort({});
- }
- static LongShake() {
- Laya.Browser.window.wx.vibrateLong({});
- }
- static Shake(_short = true) {
- if (Laya.Browser.onWeiXin && WXSDK.shake) {
- if (_short) {
- this.ShortShake();
- }
- else {
- this.LongShake();
- }
- }
- }
- static LoadSubPackage(name, _complete) {
- if (Laya.Browser.onWeiXin) {
- const loadTask = Laya.Browser.window.wx.loadSubpackage({
- name: 'Game',
- success: function (res) {
- _complete && _complete(true);
- console.log("分包加载成功");
- },
- fail: function (res) {
- _complete && _complete(false);
- console.log("分包加载失败");
- }
- });
- }
- else {
- console.log("未进行分包加载");
- _complete && _complete(true);
- }
- }
- static stageShake(callBack = null, speed = 32) {
- if (this.isShake || !this.canshakestage)
- return;
- this.isShake = true;
- var point = new Laya.Vector2(Laya.stage.x, Laya.stage.y);
- Laya.stage.timerLoop(speed, this, this.shakeObject, [point, callBack]);
- }
- static shakeObject(_point, _callBack) {
- var count = (this.num++) % 4;
- this.offsetArr[this.num % 2] = count < 2 ? 0 : this.offset;
- Laya.stage.x = this.offsetArr[0] + _point.x;
- Laya.stage.y = this.offsetArr[1] + _point.y;
- if (this.num > (this.times * 4 + 1)) {
- Laya.stage.clearTimer(this, this.shakeObject);
- Laya.stage.pos(0, 0);
- this.num = 0;
- this.isShake = false;
- if (_callBack != null) {
- _callBack();
- }
- }
- }
- static UpdateGuide(ShowGuide = 0) {
- var kvDataList = new Array();
- let date = new Date().getTime();
- var myValue = JSON.stringify({
- "guide": {
- "ShowGuide": ShowGuide,
- "update_time": date.toString()
- }
- });
- kvDataList.push({ key: "ShowGuide", value: myValue });
- if (Laya.Browser.window.wx) {
- Laya.Browser.window.wx.setUserCloudStorage({
- KVDataList: kvDataList,
- success: r => {
- console.log("KVDATALIST---", kvDataList);
- console.log("上传新手指引成功:" + ShowGuide);
- }
- });
- }
- }
- static UpdateScore(max_score) {
- var kvDataList = new Array();
- let date = new Date().getTime();
- var myValue = JSON.stringify({
- "wxgame": {
- "max_score": max_score,
- "update_time": date.toString(),
- }
- });
- kvDataList.push({ key: "max_score", value: myValue });
- if (Laya.Browser.window.wx) {
- Laya.Browser.window.wx.setUserCloudStorage({
- KVDataList: kvDataList,
- success: r => {
- console.log("KVDATALIST---", kvDataList);
- console.log("上传分数成功:" + max_score);
- }
- });
- }
- }
- static fengxiangtupian(callback) {
- if (Laya.Browser.window.wx == null) {
- return;
- }
- var _title = "有人@你,一起骑马仗箭走天涯";
- var t = AccountManager.Instance.ServerTime;
- Laya.Browser.window.wx.aldShareAppMessage({
- title: _title,
- imageUrl: "Game/res/textrue/share.jpg",
- query: "userId=" + AccountManager.Instance.curplayerData.userId + "_" + t + "_" + Math.floor(9999 * Math.random()).toString()
- });
- }
- static ShareContent() {
- return AccountManager.Instance.curplayerData.ShareContent;
- }
- static AldEvent(eventName, key = "用户id", value = "") {
- if (!Laya.Browser.onWeiXin)
- return;
- Laya.Browser.window.wx.aldSendEvent(eventName, { key: value });
- }
- static AldStart(stageId) {
- if (!Laya.Browser.onWeiXin)
- return;
- Laya.Browser.window.wx.aldStage.onStart({
- stageId: stageId,
- stageName: "第" + stageId + "关",
- });
- }
- static AldEnd(stageId, isComplete) {
- if (!Laya.Browser.onWeiXin)
- return;
- let event = isComplete ? "complete" : "fail";
- let desc = isComplete ? "关卡完成" : "关卡失败";
- Laya.Browser.window.wx.aldStage.onEnd({
- stageId: stageId,
- stageName: "第" + stageId + "关",
- event: event,
- params: {
- desc: desc
- }
- });
- }
- }
- WXSDK.codeValue = "";
- WXSDK.shareOpenId = "";
- WXSDK.openId = 0;
- WXSDK.shareScene = "";
- WXSDK.uid = "123";
- WXSDK.querychannel = "";
- WXSDK.referrerInfoappId = "";
- WXSDK.shake = true;
- WXSDK.times = 1.3;
- WXSDK.num = 0;
- WXSDK.offsetArr = [0, 0];
- WXSDK.offset = 14;
- WXSDK.canshakestage = false;
- var REG = Laya.ClassUtils.regClass;
- var ui;
- (function (ui) {
- class CompleteViewUI extends Laya.Scene {
- constructor() { super(); }
- createChildren() {
- super.createChildren();
- this.createView(CompleteViewUI.uiView);
- }
- }
- 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": [] };
- ui.CompleteViewUI = CompleteViewUI;
- REG("ui.CompleteViewUI", CompleteViewUI);
- class ExportViewUI extends Laya.Scene {
- constructor() { super(); }
- createChildren() {
- super.createChildren();
- this.createView(ExportViewUI.uiView);
- }
- }
- 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": [] };
- ui.ExportViewUI = ExportViewUI;
- REG("ui.ExportViewUI", ExportViewUI);
- class InGameViewUI extends Laya.Scene {
- constructor() { super(); }
- createChildren() {
- super.createChildren();
- this.createView(InGameViewUI.uiView);
- }
- }
- 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": [] };
- ui.InGameViewUI = InGameViewUI;
- REG("ui.InGameViewUI", InGameViewUI);
- class LoadViewUI extends Laya.Scene {
- constructor() { super(); }
- createChildren() {
- super.createChildren();
- this.createView(LoadViewUI.uiView);
- }
- }
- 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": [] };
- ui.LoadViewUI = LoadViewUI;
- REG("ui.LoadViewUI", LoadViewUI);
- class MainGameViewUI extends Laya.Scene {
- constructor() { super(); }
- createChildren() {
- super.createChildren();
- this.createView(MainGameViewUI.uiView);
- }
- }
- 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": [] };
- ui.MainGameViewUI = MainGameViewUI;
- REG("ui.MainGameViewUI", MainGameViewUI);
- class SkinViewUI extends Laya.Scene {
- constructor() { super(); }
- createChildren() {
- super.createChildren();
- this.createView(SkinViewUI.uiView);
- }
- }
- 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": [] };
- ui.SkinViewUI = SkinViewUI;
- REG("ui.SkinViewUI", SkinViewUI);
- class TrialViewUI extends Laya.Scene {
- constructor() { super(); }
- createChildren() {
- super.createChildren();
- this.createView(TrialViewUI.uiView);
- }
- }
- 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": [] };
- ui.TrialViewUI = TrialViewUI;
- REG("ui.TrialViewUI", TrialViewUI);
- })(ui || (ui = {}));
- var MusicType;
- (function (MusicType) {
- MusicType[MusicType["click"] = 0] = "click";
- MusicType[MusicType["hit"] = 1] = "hit";
- MusicType[MusicType["shoot"] = 2] = "shoot";
- MusicType[MusicType["OpenView"] = 3] = "OpenView";
- MusicType[MusicType["Lose"] = 4] = "Lose";
- MusicType[MusicType["Win"] = 5] = "Win";
- MusicType[MusicType["die"] = 6] = "die";
- })(MusicType || (MusicType = {}));
- var BGMType;
- (function (BGMType) {
- BGMType[BGMType["BGM"] = 0] = "BGM";
- })(BGMType || (BGMType = {}));
- class AudioManager {
- constructor() { }
- static musicres(_type) {
- return "Game/res/music/" + MusicType[_type] + ".mp3";
- }
- static bgmres(_type) {
- return "Game/res/music/" + BGMType[_type] + ".mp3";
- }
- static playMusic(_type) {
- if (!this.open)
- return;
- Laya.SoundManager.playSound(this.musicres(_type));
- }
- static StopMusic() {
- Laya.SoundManager.stopMusic();
- }
- static PlayBGM(_type) {
- if (!this.open)
- return;
- Laya.SoundManager.playMusic(this.bgmres(_type), 0);
- }
- }
- AudioManager.open = true;
- class MainGameView extends ui.MainGameViewUI {
- constructor() {
- super();
- MainGameView.ins = this;
- }
- static get Instance() {
- if (MainGameView.ins) {
- return MainGameView.ins;
- }
- else {
- return new MainGameView();
- }
- }
- Show() {
- WXSDK.AldEvent("打开主界面");
- AudioManager.PlayBGM(BGMType.BGM);
- this.BaoKuan.visible = false;
- this.StartBtn.clickHandler = Laya.Handler.create(this, this.ClickStart);
- this.SkinBtn.clickHandler = Laya.Handler.create(this, this.ClickSkin);
- this.MoreFunBtn.clickHandler = new Laya.Handler(this, this.ClickMoreFun);
- this.BaoKuanBtn.clickHandler = new Laya.Handler(this, this.OpenChouTi);
- this.goaltext = this.GoalProgress.getChildByName("goal");
- this.goaltext.text = GameManager.Instance.KillNum.toString();
- this.GoldNum.text = AccountManager.Instance.curplayerData.GainAccount("money");
- this.LevelNum.text = AccountManager.Instance.curplayerData.GainAccount("stage");
- this.SoundBox.on(Laya.Event.CLICK, this, this.ClickSound);
- this.sound = this.SoundBox.getChildByName("sound");
- this.shake = this.SoundBox.getChildByName("shake");
- this.sound.visible = AudioManager.open;
- this.shake.visible = WXSDK.shake;
- this.SetData();
- this.SetTopAd();
- this.height = Laya.stage.height;
- Laya.stage.on(Laya.Event.RESIZE, this, () => {
- this.height = Laya.stage.height;
- });
- }
- Close() {
- Laya.stage.off(Laya.Event.MOUSE_DOWN, this, this.ClickStart);
- }
- ClickStart() {
- let stage = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
- if (stage > 2) {
- AudioManager.playMusic(MusicType.click);
- ViewManager.Instance.ShowView(ViewType.TrialView);
- }
- else {
- var agrs = [{ "t": AccountManager.Instance.ServerTime.toString() }];
- ServerManager.Instance.SendHttp(ArcherWorrior.KaiShi, agrs, Laya.Handler.create(this, this.GameStart), null);
- }
- }
- ClickSkin() {
- AudioManager.playMusic(MusicType.click);
- ViewManager.Instance.ShowView(ViewType.ShopView);
- }
- ClickMoreFun() {
- ViewManager.Instance.OpenPopView(ViewType.ExportView);
- }
- ClickSound() {
- if (this.sound.visible) {
- this.sound.visible = false;
- this.shake.visible = true;
- AudioManager.open = false;
- WXSDK.shake = true;
- AudioManager.StopMusic();
- console.log("关闭声音,打开震动---");
- }
- else {
- this.sound.visible = true;
- this.shake.visible = false;
- AudioManager.open = true;
- WXSDK.shake = true;
- AudioManager.PlayBGM(BGMType.BGM);
- console.log("打开声音,关闭震动");
- }
- }
- GameStart(_data) {
- let stage = AccountManager.Instance.curplayerData.GainAccount("stage");
- WXSDK.AldStart(stage);
- AudioManager.playMusic(MusicType.click);
- this.play_id = _data.play_id;
- EventManager.StageTrigger(StageState.Start);
- ViewManager.Instance.ShowView(ViewType.IngameView);
- }
- OpenChouTi() {
- this.BaoKuanBtn.visible = false;
- this.BaoKuan.visible = true;
- this.CloseBaoKuan.clickHandler = Laya.Handler.create(this, this.CloseChouTi);
- this.chouti.play(null, false);
- this.InitAd();
- }
- CloseChouTi() {
- this.BaoKuan.visible = false;
- this.BaoKuanBtn.visible = true;
- this.CloseBaoKuan.clickHandler = null;
- }
- InitAd() {
- SDKZS.SetHuTuiList(this.BaoKuanList, 1, "");
- this.GunGun2();
- }
- GunGun2() {
- this.BaoKuanList.scrollBar.value = 0;
- var maxTop = this.BaoKuanList.scrollBar.max;
- var tempTop = 1;
- Laya.timer.frameLoop(1, this, () => {
- this.BaoKuanList.scrollBar.value += tempTop;
- if (this.BaoKuanList.scrollBar.value >= maxTop || this.BaoKuanList.scrollBar.value <= 0) {
- tempTop = -tempTop;
- }
- });
- }
- SetData() {
- SDKZS.SetHuTuiList(this.BottomList, 2, "");
- this.GunGun();
- }
- GunGun() {
- var maxBtm;
- try {
- this.BottomList.scrollBar.value = 0;
- maxBtm = this.BottomList.scrollBar.max;
- }
- catch (error) {
- console.error(error);
- return;
- }
- var tempBtm = 1;
- Laya.timer.frameLoop(1, this, () => {
- this.BottomList.scrollBar.value += tempBtm;
- if (this.BottomList.scrollBar.value >= maxBtm || this.BottomList.scrollBar.value <= 0) {
- tempBtm = -tempBtm;
- }
- });
- }
- SetTopAd() {
- this.topAdData = SDKZS.data.promotion || [];
- this.LeftPushIcon.visible = this.RightPushIcon.visible = this.topAdData.length >= 2;
- if (this.topAdData.length < 2)
- return;
- this.topLeftAdIndex = { index: 0 };
- this.topRightAdIndex = { index: 1 };
- this._setTopAd(this.LeftPushIcon, this.topLeftAdIndex);
- this._setTopAd(this.RightPushIcon, this.topRightAdIndex);
- }
- _setTopAd(topAd, adIndex) {
- let _icon = topAd.getChildByName("icon");
- let _name = topAd.getChildByName("name");
- topAd.clickHandler = new Laya.Handler(this, () => {
- SDKZS.navigate2Mini(this.topAdData[adIndex.index]);
- });
- this._setIcon(_icon, _name, adIndex);
- Laya.timer.loop(5000, this, () => {
- this._setIcon(_icon, _name, adIndex);
- this.lefticon.play(null, false);
- this.righticon.play(null, false);
- });
- }
- _setIcon(_icon, _name, adIndex) {
- adIndex.index = (adIndex.index + 2) % this.topAdData.length;
- _icon.skin = this.topAdData[adIndex.index].app_icon;
- _name.text = this.topAdData[adIndex.index].app_title;
- }
- }
- class DataManager {
- constructor() {
- DataManager.ins = this;
- }
- static get Instance() {
- if (DataManager.ins) {
- return DataManager.ins;
- }
- else {
- return new DataManager();
- }
- }
- }
- DataManager.DoorArray = [];
- var Sprite3D$1 = Laya.Sprite3D;
- var Vector3$2 = Laya.Vector3;
- class Prop {
- constructor(_id) {
- this.id = _id;
- }
- }
- class Plane {
- constructor(_index, _id, pos, data, proppos, propoffest) {
- this.things = [];
- this.thinghight = 0;
- this.thingwight = 0;
- this.index = _index;
- this.planeid = _id;
- this.position = pos;
- this.GetProp(data, proppos, propoffest);
- }
- GetProp(data, pos, offset) {
- var config = AccountManager.Instance.curplayerData.GainCollocation("things");
- var datas = data.split(";");
- var poss = pos.split(";");
- var offestX = offset.split(";");
- for (var i = 0; i < datas.length; i++) {
- if (datas[i] == "0")
- continue;
- var prop = new Prop(Number(datas[i]));
- var configid = prop.id - 1;
- var curconfig = config[configid.toString()];
- var ps = (i <= poss.length - 1) ? Number(poss[i]) : this.long;
- var hs = (i <= poss.length - 1) ? Number(offestX[i]) : this.long;
- prop.pos = new Vector3$2(this.position.x, this.position.y, this.position.z + ps);
- prop.type = Number(curconfig.type);
- this.things.push(prop);
- }
- }
- }
- class Grade {
- constructor(_index, _id) {
- this.startpoint = new Vector3$2(0, 0, 0);
- this.planes = [];
- this.scencerys = [];
- this.MaxLength = 0;
- this.MaxHight = 0;
- this.fencearray = [];
- this.fencepos = 0;
- this.fencepos2 = 0;
- this.fencenum = 0;
- this.fenceleftpos = 0;
- this.fencerightpos = 0;
- this.creat = false;
- this.floorarray = [];
- this.floornum = 0;
- this.floorpos = 0;
- this.treenum = 0;
- this.treepos = 0;
- this.treepos2 = 0;
- this.creatnum = 0;
- this.index = _index;
- this.gradeid = _id;
- }
- Init() {
- this.GetPlane();
- this.endpointpoint = new Vector3$2(0, this.MaxHight, this.MaxLength);
- }
- GetPlane() {
- var config = AccountManager.Instance.curplayerData.GainCollocation("road");
- for (var key in config) {
- if (Number(config[key].road_id) == this.gradeid) {
- var planedata = config[key];
- var long = Number(planedata.long);
- var posz = this.startpoint.z;
- var roadid = Number(planedata.street);
- var planepos = new Vector3$2(9 - (roadid * 1.65), 0, posz);
- var plane = new Plane(Number(planedata.street), Number(planedata.road_id), planepos, planedata.things, planedata.position, planedata.offset);
- plane.long = Number(planedata.long);
- this.MaxHight = (plane.thinghight) < this.MaxHight ? plane.thinghight : this.MaxHight;
- if (long != 0) {
- this.MaxLength = posz + long > this.MaxLength ? posz + long : this.MaxLength;
- }
- this.planes.push(plane);
- }
- }
- }
- Clear() {
- for (var j = 0; j < this.planes.length; j++) {
- var model = this.planes[j].model;
- if (model && model.active && !model.destroyed) {
- GamePool.Instance.RecoveryModel(model);
- }
- this.planes[j].model = null;
- var things = this.planes[j].things;
- for (var k = 0; k < things.length; k++) {
- model = things[k].model;
- if (model && model.active && !model.destroyed)
- GamePool.Instance.RecoveryModel(model);
- things[k].model = null;
- }
- }
- for (var i = 0; i < this.scencerys.length; i++) {
- var scencery = this.scencerys[i];
- if (scencery && scencery.active && !scencery.destroyed)
- GamePool.Instance.RecoveryModel(scencery);
- this.scencerys[i] = null;
- }
- this.scencerys.splice(0, this.scencerys.length);
- for (let k = 0; k < this.fencearray.length; k++) {
- var _fence = this.fencearray[k];
- if (_fence && _fence.active && !_fence.destroyed)
- GamePool.Instance.RecoveryModel(_fence);
- this.fencearray[k] = null;
- }
- this.fencearray.splice(0, this.fencearray.length);
- if (this.spr)
- this.spr.destroy();
- }
- Creat(_stage = null, _id) {
- if (_stage == null)
- _stage = StageControl.Instance.curstage;
- this.spr = new Sprite3D$1();
- for (var j = 0; j < this.planes.length; j++) {
- var plane = this.planes[j];
- if (plane.long > 0) {
- var res = AssetManager.Instance.Plane.get(1);
- plane.model = GamePool.Instance.GetModel(res, "");
- this.spr.addChild(plane.model);
- plane.model.transform.position = plane.position;
- plane.model.transform.scale = new Laya.Vector3(plane.model.transform.scale.x, plane.model.transform.scale.y, plane.long);
- GameTools.Instance.SetCollider(plane.model, 100);
- var things = plane.things;
- for (var k = 0; k < things.length; k++) {
- var thingdata = things[k];
- var tre = AssetManager.Instance.Prop.get(thingdata.id);
- thingdata.model = GamePool.Instance.GetModel(tre, "");
- if (thingdata.id == 1) {
- DataManager.DoorArray.push(thingdata.model);
- }
- if (thingdata.id == 13) {
- GameManager.Instance.CreatEnemy(thingdata.model);
- }
- else if (thingdata.id == 14) {
- GameManager.Instance.CreatChaseCharacter(thingdata.model);
- }
- else {
- GameTools.Instance.SetCollider(thingdata.model, 100);
- }
- this.spr.addChild(thingdata.model);
- thingdata.model.transform.position = thingdata.pos;
- }
- }
- else {
- if (plane.things.length > 0) {
- for (var k = 0; k < plane.things.length; k++) {
- var thingdata = plane.things[k];
- var tre = AssetManager.Instance.Prop.get(thingdata.id);
- thingdata.model = GamePool.Instance.GetModel(tre, "");
- GameTools.Instance.SetCollider(thingdata.model, 100);
- this.spr.addChild(thingdata.model);
- thingdata.model.transform.position = thingdata.pos;
- }
- }
- }
- AssetManager.Instance.mainscene.addChild(this.spr);
- }
- }
- }
- class GK {
- constructor(_id) {
- this.curgrades = [];
- this.ChooseGrade = [];
- this.Id = Number(_id);
- this.scenery = GameTools.RandomANumber(1, 5);
- this.GetGrade();
- }
- GetGrade() {
- var config = AccountManager.Instance.curplayerData.GainCollocation("mission");
- var gradedatas = config[this.Id - 1].roads.split(";");
- var roadnum = Number(config[this.Id - 1].road_num);
- this.mainrolespeed = Number(config[this.Id - 1].PlayerSpeed);
- this.npcspeed = Number(config[this.Id - 1].NpcSpeed);
- this.hostspeed = Number(config[this.Id - 1].HostageSpeed);
- this.BossHp = Number(config[this.Id - 1].boss_HP);
- this.Goal = Number(config[this.Id - 1].goal);
- this.Modulus = Number(config[this.Id - 1].modulus);
- this.isboss = Number(config[this.Id - 1].boss);
- let GradeArray = [];
- let num = 0;
- if (this.Id > 2) {
- while (num == 0) {
- var random = GameTools.RandomANumber(0, gradedatas.length);
- var value = Number(gradedatas[random]);
- gradedatas.splice(random, 1);
- GradeArray.push(value);
- if (GradeArray.length == roadnum) {
- num = 1;
- }
- }
- var endpos = new Vector3$2();
- for (var i = 0; i < GradeArray.length; i++) {
- var gradeid = Number(GradeArray[i]);
- var grade = new Grade(i, gradeid);
- if (i > 0)
- grade.startpoint = endpos;
- grade.Init();
- endpos = grade.endpointpoint;
- this.curgrades.push(grade);
- }
- this.endposition = endpos;
- this.ChooseGrade = GradeArray;
- }
- else {
- var endpos = new Vector3$2();
- for (var i = 0; i < gradedatas.length; i++) {
- var gradeid = Number(gradedatas[i]);
- var grade = new Grade(i, gradeid);
- if (i > 0)
- grade.startpoint = endpos;
- grade.Init();
- endpos = grade.endpointpoint;
- this.curgrades.push(grade);
- }
- this.endposition = endpos;
- }
- console.log("GradeArray -- ", GradeArray.length);
- }
- }
- var Vector3$3 = Laya.Vector3;
- class StageControl {
- constructor() {
- this.floorarray = [];
- this.treearray = [];
- this.fencearray = [];
- this.num = 1;
- this.curstagedic = {};
- StageControl.ins = this;
- EventManager.EventOn(EventState.SceneInit, this, this.StageInit);
- EventManager.StageOn(StageState.Restart, this, this.RessetStage);
- }
- static get Instance() {
- if (StageControl.ins) {
- return StageControl.ins;
- }
- else {
- return new StageControl();
- }
- }
- StageInit() {
- var config = AccountManager.Instance.curplayerData.GainCollocation("mission");
- for (var index in config) {
- var data = config[index];
- var gk = new GK(data.id);
- this.curstagedic[gk.Id] = gk;
- }
- EventManager.EventTrigger(EventState.StageInit);
- }
- RessetStage() {
- GameManager.Instance.KillNum = 0;
- GameManager.Instance.ReviveNum = 1;
- GameManager.Instance.fenceleftpos = 0;
- GameManager.Instance.fencerightpos = 0;
- GameManager.Instance.treeleftpos = 0;
- GameManager.Instance.treerightpos = 0;
- GameManager.Instance.GuideKill = 0;
- if (this.curstage)
- this.ClearStageResources();
- var level = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
- this.curstage = this.CreatStage(level);
- console.log("本关卡为---", this.curstage.Id);
- for (let i = 0; i < this.curstage.ChooseGrade.length; i++) {
- console.log("选中路段为---", this.curstage.ChooseGrade[i]);
- }
- EventManager.EventTrigger(EventState.StageCreateComplete);
- }
- ClearStageResources() {
- var stage = this.curstage;
- console.log("舞台id为:--------", this.curstage.Id);
- for (let j = 0; j < this.floorarray.length; j++) {
- let floor = this.floorarray[j];
- if (floor && floor.active && !floor.destroyed) {
- GamePool.Instance.RecoveryModel(floor);
- }
- this.floorarray[j] = null;
- }
- this.floorarray.slice(0, this.floorarray.length);
- for (let k = 0; k < this.treearray.length; k++) {
- let tree = this.treearray[k];
- if (tree && tree.active && !tree.destroyed) {
- GamePool.Instance.RecoveryModel(tree);
- }
- this.treearray[k] = null;
- }
- this.treearray.splice(0, this.treearray.length);
- for (let l = 0; l < this.fencearray.length; l++) {
- let fence = this.fencearray[l];
- if (fence && fence.active && !fence.destroyed) {
- GamePool.Instance.RecoveryModel(fence);
- }
- this.fencearray[l] = null;
- }
- this.fencearray.splice(0, this.fencearray.length);
- for (var i = 0; i < stage.curgrades.length; i++) {
- stage.curgrades[i].Clear();
- }
- GameManager.Instance.RecoveryCharacter();
- }
- CreatStage(_id) {
- var stage = this.curstagedic[_id];
- if (!stage) {
- var config = AccountManager.Instance.curplayerData.GainCollocation("road");
- var from = Math.floor(config.length * 0.8);
- stage = this.curstagedic[GameTools.RandomANumber(from, config.length - 1)];
- stage.Id = _id;
- }
- this.CreatStageResources(stage, _id);
- return stage;
- }
- CreatStageResources(_stage, _id) {
- for (var i = 0; i < _stage.curgrades.length; i++) {
- _stage.curgrades[i].Creat(_stage, _id);
- }
- let stage = StageControl.Instance.curstagedic[_id];
- let floornum = Math.floor(stage.endposition.z * 1.65 / 8.23) + 13;
- let floorpos = -8.24;
- for (let i = 0; i < floornum; i++) {
- var _floor = GamePool.Instance.GetModel(AssetManager.Instance.Prop.get(19), "");
- if (i > 0) {
- _floor.transform.position = new Vector3$3(0, -0.5, floorpos);
- floorpos += 8.24;
- }
- else {
- _floor.transform.position = new Vector3$3(0, -0.5, -16.48);
- }
- AssetManager.Instance.mainscene.addChild(_floor);
- this.floorarray.push(_floor);
- this.LastGround = _floor.transform.position.z;
- }
- let planearray = [];
- for (let i = 0; i < StageControl.Instance.curstagedic[_id].curgrades[0].planes.length; i++) {
- if (StageControl.Instance.curstagedic[_id].curgrades[0].planes[i].long > 0) {
- planearray.push(StageControl.Instance.curstagedic[_id].curgrades[0].planes[i]);
- }
- }
- let first_plane = planearray[0].index;
- let last_plane = planearray[planearray.length - 1].index;
- let fenceLeft = (9 - (first_plane * 1.65)) + 1;
- GameManager.Instance.fenceleftpos = fenceLeft;
- let fenceRight = (9 - (last_plane * 1.65)) - 1;
- GameManager.Instance.fencerightpos = fenceRight;
- let treeLeft = (9 - (first_plane * 1.65)) + 5;
- GameManager.Instance.treeleftpos = treeLeft;
- let treeRight = (9 - (last_plane * 1.65)) - 4;
- GameManager.Instance.treerightpos = treeRight;
- let fencepos = -13.35;
- let fencenum = _stage.endposition.z + 60;
- for (let i = 0; i < fencenum; i++) {
- var _fence = GamePool.Instance.GetModel(AssetManager.Instance.Small_Fence.get(1), "");
- if (i > 0) {
- _fence.transform.position = new Vector3$3(fenceLeft, 0, fencepos);
- }
- else {
- _fence.transform.position = new Vector3$3(fenceLeft, 0, -15);
- }
- _fence.transform.rotationEuler = new Vector3$3(0, -90, 0);
- AssetManager.Instance.mainscene.addChild(_fence);
- GameTools.Instance.SetCollider(_fence, 100);
- this.fencearray.push(_fence);
- var _fence2 = GamePool.Instance.GetModel(AssetManager.Instance.Small_Fence.get(1), "");
- if (i > 0) {
- _fence2.transform.position = new Vector3$3(fenceRight, 0, fencepos);
- }
- else {
- _fence2.transform.position = new Vector3$3(fenceRight, 0, -15);
- }
- _fence2.transform.rotationEuler = new Vector3$3(fenceRight, 90, 0);
- fencepos += 1.65;
- AssetManager.Instance.mainscene.addChild(_fence2);
- GameTools.Instance.SetCollider(_fence2, 100);
- this.fencearray.push(_fence2);
- }
- let treepos = 0;
- let treenum = _stage.endposition.z * 1.65 / 5 + 65;
- for (let i = 0; i < treenum; i++) {
- var _random = GameTools.RandomANumber(1, 5);
- var tree = GamePool.Instance.GetModel(AssetManager.Instance.Tree.get(_random), "");
- if (i > 0) {
- tree.transform.position = new Vector3$3(treeLeft, 0, treepos);
- }
- else {
- tree.transform.position = new Vector3$3(treeLeft, 0, -20);
- }
- AssetManager.Instance.mainscene.addChild(tree);
- this.treearray.push(tree);
- var _random2 = GameTools.RandomANumber(1, 5);
- var tree2 = GamePool.Instance.GetModel(AssetManager.Instance.Tree.get(_random2), "");
- if (i > 0) {
- tree2.transform.position = new Vector3$3(treeRight, 0, treepos);
- }
- else {
- tree2.transform.position = new Vector3$3(treeRight, 0, -20);
- }
- AssetManager.Instance.mainscene.addChild(tree2);
- this.treearray.push(tree2);
- treepos += 3;
- }
- let STAGE = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
- let boss = _stage.isboss == 1 ? true : false;
- if (boss) {
- let EndZ = _stage.curgrades[_stage.curgrades.length - 1].endpointpoint.z * 1.2;
- let EndX = GameTools.RandomANumber(-2, 2);
- GameManager.Instance.CreatBoss(new Vector3$3(EndX, 0, EndZ));
- }
- }
- CreatGround(num) {
- var startZ = this.LastGround;
- var floorarr = [];
- for (let i = 0; i < num; i++) {
- var floor = GamePool.Instance.GetModel(AssetManager.Instance.Prop.get(19), "");
- if (i > 0) {
- floor.transform.position = new Vector3$3(0, -0.5, startZ);
- }
- else {
- floor.transform.position = new Vector3$3(0, -0.5, startZ);
- }
- AssetManager.Instance.mainscene.addChild(floor);
- this.floorarray.push(floor);
- floorarr.push(floor);
- startZ += 8.24;
- }
- this.LastGround = startZ;
- var first = floorarr[0].transform.position.z;
- var last = floorarr[floorarr.length - 1].transform.position.z;
- this.CreatFence(first, last);
- this.CreatTree(first, last);
- }
- CreatFence(_start, _end) {
- var Fir = _start;
- var End_Fence = this.curstage.curgrades[this.curstage.curgrades.length - 1].fencearray;
- let fencenum = Math.floor((_end - _start) / 1.65) + 8;
- for (let i = 0; i < fencenum; i++) {
- var _fence = GamePool.Instance.GetModel(AssetManager.Instance.Small_Fence.get(1), "");
- if (i > 0) {
- _fence.transform.position = new Vector3$3(GameManager.Instance.fenceleftpos, 0, Fir);
- }
- else {
- _fence.transform.position = new Vector3$3(GameManager.Instance.fenceleftpos, 0, Fir - 8.3);
- }
- AssetManager.Instance.mainscene.addChild(_fence);
- End_Fence.push(_fence);
- var _fence2 = GamePool.Instance.GetModel(AssetManager.Instance.Small_Fence.get(1), "");
- if (i > 0) {
- _fence2.transform.position = new Vector3$3(GameManager.Instance.fencerightpos, 0, Fir);
- }
- else {
- _fence2.transform.position = new Vector3$3(GameManager.Instance.fencerightpos, 0, Fir - 8.3);
- }
- AssetManager.Instance.mainscene.addChild(_fence2);
- End_Fence.push(_fence2);
- Fir += 1.65;
- }
- }
- CreatTree(_start, _end) {
- var End_Fence = this.curstage.curgrades[this.curstage.curgrades.length - 1].scencerys;
- let treenum = Math.floor((_end - _start) / 3) + 1;
- for (let i = 0; i < treenum; i++) {
- let _random = GameTools.RandomANumber(1, 5);
- var _tree = GamePool.Instance.GetModel(AssetManager.Instance.Tree.get(_random), "");
- _tree.transform.position = new Vector3$3(GameManager.Instance.treeleftpos, 0, _start);
- AssetManager.Instance.mainscene.addChild(_tree);
- End_Fence.push(_tree);
- var _tree2 = GamePool.Instance.GetModel(AssetManager.Instance.Tree.get(_random), "");
- _tree2.transform.position = new Vector3$3(GameManager.Instance.treerightpos, 0, _start);
- AssetManager.Instance.mainscene.addChild(_tree2);
- End_Fence.push(_tree2);
- _start += 3;
- }
- }
- }
- class InGameView extends ui.InGameViewUI {
- constructor() {
- super();
- InGameView.ins = this;
- }
- static get Instance() {
- if (InGameView.ins) {
- return InGameView.ins;
- }
- else {
- return new InGameView();
- }
- }
- Show() {
- WXSDK.AldEvent("进入游戏内界面");
- let stage = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
- if (stage == 1) {
- this.Guide1.visible = true;
- this.ani1.play(0, true);
- this.Guide2.visible = false;
- this.Guide3.visible = false;
- this.Guide4.visible = false;
- }
- else if (stage == 2) {
- this.Guide1.visible = false;
- this.Guide2.visible = false;
- this.Guide3.visible = false;
- this.Guide4.visible = false;
- }
- else {
- this.Guide1.visible = false;
- this.Guide2.visible = false;
- this.Guide3.visible = false;
- this.Guide4.visible = false;
- }
- this.GoldNum.text = AccountManager.Instance.curplayerData.GainAccount("money");
- this.goaltext = this.GoalProgress.getChildByName("goal");
- this.SetData();
- this.InitUI();
- this.height = Laya.stage.height;
- Laya.stage.on(Laya.Event.RESIZE, this, () => {
- this.height = Laya.stage.height;
- });
- }
- Close() {
- }
- InitUI() {
- this.goaltext.text = GameManager.Instance.KillNum.toString();
- this.GoalProgress.value = GameManager.Instance.KillNum / StageControl.Instance.curstage.Goal;
- }
- SetData() {
- SDKZS.SetHuTuiList(this.BottomList, 2, "");
- this.GunGun();
- }
- GunGun() {
- var maxBtm;
- try {
- this.BottomList.scrollBar.value = 0;
- maxBtm = this.BottomList.scrollBar.max;
- }
- catch (error) {
- console.error(error);
- return;
- }
- var tempBtm = 1;
- Laya.timer.frameLoop(1, this, () => {
- this.BottomList.scrollBar.value += tempBtm;
- if (this.BottomList.scrollBar.value >= maxBtm || this.BottomList.scrollBar.value <= 0) {
- tempBtm = -tempBtm;
- }
- });
- }
- }
- class GuangGao {
- constructor() {
- this.isVideoLoadCom = false;
- GuangGao.ins = this;
- }
- static get Instance() {
- if (GuangGao.ins) {
- return GuangGao.ins;
- }
- else {
- return new GuangGao();
- }
- }
- static InitId() {
- }
- static JiaZaiShiPin() {
- if (this.afsfsaafsfsa)
- return;
- if (!Laya.Browser.onWeiXin)
- return;
- this.fsaasfafssfa = Laya.Browser.window.wx.createRewardedVideoAd({ adUnitId: this.videlAdUnitId });
- this.fsaasfafssfa.onLoad(() => {
- console.log('激励视频 广告加载成功');
- this.asfasfsaffsa = true;
- });
- this.fsaasfafssfa.onError(err => {
- console.log("激励视屏加载失败:" + err);
- this.asfasfsaffsa = false;
- });
- this.afsfasfasasf = 0;
- this.afsfsaafsfsa = true;
- }
- static fassfafasafs(callback) {
- this.fsaasfafssfa.offClose();
- this.fsaasfafssfa.onClose(res => {
- console.log("激励视频关闭:" + res.isEnded);
- if (res && res.isEnded || res === undefined) {
- callback && callback(true);
- }
- else {
- callback && callback(false);
- }
- this.fsaasfafssfa.offClose();
- });
- }
- showBanner(success = null, fail = null) {
- if (!Laya.Browser.onWeiXin)
- return;
- let ad = GuangGao.bannerAdUnitId;
- let bannerAd = Laya.Browser.window.wx.createBannerAd({
- adUnitId: ad,
- style: {
- left: 0,
- top: 0,
- width: 460
- }
- });
- bannerAd.onLoad(() => {
- console.log("[LOG] Banner广告加载成功");
- this.hideBanner();
- this._bannerAd = bannerAd;
- let info = Laya.Browser.window.wx.getSystemInfoSync();
- this._bannerAd.style.width = info.windowWidth;
- this._bannerAd.style.top = info.windowHeight - this._bannerAd.style.realHeight - 20;
- this._bannerAd.show();
- success && success(this._bannerAd);
- });
- bannerAd.onError(err => {
- console.log("[LOG] Banner广告加载失败");
- console.log(err);
- fail && fail();
- });
- }
- hideBanner() {
- if (!Laya.Browser.onWeiXin)
- return;
- if (this._bannerAd) {
- this._bannerAd.hide();
- this._bannerAd.destroy();
- this._bannerAd = null;
- }
- }
- static OpenBanner(gap = 0, callVack = null, iswait = false) {
- if (!Laya.Browser.onWeiXin)
- return;
- if (this.afsfasfasasf >= 10000) {
- var hh = this.gasagsgasgsa(gap);
- if (iswait) {
- this.asgagassga.hide();
- Laya.timer.once(AccountManager.Instance.curplayerData.wudaoshijian * 1000, this, () => {
- if (callVack != null) {
- callVack(hh);
- }
- this.asgagassga.show();
- });
- }
- else {
- if (callVack != null) {
- callVack(hh);
- }
- this.asgagassga.show();
- }
- }
- else {
- var idd = this.bannerAdUnitId;
- console.log("adUnitId:" + idd);
- let newBanner = Laya.Browser.window.wx.createBannerAd({
- adUnitId: idd,
- style: {
- left: 0,
- top: 0,
- width: 460
- }
- });
- newBanner.onError(err => {
- console.log("没有拉到banner--");
- console.log(err);
- newBanner = Laya.Browser.window.wx.createBannerAd({
- adUnitId: idd,
- style: {
- left: 0,
- top: 0,
- width: 460
- }
- });
- this.gasagsgasgsa(gap);
- });
- newBanner.onLoad(() => {
- this.afsfasfasasf++;
- if (this.asgagassga)
- this.asgagassga.destroy();
- this.asgagassga = newBanner;
- var hight = this.gasagsgasgsa(gap);
- if (iswait) {
- this.asgagassga.hide();
- Laya.timer.once(AccountManager.Instance.curplayerData.wudaoshijian * 1000, this, () => {
- if (callVack != null) {
- callVack(hight);
- }
- this.asgagassga.show();
- });
- }
- else {
- if (callVack != null) {
- callVack(hight);
- }
- this.asgagassga.show();
- }
- });
- }
- }
- static gasagsgasgsa(gap) {
- if (this.asgagassga) {
- let info = Laya.Browser.window.wx.getSystemInfoSync();
- this.asgagassga.style.width = info.windowWidth;
- this.asgagassga.style.top = info.windowHeight - this.asgagassga.style.realHeight - gap - 20;
- return Laya.stage.height / info.windowHeight * this.asgagassga.style.realHeight;
- }
- }
- static Clear() {
- Laya.timer.clearAll(this);
- if (!Laya.Browser.onWeiXin)
- return;
- if (this.asgagassga)
- this.asgagassga.hide();
- }
- static agagsagags() {
- if (!Laya.Browser.onWeiXin)
- return;
- if (this.asgagassga)
- this.asgagassga.hide();
- }
- static gasagsasg() {
- if (!Laya.Browser.onWeiXin)
- return;
- if (this.asgagassga)
- this.asgagassga.show();
- }
- static get keyiwudao() {
- var wudao = AccountManager.Instance.curplayerData.Cheat;
- if (wudao == false) {
- console.log("cheat:" + wudao);
- return false;
- }
- if (Main.SceneNum == "1037" || Main.SceneNum == "1058"
- || Main.SceneNum == "1067" || Main.SceneNum == "1095") {
- console.log("cheat:true-> " + Main.SceneNum);
- return true;
- }
- else {
- var checkscence = AccountManager.Instance.curplayerData.CheckScene;
- if (checkscence == false) {
- console.log("cheat:true->checkscence: " + checkscence);
- return true;
- }
- }
- console.log("cheat:false-> " + Main.SceneNum);
- return false;
- }
- static WudaoAnNiu(btn, ShowBanner = true, complete = null, gap = 0) {
- if (AccountManager.Instance.curplayerData.Banner) {
- GuangGao.agagsagags();
- if (GuangGao.keyiwudao == false) {
- btn.bottom = 350;
- GuangGao.OpenBanner();
- }
- else {
- if (ShowBanner) {
- btn.bottom = 100;
- btn.mouseEnabled = false;
- console.log("bottom:100");
- GuangGao.OpenBanner(gap, (height) => {
- if (height == null) {
- console.log("展示互推位");
- var end = Laya.stage.height - height - btn.height;
- btn.y = end;
- btn.bottom = NaN;
- }
- else {
- var end = Laya.stage.height - height - btn.height;
- btn.y = end - 100;
- btn.bottom = NaN;
- console.log("y:" + end);
- }
- }, true);
- Laya.timer.once(AccountManager.Instance.curplayerData.wudaoshijian * 1000, this, () => {
- btn.mouseEnabled = true;
- if (complete != null) {
- complete();
- }
- });
- }
- else {
- if (complete != null) {
- complete();
- }
- }
- }
- }
- }
- loadVideo(cb) {
- if (!Laya.Browser.onWeiXin) {
- if (cb)
- cb(true);
- return;
- }
- this._onLoadVideo = cb;
- if (!this._rewardedVideoAd) {
- let index = GuangGao.videlAdUnitId;
- this._rewardedVideoAd = Laya.Browser.window.wx.createRewardedVideoAd({ adUnitId: index });
- var isc = false;
- this._rewardedVideoAd.onLoad(() => {
- console.log("[LOG] 激励视频广告加载成功");
- this.isVideoLoadCom = true;
- if (isc)
- return;
- isc = true;
- this._onLoadVideo && this._onLoadVideo(true);
- this._onLoadVideo = null;
- });
- this._rewardedVideoAd.onError(err => {
- console.log("[LOG] 激励视频广告加载失败");
- console.log(err);
- this.isVideoLoadCom = false;
- this._onLoadVideo && this._onLoadVideo(false);
- this._onLoadVideo = null;
- });
- this._rewardedVideoAd.onClose(res => {
- if (!res || res.isEnded) {
- this._onVideoClose && this._onVideoClose(true);
- this._onVideoClose = null;
- }
- else {
- this._onVideoClose && this._onVideoClose(false);
- this._onVideoClose = null;
- }
- });
- }
- else {
- if (this.isVideoLoadCom) {
- this._onLoadVideo && this._onLoadVideo(true);
- this._onLoadVideo = null;
- }
- else {
- this._onLoadVideo && this._onLoadVideo(false);
- this._onLoadVideo = null;
- }
- }
- }
- showVideo(cb) {
- if (!Laya.Browser.onWeiXin) {
- if (cb)
- cb(true);
- return;
- }
- this._onVideoClose = cb;
- this._rewardedVideoAd.show().catch(err => {
- this._rewardedVideoAd.load().then(() => {
- this._rewardedVideoAd.show();
- });
- });
- }
- }
- GuangGao.videlAdUnitId = "adunit-40ac03a5538e8de0";
- GuangGao.bannerAdUnitId = "adunit-dc3e1cfa3ac69be3";
- GuangGao.afsfsaafsfsa = false;
- GuangGao.asfasfsaffsa = false;
- GuangGao.afsfasfasasf = 0;
- class ShopItem extends Laya.Script {
- constructor() {
- super();
- this.use = false;
- ShopItem.ins = this;
- }
- static get Instance() {
- if (ShopItem.ins) {
- return ShopItem.ins;
- }
- else {
- return new ShopItem();
- }
- }
- onAwake() {
- this.selfobj = this.owner;
- this._select = this.selfobj.getChildByName("choose");
- this._skin = this.selfobj.getChildByName("icon");
- this.using = this.selfobj.getChildByName("used");
- this.click1_btn = this.selfobj.getChildByName("btn");
- this.click1_btn.clickHandler = new Laya.Handler(this, this._ClickHander);
- EventManager.EventOn(EventState.Select, this, this.ShowSelect);
- }
- RefreshItem(any, comeType) {
- this.comeType = comeType;
- if (any)
- this.instance = any;
- else
- this.instance = ShopView.Instance;
- this._data = (this.selfobj.dataSource);
- var _id = this._data.id;
- var usingId = AccountManager.Instance.curplayerData.GetUser(AccountUser.equip_themes)["1"];
- var usingId2 = AccountManager.Instance.curplayerData.GetUser(AccountUser.equip_themes)["2"];
- var hasequip = AccountManager.Instance.curplayerData.HasEquip(_id);
- var require_type = this._data.require_type;
- this._skin.skin = "Game/res/Skin/" + this._data.icon + ".png";
- this._skin.rotation = 0;
- if (usingId == _id || usingId2 == _id) {
- this.skinGetForType = SkinGetForType.Using;
- this.showui();
- return;
- }
- if (hasequip) {
- this.skinGetForType = SkinGetForType.Geted;
- this.showui();
- return;
- }
- if (require_type == 2) {
- this.skinGetForType = SkinGetForType.Bycoin;
- this.showui();
- return;
- }
- if (require_type == 4) {
- this.skinGetForType = SkinGetForType.GetByActivity;
- this.showui();
- return;
- }
- if (require_type == 3) {
- this.skinGetForType = SkinGetForType.GetByVideo;
- this.showui();
- return;
- }
- }
- showui() {
- var type = this.skinGetForType;
- if (this._data.id == 1 || this._data.id == 50) {
- this._select.visible = true;
- }
- else {
- this._select.visible = false;
- }
- if (this.skinGetForType == SkinGetForType.Using) {
- this.using.visible = true;
- }
- else {
- this.using.visible = false;
- }
- }
- ShowUi() {
- var type = this.skinGetForType;
- this._select.visible = type == SkinGetForType.Using;
- if (this.skinGetForType == SkinGetForType.Using) {
- this.using.visible = true;
- }
- else {
- this.using.visible = false;
- }
- }
- _ClickHander() {
- this.instance._data = this._data;
- ShopView.Instance.RefreshButton(this.skinGetForType);
- this.instance.showroleId = this._data.id;
- this.ShowUi();
- this.ShowModel();
- }
- ShowModel() {
- EventManager.EventTrigger(EventState.Select);
- }
- ShowSelect() {
- if (!this._data) {
- return;
- }
- this._select.visible = this.instance.showroleId == this._data.id;
- }
- }
- var SkinGetForType;
- (function (SkinGetForType) {
- SkinGetForType[SkinGetForType["Geted"] = 1] = "Geted";
- SkinGetForType[SkinGetForType["Bycoin"] = 2] = "Bycoin";
- SkinGetForType[SkinGetForType["GetByVideo"] = 3] = "GetByVideo";
- SkinGetForType[SkinGetForType["GetByActivity"] = 4] = "GetByActivity";
- SkinGetForType[SkinGetForType["Using"] = -1] = "Using";
- })(SkinGetForType || (SkinGetForType = {}));
- class ShopView extends ui.SkinViewUI {
- constructor() {
- super();
- this.firstopen = true;
- this.showroleId = 0;
- this.uiArr = [];
- this.CapArray = [];
- this.HorseArray = [];
- ShopView.ins = this;
- }
- static get Instance() {
- if (ShopView.ins == null) {
- console.log("new shopview");
- return new ShopView();
- }
- return ShopView.ins;
- }
- Show() {
- WXSDK.AldEvent("打开皮肤商店界面");
- let data = AccountManager.Instance.curplayerData.GainCollocation("theme");
- for (let i = 0; i < data.length; i++) {
- if (i < 5) {
- this.CapArray.push(data[i]);
- }
- else {
- this.HorseArray.push(data[i]);
- }
- }
- this.BackBtn.clickHandler = new Laya.Handler(this, this.ClickClose);
- this.CharacterBtn.clickHandler = new Laya.Handler(this, this.ClickCap);
- this.HorseBtn.clickHandler = new Laya.Handler(this, this.ClickHorse);
- this.GetBtn.clickHandler = new Laya.Handler(this, this.ClickGet);
- this.VideoGetCoinBtn.clickHandler = new Laya.Handler(this, this.VideoGet);
- this.CharacterLightImage = this.CharacterBtn.getChildByName("light");
- this.HorseLightImage = this.HorseBtn.getChildByName("light");
- this.GetByCoin = this.GetBtn.getChildByName("GetByCoin");
- this.RequireCoinNum = this.GetByCoin.getChildByName("CoinNum");
- this.GetByVideo = this.GetBtn.getChildByName("GetByVideo");
- this.RequireVideoNum = this.GetByVideo.getChildByName("VideoNum");
- this.GetByActive = this.GetBtn.getChildByName("GetByActive");
- this.Geted = this.GetBtn.getChildByName("Geted");
- this.Using = this.GetBtn.getChildByName("Using");
- this.uiArr.push(this.Using);
- this.uiArr.push(this.Geted);
- this.uiArr.push(this.GetByCoin);
- this.uiArr.push(this.GetByVideo);
- this.uiArr.push(this.GetByActive);
- this.equip_Horse = AccountManager.Instance.curplayerData.GetUser(AccountUser.equip_themes)["2"];
- this.equip_Cap = AccountManager.Instance.curplayerData.GetUser(AccountUser.equip_themes)["1"];
- this.showroleId = 1;
- this.ItemList.selectEnable = false;
- this.ItemList.vScrollBarSkin = "";
- this.ItemList.renderHandler = Laya.Handler.create(this, this.UpdateItem, null, false);
- this.ItemList.array = this.CapArray;
- this.ItemList.refresh();
- this.ShowButton(1);
- this.height = Laya.stage.height;
- Laya.stage.on(Laya.Event.RESIZE, this, () => {
- this.height = Laya.stage.height;
- });
- }
- Close() {
- WXSDK.AldEvent("关闭皮肤商城界面");
- }
- ClickClose() {
- var equiphorseid = Number(AccountManager.Instance.curplayerData.GetUser(AccountUser.equip_themes)["2"]);
- var equipcap = Number(AccountManager.Instance.curplayerData.GetUser(AccountUser.equip_themes)["1"]);
- if (equipcap) {
- if (equipcap != this.equip_Cap) {
- GameManager.Instance.SetCap(equipcap);
- }
- }
- if (equiphorseid != this.equip_Horse) {
- GameManager.Instance.SetHorse(equiphorseid);
- }
- ViewManager.Instance.ShowView(ViewType.MainView);
- }
- UpdateItem(cell, index) {
- let item = cell.getComponent(ShopItem);
- item.RefreshItem();
- }
- RefreshItem() {
- this.ItemList.refresh();
- }
- ClickCap() {
- this.firstopen = true;
- if (this.equip_Cap) {
- this.showroleId = this.equip_Cap;
- }
- else {
- this.showroleId = 1;
- }
- this.ShowButton(1);
- this.CharacterLightImage.visible = true;
- this.HorseLightImage.visible = false;
- this.ItemList.vScrollBarSkin = "";
- this.ItemList.array = this.CapArray;
- this.ItemList.renderHandler = Laya.Handler.create(this, this.UpdateItem, null, false);
- }
- ClickHorse() {
- this.firstopen = true;
- this.showroleId = this.equip_Horse;
- this.ShowButton(2);
- this.CharacterLightImage.visible = false;
- this.HorseLightImage.visible = true;
- this.ItemList.vScrollBarSkin = "";
- this.ItemList.array = this.HorseArray;
- this.ItemList.renderHandler = Laya.Handler.create(this, this.UpdateItem, null, false);
- }
- RefreshButton(_skinGetForType) {
- this.skinGetForType = _skinGetForType;
- this.ShowUI(this.skinGetForType);
- }
- ShowButton(type) {
- if (type == 1) {
- var equipcap = Number(AccountManager.Instance.curplayerData.GetUser(AccountUser.equip_themes)["1"]);
- var usingId = equipcap;
- let item = this.CapArray[0].require_type;
- this._data = this.CapArray[0];
- var _id = this._data.id;
- var hasequip = AccountManager.Instance.curplayerData.HasEquip(_id);
- var require_type = item;
- if (usingId == _id) {
- this.skinGetForType = SkinGetForType.Using;
- this.RefreshButton(this.skinGetForType);
- return;
- }
- if (hasequip) {
- this.skinGetForType = SkinGetForType.Geted;
- this.RefreshButton(this.skinGetForType);
- return;
- }
- if (require_type == 2) {
- this.skinGetForType = SkinGetForType.Bycoin;
- this.RefreshButton(this.skinGetForType);
- return;
- }
- if (require_type == 4) {
- this.skinGetForType = SkinGetForType.GetByActivity;
- this.RefreshButton(this.skinGetForType);
- return;
- }
- if (require_type == 3) {
- this.skinGetForType = SkinGetForType.GetByVideo;
- this.RefreshButton(this.skinGetForType);
- return;
- }
- }
- else {
- var equiphorse = Number(AccountManager.Instance.curplayerData.GetUser(AccountUser.equip_themes)["2"]);
- var usingId = equiphorse;
- let item = this.HorseArray[0].require_type;
- this._data = this.HorseArray[0];
- var _id = this._data.id;
- var hasequip = AccountManager.Instance.curplayerData.HasEquip(_id);
- var require_type = item;
- if (usingId == _id) {
- this.skinGetForType = SkinGetForType.Using;
- this.RefreshButton(this.skinGetForType);
- return;
- }
- if (hasequip) {
- this.skinGetForType = SkinGetForType.Geted;
- this.RefreshButton(this.skinGetForType);
- return;
- }
- if (require_type == 2) {
- this.skinGetForType = SkinGetForType.Bycoin;
- this.RefreshButton(this.skinGetForType);
- return;
- }
- if (require_type == 4) {
- this.skinGetForType = SkinGetForType.GetByActivity;
- this.RefreshButton(this.skinGetForType);
- return;
- }
- if (require_type == 3) {
- this.skinGetForType = SkinGetForType.GetByVideo;
- this.RefreshButton(this.skinGetForType);
- return;
- }
- }
- }
- ClickGet() {
- switch (this.skinGetForType) {
- case SkinGetForType.Bycoin:
- var money = Number(AccountManager.Instance.curplayerData.GainAccount("money"));
- if (money < Number(this._data.require_num)) {
- WXSDK.ShowTxt("金币不足--");
- }
- else {
- this.Buy();
- }
- console.log("金币--");
- break;
- case SkinGetForType.GetByActivity:
- WXSDK.ShowTxt("暂未开放!");
- console.log("活动获取--");
- break;
- case SkinGetForType.GetByVideo:
- console.log("视频获取--");
- this.VideoGet();
- break;
- case SkinGetForType.Geted:
- this.Use();
- break;
- }
- }
- ShowUI(_type) {
- console.log("所需类型--", _type);
- if (_type == SkinGetForType.Using) {
- for (let index = 0; index < this.uiArr.length; index++) {
- if (index == 0) {
- this.uiArr[index].visible = true;
- }
- else {
- this.uiArr[index].visible = false;
- }
- }
- return;
- }
- this.Using.visible = false;
- for (let index = 1; index < this.uiArr.length; index++) {
- if (index == _type) {
- this.uiArr[index].visible = true;
- }
- else {
- this.uiArr[index].visible = false;
- }
- }
- switch (_type) {
- case SkinGetForType.Bycoin:
- this.RequireCoinNum.text = this._data.require_num.toString();
- break;
- case SkinGetForType.GetByVideo:
- this.RequireVideoNum.text = AccountManager.Instance.curplayerData.GetProgress(this._data.id) + "/" + this._data.require_num.toString();
- break;
- }
- }
- VideoGet() {
- GuangGao.Instance.loadVideo(isLoaded => {
- if (isLoaded) {
- GuangGao.Instance.showVideo(isOk => {
- if (isOk) {
- WXSDK.AldEvent("皮肤界面看视频得金币成功");
- var getkey = ArcherWorrior.vd;
- let param = [{ "reward_item": "1000" }, { "reward_num": "200" }, { "t": AccountManager.Instance.ServerTime.toString() }];
- ServerManager.Instance.SendHttp(getkey, param, Laya.Handler.create(this, this.VideoGetSuccess), Laya.Handler.create(this, this.VideoGetFail));
- }
- });
- }
- else {
- WXSDK.fengxiangtupian(isOk => {
- if (isOk) {
- WXSDK.AldEvent("皮肤界面看视频得金币成功");
- var getkey = ArcherWorrior.vd;
- let param = [{ "reward_item": "1000" }, { "reward_num": "200" }, { "t": AccountManager.Instance.ServerTime.toString() }];
- ServerManager.Instance.SendHttp(getkey, param, Laya.Handler.create(this, this.VideoGetSuccess), Laya.Handler.create(this, this.VideoGetFail));
- }
- });
- }
- });
- }
- VideoGetSuccess(_data) {
- this.RefreshItem();
- console.log("LookVideo->suc:" + JSON.stringify(_data));
- }
- VideoGetFail(_data) {
- console.log("LookVideo->fail:" + JSON.stringify(_data));
- }
- Use() {
- var agrs = [{ "id": this._data.id }];
- ServerManager.Instance.SendHttp(ArcherWorrior.WearEquip, agrs, Laya.Handler.create(this, this.UseSuccess), Laya.Handler.create(this, this.UseFail));
- }
- UseSuccess(data) {
- this.RefreshItem();
- this.RefreshButton(SkinGetForType.Using);
- WXSDK.ShowTxt("装备成功!");
- console.log("装备suc:" + JSON.stringify(data));
- }
- UseFail(data) {
- console.log(data);
- }
- Buy() {
- var agrs = [{ "id": this._data.id.toString() }];
- ServerManager.Instance.SendHttp(ArcherWorrior.BuyEquip, agrs, Laya.Handler.create(this, this.BuySuccess), Laya.Handler.create(this, this.BuyFail));
- }
- BuySuccess(data) {
- WXSDK.AldEvent("购买" + this._data.name + "成功");
- this.RefreshItem();
- this.RefreshButton(SkinGetForType.Using);
- console.log("购买suc:" + JSON.stringify(data));
- }
- BuyFail(data) {
- console.log("购买fail:" + JSON.stringify(data));
- }
- }
- class ShopScene {
- constructor() {
- this.first = true;
- this.motordic = new ResDic();
- ShopScene.ins = this;
- }
- static get Instance() {
- if (ShopScene.ins) {
- return ShopScene.ins;
- }
- else {
- return new ShopScene();
- }
- }
- CreateMoto(_motorindex, _image, trial = null) {
- if (!this._shopscene || this._shopscene.destroyed || this._shopscene == null) {
- this.first = true;
- this._shopscene = new Laya.Scene3D();
- this._camera = new Laya.Camera();
- if (trial) {
- this._camera.transform.position = new Laya.Vector3(0, 0.7, 3);
- this._camera.clearFlag = 2;
- this._camera.fieldOfView = 40;
- }
- else {
- this._camera.transform.position = new Laya.Vector3(0, 0.6, 3.5);
- this._camera.clearFlag = 2;
- this._camera.fieldOfView = 30;
- }
- this._shopscene.addChild(this._camera);
- let _light = new Laya.DirectionLight();
- _light.intensity = 0.5;
- this._shopscene.addChild(_light);
- var player = GamePool.Instance.GetModel(AssetManager.Instance.Horse.get(_motorindex), "");
- this._shopscene.addChild(player);
- _image.addChild(this._shopscene);
- player.transform.position = new Laya.Vector3(0, 0, -2);
- this._position = new Laya.Vector3(0, 0.01, 0);
- }
- if (_image) {
- this._camera.viewport = new Laya.Viewport(_image.x, _image.y, _image.width, _image.height);
- }
- if (this._motor) {
- this._motor.active = false;
- this._motor.removeSelf();
- this._motor = null;
- }
- if (!this.first)
- return;
- this.first = false;
- Laya.timer.frameLoop(1, this, this.Rotation, [player]);
- }
- Rotation(model) {
- model.transform.rotate(this._position);
- }
- CloseShop() {
- Laya.timer.clear(this, this.Rotation);
- if (this._motor) {
- this._motor.active = false;
- this._motor.removeSelf();
- }
- if (this._player) {
- this._player.active = false;
- this._player.removeSelf();
- }
- if (this._shopscene) {
- this._shopscene.destroy(true);
- }
- this._shopscene = null;
- this._motor = null;
- this._sprite = null;
- this._player = null;
- this.first = true;
- }
- }
- class TrialView extends ui.TrialViewUI {
- constructor() {
- super();
- }
- static get Instance() {
- if (TrialView.ins) {
- return TrialView.ins;
- }
- else {
- return new TrialView();
- }
- }
- Show() {
- WXSDK.AldEvent("打开皮肤试用界面");
- GuangGao.OpenBanner();
- this.Init();
- this.TrialBtn.clickHandler = Laya.Handler.create(this, this.Trial);
- this.NoTrialBtn.visible = false;
- Laya.timer.once(2000, this, () => {
- this.NoTrialBtn.visible = true;
- this.NoTrialBtn.clickHandler = Laya.Handler.create(this, this.ClickClose);
- });
- this.height = Laya.stage.height;
- Laya.stage.on(Laya.Event.RESIZE, this, () => {
- this.height = Laya.stage.height;
- });
- }
- Close() {
- WXSDK.AldEvent("关闭皮肤试用界面");
- }
- ClickClose() {
- var agrs = [{ "t": AccountManager.Instance.ServerTime.toString() }];
- ServerManager.Instance.SendHttp(ArcherWorrior.KaiShi, agrs, Laya.Handler.create(this, this.Complete), null);
- }
- Trial() {
- GuangGao.Instance.loadVideo(isLoaded => {
- if (isLoaded) {
- GuangGao.Instance.showVideo(isOk => {
- if (isOk) {
- WXSDK.AldEvent("观看视频试用皮肤成功");
- var agrs = [{ "t": AccountManager.Instance.ServerTime.toString() }];
- ServerManager.Instance.SendHttp(ArcherWorrior.KaiShi, agrs, Laya.Handler.create(this, this.Complete), null);
- GameManager.Instance.SetHorse(this.arr.id);
- }
- else {
- WXSDK.AldEvent("观看视频试用皮肤失败");
- var agrs = [{ "t": AccountManager.Instance.ServerTime.toString() }];
- ServerManager.Instance.SendHttp(ArcherWorrior.KaiShi, agrs, Laya.Handler.create(this, this.Complete), null);
- }
- });
- }
- else {
- WXSDK.fengxiangtupian(isOk => {
- if (isOk) {
- WXSDK.AldEvent("分享好友试用皮肤成功");
- var agrs = [{ "t": AccountManager.Instance.ServerTime.toString() }];
- ServerManager.Instance.SendHttp(ArcherWorrior.KaiShi, agrs, Laya.Handler.create(this, this.Complete), null);
- GameManager.Instance.SetHorse(this.arr.id);
- }
- else {
- WXSDK.AldEvent("分享好友试用皮肤失败");
- var agrs = [{ "t": AccountManager.Instance.ServerTime.toString() }];
- ServerManager.Instance.SendHttp(ArcherWorrior.KaiShi, agrs, Laya.Handler.create(this, this.Complete), null);
- }
- });
- }
- });
- }
- Complete(_data) {
- ShopScene.Instance.CloseShop();
- ViewManager.Instance.ShowView(ViewType.IngameView);
- let stage = AccountManager.Instance.curplayerData.GainAccount("stage");
- WXSDK.AldStart(stage);
- AudioManager.playMusic(MusicType.click);
- MainGameView.Instance.play_id = _data.play_id;
- EventManager.StageTrigger(StageState.Start);
- ViewManager.Instance.ShowView(ViewType.IngameView);
- }
- Init() {
- this.data = this.GetTryOutTheme();
- this.count = this.data.length;
- if (this.count == 1) {
- this.arr = this.data[0];
- }
- else {
- let index = GameTools.RandomANumber(0, this.count);
- this.arr = this.data[index];
- }
- ShopScene.Instance.CreateMoto(this.arr.id, this.SceneViewPort, 1);
- }
- GetTryOutTheme() {
- let arr = [];
- let themeCfg = AccountManager.Instance.curplayerData.GainCollocation("theme");
- let temp;
- if (themeCfg) {
- for (let index = 5; index < themeCfg.length; index++) {
- const element = themeCfg[index];
- let _id = element.id;
- if (!AccountManager.Instance.curplayerData.HasEquip(_id)) {
- arr.push(element);
- }
- if (index == themeCfg.length - 2) {
- temp = element;
- }
- }
- }
- if (arr.length == 0)
- arr.push(temp);
- return arr;
- }
- }
- class CompleteView extends ui.CompleteViewUI {
- constructor() {
- super();
- this.win = true;
- }
- static get Instance() {
- if (CompleteView.ins) {
- return CompleteView.ins;
- }
- else {
- return new CompleteView();
- }
- }
- Show(_data) {
- this.Init(_data);
- GuangGao.WudaoAnNiu(this.BtnBox);
- let gold = this.DealData(GameManager.Instance.KillNum);
- this.goldnum.text = Math.floor(gold).toString();
- this.SetData();
- this.height = Laya.stage.height;
- Laya.stage.on(Laya.Event.RESIZE, this, () => {
- this.height = Laya.stage.height;
- });
- }
- Close() {
- }
- Init(_data) {
- switch (_data) {
- case 1:
- WXSDK.AldEvent("打开胜利界面");
- this.loseimage.visible = false;
- this.reviveimage.visible = false;
- this.NoBtn.visible = false;
- this.TryAgainBtn.visible = false;
- this.ReviveBtn.visible = false;
- this.NextLevelBtn.clickHandler = Laya.Handler.create(this, this.NextLevel, [true]);
- break;
- case 2:
- WXSDK.AldEvent("打开失败界面");
- this.winimage.visible = false;
- this.reviveimage.visible = false;
- this.NoBtn.visible = false;
- this.NextLevelBtn.visible = false;
- this.ReviveBtn.visible = false;
- this.TryAgainBtn.clickHandler = Laya.Handler.create(this, this.TryAgain, [false]);
- break;
- case 3:
- WXSDK.AldEvent("打开结算界面");
- this.winimage.visible = false;
- this.loseimage.visible = false;
- this.NextLevelBtn.visible = false;
- this.TryAgainBtn.visible = false;
- this.NoBtn.clickHandler = Laya.Handler.create(this, this.NoRevive);
- this.ReviveBtn.clickHandler = Laya.Handler.create(this, this.Revive);
- }
- }
- NextLevel(_win) {
- let stage = AccountManager.Instance.curplayerData.GainAccount("stage");
- WXSDK.AldEnd(stage, true);
- AudioManager.playMusic(MusicType.click);
- this.win = _win;
- var iswin = _win ? "1" : "0";
- var coinnum = this.goldnum.text;
- var args = [{ "t": AccountManager.Instance.ServerTime.toString() }, { "play_id": MainGameView.Instance.play_id }, { "win": iswin }, { "money": coinnum }];
- ServerManager.Instance.SendHttp(ArcherWorrior.JieShu, args, Laya.Handler.create(this, this.Success), null);
- }
- Revive() {
- AudioManager.playMusic(MusicType.click);
- GuangGao.Instance.loadVideo(isLoaded => {
- if (isLoaded) {
- GuangGao.Instance.showVideo(isOk => {
- if (isOk) {
- WXSDK.AldEvent("观看视频复活成功");
- GameManager.Instance.ReviveNum -= 1;
- GameManager.Instance.Revive();
- }
- });
- }
- else {
- WXSDK.fengxiangtupian(isOk => {
- if (isOk) {
- WXSDK.AldEvent("分享复活成功");
- GameManager.Instance.ReviveNum -= 1;
- GameManager.Instance.Revive();
- }
- else {
- EventManager.StageTrigger(StageState.Lose);
- }
- });
- }
- });
- }
- NoRevive() {
- GameManager.Instance.ReviveNum -= 1;
- ViewManager.Instance.ShowView(ViewType.CompleteView, 2);
- }
- TryAgain(_win) {
- let stage = AccountManager.Instance.curplayerData.GainAccount("stage");
- WXSDK.AldEnd(stage, false);
- AudioManager.playMusic(MusicType.click);
- this.win = _win;
- var iswin = _win ? "1" : "0";
- var coinnum = this.goldnum.text;
- var args = [{ "t": AccountManager.Instance.ServerTime.toString() }, { "play_id": MainGameView.Instance.play_id }, { "win": iswin }, { "money": coinnum }];
- ServerManager.Instance.SendHttp(ArcherWorrior.JieShu, args, Laya.Handler.create(this, this.Success), null);
- }
- Success() {
- EventManager.StageTrigger(StageState.Restart);
- ViewManager.Instance.OpenPopView(ViewType.ExportView);
- }
- DealData(_num) {
- if (_num > StageControl.Instance.curstage.Goal) {
- _num = StageControl.Instance.curstage.Goal;
- }
- var _reward = AccountManager.Instance.curplayerData.GlobalData("mission_reward");
- var gold = _reward * StageControl.Instance.curstage.Modulus * (_num / StageControl.Instance.curstage.Goal);
- return gold;
- }
- SetData() {
- SDKZS.SetHuTuiList(this.PushList, 1, "");
- this.GunGun();
- }
- GunGun() {
- var maxBtm;
- try {
- this.PushList.scrollBar.value = 0;
- maxBtm = this.PushList.scrollBar.max;
- }
- catch (error) {
- console.error(error);
- return;
- }
- let tempBtm = 1;
- Laya.timer.frameLoop(1, this, () => {
- this.PushList.scrollBar.value += tempBtm;
- if (this.PushList.scrollBar.value >= maxBtm || this.PushList.scrollBar.value <= 0) {
- tempBtm = -tempBtm;
- }
- });
- }
- }
- class ExportView extends ui.ExportViewUI {
- OnOpen(data) {
- WXSDK.AldEvent("打开全屏幕导出界面");
- this.CloseExportBtn.clickHandler = Laya.Handler.create(this, this.ClickClose, [data]);
- this.SetData();
- this.height = Laya.stage.height;
- Laya.stage.on(Laya.Event.RESIZE, this, () => {
- this.height = Laya.stage.height;
- });
- }
- OnHide() {
- Laya.timer.clearAll(this);
- WXSDK.AldEvent("关闭全屏导出界面");
- }
- ClickClose(data) {
- ViewManager.Instance.ClosePopView(ViewType.ExportView);
- }
- SetData() {
- SDKZS.SetHuTuiList(this.HList, 2, "");
- SDKZS.SetHuTuiList(this.VList, 1, "");
- this.GunGun();
- }
- GunGun() {
- var maxTop;
- var maxBtm;
- try {
- this.VList.scrollBar.value = 0;
- this.HList.scrollBar.value = 0;
- maxTop = this.HList.scrollBar.max;
- maxBtm = this.VList.scrollBar.max;
- }
- catch (error) {
- console.error(error);
- return;
- }
- var tempTop = 1;
- var tempBtm = 1;
- Laya.timer.frameLoop(1, this, () => {
- this.HList.scrollBar.value += tempTop;
- if (this.HList.scrollBar.value >= maxTop || this.HList.scrollBar.value <= 0) {
- tempTop = -tempTop;
- }
- this.VList.scrollBar.value += tempBtm;
- if (this.VList.scrollBar.value >= maxBtm || this.VList.scrollBar.value <= 0) {
- tempBtm = -tempBtm;
- }
- });
- }
- }
- var ViewType;
- (function (ViewType) {
- ViewType[ViewType["MainView"] = 0] = "MainView";
- ViewType[ViewType["IngameView"] = 1] = "IngameView";
- ViewType[ViewType["ShopView"] = 2] = "ShopView";
- ViewType[ViewType["TrialView"] = 3] = "TrialView";
- ViewType[ViewType["CompleteView"] = 4] = "CompleteView";
- ViewType[ViewType["ExportView"] = 5] = "ExportView";
- })(ViewType || (ViewType = {}));
- class ViewManager {
- constructor() {
- this.showexportview = 0;
- this.popViewDic = [];
- this.ViewSprite = new Laya.Sprite();
- this.OtherViewSprite = new Laya.Sprite();
- ViewManager.ins = this;
- Laya.stage.addChild(this.ViewSprite);
- Laya.stage.addChild(this.OtherViewSprite);
- }
- static get Instance() {
- if (ViewManager.ins) {
- return ViewManager.ins;
- }
- else {
- return new ViewManager();
- }
- }
- ShowView(_viewtype, data = null) {
- if (this.curView != null) {
- this.curView.Close();
- this.curView.destroy();
- this.curView.removeSelf();
- }
- GuangGao.Clear();
- this.curView = this.CreateView(_viewtype);
- this.curView.name = ViewType[_viewtype];
- this.ViewSprite.addChild(this.curView);
- this.curView.Show(data);
- }
- CloseView() {
- if (this.curView != null) {
- this.curView.Close();
- this.curView.destroy();
- this.curView.removeSelf();
- }
- }
- OpenPopView(viewType, data = null) {
- GuangGao.Clear();
- var popView;
- if (this.popViewDic[viewType]) {
- popView = this.popViewDic[viewType];
- this.OtherViewSprite.setChildIndex(popView, this.OtherViewSprite.numChildren - 1);
- popView.visible = true;
- }
- else {
- popView = this.CreateView(viewType);
- this.OtherViewSprite.addChild(popView);
- this.popViewDic[viewType] = popView;
- }
- this.showexportview = 1;
- popView.OnOpen(data);
- }
- ClosePopView(viewType) {
- var popView = this.popViewDic[viewType];
- if (popView == null) {
- return;
- }
- GuangGao.Clear();
- popView.OnHide();
- popView.visible = false;
- this.showexportview = 0;
- }
- ClearPopViews() {
- GuangGao.Clear();
- }
- CreateView(_viewtype) {
- switch (_viewtype) {
- case ViewType.MainView:
- return new MainGameView();
- case ViewType.IngameView:
- return new InGameView();
- case ViewType.TrialView:
- return new TrialView();
- case ViewType.CompleteView:
- return new CompleteView();
- case ViewType.ExportView:
- return new ExportView();
- case ViewType.ShopView:
- return new ShopView();
- }
- return null;
- }
- }
- class SDKZS {
- static SetHuTuiList(list, scrol = 1, type = "") {
- console.log("互推数据--", SDKZS.data);
- console.log("互推数据准备状态---", SDKZS.isReady);
- let arr = SDKZS.data.promotion;
- if (!arr || arr.length == 0)
- return;
- list.selectEnable = false;
- scrol == 1 ? list.vScrollBarSkin = "" : list.hScrollBarSkin = "";
- list.renderHandler = Laya.Handler.create(this, SDKZS.updateItem, [type], false);
- list.array = arr;
- list.refresh();
- }
- static updateItem(type, cell, index) {
- var aditem = cell.getComponent(ListItem);
- aditem.Refresh(type);
- }
- static loadData() {
- zs.sdk.loadAd((res) => {
- console.log("[LOG]互推数据");
- console.log(res);
- SDKZS.data = res;
- console.log("拉取互推数据--", SDKZS.data);
- SDKZS.isReady = true;
- });
- }
- static navigate2Mini(data) {
- zs.sdk.navigate2Mini(data, AccountManager.Instance.curplayerData.openid, () => {
- WXSDK.AldEvent("成功跳转到" + data.app_title);
- }, () => {
- WXSDK.AldEvent("跳转" + data.app_title + "失败");
- if (ViewManager.Instance.showexportview == 0) {
- ViewManager.Instance.OpenPopView(ViewType.ExportView);
- }
- }, () => {
- });
- }
- static get CanCheat() {
- var checkscence = AccountManager.Instance.curplayerData.CheckScene;
- if (checkscence == false) {
- return true;
- }
- if (Main.SceneNum == "1037" || Main.SceneNum == "1058"
- || Main.SceneNum == "1067" || Main.SceneNum == "1095") {
- return true;
- }
- return false;
- }
- }
- SDKZS.isReady = false;
- class ListItem extends Laya.Script {
- constructor() { super(); }
- onAwake() {
- this.self = this.owner;
- this.icon = this.self.getChildByName("icon");
- this.btn = this.self.getChildByName("btn");
- this.name = this.self.getChildByName("name");
- this._tip = this.self.getChildByName("tip");
- this.bottom = this.self.getChildByName("bottom");
- this.remen = this.self.getChildByName("remen");
- this.diandian = this.icon.getChildAt(0);
- this.btn.clickHandler = new Laya.Handler(this, this.clickAd);
- }
- Refresh(type) {
- this.data = this.self.dataSource;
- this.type = type;
- if (this.name) {
- this.name.text = this.data.app_title;
- }
- if (this._tip) {
- this._tip.visible = true;
- let rnd = GameTools.RandomANumber(1, 200000);
- let text = rnd.toString() + "人玩过";
- if (rnd > 9999) {
- text = Math.floor(rnd / 10000) + "W人玩过";
- }
- this._tip.text = text;
- }
- if (this.diandian) {
- this.diandian.visible = false;
- }
- if (this.bottom) {
- let num = GameTools.RandomANumber(1, 10);
- this.bottom.skin = "Game/res/bottom/" + num + ".png";
- }
- if (this.remen) {
- this.remen.visible = Math.random() < 0.2 ? true : false;
- }
- this.icon.skin = this.data.app_icon;
- }
- clickAd() {
- SDKZS.navigate2Mini(this.data);
- }
- onDestroy() {
- this.btn.clickHandler = null;
- }
- }
- class GameConfig {
- constructor() { }
- static init() {
- var reg = Laya.ClassUtils.regClass;
- reg("Tools/ListItem.ts", ListItem);
- reg("Tools/ShopItem.ts", ShopItem);
- }
- }
- GameConfig.width = 720;
- GameConfig.height = 1280;
- GameConfig.scaleMode = "fixedwidth";
- GameConfig.screenMode = "none";
- GameConfig.alignV = "top";
- GameConfig.alignH = "left";
- GameConfig.startScene = "LoadView.scene";
- GameConfig.sceneRoot = "";
- GameConfig.debug = false;
- GameConfig.stat = false;
- GameConfig.physicsDebug = false;
- GameConfig.exportSceneToJson = true;
- GameConfig.init();
- class Main {
- constructor() {
- if (CheckMain.Creat)
- return;
- CheckMain.Creat = true;
- if (window["Laya3D"])
- Laya3D.init(GameConfig.width, GameConfig.height);
- else
- Laya.init(GameConfig.width, GameConfig.height, Laya["WebGL"]);
- Laya["Physics"] && Laya["Physics"].enable();
- Laya["DebugPanel"] && Laya["DebugPanel"].enable();
- Laya.stage.scaleMode = GameConfig.scaleMode;
- Laya.stage.screenMode = GameConfig.screenMode;
- Laya.stage.alignV = GameConfig.alignV;
- Laya.stage.alignH = GameConfig.alignH;
- Laya.URL.exportSceneToJson = GameConfig.exportSceneToJson;
- if (GameConfig.debug || Laya.Utils.getQueryString("debug") == "true")
- Laya.enableDebugPanel();
- if (GameConfig.physicsDebug && Laya["PhysicsDebugDraw"])
- Laya["PhysicsDebugDraw"].enable();
- if (GameConfig.stat)
- Laya.Stat.show();
- Laya.alertGlobalError = true;
- if (Laya.Browser.onWeiXin) {
- Laya.Browser.window.wx.showShareMenu({
- withShareTicket: true
- });
- Laya.Browser.window.wx.onShareAppMessage(function () {
- return {
- title: "有人@你,一起骑马仗箭走天涯",
- imageUrl: "Game/res/textrue/share.jpg",
- };
- });
- Laya.Browser.window.wx.onShow((option) => {
- var shareTicket = option.shareTicket;
- var userId = option.query.userId;
- var shareTitle = option.query.shareTitle;
- var scenevalue = Laya.LocalStorage.getItem("SceneValue");
- if (scenevalue) {
- Main.SceneNum = scenevalue;
- }
- else {
- Laya.LocalStorage.setItem("SceneValue", option.scene);
- Main.SceneNum = option.scene;
- }
- WXSDK.querychannel = option.query.channel;
- WXSDK.shareOpenId = option.query.userId;
- console.log("scene:", option.scene);
- if (WXSDK.querychannel != null) {
- console.log("onShow channel is:", WXSDK.querychannel);
- }
- if (option.referrerInfo) {
- WXSDK.referrerInfoappId = option.referrerInfo.appId;
- console.log("onShow appId is:", option.referrerInfo.appId);
- }
- });
- if (!Laya.Browser.onWeiXin)
- return;
- const updateManager = Laya.Browser.window.wx.getUpdateManager();
- updateManager.onCheckForUpdate(function (res) {
- console.log("最新版本:" + res.hasUpdate);
- });
- updateManager.onUpdateReady(function () {
- Laya.Browser.window.wx.showModal({
- showCancel: false,
- title: '更新提示',
- content: '新版本已经准备好,是否重启应用?',
- success(res) {
- updateManager.applyUpdate();
- },
- fail(res) {
- updateManager.applyUpdate();
- }
- });
- });
- }
- Laya.ResourceVersion.enable("version.json", Laya.Handler.create(this, this.onVersionLoaded), Laya.ResourceVersion.FILENAME_VERSION);
- }
- onVersionLoaded() {
- Laya.AtlasInfoManager.enable("fileconfig.json", Laya.Handler.create(this, this.onConfigLoaded));
- }
- onConfigLoaded() {
- new LoadView();
- }
- }
- Main.Ver = "1.0.0";
- Main.CFG = "123";
- new Main();
- var HttpRequest = Laya.HttpRequest;
- var Event = Laya.Event;
- const ArcherWorriorApiUrl = "https://archerworriorapi.xwxgame.com/";
- class ArcherWorrior {
- }
- ArcherWorrior.DengLu = "user/login";
- ArcherWorrior.KaiShi = "game/start";
- ArcherWorrior.JieShu = "game/play";
- ArcherWorrior.QianDao = "sign/sign";
- ArcherWorrior.Chengjiu = "achievement/getRewards";
- ArcherWorrior.Config = "config/table";
- ArcherWorrior.FenXiang = "fission/share";
- ArcherWorrior.LiXian = "fission/offline";
- ArcherWorrior.vd = "fission/vd";
- ArcherWorrior.FuHuo = "game/revival";
- ArcherWorrior.gadagdag = "treasure/click";
- ArcherWorrior.Invite = "invite/getRewards";
- ArcherWorrior.Lottery = "lottery/lottery";
- ArcherWorrior.ShareGetSkin = "theme/fission";
- ArcherWorrior.WearEquip = "theme/equip";
- ArcherWorrior.BuyEquip = "theme/buy";
- ArcherWorrior.ShouQuan = "user/auth";
- ArcherWorrior.JinBi = "user/sync";
- class ServerManager {
- constructor() { }
- static get Instance() {
- if (ServerManager.ins) {
- return ServerManager.ins;
- }
- else {
- return new ServerManager();
- }
- }
- Login(progresscb, completecb, errorcb) {
- var Account = AccountManager.Instance;
- var ver = Main.Ver;
- 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}`;
- let httpRequest = new HttpRequest();
- httpRequest.once(Event.PROGRESS, this, this.Progress, [progresscb, httpRequest]);
- httpRequest.once(Event.COMPLETE, this, this.Complete, [completecb, httpRequest]);
- httpRequest.once(Event.ERROR, this, this.Errorcb, [errorcb, httpRequest]);
- httpRequest.send(ArcherWorriorApiUrl + ArcherWorrior.DengLu, Data, "post", "text");
- }
- Progress(_progresscb, _httpreq) {
- if (_progresscb) {
- _progresscb.run();
- }
- }
- Complete(_completecb, _httpreq) {
- let data = JSON.parse(_httpreq.data);
- console.log(data);
- if (data["code"] != "0") {
- console.log("登录异常错误!错误信息sssssssss:", _httpreq.data["code"]);
- return;
- }
- console.log("-----------sss", data["t"]);
- AccountManager.Instance.SFSFSF = data["t"];
- this.RessetConfig(data, _completecb);
- }
- RessetConfig(data, completecb) {
- AccountManager.Instance.ReSetting(data, (flag) => {
- if (flag) {
- completecb.runWith(data);
- }
- else {
- this.RessetConfig(data, completecb);
- }
- });
- }
- Errorcb(_errorcb, _httpreq) {
- if (_errorcb != null) {
- _errorcb.runWith(_httpreq);
- }
- }
- SendHttp(protocol, param, completecb, errorcb, hasToken = true) {
- let sfaasfsfa = "";
- let daadsads = ArcherWorriorApiUrl + protocol;
- if (hasToken == true) {
- sfaasfsfa = `token=${AccountManager.Instance.curplayerData.zhengshu}&`;
- }
- if (protocol == ArcherWorrior.KaiShi || protocol == ArcherWorrior.JieShu || protocol == ArcherWorrior.vd || protocol == ArcherWorrior.Lottery) {
- let asddsa = "abcdefghijkimnopqrstuvwxyz0123456789";
- let adsassda = "{";
- let saafsafs = "";
- for (let i = 0; i < 4; i++) {
- saafsafs += asddsa[Math.floor(Math.random() * 100) % asddsa.length];
- }
- for (let i = 0; i < param.length; i++) {
- for (let key in param[i]) {
- adsassda += `\"${key}\":\"${param[i][key]}\"`;
- }
- if (i < param.length - 1) {
- adsassda += ",";
- }
- else {
- adsassda += "}";
- }
- }
- sfaasfsfa += "_r=" + saafsafs + this.SFGSGSG(adsassda);
- }
- else {
- if (param != null) {
- for (let i = 0; i < param.length; i++) {
- for (let key in param[i]) {
- let val = param[i][key];
- sfaasfsfa += `${key}=${val}`;
- if (i < param.length - 1) {
- sfaasfsfa += "&";
- }
- }
- }
- }
- }
- let httpRequest = new HttpRequest();
- httpRequest.once(Event.COMPLETE, this, this.onHttpRequestComplete, [completecb, errorcb, httpRequest]);
- httpRequest.once(Event.ERROR, this, this.Errorcb, [errorcb, httpRequest]);
- httpRequest.send(daadsads, sfaasfsfa, "post", "text");
- }
- onHttpRequestComplete(succeedcb, failurecb, httpRequest) {
- let data = JSON.parse(httpRequest.data);
- if (data["code"] == 0) {
- AccountManager.Instance.ReSetting(data);
- if (succeedcb != null) {
- succeedcb.runWith(data);
- }
- }
- else {
- if (failurecb != null) {
- failurecb.runWith(data);
- }
- console.log("Error! Http request complete error, code: " + data["code"] + " message: " + data["message"]);
- }
- }
- SFGSGSG(str) {
- var c1, c2, c3;
- var SFSFFSFSFSFS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
- var i = 0, len = str.length, SFFSSFFS = '';
- while (i < len) {
- c1 = str.charCodeAt(i++) & 0xff;
- if (i == len) {
- SFFSSFFS += SFSFFSFSFSFS.charAt(c1 >> 2);
- SFFSSFFS += SFSFFSFSFSFS.charAt((c1 & 0x3) << 4);
- SFFSSFFS += "==";
- break;
- }
- c2 = str.charCodeAt(i++);
- if (i == len) {
- SFFSSFFS += SFSFFSFSFSFS.charAt(c1 >> 2);
- SFFSSFFS += SFSFFSFSFSFS.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
- SFFSSFFS += SFSFFSFSFSFS.charAt((c2 & 0xF) << 2);
- SFFSSFFS += "=";
- break;
- }
- c3 = str.charCodeAt(i++);
- SFFSSFFS += SFSFFSFSFSFS.charAt(c1 >> 2);
- SFFSSFFS += SFSFFSFSFSFS.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
- SFFSSFFS += SFSFFSFSFSFS.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6));
- SFFSSFFS += SFSFFSFSFSFS.charAt(c3 & 0x3F);
- }
- return SFFSSFFS;
- }
- }
- class AccountManager {
- constructor(_code, _userinfo, _nickname, _avatarurl, _gender, _province, _city, _country, _device, _shareid, _scene, _v) {
- this.createTime = Laya.timer.currTimer;
- AccountManager.ins = this;
- this.code = _code;
- this.userInfo = _userinfo;
- this.nickName = _nickname;
- this.avatarUrl = _avatarurl;
- this.gender = _gender;
- this.province = _province;
- this.city = _city;
- this.country = _country;
- this.device = _device;
- this.share_id = _shareid;
- this.scene = _scene;
- this.v = _v;
- }
- static get Instance() {
- if (AccountManager.ins == null) {
- new AccountManager("222222", "你找谁?", "1233", "123", 1, "中国", "上海", "上海", "iphone6s", "123", "123", "123");
- }
- return AccountManager.ins;
- }
- ReSetting(data, cb = null) {
- var zhengshu = data["token"];
- var netset = data["app_setting"];
- var user = data["user"];
- var jichu = data["user_base"];
- var qiandao = data["user_sign"];
- var chengjiu = data["user_achievement"];
- var invite = data["user_invite"];
- var lottery = data["user_lottery"];
- if (this.curplayerData == null) {
- this.curplayerData = new PlayerData(zhengshu, null, netset, user, jichu, invite, null, qiandao, chengjiu, lottery);
- this.JundgCfg(data.table_version, cb);
- }
- else {
- if (netset) {
- this.curplayerData.netzheshe = netset;
- }
- if (user) {
- this.curplayerData.account = user;
- }
- if (jichu) {
- this.curplayerData.accountssss = jichu;
- }
- if (qiandao) {
- this.curplayerData.qiandao = qiandao;
- }
- if (chengjiu) {
- this.curplayerData.renwu = chengjiu;
- }
- }
- }
- JundgCfg(ver, callball) {
- var cfg = Laya.LocalStorage.getJSON(Main.CFG);
- if (cfg) {
- if (cfg.VER == ver) {
- console.log("已经拥有,不用更新");
- this.SetCfg(cfg);
- if (callball)
- callball(true);
- }
- else {
- console.log("cfg存在但是过期了");
- Laya.LocalStorage.removeItem(Main.CFG);
- ServerManager.Instance.SendHttp(ArcherWorrior.Config, null, Laya.Handler.create(this, (data) => {
- data.configs.VER = ver;
- Laya.LocalStorage.setJSON(Main.CFG, data.configs);
- this.SetCfg(data.configs);
- if (callball)
- callball(true);
- }), Laya.Handler.create(this, (data) => {
- console.log("配置获取失败" + data);
- if (callball)
- callball(false);
- return;
- }));
- }
- }
- else {
- console.log("本地没有cfg");
- ServerManager.Instance.SendHttp(ArcherWorrior.Config, null, Laya.Handler.create(this, (data) => {
- data.configs.VER = ver;
- Laya.LocalStorage.setJSON(Main.CFG, data.configs);
- this.SetCfg(data.configs);
- if (callball)
- callball(true);
- }), Laya.Handler.create(this, (data) => {
- console.log("配置获取失败" + data);
- }));
- }
- }
- SetCfg(data) {
- this.curplayerData.peizhis = data;
- }
- RessetConfig() {
- ServerManager.Instance.SendHttp(ArcherWorrior.Config, null, Laya.Handler.create(this, (data) => {
- this.curplayerData.peizhis = data["configs"];
- }), null);
- }
- get ServerTime() {
- let time = Laya.timer.currTimer;
- let stime = this.SFSFSF + Math.ceil((time - this.createTime) / 1000);
- return stime;
- }
- }
- var Vector3$4 = Laya.Vector3;
- var NpcState;
- (function (NpcState) {
- NpcState[NpcState["Attack"] = 0] = "Attack";
- NpcState[NpcState["Idle"] = 1] = "Idle";
- NpcState[NpcState["Win"] = 2] = "Win";
- NpcState[NpcState["Pursue"] = 3] = "Pursue";
- NpcState[NpcState["Run"] = 4] = "Run";
- NpcState[NpcState["Die"] = 5] = "Die";
- })(NpcState || (NpcState = {}));
- class NpcRunner extends Laya.Script {
- constructor() {
- super();
- this.m_distance = 20;
- this.m_distanceatk = 5;
- this.DIE = false;
- this.m_npcspeed = 0;
- this.atked = false;
- this.wined = false;
- this.begin = false;
- this.frontdie = false;
- this.reardie = false;
- this.canmove = false;
- this.dir = new Vector3$4();
- this.currotV = new Vector3$4();
- this.currot = new Laya.Quaternion;
- this.CurrectRotate = new Laya.Quaternion();
- this.curspeed = 0;
- this.offest = new Vector3$4();
- this.curpos = new Vector3$4();
- this.die = false;
- NpcRunner.ins = this;
- EventManager.StageOn(StageState.Start, this, this.Begin);
- EventManager.StageOn(StageState.Lose, this, this.GameOver);
- EventManager.StageOn(StageState.Win, this, this.GameOver);
- EventManager.StageOn(StageState.Press, this, this.AddSpeed);
- EventManager.StageOn(StageState.UnPress, this, this.SlowSpeed);
- }
- static get Instance() {
- if (NpcRunner.ins) {
- return NpcRunner.ins;
- }
- else {
- return new NpcRunner();
- }
- }
- onAwake() {
- this.m_npcmodel = this.owner;
- this.m_npcanimator = this.owner.getComponent(Laya.Animator);
- this.player = PlayerControl.Instance.Player;
- this.m_distance = AccountManager.Instance.curplayerData.NpcRunDistance * 1.65;
- this.m_distanceatk = AccountManager.Instance.curplayerData.NpcAtkDistance * 1.65;
- let stage = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
- if (stage == 1) {
- this.m_npcspeed = 0.1;
- }
- else {
- this.m_npcspeed = StageControl.Instance.curstage.npcspeed;
- }
- }
- Begin() {
- this.ChangeState(NpcState.Idle);
- this.begin = true;
- }
- onUpdate() {
- if (!this.begin)
- return;
- if (this.npc_state == NpcState.Die)
- return;
- if (this.frontdie || this.reardie) {
- this.ChangeState(NpcState.Die);
- return;
- }
- let stage = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
- var distance = Vector3$4.distance(this.player.transform.position, this.m_npcmodel.transform.position);
- if (distance < this.m_distance && distance > this.m_distanceatk && !this.atked && stage > 2) {
- Vector3$4.subtract(this.player.transform.position, this.m_npcmodel.transform.position, this.currotV);
- Vector3$4.normalize(this.currotV, this.currotV);
- 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));
- this.NPCMoveDir = this.currotV;
- this.canmove = true;
- this.ChangeState(NpcState.Run);
- }
- else if (distance <= this.m_distanceatk && !this.atked && stage > 2) {
- Vector3$4.subtract(this.player.transform.position, this.m_npcmodel.transform.position, this.currotV);
- Vector3$4.normalize(this.currotV, this.currotV);
- 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));
- this.NPCMoveDir = this.currotV;
- this.atked = true;
- this.ChangeState(NpcState.Attack);
- }
- this.Move(this.NPCMoveDir, this.m_npcspeed);
- this.RayCheck();
- }
- Move(_dir, _speed) {
- if (this.canmove) {
- var sp = GameTools.Instance.lerp(this.curspeed, _speed, 0.1);
- this.curspeed = sp;
- Vector3$4.scale(_dir, this.curspeed, this.offest);
- Vector3$4.add(this.m_npcmodel.transform.position, this.offest, this.curpos);
- Vector3$4.lerp(this.m_npcmodel.transform.position, this.curpos, 0.15, this.curpos);
- this.curpos = new Vector3$4(this.curpos.x, this.curpos.y, this.curpos.z);
- this.m_npcmodel.transform.position = this.curpos;
- }
- }
- AddSpeed() {
- this.m_npcspeed = StageControl.Instance.curstage.npcspeed;
- }
- SlowSpeed() {
- this.m_npcspeed = StageControl.Instance.curstage.npcspeed / 2;
- }
- GameOver() {
- EventManager.StageOff(StageState.Press, this, this.AddSpeed);
- EventManager.StageOff(StageState.UnPress, this, this.SlowSpeed);
- EventManager.StageOff(StageState.Start, this, this.Begin);
- }
- ChangeState(_state) {
- if (this.npc_state == _state)
- return;
- this.npc_state = _state;
- switch (this.npc_state) {
- case NpcState.Attack:
- this.Attack();
- break;
- case NpcState.Pursue:
- this.Pursue();
- break;
- case NpcState.Win:
- this.Win();
- break;
- case NpcState.Idle:
- this.Idle();
- break;
- case NpcState.Run:
- this.Run();
- break;
- case NpcState.Die:
- this.Die();
- break;
- }
- }
- Idle() {
- this.m_npcanimator.play("idle");
- }
- Attack() {
- this.m_npcanimator.play("atk");
- Laya.timer.once(500, this, () => {
- this.canmove = false;
- });
- }
- Win() {
- this.m_npcanimator.play("win");
- }
- Pursue() {
- }
- Run() {
- this.m_npcanimator.play("run");
- }
- Die() {
- if (this.die)
- return;
- this.die = true;
- AudioManager.playMusic(MusicType.die);
- this.PiaoZi();
- EventManager.StageOff(StageState.Start, this, this.Begin);
- Laya.timer.once(500, this, () => {
- GamePool.Instance.RecoveryModel(this.m_npcmodel);
- });
- if (this.frontdie) {
- this.m_npcanimator.play("diefront");
- }
- else if (this.reardie) {
- this.m_npcanimator.play("dierear");
- }
- this.canmove = false;
- }
- PiaoZi() {
- let headshoot = new Laya.Image();
- headshoot.skin = "Game/res/textrue/headshoot.png";
- headshoot.scaleX = 0.5;
- headshoot.scaleY = 0.5;
- headshoot.anchorX = 0.5;
- headshoot.anchorY = 0.5;
- Laya.stage.addChild(headshoot);
- Laya.timer.once(1000, this, () => {
- headshoot.visible = false;
- });
- GameManager.Instance.UIArray.push(headshoot);
- let UIPos = this.m_npcmodel.getChildByName("UIPos");
- let screenpos1 = new Vector3$4();
- Laya.timer.frameLoop(1, this, this.UIFollow, [UIPos, headshoot, screenpos1]);
- }
- UIFollow(UIPos, UI, POS) {
- AssetManager.Instance.maincamera.worldToViewportPoint(UIPos.transform.position, POS);
- UI.pos(POS.x, POS.y);
- }
- RayCheck() {
- if (this.wined)
- return;
- 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);
- let dir = Transform3DHelper.getForward(this.m_npcmodel.transform);
- let ray = new Laya.Ray(startpos, dir);
- let hitres = new Laya.HitResult();
- let isHit = AssetManager.Instance.mainscene.physicsSimulation.rayCast(ray, hitres, 1, 200);
- if (isHit) {
- let target = hitres.collider.owner.parent;
- if (target.name == "player") {
- let runner = target.getComponent(Runner);
- let ani = target.getComponent(Laya.Animator);
- if (!runner.Invincible) {
- Laya.timer.once(150, this, () => {
- runner.isdead = true;
- this.wined = true;
- });
- }
- }
- else if (target.name == "bonfire") {
- this.ChangeState(NpcState.Die);
- this.wined = true;
- }
- else if (target.name == "stone") ;
- else if (target.name == "") ;
- }
- }
- }
- var Vector3$5 = Laya.Vector3;
- var HostageState;
- (function (HostageState) {
- HostageState[HostageState["Run"] = 0] = "Run";
- HostageState[HostageState["Rescue"] = 1] = "Rescue";
- HostageState[HostageState["Arrest"] = 2] = "Arrest";
- HostageState[HostageState["Die"] = 3] = "Die";
- })(HostageState || (HostageState = {}));
- class Hostage extends Laya.Script {
- constructor() {
- super();
- this._hostagespeed = 0;
- this.begin = false;
- this.isbarrier = false;
- this.canmove = false;
- this.isdead = false;
- this.DownHit = new Laya.HitResult();
- this.FowardHit = new Laya.HitResult();
- this.currotV = new Vector3$5();
- this.hostagedir = new Vector3$5();
- this.offest = new Vector3$5();
- this.curpos = new Vector3$5();
- this.curspeed = 0;
- Hostage.ins = this;
- EventManager.StageOn(StageState.Start, this, this.Begin);
- EventManager.StageOn(StageState.Lose, this, this.GameOver);
- EventManager.StageOn(StageState.Win, this, this.GameOver);
- EventManager.StageOn(StageState.Press, this, this.AddSpeed);
- EventManager.StageOn(StageState.UnPress, this, this.SlowSpeed);
- }
- static get Instance() {
- if (Hostage.ins) {
- return Hostage.ins;
- }
- else {
- return new Hostage();
- }
- }
- onAwake() {
- this.m_hostagemodel = this.owner;
- this.m_hostageanimator = this.m_hostagemodel.getComponent(Laya.Animator);
- this.enemy = this.owner.parent.parent.getChildByName("enemy").getChildAt(0);
- this._hostagespeed = StageControl.Instance.curstage.hostspeed;
- }
- Begin() {
- this.ChangeState(HostageState.Run);
- this.begin = true;
- }
- onUpdate() {
- if (!this.begin)
- return;
- if (this.isdead) {
- this.ChangeState(HostageState.Die);
- return;
- }
- let npc = this.enemy.getComponent(ChaseNpc);
- if (npc.isdead || this.enemy == null || this.enemy.destroyed) {
- this.canmove = false;
- this.ChangeState(HostageState.Rescue);
- return;
- }
- this.RayCheck();
- let target = this.LookforRoad();
- if (this.canmove) {
- if (target) {
- Vector3$5.subtract(target.transform.position, this.m_hostagemodel.transform.position, this.currotV);
- Vector3$5.normalize(this.currotV, this.currotV);
- 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));
- this.hostagedir = this.currotV;
- if (!this.isbarrier) {
- this.Move(this.currotV, this._hostagespeed);
- }
- }
- else {
- if (!this.isbarrier) {
- this.Move(new Vector3$5(0, 0, 1), this._hostagespeed);
- }
- }
- }
- }
- LookforRoad() {
- var doorarr = [];
- for (let i = 0; i < DataManager.DoorArray.length; i++) {
- let _door = DataManager.DoorArray[i];
- if (this.m_hostagemodel.transform.position.z < _door.transform.position.z) {
- doorarr.push(_door);
- }
- }
- for (let i = 0; i < doorarr.length; i++) {
- for (let j = 0; j < doorarr.length - i - 1; j++) {
- var _dis = Vector3$5.distance(doorarr[i].transform.position, this.m_hostagemodel.transform.position);
- var _dis2 = Vector3$5.distance(doorarr[i + 1].transform.position, this.m_hostagemodel.transform.position);
- if (_dis > _dis2) {
- let door1 = doorarr[i];
- doorarr[i] = doorarr[i + 1];
- doorarr[i + 1] = door1;
- }
- }
- }
- return doorarr[0];
- }
- Move(_dir, _speed) {
- let stage = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
- if (stage == 1)
- return;
- if (this.canmove) {
- var sp = GameTools.Instance.lerp(this.curspeed, _speed, 0.1);
- this.curspeed = sp;
- Vector3$5.scale(_dir, this.curspeed, this.offest);
- Vector3$5.add(this.m_hostagemodel.transform.position, this.offest, this.curpos);
- Vector3$5.lerp(this.m_hostagemodel.transform.position, this.curpos, 0.15, this.curpos);
- this.curpos = new Vector3$5(this.curpos.x, this.curpos.y, this.curpos.z);
- this.m_hostagemodel.transform.position = this.curpos;
- }
- }
- AddSpeed() {
- this._hostagespeed = StageControl.Instance.curstage.hostspeed;
- }
- SlowSpeed() {
- this._hostagespeed = StageControl.Instance.curstage.hostspeed / 2;
- }
- GameOver() {
- EventManager.StageOff(StageState.Press, this, this.AddSpeed);
- EventManager.StageOff(StageState.UnPress, this, this.SlowSpeed);
- EventManager.StageOff(StageState.Start, this, this.Begin);
- Laya.timer.clearAll(this);
- this.canmove = false;
- }
- ChangeState(_state) {
- if (this.m_hostagestate == _state)
- return;
- this.m_hostagestate = _state;
- switch (this.m_hostagestate) {
- case HostageState.Run:
- this.Run();
- break;
- case HostageState.Arrest:
- this.Arrest();
- break;
- case HostageState.Rescue:
- this.Rescue();
- break;
- case HostageState.Die:
- this.Die();
- break;
- }
- }
- Run() {
- this.m_hostageanimator.play("run");
- }
- Rescue() {
- this.m_hostageanimator.play("thank");
- this.PiaoZi();
- }
- Arrest() {
- this.m_hostageanimator.play("dierear");
- this.canmove = false;
- }
- Die() {
- WXSDK.Shake(true);
- this.m_hostageanimator.play("dierear");
- this.canmove = false;
- EventManager.StageOff(StageState.Start, this, this.Begin);
- Laya.timer.clearAll(this);
- EventManager.StageTrigger(StageState.Lose);
- }
- RayCheck() {
- if (this.FowardRayCheck) {
- this.CrashBarrier();
- this.isbarrier = true;
- }
- else {
- this.isbarrier = false;
- }
- }
- PiaoZi() {
- let smile = new Laya.Image();
- smile.skin = "Game/res/textrue/happy.png";
- smile.scaleX = 0.05;
- smile.scaleY = 0.05;
- smile.anchorX = 0.5;
- smile.anchorY = 0.5;
- Laya.stage.addChild(smile);
- Laya.timer.once(1000, this, () => {
- smile.visible = false;
- Laya.timer.clear(this, this.UIFollow);
- });
- GameManager.Instance.UIArray.push(smile);
- let UIPos = this.m_hostagemodel.getChildByName("UIPos");
- let screenpos = new Vector3$5();
- Laya.timer.frameLoop(1, this, this.UIFollow, [UIPos, smile, screenpos]);
- }
- UIFollow(UIPos, UI, POS) {
- AssetManager.Instance.maincamera.worldToViewportPoint(UIPos.transform.position, POS);
- UI.pos(POS.x, POS.y);
- }
- CrashBarrier() {
- var target = this.FowardHit.collider.owner.parent;
- if (target.name == "stone") {
- this._hostagespeed = 0;
- }
- else if (target.name == "bonfire") ;
- else if (target.name == "big_fence") {
- this._hostagespeed = 0;
- }
- else if (target.name == "wood_Cylinder") {
- this._hostagespeed = 0;
- }
- }
- get FowardRayCheck() {
- var isFowardHit = false;
- 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);
- var direction = new Vector3$5(0, 0, 1);
- var DownRay = new Laya.Ray(startPos, direction);
- if (AssetManager.Instance.mainscene.physicsSimulation.rayCast(DownRay, this.FowardHit, 1)) {
- if (this.FowardHit.collider.collisionGroup == 100) {
- isFowardHit = true;
- }
- }
- return isFowardHit;
- }
- }
- var Vector3$6 = Laya.Vector3;
- var ChaseNpcState;
- (function (ChaseNpcState) {
- ChaseNpcState[ChaseNpcState["Idle"] = 0] = "Idle";
- ChaseNpcState[ChaseNpcState["Run"] = 1] = "Run";
- ChaseNpcState[ChaseNpcState["Die"] = 2] = "Die";
- ChaseNpcState[ChaseNpcState["Atk"] = 3] = "Atk";
- })(ChaseNpcState || (ChaseNpcState = {}));
- class ChaseNpc extends Laya.Script {
- constructor() {
- super();
- this.frontdie = false;
- this.reardie = false;
- this.canmove = false;
- this.isdead = false;
- this.atked = false;
- this.begin = false;
- this.m_chasenpcspeed = 0;
- this.pursuediatance = 0;
- this.atkdistance = 10;
- this.NPCRushSpeed = 0;
- this.Distance = 0;
- this.ChaseDistance = 0;
- this.NpcStartPos = new Vector3$6();
- this.dir = new Vector3$6();
- this.currotV = new Vector3$6();
- this.currot = new Laya.Quaternion;
- this.CurrectRotate = new Laya.Quaternion();
- this.curspeed = 0;
- this.offest = new Vector3$6();
- this.curpos = new Vector3$6();
- this.die = false;
- ChaseNpc.ins = this;
- EventManager.StageOn(StageState.Start, this, this.Begin);
- EventManager.StageOn(StageState.Lose, this, this.GameOver);
- EventManager.StageOn(StageState.Win, this, this.GameOver);
- EventManager.StageOn(StageState.Press, this, this.AddSpeed);
- EventManager.StageOn(StageState.UnPress, this, this.SlowSpeed);
- }
- static get Instance() {
- if (ChaseNpc.ins) {
- return ChaseNpc.ins;
- }
- else {
- return new ChaseNpc();
- }
- }
- onAwake() {
- this.m_chasenpcmodel = this.owner;
- }
- onStart() {
- this.m_chasenpcanimator = this.m_chasenpcmodel.getComponent(Laya.Animator);
- this.m_hostage = this.owner.parent.parent.getChildByName("player").getChildAt(0);
- this.NpcStartPos = this.m_chasenpcmodel.transform.position.clone();
- this.m_chasenpcspeed = StageControl.Instance.curstage.npcspeed;
- this.Distance = AccountManager.Instance.curplayerData.NpcChaseDistance * 1.65;
- this.ChaseDistance = AccountManager.Instance.curplayerData.NpcRushDistance * 1.65;
- this.NPCRushSpeed = AccountManager.Instance.curplayerData.NPCRushSpeed;
- }
- Begin() {
- this.ChangeState(ChaseNpcState.Run);
- this.begin = true;
- }
- onUpdate() {
- if (!this.begin)
- return;
- if (this.isdead)
- return;
- let _host = this.m_hostage.getComponent(Hostage);
- if (_host.isdead) {
- this.ChangeState(ChaseNpcState.Idle);
- return;
- }
- if (this.frontdie || this.reardie) {
- this.ChangeState(ChaseNpcState.Die);
- return;
- }
- var distance = Vector3$6.distance(PlayerControl.Instance.Player.transform.position, this.m_chasenpcmodel.transform.position);
- if (distance < this.Distance && !this.atked) {
- Vector3$6.subtract(this.m_hostage.transform.position, this.m_chasenpcmodel.transform.position, this.currotV);
- Vector3$6.normalize(this.currotV, this.currotV);
- 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));
- this.NPCMoveDir = this.currotV;
- this.canmove = true;
- _host.canmove = true;
- let _dis = this.m_chasenpcmodel.transform.position.z - this.NpcStartPos.z;
- if (_dis >= this.ChaseDistance) {
- this.atked = true;
- this.m_chasenpcspeed = this.NPCRushSpeed;
- this.ChangeState(ChaseNpcState.Atk);
- }
- }
- this.Move(this.NPCMoveDir, this.m_chasenpcspeed);
- this.RayCheck();
- }
- Move(_dir, _speed) {
- let stage = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
- if (stage <= 2)
- return;
- if (this.canmove) {
- var sp = GameTools.Instance.lerp(this.curspeed, _speed, 0.1);
- this.curspeed = sp;
- Vector3$6.scale(_dir, this.curspeed, this.offest);
- Vector3$6.add(this.m_chasenpcmodel.transform.position, this.offest, this.curpos);
- Vector3$6.lerp(this.m_chasenpcmodel.transform.position, this.curpos, 0.15, this.curpos);
- this.curpos = new Vector3$6(this.curpos.x, this.curpos.y, this.curpos.z);
- this.m_chasenpcmodel.transform.position = this.curpos;
- }
- }
- AddSpeed() {
- this.m_chasenpcspeed = StageControl.Instance.curstage.npcspeed;
- }
- SlowSpeed() {
- this.m_chasenpcspeed = StageControl.Instance.curstage.npcspeed / 2;
- }
- GameOver() {
- EventManager.StageOff(StageState.Press, this, this.AddSpeed);
- EventManager.StageOff(StageState.UnPress, this, this.SlowSpeed);
- EventManager.StageOff(StageState.Start, this, this.Begin);
- EventManager.StageOff(StageState.Lose, this, this.GameOver);
- EventManager.StageOff(StageState.Win, this, this.GameOver);
- }
- ChangeState(_state) {
- if (this.m_chasenpcstate == _state)
- return;
- this.m_chasenpcstate = _state;
- switch (this.m_chasenpcstate) {
- case ChaseNpcState.Atk:
- this.Attack();
- break;
- case ChaseNpcState.Idle:
- this.Idle();
- break;
- case ChaseNpcState.Run:
- this.Run();
- break;
- case ChaseNpcState.Die:
- this.Die();
- break;
- }
- }
- Idle() {
- this.m_chasenpcanimator.play("idle");
- }
- Attack() {
- this.m_chasenpcanimator.play("atk");
- Laya.timer.once(500, this, () => {
- this.canmove = false;
- });
- }
- Win() {
- this.m_chasenpcanimator.play("win");
- }
- Run() {
- this.m_chasenpcanimator.play("run");
- }
- Die() {
- if (this.die)
- return;
- this.die = true;
- AudioManager.playMusic(MusicType.die);
- this.PiaoZi();
- this.isdead = true;
- EventManager.StageOff(StageState.Start, this, this.Begin);
- if (this.frontdie) {
- this.m_chasenpcanimator.play("diefront");
- }
- if (this.reardie) {
- this.m_chasenpcanimator.play("dierear");
- }
- this.m_chasenpcanimator.play("diefront");
- this.canmove = false;
- }
- PiaoZi() {
- let headshoot = new Laya.Image();
- headshoot.skin = "Game/res/textrue/headshoot.png";
- headshoot.scaleX = 0.5;
- headshoot.scaleY = 0.5;
- headshoot.anchorX = 0.5;
- headshoot.anchorY = 0.5;
- Laya.stage.addChild(headshoot);
- Laya.timer.once(1000, this, () => {
- headshoot.visible = false;
- Laya.timer.clear(this, this.UIFollow);
- });
- GameManager.Instance.UIArray.push(headshoot);
- let UIPos = this.m_chasenpcmodel.getChildByName("UIPos");
- let screenpos2 = new Vector3$6();
- Laya.timer.frameLoop(1, this, this.UIFollow, [UIPos, headshoot, screenpos2]);
- }
- UIFollow(UIPos, UI, POS) {
- AssetManager.Instance.maincamera.worldToViewportPoint(UIPos.transform.position, POS);
- UI.pos(POS.x, POS.y);
- }
- RayCheck() {
- 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);
- let dir = Transform3DHelper.getForward(this.m_chasenpcmodel.transform);
- let ray = new Laya.Ray(startpos, dir);
- let hitres = new Laya.HitResult();
- let isHit = AssetManager.Instance.mainscene.physicsSimulation.rayCast(ray, hitres, 3, 200);
- if (isHit) {
- let target = hitres.collider.owner.parent;
- if (target.name == "hostage") {
- let _hostage = target.getComponent(Hostage);
- _hostage.isdead = true;
- }
- else if (target.name == "bonfire") {
- this.ChangeState(ChaseNpcState.Die);
- }
- else if (target.name == "stone") {
- this.m_chasenpcspeed = 0;
- }
- else if (target.name == "") ;
- }
- }
- }
- class Dictionary {
- constructor() {
- this.keys = new Array();
- this.values = new Array();
- }
- get count() {
- return this.keys.length;
- }
- add(key, value) {
- let index = this.keys.indexOf(key);
- if (index == -1) {
- this.keys.push(key);
- this.values.push(value);
- }
- else {
- this.values[index] = value;
- }
- }
- remove(key) {
- let index = this.keys.indexOf(key);
- if (index != -1) {
- this.keys.splice(index, 1);
- this.values.splice(index, 1);
- }
- }
- getValue(key) {
- let index = this.keys.indexOf(key);
- if (index != -1) {
- return this.values[index];
- }
- return null;
- }
- containKey(key) {
- let index = this.keys.indexOf(key);
- if (index != -1) {
- return true;
- }
- return false;
- }
- containValue(value) {
- let index = this.values.indexOf(value);
- if (index != -1) {
- return true;
- }
- return false;
- }
- clear() {
- this.keys.length = 0;
- this.values.length = 0;
- }
- }
- var Vector3$7 = Laya.Vector3;
- var BossState;
- (function (BossState) {
- BossState[BossState["Idle"] = 0] = "Idle";
- BossState[BossState["Run"] = 1] = "Run";
- BossState[BossState["Die"] = 2] = "Die";
- BossState[BossState["Walk"] = 3] = "Walk";
- })(BossState || (BossState = {}));
- class Boss extends Laya.Script {
- constructor() {
- super();
- this.canmove = false;
- this.FowardHit = new Laya.HitResult();
- this.isfence = false;
- this.arrowarray = [];
- this.m_arrowspeed = 0;
- this.AtkInterval = 0;
- this.BossSpeed = 1;
- this.CreatGround = false;
- this.randomdir = false;
- this.ArrowList = new Dictionary();
- this.currotV = new Vector3$7();
- this.currot = new Laya.Quaternion;
- this.NormalizeSpeed = new Vector3$7();
- this.curpos = new Vector3$7();
- this.offest = new Vector3$7();
- this.offestx = 0;
- this.atk = false;
- this.run = false;
- this.curspeed = 0;
- this.BossMoveDir = new Vector3$7(0, 0, 1);
- this.CurrectRotate = new Laya.Quaternion();
- this.recover = false;
- this.speed = 0;
- this.arrowoffset = new Vector3$7();
- this.arrowcurpos = new Vector3$7();
- EventManager.StageOn(StageState.Press, this, this.AddSpeed);
- EventManager.StageOn(StageState.UnPress, this, this.SlowSpeed);
- EventManager.StageOn(StageState.Win, this, this.GameOver);
- EventManager.StageOn(StageState.Lose, this, this.GameOver);
- }
- static get Instance() {
- if (Boss.ins) {
- return Boss.ins;
- }
- else {
- return new Boss();
- }
- }
- onAwake() {
- this.m_bossmodel = this.owner;
- this.m_horsemodel = this.m_bossmodel.parent;
- this.m_bossanimator = this.m_bossmodel.getComponent(Laya.Animator);
- this.m_horseanimator = this.m_horsemodel.getComponent(Laya.Animator);
- this.arrowpos = this.m_bossmodel.getChildByName("arrowpos");
- this.archerpos = this.m_bossmodel.getChildByName("archerpos");
- this.raypos = this.m_bossmodel.getChildByName("raypos");
- this.CreatRay(this.raypos.transform.position.clone(), this.raypos.transform.rotationEuler.clone(), this.raypos);
- this.CreatArcher(this.archerpos.transform.position.clone(), this.archerpos.transform.rotationEuler.clone(), this.archerpos);
- this.Player = PlayerControl.Instance.Player;
- let stage = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
- this.BossHp = Number(StageControl.Instance.curstagedic[stage].BossHp);
- this.NowBossHp = this.BossHp;
- this.AddHpUI();
- this.BossDistance = AccountManager.Instance.curplayerData.BossDistance * 1.65;
- this.level = AccountManager.Instance.curplayerData.GainAccount("stage");
- this.AtkInterval = AccountManager.Instance.curplayerData.BossAtkInterval - (this.level - 1) * 0.5;
- this.m_arrowspeed = AccountManager.Instance.curplayerData.ArrowSpeed;
- }
- onUpdate() {
- if (this.isdead)
- return;
- var dis = Vector3$7.distance(this.Player.transform.position, this.m_bossmodel.transform.position);
- if (dis <= this.BossDistance && !this.run) {
- this.run = true;
- WXSDK.Shake();
- this.ChangeState(BossState.Run);
- }
- if (dis >= AccountManager.Instance.curplayerData.MaxBossDistance * 1.65 && this.run) {
- this.canmove = false;
- }
- else if (dis > AccountManager.Instance.curplayerData.MinBossDistance * 1.65 && dis < AccountManager.Instance.curplayerData.MaxBossDistance * 1.65 && this.run) {
- this.ChangeState(BossState.Run);
- this.canmove = true;
- this.BossSpeed = StageControl.Instance.curstage.mainrolespeed;
- }
- if (!this.canmove)
- return;
- this.Move(this.BossMoveDir, this.BossSpeed);
- if (!this.atk) {
- this.atk = true;
- Laya.timer.once(this.AtkInterval * 1000, this, this.Atk);
- }
- if (!this.CreatGround && this.m_bossmodel.transform.position.z > StageControl.Instance.LastGround - 50) {
- StageControl.Instance.CreatGround(5);
- }
- if (!this.randomdir) {
- this.randomdir = true;
- Laya.timer.once(2000, this, this.RandomDir);
- }
- this.RayCheck();
- if (this.ArrowList != null) {
- var keys = this.ArrowList.keys;
- for (var i = 0; i < keys.length; i++) {
- var key = keys[i];
- if (keys[i] != null) {
- var value = this.ArrowList.getValue(keys[i]);
- this.ArrowMove(key, (this.ArrowList.getValue(key))[0], (this.ArrowList.getValue(key))[1]);
- }
- }
- }
- }
- TurnDir(_dir) {
- if (_dir.x != 0) {
- Vector3$7.lerp(this.currotV, _dir, 0.35, _dir);
- this.currotV = _dir;
- Laya.Quaternion.rotationLookAt(_dir, new Vector3$7(0, 1, 0), this.currot);
- Laya.Quaternion.slerp(this.m_horsemodel.transform.rotation, this.currot, 0.025, this.currot);
- this.currot = new Laya.Quaternion(0, this.currot.y, 0);
- this.m_horsemodel.transform.rotation = this.currot;
- }
- }
- MoveX(_speed) {
- if (this.m_horsemodel.transform.position.x < 0 && _speed < 0 && this.isfence) {
- return;
- }
- else if (this.m_horsemodel.transform.position.x > 0 && _speed > 0 && this.isfence) {
- return;
- }
- else if (this.m_horsemodel.transform.position.x >= GameManager.Instance.fenceleftpos && _speed > 0) {
- return;
- }
- else if (this.m_horsemodel.transform.position.x <= GameManager.Instance.fencerightpos && _speed < 0) {
- return;
- }
- _speed *= 0.07;
- this.m_horsemodel.transform.translate(new Vector3$7(_speed, 0, 0));
- }
- RandomDir() {
- let _dir = Math.random() > 0.5 ? -0.5 : 0.5;
- this.BossMoveDir = new Vector3$7(_dir, 0, 1);
- Laya.timer.once(200, this, () => {
- this.BossMoveDir = new Vector3$7(0, 0, 1);
- this.randomdir = false;
- });
- }
- Move(_dir, _speed) {
- var sp = GameTools.Instance.lerp(this.curspeed, _speed, 0.1);
- this.curspeed = sp;
- Vector3$7.scale(_dir, this.curspeed, this.offest);
- Vector3$7.add(this.m_horsemodel.transform.position, this.offest, this.curpos);
- Vector3$7.lerp(this.m_horsemodel.transform.position, this.curpos, 0.15, this.curpos);
- this.m_horsemodel.transform.position = this.curpos;
- 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;
- 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;
- }
- Atk() {
- Laya.timer.frameLoop(1, this, this.RotationMove);
- }
- SlowSpeed() {
- if (this.run) {
- this.ChangeState(BossState.Walk);
- this.BossSpeed = AccountManager.Instance.curplayerData.BossSpeed / 2;
- }
- }
- AddSpeed() {
- if (this.run) {
- this.ChangeState(BossState.Run);
- this.BossSpeed = AccountManager.Instance.curplayerData.BossSpeed;
- }
- }
- GameOver() {
- EventManager.StageOff(StageState.Press, this, this.AddSpeed);
- EventManager.StageOff(StageState.UnPress, this, this.SlowSpeed);
- }
- RotationMove() {
- Vector3$7.subtract(this.Player.transform.position, this.m_bossmodel.transform.position, this.currotV);
- Vector3$7.normalize(this.currotV, this.currotV);
- var curdir = new Vector3$7(-this.currotV.x, -this.currotV.y, -this.currotV.z);
- Laya.Quaternion.rotationLookAt(curdir, new Vector3$7(0, 10, 0), this.CurrectRotate);
- this.CurrectRotate.invert(this.CurrectRotate);
- Laya.Quaternion.slerp(this.m_bossmodel.transform.rotation, this.CurrectRotate, 0.05, this.CurrectRotate);
- this.m_bossmodel.transform.rotation = this.CurrectRotate;
- var bossfoward = Transform3DHelper.getForward(this.m_bossmodel.transform);
- let _angle = this.JupdeAngle(bossfoward, this.currotV);
- if (_angle > 0.995) {
- Laya.timer.clear(this, this.RotationMove);
- this.Shoot();
- let rotation2 = GameTools.tweenRotate(this.m_bossmodel.transform, new Vector3$7(0, 0, 0), 700, Laya.Ease.linearInOut, Laya.Handler.create(this, () => {
- rotation2.clear();
- this.atk = false;
- }));
- }
- }
- JupdeAngle(dir1, dir2) {
- let Dir1 = new Vector3$7(dir1.x, 0, dir1.z);
- let Dir2 = new Vector3$7(dir2.x, 0, dir2.z);
- Vector3$7.normalize(Dir1, Dir1);
- Vector3$7.normalize(Dir2, Dir2);
- var dot = Vector3$7.dot(Dir1, Dir2);
- return dot;
- }
- Shoot() {
- this.CreatArrow();
- var currect = this.m_arrow;
- this.m_arrow = null;
- let ray = this.owner.getChildByName("raypos").getChildAt(0);
- let forw = Transform3DHelper.getForward(ray.transform);
- let raypos = this.owner.getChildByName("raypos");
- let trans = raypos.transform;
- let testRay = new Laya.Ray(new Vector3$7(trans.position.x, trans.position.y - 1, trans.position.z), forw);
- let hitRes = new Laya.HitResult();
- this.m_bossanimator.play("shoot");
- if (AssetManager.Instance.mainscene.physicsSimulation.rayCast(testRay, hitRes)) {
- let target = hitRes.collider.owner.parent;
- this.ArrowList.add(currect, [forw, target]);
- }
- else {
- this.ArrowList.add(currect, [forw, null]);
- }
- }
- ArrowMove(arrow, _dir, target) {
- if (target) {
- if (arrow.destroyed)
- return;
- if (arrow.transform.position.z <= target.transform.position.z) {
- if (target.name == "player") {
- let _runner = target.getComponent(Runner);
- _runner.isdead = true;
- this.BossProgress.visible = false;
- }
- if (this.ArrowList.containKey(arrow)) {
- this.ArrowList.remove(arrow);
- }
- GamePool.Instance.RecoveryModel(arrow);
- }
- else {
- var sp = GameTools.Instance.lerp(this.speed, this.m_arrowspeed, 0.1);
- this.speed = sp;
- Vector3$7.scale(_dir, this.speed, this.arrowoffset);
- Vector3$7.add(arrow.transform.position, this.arrowoffset, this.arrowcurpos);
- Vector3$7.lerp(arrow.transform.position, this.arrowcurpos, 0.15, this.arrowcurpos);
- arrow.transform.position = this.arrowcurpos;
- }
- }
- else {
- var sp = GameTools.Instance.lerp(this.speed, this.m_arrowspeed, 0.1);
- this.speed = sp;
- Vector3$7.scale(_dir, this.speed, this.arrowoffset);
- Vector3$7.add(arrow.transform.position, this.arrowoffset, this.arrowcurpos);
- Vector3$7.lerp(arrow.transform.position, this.arrowcurpos, 0.15, this.arrowcurpos);
- arrow.transform.position = this.arrowcurpos;
- if (!this.recover) {
- this.recover = true;
- Laya.timer.once(1000, this, () => {
- if (this.ArrowList.containKey(arrow)) {
- this.ArrowList.remove(arrow);
- }
- GamePool.Instance.RecoveryModel(arrow);
- this.recover = false;
- });
- }
- }
- }
- ChangeState(_state) {
- if (this._bossstate == _state)
- return;
- this._bossstate = _state;
- switch (this._bossstate) {
- case BossState.Idle:
- this.Idle();
- break;
- case BossState.Run:
- this.Run();
- break;
- case BossState.Die:
- this.Die();
- break;
- case BossState.Walk:
- this.Walk();
- break;
- }
- }
- Idle() {
- this.m_bossanimator.play("idle");
- this.m_horseanimator.play("idle");
- }
- Walk() {
- this.m_horseanimator.play("walk");
- this.m_bossanimator.play("down");
- }
- Run() {
- this.canmove = true;
- this.m_bossanimator.play("down");
- this.m_horseanimator.play("run");
- }
- Die() {
- this.BossProgress.visible = false;
- this.isdead = true;
- Laya.timer.clearAll(this);
- this.m_horseanimator.play("idle");
- this.m_bossanimator.play("die");
- EventManager.StageTrigger(StageState.Win);
- }
- RayCheck() {
- if (this.FowardRayCheck) {
- this.CrashBarrier();
- }
- else {
- this.isfence = false;
- }
- }
- CrashBarrier() {
- var target = this.FowardHit.collider.owner.parent;
- if (target.name == "small_fence") {
- this.isfence = true;
- }
- }
- get FowardRayCheck() {
- var isFowardHit = false;
- 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);
- let dir = Transform3DHelper.getForward(this.m_bossmodel.transform);
- var DownRay = new Laya.Ray(startPos, dir);
- if (AssetManager.Instance.mainscene.physicsSimulation.rayCast(DownRay, this.FowardHit, 1)) {
- if (this.FowardHit.collider.collisionGroup == 100) {
- isFowardHit = true;
- }
- }
- return isFowardHit;
- }
- CreatRay(pos, euler, raypos) {
- var ray = this.CreatRayPrefab();
- raypos.addChild(ray);
- ray.transform.position = pos;
- ray.transform.rotationEuler = euler;
- }
- CreatRayPrefab() {
- var ray = GamePool.Instance.GetModel(AssetManager.Instance.Prop.get(18), "");
- return ray;
- }
- CreatArcher(_pos, _euler, archerpos) {
- var archer = GamePool.Instance.GetModel(AssetManager.Instance.Prop.get(16), "");
- archerpos.addChild(archer);
- archer.transform.position = _pos;
- archer.transform.rotationEuler = _euler;
- var scale = archer.transform.scale.clone();
- scale.x = 0.3;
- scale.y = 0.3;
- scale.z = 0.6;
- archer.transform.scale = scale;
- }
- CreatArrow() {
- var arrow = GamePool.Instance.GetModel(AssetManager.Instance.Prop.get(17), "");
- AssetManager.Instance.mainscene.addChild(arrow);
- this.arrowarray.push(arrow);
- arrow.transform.position = this.arrowpos.transform.position.clone();
- var euler = this.arrowpos.transform.rotationEuler.clone();
- arrow.transform.rotationEuler = euler;
- let scale = arrow.transform.scale.clone();
- scale.z = 0.5;
- scale.x = 0.5;
- scale.y = 0.5;
- arrow.transform.scale = scale;
- this.m_arrow = arrow;
- }
- AddHpUI() {
- this.BossProgress = new Laya.ProgressBar();
- this.BossProgress.skin = "Game/res/textrue/healthbar1.png";
- this.BossProgress.scaleX = 0.4;
- this.BossProgress.scaleY = 0.4;
- this.BossProgress.anchorX = 0.5;
- this.BossProgress.anchorY = 0.5;
- Laya.stage.addChild(this.BossProgress);
- GameManager.Instance.UIArray.push(this.BossProgress);
- let UIPos = this.m_bossmodel.getChildByName("UIPos");
- this.InitHpUI();
- Laya.timer.frameLoop(1, this, () => {
- let ScreenPos = new Vector3$7();
- AssetManager.Instance.maincamera.worldToViewportPoint(UIPos.transform.position, ScreenPos);
- this.BossProgress.pos(ScreenPos.x, ScreenPos.y);
- });
- }
- InitHpUI() {
- this.BossProgress.value = this.NowBossHp / this.BossHp;
- }
- LoseHp(_damage) {
- GameManager.Instance.KillNum++;
- InGameView.Instance.InitUI();
- if (this.NowBossHp >= _damage) {
- this.NowBossHp = this.NowBossHp -= _damage;
- }
- else if (this.NowBossHp < _damage && this.NowBossHp > 0) {
- this.NowBossHp = 0;
- }
- if (this.NowBossHp == 0) {
- this.ChangeState(BossState.Die);
- this.BossProgress.destroy();
- }
- else {
- this.InitHpUI();
- }
- }
- }
- var Vector3$8 = Laya.Vector3;
- var CharacterState;
- (function (CharacterState) {
- CharacterState[CharacterState["Run"] = 0] = "Run";
- CharacterState[CharacterState["Idle"] = 1] = "Idle";
- CharacterState[CharacterState["Die"] = 2] = "Die";
- CharacterState[CharacterState["Win"] = 3] = "Win";
- CharacterState[CharacterState["Shoot"] = 4] = "Shoot";
- CharacterState[CharacterState["Walk"] = 5] = "Walk";
- CharacterState[CharacterState["Revive"] = 6] = "Revive";
- })(CharacterState || (CharacterState = {}));
- class Runner extends Laya.Script3D {
- constructor() {
- super();
- this.Invincible = false;
- this.started = false;
- this.shoot = false;
- this.isbarrier = false;
- this.isfence = false;
- this.arrowarray = [];
- this.isdead = false;
- this.canmove = false;
- this._speed = 0;
- this._press = false;
- this.RayDir = new Vector3$8();
- this.DownHit = new Laya.HitResult();
- this.FowardHit = new Laya.HitResult();
- this.curspeed = 0;
- this.currotV = new Vector3$8();
- this.currot = new Laya.Quaternion;
- this.NormalizeSpeed = new Vector3$8();
- this.curpos = new Vector3$8();
- this.offest = new Vector3$8();
- this.ArrowList = new Dictionary();
- this.arrowspeed = 0;
- this.speed = 0;
- this.arrowoffset = new Vector3$8();
- this.arrowcurpos = new Vector3$8();
- this.recover = false;
- this.hitfence = false;
- EventManager.StageOn(StageState.Start, this, this.Begin);
- EventManager.StageOn(StageState.Lose, this, this.GameOver);
- EventManager.StageOn(StageState.Win, this, this.GameOver);
- }
- static get Instance() {
- if (Runner.ins) {
- return Runner.ins;
- }
- else {
- return new Runner();
- }
- }
- onAwake() {
- this.m_player = this.owner;
- this.m_animator = this.owner.getComponent(Laya.Animator);
- this.m_arrowpos = this.owner.getChildByName("arrowpos");
- this.m_raypos = this.owner.getChildByName("raypos");
- this.m_archerpos = this.owner.getChildByName("archerpos");
- this.m_horseanimator = this.owner.getChildAt(this.owner.numChildren - 1).getComponent(Laya.Animator);
- this._speed = StageControl.Instance.curstage.mainrolespeed;
- this.m_PlayerDamage = AccountManager.Instance.curplayerData.PlayerDamage;
- this.stage = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
- this.ChangeState(CharacterState.Idle);
- this.DirRoatationLerp = AccountManager.Instance.curplayerData.DirRoatationLerp;
- this.DirMoveLerp = AccountManager.Instance.curplayerData.DirMoveLerp;
- this.arrowspeed = AccountManager.Instance.curplayerData.ArrowSpeed;
- this.m_range = AccountManager.Instance.curplayerData.Range;
- }
- Begin() {
- this.canmove = true;
- this.CreatArrow();
- this.ChangeState(CharacterState.Walk);
- }
- onUpdate() {
- if (this.isdead) {
- this.ChangeState(CharacterState.Die);
- return;
- }
- if (this.canmove && this.started) {
- var speed;
- if (!this.isbarrier) {
- if (this._press) {
- speed = StageControl.Instance.curstage.mainrolespeed;
- }
- else {
- speed = StageControl.Instance.curstage.mainrolespeed / 2;
- }
- let foward = Transform3DHelper.getForward(this.m_player.transform);
- this.Move(foward, speed);
- }
- }
- this.RayCheck();
- if (this.ArrowList != null) {
- var keys = this.ArrowList.keys;
- for (var i = 0; i < keys.length; i++) {
- var key = keys[i];
- if (keys[i] != null) {
- var value = this.ArrowList.getValue(keys[i]);
- this.ArrowMove(key, (this.ArrowList.getValue(key))[0], (this.ArrowList.getValue(key))[1]);
- }
- }
- }
- }
- MoveX(_speed) {
- if (this.m_player.transform.position.x < 0 && _speed < 0 && this.isfence) {
- return;
- }
- else if (this.m_player.transform.position.x > 0 && _speed > 0 && this.isfence) {
- return;
- }
- else if (this.m_player.transform.position.x >= GameManager.Instance.fenceleftpos && _speed > 0) {
- return;
- }
- else if (this.m_player.transform.position.x <= GameManager.Instance.fencerightpos && _speed < 0) {
- return;
- }
- _speed *= this.DirMoveLerp;
- if (this.canmove && this.started) {
- this.m_player.transform.translate(new Vector3$8(_speed, 0, 0));
- }
- }
- TurnDir(_dir) {
- if (_dir.x != 0) {
- Vector3$8.lerp(this.currotV, _dir, 0.35, _dir);
- this.currotV = _dir;
- Laya.Quaternion.rotationLookAt(_dir, new Vector3$8(0, 1, 0), this.currot);
- Laya.Quaternion.slerp(this.m_player.transform.rotation, this.currot, this.DirRoatationLerp, this.currot);
- this.currot = new Laya.Quaternion(0, this.currot.y, 0);
- this.m_player.transform.rotation = this.currot;
- }
- }
- Move(_dir, _speed) {
- var sp = GameTools.Instance.lerp(this.curspeed, _speed, 0.1);
- this.curspeed = sp;
- Vector3$8.scale(_dir, this.curspeed, this.offest);
- Vector3$8.add(this.m_player.transform.position, this.offest, this.curpos);
- Vector3$8.lerp(this.m_player.transform.position, this.curpos, 0.15, this.curpos);
- this.curpos = new Vector3$8(this.curpos.x, this.curpos.y, this.curpos.z);
- this.m_player.transform.position = this.curpos;
- 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;
- 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;
- }
- ChangeState(_state) {
- if (this.m_characterstate == _state)
- return;
- this.m_characterstate = _state;
- switch (this.m_characterstate) {
- case CharacterState.Idle:
- this.Idle();
- break;
- case CharacterState.Run:
- this.Run();
- break;
- case CharacterState.Die:
- this.Die();
- break;
- case CharacterState.Shoot:
- this.Shoot();
- break;
- case CharacterState.Walk:
- this.Walk();
- break;
- }
- }
- Idle() {
- this.m_animator.play("idle");
- this.m_horseanimator.play("idle");
- }
- Run() {
- this.m_animator.play("down");
- this.m_horseanimator.play("run");
- }
- ReviveState() {
- this.m_horseanimator.play("walk");
- this.m_animator.play("down");
- }
- Die() {
- WXSDK.Shake(true);
- this.canmove = false;
- this.m_animator.play("die");
- this.m_horseanimator.play("idle");
- EventManager.StageTrigger(StageState.Lose);
- }
- GameOver() {
- Laya.timer.clear(this, this.AnimatorState);
- EventManager.StageOff(StageState.Start, this, this.Begin);
- }
- Walk() {
- this.m_horseanimator.play("walk");
- }
- Shoot() {
- this.m_animator.play("shoot");
- }
- RayCheck() {
- if (this.FowardRayCheck) {
- this.CrashBarrier();
- }
- else {
- this.isbarrier = false;
- this.isfence = false;
- }
- }
- CrashBarrier() {
- var target = this.FowardHit.collider.owner.parent;
- if (target.name == "stone") {
- this.isbarrier = true;
- }
- else if (target.name == "bonfire") {
- this.ChangeState(CharacterState.Die);
- }
- else if (target.name == "big_fence") {
- this.isbarrier = true;
- }
- else if (target.name == "wood_Cylinder") {
- this.isbarrier = true;
- }
- else if (target.name == "small_fence") {
- this.isfence = true;
- }
- }
- get FowardRayCheck() {
- var isFowardHit = false;
- 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);
- let dir = Transform3DHelper.getForward(this.m_player.transform);
- var DownRay = new Laya.Ray(startPos, dir);
- if (AssetManager.Instance.mainscene.physicsSimulation.rayCast(DownRay, this.FowardHit, 1)) {
- if (this.FowardHit.collider.collisionGroup == 100) {
- isFowardHit = true;
- }
- }
- return isFowardHit;
- }
- Archery() {
- var currect = this.m_arrow;
- this.m_arrow = null;
- AudioManager.playMusic(MusicType.shoot);
- Laya.timer.clear(this, this.ArrowFollow);
- Laya.timer.clear(this, this.AnimatorState);
- let ray = this.owner.getChildByName("raypos").getChildAt(0);
- let forw = Transform3DHelper.getForward(ray.transform);
- let raypos = this.owner.getChildByName("raypos");
- let trans = raypos.transform;
- let testRay = new Laya.Ray(new Vector3$8(trans.position.x, trans.position.y - 0.5, trans.position.z), forw);
- let hitRes = new Laya.HitResult();
- this.m_animator.play("shoot");
- Laya.timer.frameLoop(1, this, this.AnimatorState);
- if (this.stage <= 2) {
- if (AssetManager.Instance.mainscene.physicsSimulation.rayCast(testRay, hitRes, this.m_range)) {
- let target = hitRes.collider.owner;
- this.ArrowList.add(currect, [forw, target]);
- }
- else {
- this.ArrowList.add(currect, [forw, null]);
- }
- }
- else {
- if (AssetManager.Instance.mainscene.physicsSimulation.rayCast(testRay, hitRes)) {
- let target = hitRes.collider.owner;
- this.ArrowList.add(currect, [forw, target]);
- }
- else {
- this.ArrowList.add(currect, [forw, null]);
- }
- }
- }
- ArrowMove(arrow, _dir, target) {
- if (target) {
- if (arrow.destroyed)
- return;
- let parent = target.parent;
- if (arrow.transform.position.z >= parent.transform.position.z) {
- if (parent.name == "npc") {
- AudioManager.playMusic(MusicType.hit);
- if (this.stage == 1) {
- if (InGameView.Instance.Guide2.visible) {
- if (GameManager.Instance.GuideKill < 2) {
- GameManager.Instance.GuideKill += 1;
- }
- if (GameManager.Instance.GuideKill == 1) {
- this.started = true;
- InGameView.Instance.Guide2.visible = false;
- Laya.timer.once(2500, this, () => {
- this.started = false;
- InGameView.Instance.Guide3.visible = true;
- this.m_range = 100;
- });
- }
- }
- }
- else if (this.stage == 2) {
- if (InGameView.Instance.Guide2.visible) {
- GameManager.Instance.GuideKill += 1;
- if (GameManager.Instance.GuideKill >= 1) {
- this.started = true;
- InGameView.Instance.Guide2.visible = false;
- Laya.timer.once(2000, this, () => {
- this.started = false;
- InGameView.Instance.Guide4.visible = true;
- this.m_range = 100;
- });
- }
- }
- }
- let _npcrunner = parent.getComponent(NpcRunner);
- let _chaseNpc = parent.getComponent(ChaseNpc);
- if (_npcrunner) {
- let stage = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
- if (stage == 1) {
- if (GameManager.Instance.GuideKill == 1) {
- if (target.name == "npcfrontcollider") {
- _npcrunner.frontdie = true;
- }
- else if (target.name == "npcrearcollider") {
- _npcrunner.reardie = true;
- }
- GameManager.Instance.KillNum++;
- InGameView.Instance.InitUI();
- }
- }
- else if (stage == 2) {
- if (InGameView.Instance.Guide2.visible || GameManager.Instance.GuideKill == 1) {
- if (target.name == "npcfrontcollider") {
- _npcrunner.frontdie = true;
- }
- else if (target.name == "npcrearcollider") {
- _npcrunner.reardie = true;
- }
- }
- GameManager.Instance.KillNum++;
- InGameView.Instance.InitUI();
- }
- else if (stage > 2) {
- if (target.name == "npcfrontcollider") {
- _npcrunner.frontdie = true;
- }
- else if (target.name == "npcrearcollider") {
- _npcrunner.reardie = true;
- }
- GameManager.Instance.KillNum++;
- InGameView.Instance.InitUI();
- }
- WXSDK.Shake(true);
- WXSDK.stageShake();
- }
- else if (_chaseNpc) {
- if (this.stage == 2) {
- if (InGameView.Instance.Guide4.visible && GameManager.Instance.GuideKill >= 1) {
- InGameView.Instance.Guide4.visible = false;
- WXSDK.AldEvent("完成第四阶段引导");
- this.started = true;
- Laya.timer.once(3000, this, () => {
- EventManager.StageTrigger(StageState.Win);
- });
- if (target.name == "npcfrontcollider") {
- _chaseNpc.frontdie = true;
- }
- else if (target.name == "npcrearcollider") {
- _chaseNpc.reardie = true;
- }
- GameManager.Instance.KillNum++;
- InGameView.Instance.InitUI();
- }
- }
- else {
- if (target.name == "npcfrontcollider") {
- _chaseNpc.frontdie = true;
- }
- else if (target.name == "npcrearcollider") {
- _chaseNpc.reardie = true;
- }
- GameManager.Instance.KillNum++;
- InGameView.Instance.InitUI();
- }
- WXSDK.Shake(true);
- WXSDK.stageShake();
- }
- }
- else if (parent.name == "big_fence") {
- AudioManager.playMusic(MusicType.hit);
- WXSDK.Shake(true);
- if (this.stage == 1) {
- if (GameManager.Instance.GuideKill >= 1) {
- InGameView.Instance.Guide3.visible = false;
- if (!this.hitfence) {
- Laya.timer.once(5000, this, () => {
- EventManager.StageTrigger(StageState.Win);
- });
- WXSDK.AldEvent("完成第三阶段引导");
- this.started = true;
- this.hitfence = true;
- }
- 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, () => {
- tweenpos.clear();
- }));
- let tweenrot = GameTools.tweenRotate(parent.transform, new Vector3$8(90, 0, 0), 500, Laya.Ease.linearInOut, Laya.Handler.create(this, () => {
- tweenrot.clear();
- }));
- Laya.timer.once(500, this, () => {
- GamePool.Instance.RecoveryModel(parent);
- });
- }
- }
- else {
- 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, () => {
- tweenpos.clear();
- }));
- let tweenrot = GameTools.tweenRotate(parent.transform, new Vector3$8(90, 0, 0), 500, Laya.Ease.linearInOut, Laya.Handler.create(this, () => {
- tweenrot.clear();
- }));
- Laya.timer.once(1000, this, () => {
- GamePool.Instance.RecoveryModel(parent);
- });
- }
- }
- else if (parent.name == "hostage") {
- if (this.stage > 1) {
- AudioManager.playMusic(MusicType.hit);
- let _host = parent.getComponent(Hostage);
- _host.isdead = true;
- }
- }
- else if (parent.name == "boss") {
- AudioManager.playMusic(MusicType.hit);
- let _boss = parent.getComponent(Boss);
- _boss.LoseHp(this.m_PlayerDamage);
- }
- if (this.ArrowList.containKey(arrow)) {
- this.ArrowList.remove(arrow);
- }
- GamePool.Instance.RecoveryModel(arrow);
- }
- else {
- var sp = GameTools.Instance.lerp(this.speed, this.arrowspeed, 0.1);
- this.speed = sp;
- Vector3$8.scale(_dir, this.speed, this.arrowoffset);
- Vector3$8.add(arrow.transform.position, this.arrowoffset, this.arrowcurpos);
- Vector3$8.lerp(arrow.transform.position, this.arrowcurpos, 0.15, this.arrowcurpos);
- arrow.transform.position = this.arrowcurpos;
- }
- }
- else {
- var sp = GameTools.Instance.lerp(this.speed, this.arrowspeed, 0.1);
- this.speed = sp;
- Vector3$8.scale(_dir, this.speed, this.arrowoffset);
- Vector3$8.add(arrow.transform.position, this.arrowoffset, this.arrowcurpos);
- Vector3$8.lerp(arrow.transform.position, this.arrowcurpos, 0.15, this.arrowcurpos);
- arrow.transform.position = this.arrowcurpos;
- if (!this.recover) {
- this.recover = true;
- Laya.timer.once(500, this, () => {
- if (this.ArrowList.containKey(arrow)) {
- this.ArrowList.remove(arrow);
- }
- GamePool.Instance.RecoveryModel(arrow);
- this.recover = false;
- });
- }
- }
- }
- AnimatorState() {
- if (this.m_animator.getCurrentAnimatorPlayState(0).normalizedTime >= 1) {
- Laya.timer.clear(this, this.AnimatorState);
- if (!this.m_arrowpos.destroyed) {
- this.CreatArrow();
- this.shoot = false;
- }
- }
- }
- CreatArrow() {
- var arrow = GamePool.Instance.GetModel(AssetManager.Instance.Prop.get(17), "");
- AssetManager.Instance.mainscene.addChild(arrow);
- this.arrowarray.push(arrow);
- arrow.transform.position = this.m_arrowpos.transform.position.clone();
- var euler = this.m_arrowpos.transform.rotationEuler.clone();
- arrow.transform.rotationEuler = euler;
- let scale = arrow.transform.scale.clone();
- scale.z = 0.5;
- scale.x = 0.8;
- scale.y = 0.5;
- arrow.transform.scale = scale;
- this.m_arrow = arrow;
- Laya.timer.frameLoop(1, this, this.ArrowFollow, [arrow, this.m_arrowpos]);
- }
- ArrowFollow(arrow, arrowpos) {
- if (!arrowpos.destroyed) {
- arrow.transform.position = arrowpos.transform.position.clone();
- arrow.transform.rotationEuler = arrowpos.transform.rotationEuler.clone();
- }
- else {
- Laya.timer.clear(this, this.ArrowFollow);
- }
- }
- Revive() {
- this.Invincible = true;
- Laya.timer.once(AccountManager.Instance.curplayerData.Invincible, this, () => {
- this.Invincible = false;
- });
- this.ReviveState();
- 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);
- this.canmove = true;
- this.ChangeState(CharacterState.Walk);
- }
- }
- var Vector3$9 = Laya.Vector3;
- class PlayerControl {
- constructor() {
- this.DownHit = new Laya.HitResult();
- this.speed = 1;
- this.press = false;
- this.win = false;
- this.offset = new Vector3$9(0, 0, 0);
- this.offestx = 0;
- this.first = false;
- this.poschazhi = new Vector3$9();
- this.gengsuipos = new Vector3$9();
- this.lllpos = new Vector3$9();
- this.hights = 0;
- this.wights = 0;
- PlayerControl.ins = this;
- EventManager.StageOn(StageState.Lose, this, this.GameOver);
- EventManager.StageOn(StageState.Win, this, this.GameOver);
- }
- static get Instance() {
- if (PlayerControl.ins) {
- return PlayerControl.ins;
- }
- else {
- return new PlayerControl();
- }
- }
- Init(_player) {
- this.win = false;
- this.Player = _player;
- this.arrowpos = _player.getChildByName("arrowpos");
- let runner = this.Player.getComponent(Runner);
- if (runner) {
- runner.destroy();
- }
- this._runner = this.Player.addComponent(Runner);
- this.Camera = AssetManager.Instance.maincamera;
- this.Camera.transform.position = new Laya.Vector3(0, 10, -19);
- this.Camera.transform.rotationEuler = new Laya.Vector3(-35.7, 180, 0);
- Laya.stage.on(Laya.Event.MOUSE_DOWN, this, this.onMouseDown);
- this.CameraFollow();
- Laya.timer.frameLoop(1, this, this.CheckWin);
- this.stage = Number(AccountManager.Instance.curplayerData.GainAccount("stage"));
- this.curtouchsmoothness = AccountManager.Instance.curplayerData.CurTouchsmoothness;
- this.curtouchsize = AccountManager.Instance.curplayerData.CurTouchsize;
- }
- CheckWin() {
- if (this.stage == 1) {
- if (this.Player.transform.position.z >= StageControl.Instance.curstage.endposition.z * 1.65 && !this.win) {
- this.win = true;
- EventManager.StageTrigger(StageState.Win);
- Laya.timer.clear(this, this.CheckWin);
- }
- }
- else if (this.stage > 2 && StageControl.Instance.curstage.isboss == 0) {
- if (this.Player.transform.position.z >= StageControl.Instance.curstage.endposition.z * 1.2 && !this.win) {
- this.win = true;
- EventManager.StageTrigger(StageState.Win);
- Laya.timer.clear(this, this.CheckWin);
- }
- }
- }
- onMouseDown(e) {
- if (!this._runner.canmove)
- return;
- if (this.stage > 2) {
- this._runner.started = true;
- }
- else if (this.stage == 2 && !this.first) {
- this._runner.started = true;
- }
- if (this.stage == 2 && !this.first) {
- this.first = true;
- Laya.timer.once(1500, this, () => {
- this._runner.started = false;
- InGameView.Instance.Guide2.visible = true;
- });
- }
- if (InGameView.Instance.Guide1.visible) {
- InGameView.Instance.Guide1.visible = false;
- WXSDK.AldEvent("完成第一阶段引导");
- InGameView.Instance.ani1.stop();
- this._runner.started = true;
- Laya.timer.once(2000, this, () => {
- this._runner.started = false;
- InGameView.Instance.Guide2.visible = true;
- });
- }
- this._runner._press = true;
- this.curMousePos = new Laya.Vector2(Laya.MouseManager.instance.mouseX, Laya.MouseManager.instance.mouseY);
- Laya.timer.frameLoop(1, this, this.onMouseMove);
- Laya.stage.on(Laya.Event.MOUSE_UP, this, this.onMouseUp);
- Laya.stage.on(Laya.Event.MOUSE_OUT, this, this.onMouseUp);
- this._runner.ChangeState(CharacterState.Run);
- EventManager.StageTrigger(StageState.Press);
- }
- onMouseMove() {
- if (this.stage != 1) {
- if (!this._runner.canmove) {
- Laya.timer.clear(this, this.onMouseMove);
- return;
- }
- }
- var MousePos = new Laya.Vector2(Laya.MouseManager.instance.mouseX, Laya.MouseManager.instance.mouseY);
- var offestX = MousePos.x - this.curMousePos.x;
- offestX = offestX > 50 ? 50 : offestX;
- offestX = offestX < -50 ? -50 : offestX;
- this.offestx = GameTools.Instance.lerp(this.offestx, offestX, this.curtouchsmoothness);
- var dir = new Vector3$9(-offestX * this.curtouchsize, 0, 0);
- this._runner.TurnDir(dir);
- this.curMousePos = MousePos;
- }
- onMouseUp() {
- if (!this._runner.canmove)
- return;
- this.offestx = 0;
- Laya.timer.clear(this, this.onMouseMove);
- this._runner._press = false;
- Laya.stage.off(Laya.Event.MOUSE_MOVE, this, this.onMouseMove);
- Laya.stage.off(Laya.Event.MOUSE_UP, this, this.onMouseUp);
- Laya.stage.off(Laya.Event.MOUSE_OUT, this, this.onMouseUp);
- if (!this._runner.shoot) {
- this._runner.shoot = true;
- this._runner.Archery();
- }
- this._runner.ChangeState(CharacterState.Walk);
- EventManager.StageTrigger(StageState.UnPress);
- }
- GameOver() {
- this._runner.canmove = false;
- this._runner._press = false;
- this.CameraCancelFollow();
- Laya.timer.clear(this, this.CheckWin);
- Laya.stage.off(Laya.Event.MOUSE_MOVE, this, this.onMouseMove);
- Laya.stage.off(Laya.Event.MOUSE_UP, this, this.onMouseUp);
- Laya.stage.off(Laya.Event.MOUSE_OUT, this, this.onMouseUp);
- Laya.stage.off(Laya.Event.MOUSE_DOWN, this, this.onMouseDown);
- }
- Revive() {
- this.Camera.transform.position = new Vector3$9(this.Camera.transform.position.x, this.Camera.transform.position.y, this.Camera.transform.position.z - 15);
- this._runner.Revive();
- this.CameraFollow();
- Laya.stage.on(Laya.Event.MOUSE_DOWN, this, this.onMouseDown);
- }
- CameraFollow() {
- this.hights = 0;
- this.wights = 0;
- Vector3$9.subtract(this.Player.transform.position, this.Camera.transform.position, this.poschazhi);
- Laya.timer.frameLoop(1, this, this.GenSui);
- }
- GenSui() {
- Vector3$9.subtract(this.Player.transform.position, this.poschazhi, this.gengsuipos);
- this.hights = GameTools.Instance.lerp(this.hights, 1, 0.03);
- this.wights = GameTools.Instance.lerp(this.wights, 0.8, 0.02);
- this.gengsuipos = new Vector3$9(this.gengsuipos.x, this.gengsuipos.y, this.gengsuipos.z - this.wights);
- Vector3$9.lerp(this.Camera.transform.position, this.gengsuipos, 0.25, this.lllpos);
- this.lllpos = new Vector3$9(this.gengsuipos.x, this.lllpos.y, this.lllpos.z);
- this.Camera.transform.position = this.lllpos;
- var qqqwe = new Laya.Quaternion();
- var eyePos = new Vector3$9(this.gengsuipos.x, this.gengsuipos.y - 0.8, this.gengsuipos.z);
- Laya.Quaternion.lookAt(eyePos, this.Player.transform.position, new Vector3$9(0, 1, 0), qqqwe);
- qqqwe.invert(qqqwe);
- Laya.Quaternion.slerp(this.Camera.transform.rotation, qqqwe, 0.1, qqqwe);
- this.Camera.transform.rotation = qqqwe;
- }
- CameraCancelFollow() {
- Laya.timer.clear(this, this.GenSui);
- }
- }
- class NpcControl {
- constructor() {
- NpcControl.ins = this;
- }
- static get Instance() {
- if (NpcControl.ins) {
- return NpcControl.ins;
- }
- else {
- return new NpcControl();
- }
- }
- Init(_npc) {
- this.m_npcmodel = _npc;
- let npcrunner = this.m_npcmodel.getComponent(NpcRunner);
- if (npcrunner) {
- npcrunner.destroy();
- }
- this.m_npcrunner = this.m_npcmodel.addComponent(NpcRunner);
- }
- }
- class GameManager {
- constructor() {
- this.started = false;
- this.GuideKill = 0;
- this.KillNum = 0;
- this.ReviveNum = 1;
- this.CharacterArray = [];
- this.UIArray = [];
- this.fenceleftpos = 0;
- this.fencerightpos = 0;
- this.treeleftpos = 0;
- this.treerightpos = 0;
- GameManager.ins = this;
- EventManager.EventOn(EventState.StageInit, this, this.CreatStage);
- EventManager.EventOn(EventState.StageCreateComplete, this, this.Init);
- }
- static get Instance() {
- if (GameManager.ins) {
- return GameManager.ins;
- }
- else {
- return new GameManager();
- }
- }
- Init() {
- this.CreatCharacter();
- this.mainscene = AssetManager.Instance.mainscene;
- Laya.stage.addChildAt(this.mainscene, 0);
- ViewManager.Instance.ShowView(ViewType.MainView);
- }
- CreatStage() {
- StageControl.Instance.RessetStage();
- }
- CreatCharacter() {
- this.CreatPlayer();
- }
- CreatPlayer() {
- var equiphorseid = Number(AccountManager.Instance.curplayerData.GetUser(AccountUser.equip_themes)["2"]);
- var equipcap = Number(AccountManager.Instance.curplayerData.GetUser(AccountUser.equip_themes)["1"]);
- var playermodel = GamePool.Instance.GetModel(AssetManager.Instance.Player.get(1), "");
- var horsemodel = GamePool.Instance.GetModel(AssetManager.Instance.Horse.get(equiphorseid), "");
- playermodel.addChild(horsemodel);
- playermodel.transform.position = new Laya.Vector3(0, 0, -9);
- horsemodel.transform.localScale = new Laya.Vector3(1, 1, 1);
- horsemodel.transform.localPosition = new Laya.Vector3(0, 0, 0);
- this.raypos = playermodel.getChildByName("raypos");
- this.archerpos = playermodel.getChildByName("archerpos");
- this.arrowpos = playermodel.getChildByName("arrowpos");
- this.cappos = playermodel.getChildByName("cappos");
- if (equipcap) {
- var capmodel = GamePool.Instance.GetModel(AssetManager.Instance.Cap.get(equipcap), "");
- this.cappos.addChild(capmodel);
- capmodel.transform.localScale = new Laya.Vector3(0.5, 0.5, 0.5);
- capmodel.transform.localPosition = new Laya.Vector3(0, 0, 0);
- capmodel.transform.localRotationEuler = new Laya.Vector3(-90, 0, 0);
- }
- let ray = this.raypos.getChildAt(0);
- if (!ray) {
- this.CreatRay(this.raypos.transform.position.clone(), this.raypos.transform.rotationEuler.clone(), this.raypos);
- }
- let archer = this.archerpos.getChildAt(0);
- if (!archer) {
- this.CreatArcher(this.archerpos.transform.position.clone(), this.archerpos.transform.rotationEuler.clone(), this.archerpos);
- }
- PlayerControl.Instance.Init(playermodel);
- AssetManager.Instance.mainscene.addChild(playermodel);
- this.CharacterArray.push(playermodel);
- GameTools.Instance.PlayerSetCollider(playermodel, 200);
- }
- CreatEnemy(enemy) {
- enemy.transform.rotationEuler = new Laya.Vector3(0, 180, 0);
- NpcControl.Instance.Init(enemy);
- GameTools.Instance.EnemySetCollider(enemy, 100);
- this.CharacterArray.push(enemy);
- }
- CreatChaseCharacter(_node) {
- let enemy = _node.getChildByName("enemy").getChildAt(0);
- let hostage = _node.getChildByName("player").getChildAt(0);
- hostage.transform.localPosition = new Laya.Vector3(0, 0, 0);
- hostage.transform.localRotationEuler = new Laya.Vector3(0, 0, 0);
- enemy.transform.localPosition = new Laya.Vector3(0, 0, -2);
- enemy.transform.localRotationEuler = new Laya.Vector3(0, 0, 0);
- GameTools.Instance.EnemySetCollider(enemy, 100);
- GameTools.Instance.HostageSetCollider(hostage, 200);
- let chase = enemy.getComponent(ChaseNpc);
- if (chase) {
- chase.destroy();
- }
- else {
- let _ChaseNpc = enemy.addComponent(ChaseNpc);
- }
- let host = hostage.getComponent(Hostage);
- if (host) {
- host.destroy();
- }
- else {
- let _Hostage = hostage.addComponent(Hostage);
- }
- this.CharacterArray.push(_node);
- }
- CreatBoss(_pos) {
- var bossmodel = GamePool.Instance.GetModel(AssetManager.Instance.Boss.get(1), "");
- var horsemodel = GamePool.Instance.GetModel(AssetManager.Instance.Horse.get(50), "");
- let bos = bossmodel.getComponent(Boss);
- if (bos) ;
- else {
- let _boss = bossmodel.addComponent(Boss);
- }
- horsemodel.addChild(bossmodel);
- bossmodel.transform.localPosition = new Laya.Vector3(0, 0, 0);
- bossmodel.transform.localScale = new Laya.Vector3(1, 1, 1);
- horsemodel.transform.position = _pos.clone();
- AssetManager.Instance.mainscene.addChild(horsemodel);
- this.CharacterArray.push(horsemodel);
- }
- RecoveryCharacter() {
- for (let i = 0; i < this.CharacterArray.length; i++) {
- let model = this.CharacterArray[i];
- switch (model.name) {
- case "npc":
- let npcrunner = model.getComponent(NpcRunner);
- if (npcrunner)
- npcrunner.destroy();
- break;
- case "pursue":
- let hostage = model.getChildByName("player").getChildAt(0).getComponent(Hostage);
- let chasenpc = model.getChildByName("enemy").getChildAt(0).getComponent(ChaseNpc);
- if (hostage)
- hostage.destroy();
- if (chasenpc)
- chasenpc.destroy();
- break;
- case "horse1":
- let boss = model.getChildByName("boss");
- boss.active = false;
- boss.removeSelf();
- GamePool.Instance.RecoveryModel(boss);
- let _bs = boss.getComponent(Boss);
- if (_bs) {
- for (let i = 0; i < _bs.arrowarray.length; i++) {
- let arrow = _bs.arrowarray[i];
- GamePool.Instance.RecoveryModel(arrow);
- _bs.arrowarray[i] = null;
- }
- _bs.arrowarray.splice(0, _bs.arrowarray.length);
- _bs.destroy();
- }
- break;
- case "player":
- let runner = model.getComponent(Runner);
- let horse = model.getChildAt(model.numChildren - 1);
- let cap = model.getChildByName("cappos").getChildAt(0);
- if (cap) {
- cap.removeSelf();
- GamePool.Instance.RecoveryModel(cap);
- }
- horse.active = false;
- horse.removeSelf();
- GamePool.Instance.RecoveryModel(horse);
- if (runner) {
- for (let i = 0; i < runner.arrowarray.length; i++) {
- let arrow = runner.arrowarray[i];
- GamePool.Instance.RecoveryModel(arrow);
- runner.arrowarray[i] = null;
- }
- runner.arrowarray.splice(0, runner.arrowarray.length);
- runner.destroy();
- }
- break;
- }
- GamePool.Instance.RecoveryModel(model);
- this.CharacterArray[i] = null;
- }
- this.CharacterArray.splice(0, this.CharacterArray.length);
- for (let i = 0; i < this.UIArray.length; i++) {
- let UI = this.UIArray[i];
- UI.removeSelf();
- UI.destroy();
- }
- this.UIArray.splice(0, this.UIArray.length);
- }
- CreatRay(pos, euler, raypos) {
- var ray = this.CreatRayPrefab();
- raypos.addChild(ray);
- ray.transform.position = pos;
- ray.transform.rotationEuler = euler;
- }
- CreatRayPrefab() {
- var ray = GamePool.Instance.GetModel(AssetManager.Instance.Prop.get(18), "");
- return ray;
- }
- CreatArcher(_pos, _euler, archerpos) {
- var archer = GamePool.Instance.GetModel(AssetManager.Instance.Prop.get(16), "");
- archerpos.addChild(archer);
- archer.transform.position = _pos;
- archer.transform.rotationEuler = _euler;
- var scale = archer.transform.scale.clone();
- scale.x = 0.3;
- scale.y = 0.3;
- scale.z = 0.6;
- archer.transform.scale = scale;
- }
- Revive() {
- PlayerControl.Instance.Revive();
- ViewManager.Instance.ShowView(ViewType.IngameView);
- }
- SetHorse(_id) {
- let horsemodel = PlayerControl.Instance.Player.getChildAt(PlayerControl.Instance.Player.numChildren - 1);
- horsemodel.removeSelf();
- GamePool.Instance.RecoveryModel(horsemodel);
- var newhorsemodel = GamePool.Instance.GetModel(AssetManager.Instance.Horse.get(_id), "");
- PlayerControl.Instance.Player.addChild(newhorsemodel);
- newhorsemodel.transform.localScale = new Laya.Vector3(1, 1, 1);
- newhorsemodel.transform.localPosition = new Laya.Vector3(0, 0, 0);
- PlayerControl.Instance._runner.m_horseanimator = newhorsemodel.getComponent(Laya.Animator);
- }
- SetCap(_id) {
- let cappos = PlayerControl.Instance._runner.m_player.getChildByName("cappos");
- let cap = cappos.getChildAt(0);
- if (cap) {
- cap.removeSelf();
- GamePool.Instance.RecoveryModel(cap);
- }
- let newcap = GamePool.Instance.GetModel(AssetManager.Instance.Cap.get(_id), "");
- cappos.addChild(newcap);
- newcap.transform.localPosition = new Laya.Vector3(0, 0, 0);
- newcap.transform.localScale = new Laya.Vector3(0.5, 0.5, 0.5);
- newcap.transform.localRotationEuler = new Laya.Vector3(-90, 0, 0);
- }
- }
- class MainGame {
- constructor() {
- MainGame.ins = this;
- EventManager.StageOn(StageState.Lose, this, this.GameFailure);
- EventManager.StageOn(StageState.Win, this, this.GameWin);
- }
- static get Instance() {
- if (MainGame.ins) {
- return MainGame.ins;
- }
- else {
- return new MainGame();
- }
- }
- GameFailure() {
- if (GameManager.Instance.ReviveNum > 0) {
- ViewManager.Instance.ShowView(ViewType.CompleteView, 3);
- }
- else {
- AudioManager.StopMusic();
- AudioManager.playMusic(MusicType.Lose);
- ViewManager.Instance.ShowView(ViewType.CompleteView, 2);
- }
- }
- GameWin() {
- AudioManager.StopMusic();
- AudioManager.playMusic(MusicType.Win);
- ViewManager.Instance.ShowView(ViewType.CompleteView, 1);
- }
- Revive() {
- ViewManager.Instance.ShowView(ViewType.CompleteView, 3);
- }
- }
- class LoadView extends ui.LoadViewUI {
- constructor() {
- super();
- this.progressnum = 0;
- this.fast = 0.07;
- this.slow = 0.001;
- this.End = false;
- this.EndProgress = false;
- Laya.stage.addChild(this);
- LoadView.ins = this;
- this.height = Laya.stage.height;
- Laya.stage.on(Laya.Event.RESIZE, this, () => {
- this.height = Laya.stage.height;
- });
- this.Init();
- }
- static get Instance() {
- if (LoadView.ins) {
- return LoadView.ins;
- }
- else {
- return new LoadView();
- }
- }
- Init() {
- console.log("load界面构造函数");
- new GameManager();
- new StageControl();
- new MainGame();
- this.Login();
- Laya.timer.frameLoop(1, this, this.UpdateProgress);
- }
- UpdateProgress() {
- if (this.progressnum <= 0.7) {
- this.progressnum += this.fast;
- }
- else if (this.progressnum > 0.7 && this.progressnum < 0.99) {
- this.progressnum += this.slow;
- }
- else {
- if (this.End) {
- this.progressnum += this.slow;
- }
- }
- if (!this.EndProgress && this.progressnum >= 1) {
- this.EndProgress = true;
- this.progressnum = 1;
- Laya.timer.clear(this, this.UpdateProgress);
- this.LoadComplete();
- }
- this.LoadProgress.value = this.progressnum;
- }
- complete() {
- this.End = true;
- this.slow = this.fast;
- }
- Login() {
- WXSDK.AldEvent("开始加载");
- if (Laya.Browser.onWeiXin) {
- this.WXLogin();
- }
- else {
- this.LocalLogin();
- }
- }
- WXLogin() {
- if (Laya.Browser.onWeiXin) {
- WXSDK.DengLu((res) => {
- if (res != "error") {
- WXSDK.AldEvent("微信登陆成功");
- console.log("1微信登录成功:" + res);
- this.LocalLogin();
- }
- else {
- this.WXLogin();
- }
- });
- }
- else {
- this.LocalLogin();
- }
- }
- LocalLogin() {
- ServerManager.Instance.Login(null, Laya.Handler.create(this, this.LoginComplete), Laya.Handler.create(this, this.LoginFail));
- }
- LoginComplete() {
- WXSDK.canshakestage = AccountManager.Instance.curplayerData.CanStageShake;
- SDKZS.loadData();
- WXSDK.AldEvent("本地服务器登陆成功");
- console.log("本地服务器登陆成功");
- this.LoadSubPackage();
- }
- LoginFail() {
- console.log("本地服务器登陆失败");
- }
- LoadComplete() {
- this.destroy();
- EventManager.EventTrigger(EventState.LoadComplete);
- WXSDK.AldEvent("资源加载完毕,开始进入主界面");
- console.log("加载完毕--");
- }
- LoadSubPackage() {
- WXSDK.LoadSubPackage("Game", callback => {
- if (callback) {
- WXSDK.AldEvent("分包加载成功");
- this.LoadScene();
- }
- });
- }
- LoadScene() {
- Laya.Scene3D.load(ResourcesPath.MainScene, Laya.Handler.create(this, (scene) => {
- this.mainscene = scene;
- AssetManager.Instance.mainscene = this.mainscene;
- console.log("场景资源加载完毕---");
- this.LoadPlayer();
- }));
- }
- LoadPlayer() {
- var path = [];
- for (let i = 0; i < ResourcesPath.Player.length; i++) {
- path.push(ResourcesPath.Player[i]);
- }
- Laya.loader.create(path, Laya.Handler.create(this, () => {
- for (let i = 0; i < ResourcesPath.Player.length; i++) {
- var model = Laya.loader.getRes(ResourcesPath.Player[i]);
- AssetManager.Instance.Player.set(i + 1, model);
- Laya.loader.clearRes(ResourcesPath.Player[i]);
- }
- console.log("玩家模型资源加载完毕---");
- this.LoadHorse();
- }));
- }
- LoadHorse() {
- var path = [];
- for (let i = 0; i < ResourcesPath.Horse.length; i++) {
- path.push(ResourcesPath.Horse[i]);
- }
- Laya.loader.create(path, Laya.Handler.create(this, () => {
- for (let i = 0; i < ResourcesPath.Horse.length; i++) {
- var model = Laya.loader.getRes(ResourcesPath.Horse[i]);
- AssetManager.Instance.Horse.set(i + 50, model);
- Laya.loader.clearRes(ResourcesPath.Horse[i]);
- }
- console.log("马模型资源加载完毕---");
- this.LoadBoss();
- }));
- }
- LoadBoss() {
- var path = [];
- for (let i = 0; i < ResourcesPath.Boss.length; i++) {
- path.push(ResourcesPath.Boss[i]);
- }
- Laya.loader.create(path, Laya.Handler.create(this, () => {
- for (let i = 0; i < ResourcesPath.Boss.length; i++) {
- var model = Laya.loader.getRes(ResourcesPath.Boss[i]);
- AssetManager.Instance.Boss.set(i + 1, model);
- Laya.loader.clearRes(ResourcesPath.Boss[i]);
- }
- console.log("boss模型资源加载完毕---");
- this.LoadCap();
- }));
- }
- LoadCap() {
- var path = [];
- for (let i = 0; i < ResourcesPath.Cap.length; i++) {
- path.push(ResourcesPath.Cap[i]);
- }
- Laya.loader.create(path, Laya.Handler.create(this, () => {
- for (let i = 0; i < ResourcesPath.Cap.length; i++) {
- var model = Laya.loader.getRes(ResourcesPath.Cap[i]);
- AssetManager.Instance.Cap.set(i + 1, model);
- Laya.loader.clearRes(ResourcesPath.Cap[i]);
- }
- console.log("帽子模型资源加载完毕---");
- this.LoadProp();
- }));
- }
- LoadProp() {
- Laya.loader.create(ResourcesPath.Prop, Laya.Handler.create(this, this.LoadResources));
- }
- LoadResources(_prop) {
- var Prop = _prop.getChildByName("Prop");
- for (let i = 0; i < Prop.numChildren; i++) {
- var model = Prop.getChildAt(i);
- model.active = false;
- AssetManager.Instance.Prop.set(i + 1, model);
- }
- var Plane = _prop.getChildByName("plane");
- AssetManager.Instance.Plane.set(1, Plane);
- var smallfence = _prop.getChildByName("small_fence");
- AssetManager.Instance.Small_Fence.set(1, smallfence);
- var Tree = _prop.getChildByName("Tree");
- for (let i = 0; i < Tree.numChildren; i++) {
- var tree = Tree.getChildAt(i);
- tree.active = false;
- AssetManager.Instance.Tree.set(i + 1, tree);
- }
- Laya.loader.clearRes(ResourcesPath.Prop);
- console.log("道具资源加载完毕---");
- this.complete();
- }
- }
- class Main$1 {
- constructor() {
- if (CheckMain.Creat)
- return;
- CheckMain.Creat = true;
- if (window["Laya3D"])
- Laya3D.init(GameConfig.width, GameConfig.height);
- else
- Laya.init(GameConfig.width, GameConfig.height, Laya["WebGL"]);
- Laya["Physics"] && Laya["Physics"].enable();
- Laya["DebugPanel"] && Laya["DebugPanel"].enable();
- Laya.stage.scaleMode = GameConfig.scaleMode;
- Laya.stage.screenMode = GameConfig.screenMode;
- Laya.stage.alignV = GameConfig.alignV;
- Laya.stage.alignH = GameConfig.alignH;
- Laya.URL.exportSceneToJson = GameConfig.exportSceneToJson;
- if (GameConfig.debug || Laya.Utils.getQueryString("debug") == "true")
- Laya.enableDebugPanel();
- if (GameConfig.physicsDebug && Laya["PhysicsDebugDraw"])
- Laya["PhysicsDebugDraw"].enable();
- if (GameConfig.stat)
- Laya.Stat.show();
- Laya.alertGlobalError = true;
- if (Laya.Browser.onWeiXin) {
- Laya.Browser.window.wx.showShareMenu({
- withShareTicket: true
- });
- Laya.Browser.window.wx.onShareAppMessage(function () {
- return {
- title: "有人@你,一起骑马仗箭走天涯",
- imageUrl: "Game/res/textrue/share.jpg",
- };
- });
- Laya.Browser.window.wx.onShow((option) => {
- var shareTicket = option.shareTicket;
- var userId = option.query.userId;
- var shareTitle = option.query.shareTitle;
- var scenevalue = Laya.LocalStorage.getItem("SceneValue");
- if (scenevalue) {
- Main$1.SceneNum = scenevalue;
- }
- else {
- Laya.LocalStorage.setItem("SceneValue", option.scene);
- Main$1.SceneNum = option.scene;
- }
- WXSDK.querychannel = option.query.channel;
- WXSDK.shareOpenId = option.query.userId;
- console.log("scene:", option.scene);
- if (WXSDK.querychannel != null) {
- console.log("onShow channel is:", WXSDK.querychannel);
- }
- if (option.referrerInfo) {
- WXSDK.referrerInfoappId = option.referrerInfo.appId;
- console.log("onShow appId is:", option.referrerInfo.appId);
- }
- });
- if (!Laya.Browser.onWeiXin)
- return;
- const updateManager = Laya.Browser.window.wx.getUpdateManager();
- updateManager.onCheckForUpdate(function (res) {
- console.log("最新版本:" + res.hasUpdate);
- });
- updateManager.onUpdateReady(function () {
- Laya.Browser.window.wx.showModal({
- showCancel: false,
- title: '更新提示',
- content: '新版本已经准备好,是否重启应用?',
- success(res) {
- updateManager.applyUpdate();
- },
- fail(res) {
- updateManager.applyUpdate();
- }
- });
- });
- }
- Laya.ResourceVersion.enable("version.json", Laya.Handler.create(this, this.onVersionLoaded), Laya.ResourceVersion.FILENAME_VERSION);
- }
- onVersionLoaded() {
- Laya.AtlasInfoManager.enable("fileconfig.json", Laya.Handler.create(this, this.onConfigLoaded));
- }
- onConfigLoaded() {
- new LoadView();
- }
- }
- Main$1.Ver = "1.0.0";
- Main$1.CFG = "123";
- new Main$1();
- exports.Main = Main$1;
- return exports;
- }({}));
- //# sourceMappingURL=bundle.js.map
|