bundle.js 261 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966
  1. (function () {
  2. 'use strict';
  3. class ImageRunTime extends Laya.Image {
  4. constructor() {
  5. super();
  6. this.scaleTime = 80;
  7. this.clickId = false;
  8. this.on(Laya.Event.MOUSE_DOWN, this, this.scaleSmall);
  9. this.on(Laya.Event.MOUSE_OVER, this, this.overs);
  10. this.on(Laya.Event.MOUSE_UP, this, this.scaleBig);
  11. this.on(Laya.Event.MOUSE_OUT, this, this.mouseout);
  12. }
  13. scaleBig(e) {
  14. if (!this.clickId)
  15. return;
  16. this.clickId = false;
  17. this.alpha = 1;
  18. if (this.CZ) {
  19. this.CZ();
  20. }
  21. }
  22. overs() {
  23. this.alpha = 0.7;
  24. }
  25. mouseout() {
  26. this.alpha = 1;
  27. }
  28. scaleSmall(e) {
  29. this.clickId = true;
  30. }
  31. onDestroy() {
  32. this.ClearRunTime();
  33. }
  34. ClearRunTime() {
  35. this.off(Laya.Event.MOUSE_DOWN, this, this.scaleSmall);
  36. this.off(Laya.Event.MOUSE_UP, this, this.scaleBig);
  37. this.off(Laya.Event.MOUSE_OUT, this, this.mouseout);
  38. this.off(Laya.Event.MOUSE_OVER, this, this.overs);
  39. this.CZ = null;
  40. }
  41. }
  42. class GameConfig {
  43. constructor() { }
  44. static init() {
  45. var reg = Laya.ClassUtils.regClass;
  46. reg("Window/Com/ButtonRunTime.ts", ImageRunTime);
  47. }
  48. }
  49. GameConfig.width = 720;
  50. GameConfig.height = 1280;
  51. GameConfig.scaleMode = "fixedwidth";
  52. GameConfig.screenMode = "vertical";
  53. GameConfig.alignV = "middle";
  54. GameConfig.alignH = "center";
  55. GameConfig.startScene = "ShadeView.scene";
  56. GameConfig.sceneRoot = "";
  57. GameConfig.debug = false;
  58. GameConfig.stat = false;
  59. GameConfig.physicsDebug = false;
  60. GameConfig.exportSceneToJson = true;
  61. GameConfig.init();
  62. class GameSetting {
  63. }
  64. GameSetting.VER = "1.0.7";
  65. GameSetting.CFG = "CFG";
  66. GameSetting.wxValue = "";
  67. GameSetting.isX = false;
  68. GameSetting.mSharePeopleScene = null;
  69. var SoundManager = Laya.SoundManager;
  70. var SoundType;
  71. (function (SoundType) {
  72. SoundType[SoundType["hit"] = 0] = "hit";
  73. SoundType[SoundType["click"] = 1] = "click";
  74. SoundType[SoundType["win"] = 2] = "win";
  75. SoundType[SoundType["defeat"] = 3] = "defeat";
  76. })(SoundType || (SoundType = {}));
  77. class SettingController {
  78. constructor() {
  79. this.vibrate = true;
  80. this.sound = true;
  81. this.SoundS = {
  82. click: "subpackage1/sound/click.mp3",
  83. win: "subpackage1/sound/vector.mp3",
  84. defeat: "subpackage1/sound/defeat.mp3",
  85. car_crush_1: "subpackage1/sound/car_crush_1.mp3",
  86. car_crush_2: "subpackage1/sound/car_crush_2.mp3",
  87. car_crush_3: "subpackage1/sound/car_crush_3.mp3",
  88. explotion1: "subpackage1/sound/explotion1.mp3",
  89. explotion2: "subpackage1/sound/explotion2.mp3",
  90. gun_fire_1: "subpackage1/sound/gun_fire_1.mp3",
  91. gun_fire_2: "subpackage1/sound/gun_fire_2.mp3",
  92. gun_fire_3: "subpackage1/sound/gun_fire_3.mp3",
  93. reload_gun_1: "subpackage1/sound/reload_gun_1.mp3",
  94. reload_gun_2: "subpackage1/sound/reload_gun_2.mp3",
  95. hitcar: "subpackage1/sound/hitcar.mp3",
  96. hitrole: "subpackage1/sound/hitrole.mp3",
  97. hit: "subpackage1/sound/hit.mp3"
  98. };
  99. this.bg = "subpackage1/sound/bgm.mp3";
  100. }
  101. static get Instance() {
  102. return this.instasnce || (this.instasnce = new SettingController());
  103. }
  104. Init() {
  105. var v = Laya.LocalStorage.getItem("vibrate");
  106. this.vibrate = Number(v) ? v == "1" ? true : false : true;
  107. var s = Laya.LocalStorage.getItem("sound");
  108. this.sound = Number(s) ? s == "1" ? true : false : true;
  109. }
  110. SettingSound(value) {
  111. if (this.soundChannel)
  112. this.soundChannel.volume = value;
  113. }
  114. _playMusic(on) {
  115. if (on == null)
  116. on = this.sound;
  117. if (on) {
  118. if (this.soundChannel == null) {
  119. this.soundChannel = SoundManager.playMusic(this.bg, 0, new Laya.Handler(this, () => {
  120. this.soundChannel.play();
  121. }));
  122. }
  123. else {
  124. this.soundChannel.resume();
  125. }
  126. }
  127. else {
  128. if (this.soundChannel) {
  129. this.soundChannel.pause();
  130. }
  131. }
  132. }
  133. SetSoundV(value) {
  134. }
  135. PlaySound(type) {
  136. if (!this.sound)
  137. return;
  138. var _name = SoundType[type];
  139. SoundManager.playSound(this.SoundS[_name]);
  140. }
  141. StopSound(type) {
  142. if (!this.sound)
  143. return;
  144. var _name = SoundType[type];
  145. SoundManager.stopSound(this.SoundS[_name]);
  146. }
  147. }
  148. class Dictionary {
  149. constructor() {
  150. this._container = {};
  151. this._length = 0;
  152. }
  153. get container() {
  154. return this._container;
  155. }
  156. get size() {
  157. return this._length;
  158. }
  159. set(key, value) {
  160. if (!this._container.hasOwnProperty(key)) {
  161. this._length++;
  162. }
  163. this._container[key] = value;
  164. }
  165. delete(key) {
  166. if (this._container.hasOwnProperty(key)) {
  167. delete this._container[key];
  168. this._length--;
  169. }
  170. }
  171. has(key) {
  172. return this._container.hasOwnProperty(key) ? true : false;
  173. }
  174. get(key) {
  175. if (this._container.hasOwnProperty(key)) {
  176. return this._container[key];
  177. }
  178. else {
  179. return undefined;
  180. }
  181. }
  182. clear() {
  183. this._container = {};
  184. this._length = 0;
  185. }
  186. }
  187. class DispatcherManager {
  188. static get Disispatcher() {
  189. return DispatcherManager.disispatcher || (DispatcherManager.disispatcher = new Laya.EventDispatcher());
  190. }
  191. static on(type, call, data) {
  192. this.Disispatcher.on(type, call, data);
  193. }
  194. static off(type, call, data) {
  195. this.Disispatcher.off(type, call, data);
  196. }
  197. static event(type, data = null) {
  198. this.Disispatcher.event(type, data);
  199. }
  200. }
  201. class EventType {
  202. }
  203. EventType.Event = {
  204. CamFollowArg: "CamFollowArg",
  205. SetAimPos: "SetAimPos",
  206. RefreshBulletCount: "RefreshBulletCount",
  207. RefreshRemainEnemyCount: "RefreshRemainEnemyCount",
  208. GameShowTips: "GameShowTips",
  209. StartShot: 'StartShot',
  210. StopShot: 'StopShot',
  211. ShowMainUi: "ShowMainUi",
  212. SetMonery: "SetMonery",
  213. SetStage: "SetStage",
  214. SetStagePro: "SetStagePro"
  215. };
  216. var Vector3 = Laya.Vector3;
  217. class GameTool {
  218. static GetObjKey(obj) {
  219. if (obj == null)
  220. return null;
  221. for (const key in obj) {
  222. if (obj.hasOwnProperty(key)) {
  223. return key;
  224. }
  225. }
  226. }
  227. static randomInt(min, max) {
  228. if (max < min)
  229. return parseInt(min);
  230. return parseInt(Math.random() * (max - min + 1) + min);
  231. }
  232. static randomFl(from, to) {
  233. if (from >= to) {
  234. return 0;
  235. }
  236. var size = to - from;
  237. var curNumber = Math.random() * size + from;
  238. return curNumber;
  239. }
  240. static getAng(xx, yy, obl) {
  241. return 180 / Math.PI * GameTool.getRad(xx, yy, obl);
  242. }
  243. static getRad(xx, yy, obl) {
  244. var rad = yy < 0 ? Math.acos(xx / obl) : (Math.PI * 2 - Math.acos(xx / obl));
  245. return rad;
  246. }
  247. static getM_Vector(v1, v2) {
  248. let temp = new Laya.Vector3();
  249. Laya.Vector3.add(v1, v2, temp);
  250. return new Laya.Vector3(temp.x * 0.5, temp.y * 0.5, temp.z * 0.5);
  251. }
  252. static SpliteString(s, sp) {
  253. var _sp = sp ? sp : ";";
  254. let s_s = s.split(_sp);
  255. let result = [];
  256. for (let i = 0; i < s_s.length; i++) {
  257. result.push(s_s[i]);
  258. }
  259. return result;
  260. }
  261. static random_1to1() {
  262. var iszheng = Math.random() > 0.5 ? -1 : 1;
  263. return Math.random() * iszheng;
  264. }
  265. static GetWeight(s) {
  266. let arr = GameTool.SpliteString(s);
  267. var sum = 0;
  268. for (var i = 0; i < arr.length; i++) {
  269. sum += Number(arr[i]);
  270. }
  271. let result = GameTool.randomInt(1, sum);
  272. let temp_sum = 0;
  273. for (let i = 0; i < arr.length; i++) {
  274. temp_sum += Number(arr[i]);
  275. if (result <= temp_sum) {
  276. return i;
  277. }
  278. }
  279. }
  280. static get64Encode(str) {
  281. var c1, c2, c3;
  282. var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  283. var i = 0, len = str.length, string = '';
  284. while (i < len) {
  285. c1 = str.charCodeAt(i++) & 0xff;
  286. if (i == len) {
  287. string += base64EncodeChars.charAt(c1 >> 2);
  288. string += base64EncodeChars.charAt((c1 & 0x3) << 4);
  289. string += "==";
  290. break;
  291. }
  292. c2 = str.charCodeAt(i++);
  293. if (i == len) {
  294. string += base64EncodeChars.charAt(c1 >> 2);
  295. string += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
  296. string += base64EncodeChars.charAt((c2 & 0xF) << 2);
  297. string += "=";
  298. break;
  299. }
  300. c3 = str.charCodeAt(i++);
  301. string += base64EncodeChars.charAt(c1 >> 2);
  302. string += base64EncodeChars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
  303. string += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6));
  304. string += base64EncodeChars.charAt(c3 & 0x3F);
  305. }
  306. return string;
  307. }
  308. static makeRandomArr(arrList, num) {
  309. if (num > arrList.length) {
  310. return;
  311. }
  312. var tempArr = arrList.slice(0);
  313. var newArrList = [];
  314. for (var i = 0; i < num; i++) {
  315. var random = Math.floor(Math.random() * (tempArr.length - 1));
  316. var arr = tempArr[random];
  317. tempArr.splice(random, 1);
  318. newArrList.push(arr);
  319. }
  320. return newArrList;
  321. }
  322. static CopyArr(o) {
  323. var arr = [];
  324. for (let index = 0; index < o.length; index++) {
  325. const element = o[index];
  326. arr.push(element);
  327. }
  328. return arr;
  329. }
  330. static clamp(n, min, max) {
  331. return n > max ? max : (n < min ? min : n);
  332. }
  333. static GetVecByArr(arr) {
  334. if (!arr)
  335. return null;
  336. var vec = new Vector3();
  337. vec.x = arr[0];
  338. vec.y = arr[1];
  339. vec.z = arr[2];
  340. return vec;
  341. }
  342. static IsNext() {
  343. let uuid = Laya.LocalStorage.getItem("isNext");
  344. if (uuid) {
  345. let lastSignTime = new Date(Number(Laya.LocalStorage.getItem("isNext")));
  346. let todayZero = new Date(Laya.timer.currTimer);
  347. todayZero.setHours(0, 0, 0, 0);
  348. if (lastSignTime.valueOf() < todayZero.valueOf()) {
  349. Laya.LocalStorage.setItem("isNext", Laya.timer.currTimer.toString());
  350. return true;
  351. }
  352. else {
  353. return false;
  354. }
  355. }
  356. else {
  357. Laya.LocalStorage.setItem("isNext", Laya.timer.currTimer.toString());
  358. return true;
  359. }
  360. }
  361. static ToTimeStr1(l) {
  362. let str = "";
  363. let minute = 0;
  364. let second = 0;
  365. second = l;
  366. if (second > 60) {
  367. minute = Math.floor(second / 60);
  368. second = second % 60;
  369. }
  370. str = second < 10 ? "0" + second : second + "";
  371. return (minute + ":" + str);
  372. }
  373. static ToTimeStr(l, isHour = false) {
  374. let hour = 0;
  375. let minute = 0;
  376. let second = 0;
  377. second = l;
  378. if (second > 60) {
  379. minute = Math.floor(second / 60);
  380. second = second % 60;
  381. }
  382. if (isHour && minute > 60) {
  383. hour = Math.floor(minute / 60);
  384. minute = minute % 60;
  385. let ss = second >= 10 ? second + "" : "0" + second.toString();
  386. let mm = minute >= 10 ? minute + "" : "0" + minute.toString();
  387. let hh = hour >= 10 ? hour + "" : "0" + hour.toString();
  388. return (hh + ":" + mm + ":" + ss);
  389. }
  390. else {
  391. if (minute > 60) {
  392. minute = Math.floor(second / 60);
  393. second = second % 60;
  394. }
  395. let ss = second >= 10 ? second + "" : "0" + second.toString();
  396. let mm = minute >= 10 ? minute + "" : "0" + minute.toString();
  397. return (mm + ":" + ss);
  398. }
  399. }
  400. }
  401. class CfgManager {
  402. static get Instance() {
  403. return this.instance || (this.instance = new CfgManager());
  404. }
  405. GetSign(id) {
  406. if (this.sign) {
  407. return this.sign[id - 1];
  408. }
  409. }
  410. GetReward(id) {
  411. if (this.rewards) {
  412. for (let index = 0; index < this.rewards.length; index++) {
  413. const element = this.rewards[index];
  414. if (element.id == id) {
  415. return element;
  416. }
  417. }
  418. }
  419. }
  420. GetMission(id) {
  421. if (this.mission) {
  422. return this.mission[id - 1];
  423. }
  424. return null;
  425. }
  426. GetEnemyTeam(id) {
  427. if (this.enemyteam) {
  428. return this.enemyteam[id - 1];
  429. }
  430. return null;
  431. }
  432. GetRole(id) {
  433. if (this.role) {
  434. return this.role[id - 1];
  435. }
  436. return null;
  437. }
  438. GetLevel(id) {
  439. if (this._level) {
  440. return this._level[id - 1];
  441. }
  442. return null;
  443. }
  444. GetRoad(id) {
  445. if (this._road) {
  446. return this._road[id - 1];
  447. }
  448. return null;
  449. }
  450. GetBlock(id) {
  451. if (this._block) {
  452. return this._block[id - 1];
  453. }
  454. return null;
  455. }
  456. GetThing(id) {
  457. if (this._thing) {
  458. return this._thing[id - 1];
  459. }
  460. return null;
  461. }
  462. GetAtk(id) {
  463. if (this._atk) {
  464. return this._atk[id - 1];
  465. }
  466. return null;
  467. }
  468. GetRate(id) {
  469. if (this._rate) {
  470. return this._rate[id - 1];
  471. }
  472. return null;
  473. }
  474. GetCar(id) {
  475. if (this.car) {
  476. return this.car[id - 1];
  477. }
  478. return null;
  479. }
  480. GetGlobe(key) {
  481. if (this._globe) {
  482. for (let index = 0; index < this._globe.length; index++) {
  483. const element = this._globe[index];
  484. if (element.key == key) {
  485. return element.value;
  486. }
  487. }
  488. }
  489. }
  490. GetTheme(id) {
  491. if (this._theme) {
  492. return this._theme[id - 1];
  493. }
  494. return null;
  495. }
  496. GetLottery(id) {
  497. if (this._lottery) {
  498. return this._lottery[id - 1];
  499. }
  500. return null;
  501. }
  502. GetAchievement(type, level) {
  503. if (this._achievement) {
  504. for (let index = 0; index < this._achievement.length; index++) {
  505. if (this._achievement[index].type == type) {
  506. if (this._achievement[index].level == level) {
  507. return this._achievement[index];
  508. }
  509. }
  510. }
  511. }
  512. }
  513. GetTypeLevel(type) {
  514. var count = 0;
  515. if (this._achievement) {
  516. for (let index = 0; index < this._achievement.length; index++) {
  517. if (this._achievement[index].type == type) {
  518. count++;
  519. }
  520. }
  521. return count;
  522. }
  523. }
  524. GetachieveType() {
  525. if (this._achieveType == null) {
  526. if (this._achievement) {
  527. for (let index = 0; index < this._achievement.length; index++) {
  528. this._achieveType = this._achievement[index].type;
  529. }
  530. }
  531. }
  532. return this._achieveType;
  533. }
  534. }
  535. class AssetPath {
  536. }
  537. AssetPath.main_path = "subpackage/LayaScene_main/Conventional/main.ls";
  538. AssetPath.player_path = ["subpackage/LayaScene_role/Conventional/player1.lh",
  539. "subpackage/LayaScene_role/Conventional/player2.lh",
  540. "subpackage/LayaScene_role/Conventional/player3.lh",
  541. "subpackage/LayaScene_role/Conventional/player4.lh",
  542. "subpackage/LayaScene_role/Conventional/player5.lh",
  543. "subpackage/LayaScene_role/Conventional/player6.lh",
  544. "subpackage/LayaScene_role/Conventional/player7.lh",
  545. ];
  546. AssetPath.enemytexture = [
  547. "subpackage/EnemyTexture/enemy_1.png",
  548. "subpackage/EnemyTexture/enemy_2.png",
  549. "subpackage/EnemyTexture/enemy_3.png",
  550. ];
  551. AssetPath.enemy_path = "subpackage/LayaScene_role/Conventional/enemy.lh";
  552. AssetPath.playerBullet_path = "subpackage/LayaScene_prop/Conventional/PlayerBullet.lh";
  553. AssetPath.tower_path = "subpackage/LayaScene_prop/Conventional/Tower.lh";
  554. AssetPath.barrier_paths = [
  555. "subpackage/LayaScene_barrier/Conventional/barrier_1.lh",
  556. "subpackage/LayaScene_barrier/Conventional/barrier_2.lh",
  557. "subpackage/LayaScene_barrier/Conventional/barrier_3.lh",
  558. "subpackage/LayaScene_barrier/Conventional/barrier_4.lh",
  559. "subpackage/LayaScene_barrier/Conventional/move_barrier.lh",
  560. "subpackage/LayaScene_barrier/Conventional/stone_1.lh",
  561. "subpackage/LayaScene_barrier/Conventional/stone_2.lh",
  562. "subpackage/LayaScene_barrier/Conventional/stone_3.lh",
  563. "subpackage/LayaScene_barrier/Conventional/stone_4.lh",
  564. "subpackage/LayaScene_barrier/Conventional/Block1.lh",
  565. ];
  566. AssetPath.effect_path = [
  567. "subpackage/LayaScene_effect/Conventional/boom.lh",
  568. "subpackage/LayaScene_effect/Conventional/hit.lh",
  569. "subpackage/LayaScene_effect/Conventional/xue.lh",
  570. ];
  571. AssetPath.muchs = [
  572. "100万",
  573. "61万",
  574. "8万",
  575. "16万", "55万",
  576. "123万",
  577. "1004万",
  578. "88万",
  579. "69万",
  580. "90万",
  581. "7万",
  582. "14万",
  583. "6万",
  584. "12万",
  585. ];
  586. AssetPath.tableName = {
  587. level: "level",
  588. road: "road",
  589. block: "block",
  590. thing: "thing",
  591. atk: "atk",
  592. rate: "rate",
  593. global: "global",
  594. theme: "theme"
  595. };
  596. class AppSetting {
  597. }
  598. AppSetting.moveTime = 1;
  599. class PlayerManager {
  600. constructor() {
  601. this.stage = 1;
  602. this.killCount = 0;
  603. this.istry = false;
  604. this.equipId = 1;
  605. }
  606. static get Instance() {
  607. return PlayerManager.instance || (PlayerManager.instance = new PlayerManager());
  608. }
  609. ;
  610. SetTheme() {
  611. }
  612. SetTryOutById(id) {
  613. }
  614. static SetGlobe() {
  615. PlayerManager.tower_reward = Number(CfgManager.Instance.GetGlobe("tower_reward"));
  616. PlayerManager.block_reward = Number(CfgManager.Instance.GetGlobe("block_reward"));
  617. PlayerManager.enemy_reward = Number(CfgManager.Instance.GetGlobe("enemy_reward"));
  618. }
  619. SetPlayer() {
  620. var usermodel = UserModel.Instance.CurModel;
  621. PlayerManager.instance.stage = (Number(usermodel.GetUserAttr(UserAttr.stage)) + 1);
  622. PlayerManager.instance.equipId = Number(usermodel.GetUserAttr(UserAttr.equip_themes)["1"]);
  623. this.SetArr();
  624. }
  625. SetArr() {
  626. let power = UserModel.Instance.CurModel.GetUserAttr(UserAttr.attrs)["power"];
  627. if (power)
  628. this.powerLevel = Number(power);
  629. else
  630. this.powerLevel = 1;
  631. let al = CfgManager.Instance._atk.length;
  632. let t = this.powerLevel > al ? al : this.powerLevel;
  633. PlayerManager.bulletAttack = CfgManager.Instance.GetAtk(t)["atk"];
  634. let rate = UserModel.Instance.CurModel.GetUserAttr(UserAttr.attrs)["rate"];
  635. if (rate)
  636. this.rateLevel = Number(rate);
  637. else
  638. this.rateLevel = 1;
  639. let al1 = CfgManager.Instance._rate.length;
  640. let t1 = this.rateLevel > al1 ? al1 : this.rateLevel;
  641. PlayerManager.bulletTime = CfgManager.Instance.GetRate(t1)["rate"];
  642. }
  643. GradePower(level, chanel, count, callback) {
  644. let param = [{ "t": UserModel.Instance.CurModel.ServerTime }, { "attr": "power" }, { "level": level }, { "channel": chanel }, { "amount": count }];
  645. NetManager.Instance.HttpPostRequest(PROTOCOLS.protocols.UpgradeAttr, param, (data) => {
  646. if (callback)
  647. callback(true);
  648. }, (data) => {
  649. if (callback)
  650. callback(false);
  651. });
  652. }
  653. GradeRate(level, chanel, count, callback) {
  654. let param = [{ "t": UserModel.Instance.CurModel.ServerTime }, { "attr": "rate" }, { "level": level }, { "channel": chanel }, { "amount": count }];
  655. NetManager.Instance.HttpPostRequest(PROTOCOLS.protocols.UpgradeAttr, param, (data) => {
  656. if (callback)
  657. callback(true);
  658. }, (data) => {
  659. if (callback)
  660. callback(false);
  661. });
  662. }
  663. }
  664. PlayerManager.bulletAttack = 1;
  665. PlayerManager.bulletTime = 0.3;
  666. class GlobalVariable {
  667. }
  668. GlobalVariable.playerspeed = 0.1;
  669. GlobalVariable.friendspeed = 0.2;
  670. GlobalVariable.bulletspeed = 0.8;
  671. GlobalVariable.sliderFactor = 0.02;
  672. GlobalVariable.playerMoveMaxX = 4.5;
  673. GlobalVariable.playerRayLengthF = 1.3;
  674. GlobalVariable.playerRayLengthLR = 0.3;
  675. GlobalVariable.bulletRayLength = 1;
  676. GlobalVariable.bulletMaxDis = 40;
  677. GlobalVariable.barrierRoadLength = 50;
  678. GlobalVariable.barrierRoadAverageNum = 50;
  679. GlobalVariable.hitmaxcount = 2;
  680. GlobalVariable.boommaxcount = 2;
  681. GlobalVariable.blockLRmoveMaxDis = 5;
  682. GlobalVariable.arriveStandWidth = 5;
  683. GlobalVariable.enemySpeed = 0.1;
  684. class UserInfoManager {
  685. static GameInfo() {
  686. PlayerManager.Instance.SetPlayer();
  687. }
  688. static SetCfg(cfg) {
  689. CfgManager.Instance._level = cfg[AssetPath.tableName.level];
  690. CfgManager.Instance._road = cfg[AssetPath.tableName.road];
  691. CfgManager.Instance._block = cfg[AssetPath.tableName.block];
  692. CfgManager.Instance._thing = cfg[AssetPath.tableName.thing];
  693. CfgManager.Instance._atk = cfg[AssetPath.tableName.atk];
  694. CfgManager.Instance._rate = cfg[AssetPath.tableName.rate];
  695. CfgManager.Instance._theme = cfg[AssetPath.tableName.theme];
  696. CfgManager.Instance._globe = cfg[AssetPath.tableName.global];
  697. PlayerManager.SetGlobe();
  698. }
  699. static Appseting(data) {
  700. AppSetting.shareimage = data["shareimage"];
  701. AppSetting.sharetitle = data["sharetitle"];
  702. AppSetting.bannerCanMove = Number(data["bannerCanMove"]);
  703. AppSetting.moveTime = Number(data["moveTime"]);
  704. AppSetting.OpenSceneValue = Number(data["OpenSceneValue"]);
  705. AppSetting.freeUpdateVideotime = Number(data["freeUpdateVideotime"]);
  706. AppSetting.freecoinValue = Number(data["freecoinValue"]);
  707. AppSetting.freeGetcoinTime = Number(data["freeGetcoinTime"]);
  708. GlobalVariable.playerspeed = Number(data["playerspeed"]);
  709. GlobalVariable.friendspeed = Number(data["friendspeed"]);
  710. GlobalVariable.bulletspeed = Number(data["bulletspeed"]);
  711. GlobalVariable.sliderFactor = Number(data["sliderFactor"]);
  712. GlobalVariable.playerMoveMaxX = Number(data["playerMoveMaxX"]);
  713. GlobalVariable.playerRayLengthF = Number(data["playerRayLengthF"]);
  714. GlobalVariable.playerRayLengthLR = Number(data["playerRayLengthLR"]);
  715. GlobalVariable.bulletRayLength = Number(data["bulletRayLength"]);
  716. GlobalVariable.bulletMaxDis = Number(data["bulletMaxDis"]);
  717. GlobalVariable.barrierRoadLength = Number(data["barrierRoadLength"]);
  718. GlobalVariable.barrierRoadAverageNum = Number(data["barrierRoadAverageNum"]);
  719. GlobalVariable.hitmaxcount = Number(data["hitmaxcount"]);
  720. GlobalVariable.boommaxcount = Number(data["boommaxcount"]);
  721. GlobalVariable.blockLRmoveMaxDis = Number(data["blockLRmoveMaxDis"]);
  722. GlobalVariable.arriveStandWidth = Number(data["arriveStandWidth"]);
  723. GlobalVariable.enemySpeed = Number(data["enemySpeed"]);
  724. }
  725. }
  726. var Event = Laya.Event;
  727. var HttpRequest = Laya.HttpRequest;
  728. const PROTOCOL_URL = "https://gungangapi.xwxgame.com/";
  729. class PROTOCOLS {
  730. }
  731. PROTOCOLS.protocols = {
  732. Login: "user/login",
  733. Userauth: "user/auth",
  734. BuyLand: "shop/land",
  735. UserSync: "user/sync",
  736. ShopBuild: "shop/build",
  737. ShopUpgrade: "shop/upgrade",
  738. ShopSale: "shop/sale",
  739. RoleUpgrade: "role/upgrade",
  740. Fissionvd: "fission/vd",
  741. DailyTaskrefresh: "dailytask/refresh",
  742. DailyTaskrewards: "dailytask/rewards",
  743. Rankingvmoney: "ranking/vmoney",
  744. Lotterylottery: "lottery/lottery",
  745. AchievementgetRewards: "achievement/getRewards",
  746. Fissiondeduct: "fission/deduct",
  747. Sign: "sign/sign",
  748. InvitegetRewards: "invite/getRewards",
  749. InvitetargetRewards: "invite/targetRewards",
  750. GameResult: "game/play",
  751. Easter: "game/revival",
  752. GetCfg: "config/table",
  753. DoubleAward: "fission/vd",
  754. KunDiscard: "kun/discard",
  755. KunEquip: "kun/equip",
  756. KunMove: "kun/move",
  757. KunBuy: "kun/buy",
  758. Opentreasure: "treasure/open",
  759. Entertreasure: "treasure/enter",
  760. Buy: "theme/buy",
  761. Equip: "theme/equip",
  762. themefission: "theme/fission",
  763. Start: "game/start",
  764. UpgradeAttr: "attr/upgrade"
  765. };
  766. class NetManager {
  767. PostTokenRequest(protocol, completecb, errorcb, isload = true) {
  768. let args = "";
  769. let url = PROTOCOL_URL + protocol;
  770. args = args = `token=${UserModel.Instance.CurModel.m_token}`;
  771. let httpRequest = new HttpRequest();
  772. httpRequest.once(Event.COMPLETE, this, this.onHttpRequestComplete, [completecb, errorcb, httpRequest, isload]);
  773. httpRequest.once(Event.ERROR, this, this.onHttpRequestError, [errorcb, httpRequest]);
  774. httpRequest.send(url, args, "post", "text");
  775. if (isload) {
  776. WXSdk.ShowLoading("");
  777. }
  778. }
  779. onHttpRequestComplete(succeedcb, failurecb, httpRequest, isload) {
  780. let data;
  781. if (isload) {
  782. WXSdk.HideLoading();
  783. }
  784. data = JSON.parse(httpRequest.data);
  785. console.log("请求成功:" + JSON.stringify(data));
  786. if (data["code"] == 0) {
  787. UserModel.Instance.RefreshModel(data);
  788. if (succeedcb != null) {
  789. succeedcb(data);
  790. }
  791. }
  792. else {
  793. if (failurecb != null) {
  794. var mess = GameTool.SpliteString(data["message"], ",")[0];
  795. failurecb(mess);
  796. }
  797. }
  798. }
  799. onHttpRequestError(errorcb, httpRequest, isload) {
  800. if (errorcb != null) {
  801. var data = JSON.parse(httpRequest.data);
  802. errorcb(data);
  803. }
  804. console.log("Error! Http request error, code: " + data);
  805. if (isload) {
  806. WXSdk.HideLoading();
  807. }
  808. }
  809. static get Instance() {
  810. return NetManager.instance || (NetManager.instance = new NetManager());
  811. }
  812. login(progresscb, completecb, errorcb) {
  813. console.log("发送登录请求");
  814. var userInfor = UserModel.Instance;
  815. var ver = GameSetting.VER;
  816. let args = `code=${userInfor.m_code}&nickname=${userInfor.m_nickname}&avatar=${userInfor.m_avatar}&gender=${userInfor.m_gender}&country=${userInfor.m_country}&province=${userInfor.m_province}&city=${userInfor.m_city}&device=${userInfor.m_device}&share_id=${userInfor.m_share_id}&scene=${userInfor.channel}&v=${ver}`;
  817. console.log("登录 参数: " + args);
  818. let httpRequest = new HttpRequest();
  819. httpRequest.once(Event.PROGRESS, this, this.onHttpRequestProgress, [progresscb, httpRequest]);
  820. httpRequest.once(Event.COMPLETE, this, this.onLoginRequestComplete, [completecb, httpRequest]);
  821. httpRequest.once(Event.ERROR, this, this.onHttpRequestError, [errorcb, httpRequest]);
  822. httpRequest.send(PROTOCOL_URL + PROTOCOLS.protocols.Login, args, "post", "text");
  823. }
  824. onHttpRequestProgress() {
  825. }
  826. onLoginRequestComplete(completecb, httpRequest) {
  827. let data = JSON.parse(httpRequest.data);
  828. console.log(data);
  829. console.log("登录完成");
  830. if (data["code"] != "0") {
  831. var errInfo = JSON.stringify(httpRequest.data);
  832. console.log("登录异常错误!错误信息:", errInfo);
  833. completecb(data);
  834. return;
  835. }
  836. UserModel.Instance.SetUserModel(new NetUserModel(data["token"], data["configs"], data["app_setting"], data["user"], data["user_base"], data["user_invite"], data["user_lottery"], data["user_treasure"], data["t"], data["user_achievement"], data["user_sign"], data["user_arena"], data["is_new"], data["user_shop"], data["user_daily_task"], data["user_video"]));
  837. UserInfoManager.Appseting(data["app_setting"]);
  838. var ver = data["table_version"];
  839. UserModel.Instance.CurModel.JundgCfg(ver, (c) => {
  840. if (c) {
  841. UserInfoManager.GameInfo();
  842. completecb(data);
  843. }
  844. });
  845. WXSdk.ShareMessage();
  846. }
  847. PostCfgRequest(completecb, errorcb) {
  848. let args = "";
  849. let url = PROTOCOL_URL + PROTOCOLS.protocols.GetCfg;
  850. args = `token=${UserModel.Instance.CurModel.m_token}`;
  851. let httpRequest = new HttpRequest();
  852. httpRequest.once(Event.COMPLETE, this, () => {
  853. var data = JSON.parse(httpRequest.data);
  854. if (data["code"] == 0) {
  855. if (completecb != null) {
  856. if (data["configs"]) {
  857. completecb(data["configs"]);
  858. }
  859. }
  860. }
  861. else {
  862. if (errorcb != null) {
  863. errorcb(data);
  864. }
  865. }
  866. });
  867. httpRequest.once(Event.ERROR, this, () => {
  868. var data = JSON.parse(httpRequest.data);
  869. if (errorcb != null) {
  870. errorcb(data);
  871. }
  872. });
  873. httpRequest.send(url, args, "post", "text");
  874. }
  875. HttpPostRequest(protocol, param, completecb, errorcb, hasToken = true, isload = true) {
  876. let args = "";
  877. let url = PROTOCOL_URL + protocol;
  878. if (hasToken == true) {
  879. args = `token=${UserModel.Instance.CurModel.m_token}&`;
  880. }
  881. if (protocol == PROTOCOLS.protocols.UserSync || protocol == PROTOCOLS.protocols.Fissionvd || protocol == PROTOCOLS.protocols.Lotterylottery
  882. || protocol == PROTOCOLS.protocols.Fissiondeduct || protocol == PROTOCOLS.protocols.KunBuy || protocol == PROTOCOLS.protocols.KunDiscard
  883. || protocol == PROTOCOLS.protocols.KunEquip || protocol == PROTOCOLS.protocols.KunMove || protocol == PROTOCOLS.protocols.Start || protocol == PROTOCOLS.protocols.GameResult
  884. || protocol == PROTOCOLS.protocols.themefission || protocol == PROTOCOLS.protocols.Opentreasure || protocol == PROTOCOLS.protocols.UpgradeAttr) {
  885. let str = "abcdefghijkimnopqrstuvwxyz0123456789";
  886. let code = "{";
  887. let mask = "";
  888. for (let i = 0; i < 4; i++) {
  889. mask += str[Math.floor(Math.random() * 100) % str.length];
  890. }
  891. for (let i = 0; i < param.length; i++) {
  892. for (let key in param[i]) {
  893. code += "\"" + key + "\":";
  894. if (typeof param[i][key] === 'string') {
  895. code += "\"" + param[i][key] + "\"";
  896. }
  897. else {
  898. code += param[i][key];
  899. }
  900. }
  901. if (i < param.length - 1) {
  902. code += ",";
  903. }
  904. else {
  905. code += "}";
  906. }
  907. }
  908. args += "_r=" + mask + GameTool.get64Encode(code);
  909. }
  910. else {
  911. if (param != null) {
  912. for (let i = 0; i < param.length; i++) {
  913. for (let key in param[i]) {
  914. let val = param[i][key];
  915. args += `${key}=${val}`;
  916. if (i < param.length - 1) {
  917. args += "&";
  918. }
  919. }
  920. }
  921. }
  922. }
  923. let httpRequest = new HttpRequest();
  924. httpRequest.once(Event.COMPLETE, this, this.onHttpRequestComplete, [completecb, errorcb, httpRequest, isload]);
  925. httpRequest.once(Event.ERROR, this, this.onHttpRequestError, [errorcb, httpRequest, isload]);
  926. httpRequest.send(url, args, "post", "text");
  927. if (isload) {
  928. WXSdk.ShowLoading("");
  929. }
  930. }
  931. static errorRequest(arg, callback) {
  932. let httpRequest = new Laya.HttpRequest();
  933. if (callback) {
  934. httpRequest.once(Laya.Event.PROGRESS, this, () => { callback.progress && callback.progress(httpRequest); });
  935. httpRequest.once(Laya.Event.ERROR, this, () => { callback.error && callback.error(httpRequest); });
  936. httpRequest.once(Laya.Event.COMPLETE, this, () => { callback.complete && callback.complete(httpRequest); });
  937. }
  938. httpRequest.send("https://r.94xj.net/e", arg, "post", "json", ["Content-Type", "application/json"]);
  939. }
  940. static ErrorReport() {
  941. let arg = {
  942. "code": 1003,
  943. "msg": "invalid code",
  944. "user_id": 0,
  945. "game": "parkourrace",
  946. "type": "backend",
  947. "platform": "weixin"
  948. };
  949. this.errorRequest(arg, {
  950. complete: (request) => {
  951. },
  952. error: (request) => {
  953. }
  954. });
  955. }
  956. }
  957. var UserConfigName;
  958. (function (UserConfigName) {
  959. UserConfigName[UserConfigName["train"] = 0] = "train";
  960. UserConfigName[UserConfigName["sign"] = 1] = "sign";
  961. UserConfigName[UserConfigName["rewards"] = 2] = "rewards";
  962. })(UserConfigName || (UserConfigName = {}));
  963. var UserAttr;
  964. (function (UserAttr) {
  965. UserAttr[UserAttr["user_id"] = 0] = "user_id";
  966. UserAttr[UserAttr["diamond"] = 1] = "diamond";
  967. UserAttr[UserAttr["energy"] = 2] = "energy";
  968. UserAttr[UserAttr["list_kun"] = 3] = "list_kun";
  969. UserAttr[UserAttr["stage"] = 4] = "stage";
  970. UserAttr[UserAttr["vmoney"] = 5] = "vmoney";
  971. UserAttr[UserAttr["equip_kun"] = 6] = "equip_kun";
  972. UserAttr[UserAttr["unlock_kun"] = 7] = "unlock_kun";
  973. UserAttr[UserAttr["buyed_kun"] = 8] = "buyed_kun";
  974. UserAttr[UserAttr["money"] = 9] = "money";
  975. UserAttr[UserAttr["progress_themes"] = 10] = "progress_themes";
  976. UserAttr[UserAttr["equip_themes"] = 11] = "equip_themes";
  977. UserAttr[UserAttr["get_themes"] = 12] = "get_themes";
  978. UserAttr[UserAttr["attrs"] = 13] = "attrs";
  979. })(UserAttr || (UserAttr = {}));
  980. class NetUserModel {
  981. constructor(_token, _config, _appSetting, _user, _userbase, _useInvite, _user_lottery, _user_treasure, t, _user_achievement, _user_sign, _user_arena, is_new, user_shop, user_daily_task, user_video) {
  982. this.loginSeverTime = 0;
  983. this.m_avatar = "";
  984. this.localTime = Laya.timer.currTimer;
  985. this.loginSeverTime = t;
  986. this.m_token = _token;
  987. this.m_user = _user;
  988. this.m_base = _userbase;
  989. this.m_invite = _useInvite;
  990. this.m_lottery = _user_lottery;
  991. this.m_treasure = _user_treasure;
  992. this.m_achievement = _user_achievement;
  993. this.m_sign = _user_sign;
  994. this.m_arena = _user_arena;
  995. this.m_shop = user_shop;
  996. this.user_video = user_video;
  997. this.user_daily_task = user_daily_task;
  998. this.m_userid = this.m_user["user_id"];
  999. this.m_openid = this.m_base["openid"];
  1000. this.m_nickname = this.m_base["nickname"];
  1001. this.is_new = Number(is_new);
  1002. }
  1003. GetUserAttr(_attr) {
  1004. var attr = UserAttr[_attr];
  1005. return this.m_user[attr];
  1006. }
  1007. get ServerTime() {
  1008. let time = Laya.timer.currTimer;
  1009. let stime = this.loginSeverTime + Math.ceil((time - this.localTime) / 1000);
  1010. return stime;
  1011. }
  1012. HasTheme(_id) {
  1013. var data = this.GetUserAttr(UserAttr.get_themes);
  1014. for (var i = 0; i < data.length; i++) {
  1015. var hd = data[i];
  1016. if (_id == hd) {
  1017. return true;
  1018. }
  1019. }
  1020. return false;
  1021. }
  1022. GetThemeProgress(_id) {
  1023. var config = this.GetUserAttr(UserAttr.progress_themes);
  1024. var progress = config[_id] ? config[_id] : 0;
  1025. return progress;
  1026. }
  1027. JundgCfg(ver, callball) {
  1028. var cfg = Laya.LocalStorage.getJSON(GameSetting.CFG);
  1029. if (cfg) {
  1030. if (cfg.VER == ver) {
  1031. console.log("已经拥有,不用更新");
  1032. UserInfoManager.SetCfg(cfg);
  1033. callball(true);
  1034. }
  1035. else {
  1036. console.log("cfg存在但是过期了");
  1037. Laya.LocalStorage.removeItem(GameSetting.CFG);
  1038. NetManager.Instance.PostCfgRequest((data) => {
  1039. data.VER = ver;
  1040. Laya.LocalStorage.setJSON(GameSetting.CFG, data);
  1041. UserInfoManager.SetCfg(data);
  1042. callball(true);
  1043. }, (data) => {
  1044. console.log("配置获取失败" + data);
  1045. callball(false);
  1046. return;
  1047. });
  1048. }
  1049. }
  1050. else {
  1051. console.log("本地没有cfg");
  1052. NetManager.Instance.PostCfgRequest((data) => {
  1053. console.log("cfg" + data);
  1054. data.VER = ver;
  1055. Laya.LocalStorage.setJSON(GameSetting.CFG, data);
  1056. UserInfoManager.SetCfg(data);
  1057. callball(true);
  1058. }, (data) => {
  1059. console.log("配置获取失败" + data);
  1060. });
  1061. }
  1062. }
  1063. }
  1064. class UserModel {
  1065. get CurModel() {
  1066. return this.curModel;
  1067. }
  1068. constructor(code, nickname, avatar, gender, country, province, city, device, share_id, channel) {
  1069. UserModel.instance = this;
  1070. this.m_code = code;
  1071. this.m_nickname = nickname ? nickname : "";
  1072. this.m_avatar = avatar ? avatar : "";
  1073. this.m_gender = gender ? gender : 0;
  1074. this.m_city = city ? city : "";
  1075. this.m_device = device ? device : "";
  1076. this.m_share_id = share_id ? share_id : "";
  1077. this.channel = channel ? channel : "";
  1078. this.m_country = country ? country : "";
  1079. this.m_province = province ? province : "";
  1080. }
  1081. static get Instance() {
  1082. if (UserModel.instance) {
  1083. return UserModel.instance;
  1084. }
  1085. else {
  1086. UserModel.instance = new UserModel("11", "", "", 0, "", "", "", "", "", "");
  1087. return UserModel.instance;
  1088. }
  1089. }
  1090. SetUserModel(_model) {
  1091. this.curModel = _model;
  1092. }
  1093. RefreshModel(data) {
  1094. if (data["user"])
  1095. this.curModel.m_user = data["user"];
  1096. if (data["user_invite"])
  1097. this.curModel.m_invite = data["user_invite"];
  1098. if (data["user_lottery"])
  1099. this.curModel.m_lottery = data["user_lottery"];
  1100. if (data["user_achievement"]) {
  1101. this.curModel.m_achievement = data["user_achievement"];
  1102. }
  1103. if (data["user_sign"])
  1104. this.curModel.m_sign = data["user_sign"];
  1105. if (data["user_shop"])
  1106. this.curModel.m_shop = data["user_shop"];
  1107. if (data["user_daily_task"])
  1108. this.curModel.user_daily_task = data["user_daily_task"];
  1109. if (data["user_video"])
  1110. this.curModel.user_video = data["user_video"];
  1111. }
  1112. }
  1113. var Sprite3D = Laya.Sprite3D;
  1114. var PoolType;
  1115. (function (PoolType) {
  1116. PoolType[PoolType["WarnTips"] = 1] = "WarnTips";
  1117. PoolType[PoolType["HpText"] = 2] = "HpText";
  1118. })(PoolType || (PoolType = {}));
  1119. class GamePool {
  1120. constructor() {
  1121. this.poolDic = new Dictionary();
  1122. this.prefabDic = new Dictionary();
  1123. this.singleobjDic = new Dictionary();
  1124. }
  1125. static get Instance() {
  1126. return GamePool.instance || (GamePool.instance = new GamePool());
  1127. }
  1128. InitData(name, prefab) {
  1129. if (prefab != null) {
  1130. if (!this.prefabDic.has(name))
  1131. this.prefabDic.set(name, prefab);
  1132. }
  1133. }
  1134. HasSprInPool(name) {
  1135. return this.prefabDic.has(name);
  1136. }
  1137. SetActiveObject(name) {
  1138. if (name == "PlayerBullet")
  1139. GamePool.bulletCount++;
  1140. if (this.poolDic.has(name)) {
  1141. if (this.poolDic.get(name).length > 0) {
  1142. var result = this.poolDic.get(name).shift();
  1143. result.active = true;
  1144. return result;
  1145. }
  1146. else {
  1147. if (this.prefabDic.has(name)) {
  1148. var curObj = Sprite3D.instantiate(this.prefabDic.get(name));
  1149. curObj.name = name;
  1150. console.log("正在克隆中>>>>>" + name + "__id:" + curObj.id);
  1151. return curObj;
  1152. }
  1153. else {
  1154. return null;
  1155. }
  1156. }
  1157. }
  1158. else {
  1159. if (this.prefabDic.has(name)) {
  1160. var curObj = Sprite3D.instantiate(this.prefabDic.get(name));
  1161. curObj.name = name;
  1162. console.log("正在克隆中>>>>>" + name + "__id:" + curObj.id);
  1163. return curObj;
  1164. }
  1165. else {
  1166. return null;
  1167. }
  1168. }
  1169. }
  1170. SetActiveForUi(type) {
  1171. if (this.singleobjDic.has(type)) {
  1172. if (this.singleobjDic.get(type).length > 0) {
  1173. var result = this.singleobjDic.get(type).shift();
  1174. result.visible = true;
  1175. return result;
  1176. }
  1177. else {
  1178. return this.GetByType(type);
  1179. }
  1180. }
  1181. else {
  1182. return this.GetByType(type);
  1183. }
  1184. }
  1185. GetByType(type) {
  1186. if (type == PoolType.WarnTips) {
  1187. var _t = new Laya.Text();
  1188. _t.width = 720;
  1189. _t.height = 60;
  1190. _t.align = "center";
  1191. _t.valign = "middle";
  1192. _t.fontSize = 35;
  1193. _t.bold = true;
  1194. _t.pivotX = 360;
  1195. _t.pivotY = 30;
  1196. _t.color = "#ffffff";
  1197. _t.stroke = 5;
  1198. _t.strokeColor = "#000000";
  1199. return _t;
  1200. }
  1201. else if (type == PoolType.HpText) {
  1202. var _t = new Laya.Text();
  1203. _t.font = "Microsoft YaHei";
  1204. _t.width = 260;
  1205. _t.height = 50;
  1206. _t.align = "center";
  1207. _t.valign = "middle";
  1208. _t.fontSize = 30;
  1209. _t.bold = true;
  1210. _t.pivotX = 130;
  1211. _t.pivotY = 25;
  1212. _t.color = "#ffffff";
  1213. return _t;
  1214. }
  1215. }
  1216. SetDisableForUi(type, go) {
  1217. go.visible = false;
  1218. go.removeSelf();
  1219. if (!this.singleobjDic.has(type)) {
  1220. this.singleobjDic.set(type, new Array());
  1221. }
  1222. this.singleobjDic.get(type).push(go);
  1223. }
  1224. SetDisableObject(go) {
  1225. if (!go)
  1226. return;
  1227. go.active = false;
  1228. go.removeSelf();
  1229. var key = go.name;
  1230. if (!this.poolDic.has(key)) {
  1231. this.poolDic.set(key, new Array());
  1232. }
  1233. this.poolDic.get(key).push(go);
  1234. }
  1235. SetDisableMutiObject(go, timer) {
  1236. Laya.timer.once(timer, this, () => {
  1237. if (go)
  1238. go.active = false;
  1239. var key = go.name;
  1240. if (!this.poolDic.has(key)) {
  1241. this.poolDic.set(key, new Array());
  1242. }
  1243. this.poolDic.get(key).push(go);
  1244. });
  1245. }
  1246. }
  1247. GamePool.pooltype = {
  1248. Tower: "Tower",
  1249. PlayerBullet: "PlayerBullet",
  1250. player: "player",
  1251. enemy: "enemy"
  1252. };
  1253. GamePool.bulletCount = 0;
  1254. class Mathf {
  1255. static GetData(value) {
  1256. var theTime = Math.floor(value);
  1257. var theTime1 = 0;
  1258. var theTime2 = 0;
  1259. var theTime3 = 0;
  1260. if (theTime > 60) {
  1261. theTime1 = Math.floor(theTime / 60);
  1262. theTime = theTime % 60;
  1263. if (theTime1 > 60) {
  1264. theTime2 = Math.floor(theTime1 / 60);
  1265. theTime1 = theTime1 % 60;
  1266. if (theTime2 > 24) {
  1267. theTime3 = Math.floor(theTime2 / 24);
  1268. theTime2 = theTime2 % 24;
  1269. }
  1270. }
  1271. }
  1272. var result = '';
  1273. result = "" + theTime1 + "分" + result;
  1274. result = "" + theTime2 + "时" + result;
  1275. result = "" + theTime3 + "天" + result;
  1276. return result;
  1277. }
  1278. static GetNumAccuracy(num) {
  1279. var b = Math.ceil(num * 10) / 10;
  1280. if (Math.abs(b - num) < 0.0001) {
  1281. return b;
  1282. }
  1283. var a = Math.floor(num * 10) / 10;
  1284. if (Math.abs(a - num) < 0.0001) {
  1285. return a;
  1286. }
  1287. return num;
  1288. }
  1289. static get VecZero() {
  1290. return new Laya.Vector3();
  1291. }
  1292. static RandomNumber(from, to) {
  1293. if (from >= to) {
  1294. return 0;
  1295. }
  1296. var size = to - from;
  1297. var curNumber = Math.random() * size + from;
  1298. return curNumber;
  1299. }
  1300. static SpToCam(v3) {
  1301. v3.x = -v3.x;
  1302. v3.y = v3.y - 180;
  1303. v3.z = -v3.z;
  1304. return v3;
  1305. }
  1306. static get Gravity() {
  1307. return new Laya.Vector3(0, -10, 0);
  1308. }
  1309. static MixVector3(from, to, t, res = null) {
  1310. if (res == null) {
  1311. res = this.m_mixVector;
  1312. }
  1313. res.x = Mathf.MixNumber(from.x, to.x, t);
  1314. res.y = Mathf.MixNumber(from.y, to.y, t);
  1315. res.z = Mathf.MixNumber(from.z, to.z, t);
  1316. return res;
  1317. }
  1318. static MixVector4(from, to, t, res) {
  1319. res.x = Mathf.MixNumber(from.x, to.x, t);
  1320. res.y = Mathf.MixNumber(from.y, to.y, t);
  1321. res.z = Mathf.MixNumber(from.z, to.z, t);
  1322. res.w = Mathf.MixNumber(from.w, to.w, t);
  1323. return res;
  1324. }
  1325. static MixNumber(from, to, t) {
  1326. t = Mathf.Clamp(t, 0, 1);
  1327. from = (to - from) * t + from;
  1328. return from;
  1329. }
  1330. static Clamp(value, from, to) {
  1331. if (value < from) {
  1332. value = from;
  1333. }
  1334. if (value > to) {
  1335. value = to;
  1336. }
  1337. return value;
  1338. }
  1339. }
  1340. Mathf.m_mixVector = new Laya.Vector3();
  1341. class FollowNumber {
  1342. constructor(t, from = 0, to = 0, tiny = 0) {
  1343. this.m_t = 0;
  1344. this.target = 0;
  1345. this.follow = 0;
  1346. this.m_tiny = 0;
  1347. this.m_t = t;
  1348. this.target = to;
  1349. this.follow = from;
  1350. this.m_tiny = tiny;
  1351. }
  1352. ChangeT(value) {
  1353. this.m_t = value;
  1354. }
  1355. get t() { return this.m_t; }
  1356. update() {
  1357. this.follow = Mathf.MixNumber(this.follow, this.target, this.m_t);
  1358. if (this.m_tiny != 0 && this.target != this.follow) {
  1359. if (Math.abs(this.target - this.follow) <= this.m_tiny) {
  1360. this.follow = this.target;
  1361. }
  1362. }
  1363. }
  1364. }
  1365. var ColliderGroup;
  1366. (function (ColliderGroup) {
  1367. ColliderGroup[ColliderGroup["mound"] = 8] = "mound";
  1368. ColliderGroup[ColliderGroup["wall"] = 9] = "wall";
  1369. ColliderGroup[ColliderGroup["opponent"] = 10] = "opponent";
  1370. ColliderGroup[ColliderGroup["obstacle1"] = 11] = "obstacle1";
  1371. ColliderGroup[ColliderGroup["obstacle2"] = 12] = "obstacle2";
  1372. ColliderGroup[ColliderGroup["obstacle3"] = 13] = "obstacle3";
  1373. })(ColliderGroup || (ColliderGroup = {}));
  1374. class MusicType {
  1375. }
  1376. MusicType.Idle = "Idle";
  1377. MusicType.CrouchFiring = "CrouchFiring";
  1378. MusicType.Dance = "Dance";
  1379. MusicType.RunAndGun = "RunAndGun";
  1380. MusicType.RunningHysteric = "RunningHysteric";
  1381. class CameraManager {
  1382. static get Instance() {
  1383. return this.instance || (this.instance = new CameraManager());
  1384. }
  1385. Init(cam, startPos) {
  1386. this.startPosTra = startPos.transform;
  1387. if (cam) {
  1388. this._camer = cam;
  1389. this.Camera = this._camer.addComponent(Camera);
  1390. this.Camera.Init();
  1391. }
  1392. }
  1393. SetCamState(type, arg) {
  1394. if (this.Camera)
  1395. this.Camera.SetCameraByState(type, arg);
  1396. }
  1397. CameraMoveIngame(z) {
  1398. if (this.Camera)
  1399. this.Camera.MoveGame(z);
  1400. }
  1401. }
  1402. class ConstructManager {
  1403. constructor() {
  1404. this.tarDis = 100;
  1405. this.buildArr = [];
  1406. }
  1407. static get Instance() {
  1408. return this.instance || (this.instance = new ConstructManager());
  1409. }
  1410. Init(builds) {
  1411. this.buildArr.push(builds.getChildAt(1));
  1412. this.buildArr.push(builds.getChildAt(0));
  1413. }
  1414. SetBuild() {
  1415. for (let index = this.buildArr.length - 1; index >= 0; index--) {
  1416. const element = this.buildArr[index];
  1417. element.transform.localPositionZ = (1 - index) * 100;
  1418. }
  1419. this.tarDis = 70;
  1420. }
  1421. CheckPlayerRoadPos(_zp) {
  1422. let d = this.tarDis - _zp;
  1423. if (d > 0)
  1424. return;
  1425. this.SwitchRoad();
  1426. }
  1427. SwitchRoad() {
  1428. let rs = this.buildArr.pop();
  1429. rs.transform.localPositionZ = this.tarDis + 30 + 100;
  1430. this.buildArr.unshift(rs);
  1431. this.tarDis = this.tarDis + 100;
  1432. }
  1433. }
  1434. class Level {
  1435. constructor() {
  1436. this.road_list = [];
  1437. this.fail_gold = 0;
  1438. }
  1439. SetLevel(data) {
  1440. this.road_list = GameTool.SpliteString(data["road_list"]);
  1441. this.gold = Number(data["gold"]);
  1442. this.fail_gold = Number(data["fail_gold"]);
  1443. this.enemy = data["enemy"];
  1444. this.enemy_hp = data["enemy_hp"];
  1445. this.isgold = Number(data["isgold"]) == 1;
  1446. this.enemy_cloth = data["enemy_cloth"] ? Number(data["enemy_cloth"]) : 1;
  1447. }
  1448. }
  1449. class LevelController {
  1450. static get Instance() {
  1451. return LevelController.instance || (LevelController.instance = new LevelController());
  1452. }
  1453. SetLevel(level) {
  1454. let len = CfgManager.Instance._level.length;
  1455. let index = PlayerManager.Instance.stage;
  1456. if (PlayerManager.Instance.stage > len)
  1457. index = GameTool.randomInt(1, len);
  1458. this.curLevelData = CfgManager.Instance.GetLevel(index);
  1459. if (!this._level)
  1460. this._level = new Level();
  1461. this._level.SetLevel(this.curLevelData);
  1462. }
  1463. }
  1464. class MoundManager {
  1465. static get Instance() {
  1466. return this.instance || (this.instance = new MoundManager());
  1467. }
  1468. constructor() {
  1469. this.towerDic = new Dictionary();
  1470. }
  1471. Init(da) {
  1472. this.towerContainer = da;
  1473. }
  1474. CreateTower(data) {
  1475. let tower = GamePool.Instance.SetActiveObject(GamePool.pooltype.Tower);
  1476. if (!tower)
  1477. return;
  1478. this.towerContainer.addChild(tower);
  1479. let ts = tower.getComponent(Mound);
  1480. if (!ts)
  1481. ts = tower.addComponent(Mound);
  1482. ts.SetTower(data);
  1483. this.towerDic.set(tower.id, ts);
  1484. }
  1485. RemoveTower(sp) {
  1486. this.towerDic.delete(sp.id);
  1487. }
  1488. CreateHpText() {
  1489. return GamePool.Instance.SetActiveForUi(PoolType.HpText);
  1490. }
  1491. Reset() {
  1492. let arr = [];
  1493. for (const key in this.towerDic.container) {
  1494. arr.push(key);
  1495. }
  1496. if (arr.length > 0) {
  1497. for (let index = 0; index < arr.length; index++) {
  1498. const element = arr[index];
  1499. let s = this.towerDic.get(element);
  1500. if (s)
  1501. s.Des();
  1502. }
  1503. }
  1504. console.log("this.towerDic.size", this.towerDic.size);
  1505. }
  1506. }
  1507. class MatrixTransform {
  1508. static WorldToScreen2(camera, point) {
  1509. var pointA = this.InverseTransformPoint(camera.transform, point);
  1510. var distance = pointA.z;
  1511. var out = new Laya.Vector3();
  1512. camera.viewport.project(point, camera.projectionViewMatrix, out);
  1513. var value = new Laya.Vector3(out.x / Laya.stage.clientScaleX, out.y / Laya.stage.clientScaleY, distance);
  1514. return value;
  1515. }
  1516. static ScreenToWorld(camera, point) {
  1517. var halfFOV = (camera.fieldOfView * 0.5) * Math.PI / 180;
  1518. let height = point.z * Math.tan(halfFOV);
  1519. let width = height * camera.aspectRatio;
  1520. let lowerLeft = this.GetLowerLeft(camera.transform, point.z, width, height);
  1521. let v = this.GetScreenScale(width, height);
  1522. var value = new Laya.Vector3();
  1523. var lowerLeftA = this.InverseTransformPoint(camera.transform, lowerLeft);
  1524. value = new Laya.Vector3(-point.x / v.x, point.y / v.y, 0);
  1525. Laya.Vector3.add(lowerLeftA, value, value);
  1526. value = this.TransformPoint(camera.transform, value);
  1527. return value;
  1528. }
  1529. static GetScreenScale(width, height) {
  1530. var v = new Laya.Vector3();
  1531. v.x = Laya.stage.width / width / 2;
  1532. v.y = Laya.stage.height / height / 2;
  1533. return v;
  1534. }
  1535. static GetLowerLeft(transform, distance, width, height) {
  1536. var lowerLeft = new Laya.Vector3();
  1537. var right = new Laya.Vector3();
  1538. transform.getRight(right);
  1539. Laya.Vector3.normalize(right, right);
  1540. var xx = new Laya.Vector3(right.x * width, right.y * width, right.z * width);
  1541. Laya.Vector3.add(transform.position, xx, lowerLeft);
  1542. var up = new Laya.Vector3();
  1543. transform.getUp(up);
  1544. Laya.Vector3.normalize(up, up);
  1545. var yy = new Laya.Vector3(up.x * height, up.y * height, up.z * height);
  1546. Laya.Vector3.subtract(lowerLeft, yy, lowerLeft);
  1547. var forward = new Laya.Vector3();
  1548. transform.getForward(forward);
  1549. Laya.Vector3.normalize(forward, forward);
  1550. var zz = new Laya.Vector3(forward.x * distance, forward.y * distance, forward.z * distance);
  1551. Laya.Vector3.subtract(lowerLeft, zz, lowerLeft);
  1552. return lowerLeft;
  1553. }
  1554. static InverseTransformPoint(origin, point) {
  1555. var xx = new Laya.Vector3();
  1556. origin.getRight(xx);
  1557. var yy = new Laya.Vector3();
  1558. origin.getUp(yy);
  1559. var zz = new Laya.Vector3();
  1560. origin.getForward(zz);
  1561. var zz1 = new Laya.Vector3(-zz.x, -zz.y, -zz.z);
  1562. var x = this.ProjectDistance(point, origin.position, xx);
  1563. var y = this.ProjectDistance(point, origin.position, yy);
  1564. var z = this.ProjectDistance(point, origin.position, zz1);
  1565. var value = new Laya.Vector3(x, y, z);
  1566. return value;
  1567. }
  1568. static TransformPoint(origin, point) {
  1569. var value = new Laya.Vector3();
  1570. Laya.Vector3.transformQuat(point, origin.rotation, value);
  1571. Laya.Vector3.add(value, origin.position, value);
  1572. return value;
  1573. }
  1574. static ProjectDistance(A, C, B) {
  1575. var CA = new Laya.Vector3();
  1576. Laya.Vector3.subtract(A, C, CA);
  1577. var angle = this.Angle2(CA, B) * Math.PI / 180;
  1578. var distance = Laya.Vector3.distance(A, C);
  1579. distance *= Math.cos(angle);
  1580. return distance;
  1581. }
  1582. static Angle2(ma, mb) {
  1583. var v1 = (ma.x * mb.x) + (ma.y * mb.y) + (ma.z * mb.z);
  1584. var ma_val = Math.sqrt(ma.x * ma.x + ma.y * ma.y + ma.z * ma.z);
  1585. var mb_val = Math.sqrt(mb.x * mb.x + mb.y * mb.y + mb.z * mb.z);
  1586. var cosM = v1 / (ma_val * mb_val);
  1587. if (cosM < -1)
  1588. cosM = -1;
  1589. if (cosM > 1)
  1590. cosM = 1;
  1591. var angleAMB = Math.acos(cosM) * 180 / Math.PI;
  1592. return angleAMB;
  1593. }
  1594. }
  1595. class ParticleManager {
  1596. constructor() {
  1597. this.hitmaxcount = 0;
  1598. this.boommaxcount = 0;
  1599. }
  1600. static get Instance() {
  1601. return ParticleManager.instance || (ParticleManager.instance = new ParticleManager());
  1602. }
  1603. CreateHitEffect(pos) {
  1604. if (this.hitmaxcount >= GlobalVariable.hitmaxcount)
  1605. return;
  1606. let h = GamePool.Instance.SetActiveObject("hit");
  1607. h.transform.position = pos;
  1608. Scene3DManager.Instance.effectCon.addChild(h);
  1609. this.hitmaxcount++;
  1610. Laya.timer.once(800, this, this.DisSpH, [h], false);
  1611. }
  1612. DisSpH(sp) {
  1613. GamePool.Instance.SetDisableObject(sp);
  1614. this.hitmaxcount--;
  1615. }
  1616. CreateBoomEffect(pos) {
  1617. if (this.boommaxcount >= GlobalVariable.boommaxcount)
  1618. return;
  1619. let h = GamePool.Instance.SetActiveObject("boom");
  1620. h.transform.position = pos;
  1621. Scene3DManager.Instance.effectCon.addChild(h);
  1622. this.boommaxcount++;
  1623. Laya.timer.once(800, this, this.DisSpB, [h], false);
  1624. }
  1625. DisSpB(sp) {
  1626. GamePool.Instance.SetDisableObject(sp);
  1627. this.boommaxcount--;
  1628. }
  1629. CreateXueEffect(pos) {
  1630. let h = GamePool.Instance.SetActiveObject("xue");
  1631. h.transform.position = pos;
  1632. Scene3DManager.Instance.effectCon.addChild(h);
  1633. Laya.timer.once(800, this, this.DisSpX, [h], false);
  1634. }
  1635. DisSpX(sp) {
  1636. GamePool.Instance.SetDisableObject(sp);
  1637. }
  1638. }
  1639. ParticleManager.effectName = {
  1640. hit: "hit",
  1641. xue: "xue",
  1642. boom: "boom"
  1643. };
  1644. var Event$1 = Laya.Event;
  1645. var MouseManager = Laya.MouseManager;
  1646. class MouseEvent {
  1647. constructor() {
  1648. this._switch = false;
  1649. this._isCanClick = true;
  1650. this.clickD = false;
  1651. this._mousePos = Mathf.VecZero;
  1652. this.tempMouse = Mathf.VecZero;
  1653. this.clickCount = 0;
  1654. }
  1655. static get Instance() {
  1656. return this.instance || (this.instance = new MouseEvent());
  1657. }
  1658. InitMouseEvent() {
  1659. Laya.stage.on(Event$1.MOUSE_DOWN, this, this.OnClickDown);
  1660. Laya.stage.on(Event$1.MOUSE_OUT, this, this.OnClickUp);
  1661. }
  1662. OnClickDown(e) {
  1663. if (!this._isCanClick || !this._switch)
  1664. return;
  1665. if (e.target instanceof Laya.UIComponent)
  1666. return;
  1667. this.clickD = true;
  1668. Laya.stage.on(Event$1.MOUSE_UP, this, this.OnClickUp);
  1669. Laya.stage.on(Event$1.MOUSE_MOVE, this, this.OnSlider);
  1670. this._mousePos.x = MouseManager.instance.mouseX;
  1671. this._mousePos.y = MouseManager.instance.mouseY;
  1672. this.MouseD();
  1673. }
  1674. StartGameClick() {
  1675. this._switch = true;
  1676. if (!this._isCanClick)
  1677. return;
  1678. this.clickD = true;
  1679. Laya.stage.on(Event$1.MOUSE_UP, this, this.OnClickUp);
  1680. Laya.stage.on(Event$1.MOUSE_MOVE, this, this.OnSlider);
  1681. this._mousePos.x = MouseManager.instance.mouseX;
  1682. this.MouseD();
  1683. }
  1684. MouseD() {
  1685. MainRoleManager.Instance.SetPlayerPos(this._mousePos.x);
  1686. MainRoleManager.Instance.CreateBullet();
  1687. }
  1688. OnClickUp(e) {
  1689. if (!this._isCanClick || !this._switch)
  1690. return;
  1691. if (!this.clickD)
  1692. return;
  1693. this.MouseU();
  1694. }
  1695. OffMouseEvent() {
  1696. Laya.stage.off(Event$1.MOUSE_DOWN, this, this.OnClickDown);
  1697. Laya.stage.off(Event$1.MOUSE_UP, this, this.OnClickUp);
  1698. Laya.stage.off(Event$1.MOUSE_OUT, this, this.OnClickUp);
  1699. }
  1700. MouseU() {
  1701. this.clickD = false;
  1702. Laya.stage.off(Event$1.MOUSE_MOVE, this, this.OnSlider);
  1703. Laya.stage.off(Event$1.MOUSE_UP, this, this.OnClickUp);
  1704. }
  1705. OnSlider(e) {
  1706. this.tempMouse.x = MouseManager.instance.mouseX;
  1707. let offestX = this.tempMouse.x - this._mousePos.x;
  1708. if (offestX >= 0)
  1709. offestX = offestX < 20 ? offestX : 20;
  1710. if (offestX < 0)
  1711. offestX = offestX > -20 ? offestX : -20;
  1712. MainRoleManager.Instance.SliderPlayer(-offestX);
  1713. this._mousePos.x = this.tempMouse.x;
  1714. this._mousePos.y = this.tempMouse.y;
  1715. }
  1716. OpenInput() {
  1717. this.clickCount++;
  1718. if (this.clickCount > 1)
  1719. return;
  1720. this._isCanClick = true;
  1721. }
  1722. CloseInput() {
  1723. this.clickCount--;
  1724. if (this.clickCount > 0)
  1725. return;
  1726. this._isCanClick = false;
  1727. this.clickD = false;
  1728. }
  1729. set _Switch(value) {
  1730. this._switch = value;
  1731. }
  1732. }
  1733. class Street extends Laya.Script3D {
  1734. constructor() {
  1735. super(...arguments);
  1736. this.rotate = Mathf.VecZero;
  1737. this.speed = Mathf.VecZero;
  1738. }
  1739. onAwake() {
  1740. this.selfobj = this.owner;
  1741. this.tran = this.selfobj.transform;
  1742. }
  1743. SetBlock(thing) {
  1744. this.tran.localPositionZ = Number(thing.z);
  1745. this.tran.localPositionX = Number(thing.x);
  1746. this.tran.rotationEuler = Mathf.VecZero;
  1747. this.thing = thing;
  1748. if (!MainRoleManager.Instance.player)
  1749. return;
  1750. this.tarTran = MainRoleManager.Instance.player.transform;
  1751. this.SetDate();
  1752. }
  1753. SetDate() {
  1754. if (this.thing.type == 5) {
  1755. this.ttttt = this.selfobj.getChildAt(0).transform;
  1756. }
  1757. else {
  1758. this.ttttt = this.tran;
  1759. if (this.thing.type == 4) {
  1760. StreetManager.Instance.AddCubeBlock(this.selfobj);
  1761. }
  1762. }
  1763. if (this.thing.moveType == 1) {
  1764. Laya.timer.frameLoop(3, this, this.Cheack);
  1765. return;
  1766. }
  1767. else if (this.thing.moveType == 2) {
  1768. this.rotate.x = 0;
  1769. this.rotate.y = -this.thing.moveSpeed;
  1770. this.rotate.z = 0;
  1771. Laya.timer.frameLoop(2, this, this.Move2);
  1772. }
  1773. else if (this.thing.moveType == 3) {
  1774. this.rotate.x = 0;
  1775. this.rotate.y = this.thing.moveSpeed;
  1776. this.rotate.z = 0;
  1777. Laya.timer.frameLoop(2, this, this.Move2);
  1778. }
  1779. else if (this.thing.moveType == 4) {
  1780. this.rotate.x = 0;
  1781. this.rotate.y = 0;
  1782. this.rotate.z = this.thing.moveSpeed;
  1783. Laya.timer.frameLoop(1, this, this.Move3);
  1784. }
  1785. else if (this.thing.moveType == 5) {
  1786. this.rotate.x = 0;
  1787. this.rotate.y = 0;
  1788. this.rotate.z = -this.thing.moveSpeed;
  1789. Laya.timer.frameLoop(1, this, this.Move3);
  1790. }
  1791. else if (this.thing.moveType == 6) {
  1792. this.speed.x = -this.thing.moveSpeed;
  1793. this.speed.y = 0;
  1794. this.speed.z = 0;
  1795. Laya.timer.frameLoop(1, this, this.Move4);
  1796. }
  1797. else if (this.thing.moveType == 7) {
  1798. this.speed.x = this.thing.moveSpeed;
  1799. this.speed.y = 0;
  1800. this.speed.z = 0;
  1801. Laya.timer.frameLoop(1, this, this.Move4);
  1802. }
  1803. else if (this.thing.moveType == 8) ;
  1804. else if (this.thing.moveType == 9) ;
  1805. }
  1806. Move2() {
  1807. this.ttttt.rotate(this.rotate);
  1808. this.Cheack();
  1809. }
  1810. Move3() {
  1811. this.ttttt.rotate(this.rotate);
  1812. if (Math.abs(this.ttttt.localRotationEulerZ) >= 50)
  1813. this.rotate.z = -this.rotate.z;
  1814. this.Cheack();
  1815. }
  1816. Move4() {
  1817. this.ttttt.translate(this.speed);
  1818. if (Math.abs(this.ttttt.localPositionX) >= GlobalVariable.blockLRmoveMaxDis)
  1819. this.speed.x = -this.speed.x;
  1820. this.Cheack();
  1821. }
  1822. Cheack() {
  1823. if (this.tarTran.localPositionZ - this.tran.localPositionZ >= 10) {
  1824. console.log("回收block", this.selfobj.name);
  1825. this.Des();
  1826. return;
  1827. }
  1828. }
  1829. Des() {
  1830. if (this.thing.type) {
  1831. StreetManager.Instance.ResetCubBlock(this.selfobj.id);
  1832. }
  1833. Laya.timer.clearAll(this);
  1834. StreetManager.Instance.RemoveBlock(this.selfobj);
  1835. GamePool.Instance.SetDisableObject(this.selfobj);
  1836. }
  1837. onDestroy() {
  1838. }
  1839. }
  1840. var REG = Laya.ClassUtils.regClass;
  1841. var ui;
  1842. (function (ui) {
  1843. class AttributeUpViewUI extends Laya.Scene {
  1844. constructor() { super(); }
  1845. createChildren() {
  1846. super.createChildren();
  1847. this.createView(AttributeUpViewUI.uiView);
  1848. }
  1849. }
  1850. AttributeUpViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Image", "props": { "top": 0, "skin": "gameRes1/zhujiemian-1-20.png", "right": 0, "left": 0, "bottom": 0, "alpha": 0.8, "sizeGrid": "18,18,15,19" }, "compId": 3 }, { "type": "Box", "props": { "x": 52, "width": 636, "height": 538, "centerY": -41 }, "compId": 4, "child": [{ "type": "Image", "props": { "top": 0, "skin": "gameRes1/d0bg-shengji.png", "right": 0, "left": 0, "bottom": 0, "sizeGrid": "13,14,14,15" }, "compId": 31, "child": [{ "type": "Image", "props": { "y": -43, "x": 134, "skin": "gameRes1/aasudu-bg-2 (2).png" }, "compId": 32 }] }, { "type": "Button", "props": { "y": 116, "x": 342, "var": "rateBtn", "stateNum": 1, "skin": "gameRes1/aasudu-bg-2 (1).png" }, "compId": 34, "child": [{ "type": "Image", "props": { "y": 19, "x": 44, "skin": "gameRes1/aasudu-bg-2 (5).png" }, "compId": 35 }, { "type": "Image", "props": { "y": 124, "x": 11, "var": "_rate", "stateNum": 1, "skin": "gameRes1/aasudu-bg-2 (8).png" }, "compId": 36, "child": [{ "type": "Image", "props": { "y": 9, "x": 3, "skin": "gameRes1/aasudu-bg-2 (9).png" }, "compId": 37 }, { "type": "Image", "props": { "y": 13, "x": 57, "skin": "gameRes1/aasudu-bg-2 (6).png" }, "compId": 38, "child": [{ "type": "Text", "props": { "y": 2, "x": 38, "width": 133, "var": "rateValue", "valign": "middle", "text": "800", "height": 41, "fontSize": 40, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 39 }] }] }, { "type": "Text", "props": { "y": 71, "x": 72, "width": 106, "var": "rateLv", "valign": "middle", "text": "LV8", "height": 41, "fontSize": 42, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 40 }, { "type": "Image", "props": { "y": 124, "x": 11, "visible": false, "var": "_rateVideo", "stateNum": 1, "skin": "gameRes1/aasudu-bg-2 (8).png" }, "compId": 41, "child": [{ "type": "Image", "props": { "y": 9, "x": 3, "skin": "gameRes1/aasudu-bg-2 (9).png" }, "compId": 42 }, { "type": "Image", "props": { "y": 12, "x": 117, "skin": "gameRes1/aasudu-bg-2 (10).png" }, "compId": 43 }] }, { "type": "Image", "props": { "y": 154, "x": 137, "var": "click2", "skin": "gameRes1/shou.png", "anchorX": 0.5 }, "compId": 49 }] }, { "type": "Button", "props": { "y": 116, "x": 46, "var": "atkBtn", "stateNum": 1, "skin": "gameRes1/aasudu-bg-2 (3).png" }, "compId": 5, "child": [{ "type": "Image", "props": { "y": 19, "x": 66, "skin": "gameRes1/aasudu-bg-2 (4).png" }, "compId": 10 }, { "type": "Image", "props": { "y": 124, "x": 11, "var": "_atk", "stateNum": 1, "skin": "gameRes1/aasudu-bg-2 (8).png" }, "compId": 13, "child": [{ "type": "Image", "props": { "y": 9, "x": 3, "skin": "gameRes1/aasudu-bg-2 (9).png" }, "compId": 33 }, { "type": "Image", "props": { "y": 13, "x": 57, "skin": "gameRes1/aasudu-bg-2 (6).png" }, "compId": 14, "child": [{ "type": "Text", "props": { "y": 2, "x": 38, "width": 133, "var": "atkValue", "valign": "middle", "text": "800", "height": 41, "fontSize": 40, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 16 }] }] }, { "type": "Text", "props": { "y": 71, "x": 57, "width": 136, "var": "atkLv", "valign": "middle", "text": "LV8", "height": 41, "fontSize": 42, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 12 }, { "type": "Image", "props": { "y": 124, "x": 11, "visible": false, "var": "_atkVideo", "stateNum": 1, "skin": "gameRes1/aasudu-bg-2 (8).png" }, "compId": 45, "child": [{ "type": "Image", "props": { "y": 9, "x": 3, "skin": "gameRes1/aasudu-bg-2 (9).png" }, "compId": 46 }, { "type": "Image", "props": { "y": 12, "x": 117, "skin": "gameRes1/aasudu-bg-2 (10).png" }, "compId": 47 }] }, { "type": "Image", "props": { "y": 154.5, "x": 137, "var": "click1", "skin": "gameRes1/shou.png", "anchorX": 0.5 }, "compId": 48 }] }, { "type": "Image", "props": { "y": 426, "x": 209, "var": "backBtn", "skin": "gameRes1/aasudu-bg-2 (7).png", "runtime": "Window/Com/ButtonRunTime.ts", "centerY": 180 }, "compId": 8 }] }], "animations": [{ "nodes": [{ "target": 48, "keyframes": { "y": [{ "value": 154.5, "tweenMethod": "linearNone", "tween": true, "target": 48, "key": "y", "index": 0 }, { "value": 207, "tweenMethod": "linearNone", "tween": true, "target": 48, "key": "y", "index": 5 }, { "value": 154.5, "tweenMethod": "linearNone", "tween": true, "target": 48, "key": "y", "index": 10 }] } }], "name": "ani1", "id": 1, "frameRate": 24, "action": 2 }, { "nodes": [{ "target": 49, "keyframes": { "y": [{ "value": 154, "tweenMethod": "linearNone", "tween": true, "target": 49, "key": "y", "index": 0 }, { "value": 201, "tweenMethod": "linearNone", "tween": true, "target": 49, "key": "y", "index": 5 }, { "value": 154.5, "tweenMethod": "linearNone", "tween": true, "target": 49, "key": "y", "index": 10 }] } }], "name": "ani2", "id": 2, "frameRate": 24, "action": 2 }], "loadList": ["gameRes1/zhujiemian-1-20.png", "gameRes1/d0bg-shengji.png", "gameRes1/aasudu-bg-2 (2).png", "gameRes1/aasudu-bg-2 (1).png", "gameRes1/aasudu-bg-2 (5).png", "gameRes1/aasudu-bg-2 (8).png", "gameRes1/aasudu-bg-2 (9).png", "gameRes1/aasudu-bg-2 (6).png", "gameRes1/aasudu-bg-2 (10).png", "gameRes1/shou.png", "gameRes1/aasudu-bg-2 (3).png", "gameRes1/aasudu-bg-2 (4).png", "gameRes1/aasudu-bg-2 (7).png"], "loadList3D": [] };
  1851. ui.AttributeUpViewUI = AttributeUpViewUI;
  1852. REG("ui.AttributeUpViewUI", AttributeUpViewUI);
  1853. class CompleteViewUI extends Laya.Scene {
  1854. constructor() { super(); }
  1855. createChildren() {
  1856. super.createChildren();
  1857. this.createView(CompleteViewUI.uiView);
  1858. }
  1859. }
  1860. CompleteViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Image", "props": { "top": 0, "skin": "gameRes1/zhujiemian-1-20.png", "right": 0, "left": 0, "bottom": 0, "alpha": 0.9, "sizeGrid": "18,18,15,19" }, "compId": 22 }, { "type": "Box", "props": { "x": 178, "width": 364, "var": "winbtnBox", "height": 226, "bottom": 292 }, "compId": 47, "child": [{ "type": "Image", "props": { "x": 130, "var": "nextBtn", "skin": "gameRes1/no.png", "runtime": "Window/Com/ButtonRunTime.ts", "bottom": 0 }, "compId": 46 }, { "type": "Image", "props": { "y": 0, "x": 9, "var": "doublegetBtn", "skin": "gameRes1/sanbei-bt.png", "runtime": "Window/Com/ButtonRunTime.ts" }, "compId": 28 }, { "type": "Image", "props": { "y": 74, "x": 33, "skin": "gameRes1/jinbi-da.png" }, "compId": 66, "child": [{ "type": "Text", "props": { "y": 3, "x": 81, "width": 218, "var": "doubleText", "valign": "middle", "text": "50", "strokeColor": "#714800", "stroke": 2, "height": 71, "fontSize": 56, "color": "#bc3e01", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 67 }] }] }, { "type": "Image", "props": { "x": 80, "var": "shibaiTop", "skin": "gameRes1/shibai.png", "centerY": -481 }, "compId": 68 }, { "type": "Image", "props": { "x": 92, "var": "winTop", "skin": "gameRes1/win-biao.png", "centerY": -481 }, "compId": 44 }, { "type": "Image", "props": { "x": 238, "width": 60, "skin": "gameRes1/jinbi-da.png", "height": 60, "centerY": 82 }, "compId": 69, "child": [{ "type": "Text", "props": { "y": -8, "x": 77, "width": 165, "var": "valueText", "valign": "middle", "text": "50(+100)", "height": 75, "fontSize": 40, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 70 }] }, { "type": "Box", "props": { "y": 258, "x": 138, "width": 444, "height": 429, "centerY": -168 }, "compId": 71, "child": [{ "type": "Image", "props": { "y": 0, "x": 0, "width": 444, "skin": "gameRes1/zhengchang-di.png", "height": 100, "sizeGrid": "17,31,12,28" }, "compId": 72, "child": [{ "type": "Image", "props": { "y": 31, "x": 52, "skin": "gameRes1/jianxingzhuang.png" }, "compId": 73 }, { "type": "Image", "props": { "y": 31, "x": 343, "skin": "gameRes1/jianxingzhuang.png" }, "compId": 74 }, { "type": "Image", "props": { "y": 31, "x": 177, "skin": "gameRes1/jiangli.png" }, "compId": 75 }] }, { "type": "Image", "props": { "y": 107, "x": 0, "width": 444, "skin": "gameRes1/zhengchang-di.png", "height": 100, "sizeGrid": "17,31,12,28" }, "compId": 76, "child": [{ "type": "Image", "props": { "y": 18, "x": 26, "skin": "gameRes1/baolei.png" }, "compId": 80 }, { "type": "Image", "props": { "y": 25, "x": 384, "width": 50, "skin": "gameRes1/jinbi-da.png", "height": 50 }, "compId": 83 }, { "type": "Text", "props": { "y": 18, "x": 300, "width": 78, "var": "towerValue", "valign": "middle", "text": "X10", "height": 63, "fontSize": 36, "color": "#ffffff", "bold": true, "align": "right", "runtime": "laya.display.Text" }, "compId": 82 }, { "type": "Text", "props": { "y": 18, "x": 97, "width": 78, "var": "towerCount", "valign": "middle", "text": "X10", "height": 63, "fontSize": 36, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 81 }] }, { "type": "Image", "props": { "y": 214, "x": 0, "width": 444, "skin": "gameRes1/zhengchang-di.png", "height": 100, "sizeGrid": "17,31,12,28" }, "compId": 84, "child": [{ "type": "Image", "props": { "y": 18, "x": 26, "skin": "gameRes1/rentu.png" }, "compId": 85 }, { "type": "Image", "props": { "y": 25, "x": 384, "width": 50, "skin": "gameRes1/jinbi-da.png", "height": 50 }, "compId": 88 }, { "type": "Text", "props": { "y": 18, "x": 97, "width": 78, "var": "roleCount", "valign": "middle", "text": "X10", "height": 63, "fontSize": 36, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 86 }, { "type": "Text", "props": { "y": 18, "x": 300, "width": 78, "var": "roleValue", "valign": "middle", "text": "X10", "height": 63, "fontSize": 36, "color": "#ffffff", "bold": true, "align": "right", "runtime": "laya.display.Text" }, "compId": 87 }] }, { "type": "Image", "props": { "y": 321, "x": 0, "width": 444, "skin": "gameRes1/zhengchang-di.png", "height": 100, "sizeGrid": "17,31,12,28" }, "compId": 89, "child": [{ "type": "Image", "props": { "y": 18, "x": 26, "skin": "gameRes1/baohe.png" }, "compId": 90 }, { "type": "Image", "props": { "y": 25, "x": 384, "width": 50, "skin": "gameRes1/jinbi-da.png", "height": 50 }, "compId": 93 }, { "type": "Text", "props": { "y": 18, "x": 97, "width": 78, "var": "blockCount", "valign": "middle", "text": "X10", "height": 63, "fontSize": 36, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 91 }, { "type": "Text", "props": { "y": 18, "x": 300, "width": 78, "var": "blockValue", "valign": "middle", "text": "X10", "height": 63, "fontSize": 36, "color": "#ffffff", "bold": true, "align": "right", "runtime": "laya.display.Text" }, "compId": 92 }] }] }, { "type": "Sprite", "props": { "y": 0, "x": 0, "var": "duohuituiSp" }, "compId": 94 }, { "type": "Sprite", "props": { "y": 0, "x": 0, "var": "bannerHuiTuiSp" }, "compId": 95 }], "animations": [{ "nodes": [{ "target": 18, "keyframes": { "scaleY": [{ "value": 1, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "scaleY", "index": 0 }, { "value": 0.5, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "scaleY", "index": 10 }, { "value": 1, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "scaleY", "index": 20 }, { "value": 0.5, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "scaleY", "index": 30 }, { "value": 1, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "scaleY", "index": 40 }], "scaleX": [{ "value": 1, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "scaleX", "index": 0 }, { "value": 0.5, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "scaleX", "index": 10 }, { "value": 1, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "scaleX", "index": 20 }, { "value": 0.5, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "scaleX", "index": 30 }, { "value": 1, "tweenMethod": "linearNone", "tween": true, "target": 18, "key": "scaleX", "index": 40 }] } }], "name": "aim", "id": 1, "frameRate": 24, "action": 0 }], "loadList": ["gameRes1/zhujiemian-1-20.png", "gameRes1/no.png", "gameRes1/sanbei-bt.png", "gameRes1/jinbi-da.png", "gameRes1/shibai.png", "gameRes1/win-biao.png", "gameRes1/zhengchang-di.png", "gameRes1/jianxingzhuang.png", "gameRes1/jiangli.png", "gameRes1/baolei.png", "gameRes1/rentu.png", "gameRes1/baohe.png"], "loadList3D": [] };
  1861. ui.CompleteViewUI = CompleteViewUI;
  1862. REG("ui.CompleteViewUI", CompleteViewUI);
  1863. class GuideViewUI extends Laya.Scene {
  1864. constructor() { super(); }
  1865. createChildren() {
  1866. super.createChildren();
  1867. this.createView(GuideViewUI.uiView);
  1868. }
  1869. }
  1870. GuideViewUI.uiView = { "type": "Scene", "props": { "width": 720, "mouseThrough": true, "height": 1280 }, "compId": 2, "child": [{ "type": "Box", "props": { "y": 30, "x": 958, "width": 104, "var": "guide1Box", "scaleY": 0.8, "scaleX": 0.8, "height": 44, "anchorY": 1, "anchorX": 0.5 }, "compId": 7, "child": [{ "type": "Image", "props": { "y": 3, "x": -3, "skin": "gameRes1/zzzzzzguangquan(1).png" }, "compId": 8 }, { "type": "Image", "props": { "y": -123, "x": 2, "skin": "gameRes1/zzzzz1.png" }, "compId": 9 }] }, { "type": "Box", "props": { "y": 154, "x": 969, "width": 207, "var": "guide2Box", "scaleY": 0.8, "scaleX": 0.8, "height": 56, "anchorY": 0.5, "anchorX": 0 }, "compId": 10, "child": [{ "type": "Image", "props": { "y": 28, "x": 207, "width": 0, "skin": "gameRes1/zzzzzuoyou-jiantou(1).png", "rotation": 180, "pivotY": 48, "height": 96 }, "compId": 12 }, { "type": "Image", "props": { "y": 15, "x": 181, "skin": "gameRes1/shou.png" }, "compId": 11 }] }, { "type": "Box", "props": { "y": 298, "x": 1790, "width": 207, "var": "guide3Box", "scaleY": 0.8, "scaleX": 0.8, "height": 48, "anchorY": 0.5, "anchorX": 1 }, "compId": 13, "child": [{ "type": "Image", "props": { "y": 22, "x": 0, "width": 0, "skin": "gameRes1/zzzzzuoyou-jiantou(1).png", "pivotY": 48, "height": 96 }, "compId": 14 }, { "type": "Image", "props": { "y": 6, "x": -17, "width": 61, "skin": "gameRes1/shou.png" }, "compId": 15 }] }, { "type": "Box", "props": { "y": 278, "x": -163, "width": 104, "var": "guide4Box", "scaleY": 0.8, "scaleX": 0.8, "height": 44, "anchorY": 1, "anchorX": 0.5 }, "compId": 19, "child": [{ "type": "Image", "props": { "y": -106, "x": 4, "skin": "gameRes1/zzzzz1.png" }, "compId": 21 }] }, { "type": "Image", "props": { "x": 203, "var": "guide1Image", "skin": "gameRes1/zzzzbiaoyu(2).png", "bottom": 213 }, "compId": 16 }, { "type": "Image", "props": { "x": 164, "var": "guide2Image", "skin": "gameRes1/zzzzbiaoyu(1).png", "bottom": 218 }, "compId": 17 }, { "type": "Image", "props": { "x": 136, "var": "guide3Image", "skin": "gameRes1/zzzzbiaoyu.png", "bottom": 220 }, "compId": 18 }], "animations": [{ "nodes": [{ "target": 9, "keyframes": { "y": [{ "value": -116, "tweenMethod": "linearNone", "tween": true, "target": 9, "key": "y", "index": 0 }, { "value": -197, "tweenMethod": "linearNone", "tween": true, "target": 9, "key": "y", "index": 5 }, { "value": -115, "tweenMethod": "linearNone", "tween": true, "target": 9, "key": "y", "index": 10 }] } }], "name": "guide1", "id": 1, "frameRate": 24, "action": 0 }, { "nodes": [{ "target": 11, "keyframes": { "x": [{ "value": 181, "tweenMethod": "linearNone", "tween": true, "target": 11, "key": "x", "index": 0 }, { "value": 21, "tweenMethod": "linearNone", "tween": true, "target": 11, "key": "x", "index": 10 }] } }, { "target": 12, "keyframes": { "width": [{ "value": 0, "tweenMethod": "linearNone", "tween": true, "target": 12, "key": "width", "index": 0 }, { "value": 188, "tweenMethod": "linearNone", "tween": true, "target": 12, "key": "width", "index": 10 }] } }], "name": "guide2", "id": 2, "frameRate": 24, "action": 0 }, { "nodes": [{ "target": 15, "keyframes": { "x": [{ "value": -17, "tweenMethod": "linearNone", "tween": true, "target": 15, "key": "x", "index": 0 }, { "value": 122, "tweenMethod": "linearNone", "tween": true, "target": 15, "key": "x", "index": 10 }] } }, { "target": 14, "keyframes": { "width": [{ "value": 0, "tweenMethod": "linearNone", "tween": true, "target": 14, "key": "width", "index": 0 }, { "value": 149, "tweenMethod": "linearNone", "tween": true, "target": 14, "key": "width", "index": 10 }] } }], "name": "guide3", "id": 3, "frameRate": 24, "action": 0 }, { "nodes": [{ "target": 21, "keyframes": { "y": [{ "value": -212, "tweenMethod": "linearNone", "tween": true, "target": 21, "key": "y", "index": 0 }, { "value": -106, "tweenMethod": "linearNone", "tween": true, "target": 21, "key": "y", "index": 10 }] } }], "name": "guide4", "id": 4, "frameRate": 24, "action": 0 }], "loadList": ["gameRes1/zzzzzzguangquan(1).png", "gameRes1/zzzzz1.png", "gameRes1/zzzzzuoyou-jiantou(1).png", "gameRes1/shou.png", "gameRes1/zzzzbiaoyu(2).png", "gameRes1/zzzzbiaoyu(1).png", "gameRes1/zzzzbiaoyu.png"], "loadList3D": [] };
  1871. ui.GuideViewUI = GuideViewUI;
  1872. REG("ui.GuideViewUI", GuideViewUI);
  1873. class InGameViewUI extends Laya.Scene {
  1874. constructor() { super(); }
  1875. createChildren() {
  1876. super.createChildren();
  1877. this.createView(InGameViewUI.uiView);
  1878. }
  1879. }
  1880. InGameViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "loadList": [], "loadList3D": [] };
  1881. ui.InGameViewUI = InGameViewUI;
  1882. REG("ui.InGameViewUI", InGameViewUI);
  1883. class IntensifyViewUI extends Laya.Scene {
  1884. constructor() { super(); }
  1885. createChildren() {
  1886. super.createChildren();
  1887. this.createView(IntensifyViewUI.uiView);
  1888. }
  1889. }
  1890. IntensifyViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Image", "props": { "top": 0, "skin": "gameRes1/111111.png", "right": 0, "left": 0, "bottom": 0, "alpha": 0.8, "sizeGrid": "22,12,11,12" }, "compId": 3 }, { "type": "Box", "props": { "x": 52, "width": 636, "height": 626, "centerY": -18 }, "compId": 4, "child": [{ "type": "Image", "props": { "y": 0, "x": 0, "width": 636, "var": "atkBox", "skin": "gameRes1/11.png", "height": 185, "sizeGrid": "21,22,21,22" }, "compId": 5, "child": [{ "type": "Image", "props": { "y": 43, "x": 183, "skin": "gameRes1/gongji-2.png" }, "compId": 10 }, { "type": "Image", "props": { "y": 43, "x": 34, "skin": "gameRes1/gongji-icon.png" }, "compId": 9 }, { "type": "Image", "props": { "y": 125, "x": 179, "skin": "gameRes1/gongji-1.png" }, "compId": 11 }, { "type": "Button", "props": { "y": 89, "x": 412, "var": "atkBtn", "stateNum": 1, "skin": "gameRes1/lv-di.png" }, "compId": 13, "child": [{ "type": "Image", "props": { "y": 13, "x": 12, "width": 45, "skin": "gameRes1/jinbi.png", "height": 45 }, "compId": 14, "child": [{ "type": "Text", "props": { "y": 2, "x": 47, "width": 134, "var": "atkValue", "valign": "middle", "text": "800", "height": 41, "fontSize": 48, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 16 }] }] }, { "type": "Text", "props": { "y": 31, "x": 449, "width": 106, "var": "atkLv", "valign": "middle", "text": "LV8", "height": 41, "fontSize": 48, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 12 }] }, { "type": "Image", "props": { "y": 226, "x": 0, "width": 636, "var": "rateBox", "skin": "gameRes1/11.png", "height": 185, "sizeGrid": "21,22,21,22" }, "compId": 6, "child": [{ "type": "Image", "props": { "y": 43, "x": 161, "skin": "gameRes1/sudu-2.png" }, "compId": 17 }, { "type": "Image", "props": { "y": 43, "x": 34, "skin": "gameRes1/iconqiang.png" }, "compId": 18 }, { "type": "Image", "props": { "y": 125, "x": 164, "skin": "gameRes1/sudu-1(1).png" }, "compId": 19 }, { "type": "Button", "props": { "y": 89, "x": 412, "var": "rateBtn", "stateNum": 1, "skin": "gameRes1/lv-di.png" }, "compId": 20, "child": [{ "type": "Image", "props": { "y": 13, "x": 12, "width": 45, "skin": "gameRes1/jinbi.png", "height": 45 }, "compId": 22, "child": [{ "type": "Text", "props": { "y": 2, "x": 47, "width": 134, "var": "rateValue", "valign": "middle", "text": "800", "height": 41, "fontSize": 48, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 23 }] }] }, { "type": "Text", "props": { "y": 31, "x": 449, "width": 106, "var": "rateLv", "valign": "middle", "text": "LV8", "height": 41, "fontSize": 48, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 21 }] }, { "type": "Image", "props": { "y": 444, "x": 0, "width": 636, "visible": true, "var": "coinBox", "skin": "gameRes1/11.png", "height": 185, "sizeGrid": "21,22,21,22" }, "compId": 7, "child": [{ "type": "Image", "props": { "y": 43, "x": 161, "skin": "gameRes1/huode.png" }, "compId": 24 }, { "type": "Image", "props": { "y": 43, "x": 34, "skin": "gameRes1/jinbi (2).png" }, "compId": 25 }, { "type": "Image", "props": { "y": 125, "x": 156, "skin": "gameRes1/tishengjinbi3.png" }, "compId": 26 }, { "type": "Button", "props": { "y": 57, "x": 412, "var": "coinBtn", "stateNum": 1, "skin": "gameRes1/lv-di.png" }, "compId": 27, "child": [{ "type": "Image", "props": { "y": 13, "x": 12, "width": 45, "skin": "gameRes1/shipin-icon.png", "height": 45 }, "compId": 29, "child": [{ "type": "Text", "props": { "y": 2, "x": 47, "width": 134, "var": "coinValue", "valign": "middle", "text": "800", "height": 41, "fontSize": 48, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 30 }] }] }] }] }, { "type": "Image", "props": { "x": 17, "var": "backBtn", "skin": "gameRes1/p__fanhui.png", "runtime": "Window/Com/ButtonRunTime.ts", "centerY": -436 }, "compId": 8 }, { "type": "Image", "props": { "x": 290, "skin": "gameRes1/shengji.png", "centerY": -478 }, "compId": 31 }], "loadList": ["gameRes1/111111.png", "gameRes1/11.png", "gameRes1/gongji-2.png", "gameRes1/gongji-icon.png", "gameRes1/gongji-1.png", "gameRes1/lv-di.png", "gameRes1/jinbi.png", "gameRes1/sudu-2.png", "gameRes1/iconqiang.png", "gameRes1/sudu-1(1).png", "gameRes1/huode.png", "gameRes1/jinbi (2).png", "gameRes1/tishengjinbi3.png", "gameRes1/shipin-icon.png", "gameRes1/p__fanhui.png", "gameRes1/shengji.png"], "loadList3D": [] };
  1891. ui.IntensifyViewUI = IntensifyViewUI;
  1892. REG("ui.IntensifyViewUI", IntensifyViewUI);
  1893. class LoadViewUI extends Laya.Scene {
  1894. constructor() { super(); }
  1895. createChildren() {
  1896. super.createChildren();
  1897. this.createView(LoadViewUI.uiView);
  1898. }
  1899. }
  1900. LoadViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Image", "props": { "var": "bg", "top": 0, "skin": "load/bg.jpg", "right": 0, "name": "bg", "left": 0, "bottom": 0 }, "compId": 6 }, { "type": "Image", "props": { "x": 360, "var": "prepan", "centerY": -68 }, "compId": 14 }, { "type": "Image", "props": { "y": 124, "x": 52, "skin": "load/logo.png", "centerY": -360 }, "compId": 17 }, { "type": "Image", "props": { "y": 932, "x": 137, "var": "pro", "skin": "load/jindu-1.png", "centerY": 309 }, "compId": 20, "child": [{ "type": "Image", "props": { "y": 4, "x": 4, "width": 438, "var": "pro1", "skin": "load/jindu-2.png" }, "compId": 21 }, { "type": "Image", "props": { "y": 52, "x": 174, "skin": "load/jiazai-1-2.png" }, "compId": 8, "child": [{ "type": "Image", "props": { "x": 105, "width": 6, "skin": "load/jiazai-1-3.png", "height": 6, "bottom": 9 }, "compId": 9 }, { "type": "Image", "props": { "x": 120, "skin": "load/jiazai-1-3.png", "bottom": 10 }, "compId": 10 }, { "type": "Image", "props": { "x": 136, "skin": "load/jiazai-1-3.png", "bottom": 10 }, "compId": 11 }] }, { "type": "Text", "props": { "y": 0, "x": 2, "width": 442, "var": "proTex", "valign": "middle", "text": "100%", "height": 38, "fontSize": 28, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 22 }] }], "animations": [{ "nodes": [{ "target": 9, "keyframes": { "alpha": [{ "value": 0, "tweenMethod": "linearNone", "tween": true, "target": 9, "key": "alpha", "index": 0 }, { "value": 1, "tweenMethod": "linearNone", "tween": true, "target": 9, "key": "alpha", "index": 5 }, { "value": 0, "tweenMethod": "linearNone", "tween": true, "target": 9, "key": "alpha", "index": 20 }] } }, { "target": 10, "keyframes": { "alpha": [{ "value": 0, "tweenMethod": "linearNone", "tween": true, "target": 10, "key": "alpha", "index": 0 }, { "value": 1, "tweenMethod": "linearNone", "tween": true, "target": 10, "key": "alpha", "index": 10 }, { "value": 0, "tweenMethod": "linearNone", "tween": true, "target": 10, "key": "alpha", "index": 20 }] } }, { "target": 11, "keyframes": { "alpha": [{ "value": 0, "tweenMethod": "linearNone", "tween": true, "target": 11, "key": "alpha", "index": 0 }, { "value": 1, "tweenMethod": "linearNone", "tween": true, "target": 11, "key": "alpha", "index": 15 }, { "value": 0, "tweenMethod": "linearNone", "tween": true, "target": 11, "key": "alpha", "index": 20 }] } }], "name": "ani1", "id": 1, "frameRate": 24, "action": 2 }], "loadList": ["load/bg.jpg", "load/logo.png", "load/jindu-1.png", "load/jindu-2.png", "load/jiazai-1-2.png", "load/jiazai-1-3.png"], "loadList3D": [] };
  1901. ui.LoadViewUI = LoadViewUI;
  1902. REG("ui.LoadViewUI", LoadViewUI);
  1903. class MainViewUI extends Laya.Scene {
  1904. constructor() { super(); }
  1905. createChildren() {
  1906. super.createChildren();
  1907. this.createView(MainViewUI.uiView);
  1908. }
  1909. }
  1910. MainViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Box", "props": { "x": 0, "top": 82, "right": 0, "left": 0, "height": 70 }, "compId": 265, "child": [{ "type": "Image", "props": { "y": 21, "x": 282, "width": 157, "var": "pro", "skin": "gameRes1/jindu-duan.png" }, "compId": 302, "child": [{ "type": "Image", "props": { "y": 4, "x": 0, "var": "pro1", "skin": "gameRes1/jindu-guan-do.png" }, "compId": 305 }, { "type": "Image", "props": { "y": -11, "x": -49, "skin": "gameRes1/guanshu.png" }, "compId": 303, "child": [{ "type": "Text", "props": { "y": -1, "x": -3, "width": 54, "var": "stageValue", "valign": "middle", "text": "10", "height": 51, "fontSize": 32, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 264 }] }, { "type": "Image", "props": { "y": -11, "x": 155, "skin": "gameRes1/shadi.png" }, "compId": 304 }] }, { "type": "Image", "props": { "x": 533, "width": 187, "top": 85, "skin": "gameRes1/jinbi-bg.png", "right": 0 }, "compId": 261, "child": [{ "type": "Image", "props": { "y": 11, "x": 5, "skin": "gameRes1/jinbi.png" }, "compId": 262 }, { "type": "Text", "props": { "y": 6, "x": 41, "width": 142, "var": "countValue", "valign": "middle", "text": "100000", "italic": true, "height": 47, "fontSize": 36, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 263 }] }] }, { "type": "Box", "props": { "var": "mainBox", "top": 0, "right": 0, "name": "mainBox", "left": 0, "bottom": 0 }, "compId": 284, "child": [{ "type": "Button", "props": { "var": "coutiBtn", "stateNum": 1, "skin": "gameRes1/Begin-gengduoyouxi.png", "left": 0, "centerY": 0 }, "compId": 294 }, { "type": "Image", "props": { "x": 24, "var": "settingBtn", "top": 101, "skin": "gameRes1/setBtn.png", "runtime": "Window/Com/ButtonRunTime.ts" }, "compId": 260 }, { "type": "Box", "props": { "x": 29, "width": 63, "visible": false, "var": "settingBox", "top": 179, "height": 134 }, "compId": 291, "child": [{ "type": "Button", "props": { "x": 2, "width": 59, "var": "shake_btn", "stateNum": 1, "height": 59 }, "compId": 285, "child": [{ "type": "Image", "props": { "y": 0, "x": 0, "skin": "gameRes1/ButtonVibrationOn.png", "name": "kai" }, "compId": 287 }, { "type": "Image", "props": { "y": 0, "x": 0, "visible": false, "skin": "gameRes1/ButtonVibrationOff.png", "name": "guan" }, "compId": 288 }] }, { "type": "Button", "props": { "y": 74, "width": 62, "var": "sound_btn", "stateNum": 1, "height": 60 }, "compId": 286, "child": [{ "type": "Image", "props": { "y": 0, "x": 0, "skin": "gameRes1/Icon_SoundOn.png", "name": "kai" }, "compId": 289 }, { "type": "Image", "props": { "y": 0, "x": 0, "visible": false, "skin": "gameRes1/Icon_SoundOff.png", "name": "guan" }, "compId": 290 }] }] }, { "type": "Box", "props": { "var": "startBox", "right": 0, "left": 0, "height": 5, "bottom": 208 }, "compId": 259, "child": [{ "type": "Image", "props": { "var": "updateBtn", "skin": "gameRes1/updateBtn.png", "runtime": "Window/Com/ButtonRunTime.ts", "left": 0, "bottom": 0 }, "compId": 257 }, { "type": "Image", "props": { "var": "skinBtn", "skin": "gameRes1/skinBtn.png", "runtime": "Window/Com/ButtonRunTime.ts", "right": 0, "bottom": 0 }, "compId": 258 }] }, { "type": "Text", "props": { "y": 0, "x": 0, "width": 194, "var": "user_id", "valign": "middle", "text": "user_id:12", "height": 25, "fontSize": 25, "color": "#000000", "runtime": "laya.display.Text" }, "compId": 270 }, { "type": "Button", "props": { "var": "moreGameBtn", "stateNum": 1, "skin": "youziTexture/btn-entrance-nogift.png", "left": 587, "centerY": 133 }, "compId": 311 }] }, { "type": "Image", "props": { "x": 195, "var": "sliderBox", "skin": "gameRes1/huadong-tiao.png", "gray": false, "bottom": 304 }, "compId": 253, "child": [{ "type": "Image", "props": { "y": -45, "x": 95, "skin": "gameRes1/huadong.png" }, "compId": 292 }, { "type": "Image", "props": { "y": 0, "x": 164, "skin": "gameRes1/shou.png", "anchorX": 0.5 }, "compId": 293 }] }, { "type": "Sprite", "props": { "var": "duohuituiSp" }, "compId": 312 }, { "type": "Sprite", "props": { "y": 0, "x": 0, "var": "bannerHuiTuiSp" }, "compId": 313 }], "animations": [{ "nodes": [{ "target": 293, "keyframes": { "x": [{ "value": 164, "tweenMethod": "linearNone", "tween": true, "target": 293, "key": "x", "index": 0 }, { "value": 0, "tweenMethod": "linearNone", "tween": true, "target": 293, "key": "x", "index": 15 }, { "value": 164, "tweenMethod": "linearNone", "tween": true, "target": 293, "key": "x", "index": 30 }, { "value": 326, "tweenMethod": "linearNone", "tween": true, "target": 293, "key": "x", "index": 45 }, { "value": 164, "tweenMethod": "linearNone", "tween": true, "target": 293, "key": "x", "index": 60 }] } }, { "target": 292, "keyframes": { "x": [{ "value": 0, "tweenMethod": "linearNone", "tween": true, "target": 292, "key": "x", "index": 0 }], "skin": [{ "value": "gameRes1/pause1.png", "tweenMethod": "linearNone", "tween": false, "target": 292, "key": "skin", "index": 0 }] } }], "name": "gameStart", "id": 1, "frameRate": 24, "action": 2 }], "loadList": ["gameRes1/jindu-duan.png", "gameRes1/jindu-guan-do.png", "gameRes1/guanshu.png", "gameRes1/shadi.png", "gameRes1/jinbi-bg.png", "gameRes1/jinbi.png", "gameRes1/Begin-gengduoyouxi.png", "gameRes1/setBtn.png", "gameRes1/ButtonVibrationOn.png", "gameRes1/ButtonVibrationOff.png", "gameRes1/Icon_SoundOn.png", "gameRes1/Icon_SoundOff.png", "gameRes1/updateBtn.png", "gameRes1/skinBtn.png", "youziTexture/btn-entrance-nogift.png", "gameRes1/huadong-tiao.png", "gameRes1/huadong.png", "gameRes1/shou.png", "gameRes1/pause1.png"], "loadList3D": [] };
  1911. ui.MainViewUI = MainViewUI;
  1912. REG("ui.MainViewUI", MainViewUI);
  1913. class ShadeViewUI extends Laya.View {
  1914. constructor() { super(); }
  1915. createChildren() {
  1916. super.createChildren();
  1917. this.createView(ShadeViewUI.uiView);
  1918. }
  1919. }
  1920. ShadeViewUI.uiView = { "type": "View", "props": { "width": 720, "height": 1280 }, "compId": 2, "loadList": [], "loadList3D": [] };
  1921. ui.ShadeViewUI = ShadeViewUI;
  1922. REG("ui.ShadeViewUI", ShadeViewUI);
  1923. class SkinShopViewUI extends Laya.View {
  1924. constructor() { super(); }
  1925. createChildren() {
  1926. super.createChildren();
  1927. this.createView(SkinShopViewUI.uiView);
  1928. }
  1929. }
  1930. SkinShopViewUI.uiView = { "type": "View", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Image", "props": { "top": 0, "skin": "gameRes1/sssdi-3.png", "right": 0, "left": 0, "bottom": 0 }, "compId": 3 }, { "type": "Image", "props": { "x": 17, "var": "backBtn", "skin": "gameRes1/pppguanbi-bt.png", "runtime": "Window/Com/ButtonRunTime.ts", "centerY": -529 }, "compId": 87 }, { "type": "Image", "props": { "skin": "gameRes1/ppppifu-biaoti.png", "centerY": -399 }, "compId": 92 }, { "type": "Box", "props": { "x": 50, "width": 626, "height": 102, "centerY": -70 }, "compId": 100, "child": [{ "type": "Button", "props": { "width": 102, "var": "leftBtn", "stateNum": 1, "height": 102 }, "compId": 93, "child": [{ "type": "Image", "props": { "y": 3, "x": 3, "skin": "gameRes1/pppwu-zuo.png", "name": "leftFalse" }, "compId": 95 }, { "type": "Image", "props": { "y": 3, "x": 3, "skin": "gameRes1/pppyou-zuo.png", "name": "leftTrue" }, "compId": 96 }] }, { "type": "Button", "props": { "x": 521, "width": 102, "var": "rightBtn", "stateNum": 1, "height": 102 }, "compId": 97, "child": [{ "type": "Image", "props": { "y": 3, "x": 3, "skin": "gameRes1/pppwu-you.png", "name": "rightFalse" }, "compId": 98 }, { "type": "Image", "props": { "y": 3, "x": 3, "skin": "gameRes1/pppyou-you.png", "name": "rightTrue" }, "compId": 99 }] }] }, { "type": "Image", "props": { "y": 813, "x": 167, "skin": "gameRes1/sssren-di-2.png", "centerY": 227 }, "compId": 101 }, { "type": "Image", "props": { "y": 469, "x": 209, "width": 302, "var": "viewPort", "height": 398, "centerY": 28 }, "compId": 102 }, { "type": "Box", "props": { "x": 196, "width": 331, "var": "btnBox", "height": 127, "centerY": 396 }, "compId": 113, "child": [{ "type": "Image", "props": { "var": "using", "skin": "gameRes1/pppbt-bg.png" }, "compId": 103, "child": [{ "type": "Text", "props": { "y": 31, "x": 63, "width": 202, "valign": "middle", "text": "使用中", "height": 65, "fontSize": 48, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 104 }] }, { "type": "Image", "props": { "var": "use", "skin": "gameRes1/pppbt-bg.png", "runtime": "Window/Com/ButtonRunTime.ts" }, "compId": 105, "child": [{ "type": "Text", "props": { "y": 31, "x": 63, "width": 202, "valign": "middle", "text": "使用", "height": 65, "fontSize": 48, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 106 }] }, { "type": "Image", "props": { "var": "coin", "skin": "gameRes1/pppbt-bg.png", "runtime": "Window/Com/ButtonRunTime.ts" }, "compId": 107, "child": [{ "type": "Image", "props": { "y": 22, "x": 25, "skin": "gameRes1/jinbi-da.png" }, "compId": 109, "child": [{ "type": "Text", "props": { "y": 8, "x": 63, "width": 202, "valign": "middle", "text": "500", "height": 65, "fontSize": 48, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 108 }] }] }, { "type": "Image", "props": { "var": "video", "skin": "gameRes1/pppbt-bg.png", "runtime": "Window/Com/ButtonRunTime.ts" }, "compId": 110, "child": [{ "type": "Image", "props": { "y": 33, "x": 54, "width": 65, "skin": "gameRes1/aasudu-bg-2 (10).png", "height": 61 }, "compId": 111, "child": [{ "type": "Text", "props": { "y": -2, "x": 63, "width": 202, "valign": "middle", "text": "1/3", "height": 65, "fontSize": 48, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 112 }] }] }] }], "loadList": ["gameRes1/sssdi-3.png", "gameRes1/pppguanbi-bt.png", "gameRes1/ppppifu-biaoti.png", "gameRes1/pppwu-zuo.png", "gameRes1/pppyou-zuo.png", "gameRes1/pppwu-you.png", "gameRes1/pppyou-you.png", "gameRes1/sssren-di-2.png", "gameRes1/pppbt-bg.png", "gameRes1/jinbi-da.png", "gameRes1/aasudu-bg-2 (10).png"], "loadList3D": [] };
  1931. ui.SkinShopViewUI = SkinShopViewUI;
  1932. REG("ui.SkinShopViewUI", SkinShopViewUI);
  1933. class TopTipUiUI extends Laya.Scene {
  1934. constructor() { super(); }
  1935. createChildren() {
  1936. super.createChildren();
  1937. this.createView(TopTipUiUI.uiView);
  1938. }
  1939. }
  1940. TopTipUiUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Image", "props": { "var": "bg", "top": 0, "skin": "gameRes1/zhujiemian-1-20.png", "right": 0, "left": 0, "bottom": 0, "alpha": 0, "sizeGrid": "18,18,15,19" }, "compId": 3 }, { "type": "Image", "props": { "y": 647, "x": 159, "width": 402, "var": "sliderBox", "skin": "gameRes1/huadong-tiao.png", "height": 33, "gray": false, "centerY": 23 }, "compId": 4, "child": [{ "type": "Image", "props": { "y": 124, "x": 37, "skin": "gameRes1/pause1.png" }, "compId": 5 }, { "type": "Image", "props": { "y": 0, "x": 201, "skin": "gameRes1/shou.png", "anchorX": 0.5 }, "compId": 6 }] }], "animations": [{ "nodes": [{ "target": 6, "keyframes": { "x": [{ "value": 201, "tweenMethod": "linearNone", "tween": true, "target": 6, "key": "x", "index": 0 }, { "value": 13, "tweenMethod": "linearNone", "tween": true, "target": 6, "key": "x", "index": 15 }, { "value": 201, "tweenMethod": "linearNone", "tween": true, "target": 6, "key": "x", "index": 30 }, { "value": 402, "tweenMethod": "linearNone", "tween": true, "target": 6, "key": "x", "index": 45 }, { "value": 201, "tweenMethod": "linearNone", "tween": true, "target": 6, "key": "x", "index": 60 }] } }], "name": "ani1", "id": 1, "frameRate": 24, "action": 2 }], "loadList": ["gameRes1/zhujiemian-1-20.png", "gameRes1/huadong-tiao.png", "gameRes1/pause1.png", "gameRes1/shou.png"], "loadList3D": [] };
  1941. ui.TopTipUiUI = TopTipUiUI;
  1942. REG("ui.TopTipUiUI", TopTipUiUI);
  1943. class TrialViewUI extends Laya.Scene {
  1944. constructor() { super(); }
  1945. createChildren() {
  1946. super.createChildren();
  1947. this.createView(TrialViewUI.uiView);
  1948. }
  1949. }
  1950. TrialViewUI.uiView = { "type": "Scene", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Image", "props": { "top": 0, "skin": "gameRes1/zhujiemian-1-20.png", "right": 0, "left": 0, "bottom": 0, "sizeGrid": "18,18,15,19" }, "compId": 3 }, { "type": "Image", "props": { "x": 125, "skin": "gameRes1/sssbiaoti.png", "centerY": -503 }, "compId": 4 }, { "type": "Image", "props": { "x": 104, "visible": false, "skin": "gameRes1/sssdi-3.png", "centerY": -100 }, "compId": 5 }, { "type": "Image", "props": { "x": 167, "skin": "gameRes1/sssren-di-2.png", "centerY": 85 }, "compId": 6 }, { "type": "Image", "props": { "x": 209, "width": 302, "var": "viewPort", "height": 398, "centerY": -108 }, "compId": 8 }, { "type": "Image", "props": { "x": 245, "skin": "gameRes1/x3.png", "centerY": -374 }, "compId": 12 }, { "type": "Box", "props": { "x": 196, "width": 325, "var": "btnBox", "height": 191, "bottom": 289 }, "compId": 11, "child": [{ "type": "Image", "props": { "y": 145, "x": 92, "var": "backBtn", "skin": "gameRes1/sssno-bt.png", "runtime": "Window/Com/ButtonRunTime.ts" }, "compId": 9 }, { "type": "Image", "props": { "var": "videoBtn", "skin": "gameRes1/sssbt.png", "runtime": "Window/Com/ButtonRunTime.ts" }, "compId": 10 }] }], "loadList": ["gameRes1/zhujiemian-1-20.png", "gameRes1/sssbiaoti.png", "gameRes1/sssdi-3.png", "gameRes1/sssren-di-2.png", "gameRes1/x3.png", "gameRes1/sssno-bt.png", "gameRes1/sssbt.png"], "loadList3D": [] };
  1951. ui.TrialViewUI = TrialViewUI;
  1952. REG("ui.TrialViewUI", TrialViewUI);
  1953. })(ui || (ui = {}));
  1954. class GuideView extends ui.GuideViewUI {
  1955. constructor() {
  1956. super();
  1957. this.isguide2or3 = false;
  1958. this.guide1pos = Mathf.VecZero;
  1959. this.guide1Com = false;
  1960. GuideView.instance = this;
  1961. this.resizeHander();
  1962. DispatcherManager.on(Laya.Event.RESIZE, this, this.resizeHander);
  1963. }
  1964. static get Instance() {
  1965. return GuideView.instance;
  1966. }
  1967. OnShow(data) {
  1968. this.InitHandler();
  1969. this.InitDate();
  1970. this.InitHandler();
  1971. this.InitUi();
  1972. }
  1973. InitUi() {
  1974. }
  1975. InitDate() {
  1976. }
  1977. InitHandler() {
  1978. }
  1979. SetGuide(type) {
  1980. if (!this.playerTran)
  1981. this.playerTran = MainRoleManager.Instance.playerTra;
  1982. if (!this._camera)
  1983. this._camera = CameraManager.Instance._camer;
  1984. if (type == 1) {
  1985. this.guide1Image.visible = true;
  1986. this.guide2Image.visible = false;
  1987. this.guide3Image.visible = false;
  1988. this.guide1Box.visible = true;
  1989. this.guide1.play(0, true);
  1990. this.guide4Box.visible = false;
  1991. if (this.playerTran.localPositionX <= GuideController.Instance.guide1pos.x) {
  1992. this.guide2Box.visible = true;
  1993. this.guide3Box.visible = false;
  1994. this.isguide2or3 = true;
  1995. this.guide2.play(0, true);
  1996. }
  1997. else {
  1998. this.guide2Box.visible = false;
  1999. this.guide3Box.visible = true;
  2000. this.isguide2or3 = false;
  2001. this.guide3.play(0, true);
  2002. }
  2003. this.guide1pos = GuideController.Instance.guide1pos.clone();
  2004. Laya.timer.frameLoop(1, this, this._guide1);
  2005. this.guide1Com = false;
  2006. }
  2007. }
  2008. _guide1() {
  2009. if (!this.guide1Com) {
  2010. let p = MatrixTransform.WorldToScreen2(this._camera, GuideController.Instance.guide1pos.clone());
  2011. this.guide1Box.pos(p.x, p.y);
  2012. this.guide1pos.z = this.playerTran.localPositionZ + 10;
  2013. let p1 = MatrixTransform.WorldToScreen2(this._camera, this.guide1pos);
  2014. if (this.isguide2or3) {
  2015. this.guide2Box.pos(p1.x, p1.y);
  2016. }
  2017. else {
  2018. this.guide3Box.pos(p1.x, p1.y);
  2019. }
  2020. if (this.playerTran.localPositionZ >= GuideController.Instance.guide1pos.z - 5) {
  2021. this.guide2.stop();
  2022. this.guide3.stop();
  2023. this.guide2Box.visible = false;
  2024. this.guide3Box.visible = false;
  2025. this.guide1Box.visible = false;
  2026. this.guide1Com = true;
  2027. this.guide1Image.visible = false;
  2028. }
  2029. }
  2030. else {
  2031. if (this.playerTran.localPositionZ >= GuideController.Instance.guide1pos.z) {
  2032. console.log(111);
  2033. Laya.timer.clear(this, this._guide1);
  2034. this.Guide2();
  2035. }
  2036. }
  2037. }
  2038. Guide2() {
  2039. this.guide3Box.visible = true;
  2040. this.guide4Box.visible = true;
  2041. this.guide2Image.visible = true;
  2042. this.guide3.play(0, true);
  2043. this.guide4.play(0, true);
  2044. Laya.timer.frameLoop(1, this, this._guide2);
  2045. this.guide1pos.x = -4.5;
  2046. this.guide1pos.y = 0;
  2047. }
  2048. _guide2() {
  2049. let p = MatrixTransform.WorldToScreen2(this._camera, GuideController.Instance.guide2Pos.clone());
  2050. this.guide4Box.pos(p.x, p.y);
  2051. this.guide1pos.z = this.playerTran.localPositionZ + 5;
  2052. let p1 = MatrixTransform.WorldToScreen2(this._camera, this.guide1pos);
  2053. this.guide3Box.pos(p1.x, p1.y);
  2054. if (this.playerTran.localPositionZ >= GuideController.Instance.guide2Pos.z - 10) {
  2055. this.guide3Box.visible = false;
  2056. this.guide4Box.visible = false;
  2057. this.guide2Image.visible = false;
  2058. this.guide3Image.visible = true;
  2059. this.guide3.stop();
  2060. this.guide4.stop();
  2061. Laya.timer.clear(this, this._guide2);
  2062. Laya.timer.once(5000, this, () => {
  2063. GuideController.Instance.OverGuide();
  2064. });
  2065. }
  2066. }
  2067. OnClose() {
  2068. DispatcherManager.off(Laya.Event.RESIZE, this, this.resizeHander);
  2069. GuideView.instance = null;
  2070. Laya.timer.clearAll(this);
  2071. }
  2072. resizeHander() {
  2073. this.height = Laya.stage.height;
  2074. }
  2075. }
  2076. class GuideController {
  2077. constructor() {
  2078. this.isguide = false;
  2079. this.guide1pos = new Laya.Vector3(2.5, 0, 59.4);
  2080. this.guide2Pos = new Laya.Vector3(-5, 2, 104.4);
  2081. this.index = 0;
  2082. }
  2083. static get Instance() {
  2084. return this.instance || (this.instance = new GuideController());
  2085. }
  2086. IsGuide() {
  2087. let t = Laya.LocalStorage.getItem("guide");
  2088. if (PlayerManager.Instance.stage == 1) {
  2089. Laya.LocalStorage.setItem("guide", "1");
  2090. this.isguide = true;
  2091. return true;
  2092. }
  2093. this.isguide = false;
  2094. return false;
  2095. }
  2096. SetGuidePos(p) {
  2097. if (this.index == 0) {
  2098. this.guide1pos.z = p;
  2099. this.index++;
  2100. }
  2101. else if (this.index == 1) {
  2102. this.guide2Pos.z = p;
  2103. this.index++;
  2104. }
  2105. }
  2106. StartGuide() {
  2107. if (this.isguide) {
  2108. Laya.timer.once(500, this, this.Guide1);
  2109. }
  2110. }
  2111. OverGuide() {
  2112. this.isguide = false;
  2113. ViewManager.Instance.CloseGuideView();
  2114. }
  2115. Guide1() {
  2116. ViewManager.Instance.ShowGuideView();
  2117. if (GuideView.Instance) {
  2118. GuideView.Instance.SetGuide(1);
  2119. }
  2120. }
  2121. GameDied() {
  2122. if (this.isguide) {
  2123. ViewManager.Instance.CloseGuideView();
  2124. }
  2125. }
  2126. }
  2127. class RoadArr {
  2128. constructor(blocks, blockPos) {
  2129. this.blocks = blocks;
  2130. this.blockPos = blockPos;
  2131. }
  2132. }
  2133. class BlockArr {
  2134. constructor(things, thingPos, blockHp) {
  2135. this.things = things;
  2136. this.thingPos = thingPos;
  2137. this.blockHp = blockHp;
  2138. }
  2139. }
  2140. class ThingArr {
  2141. constructor(type, prrfabName, moveType, moveSpeed) {
  2142. this.type = type;
  2143. this.prrfabName = prrfabName;
  2144. this.moveType = moveType;
  2145. this.moveSpeed = moveSpeed;
  2146. }
  2147. }
  2148. class StreetManager {
  2149. constructor() {
  2150. this.isover = false;
  2151. this.curindex = 1;
  2152. this.blockDic = new Dictionary();
  2153. this.cubeBlockDic = new Dictionary();
  2154. }
  2155. static get Instance() {
  2156. return StreetManager.instance || (StreetManager.instance = new StreetManager());
  2157. }
  2158. Init(BlockContainer) {
  2159. this.BlockContainer = BlockContainer;
  2160. }
  2161. SetBlock() {
  2162. this.isover = false;
  2163. this.curindex = 1;
  2164. this.CreateBlock();
  2165. }
  2166. CreateBlock() {
  2167. let road_list = LevelController.Instance._level.road_list;
  2168. if (this.curindex > road_list.length - 1) {
  2169. this.isover = true;
  2170. console.log("没有障碍物了");
  2171. return;
  2172. }
  2173. this.tarDis =
  2174. this.curindex * GlobalVariable.barrierRoadLength;
  2175. let roadindex = road_list[this.curindex];
  2176. if (roadindex == 0)
  2177. return;
  2178. let roads = CfgManager.Instance.GetRoad(roadindex);
  2179. if (!roads)
  2180. return;
  2181. let blocks = GameTool.SpliteString(roads["blocks"]);
  2182. let blockPoss = GameTool.SpliteString(roads["position"]);
  2183. let bps = [];
  2184. let d = GlobalVariable.barrierRoadLength / GlobalVariable.barrierRoadAverageNum;
  2185. blockPoss.forEach(element => {
  2186. bps.push(this.tarDis + element * d);
  2187. });
  2188. let bbs = [];
  2189. blocks.forEach(element => {
  2190. let thing = CfgManager.Instance.GetBlock(element);
  2191. let tss = GameTool.SpliteString(thing["block_things"]);
  2192. let tps = GameTool.SpliteString(thing["thing_position"]);
  2193. let ths = GameTool.SpliteString(thing["block_hp"]);
  2194. let ttt = [];
  2195. tss.forEach(element1 => {
  2196. let t = CfgManager.Instance.GetThing(element1);
  2197. let tt = new ThingArr(t["type"], t["prefabs"], t["dynamic_type"], t["dynamic_speed"]);
  2198. ttt.push(tt);
  2199. });
  2200. let things = new BlockArr(ttt, tps, ths);
  2201. bbs.push(things);
  2202. });
  2203. let blockB = new RoadArr(bbs, bps);
  2204. this.CreateSp(blockB);
  2205. }
  2206. CheckPlayerRoadPos(_zp) {
  2207. if (this.isover)
  2208. return;
  2209. let d = this.tarDis - _zp;
  2210. if (d > 0)
  2211. return;
  2212. this.SwitchBlock();
  2213. }
  2214. SwitchBlock() {
  2215. this.curindex++;
  2216. console.log("到达一个障碍物");
  2217. this.CreateBlock();
  2218. }
  2219. CreateSp(road) {
  2220. if (GuideController.Instance.isguide) {
  2221. GuideController.Instance.SetGuidePos(road.blockPos[0]);
  2222. }
  2223. let blocks = road.blocks;
  2224. let blockPos = road.blockPos;
  2225. let j = 0;
  2226. for (let index = 0; index < blocks.length; index++) {
  2227. const element = blocks[index];
  2228. const p = blockPos[index];
  2229. let things = element.things;
  2230. let thingPos = element.thingPos;
  2231. let blockHp = element.blockHp;
  2232. let isr = blockHp.length > 1;
  2233. for (let index = 0; index < things.length; index++) {
  2234. const element1 = things[index];
  2235. element1.z = p;
  2236. element1.x = thingPos[index];
  2237. element1.towerR = isr;
  2238. element1.hp = blockHp[index];
  2239. j++;
  2240. Laya.timer.frameOnce(j, this, this._crete, [element1], false);
  2241. }
  2242. }
  2243. }
  2244. _crete(thing) {
  2245. if (thing.type == 1 || thing.type == 2) {
  2246. MoundManager.Instance.CreateTower(thing);
  2247. }
  2248. else {
  2249. let p = GamePool.Instance.SetActiveObject(thing.prrfabName);
  2250. if (!p)
  2251. return;
  2252. this.BlockContainer.addChild(p);
  2253. let ts = p.getComponent(Street);
  2254. if (!ts)
  2255. ts = p.addComponent(Street);
  2256. ts.SetBlock(thing);
  2257. this.blockDic.set(p.id, ts);
  2258. }
  2259. }
  2260. RemoveBlock(sp) {
  2261. this.blockDic.delete(sp.id);
  2262. }
  2263. AddCubeBlock(sp) {
  2264. if (this.cubeBlockDic.has(sp.id))
  2265. return;
  2266. this.cubeBlockDic.set(sp.id, sp);
  2267. }
  2268. ResetCubBlock(id) {
  2269. let sp = this.cubeBlockDic.get(id);
  2270. this.cubeBlockDic.delete(id);
  2271. if (!sp)
  2272. return;
  2273. console.log("回收CubeBlock,", sp.name);
  2274. for (let index = 0; index < sp.numChildren; index++) {
  2275. const element = sp.getChildAt(index);
  2276. element.active = true;
  2277. }
  2278. }
  2279. CubeBlockAtked(sp) {
  2280. sp.active = false;
  2281. ParticleManager.Instance.CreateBoomEffect(sp.transform.position);
  2282. }
  2283. Reset() {
  2284. this.isover = false;
  2285. let arr = [];
  2286. for (const key in this.blockDic.container) {
  2287. arr.push(key);
  2288. }
  2289. let j = 1;
  2290. if (arr.length > 0) {
  2291. for (let index = 0; index < arr.length; index++) {
  2292. const element = arr[index];
  2293. let s = this.blockDic.get(element);
  2294. if (s)
  2295. s.Des();
  2296. if (this.cubeBlockDic.has(element)) {
  2297. Laya.timer.frameOnce(j, this, this.ResetCubBlock, [element], false);
  2298. j++;
  2299. }
  2300. }
  2301. }
  2302. console.log("this.blockDic.size", this.blockDic.size);
  2303. }
  2304. }
  2305. var Vector3$1 = Laya.Vector3;
  2306. var Quaternion = Laya.Quaternion;
  2307. class Opponent extends Laya.Script3D {
  2308. constructor() {
  2309. super(...arguments);
  2310. this._up = new Vector3$1(0, 1, 0);
  2311. this.isArrive1 = false;
  2312. }
  2313. onAwake() {
  2314. this.selfobj = this.owner;
  2315. this.tran = this.selfobj.transform;
  2316. this.mat = (this.selfobj.getChildAt(0).getChildByName("enemy").skinnedMeshRenderer.material);
  2317. this.forW = Mathf.VecZero;
  2318. this.speed = GlobalVariable.enemySpeed;
  2319. this.quaternion1 = new Quaternion();
  2320. }
  2321. SetTar(tar, hp, cloth) {
  2322. this.tarSp = tar;
  2323. this.isArrive1 = false;
  2324. if (this.tarSp == null)
  2325. return;
  2326. this.tarPos = this.tarSp.transform.position.clone();
  2327. if (this.tarPos.x > 0) {
  2328. this.tarPos = PlaneManager.Instance.toured1.clone();
  2329. }
  2330. else {
  2331. this.tarPos = PlaneManager.Instance.toured2.clone();
  2332. }
  2333. this.hp = hp;
  2334. this.mat.albedoTexture = AssetController.Instance.cloth[cloth - 1];
  2335. this.mat.emissionTexture = AssetController.Instance.cloth[cloth - 1];
  2336. Laya.timer.frameLoop(1, this, this.Move);
  2337. }
  2338. Move() {
  2339. if (this.isArrive1) {
  2340. if (this.tarSp == null)
  2341. return;
  2342. if (!this.tarSp.active) {
  2343. this.tarSp = RoleManager.Instance.GetTar();
  2344. if (this.tarSp == null)
  2345. return;
  2346. this.tarPos = this.tarSp.transform.position.clone();
  2347. }
  2348. Vector3$1.subtract(this.tarPos, this.tran.position, this.forW);
  2349. Vector3$1.normalize(this.forW, this.forW);
  2350. this.forW = new Vector3$1(this.forW.x * this.speed, this.forW.y * this.speed, this.forW.z * this.speed);
  2351. this.tran.translate(this.forW, false);
  2352. if (Vector3$1.distance(this.tran.position, this.tarPos) < 0.1) {
  2353. return;
  2354. }
  2355. Quaternion.lookAt(this.tarPos, this.tran.position, this._up, this.quaternion1);
  2356. this.quaternion1.invert(this.quaternion1);
  2357. this.tran.rotation = this.quaternion1.clone();
  2358. }
  2359. else {
  2360. Vector3$1.subtract(this.tarPos, this.tran.position, this.forW);
  2361. Vector3$1.normalize(this.forW, this.forW);
  2362. this.forW = new Vector3$1(this.forW.x * this.speed, this.forW.y * this.speed, this.forW.z * this.speed);
  2363. this.tran.translate(this.forW, false);
  2364. if (Vector3$1.distance(this.tran.position, this.tarPos) < 0.1) {
  2365. this.tarSp = RoleManager.Instance.GetTar();
  2366. this.isArrive1 = true;
  2367. if (this.tarSp == null)
  2368. return;
  2369. this.tarPos = this.tarSp.transform.position.clone();
  2370. return;
  2371. }
  2372. Quaternion.lookAt(this.tarPos, this.tran.position, this._up, this.quaternion1);
  2373. this.quaternion1.invert(this.quaternion1);
  2374. this.tran.rotation = this.quaternion1.clone();
  2375. }
  2376. }
  2377. Atked(hitpos) {
  2378. this.hp -= PlayerManager.bulletAttack;
  2379. if (this.hp <= 0) {
  2380. this.Died();
  2381. return;
  2382. }
  2383. ParticleManager.Instance.CreateHitEffect(hitpos);
  2384. }
  2385. Died() {
  2386. ParticleManager.Instance.CreateXueEffect(this.tran.position);
  2387. this.Des();
  2388. RoleManager.Instance.CheackGame();
  2389. GameManager.Instance.roleCount++;
  2390. }
  2391. Des() {
  2392. Laya.timer.clearAll(this);
  2393. RoleManager.Instance.RemoveEnemy(this.selfobj);
  2394. GamePool.Instance.SetDisableObject(this.selfobj);
  2395. }
  2396. onDestroy() {
  2397. }
  2398. }
  2399. class RoleManager {
  2400. constructor() {
  2401. this.frameCount = 10;
  2402. this.enemyDic = new Dictionary();
  2403. }
  2404. static get Instance() {
  2405. return this.instance || (this.instance = new RoleManager());
  2406. }
  2407. CreateEnemy(startPos) {
  2408. this.startPos = startPos;
  2409. let count = LevelController.Instance._level.enemy;
  2410. let hp = LevelController.Instance._level.enemy_hp;
  2411. let texture = LevelController.Instance._level.enemy_cloth;
  2412. for (let index = 0; index < count; index++) {
  2413. let a = index;
  2414. Laya.timer.frameOnce(a * this.frameCount, this, this._crete, [hp, texture], false);
  2415. }
  2416. }
  2417. _crete(hp, texture) {
  2418. let e = GamePool.Instance.SetActiveObject(GamePool.pooltype.enemy);
  2419. if (!e)
  2420. return;
  2421. MainRoleManager.Instance.playerContainer.addChild(e);
  2422. e.transform.position = this.startPos.clone();
  2423. let ps = e.getComponent(Opponent);
  2424. if (!ps)
  2425. ps = e.addComponent(Opponent);
  2426. let sp = this.GetTar();
  2427. ps.SetTar(sp, hp, texture);
  2428. this.enemyDic.set(e.id, ps);
  2429. }
  2430. GetTar() {
  2431. let p = MainRoleManager.Instance.ArriveIsdead();
  2432. if (!p) {
  2433. if (Math.random() > 0.5) {
  2434. return MainRoleManager.Instance.playerBehavior.body;
  2435. }
  2436. else {
  2437. let s = MateManager.Instance.GetGetSp();
  2438. if (!s)
  2439. return MainRoleManager.Instance.playerBehavior.body;
  2440. else
  2441. return s;
  2442. }
  2443. }
  2444. else {
  2445. let s = MateManager.Instance.GetGetSp();
  2446. if (!s)
  2447. return null;
  2448. else
  2449. return s;
  2450. }
  2451. }
  2452. RemoveEnemy(sp) {
  2453. this.enemyDic.delete(sp.id);
  2454. }
  2455. CheackGame() {
  2456. if (this.enemyDic.size == 0) {
  2457. MouseEvent.Instance.OnClickUp();
  2458. MainRoleManager.Instance.StopCreate();
  2459. GameManager.Instance.ToDance();
  2460. }
  2461. }
  2462. PlayerGetEnemy() {
  2463. for (const key in this.enemyDic.container) {
  2464. const element = this.enemyDic.get(key);
  2465. return element.selfobj;
  2466. }
  2467. return null;
  2468. }
  2469. Reset() {
  2470. let arr = [];
  2471. for (const key in this.enemyDic.container) {
  2472. arr.push(key);
  2473. }
  2474. if (arr.length > 0) {
  2475. for (let index = 0; index < arr.length; index++) {
  2476. const element = arr[index];
  2477. let s = this.enemyDic.get(element);
  2478. if (s)
  2479. s.Des();
  2480. }
  2481. }
  2482. console.log("this.enemyDic.size", this.enemyDic.size);
  2483. }
  2484. }
  2485. class BannerAndVideo1 {
  2486. static InitVideo() {
  2487. if (!GameSetting.isWx)
  2488. return;
  2489. let index = Math.random() > 0.5 ? 0 : 1;
  2490. BannerAndVideo1.curVideo = Laya.Browser.window.wx.createRewardedVideoAd({ adUnitId: BannerAndVideo1.videlAdUnitId[index] });
  2491. BannerAndVideo1.curVideo.onLoad(() => {
  2492. console.log('激励视频 广告加载成功');
  2493. this.videoLoadCom = true;
  2494. });
  2495. BannerAndVideo1.curVideo.onError(err => {
  2496. console.log("激励视屏加载失败:" + err);
  2497. this.videoLoadCom = false;
  2498. });
  2499. BannerAndVideo1.curVideo.onClose(res => {
  2500. console.log("激励视频关闭:" + res.isEnded);
  2501. if (res && res.isEnded || res === undefined) {
  2502. this.videoCallback && this.videoCallback(true);
  2503. }
  2504. else {
  2505. this.videoCallback && this.videoCallback(false);
  2506. }
  2507. });
  2508. }
  2509. static ShowVideo(callback) {
  2510. if (GameSetting.isWx) {
  2511. if (BannerAndVideo1.videoLoadCom) {
  2512. console.log("showVideoAd:" + BannerAndVideo1.videoLoadCom);
  2513. BannerAndVideo1.videoCallback = callback;
  2514. BannerAndVideo1.curVideo.show().catch(err => {
  2515. BannerAndVideo1.curVideo.load().then(() => {
  2516. BannerAndVideo1.curVideo.show();
  2517. });
  2518. });
  2519. }
  2520. else {
  2521. WXSdk.Game_Share(callback);
  2522. }
  2523. }
  2524. else {
  2525. ViewManager.Instance.ShowTips("暂未开放");
  2526. callback(true);
  2527. }
  2528. }
  2529. static OpenBanner(callVack = null, iswait = false) {
  2530. if (!(GameSetting.isWx))
  2531. return;
  2532. BannerAndVideo1.canshowbanner = true;
  2533. var idd;
  2534. this.curBannerId++;
  2535. if (this.curBannerId > 1)
  2536. this.curBannerId = 0;
  2537. idd = BannerAndVideo1.bannerAdUnitId[this.curBannerId];
  2538. console.log("adUnitId:" + idd);
  2539. let newBanner = Laya.Browser.window.wx.createBannerAd({
  2540. adUnitId: idd,
  2541. style: {
  2542. left: 0,
  2543. top: 0,
  2544. width: 460
  2545. }
  2546. });
  2547. newBanner.onError(err => {
  2548. console.log(err);
  2549. callVack(null);
  2550. });
  2551. newBanner.onLoad(() => {
  2552. console.log("新的");
  2553. if (this.curbanner)
  2554. this.curbanner.destroy();
  2555. this.curbanner = newBanner;
  2556. let info = Laya.Browser.window.wx.getSystemInfoSync();
  2557. this.curbanner.style.width = info.windowWidth;
  2558. this.curbanner.style.top = info.windowHeight - this.curbanner.style.realHeight - 5;
  2559. var hight = Laya.stage.height / info.windowHeight * this.curbanner.style.realHeight;
  2560. if (callVack != null) {
  2561. callVack(hight);
  2562. }
  2563. if (this.canshowbanner && !iswait) {
  2564. this.curbanner.show();
  2565. }
  2566. else {
  2567. this.curbanner.hide();
  2568. }
  2569. });
  2570. }
  2571. static Clear() {
  2572. Laya.timer.clearAll(BannerAndVideo1);
  2573. Laya.Tween.clearAll(BannerAndVideo1);
  2574. BannerAndVideo1.canshowbanner = false;
  2575. if (BannerAndVideo1.curbanner)
  2576. BannerAndVideo1.curbanner.hide();
  2577. }
  2578. static showbanner() {
  2579. if (!GameSetting.isWx)
  2580. return;
  2581. if (BannerAndVideo1.curbanner)
  2582. BannerAndVideo1.curbanner.show();
  2583. }
  2584. static CheatBanner(btn, complete = null) {
  2585. if (!AppSetting.bannerCanMove || !btn || !this.WXignore()) {
  2586. console.log("ignorecheat");
  2587. BannerAndVideo1.OpenBanner();
  2588. }
  2589. else {
  2590. btn.bottom = NaN;
  2591. btn.y = Laya.stage.height - btn.height - 40;
  2592. BannerAndVideo1.OpenBanner((height) => {
  2593. if (!height) {
  2594. return;
  2595. }
  2596. else {
  2597. console.log("cheatstart", "bottom:100");
  2598. btn.mouseEnabled = false;
  2599. var end = Laya.stage.height - height - btn.height - 20;
  2600. console.log("y:" + end);
  2601. Laya.timer.once(AppSetting.moveTime * 1000, this, () => {
  2602. btn.mouseEnabled = true;
  2603. this.showbanner();
  2604. Laya.Tween.to(btn, { y: end }, 500, null, Laya.Handler.create(this, () => {
  2605. if (complete != null) {
  2606. complete();
  2607. }
  2608. }));
  2609. });
  2610. }
  2611. }, true);
  2612. }
  2613. }
  2614. static WXignore() {
  2615. if (!AppSetting.OpenSceneValue) {
  2616. return true;
  2617. }
  2618. if (GameSetting.wxValue == "1044" || GameSetting.wxValue == "1104" || GameSetting.wxValue == "00000" || GameSetting.wxValue == "1058" || GameSetting.wxValue == "1067" || GameSetting.wxValue == "1095"
  2619. || GameSetting.wxValue == "1089" || GameSetting.wxValue == "1001" || GameSetting.wxValue == "1037" || GameSetting.wxValue == "1007") {
  2620. return true;
  2621. }
  2622. return false;
  2623. }
  2624. }
  2625. BannerAndVideo1.videlAdUnitId = ["adunit-be9371877a88ed51", "adunit-3881e83f08f8b7c9"];
  2626. BannerAndVideo1.bannerAdUnitId = ["adunit-e4f1a4e63109e4ba", "adunit-541ca055934fd3f1"];
  2627. BannerAndVideo1.curBannerId = 0;
  2628. BannerAndVideo1.videoLoadCom = false;
  2629. BannerAndVideo1.canshowbanner = true;
  2630. class GameManager {
  2631. constructor() {
  2632. this.towerCount = 0;
  2633. this.roleCount = 0;
  2634. this.blockCount = 0;
  2635. this.easterCount = 0;
  2636. }
  2637. static get Instance() {
  2638. return GameManager.instance || (GameManager.instance = new GameManager());
  2639. }
  2640. GameStart() {
  2641. this.towerCount = 0;
  2642. this.roleCount = 0;
  2643. this.blockCount = 0;
  2644. }
  2645. GameWin() {
  2646. WXSdk.LongVibrate();
  2647. BannerAndVideo1.Clear();
  2648. ViewManager.Instance.AddView(ViewType.CompleteView, true);
  2649. MoundManager.Instance.Reset();
  2650. StreetManager.Instance.Reset();
  2651. MateManager.Instance.Reset();
  2652. MainRoleManager.Instance.Reset();
  2653. RoleManager.Instance.Reset();
  2654. }
  2655. ToDance(isglod = false) {
  2656. BannerAndVideo1.CheatBanner(null);
  2657. MainRoleManager.Instance.GoToDance();
  2658. if (isglod)
  2659. MateManager.Instance.GoToDance1();
  2660. else
  2661. MateManager.Instance.GoToDance();
  2662. CameraManager.Instance.SetCamState(CameraState.jump, 0.03);
  2663. Laya.timer.once(4000, this, this.GameWin);
  2664. }
  2665. GameOver() {
  2666. GuideController.Instance.GameDied();
  2667. MouseEvent.Instance.OnClickUp();
  2668. MainRoleManager.Instance.StopCreate();
  2669. MouseEvent.Instance._Switch = false;
  2670. WXSdk.LongVibrate();
  2671. BannerAndVideo1.Clear();
  2672. ViewManager.Instance.AddView(ViewType.CompleteView, false);
  2673. MoundManager.Instance.Reset();
  2674. StreetManager.Instance.Reset();
  2675. MateManager.Instance.Reset();
  2676. MainRoleManager.Instance.Reset();
  2677. MainRoleManager.Instance.SetActiveFalse();
  2678. RoleManager.Instance.Reset();
  2679. }
  2680. Pause() {
  2681. if (this.easterCount >= 1) {
  2682. this.GameOver();
  2683. return;
  2684. }
  2685. this.easterCount++;
  2686. }
  2687. Easter() {
  2688. }
  2689. Arrive() {
  2690. MoundManager.Instance.Reset();
  2691. StreetManager.Instance.Reset();
  2692. }
  2693. NextLevel() {
  2694. PlayerManager.Instance.stage++;
  2695. Scene3DManager.Instance.InItScene();
  2696. ViewManager.Instance.CloseView(ViewType.CompleteView);
  2697. DispatcherManager.event(EventType.Event.ShowMainUi);
  2698. DispatcherManager.event(EventType.Event.SetStage);
  2699. DispatcherManager.event(EventType.Event.SetStagePro, 0);
  2700. }
  2701. ReStart() {
  2702. MateManager.Instance.Reset();
  2703. Scene3DManager.Instance.InItScene();
  2704. DispatcherManager.event(EventType.Event.ShowMainUi);
  2705. DispatcherManager.event(EventType.Event.SetStagePro, 0);
  2706. }
  2707. huituiFunc(ist) {
  2708. if (ist) ;
  2709. else {
  2710. console.log("result Close huitui");
  2711. }
  2712. }
  2713. ShowTopTip() {
  2714. }
  2715. }
  2716. class Mound extends Laya.Script3D {
  2717. onAwake() {
  2718. this.selfobj = this.owner;
  2719. this.tran = this.selfobj.transform;
  2720. this.FriendSpawnPoint = this.selfobj.getChildByName("FriendSpawnPoint").transform;
  2721. this.HealthText = this.selfobj.getChildByName("HealthText").transform;
  2722. let we = this.selfobj.getChildByName("WallsEnd");
  2723. this.WallsEnd = we.transform;
  2724. this.mat = we.getChildAt(0).meshRenderer.material;
  2725. }
  2726. Cheack() {
  2727. if (this.tarTran.localPositionZ - this.tran.localPositionZ >= 5) {
  2728. console.log("回收tower");
  2729. this.Des();
  2730. return;
  2731. }
  2732. this.MoveHpText();
  2733. }
  2734. MoveHpText() {
  2735. let p = MatrixTransform.WorldToScreen2(this._camera, this.HealthText.position.clone());
  2736. if (p.x <= 0 || p.x >= Laya.stage.width || p.y <= 0 || p.y >= Laya.stage.height)
  2737. this.hpText.visible = false;
  2738. else {
  2739. if (!this.hpText.visible)
  2740. this.hpText.visible = true;
  2741. this.hpText.x = p.x;
  2742. this.hpText.y = p.y;
  2743. }
  2744. }
  2745. SetTower(data) {
  2746. this._firend = null;
  2747. this.tarTran = MainRoleManager.Instance.player.transform;
  2748. this.tran.localPositionX = data.x;
  2749. this.tran.localPositionY = 0;
  2750. this.tran.localPositionZ = data.z;
  2751. if (data.towerR)
  2752. this.WallsEnd.localRotationEulerY = 30;
  2753. else
  2754. this.WallsEnd.localRotationEulerY = 0;
  2755. if (data.type == 1) {
  2756. this._createFriend();
  2757. }
  2758. this._hp = data.hp;
  2759. if (!this.hpText) {
  2760. this.hpText = MoundManager.Instance.CreateHpText();
  2761. this.hpText.text = this._hp.toString();
  2762. if (!this._camera)
  2763. this._camera = CameraManager.Instance._camer;
  2764. ViewManager.Instance.popNode.addChild(this.hpText);
  2765. }
  2766. this.MoveHpText();
  2767. Laya.timer.frameLoop(1, this, this.Cheack);
  2768. }
  2769. _createFriend() {
  2770. this._firend = MateManager.Instance.CreateFriend(this.FriendSpawnPoint);
  2771. }
  2772. SaveFriend() {
  2773. if (this._firend) {
  2774. this._firend.TweenFall();
  2775. this._firend = null;
  2776. }
  2777. }
  2778. Atked(hitpos) {
  2779. this._hp -= PlayerManager.bulletAttack;
  2780. if (this._hp <= 0) {
  2781. this.SaveFriend();
  2782. ParticleManager.Instance.CreateBoomEffect(this.tran.position);
  2783. this.Des();
  2784. GameManager.Instance.towerCount++;
  2785. return;
  2786. }
  2787. ParticleManager.Instance.CreateHitEffect(hitpos);
  2788. let t = Math.ceil(this._hp);
  2789. this.hpText.text = t.toString();
  2790. this.SetMat();
  2791. }
  2792. SetMat() {
  2793. this.mat.albedoIntensity = 4;
  2794. Laya.timer.once(100, this, () => {
  2795. this.mat.albedoIntensity = 1;
  2796. });
  2797. }
  2798. Des() {
  2799. Laya.timer.clearAll(this);
  2800. if (this.hpText) {
  2801. GamePool.Instance.SetDisableForUi(PoolType.HpText, this.hpText);
  2802. this.hpText = null;
  2803. }
  2804. this.mat.albedoIntensity = 1;
  2805. MoundManager.Instance.RemoveTower(this.selfobj);
  2806. GamePool.Instance.SetDisableObject(this.selfobj);
  2807. if (this._firend) {
  2808. this._firend.Des();
  2809. this._firend = null;
  2810. }
  2811. }
  2812. onDisable() {
  2813. }
  2814. onDestroy() {
  2815. }
  2816. }
  2817. var Vector3$2 = Laya.Vector3;
  2818. class MainRoleShot extends Laya.Script3D {
  2819. constructor() {
  2820. super(...arguments);
  2821. this.speed = Mathf.VecZero;
  2822. this._forward = new Vector3$2(0, 0, 1);
  2823. this.over = false;
  2824. }
  2825. onAwake() {
  2826. this.selfobj = this.owner;
  2827. this.tran = this.selfobj.transform;
  2828. this.rayPoint = this.selfobj.getChildByName("rayPoint").transform;
  2829. this.speed.z = GlobalVariable.bulletspeed;
  2830. }
  2831. StartMove(tarTran, isover = false) {
  2832. this.tarTran = tarTran;
  2833. this.over = isover;
  2834. Laya.timer.frameLoop(1, this, this._MOVE);
  2835. }
  2836. _MOVE() {
  2837. this.tran.translate(this.speed);
  2838. let d = Vector3$2.distance(this.tarTran.position, this.tran.position);
  2839. if (d >= GlobalVariable.bulletMaxDis) {
  2840. this.Des();
  2841. return;
  2842. }
  2843. this.CreateRay();
  2844. }
  2845. CreateRay() {
  2846. let origP = this.rayPoint.position.clone();
  2847. if (!this._scene) {
  2848. this._scene = Scene3DManager.Instance._mainscene;
  2849. }
  2850. if (!this.ray) {
  2851. if (!this.forward)
  2852. this.forward = Mathf.VecZero;
  2853. this.ray = new Laya.Ray(Mathf.VecZero, this._forward);
  2854. this.outHit = new Laya.HitResult();
  2855. }
  2856. this.ray.origin = origP;
  2857. if (this.over) {
  2858. this.tran.getForward(this.forward);
  2859. this.forward.x = -this.forward.x;
  2860. this.forward.y = -this.forward.y;
  2861. this.forward.z = -this.forward.z;
  2862. this.ray.direction = this.forward;
  2863. }
  2864. else {
  2865. this.ray.direction = this._forward;
  2866. }
  2867. let isHItF = this._scene.physicsSimulation.rayCast(this.ray, this.outHit, GlobalVariable.bulletRayLength);
  2868. if (isHItF) {
  2869. let obj = this.outHit.collider.owner;
  2870. if (obj.layer == ColliderGroup.mound) {
  2871. let tower = obj.getComponent(Mound);
  2872. if (tower) {
  2873. tower.Atked(this.outHit.point);
  2874. }
  2875. }
  2876. else if (obj.layer == ColliderGroup.opponent) {
  2877. let tower = obj.getComponent(Opponent);
  2878. if (tower) {
  2879. tower.Atked(this.outHit.point);
  2880. }
  2881. }
  2882. else if (obj.layer == ColliderGroup.obstacle1 || obj.layer == ColliderGroup.obstacle2 || obj.layer == ColliderGroup.obstacle3) {
  2883. StreetManager.Instance.CubeBlockAtked(obj);
  2884. GameManager.Instance.blockCount++;
  2885. }
  2886. else {
  2887. ParticleManager.Instance.CreateHitEffect(this.outHit.point);
  2888. }
  2889. this.Des();
  2890. return;
  2891. }
  2892. }
  2893. Des() {
  2894. Laya.timer.clearAll(this);
  2895. GamePool.Instance.SetDisableObject(this.selfobj);
  2896. GamePool.bulletCount--;
  2897. }
  2898. onDestroy() {
  2899. }
  2900. }
  2901. var Vector3$3 = Laya.Vector3;
  2902. var Quaternion$1 = Laya.Quaternion;
  2903. class Mate extends Laya.Script3D {
  2904. constructor() {
  2905. super(...arguments);
  2906. this._up = new Vector3$3(0, 1, 0);
  2907. this.isreturn = false;
  2908. this.isover = false;
  2909. this.isClickCom = true;
  2910. this.isStop = true;
  2911. this.ts = new Vector3$3(0, 0, 0.01);
  2912. this.isFristShoot = true;
  2913. }
  2914. onAwake() {
  2915. this.selfobj = this.owner;
  2916. this.tran = this.selfobj.transform;
  2917. this.animator = this.selfobj.getChildAt(0).getComponent(Laya.Animator);
  2918. this.rayPoint = this.selfobj.getChildByName("rayPoint").transform;
  2919. this.bulletPos = this.selfobj.getChildByName("bulletPos").transform;
  2920. this.forW = Mathf.VecZero;
  2921. this.speed = GlobalVariable.friendspeed;
  2922. this.quaternion1 = new Quaternion$1();
  2923. }
  2924. SetTar() {
  2925. this.isreturn = false;
  2926. this.isClickCom = true;
  2927. this.isStop = true;
  2928. this.isover = false;
  2929. this.PlayAni(MusicType.Idle, 1);
  2930. DispatcherManager.off(EventType.Event.StopShot, this, this.StopCreate);
  2931. }
  2932. TryAddFriend(dataPar) {
  2933. this.PlayAni(MusicType.Idle, 1);
  2934. this.dataPar = dataPar;
  2935. this.dataPar["ishave"] = true;
  2936. this.isClickCom = true;
  2937. this.isStop = true;
  2938. this.isreturn = true;
  2939. this.isover = false;
  2940. MateManager.Instance.AddGetDic(this.selfobj.id, this);
  2941. this.BulletHandler();
  2942. if (MainRoleManager.Instance.IsBulleting())
  2943. this.CreateBullet();
  2944. Laya.timer.frameLoop(1, this, this.Move);
  2945. }
  2946. TweenFall() {
  2947. let tween = Laya.Tween.to(this.tran, { localPositionY: 0 }, 400, Laya.Ease.quintIn, Laya.Handler.create(this, () => {
  2948. let dataPar = MainRoleManager.Instance.GetFrindPar();
  2949. if (!dataPar) {
  2950. console.warn("friendPar没有位置了");
  2951. return;
  2952. }
  2953. this.dataPar = dataPar;
  2954. this.dataPar["ishave"] = true;
  2955. this.tar = this.dataPar["sp"];
  2956. this.tarTra = this.tar.transform;
  2957. tween.clear();
  2958. this.StartMove();
  2959. }, null, false));
  2960. }
  2961. StartMove() {
  2962. this.PlayAni(MusicType.RunAndGun, 2);
  2963. this.isreturn = false;
  2964. this.isClickCom = true;
  2965. this.isStop = true;
  2966. this.isover = false;
  2967. Laya.timer.frameLoop(1, this, this.Move);
  2968. }
  2969. _createRay() {
  2970. this.CreateRay();
  2971. }
  2972. Move() {
  2973. if (this.isreturn) {
  2974. this._createRay();
  2975. return;
  2976. }
  2977. let tarPos = this.tarTra.position.clone();
  2978. Vector3$3.subtract(tarPos, this.tran.position, this.forW);
  2979. Vector3$3.normalize(this.forW, this.forW);
  2980. this.forW = new Vector3$3(this.forW.x * this.speed, this.forW.y * this.speed, this.forW.z * this.speed);
  2981. this.tran.translate(this.forW, false);
  2982. if (Vector3$3.distance(this.tran.position, tarPos) < 0.1) {
  2983. this.ArriveTarPos();
  2984. return;
  2985. }
  2986. Quaternion$1.lookAt(tarPos, this.tran.position, this._up, this.quaternion1);
  2987. this.quaternion1.invert(this.quaternion1);
  2988. Quaternion$1.slerp(this.tran.rotation, this.quaternion1, 0.1, this.quaternion1);
  2989. this.tran.rotation = this.quaternion1.clone();
  2990. }
  2991. ArriveTarPos() {
  2992. this.isClickCom = true;
  2993. this.isStop = true;
  2994. this.isreturn = true;
  2995. this.tar.addChild(this.selfobj);
  2996. this.tran.localPosition = Mathf.VecZero;
  2997. this.PlayAni(MusicType.RunAndGun, 2);
  2998. MateManager.Instance.AddGetDic(this.selfobj.id, this);
  2999. let tween = Laya.Tween.to(this.tran, { localRotationEulerY: 0 }, 100, Laya.Ease.quintIn, Laya.Handler.create(this, () => {
  3000. tween.clear();
  3001. this.tran.localRotationEuler = Mathf.VecZero;
  3002. this.BulletHandler();
  3003. this.CreateBullet();
  3004. }, null, false));
  3005. }
  3006. CreateRay() {
  3007. let origP = this.rayPoint.position;
  3008. if (!this._scene) {
  3009. this._scene = Scene3DManager.Instance._mainscene;
  3010. }
  3011. if (!this.rayF) {
  3012. this.rayF = new Laya.Ray(Mathf.VecZero, new Vector3$3(0, 0, 1));
  3013. this.outHitF = new Laya.HitResult();
  3014. }
  3015. this.rayF.origin = origP;
  3016. let isHItF = this._scene.physicsSimulation.rayCast(this.rayF, this.outHitF, GlobalVariable.playerRayLengthF);
  3017. if (isHItF) {
  3018. let obj = this.outHitF.collider.owner;
  3019. this.Died(this.outHitF.point);
  3020. return;
  3021. }
  3022. if (!this.rayL) {
  3023. this.rayL = new Laya.Ray(Mathf.VecZero, new Vector3$3(1, 0, 0));
  3024. this.outHitL = new Laya.HitResult();
  3025. }
  3026. this.rayL.origin = origP;
  3027. let isHItL = this._scene.physicsSimulation.rayCast(this.rayL, this.outHitL, GlobalVariable.playerRayLengthLR);
  3028. if (isHItL) {
  3029. let obj = this.outHitL.collider.owner;
  3030. this.Died(this.outHitL.point);
  3031. return;
  3032. }
  3033. if (!this.rayR) {
  3034. this.rayR = new Laya.Ray(Mathf.VecZero, new Vector3$3(-1, 0, 0));
  3035. this.outHitR = new Laya.HitResult();
  3036. }
  3037. this.rayR.origin = origP;
  3038. let isHItR = this._scene.physicsSimulation.rayCast(this.rayR, this.outHitR, GlobalVariable.playerRayLengthLR);
  3039. if (isHItR) {
  3040. let obj = this.outHitR.collider.owner;
  3041. this.Died(this.outHitR.point);
  3042. return;
  3043. }
  3044. }
  3045. PlayAni(clip, speed, callback) {
  3046. this.animator.play(clip);
  3047. if (!speed)
  3048. speed = 1;
  3049. this.animator.speed = speed;
  3050. }
  3051. BulletHandler() {
  3052. DispatcherManager.on(EventType.Event.StopShot, this, this.StopCreate);
  3053. }
  3054. CreateBullet() {
  3055. this.isStop = false;
  3056. if (!this.isClickCom)
  3057. return;
  3058. this.isClickCom = false;
  3059. this._CreateBullet();
  3060. Laya.timer.loop(PlayerManager.bulletTime * 2 * 1000, this, this.LoopCreate);
  3061. }
  3062. LoopCreate() {
  3063. if (this.isStop) {
  3064. Laya.timer.clear(this, this.LoopCreate);
  3065. this.isClickCom = true;
  3066. return;
  3067. }
  3068. this._CreateBullet();
  3069. }
  3070. _CreateBullet() {
  3071. let bu = GamePool.Instance.SetActiveObject(GamePool.pooltype.PlayerBullet);
  3072. if (bu) {
  3073. Scene3DManager.Instance.bulletCon.addChild(bu);
  3074. bu.transform.position = this.bulletPos.position.clone();
  3075. bu.transform.localRotationEuler = this.bulletPos.rotationEuler.clone();
  3076. let pb = bu.getComponent(MainRoleShot);
  3077. if (!pb)
  3078. pb = bu.addComponent(MainRoleShot);
  3079. pb.StartMove(this.bulletPos, this.isover);
  3080. }
  3081. }
  3082. StopCreate() {
  3083. this.isStop = true;
  3084. }
  3085. Died(pos) {
  3086. if (this.dataPar)
  3087. this.dataPar["ishave"] = false;
  3088. ParticleManager.Instance.CreateXueEffect(pos);
  3089. MateManager.Instance.RemoveGet(this.selfobj);
  3090. this.Des();
  3091. MainRoleManager.Instance.CheackGame();
  3092. }
  3093. SetPar() {
  3094. let t = this.tran.position.clone();
  3095. MainRoleManager.Instance.playerContainer.addChild(this.selfobj);
  3096. this.tran.position = t.clone();
  3097. }
  3098. ToStand(pos) {
  3099. this.SetPar();
  3100. this.tp = pos;
  3101. Quaternion$1.lookAt(pos, this.tran.position, this._up, this.quaternion1);
  3102. this.quaternion1.invert(this.quaternion1);
  3103. this.tran.rotation = this.quaternion1.clone();
  3104. this.PlayAni(MusicType.CrouchFiring, 1);
  3105. Laya.timer.frameLoop(1, this, this._TOSTAND);
  3106. }
  3107. _TOSTAND() {
  3108. Vector3$3.subtract(this.tp, this.tran.position, this.forW);
  3109. Vector3$3.normalize(this.forW, this.forW);
  3110. this.forW = new Vector3$3(this.forW.x * 0.15, this.forW.y * 0.15, this.forW.z * 0.15);
  3111. this.tran.translate(this.forW, false);
  3112. if (Vector3$3.distance(this.tran.position, this.tp) < 0.1) {
  3113. Laya.timer.clear(this, this._TOSTAND);
  3114. let tween = Laya.Tween.to(this.tran, { localRotationEulerY: 0 }, 100, Laya.Ease.quintIn, Laya.Handler.create(this, () => {
  3115. tween.clear();
  3116. }, null, false));
  3117. return;
  3118. }
  3119. Quaternion$1.lookAt(this.tp, this.tran.position, this._up, this.quaternion1);
  3120. this.quaternion1.invert(this.quaternion1);
  3121. this.tran.rotation = this.quaternion1.clone();
  3122. }
  3123. Dance(sp) {
  3124. this.PlayAni(MusicType.RunAndGun, 2);
  3125. this.danceP = sp.position.clone();
  3126. this.r = sp.rotationEuler.clone();
  3127. Laya.timer.frameLoop(1, this, this._Dance);
  3128. }
  3129. _Dance() {
  3130. Vector3$3.subtract(this.danceP, this.tran.position, this.forW);
  3131. Vector3$3.normalize(this.forW, this.forW);
  3132. this.forW = new Vector3$3(this.forW.x * 0.15, this.forW.y * 0.15, this.forW.z * 0.15);
  3133. this.tran.translate(this.forW);
  3134. if (Vector3$3.distance(this.tran.position, this.danceP) < 0.15) {
  3135. Laya.timer.clear(this, this._Dance);
  3136. this.tran.position = this.danceP.clone();
  3137. this.tran.rotationEuler = this.r.clone();
  3138. this.PlayAni(MusicType.Dance, 1);
  3139. return;
  3140. }
  3141. Quaternion$1.lookAt(this.danceP, this.tran.position, this._up, this.quaternion1);
  3142. this.quaternion1.invert(this.quaternion1);
  3143. this.tran.rotation = this.quaternion1.clone();
  3144. }
  3145. StartAtkEnemy() {
  3146. Laya.timer.clear(this, this._TOSTAND);
  3147. this.isover = true;
  3148. this.isFristShoot = true;
  3149. this.enemyTar = null;
  3150. Laya.timer.frameLoop(1, this, this._atkEnemy);
  3151. }
  3152. _atkEnemy() {
  3153. if (this.enemyTar == null) {
  3154. this.enemyTar = RoleManager.Instance.PlayerGetEnemy();
  3155. if (this.enemyTar != null) {
  3156. this.ATKp = this.enemyTar.transform.position.clone();
  3157. Quaternion$1.lookAt(this.ATKp, this.tran.position, this._up, this.quaternion1);
  3158. this.quaternion1.invert(this.quaternion1);
  3159. this.tran.rotation = this.quaternion1.clone();
  3160. }
  3161. }
  3162. else {
  3163. if (!this.enemyTar.active) {
  3164. this.enemyTar = RoleManager.Instance.PlayerGetEnemy();
  3165. if (this.enemyTar != null) {
  3166. this.ATKp = this.enemyTar.transform.position.clone();
  3167. Quaternion$1.lookAt(this.ATKp, this.tran.position, this._up, this.quaternion1);
  3168. this.quaternion1.invert(this.quaternion1);
  3169. this.tran.rotation = this.quaternion1.clone();
  3170. }
  3171. }
  3172. if (this.enemyTar == null) {
  3173. this.StopCreate();
  3174. this.isFristShoot = true;
  3175. return;
  3176. }
  3177. if (this.isFristShoot) {
  3178. this.isFristShoot = false;
  3179. this.CreateBullet();
  3180. }
  3181. this.ATKp = this.enemyTar.transform.position.clone();
  3182. Quaternion$1.lookAt(this.ATKp, this.tran.position, this._up, this.quaternion1);
  3183. this.quaternion1.invert(this.quaternion1);
  3184. this.tran.rotation = this.quaternion1.clone();
  3185. }
  3186. }
  3187. Des() {
  3188. if (this.dataPar) {
  3189. this.dataPar["ishave"] = false;
  3190. this.dataPar = null;
  3191. }
  3192. MateManager.Instance.RemoveFriend(this.selfobj);
  3193. MateManager.Instance.RemoveGet(this.selfobj);
  3194. Laya.timer.clearAll(this);
  3195. Laya.Tween.clearAll(this);
  3196. DispatcherManager.off(EventType.Event.StopShot, this, this.StopCreate);
  3197. GamePool.Instance.SetDisableObject(this.selfobj);
  3198. }
  3199. onDestroy() {
  3200. }
  3201. }
  3202. class MateManager {
  3203. constructor() {
  3204. this.v3 = Mathf.VecZero;
  3205. this.friendDic = new Dictionary();
  3206. this.getDic = new Dictionary();
  3207. }
  3208. static get Instance() {
  3209. return this.instance || (this.instance = new MateManager());
  3210. }
  3211. CreateFriend(tra) {
  3212. let p = GamePool.Instance.SetActiveObject(GamePool.pooltype.player + PlayerManager.Instance.equipId);
  3213. if (p) {
  3214. p.transform.position = tra.position.clone();
  3215. p.transform.rotationEuler = tra.rotationEuler.clone();
  3216. MainRoleManager.Instance.playerContainer.addChild(p);
  3217. let ps = p.getComponent(Mate);
  3218. if (!ps)
  3219. ps = p.addComponent(Mate);
  3220. ps.SetTar();
  3221. this.friendDic.set(p.id, ps);
  3222. return ps;
  3223. }
  3224. return null;
  3225. }
  3226. CreateTryOut() {
  3227. for (let index = 0; index < 3; index++) {
  3228. Laya.timer.frameOnce(index, this, this._createtryout, null, false);
  3229. }
  3230. }
  3231. _createtryout() {
  3232. let dataPar = MainRoleManager.Instance.GetFrindPar();
  3233. if (!dataPar) {
  3234. console.warn("friendPar没有位置了");
  3235. return;
  3236. }
  3237. let p = GamePool.Instance.SetActiveObject(GamePool.pooltype.player + PlayerManager.Instance.equipId);
  3238. if (p) {
  3239. let tar = dataPar["sp"];
  3240. tar.addChild(p);
  3241. p.transform.localPosition = Mathf.VecZero;
  3242. p.transform.localRotationEuler = Mathf.VecZero;
  3243. let ps = p.getComponent(Mate);
  3244. if (!ps)
  3245. ps = p.addComponent(Mate);
  3246. ps.TryAddFriend(dataPar);
  3247. this.friendDic.set(p.id, ps);
  3248. }
  3249. }
  3250. TryOutFriendPlayAni() {
  3251. for (const key in this.friendDic.container) {
  3252. const element = this.friendDic.get(key);
  3253. element.CreateBullet();
  3254. element.PlayAni(MusicType.RunAndGun, 2);
  3255. }
  3256. }
  3257. RemoveFriend(sp) {
  3258. this.friendDic.delete(sp.id);
  3259. }
  3260. AddGetDic(id, fr) {
  3261. console.log(22222222);
  3262. this.getDic.set(id, fr);
  3263. }
  3264. RemoveGet(sp) {
  3265. this.getDic.delete(sp.id);
  3266. }
  3267. GetArrive() {
  3268. return this.getDic.size;
  3269. }
  3270. ToArrive(count, zs) {
  3271. if (count == 1) {
  3272. for (const key in this.getDic.container) {
  3273. const element = this.getDic.get(key);
  3274. this.v3.x = 0;
  3275. element.ToStand(this.v3.clone());
  3276. }
  3277. return;
  3278. }
  3279. let len = 2 * GlobalVariable.arriveStandWidth;
  3280. let avr = len / (count - 1);
  3281. let index = 0;
  3282. this.v3.z = zs;
  3283. for (const key in this.getDic.container) {
  3284. const element = this.getDic.get(key);
  3285. this.v3.x = GlobalVariable.arriveStandWidth - index * avr;
  3286. element.ToStand(this.v3.clone());
  3287. index++;
  3288. }
  3289. }
  3290. StartAtkEnemy() {
  3291. for (const key in this.getDic.container) {
  3292. const element = this.getDic.get(key);
  3293. element.StartAtkEnemy();
  3294. }
  3295. }
  3296. GetGetSp() {
  3297. let count = this.getDic.size;
  3298. let a = GameTool.randomInt(1, count);
  3299. let tindex = 1;
  3300. for (const key in this.getDic.container) {
  3301. if (tindex == a) {
  3302. const element = this.getDic.get(key);
  3303. return element.selfobj;
  3304. }
  3305. tindex++;
  3306. }
  3307. return null;
  3308. }
  3309. GoToDance() {
  3310. for (const key in this.getDic.container) {
  3311. let t = PlaneManager.Instance.GetDancePos();
  3312. if (!t)
  3313. return;
  3314. const element = this.getDic.get(key);
  3315. element.Dance(t);
  3316. }
  3317. }
  3318. GoToDance1() {
  3319. for (const key in this.getDic.container) {
  3320. let t = PlaneManager.Instance.GetDancePos();
  3321. const element = this.getDic.get(key);
  3322. element.SetPar();
  3323. if (t) {
  3324. element.Dance(t);
  3325. }
  3326. }
  3327. }
  3328. Reset() {
  3329. let arr = [];
  3330. for (const key in this.friendDic.container) {
  3331. arr.push(key);
  3332. }
  3333. if (arr.length > 0) {
  3334. for (let index = 0; index < arr.length; index++) {
  3335. const element = arr[index];
  3336. let s = this.friendDic.get(element);
  3337. if (s)
  3338. s.Des();
  3339. }
  3340. }
  3341. console.log("this.friendDic.size", this.friendDic.size);
  3342. this.getDic.clear();
  3343. }
  3344. }
  3345. class PlaneManager {
  3346. constructor() {
  3347. this.airisshow = false;
  3348. this.danceindex = 0;
  3349. }
  3350. static get Instance() {
  3351. return this.instance || (this.instance = new PlaneManager());
  3352. }
  3353. Init(finalP) {
  3354. if (!finalP) {
  3355. console.error("飞机不存在");
  3356. return;
  3357. }
  3358. this.finalTra = finalP.transform;
  3359. this.jumpCamTra = finalP.getChildByName("jumpCamPos").transform;
  3360. this.FinalBlock = finalP.getChildAt(0);
  3361. this.EnemySpawnPoint = this.FinalBlock.getChildByName("EnemySpawnPoint").transform;
  3362. this.PlayerDancePoint = this.FinalBlock.getChildByName("PlayerDancePoint");
  3363. this.helicopter = this.FinalBlock.getChildByName("helicopter");
  3364. this.toured = this.FinalBlock.getChildByName("toured").transform;
  3365. this.FinalBlock.active = false;
  3366. }
  3367. SetAir() {
  3368. this.danceindex = 0;
  3369. this.airisshow = false;
  3370. this.FinalBlock.active = false;
  3371. let count = LevelController.Instance._level.road_list.length;
  3372. this.winPos = (count) * GlobalVariable.barrierRoadLength;
  3373. this.finalTra.localPositionZ = this.winPos;
  3374. this.stageProLen = this.winPos - MainRoleManager.Instance.playerStartTra.localPositionZ;
  3375. let isgold = LevelController.Instance._level.isgold;
  3376. this.helicopter.active = isgold;
  3377. this.toured1 = this.FinalBlock.getChildByName("toured1").transform.position.clone();
  3378. this.toured2 = this.FinalBlock.getChildByName("toured2").transform.position.clone();
  3379. }
  3380. CheckPlayerRoadPos(_zp) {
  3381. let d = this.winPos - _zp;
  3382. if (d <= 60 && !this.airisshow) {
  3383. this.ShowAir();
  3384. return;
  3385. }
  3386. DispatcherManager.event(EventType.Event.SetStagePro, (this.stageProLen - d) / this.stageProLen);
  3387. if (d <= 0) {
  3388. this.ArriveFinal();
  3389. }
  3390. }
  3391. ShowAir() {
  3392. this.airisshow = true;
  3393. this.FinalBlock.active = true;
  3394. }
  3395. ArriveFinal() {
  3396. MainRoleManager.Instance.ArriveFinal();
  3397. if (LevelController.Instance._level.isgold) {
  3398. GameManager.Instance.ToDance(true);
  3399. }
  3400. else {
  3401. let count = 0;
  3402. let isdesd = MainRoleManager.Instance.ArriveIsdead();
  3403. if (!isdesd) {
  3404. count++;
  3405. }
  3406. let num = MateManager.Instance.GetArrive();
  3407. count += num;
  3408. if (count == 0)
  3409. return;
  3410. MateManager.Instance.ToArrive(count, this.toured.position.z);
  3411. if (!isdesd)
  3412. MainRoleManager.Instance.ToArrive(count, this.toured.position.z);
  3413. Laya.timer.once(1300, this, this.CreateEnemy);
  3414. }
  3415. }
  3416. CreateEnemy() {
  3417. MainRoleManager.Instance.StartAtkEnemy();
  3418. MateManager.Instance.StartAtkEnemy();
  3419. RoleManager.Instance.CreateEnemy(this.EnemySpawnPoint.position.clone());
  3420. }
  3421. GetDancePos() {
  3422. if (this.danceindex > this.PlayerDancePoint.numChildren - 1)
  3423. return null;
  3424. let t = this.PlayerDancePoint.getChildAt(this.danceindex).transform;
  3425. this.danceindex++;
  3426. return t;
  3427. }
  3428. }
  3429. var Vector3$4 = Laya.Vector3;
  3430. var Quaternion$2 = Laya.Quaternion;
  3431. class MainRole extends Laya.Script3D {
  3432. constructor() {
  3433. super(...arguments);
  3434. this.isarrive = false;
  3435. this.isdead = false;
  3436. this._up = new Vector3$4(0, 1, 0);
  3437. this.ts = new Vector3$4(0, 0, 0.01);
  3438. this.isFristShoot = true;
  3439. }
  3440. onAwake() {
  3441. this.selfobj = this.owner;
  3442. this.tran = this.selfobj.transform;
  3443. this.body = this.selfobj.getChildAt(0);
  3444. this.animator = this.body.getComponent(Laya.Animator);
  3445. this.rayPoint = this.selfobj.getChildByName("rayPoint").transform;
  3446. this.bulletPos = this.selfobj.getChildByName("bulletPos").transform;
  3447. this._speed = Mathf.VecZero;
  3448. this._speed.z = GlobalVariable.playerspeed;
  3449. this.forW = Mathf.VecZero;
  3450. this.quaternion1 = new Quaternion$2();
  3451. }
  3452. StartMove() {
  3453. this.isdead = false;
  3454. this.isarrive = false;
  3455. Laya.timer.frameLoop(1, this, this.Move);
  3456. }
  3457. Move() {
  3458. if (this.isarrive) {
  3459. if (this.isdead)
  3460. return;
  3461. this.CreateRay();
  3462. return;
  3463. }
  3464. this.tran.translate(this._speed);
  3465. let pz = this.tran.localPositionZ;
  3466. ConstructManager.Instance.CheckPlayerRoadPos(pz);
  3467. PlaneManager.Instance.CheckPlayerRoadPos(pz);
  3468. StreetManager.Instance.CheckPlayerRoadPos(pz);
  3469. CameraManager.Instance.CameraMoveIngame(pz);
  3470. if (this.isdead)
  3471. return;
  3472. this.CreateRay();
  3473. }
  3474. Arrive() {
  3475. this.isarrive = true;
  3476. }
  3477. CreateRay() {
  3478. let origP = this.rayPoint.position;
  3479. if (!this._scene) {
  3480. this._scene = Scene3DManager.Instance._mainscene;
  3481. }
  3482. if (!this.rayF) {
  3483. this.rayF = new Laya.Ray(Mathf.VecZero, new Vector3$4(0, 0, 1));
  3484. this.outHitF = new Laya.HitResult();
  3485. }
  3486. this.rayF.origin = origP;
  3487. let isHItF = this._scene.physicsSimulation.rayCast(this.rayF, this.outHitF, GlobalVariable.playerRayLengthF);
  3488. if (isHItF) {
  3489. let obj = this.outHitF.collider.owner;
  3490. this.Died(this.outHitF.point);
  3491. return;
  3492. }
  3493. if (!this.rayL) {
  3494. this.rayL = new Laya.Ray(Mathf.VecZero, new Vector3$4(1, 0, 0));
  3495. this.outHitL = new Laya.HitResult();
  3496. }
  3497. this.rayL.origin = origP;
  3498. let isHItL = this._scene.physicsSimulation.rayCast(this.rayL, this.outHitL, GlobalVariable.playerRayLengthLR);
  3499. if (isHItL) {
  3500. let obj = this.outHitL.collider.owner;
  3501. this.Died(this.outHitL.point);
  3502. return;
  3503. }
  3504. if (!this.rayR) {
  3505. this.rayR = new Laya.Ray(Mathf.VecZero, new Vector3$4(-1, 0, 0));
  3506. this.outHitR = new Laya.HitResult();
  3507. }
  3508. this.rayR.origin = origP;
  3509. let isHItR = this._scene.physicsSimulation.rayCast(this.rayR, this.outHitR, GlobalVariable.playerRayLengthLR);
  3510. if (isHItR) {
  3511. let obj = this.outHitR.collider.owner;
  3512. this.Died(this.outHitR.point);
  3513. return;
  3514. }
  3515. }
  3516. PlayAni(clip, speed, callback) {
  3517. this.animator.play(clip);
  3518. if (!speed)
  3519. speed = 1;
  3520. this.animator.speed = speed;
  3521. }
  3522. Slider(x) {
  3523. this.tran.localPositionX += x;
  3524. let px = this.tran.localPositionX;
  3525. let abs = Math.abs(px);
  3526. if (abs > GlobalVariable.playerMoveMaxX) {
  3527. if (px > 0)
  3528. this.tran.localPositionX = GlobalVariable.playerMoveMaxX;
  3529. else
  3530. this.tran.localPositionX = -GlobalVariable.playerMoveMaxX;
  3531. }
  3532. }
  3533. CreateBullet() {
  3534. if (this.isdead)
  3535. return null;
  3536. return this.bulletPos;
  3537. }
  3538. Died(pos) {
  3539. this.isdead = true;
  3540. this.body.active = false;
  3541. ParticleManager.Instance.CreateXueEffect(pos);
  3542. MainRoleManager.Instance.CheackGame(true);
  3543. }
  3544. Reset() {
  3545. this.body.active = true;
  3546. this.PlayAni(MusicType.Idle, 1);
  3547. Laya.timer.clearAll(this);
  3548. }
  3549. ToStand(pos) {
  3550. if (this.isdead)
  3551. return;
  3552. this.tp = pos;
  3553. Quaternion$2.lookAt(pos, this.tran.position, this._up, this.quaternion1);
  3554. this.quaternion1.invert(this.quaternion1);
  3555. this.tran.rotation = this.quaternion1.clone();
  3556. this.PlayAni(MusicType.CrouchFiring, 1);
  3557. Laya.timer.frameLoop(1, this, this._TOSTAND);
  3558. }
  3559. _TOSTAND() {
  3560. Vector3$4.subtract(this.tp, this.tran.position, this.forW);
  3561. Vector3$4.normalize(this.forW, this.forW);
  3562. this.forW = new Vector3$4(this.forW.x * 0.15, this.forW.y * 0.15, this.forW.z * 0.15);
  3563. this.tran.translate(this.forW);
  3564. if (Vector3$4.distance(this.tran.position, this.tp) < 0.1) {
  3565. Laya.timer.clear(this, this._TOSTAND);
  3566. return;
  3567. }
  3568. Quaternion$2.lookAt(this.tp, this.tran.position, this._up, this.quaternion1);
  3569. this.quaternion1.invert(this.quaternion1);
  3570. this.tran.rotation = this.quaternion1.clone();
  3571. }
  3572. StartAtkEnemy() {
  3573. Laya.timer.clear(this, this._TOSTAND);
  3574. this.isFristShoot = true;
  3575. this.enemyTar = null;
  3576. Laya.timer.frameLoop(1, this, this._atkEnemy);
  3577. }
  3578. _atkEnemy() {
  3579. if (this.isdead)
  3580. return;
  3581. if (this.enemyTar == null) {
  3582. this.enemyTar = RoleManager.Instance.PlayerGetEnemy();
  3583. if (this.enemyTar != null) {
  3584. this.tp = this.enemyTar.transform.position.clone();
  3585. Quaternion$2.lookAt(this.tp, this.tran.position, this._up, this.quaternion1);
  3586. this.quaternion1.invert(this.quaternion1);
  3587. this.tran.rotation = this.quaternion1.clone();
  3588. }
  3589. }
  3590. else {
  3591. if (!this.enemyTar.active) {
  3592. this.enemyTar = RoleManager.Instance.PlayerGetEnemy();
  3593. if (this.enemyTar != null) {
  3594. this.tp = this.enemyTar.transform.position.clone();
  3595. Quaternion$2.lookAt(this.tp, this.tran.position, this._up, this.quaternion1);
  3596. this.quaternion1.invert(this.quaternion1);
  3597. this.tran.rotation = this.quaternion1.clone();
  3598. }
  3599. }
  3600. if (this.enemyTar == null) {
  3601. MainRoleManager.Instance.StopCreate(true);
  3602. this.isFristShoot = true;
  3603. return;
  3604. }
  3605. if (this.isFristShoot) {
  3606. this.isFristShoot = false;
  3607. MainRoleManager.Instance.CreateBullet(true);
  3608. }
  3609. this.tp = this.enemyTar.transform.position.clone();
  3610. Quaternion$2.lookAt(this.tp, this.tran.position, this._up, this.quaternion1);
  3611. this.quaternion1.invert(this.quaternion1);
  3612. this.tran.rotation = this.quaternion1.clone();
  3613. }
  3614. }
  3615. Dance(sp) {
  3616. this.PlayAni(MusicType.RunAndGun, 2);
  3617. this.dancepos = sp.position.clone();
  3618. this.r = sp.rotationEuler.clone();
  3619. Laya.timer.frameLoop(1, this, this._Dance);
  3620. }
  3621. _Dance() {
  3622. Vector3$4.subtract(this.dancepos, this.tran.position, this.forW);
  3623. Vector3$4.normalize(this.forW, this.forW);
  3624. this.forW = new Vector3$4(this.forW.x * 0.15, this.forW.y * 0.15, this.forW.z * 0.15);
  3625. this.tran.translate(this.forW);
  3626. if (Vector3$4.distance(this.tran.position, this.dancepos) < 0.15) {
  3627. Laya.timer.clear(this, this._Dance);
  3628. this.tran.position = this.dancepos.clone();
  3629. this.tran.rotationEuler = this.r.clone();
  3630. this.PlayAni(MusicType.Dance, 1);
  3631. return;
  3632. }
  3633. Quaternion$2.lookAt(this.dancepos, this.tran.position, this._up, this.quaternion1);
  3634. this.quaternion1.invert(this.quaternion1);
  3635. this.tran.rotation = this.quaternion1.clone();
  3636. }
  3637. onDisable() {
  3638. }
  3639. onDestroy() {
  3640. }
  3641. }
  3642. var Vector3$5 = Laya.Vector3;
  3643. class MainRoleManager {
  3644. constructor() {
  3645. this.isover = false;
  3646. this.isClickCom = true;
  3647. this.isStop = true;
  3648. }
  3649. static get Instance() {
  3650. return this.instance || (this.instance = new MainRoleManager());
  3651. }
  3652. Init(startPos, playerCon) {
  3653. this.playerStartTra = startPos.transform;
  3654. this.playerContainer = playerCon;
  3655. }
  3656. CreatePlayer() {
  3657. let p = GamePool.Instance.SetActiveObject(GamePool.pooltype.player + PlayerManager.Instance.equipId);
  3658. if (p) {
  3659. this.player = p;
  3660. this.SetFriendPoint(p);
  3661. this.playerTra = this.player.transform;
  3662. this.playerTra.position = this.playerStartTra.position.clone();
  3663. this.playerTra.rotationEuler = this.playerStartTra.rotationEuler.clone();
  3664. this.playerContainer.addChild(this.player);
  3665. let ps = this.player.getComponent(MainRole);
  3666. if (ps)
  3667. this.playerBehavior = ps;
  3668. else
  3669. this.playerBehavior = this.player.addComponent(MainRole);
  3670. }
  3671. else {
  3672. console.error("player不存在");
  3673. }
  3674. }
  3675. InitPlayerPos() {
  3676. this.player.active = true;
  3677. this.playerTra.position = this.playerStartTra.position.clone();
  3678. this.playerTra.rotationEuler = this.playerStartTra.rotationEuler.clone();
  3679. this.playerBehavior.PlayAni(MusicType.Idle, 1);
  3680. }
  3681. ChangePlayer() {
  3682. if (this.player)
  3683. GamePool.Instance.SetDisableObject(this.player);
  3684. let p = GamePool.Instance.SetActiveObject(GamePool.pooltype.player + PlayerManager.Instance.equipId);
  3685. if (p) {
  3686. this.player = p;
  3687. this.SetFriendPoint(p);
  3688. this.playerTra = this.player.transform;
  3689. this.playerTra.position = this.playerStartTra.position.clone();
  3690. this.playerTra.rotationEuler = this.playerStartTra.rotationEuler.clone();
  3691. this.playerContainer.addChild(this.player);
  3692. let ps = this.player.getComponent(MainRole);
  3693. if (ps)
  3694. this.playerBehavior = ps;
  3695. else
  3696. this.playerBehavior = this.player.addComponent(MainRole);
  3697. }
  3698. }
  3699. SetFriendPoint(player) {
  3700. this.FriendArrPos = [];
  3701. let par = player.getChildByName("FriendSpawPos");
  3702. if (!par)
  3703. console.error("friend父物体不存在");
  3704. for (let index = 0; index < par.numChildren; index++) {
  3705. let data = {};
  3706. data["ishave"] = false;
  3707. data["sp"] = par.getChildAt(index);
  3708. this.FriendArrPos.push(data);
  3709. }
  3710. }
  3711. GetFrindPar() {
  3712. for (let index = 0; index < this.FriendArrPos.length; index++) {
  3713. const element = this.FriendArrPos[index];
  3714. if (!element["ishave"])
  3715. return element;
  3716. }
  3717. return null;
  3718. }
  3719. SetPlayerPos(x) {
  3720. if (!this.player) {
  3721. this.CreatePlayer();
  3722. this.InitPlayerPos();
  3723. }
  3724. if (!this._camera) {
  3725. this._camera = CameraManager.Instance._camer;
  3726. this._dis = -Vector3$5.distance(this.playerTra.position, this._camera.transform.position);
  3727. this._y = MatrixTransform.WorldToScreen2(this._camera, this.playerTra.position).y;
  3728. }
  3729. let uiP = new Vector3$5(x, this._y, this._dis);
  3730. let p = MatrixTransform.ScreenToWorld(this._camera, uiP);
  3731. this.playerTra.localPositionX = p.x;
  3732. }
  3733. StartGame() {
  3734. if (this.playerBehavior) {
  3735. this.playerBehavior.StartMove();
  3736. this.playerBehavior.PlayAni(MusicType.RunAndGun, 2);
  3737. }
  3738. }
  3739. SliderPlayer(offsetX) {
  3740. let x = offsetX.toFixed(2);
  3741. let x1 = Number(x) * GlobalVariable.sliderFactor;
  3742. if (this.playerBehavior)
  3743. this.playerBehavior.Slider(x1);
  3744. }
  3745. CreateBullet(isgameover = false) {
  3746. if (!this.playerBehavior)
  3747. return;
  3748. this.isStop = false;
  3749. if (!this.isClickCom)
  3750. return;
  3751. console.log("开始创建子弹");
  3752. this.isClickCom = false;
  3753. this._CreateBullet();
  3754. Laya.timer.loop(PlayerManager.bulletTime * 1000, this, this.LoopCreate);
  3755. }
  3756. LoopCreate() {
  3757. if (this.isStop) {
  3758. Laya.timer.clear(this, this.LoopCreate);
  3759. this.isClickCom = true;
  3760. return;
  3761. }
  3762. this._CreateBullet();
  3763. }
  3764. _CreateBullet() {
  3765. WXSdk.ShortVibrate();
  3766. SettingController.Instance.PlaySound(SoundType.hit);
  3767. let bulletPos = this.playerBehavior.CreateBullet();
  3768. if (bulletPos == null)
  3769. return;
  3770. let bu = GamePool.Instance.SetActiveObject(GamePool.pooltype.PlayerBullet);
  3771. if (bu) {
  3772. Scene3DManager.Instance.bulletCon.addChild(bu);
  3773. bu.transform.position = bulletPos.position.clone();
  3774. bu.transform.localRotationEuler = bulletPos.rotationEuler.clone();
  3775. let pb = bu.getComponent(MainRoleShot);
  3776. if (!pb)
  3777. pb = bu.addComponent(MainRoleShot);
  3778. pb.StartMove(bulletPos, this.isover);
  3779. }
  3780. }
  3781. StopCreate(isgameover = false) {
  3782. this.isStop = true;
  3783. if (!isgameover)
  3784. DispatcherManager.event(EventType.Event.StopShot);
  3785. }
  3786. IsBulleting() {
  3787. return !this.isStop;
  3788. }
  3789. ArriveFinal() {
  3790. MouseEvent.Instance.OnClickUp();
  3791. MainRoleManager.Instance.StopCreate();
  3792. MouseEvent.Instance._Switch = false;
  3793. GameManager.Instance.Arrive();
  3794. if (!this.playerBehavior)
  3795. return;
  3796. this.playerBehavior.Arrive();
  3797. }
  3798. ArriveIsdead() {
  3799. if (!this.playerBehavior)
  3800. return true;
  3801. return this.playerBehavior.isdead;
  3802. }
  3803. ToArrive(count, z) {
  3804. if (!this.playerBehavior)
  3805. return;
  3806. if (count == 1) {
  3807. this.playerBehavior.ToStand(new Vector3$5(0, 0, z));
  3808. }
  3809. else {
  3810. this.playerBehavior.ToStand(new Vector3$5(-GlobalVariable.arriveStandWidth, 0, z));
  3811. }
  3812. }
  3813. StartAtkEnemy() {
  3814. if (!this.playerBehavior)
  3815. return;
  3816. this.isover = true;
  3817. this.playerBehavior.StartAtkEnemy();
  3818. }
  3819. CheackGame(isplayer) {
  3820. if (isplayer) {
  3821. let count = MateManager.Instance.GetArrive();
  3822. if (count == 0) {
  3823. this.playerBehavior.Arrive();
  3824. GameManager.Instance.GameOver();
  3825. }
  3826. }
  3827. else {
  3828. let count = MateManager.Instance.GetArrive();
  3829. if (count == 0) {
  3830. let isplayerdead = this.playerBehavior.isdead;
  3831. if (isplayerdead) {
  3832. this.playerBehavior.Arrive();
  3833. GameManager.Instance.GameOver();
  3834. }
  3835. }
  3836. }
  3837. }
  3838. GoToDance() {
  3839. if (!this.playerBehavior)
  3840. return;
  3841. let t = PlaneManager.Instance.GetDancePos();
  3842. if (!t)
  3843. return;
  3844. this.playerBehavior.Dance(t);
  3845. }
  3846. Reset() {
  3847. for (let index = 0; index < this.FriendArrPos.length; index++) {
  3848. const element = this.FriendArrPos[index];
  3849. element["ishave"] = false;
  3850. }
  3851. this.isover = false;
  3852. if (!this.playerBehavior)
  3853. return;
  3854. this.playerBehavior.Reset();
  3855. }
  3856. SetActiveFalse() {
  3857. if (this.player)
  3858. this.player.active = false;
  3859. }
  3860. }
  3861. var Vector3$6 = Laya.Vector3;
  3862. var CameraState;
  3863. (function (CameraState) {
  3864. CameraState[CameraState["game"] = 1] = "game";
  3865. CameraState[CameraState["jump"] = 2] = "jump";
  3866. })(CameraState || (CameraState = {}));
  3867. class Camera extends Laya.Script3D {
  3868. constructor() {
  3869. super();
  3870. this.arg = 0.1;
  3871. this.canmovegame = false;
  3872. this.startShake = false;
  3873. this.seconds = 0;
  3874. this.started = false;
  3875. this.quake = 0.3;
  3876. }
  3877. onAwake() {
  3878. this.selfObj = this.owner;
  3879. this._tran = this.selfObj.transform;
  3880. this.nowP = Mathf.VecZero;
  3881. this.nowR = Mathf.VecZero;
  3882. this.dis = Mathf.VecZero;
  3883. this.temp = Mathf.VecZero;
  3884. }
  3885. Init() {
  3886. let t = CameraManager.Instance.startPosTra;
  3887. this._tran.position = t.position.clone();
  3888. this._tran.localRotationEuler = Mathf.SpToCam(t.localRotationEuler.clone());
  3889. this.dis.x = MainRoleManager.Instance.playerStartTra.position.x - this._tran.position.x;
  3890. this.dis.y = MainRoleManager.Instance.playerStartTra.position.y - this._tran.position.y;
  3891. this.dis.z = MainRoleManager.Instance.playerStartTra.position.z - this._tran.position.z;
  3892. }
  3893. SetCameraByState(type, arg) {
  3894. this.arg = arg;
  3895. switch (type) {
  3896. case CameraState.game:
  3897. this.tarTra = MainRoleManager.Instance.playerTra;
  3898. if (!this.tarTra)
  3899. return;
  3900. let t = CameraManager.Instance.startPosTra;
  3901. this._tran.position = t.position.clone();
  3902. this._tran.localRotationEuler = Mathf.SpToCam(t.localRotationEuler.clone());
  3903. this.canmovegame = true;
  3904. break;
  3905. case CameraState.jump:
  3906. this.tarTra = PlaneManager.Instance.jumpCamTra;
  3907. if (!this.tarTra)
  3908. return;
  3909. this.canmovegame = false;
  3910. Laya.timer.frameLoop(1, this, this.JumpCameraMove);
  3911. Laya.timer.once(3000, this, this.StopMove);
  3912. break;
  3913. }
  3914. }
  3915. StopMove() {
  3916. Laya.timer.clear(this, this.JumpCameraMove);
  3917. }
  3918. MoveGame(z) {
  3919. if (!this.canmovegame)
  3920. return;
  3921. this.temp.z = z - this.dis.z;
  3922. this._tran.localPositionZ = this.temp.z;
  3923. }
  3924. JumpCameraMove() {
  3925. let p, r;
  3926. if (this.arg == 1) {
  3927. p = this.tarTra.position;
  3928. r = Mathf.SpToCam(this.tarTra.localRotationEuler.clone());
  3929. }
  3930. else {
  3931. p = Mathf.MixVector3(this._tran.position.clone(), this.tarTra.position, this.arg, this.nowP);
  3932. r = Mathf.MixVector3(this._tran.localRotationEuler, Mathf.SpToCam(this.tarTra.localRotationEuler.clone()), this.arg, this.nowR);
  3933. }
  3934. this._tran.position = p;
  3935. this._tran.localRotationEuler = r;
  3936. }
  3937. onDisable() {
  3938. }
  3939. onDestroy() {
  3940. Laya.timer.clearAll(this);
  3941. }
  3942. ShakeFor(a, b) {
  3943. this.camPOS = this.selfObj.transform.position.clone();
  3944. this.seconds = a;
  3945. this.started = true;
  3946. this.startShake = true;
  3947. this.quake = b;
  3948. }
  3949. onLateUpdate() {
  3950. if (this.startShake) {
  3951. this.Quake();
  3952. }
  3953. if (this.started) {
  3954. this.started = false;
  3955. Laya.timer.once(this.seconds * 1000, this, () => {
  3956. this.startShake = false;
  3957. this.selfObj.transform.position = this.camPOS;
  3958. });
  3959. }
  3960. }
  3961. Quake() {
  3962. var x = GameTool.random_1to1() * this.quake;
  3963. var y = GameTool.random_1to1() * this.quake;
  3964. var z = GameTool.random_1to1() * this.quake;
  3965. var temp = new Vector3$6(this.camPOS.x + Math.random() * this.quake, this.camPOS.y + Math.random() * this.quake, this.camPOS.z + Math.random() * this.quake);
  3966. this.selfObj.transform.position = temp;
  3967. }
  3968. }
  3969. class Scene3DManager {
  3970. static get Instance() {
  3971. return Scene3DManager.instance || (Scene3DManager.instance = new Scene3DManager());
  3972. }
  3973. Init(_s) {
  3974. if (_s) {
  3975. this._mainscene = _s;
  3976. Laya.stage.addChild(_s);
  3977. }
  3978. else {
  3979. console.error("场景不存在");
  3980. return;
  3981. }
  3982. let sceneNode;
  3983. sceneNode = this._mainscene.getChildByName("scene");
  3984. if (!sceneNode) {
  3985. console.error("场景资源配置错误!");
  3986. return;
  3987. }
  3988. this._camera = this._mainscene.getChildByName("Main Camera");
  3989. this._camera.enableHDR = false;
  3990. this.bulletCon = sceneNode.getChildByName("bulletContainer");
  3991. this.effectCon = sceneNode.getChildByName("effectPos");
  3992. this.InitSceneArg();
  3993. let build = sceneNode.getChildByName("buildings");
  3994. ConstructManager.Instance.Init(build);
  3995. let playerStartPos = sceneNode.getChildByName("playerstartPoint");
  3996. let playerCon = sceneNode.getChildByName("playerContainer");
  3997. MainRoleManager.Instance.Init(playerStartPos, playerCon);
  3998. let moveBlockContainer = sceneNode.getChildByName("BlockContainer");
  3999. StreetManager.Instance.Init(moveBlockContainer);
  4000. let towerContainer = sceneNode.getChildByName("towerContainer");
  4001. MoundManager.Instance.Init(towerContainer);
  4002. let startCampos1 = sceneNode.getChildByName("startCamPos");
  4003. let startCamposX = sceneNode.getChildByName("startXCamPos");
  4004. let ps;
  4005. if (GameSetting.isX)
  4006. ps = startCamposX;
  4007. else
  4008. ps = startCampos1;
  4009. CameraManager.Instance.Init(this._camera, ps);
  4010. let finalPos = sceneNode.getChildByName("finalPos");
  4011. PlaneManager.Instance.Init(finalPos);
  4012. this.INITGAME();
  4013. }
  4014. INITGAME() {
  4015. Laya.timer.frameOnce(10, this, () => {
  4016. MainRoleManager.Instance.CreatePlayer();
  4017. this.InItScene();
  4018. });
  4019. }
  4020. ;
  4021. InitSceneArg() {
  4022. this._camera.clearFlag = Laya.BaseCamera.CLEARFLAG_SKY;
  4023. let skyRenderer = this._mainscene.skyRenderer;
  4024. skyRenderer.mesh = Laya.SkyDome.instance;
  4025. let mat = new Laya.SkyProceduralMaterial();
  4026. skyRenderer.material = mat;
  4027. mat.sunDisk = Laya.SkyProceduralMaterial.SUN_NODE;
  4028. mat.skyTint = new Laya.Vector4(1, 0.74, 0.74, 1);
  4029. }
  4030. SkyRotate() {
  4031. Laya.timer.frameLoop(2, this, this.St);
  4032. }
  4033. St() {
  4034. if (this.mat)
  4035. this.mat.rotation += 0.1;
  4036. }
  4037. InItScene() {
  4038. LevelController.Instance.SetLevel();
  4039. PlaneManager.Instance.SetAir();
  4040. ConstructManager.Instance.SetBuild();
  4041. CameraManager.Instance.SetCamState(CameraState.game, 1);
  4042. MainRoleManager.Instance.InitPlayerPos();
  4043. }
  4044. }
  4045. class AssetController {
  4046. constructor() {
  4047. this.cloth = [];
  4048. }
  4049. static get Instance() {
  4050. return this.instance || (this.instance = new AssetController());
  4051. }
  4052. LoadAsset(callback) {
  4053. var arr = [
  4054. AssetPath.main_path,
  4055. AssetPath.enemy_path,
  4056. AssetPath.playerBullet_path,
  4057. AssetPath.tower_path,
  4058. ];
  4059. let arr1 = arr.concat(AssetPath.player_path);
  4060. let arr2 = arr1.concat(AssetPath.barrier_paths);
  4061. let arr3 = arr2.concat(AssetPath.effect_path);
  4062. let arr4 = arr3.concat(AssetPath.enemytexture);
  4063. AssetController.LoadResource(arr4, () => {
  4064. this.InitAsset();
  4065. if (callback)
  4066. callback();
  4067. });
  4068. }
  4069. InitAsset() {
  4070. AssetPath.player_path.forEach(element => {
  4071. let _player = Laya.loader.getRes(element);
  4072. Laya.loader.clearRes(element);
  4073. this.LoadPoolRes(_player.name, _player);
  4074. });
  4075. AssetPath.enemytexture.forEach(element => {
  4076. let _tex = Laya.loader.getRes(element);
  4077. Laya.loader.clearRes(element);
  4078. this.cloth.push(_tex);
  4079. });
  4080. AssetPath.effect_path.forEach(element => {
  4081. let _effect = Laya.loader.getRes(element);
  4082. Laya.loader.clearRes(element);
  4083. this.LoadPoolRes(_effect.name, _effect);
  4084. });
  4085. let _enemy = Laya.loader.getRes(AssetPath.enemy_path);
  4086. Laya.loader.clearRes(AssetPath.enemy_path);
  4087. this.LoadPoolRes(_enemy.name, _enemy);
  4088. let _playerbullet = Laya.loader.getRes(AssetPath.playerBullet_path);
  4089. Laya.loader.clearRes(AssetPath.playerBullet_path);
  4090. this.LoadPoolRes(_playerbullet.name, _playerbullet);
  4091. let _tower = Laya.loader.getRes(AssetPath.tower_path);
  4092. Laya.loader.clearRes(AssetPath.tower_path);
  4093. this.LoadPoolRes(_tower.name, _tower);
  4094. let _scene = Laya.loader.getRes(AssetPath.main_path);
  4095. Laya.loader.clearRes(AssetPath.main_path);
  4096. AssetPath.barrier_paths.forEach(element => {
  4097. let _barrier = Laya.loader.getRes(element);
  4098. Laya.loader.clearRes(element);
  4099. this.LoadPoolRes(_barrier.name, _barrier);
  4100. });
  4101. Scene3DManager.Instance.Init(_scene);
  4102. }
  4103. LoadPoolRes(name, prefab) {
  4104. GamePool.Instance.InitData(name, prefab);
  4105. }
  4106. static LoadResource(path, complet) {
  4107. Laya.loader.retryNum = 2;
  4108. Laya.loader.maxLoader = 3;
  4109. Laya.loader.retryDelay = 100;
  4110. Laya.loader.create(path, new Laya.Handler(this, complet));
  4111. Laya.loader.on(Laya.Event.ERROR, this, (data) => {
  4112. console.log(data + " 资源加载失败");
  4113. });
  4114. }
  4115. }
  4116. var Tween = Laya.Tween;
  4117. class LoadView extends ui.LoadViewUI {
  4118. constructor() {
  4119. super();
  4120. this.proCom = false;
  4121. this.a = new Laya.Vector3();
  4122. this.loadResCom = false;
  4123. this.loginCom = false;
  4124. this.errorTime = 0;
  4125. this.timers = 0;
  4126. this.subLoadCom = false;
  4127. LoadView.instance = this;
  4128. DispatcherManager.on(Laya.Event.RESIZE, this, this.resizeHander);
  4129. }
  4130. static get Instance() {
  4131. return LoadView.instance;
  4132. }
  4133. resizeHander() {
  4134. this.height = Laya.stage.height;
  4135. }
  4136. OnShow(data) {
  4137. this.proTex.text = "0%";
  4138. this.pro1.width = 0;
  4139. this.InitUi();
  4140. this.LoginGame();
  4141. this.LoadSubpackage();
  4142. Laya.timer.frameOnce(5, this, () => {
  4143. this.resizeHander();
  4144. });
  4145. WXSdk.AldEvent("进入加载加载界面!");
  4146. }
  4147. InitDate() {
  4148. this.proLen = this.pro.width;
  4149. }
  4150. InitHandler() {
  4151. }
  4152. InitUi() {
  4153. Tween.to(this.a, {
  4154. x: 1, update: new Laya.Handler(this, () => {
  4155. var num = this.a.x;
  4156. this.pro1.width = this.proLen * num;
  4157. num = num * 100;
  4158. this.proTex.text = Math.ceil(num) + "%";
  4159. })
  4160. }, 1500, Laya.Ease.quadInOut, new Laya.Handler(this, () => {
  4161. this.proTex.text = "100%";
  4162. this.pro1.width = this.proLen;
  4163. this.proCom = true;
  4164. this.AllCom();
  4165. }));
  4166. }
  4167. LoadRes() {
  4168. if (this.subLoadCom && this.loginCom) {
  4169. AssetController.Instance.LoadAsset(() => {
  4170. WXSdk.AldEvent("资源加载成功");
  4171. this.loadResCom = true;
  4172. this.AllCom();
  4173. });
  4174. }
  4175. }
  4176. LoginGame() {
  4177. if (GameSetting.isWx) {
  4178. WXSdk.Login((data) => {
  4179. this.onWxLoginHandler(data);
  4180. });
  4181. }
  4182. else {
  4183. this.LocalLogin();
  4184. }
  4185. }
  4186. onWxLoginHandler(params) {
  4187. console.log("微信回调成功!");
  4188. console.log(params);
  4189. if (params == "error" || params.code == null) {
  4190. if (this.errorTime == 0) {
  4191. WXSdk.AldEvent("微信登录失败");
  4192. }
  4193. this.errorTime++;
  4194. if (this.errorTime >= 3)
  4195. return;
  4196. WXSdk.Login((data) => {
  4197. this.onWxLoginHandler(data);
  4198. });
  4199. }
  4200. else {
  4201. if (this.errorTime == 0) {
  4202. WXSdk.AldEvent("微信登录成功!");
  4203. }
  4204. let systemInfo = WXSdk.SystemInfo();
  4205. let platformModel = "ipx";
  4206. if (systemInfo != null) {
  4207. var model = systemInfo.model;
  4208. platformModel = `${systemInfo.brand}_${model}_${systemInfo.system}_wx${systemInfo.version}_SDKVer${systemInfo.SDKVersion}`;
  4209. console.log("platformModel:" + platformModel);
  4210. }
  4211. new UserModel(params.code, params.nickName, params.avatarUrl, params.gender, params.country, params.province, params.city, platformModel, WXSdk.ShareId, WXSdk.Chanel);
  4212. this.LocalLogin();
  4213. }
  4214. }
  4215. LocalLogin() {
  4216. NetManager.Instance.login(null, (data) => {
  4217. this.OnLoginComplete(data);
  4218. }, (data) => {
  4219. this.OnLoginError(data);
  4220. });
  4221. }
  4222. OnLoginComplete(data) {
  4223. if (data["code"] != "0") {
  4224. console.log("登录异常错误!");
  4225. WXSdk.AldEvent("本地登录成功!");
  4226. this.timers++;
  4227. if (this.timers >= 4)
  4228. return;
  4229. if (GameSetting.isWx) {
  4230. WXSdk.Login((data) => {
  4231. this.onWxLoginHandler(data);
  4232. });
  4233. }
  4234. else {
  4235. this.LocalLogin();
  4236. }
  4237. }
  4238. else {
  4239. this.loginCom = true;
  4240. this.LoadRes();
  4241. this.AllCom();
  4242. }
  4243. }
  4244. OnLoginError(data) {
  4245. console.log("登录错误");
  4246. WXSdk.AldEvent("本地登陆失败");
  4247. }
  4248. LoadSubpackage() {
  4249. WXSdk.LoadSubPackage("subpackage", (com) => {
  4250. if (com) {
  4251. console.log("subpackage com++++++++++++++++");
  4252. LoadView.instance.subLoadCom = true;
  4253. WXSdk.LoadSubPackage("subpackage1");
  4254. LoadView.instance.LoadRes();
  4255. }
  4256. });
  4257. }
  4258. AllCom() {
  4259. if (this.proCom && this.loadResCom && this.loginCom) {
  4260. BannerAndVideo1.InitVideo();
  4261. Laya.timer.once(1000, this, () => {
  4262. WXSdk.AldEvent("进入主界面");
  4263. ViewManager.Instance.OpenView(ViewType.MainView);
  4264. MouseEvent.Instance.InitMouseEvent();
  4265. ShareModule.OnShowHandle();
  4266. SettingController.Instance.Init();
  4267. OnHideHandler.Reg();
  4268. SettingController.Instance._playMusic();
  4269. });
  4270. }
  4271. }
  4272. OnClose() {
  4273. LoadView.instance = null;
  4274. DispatcherManager.off(Laya.Event.RESIZE, this, this.resizeHander);
  4275. }
  4276. }
  4277. class MainView extends ui.MainViewUI {
  4278. constructor() {
  4279. super();
  4280. this.isTryed = false;
  4281. MainView.instance = this;
  4282. this.resizeHander();
  4283. DispatcherManager.on(Laya.Event.RESIZE, this, this.resizeHander);
  4284. }
  4285. static get Instance() {
  4286. return MainView.instance;
  4287. }
  4288. OnShow(data) {
  4289. this.InitDate();
  4290. this.InitHandler();
  4291. this.InitUi();
  4292. if (GuideController.Instance.IsGuide()) {
  4293. this.mainBox.visible = false;
  4294. }
  4295. }
  4296. resizeHander() {
  4297. this.height = Laya.stage.height;
  4298. }
  4299. InitUi() {
  4300. this.user_id.text = "user_id:" + UserModel.Instance.CurModel.m_userid;
  4301. this.SetPlayerGrade(UserModel.Instance.CurModel.GetUserAttr(UserAttr.money));
  4302. this.SetStage();
  4303. this.SetStagePro(0);
  4304. this.SetSettingBox(false);
  4305. }
  4306. InitDate() {
  4307. this.GetImage();
  4308. this.coinFollow = new FollowNumber(0.1, 0, 0, 0.1);
  4309. this.proWidth = this.pro.width;
  4310. this.isTryed = false;
  4311. }
  4312. AdaptiveUI() {
  4313. }
  4314. moreFunc(ist) {
  4315. if (ist) ;
  4316. else {
  4317. console.log("mainui");
  4318. }
  4319. }
  4320. InitHandler() {
  4321. this.on(Laya.Event.MOUSE_DOWN, this, this.StartGame);
  4322. this.settingBtn.CZ = () => {
  4323. this.SetSettingBox();
  4324. };
  4325. this.moreGameBtn.clickHandler = new Laya.Handler(this, () => {
  4326. });
  4327. this.coutiBtn.clickHandler = new Laya.Handler(this, () => {
  4328. });
  4329. this.skinBtn.CZ = () => {
  4330. ViewManager.Instance.AddView(ViewType.SKinShopView);
  4331. };
  4332. this.updateBtn.CZ = () => {
  4333. ViewManager.Instance.AddView(ViewType.IntensifyView);
  4334. };
  4335. DispatcherManager.on(EventType.Event.ShowMainUi, this, this.ShowMainBox);
  4336. DispatcherManager.on(EventType.Event.SetMonery, this, this.SetPlayerGrade);
  4337. DispatcherManager.on(EventType.Event.SetStage, this, this.SetStage);
  4338. DispatcherManager.on(EventType.Event.SetStagePro, this, this.SetStagePro);
  4339. this.sound_btn.clickHandler = new Laya.Handler(this, () => {
  4340. this.SoundSetting();
  4341. });
  4342. this.shake_btn.clickHandler = new Laya.Handler(this, () => {
  4343. this.ShakeSetting();
  4344. });
  4345. }
  4346. SetStage() {
  4347. this.stageValue.text = PlayerManager.Instance.stage.toString();
  4348. }
  4349. SetStagePro(value) {
  4350. value = value >= 1 ? 1 : value;
  4351. this.pro1.width = this.proWidth * value;
  4352. }
  4353. SetPlayerGrade(num) {
  4354. this.tempTarGrade = num;
  4355. this.coinFollow.target = num;
  4356. Laya.timer.frameLoop(1, this, this.T2);
  4357. }
  4358. T2() {
  4359. this.coinFollow.update();
  4360. let v = Math.ceil(this.coinFollow.follow);
  4361. this.countValue.text = v.toString();
  4362. if (v >= this.tempTarGrade) {
  4363. this.countValue.text = this.tempTarGrade.toString();
  4364. Laya.timer.clear(this, this.T2);
  4365. }
  4366. }
  4367. StartGame(e) {
  4368. if (this.isTryed) {
  4369. this.TryStartGame();
  4370. return;
  4371. }
  4372. if (e.target instanceof Laya.UIComponent) {
  4373. if (e.target.name != "mainBox")
  4374. return;
  4375. }
  4376. console.log("click");
  4377. let param = [{ "t": UserModel.Instance.CurModel.ServerTime }];
  4378. NetManager.Instance.HttpPostRequest(PROTOCOLS.protocols.Start, param, (data) => {
  4379. if (data["play_id"]) {
  4380. PlayerManager.Instance.Play_Id = data["play_id"];
  4381. }
  4382. WXSdk.Start(PlayerManager.Instance.stage.toString());
  4383. if (PlayerManager.Instance.stage >= 3) {
  4384. ViewManager.Instance.AddView(ViewType.TrialView);
  4385. }
  4386. else {
  4387. this.MainStartGame();
  4388. }
  4389. }, (data) => {
  4390. });
  4391. }
  4392. MainStartGame() {
  4393. this.mainBox.visible = false;
  4394. this.sliderBox.visible = false;
  4395. this.off(Laya.Event.MOUSE_DOWN, this, this.StartGame);
  4396. this.gameStart.stop();
  4397. GameManager.Instance.GameStart();
  4398. MouseEvent.Instance.StartGameClick();
  4399. MainRoleManager.Instance.StartGame();
  4400. MateManager.Instance.TryOutFriendPlayAni();
  4401. StreetManager.Instance.SetBlock();
  4402. GuideController.Instance.StartGuide();
  4403. }
  4404. TryStartGame() {
  4405. this.sliderBox.visible = false;
  4406. this.gameStart.stop();
  4407. this.off(Laya.Event.MOUSE_DOWN, this, this.StartGame);
  4408. GameManager.Instance.GameStart();
  4409. MouseEvent.Instance.StartGameClick();
  4410. MainRoleManager.Instance.StartGame();
  4411. MateManager.Instance.TryOutFriendPlayAni();
  4412. StreetManager.Instance.SetBlock();
  4413. }
  4414. TryClick() {
  4415. this.isTryed = true;
  4416. this.mainBox.visible = false;
  4417. }
  4418. ShowMainBox() {
  4419. this.mainBox.visible = true;
  4420. this.sliderBox.visible = true;
  4421. this.gameStart.play(0, true);
  4422. this.SetPlayerGrade(UserModel.Instance.CurModel.GetUserAttr(UserAttr.money));
  4423. this.isTryed = false;
  4424. this.on(Laya.Event.MOUSE_DOWN, this, this.StartGame);
  4425. }
  4426. SetSettingBox(ist = true) {
  4427. if (!ist) {
  4428. this.settingBox.visible = false;
  4429. return;
  4430. }
  4431. this.settingBox.visible = !this.settingBox.visible;
  4432. }
  4433. GetImage() {
  4434. this.sound_open = this.sound_btn.getChildByName("kai");
  4435. this.sound_guan = this.sound_btn.getChildByName("guan");
  4436. this.shake_open = this.shake_btn.getChildByName("kai");
  4437. this.shake_guan = this.shake_btn.getChildByName("guan");
  4438. this.SoundShow(SettingController.Instance.sound);
  4439. this.ShakeShow(SettingController.Instance.vibrate);
  4440. }
  4441. SoundSetting() {
  4442. SettingController.Instance.sound = !SettingController.Instance.sound;
  4443. this.SoundShow(SettingController.Instance.sound);
  4444. }
  4445. SoundShow(isshow) {
  4446. if (!isshow) {
  4447. this.sound_open.visible = false;
  4448. this.sound_guan.visible = true;
  4449. SettingController.Instance.SettingSound(0);
  4450. Laya.LocalStorage.setItem("sound", "0");
  4451. console.log("关闭声音");
  4452. }
  4453. else {
  4454. this.sound_open.visible = true;
  4455. this.sound_guan.visible = false;
  4456. SettingController.Instance.SettingSound(1);
  4457. Laya.LocalStorage.setItem("sound", "1");
  4458. console.log("开启声音");
  4459. }
  4460. }
  4461. ShakeSetting() {
  4462. SettingController.Instance.vibrate = !SettingController.Instance.vibrate;
  4463. this.ShakeShow(SettingController.Instance.vibrate);
  4464. }
  4465. ShakeShow(isshow) {
  4466. if (!isshow) {
  4467. this.shake_open.visible = false;
  4468. this.shake_guan.visible = true;
  4469. Laya.LocalStorage.setItem("vibrate", "0");
  4470. console.log("关闭震动");
  4471. }
  4472. else {
  4473. this.shake_open.visible = true;
  4474. this.shake_guan.visible = false;
  4475. Laya.LocalStorage.setItem("vibrate", "1");
  4476. console.log("开启震动");
  4477. }
  4478. }
  4479. OnClose() {
  4480. this.off(Laya.Event.MOUSE_DOWN, this, this.StartGame);
  4481. DispatcherManager.off(Laya.Event.RESIZE, this, this.resizeHander);
  4482. DispatcherManager.off(EventType.Event.ShowMainUi, this, this.ShowMainBox);
  4483. DispatcherManager.off(EventType.Event.SetMonery, this, this.SetPlayerGrade);
  4484. DispatcherManager.off(EventType.Event.SetStage, this, this.SetStage);
  4485. DispatcherManager.off(EventType.Event.SetStagePro, this, this.SetStagePro);
  4486. MainView.instance = null;
  4487. Laya.timer.clearAll(this);
  4488. }
  4489. }
  4490. class ShadeView extends ui.ShadeViewUI {
  4491. constructor() {
  4492. super();
  4493. this.resizeHander();
  4494. DispatcherManager.on(Laya.Event.RESIZE, this, this.resizeHander);
  4495. }
  4496. OnShow(data) {
  4497. this.InitHandler();
  4498. }
  4499. InitUi() {
  4500. }
  4501. InitDate() {
  4502. }
  4503. InitHandler() {
  4504. this.on(Laya.Event.CLICK, this, this.Test);
  4505. }
  4506. Test() {
  4507. }
  4508. OnClose() {
  4509. DispatcherManager.off(Laya.Event.RESIZE, this, this.resizeHander);
  4510. this.off(Laya.Event.CLICK, this, this.Test);
  4511. }
  4512. resizeHander() {
  4513. this.height = Laya.stage.height;
  4514. }
  4515. }
  4516. class CompleteView extends ui.CompleteViewUI {
  4517. constructor() {
  4518. super();
  4519. this.isWin = false;
  4520. CompleteView.instance = this;
  4521. this.resizeHander();
  4522. DispatcherManager.on(Laya.Event.RESIZE, this, this.resizeHander);
  4523. }
  4524. static get Instance() {
  4525. return CompleteView.instance;
  4526. }
  4527. OnShow(data) {
  4528. this.isWin = data;
  4529. this.InitDate();
  4530. this.InitHandler();
  4531. this.InitUi();
  4532. BannerAndVideo1.CheatBanner(this.winbtnBox);
  4533. }
  4534. BannerMove() {
  4535. }
  4536. resizeHander() {
  4537. this.height = Laya.stage.height;
  4538. }
  4539. InitDate() {
  4540. this.coinValue = this.isWin == true ? LevelController.Instance._level.gold : LevelController.Instance._level.fail_gold;
  4541. this.tes1 = this.coinValue;
  4542. this.coinValue += (PlayerManager.tower_reward * GameManager.Instance.towerCount + PlayerManager.enemy_reward * GameManager.Instance.roleCount + PlayerManager.block_reward * GameManager.Instance.blockCount);
  4543. let iswin = this.isWin == true ? 1 : 0;
  4544. let count = this.coinValue;
  4545. let param = [{ "t": UserModel.Instance.CurModel.ServerTime }, { "play_id": PlayerManager.Instance.Play_Id }, { "win": iswin }, { "money": count }];
  4546. NetManager.Instance.HttpPostRequest(PROTOCOLS.protocols.GameResult, param, (data) => {
  4547. }, (data) => {
  4548. ViewManager.Instance.ShowTips("结算失败");
  4549. });
  4550. if (this.isWin) {
  4551. SettingController.Instance.PlaySound(SoundType.win);
  4552. WXSdk.Success(PlayerManager.Instance.stage.toString());
  4553. }
  4554. else {
  4555. SettingController.Instance.PlaySound(SoundType.defeat);
  4556. WXSdk.Fail(PlayerManager.Instance.stage.toString());
  4557. }
  4558. }
  4559. InitHandler() {
  4560. this.doublegetBtn.CZ = () => {
  4561. this.DoubleGetHandler();
  4562. };
  4563. this.nextBtn.CZ = () => {
  4564. if (this.isWin) {
  4565. this.NextHandler();
  4566. }
  4567. else {
  4568. this.ResetHandler();
  4569. }
  4570. };
  4571. }
  4572. InitUi() {
  4573. this.winTop.visible = this.isWin;
  4574. this.shibaiTop.visible = !this.isWin;
  4575. this.valueText.text = "+" + this.coinValue;
  4576. this.doubleText.text = (this.coinValue * 3).toString();
  4577. this.towerCount.text = "X" + GameManager.Instance.towerCount.toString();
  4578. this.towerValue.text = (PlayerManager.tower_reward * GameManager.Instance.towerCount).toString();
  4579. this.roleCount.text = "X" + GameManager.Instance.roleCount.toString();
  4580. this.roleValue.text = (PlayerManager.enemy_reward * GameManager.Instance.roleCount).toString();
  4581. this.blockCount.text = "X" + GameManager.Instance.blockCount.toString();
  4582. this.blockValue.text = (PlayerManager.block_reward * GameManager.Instance.blockCount).toString();
  4583. }
  4584. DoubleGetHandler() {
  4585. BannerAndVideo1.ShowVideo((isok) => {
  4586. if (isok) {
  4587. WXSdk.AldEvent("结束界面看视屏获得钱");
  4588. var param = [{ "t": UserModel.Instance.CurModel.ServerTime.toString() }, { "reward_item": "1000" }, { "reward_num": (this.coinValue * 2).toString() }];
  4589. NetManager.Instance.HttpPostRequest(PROTOCOLS.protocols.Fissionvd, param, (data) => {
  4590. ViewManager.Instance.ShowTips("金币:X" + (this.coinValue * 3));
  4591. this.NextHandler();
  4592. }, (data) => {
  4593. });
  4594. }
  4595. });
  4596. }
  4597. NextHandler() {
  4598. GameManager.Instance.NextLevel();
  4599. }
  4600. ResetHandler() {
  4601. ViewManager.Instance.CloseView(ViewType.CompleteView);
  4602. ViewManager.Instance.AddView(ViewType.AttributeUpView);
  4603. }
  4604. OnClose() {
  4605. DispatcherManager.off(Laya.Event.RESIZE, this, this.resizeHander);
  4606. CompleteView.instance = null;
  4607. Laya.timer.clearAll(this);
  4608. BannerAndVideo1.Clear();
  4609. }
  4610. }
  4611. class InGameView extends ui.InGameViewUI {
  4612. static get Instance() {
  4613. return InGameView.instance;
  4614. }
  4615. constructor() {
  4616. super();
  4617. InGameView.instance = this;
  4618. this.resizeHander();
  4619. DispatcherManager.on(Laya.Event.RESIZE, this, this.resizeHander);
  4620. }
  4621. OnShow(data) {
  4622. this.InitDate();
  4623. this.InitHandler();
  4624. this.InitUi();
  4625. }
  4626. resizeHander() {
  4627. this.height = Laya.stage.height;
  4628. }
  4629. InitDate() {
  4630. }
  4631. InitHandler() {
  4632. }
  4633. InitUi() {
  4634. }
  4635. OnClose() {
  4636. DispatcherManager.off(Laya.Event.RESIZE, this, this.resizeHander);
  4637. InGameView.instance = null;
  4638. Laya.timer.clearAll(this);
  4639. }
  4640. }
  4641. class IntensifyView extends ui.IntensifyViewUI {
  4642. constructor() {
  4643. super();
  4644. this.iscoinShowfreecoinbtn = false;
  4645. this.resizeHander();
  4646. DispatcherManager.on(Laya.Event.RESIZE, this, this.resizeHander);
  4647. }
  4648. OnShow(data) {
  4649. this.InitDate();
  4650. this.InitHandler();
  4651. this.InitUi();
  4652. BannerAndVideo1.CheatBanner(null);
  4653. }
  4654. InitUi() {
  4655. this.SetUi();
  4656. this.RefreshCoinShow();
  4657. let t = this.cost1 < this.cost2 ? this.cost1 : this.cost2;
  4658. this.freecoinValue = Math.floor(t * 1.2);
  4659. this.coinValue.text = this.freecoinValue.toString();
  4660. }
  4661. SetUi() {
  4662. this.atkLv.text = "LV" + this.tempPowerLevel;
  4663. let al = CfgManager.Instance._atk.length;
  4664. let t = this.tempPowerLevel > al ? al : this.tempPowerLevel;
  4665. this.cost1 = CfgManager.Instance.GetAtk(t)["cost"];
  4666. this.atkValue.text = this.cost1.toString();
  4667. this.rateLv.text = "LV" + this.tempRateLevel;
  4668. let al1 = CfgManager.Instance._rate.length;
  4669. let t1 = this.tempRateLevel > al1 ? al1 : this.tempRateLevel;
  4670. this.cost2 = CfgManager.Instance.GetRate(t1)["cost"];
  4671. this.rateValue.text = this.cost2.toString();
  4672. if (UserModel.Instance.CurModel.GetUserAttr(UserAttr.money) < this.cost1) {
  4673. this.atkBtn.gray = true;
  4674. this.atkBtn.mouseEnabled = false;
  4675. }
  4676. else {
  4677. this.atkBtn.gray = false;
  4678. this.atkBtn.mouseEnabled = true;
  4679. }
  4680. if (UserModel.Instance.CurModel.GetUserAttr(UserAttr.money) < this.cost2) {
  4681. this.rateBtn.gray = true;
  4682. this.rateBtn.mouseEnabled = false;
  4683. }
  4684. else {
  4685. this.rateBtn.gray = false;
  4686. this.rateBtn.mouseEnabled = true;
  4687. }
  4688. }
  4689. InitDate() {
  4690. this.tempPowerLevel = PlayerManager.Instance.powerLevel;
  4691. this.tempRateLevel = PlayerManager.Instance.rateLevel;
  4692. this.RefreshData();
  4693. }
  4694. RefreshData() {
  4695. let detail = UserModel.Instance.CurModel.user_video.detail;
  4696. if (!detail)
  4697. this.iscoinShowfreecoinbtn = true;
  4698. else {
  4699. let freet = detail.freecoin;
  4700. if (!freet) {
  4701. this.iscoinShowfreecoinbtn = true;
  4702. return;
  4703. }
  4704. if (freet < AppSetting.freeGetcoinTime) {
  4705. this.iscoinShowfreecoinbtn = true;
  4706. return;
  4707. }
  4708. this.iscoinShowfreecoinbtn = false;
  4709. }
  4710. }
  4711. RefreshCoinShow() {
  4712. if (this.iscoinShowfreecoinbtn) {
  4713. this.coinBtn.gray = false;
  4714. this.coinBtn.mouseEnabled = true;
  4715. }
  4716. else {
  4717. this.coinBtn.gray = true;
  4718. this.coinBtn.mouseEnabled = false;
  4719. }
  4720. }
  4721. InitHandler() {
  4722. this.backBtn.CZ = () => {
  4723. ViewManager.Instance.CloseView(ViewType.IntensifyView);
  4724. };
  4725. this.atkBtn.clickHandler = new Laya.Handler(this, this.AtkBtnHandler);
  4726. this.rateBtn.clickHandler = new Laya.Handler(this, this.RateBtnHandler);
  4727. this.coinBtn.clickHandler = new Laya.Handler(this, this.CoinBtnHandler);
  4728. }
  4729. AtkBtnHandler() {
  4730. if (UserModel.Instance.CurModel.GetUserAttr(UserAttr.money) < this.cost1) {
  4731. ViewManager.Instance.ShowTips("金币不足!", 1);
  4732. return;
  4733. }
  4734. PlayerManager.Instance.GradePower(this.tempPowerLevel + 1, "money", this.cost1, (iscom) => {
  4735. if (iscom) {
  4736. WXSdk.AldEvent("升级界面花钱升级攻击力");
  4737. this.tempPowerLevel++;
  4738. this.SetUi();
  4739. DispatcherManager.event(EventType.Event.SetMonery, UserModel.Instance.CurModel.GetUserAttr(UserAttr.money));
  4740. }
  4741. });
  4742. }
  4743. RateBtnHandler() {
  4744. if (UserModel.Instance.CurModel.GetUserAttr(UserAttr.money) < this.cost2) {
  4745. ViewManager.Instance.ShowTips("金币不足!", 1);
  4746. return;
  4747. }
  4748. PlayerManager.Instance.GradeRate(this.tempRateLevel + 1, "money", this.cost2, (iscom) => {
  4749. if (iscom) {
  4750. WXSdk.AldEvent("升级界面花钱升级速度");
  4751. this.tempRateLevel++;
  4752. this.SetUi();
  4753. DispatcherManager.event(EventType.Event.SetMonery, UserModel.Instance.CurModel.GetUserAttr(UserAttr.money));
  4754. }
  4755. });
  4756. }
  4757. CoinBtnHandler() {
  4758. BannerAndVideo1.ShowVideo((isok) => {
  4759. if (isok) {
  4760. var param = [{ "t": UserModel.Instance.CurModel.ServerTime.toString() }, { "reward_item": "1000" }, { "reward_num": (this.freecoinValue).toString() }, { "channel": "video:freecoin" }];
  4761. NetManager.Instance.HttpPostRequest(PROTOCOLS.protocols.Fissionvd, param, (data) => {
  4762. WXSdk.AldEvent("升级界面看视屏获得钱");
  4763. DispatcherManager.event(EventType.Event.SetMonery, UserModel.Instance.CurModel.GetUserAttr(UserAttr.money));
  4764. this.RefreshData();
  4765. this.RefreshCoinShow();
  4766. }, (data) => {
  4767. });
  4768. }
  4769. });
  4770. }
  4771. OnClose() {
  4772. DispatcherManager.off(Laya.Event.RESIZE, this, this.resizeHander);
  4773. if (this.tempPowerLevel != PlayerManager.Instance.powerLevel || this.tempRateLevel != PlayerManager.Instance.rateLevel) {
  4774. PlayerManager.Instance.SetArr();
  4775. }
  4776. BannerAndVideo1.Clear();
  4777. }
  4778. resizeHander() {
  4779. this.height = Laya.stage.height;
  4780. }
  4781. }
  4782. class AttributeUpView extends ui.AttributeUpViewUI {
  4783. constructor() {
  4784. super();
  4785. this.iscanShowVideoBtn = true;
  4786. this.isatkvideo = false;
  4787. this.isfirstatkvideo = true;
  4788. this.isfirstratevideo = true;
  4789. this.isratevideo = false;
  4790. this.atkShow = false;
  4791. this.resizeHander();
  4792. DispatcherManager.on(Laya.Event.RESIZE, this, this.resizeHander);
  4793. }
  4794. OnShow(data) {
  4795. this.InitDate();
  4796. this.InitHandler();
  4797. this.InitUi();
  4798. BannerAndVideo1.CheatBanner(null);
  4799. }
  4800. InitUi() {
  4801. this.SetUi();
  4802. }
  4803. SetUi() {
  4804. this.atkLv.text = "LV" + this.tempPowerLevel;
  4805. let al = CfgManager.Instance._atk.length;
  4806. let t = this.tempPowerLevel > al ? al : this.tempPowerLevel;
  4807. this.cost1 = CfgManager.Instance.GetAtk(t)["cost"];
  4808. this.atkValue.text = this.cost1.toString();
  4809. this.rateLv.text = "LV" + this.tempRateLevel;
  4810. let al1 = CfgManager.Instance._rate.length;
  4811. let t1 = this.tempRateLevel > al1 ? al1 : this.tempRateLevel;
  4812. this.cost2 = CfgManager.Instance.GetRate(t1)["cost"];
  4813. this.rateValue.text = this.cost2.toString();
  4814. if (UserModel.Instance.CurModel.GetUserAttr(UserAttr.money) < this.cost1) {
  4815. if (this.iscanShowVideoBtn && this.isfirstatkvideo) {
  4816. this.isatkvideo = true;
  4817. this._atk.visible = false;
  4818. this._atkVideo.visible = true;
  4819. this.atkBtn.mouseEnabled = true;
  4820. this.atkBtn.gray = false;
  4821. this.click1.visible = true;
  4822. this.atkShow = true;
  4823. }
  4824. else {
  4825. this.atkBtn.mouseEnabled = false;
  4826. this.atkBtn.gray = true;
  4827. this.isatkvideo = false;
  4828. this.click1.visible = false;
  4829. this.atkShow = false;
  4830. }
  4831. }
  4832. else {
  4833. this._atk.visible = true;
  4834. this._atkVideo.visible = false;
  4835. this.atkBtn.gray = false;
  4836. this.atkBtn.mouseEnabled = true;
  4837. this.isatkvideo = false;
  4838. this.click1.visible = true;
  4839. this.atkShow = true;
  4840. }
  4841. if (UserModel.Instance.CurModel.GetUserAttr(UserAttr.money) < this.cost2) {
  4842. if (this.iscanShowVideoBtn && this.isfirstratevideo) {
  4843. this.isratevideo = true;
  4844. this._rate.visible = false;
  4845. this._rateVideo.visible = true;
  4846. this.rateBtn.mouseEnabled = true;
  4847. this.rateBtn.gray = false;
  4848. if (this.atkShow)
  4849. this.click2.visible = false;
  4850. else
  4851. this.click2.visible = true;
  4852. }
  4853. else {
  4854. this.rateBtn.mouseEnabled = false;
  4855. this.rateBtn.gray = true;
  4856. this.isratevideo = false;
  4857. this.click2.visible = false;
  4858. }
  4859. }
  4860. else {
  4861. this._rate.visible = true;
  4862. this._rateVideo.visible = false;
  4863. this.rateBtn.gray = false;
  4864. this.rateBtn.mouseEnabled = true;
  4865. this.isratevideo = false;
  4866. if (this.atkShow)
  4867. this.click2.visible = false;
  4868. else
  4869. this.click2.visible = true;
  4870. }
  4871. }
  4872. InitDate() {
  4873. this.tempPowerLevel = PlayerManager.Instance.powerLevel;
  4874. this.tempRateLevel = PlayerManager.Instance.rateLevel;
  4875. let detail = UserModel.Instance.CurModel.user_video.detail;
  4876. if (!detail)
  4877. this.iscanShowVideoBtn = true;
  4878. else {
  4879. let freet = detail.free;
  4880. if (!freet) {
  4881. this.iscanShowVideoBtn = true;
  4882. return;
  4883. }
  4884. if (freet < AppSetting.freeUpdateVideotime) {
  4885. this.iscanShowVideoBtn = true;
  4886. return;
  4887. }
  4888. {
  4889. this.iscanShowVideoBtn = false;
  4890. }
  4891. }
  4892. }
  4893. InitHandler() {
  4894. this.backBtn.CZ = () => {
  4895. this.BackClickHandler();
  4896. };
  4897. this.atkBtn.clickHandler = new Laya.Handler(this, this.AtkBtnHandler);
  4898. this.rateBtn.clickHandler = new Laya.Handler(this, this.RateBtnHandler);
  4899. }
  4900. AtkBtnHandler() {
  4901. if (this.isatkvideo) {
  4902. BannerAndVideo1.ShowVideo((iscom) => {
  4903. if (iscom) {
  4904. PlayerManager.Instance.GradePower(this.tempPowerLevel + 1, "video:free", this.cost1, (iscom) => {
  4905. if (iscom) {
  4906. WXSdk.AldEvent("失败界面看视屏升级攻击力");
  4907. this.tempPowerLevel++;
  4908. this.isfirstatkvideo = false;
  4909. this.SetUi();
  4910. DispatcherManager.event(EventType.Event.SetMonery, UserModel.Instance.CurModel.GetUserAttr(UserAttr.money));
  4911. }
  4912. });
  4913. }
  4914. });
  4915. }
  4916. else {
  4917. PlayerManager.Instance.GradePower(this.tempPowerLevel + 1, "money", this.cost1, (iscom) => {
  4918. if (iscom) {
  4919. WXSdk.AldEvent("失败界面花钱升级攻击力");
  4920. this.tempPowerLevel++;
  4921. this.SetUi();
  4922. DispatcherManager.event(EventType.Event.SetMonery, UserModel.Instance.CurModel.GetUserAttr(UserAttr.money));
  4923. }
  4924. });
  4925. }
  4926. }
  4927. RateBtnHandler() {
  4928. if (this.isratevideo) {
  4929. BannerAndVideo1.ShowVideo((iscom) => {
  4930. if (iscom) {
  4931. PlayerManager.Instance.GradeRate(this.tempRateLevel + 1, "video:free", this.cost2, (iscom) => {
  4932. if (iscom) {
  4933. WXSdk.AldEvent("失败界面看视屏升级速度");
  4934. this.tempRateLevel++;
  4935. this.isfirstratevideo = false;
  4936. this.SetUi();
  4937. }
  4938. });
  4939. }
  4940. });
  4941. }
  4942. else {
  4943. PlayerManager.Instance.GradeRate(this.tempRateLevel + 1, "money", this.cost2, (iscom) => {
  4944. if (iscom) {
  4945. WXSdk.AldEvent("失败界面花钱升级速度");
  4946. this.tempRateLevel++;
  4947. this.SetUi();
  4948. }
  4949. });
  4950. }
  4951. }
  4952. BackClickHandler() {
  4953. ViewManager.Instance.CloseView(ViewType.AttributeUpView);
  4954. GameManager.Instance.ReStart();
  4955. }
  4956. OnClose() {
  4957. DispatcherManager.off(Laya.Event.RESIZE, this, this.resizeHander);
  4958. if (this.tempPowerLevel != PlayerManager.Instance.powerLevel || this.tempRateLevel != PlayerManager.Instance.rateLevel) {
  4959. PlayerManager.Instance.SetArr();
  4960. DispatcherManager.event(EventType.Event.SetMonery, UserModel.Instance.CurModel.GetUserAttr(UserAttr.money));
  4961. }
  4962. BannerAndVideo1.Clear();
  4963. }
  4964. resizeHander() {
  4965. this.height = Laya.stage.height;
  4966. }
  4967. }
  4968. var Vector3$7 = Laya.Vector3;
  4969. class DisplayerCarController {
  4970. static get Instance() {
  4971. return DisplayerCarController.instance || (DisplayerCarController.instance = new DisplayerCarController());
  4972. }
  4973. InitDis(par) {
  4974. if (!this._scene) {
  4975. this._scene = new Laya.Scene3D();
  4976. this._camera = new Laya.Camera();
  4977. this._camera.enableHDR = false;
  4978. this._scene.addChild(this._camera);
  4979. this._light = new Laya.DirectionLight();
  4980. this._light.transform.rotation = new Laya.Quaternion(-0.24776, 0, 0, 0.9688215);
  4981. this._light.intensity = 0.45;
  4982. this._light.color = new Vector3$7(1, 1, 1);
  4983. this._scene.addChild(this._light);
  4984. let or = 1;
  4985. this._camera.viewport = new Laya.Viewport(par.x * or, par.y * or, par.width * or, par.height * or);
  4986. this._camera.orthographic = false;
  4987. this._camera.enableHDR = false;
  4988. this._camera.clearFlag = 2;
  4989. this._camera.fieldOfView = 60;
  4990. this._camera.transform.position = new Vector3$7(0, 1.52, 3.12);
  4991. this._camera.transform.rotation = new Laya.Quaternion(0, 0, 0, 1);
  4992. }
  4993. let or = 1;
  4994. this._camera.viewport = new Laya.Viewport(par.x * or, par.y * or, par.width * or, par.height * or);
  4995. par.addChild(this._scene);
  4996. this.CreatePlayer();
  4997. }
  4998. CreatePlayer(id) {
  4999. if (!id)
  5000. id = PlayerManager.Instance.equipId;
  5001. if (!this.player) {
  5002. let p = GamePool.Instance.SetActiveObject(GamePool.pooltype.player + id);
  5003. if (p)
  5004. this.player = p;
  5005. this._scene.addChild(this.player);
  5006. this.player.transform.localPosition = Mathf.VecZero;
  5007. this.player.transform.localRotationEuler = Mathf.VecZero;
  5008. }
  5009. else {
  5010. GamePool.Instance.SetDisableObject(this.player);
  5011. let p = GamePool.Instance.SetActiveObject(GamePool.pooltype.player + id);
  5012. if (p)
  5013. this.player = p;
  5014. this._scene.addChild(this.player);
  5015. this.player.transform.localPosition = Mathf.VecZero;
  5016. this.player.transform.localRotationEuler = Mathf.VecZero;
  5017. }
  5018. let anima = this.player.getChildAt(0).getComponent(Laya.Animator);
  5019. anima.play(MusicType.Dance);
  5020. anima.speed = 1;
  5021. }
  5022. Reset() {
  5023. if (this._scene) {
  5024. this._scene.removeSelf();
  5025. }
  5026. if (this.player) {
  5027. GamePool.Instance.SetDisableObject(this.player);
  5028. this.player = null;
  5029. }
  5030. }
  5031. }
  5032. class SKinShopView extends ui.SkinShopViewUI {
  5033. static get Instance() {
  5034. return SKinShopView.instance;
  5035. }
  5036. constructor() {
  5037. super();
  5038. SKinShopView.instance = this;
  5039. this.resizeHander();
  5040. DispatcherManager.on(Laya.Event.RESIZE, this, this.resizeHander);
  5041. }
  5042. resizeHander() {
  5043. this.height = Laya.stage.height;
  5044. }
  5045. OnShow(data) {
  5046. this.InitDate();
  5047. this.InitHandler();
  5048. this.InitUi();
  5049. WXSdk.AldEvent("打开皮肤界面");
  5050. }
  5051. InitDate() {
  5052. this.oignPlayerid = PlayerManager.Instance.equipId;
  5053. this.operateIndex = this.oignPlayerid;
  5054. }
  5055. InitUi(data) {
  5056. this.SetShowbtn(this.operateIndex);
  5057. this.SetUseBtn(this.operateIndex);
  5058. DisplayerCarController.Instance.InitDis(this.viewPort);
  5059. }
  5060. InitHandler() {
  5061. this.backBtn.CZ = () => {
  5062. this.BackHandler();
  5063. };
  5064. this.leftBtn.clickHandler = Laya.Handler.create(this, () => {
  5065. if (this.operateIndex == 1)
  5066. return;
  5067. this.operateIndex--;
  5068. this.SetShowbtn(this.operateIndex);
  5069. this.SetUseBtn(this.operateIndex);
  5070. DisplayerCarController.Instance.CreatePlayer(this.operateIndex);
  5071. }, null, false);
  5072. this.rightBtn.clickHandler = Laya.Handler.create(this, () => {
  5073. if (this.operateIndex == 7)
  5074. return;
  5075. this.operateIndex++;
  5076. this.SetShowbtn(this.operateIndex);
  5077. this.SetUseBtn(this.operateIndex);
  5078. DisplayerCarController.Instance.CreatePlayer(this.operateIndex);
  5079. }, null, false);
  5080. this.use.CZ = () => {
  5081. this.NetEquip();
  5082. };
  5083. this.coin.CZ = () => {
  5084. if (UserModel.Instance.CurModel.GetUserAttr(UserAttr.money) < this.coinValue)
  5085. ViewManager.Instance.ShowTips("金币不足!", 2);
  5086. else
  5087. this.NetBuy();
  5088. };
  5089. this.video.CZ = () => {
  5090. this.VideoBtnHandler();
  5091. };
  5092. }
  5093. SetShowbtn(index) {
  5094. if (index == 1) {
  5095. this.leftBtn.getChildByName("leftFalse").visible = true;
  5096. this.leftBtn.getChildByName("leftTrue").visible = false;
  5097. this.rightBtn.getChildByName("rightFalse").visible = false;
  5098. this.rightBtn.getChildByName("rightTrue").visible = true;
  5099. return;
  5100. }
  5101. if (index == 7) {
  5102. this.leftBtn.getChildByName("leftFalse").visible = false;
  5103. this.leftBtn.getChildByName("leftTrue").visible = true;
  5104. this.rightBtn.getChildByName("rightFalse").visible = true;
  5105. this.rightBtn.getChildByName("rightTrue").visible = false;
  5106. return;
  5107. }
  5108. this.leftBtn.getChildByName("leftFalse").visible = false;
  5109. this.leftBtn.getChildByName("leftTrue").visible = true;
  5110. this.rightBtn.getChildByName("rightFalse").visible = false;
  5111. this.rightBtn.getChildByName("rightTrue").visible = true;
  5112. }
  5113. SetUseBtn(index) {
  5114. if (PlayerManager.Instance.equipId == index) {
  5115. this.using.visible = true;
  5116. this.use.visible = false;
  5117. this.coin.visible = false;
  5118. this.video.visible = false;
  5119. return;
  5120. }
  5121. if (UserModel.Instance.CurModel.HasTheme(index)) {
  5122. this.using.visible = false;
  5123. this.use.visible = true;
  5124. this.coin.visible = false;
  5125. this.video.visible = false;
  5126. return;
  5127. }
  5128. let data = CfgManager.Instance.GetTheme(index);
  5129. if (data.require_type == 2) {
  5130. this.using.visible = false;
  5131. this.use.visible = false;
  5132. this.coin.visible = true;
  5133. this.video.visible = false;
  5134. this.coinValue = Number(data.require_num);
  5135. this.coin.getChildAt(0).getChildAt(0).text = this.coinValue.toString();
  5136. return;
  5137. }
  5138. if (data.require_type == 3) {
  5139. this.using.visible = false;
  5140. this.use.visible = false;
  5141. this.coin.visible = false;
  5142. this.video.visible = true;
  5143. this.video.getChildAt(0).getChildAt(0).text = UserModel.Instance.CurModel.GetThemeProgress(data.id) + "/" + data.require_num;
  5144. return;
  5145. }
  5146. }
  5147. VideoBtnHandler() {
  5148. BannerAndVideo1.ShowVideo((done) => {
  5149. if (done) {
  5150. WXSdk.AldEvent("商店中看视屏获得皮肤");
  5151. this.NetVideo();
  5152. }
  5153. });
  5154. }
  5155. ;
  5156. NetVideo() {
  5157. var param = [{ "t": UserModel.Instance.CurModel.ServerTime.toString() }, { "id": this.operateIndex }, { "channel": "video" }];
  5158. NetManager.Instance.HttpPostRequest(PROTOCOLS.protocols.themefission, param, (data) => {
  5159. var usermodel = UserModel.Instance.CurModel;
  5160. PlayerManager.Instance.equipId = Number(usermodel.GetUserAttr(UserAttr.equip_themes)["1"]);
  5161. this.SetUseBtn(this.operateIndex);
  5162. }, (data) => {
  5163. });
  5164. }
  5165. NetBuy() {
  5166. var param = [{ "id": this.operateIndex }];
  5167. NetManager.Instance.HttpPostRequest(PROTOCOLS.protocols.Buy, param, (data) => {
  5168. var usermodel = UserModel.Instance.CurModel;
  5169. PlayerManager.Instance.equipId = Number(usermodel.GetUserAttr(UserAttr.equip_themes)["1"]);
  5170. DispatcherManager.event(EventType.Event.SetMonery, UserModel.Instance.CurModel.GetUserAttr(UserAttr.money));
  5171. this.SetUseBtn(this.operateIndex);
  5172. }, (data) => {
  5173. });
  5174. }
  5175. NetEquip() {
  5176. var param = [{ "id": this.operateIndex }];
  5177. NetManager.Instance.HttpPostRequest(PROTOCOLS.protocols.Equip, param, (data) => {
  5178. var usermodel = UserModel.Instance.CurModel;
  5179. PlayerManager.Instance.equipId = Number(usermodel.GetUserAttr(UserAttr.equip_themes)["1"]);
  5180. this.SetUseBtn(this.operateIndex);
  5181. }, (data) => {
  5182. });
  5183. }
  5184. BackHandler() {
  5185. DisplayerCarController.Instance.Reset();
  5186. if (this.oignPlayerid != PlayerManager.Instance.equipId) {
  5187. MainRoleManager.Instance.ChangePlayer();
  5188. }
  5189. ViewManager.Instance.CloseView(ViewType.SKinShopView);
  5190. }
  5191. OnClose() {
  5192. DispatcherManager.off(Laya.Event.RESIZE, this, this.resizeHander);
  5193. SKinShopView.instance = null;
  5194. WXSdk.AldEvent("关闭皮肤界面");
  5195. }
  5196. }
  5197. class TrialView extends ui.TrialViewUI {
  5198. constructor() {
  5199. super();
  5200. this.resizeHander();
  5201. DispatcherManager.on(Laya.Event.RESIZE, this, this.resizeHander);
  5202. }
  5203. OnShow(data) {
  5204. this.InitHandler();
  5205. this.InitDate();
  5206. this.InitHandler();
  5207. this.InitUi();
  5208. BannerAndVideo1.CheatBanner(this.btnBox);
  5209. }
  5210. InitUi() {
  5211. DisplayerCarController.Instance.InitDis(this.viewPort);
  5212. }
  5213. InitDate() {
  5214. }
  5215. InitHandler() {
  5216. this.videoBtn.CZ = () => {
  5217. this.VideoHandler();
  5218. };
  5219. this.backBtn.CZ = () => {
  5220. DisplayerCarController.Instance.Reset();
  5221. this.BackUi();
  5222. };
  5223. }
  5224. VideoHandler() {
  5225. BannerAndVideo1.ShowVideo((isok) => {
  5226. if (isok) {
  5227. WXSdk.AldEvent("看视屏试用");
  5228. this.VideoCom();
  5229. }
  5230. });
  5231. }
  5232. VideoCom() {
  5233. DisplayerCarController.Instance.Reset();
  5234. this.BackUi();
  5235. MateManager.Instance.CreateTryOut();
  5236. }
  5237. BackUi() {
  5238. ViewManager.Instance.CloseView(ViewType.TrialView);
  5239. if (MainView.Instance)
  5240. MainView.Instance.TryClick();
  5241. }
  5242. OnClose() {
  5243. DispatcherManager.off(Laya.Event.RESIZE, this, this.resizeHander);
  5244. BannerAndVideo1.Clear();
  5245. }
  5246. resizeHander() {
  5247. this.height = Laya.stage.height;
  5248. }
  5249. }
  5250. var ViewType;
  5251. (function (ViewType) {
  5252. ViewType[ViewType["InGameView"] = 0] = "InGameView";
  5253. ViewType[ViewType["ShadeView"] = 1] = "ShadeView";
  5254. ViewType[ViewType["CompleteView"] = 2] = "CompleteView";
  5255. ViewType[ViewType["LoadView"] = 3] = "LoadView";
  5256. ViewType[ViewType["MainView"] = 4] = "MainView";
  5257. ViewType[ViewType["SettingUi"] = 5] = "SettingUi";
  5258. ViewType[ViewType["SKinShopView"] = 6] = "SKinShopView";
  5259. ViewType[ViewType["TrialView"] = 7] = "TrialView";
  5260. ViewType[ViewType["IntensifyView"] = 8] = "IntensifyView";
  5261. ViewType[ViewType["AttributeUpView"] = 9] = "AttributeUpView";
  5262. })(ViewType || (ViewType = {}));
  5263. class ViewManager {
  5264. constructor() {
  5265. this.viewDic = [];
  5266. this.addViewDic = new Dictionary();
  5267. this._maskCnt = 0;
  5268. this.init();
  5269. }
  5270. static get Instance() {
  5271. return this.instance || (this.instance = new ViewManager());
  5272. }
  5273. init() {
  5274. this._maskCnt = 0;
  5275. this.viewDic[ViewType.InGameView] = InGameView;
  5276. this.viewDic[ViewType.LoadView] = LoadView;
  5277. this.viewDic[ViewType.MainView] = MainView;
  5278. this.viewDic[ViewType.ShadeView] = ShadeView;
  5279. this.viewDic[ViewType.IntensifyView] = IntensifyView;
  5280. this.viewDic[ViewType.CompleteView] = CompleteView;
  5281. this.viewDic[ViewType.SKinShopView] = SKinShopView;
  5282. this.viewDic[ViewType.TrialView] = TrialView;
  5283. this.viewDic[ViewType.AttributeUpView] = AttributeUpView;
  5284. this.uiNode = new Laya.Sprite();
  5285. this.popNode = new Laya.Sprite();
  5286. Laya.stage.addChild(this.uiNode);
  5287. Laya.stage.addChild(this.popNode);
  5288. this.uiNode.zOrder = 3;
  5289. this.popNode.zOrder = 4;
  5290. }
  5291. OpenView(view, data) {
  5292. if (this.curView != null) {
  5293. this.curView.OnClose();
  5294. this.uiNode.removeChild(this.curView);
  5295. this.curView.destroy(true);
  5296. this.curView = null;
  5297. }
  5298. this.curView = new this.viewDic[view];
  5299. this.uiNode.addChild(this.curView);
  5300. this.curView.OnShow(data);
  5301. }
  5302. get getCurView() {
  5303. return this.curView;
  5304. }
  5305. AddView(view, data) {
  5306. if (this.addViewDic.has(view))
  5307. return;
  5308. let t_view = new this.viewDic[view];
  5309. this.addViewDic.set(view, t_view);
  5310. this.uiNode.addChild(t_view);
  5311. t_view.OnShow(data);
  5312. MouseEvent.Instance.CloseInput();
  5313. }
  5314. RemoveView() {
  5315. if (this.curView != null) {
  5316. this.curView.OnClose();
  5317. this.uiNode.removeChild(this.curView);
  5318. this.curView.destroy(true);
  5319. this.curView = null;
  5320. }
  5321. }
  5322. HaveView(view) {
  5323. return this.addViewDic.has(view);
  5324. }
  5325. CloseView(view) {
  5326. if (!this.addViewDic.has(view))
  5327. return;
  5328. let t_view = this.addViewDic.get(view);
  5329. t_view.OnClose();
  5330. this.uiNode.removeChild(t_view);
  5331. t_view.destroy(true);
  5332. this.addViewDic.delete(view);
  5333. MouseEvent.Instance.OpenInput();
  5334. }
  5335. OpenMask() {
  5336. this._maskCnt++;
  5337. if (this._maskCnt > 1)
  5338. return;
  5339. if (this.curMask != null) {
  5340. this.curMask.OnClose();
  5341. this.popNode.removeChild(this.curView);
  5342. this.curMask.destroy();
  5343. this.curMask = null;
  5344. return;
  5345. }
  5346. this.curMask = new this.viewDic[ViewType.ShadeView];
  5347. if (!this.curMask)
  5348. return;
  5349. console.log("打开遮罩");
  5350. this.popNode.addChild(this.curMask);
  5351. this.curMask.OnShow();
  5352. }
  5353. CloseMask() {
  5354. this._maskCnt--;
  5355. if (this._maskCnt > 0)
  5356. return;
  5357. if (this.curMask != null) {
  5358. this.curMask.OnClose();
  5359. this.popNode.removeChild(this.curMask);
  5360. this.curMask.destroy(true);
  5361. console.log("关闭遮罩");
  5362. this.curMask = null;
  5363. }
  5364. }
  5365. ShowTips(value, type = 1) {
  5366. var warn = GamePool.Instance.SetActiveForUi(PoolType.WarnTips);
  5367. if (!warn)
  5368. return;
  5369. if (type == 1) {
  5370. warn.y = 0;
  5371. warn.text = value;
  5372. warn.x = Laya.stage.width >> 1;
  5373. this.popNode.addChild(warn);
  5374. let _end = (Laya.stage.height >> 1) - 300;
  5375. var tw = Laya.Tween.to(warn, { y: _end }, 1000, Laya.Ease.bounceOut, new Laya.Handler(this, () => {
  5376. tw.clear();
  5377. GamePool.Instance.SetDisableForUi(PoolType.WarnTips, warn);
  5378. }));
  5379. }
  5380. else if (type == 2) {
  5381. warn.y = Laya.stage.height - 400;
  5382. warn.text = value;
  5383. warn.x = Laya.stage.width >> 1;
  5384. this.popNode.addChild(warn);
  5385. var tw = Laya.Tween.to(warn, { alpha: 0 }, 1000, Laya.Ease.bounceOut, new Laya.Handler(this, () => {
  5386. tw.clear();
  5387. GamePool.Instance.SetDisableForUi(PoolType.WarnTips, warn);
  5388. warn.alpha = 1;
  5389. }));
  5390. }
  5391. }
  5392. ShowGuideView() {
  5393. if (!this.GuideView) {
  5394. this.GuideView = new GuideView();
  5395. this.popNode.addChild(this.GuideView);
  5396. }
  5397. this.GuideView.OnShow();
  5398. }
  5399. CloseGuideView() {
  5400. if (this.GuideView) {
  5401. this.GuideView.OnClose();
  5402. this.GuideView.removeSelf();
  5403. this.GuideView.destroy();
  5404. }
  5405. }
  5406. }
  5407. class ShareModule {
  5408. static GoShare(callBack) {
  5409. ShareModule.ShareTime = new Date().getTime();
  5410. console.log("分享点击时间=" + ShareModule.ShareTime);
  5411. ShareModule.IsSharing = true;
  5412. ShareModule.callback = callBack;
  5413. }
  5414. static OnShowHandle() {
  5415. if (Laya.Browser.window.wx) {
  5416. Laya.Browser.window.wx.onShow(function (option) {
  5417. SettingController.Instance.SetSoundV(1);
  5418. console.log("onshow share start");
  5419. console.log("进入微信");
  5420. if (ShareModule.IsSharing) {
  5421. ShareModule.IsSharing = false;
  5422. let time = new Date().getTime();
  5423. console.log("分享回到游戏时间" + time);
  5424. let wait = (time - ShareModule.ShareTime) / 1000;
  5425. console.log("分享停留时间为:" + wait);
  5426. if (wait >= 2) {
  5427. if (Math.random() <= 1) {
  5428. if (!ShareModule.callback)
  5429. return;
  5430. ShareModule.callback(true, 1);
  5431. }
  5432. else {
  5433. if (!ShareModule.callback)
  5434. return;
  5435. if (Math.random() <= 0.5) {
  5436. ViewManager.Instance.ShowTips("分享失败!");
  5437. }
  5438. else {
  5439. ViewManager.Instance.ShowTips("请分享到不同的群!");
  5440. }
  5441. ShareModule.callback(false, 1);
  5442. }
  5443. }
  5444. else {
  5445. if (!ShareModule.callback)
  5446. return;
  5447. if (Math.random() <= 0.5) {
  5448. ViewManager.Instance.ShowTips("分享失败!");
  5449. }
  5450. else {
  5451. ViewManager.Instance.ShowTips("请分享到不同的群!");
  5452. }
  5453. ShareModule.callback(false, 1);
  5454. }
  5455. }
  5456. });
  5457. }
  5458. }
  5459. }
  5460. ShareModule.IsSharing = false;
  5461. class OnHideHandler {
  5462. static Reg() {
  5463. }
  5464. }
  5465. var ALDType;
  5466. (function (ALDType) {
  5467. ALDType[ALDType["\u767B\u5F55\u52A0\u8F7D"] = 0] = "\u767B\u5F55\u52A0\u8F7D";
  5468. ALDType[ALDType["\u754C\u9762\u5F00\u542F"] = 1] = "\u754C\u9762\u5F00\u542F";
  5469. })(ALDType || (ALDType = {}));
  5470. class WXSdk {
  5471. static get ShareId() {
  5472. return this.shareId;
  5473. }
  5474. static get Chanel() {
  5475. return this._chanel;
  5476. }
  5477. static init(cb) {
  5478. this.EventStatistics();
  5479. Laya.Browser.window.wx.showShareMenu({
  5480. withShareTicket: true
  5481. });
  5482. Laya.Browser.window.wx.onShow(this.InitWx);
  5483. }
  5484. static InitWx(option) {
  5485. var shareid = option.query.share_id;
  5486. this.shareId = shareid ? shareid : "";
  5487. GameSetting.wxValue = option.scene;
  5488. var scene = Laya.LocalStorage.getItem("scene");
  5489. if (scene) {
  5490. GameSetting.wxValue = scene;
  5491. console.log("读取配置场景值:" + scene);
  5492. }
  5493. else {
  5494. console.log("第一次拉取场景值:" + GameSetting.wxValue);
  5495. Laya.LocalStorage.setItem("scene", GameSetting.wxValue);
  5496. }
  5497. var channel = option.query.channel;
  5498. this._chanel = channel ? channel : "";
  5499. Laya.Browser.window.wx.offShow(WXSdk.InitWx);
  5500. }
  5501. static ShareMessage() {
  5502. if (!GameSetting.isWx)
  5503. return;
  5504. var t = UserModel.Instance.CurModel.ServerTime;
  5505. var _title;
  5506. var _url;
  5507. _title = AppSetting.sharetitle;
  5508. _url = AppSetting.shareimage;
  5509. if (_title == null) {
  5510. _title = "枪王之王...";
  5511. _url = "res/share.png";
  5512. }
  5513. else {
  5514. let a = GameTool.SpliteString(_title);
  5515. let b = GameTool.SpliteString(_url);
  5516. _title = a[GameTool.randomInt(0, a.length - 1)];
  5517. _url = b[GameTool.randomInt(0, b.length - 1)];
  5518. }
  5519. console.log("_title:", _title);
  5520. console.log("_url:", _url);
  5521. Laya.Browser.window.wx.onShareAppMessage(() => ({
  5522. title: _title,
  5523. imageUrl: _url,
  5524. query: "share_id=" + UserModel.Instance.CurModel.m_userid + "_other_" + t + "_" + Math.floor(9999 * Math.random()).toString()
  5525. }));
  5526. }
  5527. static Login(cb) {
  5528. if (WXSdk.Lodining) {
  5529. return;
  5530. }
  5531. WXSdk.Lodining = true;
  5532. Laya.Browser.window.wx.login({
  5533. success: function (res) {
  5534. console.log("wx.login: success! res.code=" + res.code);
  5535. if (res.code) {
  5536. WXSdk.Lodining = false;
  5537. console.log("将要传递的参数:" + res);
  5538. cb(res);
  5539. }
  5540. else {
  5541. console.log('获取用户登录态失败!' + res.errMsg);
  5542. cb("error");
  5543. }
  5544. },
  5545. fail: function (res) { console.log("wx.login: failed, res=" + res); WXSdk.Lodining = false; cb("error"); }
  5546. });
  5547. }
  5548. static ShowLoading(title = "加载中...", isShowWx = true) {
  5549. console.log(title);
  5550. if (Laya.Browser.window && Laya.Browser.window.wx) {
  5551. if (isShowWx) {
  5552. Laya.Browser.window.wx.showLoading({ title: title, mask: true });
  5553. }
  5554. ViewManager.Instance.OpenMask();
  5555. }
  5556. else {
  5557. ViewManager.Instance.OpenMask();
  5558. }
  5559. }
  5560. static HideLoading(isShowWx = true) {
  5561. if (Laya.Browser.window && Laya.Browser.window.wx) {
  5562. if (isShowWx) {
  5563. Laya.Browser.window.wx.hideLoading();
  5564. }
  5565. ViewManager.Instance.CloseMask();
  5566. }
  5567. else {
  5568. ViewManager.Instance.CloseMask();
  5569. }
  5570. }
  5571. static SystemInfo() {
  5572. if (Laya.Browser.window.wx) {
  5573. if (!WXSdk.sysdata)
  5574. WXSdk.sysdata = Laya.Browser.window.wx.getSystemInfoSync();
  5575. return WXSdk.sysdata;
  5576. }
  5577. }
  5578. static ShowToast(text, icon = true) {
  5579. if (Laya.Browser.window.wx) {
  5580. var t_icon = icon ? "success" : "none";
  5581. text = text ? text : "暂未开放...";
  5582. Laya.Browser.window.wx.showToast({ title: text, icon: t_icon });
  5583. }
  5584. else {
  5585. console.log(text);
  5586. }
  5587. }
  5588. static ShortVibrate() {
  5589. if (Laya.Browser.window.wx && SettingController.Instance.vibrate) {
  5590. if (WXSdk.vibrating)
  5591. return;
  5592. WXSdk.vibrating = true;
  5593. Laya.Browser.window.wx.vibrateShort({
  5594. complete: function (res) {
  5595. WXSdk.vibrating = false;
  5596. }
  5597. });
  5598. }
  5599. }
  5600. static LongVibrate() {
  5601. if (Laya.Browser.window.wx && SettingController.Instance.vibrate) {
  5602. if (WXSdk.vibrating)
  5603. return;
  5604. WXSdk.vibrating = true;
  5605. Laya.Browser.window.wx.vibrateLong({
  5606. complete: function (res) {
  5607. WXSdk.vibrating = false;
  5608. }
  5609. });
  5610. }
  5611. }
  5612. static Success(stageId) {
  5613. if (!GameSetting.isWx)
  5614. return;
  5615. Laya.Browser.window.wx.aldStage.onEnd({
  5616. stageId: stageId,
  5617. stageName: "第" + stageId + "关",
  5618. event: "complete",
  5619. params: {
  5620. desc: "关卡完成"
  5621. }
  5622. });
  5623. }
  5624. static AldEvent(eventName, a) {
  5625. if (Laya.Browser.window && Laya.Browser.window.wx) {
  5626. Laya.Browser.window.wx.aldSendEvent(eventName, { key: "" });
  5627. }
  5628. }
  5629. static EventStatistics() {
  5630. let uuid = Laya.LocalStorage.getItem("uuidTimes");
  5631. if (uuid) {
  5632. let lastSignTime = new Date(Number(uuid));
  5633. let todayZero = new Date(Laya.timer.currTimer);
  5634. todayZero.setHours(0, 0, 0, 0);
  5635. if (lastSignTime.valueOf() < todayZero.valueOf()) {
  5636. this.IsNew = 0;
  5637. }
  5638. else {
  5639. this.IsNew = 1;
  5640. }
  5641. }
  5642. else {
  5643. this.IsNew = 1;
  5644. Laya.LocalStorage.setItem("uuidTimes", Laya.timer.currTimer.toString());
  5645. }
  5646. }
  5647. static Fail(stageId) {
  5648. if (!GameSetting.isWx)
  5649. return;
  5650. Laya.Browser.window.wx.aldStage.onEnd({
  5651. stageId: stageId,
  5652. stageName: "第" + stageId + "关",
  5653. event: "fail",
  5654. params: {
  5655. desc: "关卡失败",
  5656. }
  5657. });
  5658. }
  5659. static Start(stageId) {
  5660. if (!GameSetting.isWx)
  5661. return;
  5662. Laya.Browser.window.wx.aldStage.onStart({
  5663. stageId: stageId,
  5664. stageName: "第" + stageId + "关",
  5665. });
  5666. }
  5667. static Game_Share(callback = null, channel = "") {
  5668. if (!GameSetting.isWx) {
  5669. return;
  5670. }
  5671. var _title;
  5672. var _url;
  5673. _title = AppSetting.sharetitle;
  5674. _url = AppSetting.shareimage;
  5675. if (_title == null) {
  5676. _title = "枪王之王...";
  5677. _url = "res/share.png";
  5678. }
  5679. else {
  5680. let a = GameTool.SpliteString(_title);
  5681. let b = GameTool.SpliteString(_url);
  5682. _title = a[GameTool.randomInt(0, a.length - 1)];
  5683. _url = b[GameTool.randomInt(0, b.length - 1)];
  5684. }
  5685. console.log("_title:", _title);
  5686. console.log("_url:", _url);
  5687. var t = UserModel.Instance.CurModel.ServerTime;
  5688. Laya.Browser.window.wx.shareAppMessage({
  5689. title: _title,
  5690. imageUrl: _url,
  5691. query: "share_id=" + UserModel.Instance.CurModel.m_userid + "_" + "other" + "_" + t + "_" + Math.floor(9999 * Math.random()).toString(),
  5692. });
  5693. ShareModule.GoShare(callback);
  5694. }
  5695. static LoadSubPackage(name, callback) {
  5696. if (GameSetting.isWx) {
  5697. const loadTask = Laya.Browser.window.wx.loadSubpackage({
  5698. name: name,
  5699. success(res) {
  5700. console.log("分包下载成功:", res);
  5701. if (callback)
  5702. callback(true);
  5703. },
  5704. fail(res) {
  5705. console.log("分包下载失败:" + JSON.stringify(res));
  5706. if (callback)
  5707. callback(false);
  5708. }
  5709. });
  5710. }
  5711. else {
  5712. if (callback)
  5713. callback(true);
  5714. }
  5715. }
  5716. static IsNeedUpdate() {
  5717. if (!GameSetting.isWx)
  5718. return false;
  5719. const updateManager = Laya.Browser.window.wx.getUpdateManager();
  5720. updateManager.onCheckForUpdate(function (res) {
  5721. console.log("最新版本:" + res.hasUpdate);
  5722. });
  5723. updateManager.onUpdateReady(function () {
  5724. Laya.Browser.window.wx.showModal({
  5725. showCancel: false,
  5726. title: '更新提示',
  5727. content: '新版本已经准备好,是否重启应用?',
  5728. success(res) {
  5729. updateManager.applyUpdate();
  5730. },
  5731. fail(res) {
  5732. updateManager.applyUpdate();
  5733. }
  5734. });
  5735. });
  5736. }
  5737. static IsAuth() {
  5738. if (Laya.Browser.window && Laya.Browser.window.wx) {
  5739. Laya.Browser.window.wx.getSetting({
  5740. success: (res) => {
  5741. console.log("授权结果..");
  5742. console.log(res);
  5743. if (res.authSetting['scope.userInfo'] == true) {
  5744. WXSdk.isAuth = true;
  5745. Laya.Browser.window.wx.getUserInfo({
  5746. lang: 'zh_CN',
  5747. success: (res) => {
  5748. UserModel.Instance.CurModel.m_nickname = res.userInfo.nickName;
  5749. UserModel.Instance.CurModel.m_avatar = res.userInfo.avatarUrl;
  5750. console.log("已经受过权");
  5751. },
  5752. fail: () => {
  5753. console.log('调用getUserInfo fail');
  5754. }
  5755. });
  5756. }
  5757. }
  5758. });
  5759. }
  5760. }
  5761. static RequestAuth(callback) {
  5762. if (WXSdk.isAuth) {
  5763. if (callback != null) {
  5764. callback(true);
  5765. }
  5766. return;
  5767. }
  5768. if (GameSetting.isWx) {
  5769. console.log("-----授权");
  5770. let openAuthView = () => {
  5771. let w = Laya.stage.width;
  5772. let h = Laya.stage.height;
  5773. console.log("准备授权");
  5774. let button = Laya.Browser.window.wx.createUserInfoButton({
  5775. type: 'text',
  5776. text: '',
  5777. style: {
  5778. left: 0,
  5779. top: 0,
  5780. width: w,
  5781. height: h,
  5782. lineHeight: 40,
  5783. backgroundColor: '#00000000',
  5784. textAlign: 'center',
  5785. fontSize: 16,
  5786. borderRadius: 4
  5787. }
  5788. });
  5789. let opTapHandler = (res) => {
  5790. console.log("res:" + JSON.stringify(res));
  5791. if (res.userInfo) {
  5792. button.hide();
  5793. button.offTap(opTapHandler);
  5794. button.destroy();
  5795. console.log("userinfo", res);
  5796. UserModel.Instance.CurModel.m_nickname = res.userInfo.nickName;
  5797. UserModel.Instance.CurModel.m_avatar = res.userInfo.avatarUrl;
  5798. let param = [{ "nickname": res.userInfo.nickName }, { "avatar": res.userInfo.avatarUrl }, { "gender": res.userInfo.gender }, { "city": res.userInfo.city },
  5799. { "country": res.userInfo.country }, { "province": res.userInfo.province }];
  5800. NetManager.Instance.HttpPostRequest(PROTOCOLS.protocols.Userauth, param, () => {
  5801. WXSdk.isAuth = true;
  5802. if (callback != null) {
  5803. callback(true);
  5804. }
  5805. }, null);
  5806. }
  5807. else {
  5808. button.hide();
  5809. button.offTap(opTapHandler);
  5810. button.destroy();
  5811. if (callback != null) {
  5812. callback(false);
  5813. }
  5814. }
  5815. };
  5816. button.show();
  5817. button.onTap(opTapHandler);
  5818. };
  5819. openAuthView();
  5820. }
  5821. else {
  5822. WXSdk.isAuth = true;
  5823. if (callback != null) {
  5824. callback(true);
  5825. }
  5826. }
  5827. }
  5828. static showbjWxGameQuan(flag) {
  5829. if (!GameSetting.isWx) {
  5830. return;
  5831. }
  5832. if (flag) {
  5833. if (this.button == null) {
  5834. let info = Laya.Browser.window.wx.getSystemInfoSync();
  5835. if (!info)
  5836. return;
  5837. var top = 0.5 * info.windowHeight;
  5838. var height = 109 * info.windowHeight / Laya.stage.height;
  5839. var width = height * 80 / 109;
  5840. Laya.stage.width;
  5841. this.button = Laya.Browser.window.wx.createGameClubButton({
  5842. type: "image",
  5843. image: 'res/talk.png',
  5844. style: {
  5845. left: info.windowWidth * 0.5 + 150 * info.windowWidth / Laya.stage.width,
  5846. top: top - 240 * info.windowHeight / Laya.stage.height,
  5847. width: width,
  5848. height: height
  5849. }
  5850. });
  5851. }
  5852. this.button.show();
  5853. }
  5854. else {
  5855. if (this.button) {
  5856. this.button.hide();
  5857. }
  5858. }
  5859. }
  5860. }
  5861. WXSdk.Lodining = false;
  5862. WXSdk.shareId = "";
  5863. WXSdk._chanel = "";
  5864. WXSdk.isAuth = false;
  5865. WXSdk.vibrating = false;
  5866. WXSdk.IsNew = 0;
  5867. class Main {
  5868. constructor() {
  5869. window['Config3D'] && (window['Config3D']["_config"]["_defaultPhysicsMemory"] = 128);
  5870. window['Config3D'] && (window['Config3D']["_config"]["isAntialias"] = true);
  5871. if (window["Laya3D"])
  5872. Laya3D.init(GameConfig.width, GameConfig.height);
  5873. else
  5874. Laya.init(GameConfig.width, GameConfig.height, Laya["WebGL"]);
  5875. Laya["Physics"] && Laya["Physics"].enable();
  5876. Laya["DebugPanel"] && Laya["DebugPanel"].enable();
  5877. Laya.stage.scaleMode = GameConfig.scaleMode;
  5878. Laya.stage.screenMode = GameConfig.screenMode;
  5879. Laya.stage.alignV = GameConfig.alignV;
  5880. Laya.stage.alignH = GameConfig.alignH;
  5881. Laya.URL.exportSceneToJson = GameConfig.exportSceneToJson;
  5882. if (GameConfig.debug || Laya.Utils.getQueryString("debug") == "true")
  5883. Laya.enableDebugPanel();
  5884. if (GameConfig.physicsDebug && Laya["PhysicsDebugDraw"])
  5885. Laya["PhysicsDebugDraw"].enable();
  5886. if (GameConfig.stat)
  5887. Laya.Stat.show();
  5888. Laya.alertGlobalError = true;
  5889. GameSetting.isWx = Laya.Browser.onWeiXin;
  5890. if (GameSetting.isWx) {
  5891. WXSdk.init();
  5892. }
  5893. Laya.ResourceVersion.enable("version.json", Laya.Handler.create(this, this.onVersionLoaded), Laya.ResourceVersion.FILENAME_VERSION);
  5894. WXSdk.IsNeedUpdate();
  5895. }
  5896. onVersionLoaded() {
  5897. Laya.AtlasInfoManager.enable("fileconfig.json", Laya.Handler.create(this, this.onConfigLoaded));
  5898. Laya.MouseManager.multiTouchEnabled = false;
  5899. }
  5900. onConfigLoaded() {
  5901. ViewManager.Instance.OpenView(ViewType.LoadView);
  5902. GameSetting.isX = Laya.Browser.clientHeight / Laya.Browser.clientWidth > 2;
  5903. }
  5904. }
  5905. new Main();
  5906. }());
  5907. //# sourceMappingURL=bundle.js.map