bundle.js 378 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037
  1. (function () {
  2. 'use strict';
  3. class Consts {
  4. }
  5. Consts.width = 720;
  6. Consts.height = 1280;
  7. Consts.appName = "MiniGame";
  8. Consts.appId = "wx85f6b2f44c2c6197";
  9. Consts.appSecret = "ef546eea46fd8d07be1327c7091c6653";
  10. Consts.videoId = "adunit-bb8b86a848fa7157";
  11. Consts.bannerId = "adunit-6dddf31a31e4176f";
  12. Consts.gridId = "adunit-6dddf31a31e4176f";
  13. Consts.screenId = "adunit-cdc70d23cd88abfd";
  14. Consts.bannerAppIds = ["wx392f322b348d818a"];
  15. Consts.version = "101.2.1";
  16. Consts.debug = false;
  17. Consts.constName = "81_3dttt";
  18. Consts.host = "https://www.apgame.cn";
  19. Consts.defaultName = "游客";
  20. Consts.defaultPhoto = "UI/default.png";
  21. Consts.ad_data_statistics = false;
  22. class BaseData {
  23. static init() {
  24. Laya.timer.loop(5000, this, () => {
  25. this.saveData();
  26. });
  27. }
  28. static getNumber(key, defaultValue = 0) {
  29. let value = this.getItem(key);
  30. if (value) {
  31. return parseFloat(value);
  32. }
  33. return defaultValue;
  34. }
  35. static addNumber(key, add, max) {
  36. let old = this.getNumber(key);
  37. let value = old + add;
  38. if (max != null) {
  39. value = Math.max(Math.min(value, max), 0);
  40. }
  41. this.setNumber(key, value);
  42. }
  43. static setNumber(key, value) {
  44. this.setItem(key, value.toString());
  45. }
  46. static getBoolean(key, defaultValue = false) {
  47. let value = this.getItem(key);
  48. if (value == "1") {
  49. return true;
  50. }
  51. else if (value == "0") {
  52. return false;
  53. }
  54. return defaultValue;
  55. }
  56. static setBoolean(key, value) {
  57. if (value) {
  58. this.setItem(key, "1");
  59. }
  60. else {
  61. this.setItem(key, "0");
  62. }
  63. }
  64. static getString(key, defaultValue = "") {
  65. let value = this.getItem(key);
  66. return value ? value : defaultValue;
  67. }
  68. static setString(key, value) {
  69. this.setItem(key, value);
  70. }
  71. static setItem(key, value) {
  72. this.allDatas[key] = value;
  73. }
  74. static getItem(key) {
  75. if (this.allDatas[key] !== undefined) {
  76. return this.allDatas[key];
  77. }
  78. this.allDatas[key] = Laya.LocalStorage.getItem(key);
  79. this.cacheAllDatas[key] = this.allDatas[key];
  80. return this.allDatas[key];
  81. }
  82. static getObject(key) {
  83. let str = this.getString(key);
  84. if (str == null || str == "") {
  85. return null;
  86. }
  87. return JSON.parse(str);
  88. }
  89. static setObject(key, object) {
  90. let str = JSON.stringify(object);
  91. this.setString(key, str);
  92. }
  93. static saveData() {
  94. for (let key in this.allDatas) {
  95. if (this.cacheAllDatas[key] != this.allDatas[key]) {
  96. this.cacheAllDatas[key] = this.allDatas[key];
  97. Laya.LocalStorage.setItem(key, this.allDatas[key]);
  98. }
  99. }
  100. }
  101. }
  102. BaseData.allDatas = {};
  103. BaseData.cacheAllDatas = {};
  104. class LibData extends BaseData {
  105. static setGameData(gameData) {
  106. super.setString("GameData", gameData);
  107. }
  108. static getGameData() {
  109. let gameData = super.getString("GameData", "{\"mode\":0,\"shareDivVedio\":999,\"force\":1,\"bannerMode\":1,\"adMode\":0}");
  110. let table = JSON.parse(gameData);
  111. return table;
  112. }
  113. static getBannerMode() {
  114. let mode = this.getGameData().bannerMode;
  115. if (mode === undefined) {
  116. return 1;
  117. }
  118. return mode;
  119. }
  120. static setFriendsData(data) {
  121. super.setString("FriendsData", data);
  122. }
  123. static getFriendsData() {
  124. let s = super.getString("FriendsData", "[]");
  125. let datas = JSON.parse(s);
  126. return datas;
  127. }
  128. static getOpenid() {
  129. return super.getString("Openid");
  130. }
  131. static setOpenid(value) {
  132. super.setString("Openid", value);
  133. }
  134. static getNickname() {
  135. return super.getString("Nickname", Consts.defaultName);
  136. }
  137. static setNickname(name) {
  138. super.setString("Nickname", name);
  139. }
  140. static getPhoto() {
  141. return super.getString("Photo", Consts.defaultPhoto);
  142. }
  143. static setPhoto(value) {
  144. super.setString("Photo", value);
  145. }
  146. static getForce() {
  147. return this.getGameData().force;
  148. }
  149. static setInAppId(inAppId = 0) {
  150. super.setNumber("InAppId", inAppId);
  151. }
  152. static getInAppId() {
  153. return super.getNumber("InAppId", 0);
  154. }
  155. static getGameMode() {
  156. return this.getGameData().mode;
  157. }
  158. static setAuthorize() {
  159. super.setBoolean("Authorize", true);
  160. }
  161. static isAuthorize() {
  162. return super.getBoolean("Authorize");
  163. }
  164. static setMatchUser(data) {
  165. super.setString("MatchUser", data);
  166. }
  167. static getSessionKey() {
  168. return super.getString("SessionKey");
  169. }
  170. static setSessionKey(value) {
  171. super.setString("SessionKey", value);
  172. }
  173. static getShareDivVedio() {
  174. return this.getGameData().shareDivVedio + 1;
  175. }
  176. static setUsers(datas) {
  177. console.log(datas);
  178. super.setString("Users", datas);
  179. }
  180. static getUsers() {
  181. return JSON.parse(super.getString("Users", "[]"));
  182. }
  183. static getAddMode() {
  184. return this.getGameData().adMode;
  185. }
  186. static set_FlowIcon_Data(data) {
  187. let str = JSON.stringify(data);
  188. super.setString("FlowIconData", str);
  189. }
  190. static get_FlowIcon_Data() {
  191. let str = super.getString("FlowIconData", "[]");
  192. let table = JSON.parse(str);
  193. for (let i = 1, len = table.length; i < len; i++) {
  194. const random = Math.floor(Math.random() * (i + 1));
  195. [table[i], table[random]] = [table[random], table[i]];
  196. }
  197. return table;
  198. }
  199. static setBannerState(value) {
  200. super.setBoolean("BannerState", value);
  201. }
  202. static getBannerState() {
  203. return super.getBoolean("BannerState", true);
  204. }
  205. static setExtraData(extraStr) {
  206. super.setString("ExtraData", extraStr);
  207. }
  208. static getExtraData() {
  209. return super.getString("ExtraData", "{}");
  210. }
  211. static getGroupID() {
  212. return super.getString("GroupOpenID");
  213. }
  214. static setGroupID(value) {
  215. super.setString("GroupOpenID", value);
  216. }
  217. static setAID(id = "") {
  218. super.setString("ADAID", id);
  219. }
  220. static getAID() {
  221. return super.getString("ADAID");
  222. }
  223. static setUserType(type) {
  224. super.setNumber("UserType", type);
  225. }
  226. static getUserType() {
  227. return super.getNumber("UserType", 0);
  228. }
  229. static setUserIdentity(type) {
  230. super.setNumber("setUserIdentity", type);
  231. }
  232. static getUserIdentity() {
  233. return super.getNumber("setUserIdentity", 0);
  234. }
  235. static setExtraT(type) {
  236. super.setNumber("ExtraT", type);
  237. }
  238. static getExtraT() {
  239. return super.getNumber("ExtraT", 1);
  240. }
  241. static setExtraTT(type) {
  242. super.setNumber("ExtraTT", type);
  243. }
  244. static getExtraTT() {
  245. return super.getNumber("ExtraTT", 0);
  246. }
  247. }
  248. class Data extends BaseData {
  249. static getPlayCount() {
  250. return super.getNumber("PlayCount");
  251. }
  252. static setPlayCount(value) {
  253. super.setNumber("PlayCount", value);
  254. }
  255. static addPlayCount() {
  256. super.addNumber("PlayCount", 1);
  257. }
  258. static getScore() {
  259. return super.getNumber("Score");
  260. }
  261. static setScore(value) {
  262. super.setNumber("Score", value);
  263. }
  264. static addScore(value) {
  265. super.addNumber("Score", value);
  266. this.setMaxScore(this.getScore());
  267. }
  268. static getMaxScore() {
  269. return super.getNumber("MaxScore");
  270. }
  271. static setMaxScore(value) {
  272. let max = this.getMaxScore();
  273. super.setNumber("MaxScore", Math.max(max, value));
  274. }
  275. static getGoods(type, defaultValue = 0) {
  276. return super.getNumber("GoodsType" + type, defaultValue);
  277. }
  278. static setGoods(type, defaultValue = 0) {
  279. super.setNumber("GoodsType" + type, defaultValue);
  280. }
  281. static addGoods(type, value, max = null) {
  282. if (value <= 0) {
  283. return false;
  284. }
  285. super.addNumber("GoodsType" + type, value, max);
  286. return true;
  287. }
  288. static subGoods(type, value) {
  289. if (value <= 0) {
  290. return false;
  291. }
  292. let goods = Data.getGoods(type);
  293. if (goods < value) {
  294. return false;
  295. }
  296. super.setNumber("GoodsType" + type, goods - value);
  297. return true;
  298. }
  299. static setEnterSceneID(id = 0) {
  300. super.setNumber("EnterSceneID", id);
  301. }
  302. static getEnterSceneID() {
  303. let id = super.getNumber("EnterSceneID", 0);
  304. this.setEnterSceneID();
  305. return id;
  306. }
  307. static getHoldCoinsNum() {
  308. return super.getNumber("HoldCoinsNum");
  309. }
  310. static setHoldCoinsNum(value) {
  311. super.setNumber("HoldCoinsNum", value);
  312. }
  313. static getHoldStrengthNum() {
  314. return super.getNumber("HoldStrengthNum");
  315. }
  316. static setHoldStrengthNum(value) {
  317. super.setNumber("HoldStrengthNum", value);
  318. }
  319. static getKnifeInfo() {
  320. return super.getObject("KnifeInfo");
  321. }
  322. static setKnifeInfo(value) {
  323. super.setObject("KnifeInfo", value);
  324. }
  325. static getCritInfo() {
  326. return super.getObject("CritInfo");
  327. }
  328. static setCritInfo(value) {
  329. super.setObject("CritInfo", value);
  330. }
  331. static getCoinInfo() {
  332. return super.getObject("CoinInfo");
  333. }
  334. static setCoinInfo(value) {
  335. super.setObject("CoinInfo", value);
  336. }
  337. static getLastOfflineTime() {
  338. return super.getNumber("OfflineTime");
  339. }
  340. static setThisOfflineTime(value) {
  341. super.setNumber("OfflineTime", value);
  342. }
  343. static setAvailableIncomeData(value) {
  344. super.setNumber("AvailableIncome", value);
  345. }
  346. static getAvailableIncomeData() {
  347. return super.getNumber("AvailableIncome");
  348. }
  349. static setLastNormalStartTime(value) {
  350. super.setNumber("LastNormalStartTime", value);
  351. }
  352. static getLastNormalStartTime() {
  353. return super.getNumber("LastNormalStartTime");
  354. }
  355. static setLastFasterStartTime(value) {
  356. super.setNumber("LastFasterStartTime", value);
  357. }
  358. static getLastFasterStartTime() {
  359. return super.getNumber("LastFasterStartTime");
  360. }
  361. static setRecoverStrengthCountDownStartTime(value) {
  362. super.setNumber("RecoverStrengthCountDownStartTime", value);
  363. }
  364. static getRecoverStrengthCountDownStartTime() {
  365. return super.getNumber("RecoverStrengthCountDownStartTime");
  366. }
  367. static setPropTeach(value) {
  368. super.setBoolean("PropTeach", value);
  369. }
  370. static getPropTeach() {
  371. return super.getBoolean("PropTeach");
  372. }
  373. }
  374. class EventHandler extends Laya.EventDispatcher {
  375. static getInstance() {
  376. if (this._instance == null) {
  377. this._instance = new EventHandler();
  378. }
  379. return this._instance;
  380. }
  381. Emit(InName, agv) {
  382. this.event(InName, agv);
  383. }
  384. addEvent(InName, caller, listener, arg) {
  385. this.on(InName, caller, listener, (arg == null) ? null : ([arg]));
  386. }
  387. }
  388. EventHandler._instance = null;
  389. class WeixinAPI {
  390. static onShareAppMessage(object) {
  391. let wx = window["wx"];
  392. if (wx == null)
  393. return;
  394. wx.onShareAppMessage(object);
  395. }
  396. static showShareMenu() {
  397. let wx = window["wx"];
  398. if (wx == null)
  399. return;
  400. wx.showShareMenu();
  401. }
  402. static updateShareMenu() {
  403. let wx = window["wx"];
  404. if (wx == null)
  405. return;
  406. wx.updateShareMenu({
  407. withShareTicket: true
  408. });
  409. }
  410. static login(object) {
  411. let wx = window["wx"];
  412. if (wx == null)
  413. return;
  414. wx.login(object);
  415. }
  416. static getLaunchOptionsSync() {
  417. let wx = window["wx"];
  418. if (wx == null)
  419. return;
  420. return wx.getLaunchOptionsSync();
  421. }
  422. static onShow(object) {
  423. let wx = window["wx"];
  424. if (wx == null)
  425. return;
  426. wx.onShow(object);
  427. }
  428. static onHide(object) {
  429. let wx = window["wx"];
  430. if (wx == null)
  431. return;
  432. wx.onHide(object);
  433. }
  434. static showToast(object) {
  435. let wx = window["wx"];
  436. if (wx == null)
  437. return;
  438. wx.showToast(object);
  439. }
  440. static updateManager() {
  441. let wx = window["wx"];
  442. if (wx == null)
  443. return;
  444. if (typeof wx.getUpdateManager === 'function') {
  445. const updateManager = wx.getUpdateManager();
  446. updateManager.onUpdateReady(function () {
  447. updateManager.applyUpdate();
  448. });
  449. }
  450. }
  451. static showModal(object) {
  452. let wx = window["wx"];
  453. if (wx == null)
  454. return;
  455. wx.showModal(object);
  456. }
  457. static createRewardedVideoAd(object) {
  458. let wx = window["wx"];
  459. if (wx == null)
  460. return;
  461. return wx.createRewardedVideoAd(object);
  462. }
  463. static shareAppMessage(object) {
  464. let wx = window["wx"];
  465. if (wx == null)
  466. return;
  467. wx.shareAppMessage(object);
  468. }
  469. static setUserCloudStorage(object) {
  470. let wx = window["wx"];
  471. if (wx == null)
  472. return;
  473. wx.setUserCloudStorage(object);
  474. }
  475. static navigateToMiniProgram(object) {
  476. let wx = window["wx"];
  477. if (wx == null)
  478. return;
  479. wx.navigateToMiniProgram(object);
  480. }
  481. static createFeedbackButton(object) {
  482. let wx = window["wx"];
  483. if (wx == null)
  484. return;
  485. return wx.createFeedbackButton(object);
  486. }
  487. static getSetting(object) {
  488. let wx = window["wx"];
  489. if (wx == null)
  490. return;
  491. wx.getSetting(object);
  492. }
  493. static getShareInfo(object) {
  494. let wx = window["wx"];
  495. if (wx == null)
  496. return;
  497. wx.getShareInfo(object);
  498. }
  499. }
  500. class DataEntity {
  501. }
  502. DataEntity.shareContent = [
  503. [{ title: "发光的,一个就够了", image: "UI/shareImg1.jpg" },
  504. { title: "风里雨里,我在游戏里等你~", image: "UI/shareImg2.jpg" }],
  505. [{ title: "发光的,一个就够了", image: "UI/shareImg1.jpg" },
  506. { title: "风里雨里,我在游戏里等你~", image: "UI/shareImg2.jpg" }]
  507. ];
  508. class FlowIcon extends Laya.Image {
  509. constructor() {
  510. super();
  511. this.listData = [];
  512. this.curIndex = 0;
  513. this.curData = null;
  514. this.visible = false;
  515. this.anchorX = 0.5;
  516. this.anchorY = 0.5;
  517. this.on(Laya.Event.CLICK, this, () => {
  518. WXContro.navigateToMiniProgram(this.curData.appId);
  519. Http.sharePoint(this.curData.appName, 103);
  520. });
  521. Laya.timer.clearAll(this);
  522. Laya.timer.loop(5000, this, this.update);
  523. let action = (rot, duration, callBack) => {
  524. Laya.Tween.to(this, { rotation: rot }, duration, Laya.Ease.linearNone, Laya.Handler.create(this, callBack));
  525. };
  526. Laya.timer.loop(1500, this, () => {
  527. action(10, 50, () => {
  528. action(-10, 100, () => {
  529. action(10, 100, () => {
  530. action(-10, 100, () => {
  531. action(0, 50, () => { });
  532. });
  533. });
  534. });
  535. });
  536. });
  537. }
  538. update() {
  539. if (this.listData.length < 2) {
  540. return;
  541. }
  542. ++this.curIndex;
  543. if (this.curIndex >= this.listData.length) {
  544. this.curIndex = this.listData.length - 1;
  545. }
  546. this.curData = this.listData[this.curIndex];
  547. this.skin = this.curData.icon;
  548. }
  549. setListData(listData) {
  550. if (listData.length == 0) {
  551. this.visible = false;
  552. return;
  553. }
  554. this.visible = true;
  555. this.listData = listData;
  556. this.curIndex = 0;
  557. this.curData = this.listData[this.curIndex];
  558. this.skin = this.curData.icon;
  559. }
  560. clean() {
  561. Laya.timer.clearAll(this);
  562. this.removeSelf();
  563. }
  564. }
  565. class FlowIconMgr extends Laya.View {
  566. constructor() {
  567. super();
  568. FlowIconMgr.thiz = this;
  569. }
  570. static refresh(flowdata) {
  571. this.listData1 = [];
  572. this.listData2 = [];
  573. this.listData3 = [];
  574. Consts.bannerAppIds = [];
  575. for (let i = 0; i < flowdata.length; ++i) {
  576. let data = flowdata[i];
  577. if (data == null) {
  578. continue;
  579. }
  580. if (FlowIconMgr.showType == FlowIconMgr.TYPE_ONE) {
  581. this.listData1.push(data);
  582. }
  583. else {
  584. let index = i % 3;
  585. if (index == 0) {
  586. this.listData1.push(data);
  587. }
  588. else if (index == 1) {
  589. this.listData2.push(data);
  590. }
  591. else if (index == 2) {
  592. this.listData3.push(data);
  593. }
  594. }
  595. Consts.bannerAppIds.push(data.appId);
  596. }
  597. this.icon1.setListData(this.listData1);
  598. this.icon2.setListData(this.listData2);
  599. this.icon3.setListData(this.listData3);
  600. }
  601. static init(table, showType = FlowIconMgr.TYPE_V) {
  602. FlowIconMgr.showType = showType;
  603. if (FlowIconMgr.thiz) {
  604. this.icon1.clean();
  605. this.icon2.clean();
  606. this.icon1 = null;
  607. this.icon2 = null;
  608. this.listData3 = [];
  609. FlowIconMgr.thiz.removeSelf();
  610. FlowIconMgr.thiz = null;
  611. }
  612. FlowIconMgr.thiz = new FlowIconMgr();
  613. FlowIconMgr.thiz.x = table.x + 50;
  614. FlowIconMgr.thiz.y = table.y + 50;
  615. table.layer.addChild(FlowIconMgr.thiz);
  616. this.icon1 = new FlowIcon();
  617. FlowIconMgr.thiz.addChild(this.icon1);
  618. this.icon2 = new FlowIcon();
  619. FlowIconMgr.thiz.addChild(this.icon2);
  620. this.icon3 = new FlowIcon();
  621. FlowIconMgr.thiz.addChild(this.icon3);
  622. if (FlowIconMgr.showType == FlowIconMgr.TYPE_ONE) {
  623. this.icon2.visible = false;
  624. }
  625. if (FlowIconMgr.showType == FlowIconMgr.TYPE_V) {
  626. this.icon1.x = 0;
  627. this.icon1.y = 0;
  628. this.icon2.x = 0;
  629. this.icon2.y = 105;
  630. this.icon3.x = 0;
  631. this.icon3.y = 210;
  632. }
  633. else {
  634. this.icon1.x = 0;
  635. this.icon1.y = 0;
  636. this.icon2.x = 105;
  637. this.icon2.y = 0;
  638. this.icon3.x = 210;
  639. this.icon3.y = 0;
  640. }
  641. }
  642. static setFlowData(flowdata) {
  643. FlowIconMgr.refresh(flowdata);
  644. }
  645. static reset_FlowIconMgr_pos(x, y) {
  646. FlowIconMgr.thiz.x = x + 50;
  647. FlowIconMgr.thiz.y = y + 50;
  648. }
  649. static showFlowIcon() {
  650. FlowIconMgr.thiz.visible = true;
  651. }
  652. static hideFlowIcon() {
  653. FlowIconMgr.thiz.visible = false;
  654. }
  655. }
  656. FlowIconMgr.TYPE_H = 0;
  657. FlowIconMgr.TYPE_V = 1;
  658. FlowIconMgr.TYPE_ONE = 3;
  659. FlowIconMgr.showType = FlowIconMgr.TYPE_V;
  660. FlowIconMgr.icon1 = null;
  661. FlowIconMgr.icon2 = null;
  662. FlowIconMgr.icon3 = null;
  663. FlowIconMgr.listAllData = [];
  664. FlowIconMgr.thiz = null;
  665. FlowIconMgr.listData1 = [];
  666. FlowIconMgr.listData2 = [];
  667. FlowIconMgr.listData3 = [];
  668. class MiniBanner {
  669. static init(laya_ui, banner_data) {
  670. this.isShow = false;
  671. this.bannerUI_data = banner_data["mini_banner"];
  672. this.bannerAppId = Consts.bannerAppIds[this.bannerAppIdIndex];
  673. this.get_BannerFlow_Data();
  674. Laya.timer.once(1500, this, () => {
  675. this.createBannerFlow(laya_ui);
  676. this.refreshBannerFlow();
  677. Laya.timer.loop(30000, this, () => {
  678. this.refreshBannerFlow();
  679. });
  680. });
  681. }
  682. static get_BannerFlow_Data() {
  683. Http.getAllFlowIconData(this.get_BannerFlow_Data_success.bind(this), this.get_BannerFlow_Data_fail.bind(this));
  684. }
  685. static get_BannerFlow_Data_success(data) {
  686. this.bannerFlowData = data;
  687. for (let i = 0, _length = this.bannerFlowData.length; i < _length; i++) {
  688. this.prioritySum += this.bannerFlowData[i]["priority"];
  689. }
  690. this.set_flow_icon();
  691. let refresh_timer = FlowIconMgr.showType == FlowIconMgr.TYPE_ONE ? 50000 : 25000;
  692. Laya.timer.loop(refresh_timer, this, () => {
  693. this.set_flow_icon();
  694. });
  695. }
  696. static set_flow_icon() {
  697. let show_bannerFlow_Arr = this.getShowBannerFlow(10);
  698. if (!show_bannerFlow_Arr)
  699. return;
  700. let datas = new Array();
  701. for (let i = 0; i < show_bannerFlow_Arr.length; i++) {
  702. let data = {};
  703. data["appId"] = this.bannerFlowData[show_bannerFlow_Arr[i]]["appId"];
  704. data["appName"] = this.bannerFlowData[show_bannerFlow_Arr[i]]["appName"];
  705. data["icon"] = this.bannerFlowData[show_bannerFlow_Arr[i]]["cdnIcon"];
  706. datas.push(data);
  707. }
  708. FlowIconMgr.setFlowData(datas);
  709. }
  710. static get_BannerFlow_Data_fail() {
  711. this.bannerFlowData = null;
  712. Laya.timer.once(20000, this, () => {
  713. this.get_BannerFlow_Data();
  714. });
  715. }
  716. static createBannerFlow(laya_ui) {
  717. this.bannerFlow = new Laya.Image();
  718. if (LibData.getBannerMode() == 0) {
  719. this.bannerFlow.visible = false;
  720. }
  721. else if (LibData.getBannerMode() == 1) {
  722. this.bannerFlow.skin = "UI/ad.jpg";
  723. this.bannerFlow.on(Laya.Event.CLICK, this, () => {
  724. WXContro.navigateToMiniProgram(this.bannerAppId);
  725. Http.sharePoint("BannerAd_minigame", 103);
  726. });
  727. }
  728. else if (LibData.getBannerMode() == 2) {
  729. this.bannerFlow.skin = "UI/ad.png";
  730. }
  731. let design = new Laya.Box();
  732. design.width = Consts.width;
  733. design.height = Consts.height;
  734. design.anchorX = 0.5;
  735. design.anchorY = 0.5;
  736. design.x = Consts.width / 2;
  737. design.y = Consts.height / 2;
  738. laya_ui.addChild(design);
  739. design.mouseThrough = true;
  740. design.addChild(this.bannerFlow);
  741. this.initBannerFlow();
  742. this.bannerFlow.visible = this.isShow;
  743. }
  744. static initBannerFlow() {
  745. this.bannerFlow.width = this.bannerUI_data["width"];
  746. this.bannerFlow.height = this.bannerUI_data["height"];
  747. this.bannerFlow.anchorX = 0;
  748. this.bannerFlow.anchorY = 0;
  749. this.bannerFlow.x = this.bannerUI_data["left"];
  750. this.bannerFlow.y = this.bannerUI_data["top"];
  751. }
  752. static refreshBannerFlow() {
  753. this.recycleBannerFlow();
  754. let show_bannerFlow_Arr = this.getShowBannerFlow(this.showBannerNum);
  755. if (LibData.getBannerMode() == 2 && show_bannerFlow_Arr) {
  756. this.bannerFlow.skin = "UI/ad.png";
  757. for (let i = 0; i < 5; i++) {
  758. let x = this.bannerFlow.width / 5 / 2 + i * this.bannerFlow.width / 5;
  759. let y = this.bannerFlow.height / 2;
  760. let icon = Laya.Pool.getItemByClass("bannerFlowIcon", Laya.Image);
  761. icon.scale(this.bannerUI_data["scale"], this.bannerUI_data["scale"]);
  762. icon.skin = this.bannerFlowData[show_bannerFlow_Arr[i]]["cdnIcon"];
  763. icon.anchorX = 0.5;
  764. icon.anchorY = 0.5;
  765. icon.x = x;
  766. icon.y = y;
  767. this.bannerFlow.addChild(icon);
  768. let txt = Laya.Pool.getItemByClass("bannerFlowName", Laya.Text);
  769. txt.color = "#ffffff";
  770. txt.font = "SimHei";
  771. txt.text = this.bannerFlowData[show_bannerFlow_Arr[i]]["cnName"];
  772. txt.fontSize = 20;
  773. txt.align = "center";
  774. txt.width = this.bannerFlow.width / 5 / this.bannerUI_data["scale"];
  775. txt.y = 105;
  776. txt.x = -23;
  777. icon.addChild(txt);
  778. icon.on(Laya.Event.MOUSE_DOWN, this, () => {
  779. console.log("点击aaa", this.bannerFlowData[show_bannerFlow_Arr[i]]["cnName"], this.bannerFlowData[show_bannerFlow_Arr[i]]["appId"]);
  780. WXContro.navigateToMiniProgram(this.bannerFlowData[show_bannerFlow_Arr[i]]["appId"]);
  781. });
  782. this.BannerIconArr.push(icon);
  783. this.BannerNameArr.push(txt);
  784. }
  785. }
  786. else if (LibData.getBannerMode() == 2 && !show_bannerFlow_Arr) {
  787. this.bannerFlow.visible = false;
  788. }
  789. }
  790. static recycleBannerFlow() {
  791. for (let i = 0; i < this.BannerIconArr.length; i++) {
  792. this.BannerIconArr[i].removeSelf();
  793. this.BannerNameArr[i].removeSelf();
  794. this.BannerIconArr[i].offAll();
  795. Laya.Pool.recover("bannerFlowIcon", this.BannerIconArr[i]);
  796. Laya.Pool.recover("bannerFlowName", this.BannerNameArr[i]);
  797. }
  798. this.BannerIconArr = [];
  799. this.BannerNameArr = [];
  800. }
  801. static getShowBannerFlow(num) {
  802. let show_bannerFlow_Arr = [];
  803. if (!this.bannerFlowData) {
  804. return null;
  805. }
  806. if (this.bannerFlowData.length < num) {
  807. return null;
  808. }
  809. while (show_bannerFlow_Arr.length < num) {
  810. let random_priorty = Math.floor(Math.random() * this.prioritySum);
  811. let _id = this.getFlowIconID(random_priorty);
  812. if (!this.check_id_repetition(_id, show_bannerFlow_Arr)) {
  813. show_bannerFlow_Arr.push(_id);
  814. }
  815. }
  816. return show_bannerFlow_Arr;
  817. }
  818. static getFlowIconID(target_priorty) {
  819. let id = 0;
  820. let _priorty = 0;
  821. for (let i = 0, _length = this.bannerFlowData.length; i < _length; i++) {
  822. if (target_priorty > _priorty && target_priorty <= this.bannerFlowData[i]["priority"] + _priorty) {
  823. id = i;
  824. break;
  825. }
  826. _priorty += this.bannerFlowData[i]["priority"];
  827. }
  828. return id;
  829. }
  830. static check_id_repetition(id, arr) {
  831. for (let i = 0; i < arr.length; i++) {
  832. if (id == arr[i]) {
  833. return true;
  834. }
  835. }
  836. return false;
  837. }
  838. static show() {
  839. this.isShow = true;
  840. if (this.bannerFlow) {
  841. this.bannerFlow.visible = true;
  842. }
  843. }
  844. static hide() {
  845. this.isShow = false;
  846. if (this.bannerFlow) {
  847. this.bannerFlow.visible = false;
  848. }
  849. }
  850. }
  851. MiniBanner.isShow = false;
  852. MiniBanner.bannerUI_data = {};
  853. MiniBanner.bannerFlow = null;
  854. MiniBanner.bannerAppId = "";
  855. MiniBanner.bannerAppIdIndex = 0;
  856. MiniBanner.BannerIconArr = [];
  857. MiniBanner.BannerNameArr = [];
  858. MiniBanner.bannerFlowData = null;
  859. MiniBanner.prioritySum = 0;
  860. MiniBanner.showBannerNum = 7;
  861. class AdBanner {
  862. static init(banner_data, bannerAdKey, call) {
  863. this.banner_data = banner_data["ad_banner"];
  864. this.callBack = call;
  865. return this.createBanner(bannerAdKey);
  866. }
  867. static createBanner(bannerAdKey) {
  868. let wx = window["wx"];
  869. if (!wx) {
  870. this.callBack(null, bannerAdKey, 0);
  871. return;
  872. }
  873. let bannerAd = wx.createBannerAd({
  874. adUnitId: Consts.bannerId,
  875. style: {
  876. left: this.banner_data["left"],
  877. top: this.banner_data["top"],
  878. width: this.banner_data["width"],
  879. height: this.banner_data["height"],
  880. }
  881. });
  882. bannerAd.onError((res) => {
  883. console.log("bannerAD", res);
  884. this.callBack(null, bannerAdKey, res.errCode);
  885. });
  886. bannerAd.onLoad(() => {
  887. this.callBack(bannerAd, bannerAdKey, 0);
  888. });
  889. bannerAd.show();
  890. }
  891. }
  892. AdBanner.banner_data = {};
  893. AdBanner.callBack = null;
  894. class GridBanner {
  895. static init(banner_data, bannerAdKey, call) {
  896. this.banner_data = banner_data["grid_banner"];
  897. this.callBack = call;
  898. this.createBanner(bannerAdKey);
  899. }
  900. static createBanner(bannerAdKey) {
  901. let wx = window["wx"];
  902. if (!wx) {
  903. this.callBack(null, bannerAdKey, 0);
  904. return;
  905. }
  906. let gridAd = wx.createGridAd({
  907. adUnitId: Consts.gridId,
  908. adTheme: 'white',
  909. gridCount: 5,
  910. style: {
  911. left: this.banner_data["left"],
  912. top: this.banner_data["top"],
  913. width: this.banner_data["width"],
  914. height: this.banner_data["height"],
  915. }
  916. });
  917. gridAd.onError((res) => {
  918. console.log("gridAD", res);
  919. this.callBack(null, bannerAdKey, res.errCode);
  920. });
  921. gridAd.onLoad(() => {
  922. this.callBack(gridAd, bannerAdKey, 0);
  923. });
  924. gridAd.show();
  925. }
  926. }
  927. GridBanner.banner_data = {};
  928. GridBanner.callBack = null;
  929. class BannerAd {
  930. static init(laya_ui) {
  931. LibData.setBannerState(true);
  932. this.init_banner_data();
  933. this.create_mini_banner(laya_ui);
  934. this.init_wx_banner();
  935. }
  936. static init_wx_banner() {
  937. this.show_wx_banner();
  938. Laya.timer.loop(this.PERIOD * 2 * 1000, this, this.update);
  939. }
  940. static update() {
  941. if (!this.isShow) {
  942. return;
  943. }
  944. this.show_wx_banner();
  945. }
  946. static show_wx_banner() {
  947. if (this.autoRefresh) {
  948. this.create_wx_banner("bannerAd1");
  949. Laya.timer.once(2000, this, () => {
  950. if (this.bannerAd2) {
  951. this.bannerAd2.hide();
  952. }
  953. });
  954. Laya.timer.once(this.PERIOD * 1000, this, () => {
  955. this.create_wx_banner("bannerAd2");
  956. Laya.timer.once(2000, this, () => {
  957. if (this.bannerAd1) {
  958. this.bannerAd1.hide();
  959. }
  960. });
  961. });
  962. }
  963. }
  964. static create_wx_banner(bannerAdKey) {
  965. if (this[bannerAdKey]) {
  966. this[bannerAdKey].destroy();
  967. this[bannerAdKey] = null;
  968. }
  969. this.refreshBannerTime = new Date().getTime();
  970. this.create_wx_ad_banner(bannerAdKey);
  971. }
  972. static create_wx_ad_banner(bannerAdKey) {
  973. AdBanner.init(this.banner_data, bannerAdKey, this.create_wx_ad_banner_call.bind(this));
  974. }
  975. static create_wx_ad_banner_call(banner, bannerAdKey, errCode) {
  976. if (banner) {
  977. MiniBanner.hide();
  978. this.show_banner_type = 0;
  979. this[bannerAdKey] = banner;
  980. if (!this.isShow) {
  981. if (LibData.getBannerState()) {
  982. this.hideBannerAd(1);
  983. }
  984. else {
  985. this.hideBannerAd(0);
  986. }
  987. }
  988. this.banner_num_statistics();
  989. }
  990. else {
  991. this[bannerAdKey] = null;
  992. this.banner_num_statistics_fail(errCode);
  993. this.create_wx_grid_banner(bannerAdKey);
  994. }
  995. }
  996. static create_wx_grid_banner(bannerAdKey) {
  997. GridBanner.init(this.banner_data, bannerAdKey, this.create_wx_grid_banner_call.bind(this));
  998. }
  999. static create_wx_grid_banner_call(banner, bannerAdKey, errCode) {
  1000. if (banner) {
  1001. this.show_banner_type = 1;
  1002. MiniBanner.hide();
  1003. this[bannerAdKey] = banner;
  1004. if (!this.isShow) {
  1005. if (LibData.getBannerState()) {
  1006. this.hideBannerAd(1);
  1007. }
  1008. else {
  1009. this.hideBannerAd(0);
  1010. }
  1011. }
  1012. this.grid_num_statistics();
  1013. }
  1014. else {
  1015. this.grid_num_statistics_fail(errCode);
  1016. this[bannerAdKey] = null;
  1017. this.show_banner_type = 2;
  1018. if (this.isShow) {
  1019. MiniBanner.show();
  1020. }
  1021. else {
  1022. MiniBanner.hide();
  1023. }
  1024. }
  1025. }
  1026. static create_mini_banner(laya_ui) {
  1027. MiniBanner.init(laya_ui, this.banner_data);
  1028. }
  1029. static showBannerAd(param = 0) {
  1030. this.isShow = true;
  1031. if (this.show_banner_type != 2) {
  1032. if (this.bannerAd1) {
  1033. this.bannerAd1.show();
  1034. if (param == 0) {
  1035. LibData.setBannerState(true);
  1036. }
  1037. }
  1038. if (this.bannerAd2) {
  1039. this.bannerAd2.show();
  1040. if (param == 0) {
  1041. LibData.setBannerState(true);
  1042. }
  1043. }
  1044. }
  1045. else {
  1046. MiniBanner.show();
  1047. }
  1048. }
  1049. static hideBannerAd(param = 0) {
  1050. this.isShow = false;
  1051. if (this.bannerAd1) {
  1052. this.bannerAd1.hide();
  1053. }
  1054. if (this.bannerAd2) {
  1055. this.bannerAd2.hide();
  1056. }
  1057. MiniBanner.hide();
  1058. if (param == 0) {
  1059. LibData.setBannerState(false);
  1060. }
  1061. }
  1062. static refreshBanner() {
  1063. if (this.refreshBannerTime == 0) {
  1064. this.refreshBannerTime = new Date().getTime();
  1065. this.create_wx_banner("bannerAd1");
  1066. }
  1067. else {
  1068. if (new Date().getTime() - this.refreshBannerTime > 30 * 1000) {
  1069. this.refreshBannerTime = new Date().getTime();
  1070. this.create_wx_banner("bannerAd1");
  1071. }
  1072. }
  1073. }
  1074. static init_banner_data() {
  1075. this.init_wx_ad_banner_data();
  1076. this.init_wx_grid_banner_data();
  1077. this.init_mini_banner_data();
  1078. }
  1079. static init_wx_ad_banner_data() {
  1080. let wx = window["wx"];
  1081. if (!wx)
  1082. return;
  1083. let SCALE = 1;
  1084. let winSize = wx.getSystemInfoSync();
  1085. let bannerWidth = 0;
  1086. let bannerHeight = 0;
  1087. let top = 0;
  1088. let left = 0;
  1089. if (Consts.width > Consts.height) {
  1090. let actual_width = WXContro.wx_to_laya_size(300);
  1091. let bannerAd_Width_px = actual_width * SCALE;
  1092. let bannerAd_heigth_px = bannerAd_Width_px * this.H_DIV_W;
  1093. bannerWidth = WXContro.laya_to_wx_size(bannerAd_Width_px);
  1094. bannerHeight = WXContro.laya_to_wx_size(bannerAd_heigth_px);
  1095. let offset = 0;
  1096. offset = (WXContro.wx_to_laya_size(winSize.windowWidth) - Consts.width) / 2;
  1097. offset = WXContro.laya_to_wx_size(offset);
  1098. left = winSize.windowWidth - bannerWidth - offset;
  1099. top = winSize.windowHeight - bannerHeight;
  1100. }
  1101. else {
  1102. if (this.isSmall) {
  1103. SCALE = 300 / wx.getSystemInfoSync().windowWidth;
  1104. }
  1105. bannerWidth = winSize.windowWidth * SCALE;
  1106. bannerHeight = bannerWidth * this.H_DIV_W;
  1107. let offset = 0;
  1108. if (winSize.windowHeight / winSize.windowWidth > Consts.height / Consts.width && !this.isBottom) {
  1109. offset = (winSize.windowHeight - WXContro.laya_to_wx_size(Consts.height)) / 2;
  1110. }
  1111. left = (winSize.windowWidth - bannerWidth) / 2;
  1112. top = winSize.windowHeight - bannerHeight - offset;
  1113. }
  1114. let ad_banner = { "width": bannerWidth, "height": bannerHeight, "top": top, "left": left, "scale": SCALE };
  1115. this.banner_data["ad_banner"] = ad_banner;
  1116. }
  1117. static init_wx_grid_banner_data() {
  1118. let wx = window["wx"];
  1119. if (!wx)
  1120. return;
  1121. let SCALE = 1;
  1122. let winSize = wx.getSystemInfoSync();
  1123. let bannerWidth = 0;
  1124. let bannerHeight = 0;
  1125. let top = 0;
  1126. let left = 0;
  1127. if (Consts.width > Consts.height) {
  1128. SCALE = 1;
  1129. let actual_width = WXContro.wx_to_laya_size(300);
  1130. let bannerAd_Width_px = actual_width * SCALE;
  1131. let bannerAd_heigth_px = bannerAd_Width_px * this.H_DIV_W;
  1132. bannerWidth = WXContro.laya_to_wx_size(bannerAd_Width_px);
  1133. bannerHeight = WXContro.laya_to_wx_size(bannerAd_heigth_px);
  1134. let offset = 0;
  1135. offset = (WXContro.wx_to_laya_size(winSize.windowWidth) - Consts.width) / 2;
  1136. offset = WXContro.laya_to_wx_size(offset);
  1137. left = winSize.windowWidth - bannerWidth - offset;
  1138. top = winSize.windowHeight - bannerHeight;
  1139. }
  1140. else {
  1141. if (this.isSmall) {
  1142. SCALE = 300 / wx.getSystemInfoSync().windowWidth;
  1143. }
  1144. bannerWidth = winSize.windowWidth * SCALE;
  1145. bannerHeight = bannerWidth * this.H_DIV_W;
  1146. let offset = 0;
  1147. if (winSize.windowHeight / winSize.windowWidth > Consts.height / Consts.width && !this.isBottom) {
  1148. offset = (winSize.windowHeight - WXContro.laya_to_wx_size(Consts.height)) / 2;
  1149. }
  1150. left = (winSize.windowWidth - bannerWidth) / 2;
  1151. top = winSize.windowHeight - bannerHeight - offset;
  1152. }
  1153. let grid_banner = { "width": bannerWidth, "height": bannerHeight, "top": top, "left": left, "scale": SCALE };
  1154. this.banner_data["grid_banner"] = grid_banner;
  1155. }
  1156. static init_mini_banner_data() {
  1157. let SCALE = 1;
  1158. let bannerWidth = 0;
  1159. let bannerHeight = 0;
  1160. let top = 0;
  1161. let left = 0;
  1162. let wx = window["wx"];
  1163. if (Consts.width > Consts.height) {
  1164. SCALE = 300 / 400;
  1165. if (wx) {
  1166. bannerWidth = WXContro.wx_to_laya_size(300);
  1167. }
  1168. else {
  1169. bannerWidth = 700 * SCALE;
  1170. }
  1171. bannerHeight = bannerWidth * this.H_DIV_W;
  1172. top = Consts.height - bannerHeight;
  1173. left = Consts.width - bannerWidth;
  1174. }
  1175. else {
  1176. if (this.isSmall) {
  1177. SCALE = 300 / wx.getSystemInfoSync().windowWidth;
  1178. }
  1179. bannerWidth = Consts.width * SCALE;
  1180. bannerHeight = bannerWidth * this.H_DIV_W;
  1181. top = Consts.height - bannerHeight;
  1182. left = (Consts.width - bannerWidth) / 2;
  1183. }
  1184. let mini_banner = { "width": bannerWidth, "height": bannerHeight, "top": top, "left": left, "scale": SCALE };
  1185. this.banner_data["mini_banner"] = mini_banner;
  1186. }
  1187. static banner_num_statistics() {
  1188. let banner_num_timer = Data.getNumber("banner_num_timer", 0);
  1189. if (new Date().getTime() - banner_num_timer > 24 * 60 * 60 * 1000) {
  1190. Data.setNumber("banner_num_index", 1);
  1191. let date_timer = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), 0, 0, 0, 0).getTime();
  1192. Data.setNumber("banner_num_timer", date_timer);
  1193. }
  1194. else {
  1195. Data.addNumber("banner_num_index", 1);
  1196. }
  1197. if (Consts.ad_data_statistics) {
  1198. let index = Data.getNumber("banner_num_index", 1);
  1199. let index_str = ("000" + index).substr(-3);
  1200. Http.sharePoint("bannerAD_refresh_" + index_str, 105);
  1201. }
  1202. }
  1203. static getBannerIndex() {
  1204. if (this.show_banner_type != 0) {
  1205. return -1;
  1206. }
  1207. let banner_num_timer = Data.getNumber("banner_num_timer", 0);
  1208. if (new Date().getTime() - banner_num_timer > 24 * 60 * 60 * 1000) {
  1209. return 0;
  1210. }
  1211. else {
  1212. return Data.getNumber("banner_num_index", 1);
  1213. }
  1214. }
  1215. static banner_num_statistics_fail(errCode) {
  1216. if (!Consts.ad_data_statistics)
  1217. return;
  1218. let index = Data.getNumber("banner_num_index", 1);
  1219. let index_str = ("000" + (index + 1)).substr(-3);
  1220. let point_str = "bannerAD_err_" + errCode + "_" + index_str;
  1221. if (Data.getString("bannerAD_refresh_errS") != point_str) {
  1222. Data.setString("bannerAD_refresh_errS", point_str);
  1223. Http.sharePoint(point_str, 105);
  1224. }
  1225. }
  1226. static grid_num_statistics() {
  1227. let grid_num_timer = Data.getNumber("grid_num_timer", 0);
  1228. if (new Date().getTime() - grid_num_timer > 24 * 60 * 60 * 1000) {
  1229. Data.setNumber("grid_num_index", 1);
  1230. let date_timer = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), 0, 0, 0, 0).getTime();
  1231. Data.setNumber("grid_num_timer", date_timer);
  1232. }
  1233. else {
  1234. Data.addNumber("grid_num_index", 1);
  1235. }
  1236. if (Consts.ad_data_statistics) {
  1237. let index = Data.getNumber("grid_num_index", 1);
  1238. let index_str = ("000" + index).substr(-3);
  1239. Http.sharePoint("gridAD_refresh_" + index_str, 105);
  1240. }
  1241. }
  1242. static grid_num_statistics_fail(errCode) {
  1243. if (!Consts.ad_data_statistics)
  1244. return;
  1245. let index = Data.getNumber("grid_num_index", 1);
  1246. let index_str = ("000" + (index + 1)).substr(-3);
  1247. let point_str = "gridAD_err_" + errCode + "_" + index_str;
  1248. if (Data.getString("gridAD_refresh_errS") != point_str) {
  1249. Data.setString("gridAD_refresh_errS", point_str);
  1250. Http.sharePoint(point_str, 105);
  1251. }
  1252. }
  1253. }
  1254. BannerAd.banner_data = {};
  1255. BannerAd.H_DIV_W = 104 / 300;
  1256. BannerAd.isBottom = false;
  1257. BannerAd.PERIOD = 30;
  1258. BannerAd.bannerAd1 = null;
  1259. BannerAd.bannerAd2 = null;
  1260. BannerAd.refreshBannerTime = 0;
  1261. BannerAd.isSmall = false;
  1262. BannerAd.isShow = true;
  1263. BannerAd.autoRefresh = true;
  1264. BannerAd.show_banner_type = -1;
  1265. var SHAREIMG_POINT;
  1266. (function (SHAREIMG_POINT) {
  1267. SHAREIMG_POINT["LOGIN_SHARE_NAME"] = "LOGIN_SHARE_NAME";
  1268. SHAREIMG_POINT["LOGIN_FIRST_TIMER"] = "LOGIN_FIRST_TIMER";
  1269. SHAREIMG_POINT["LOGIN_LAST_TIMER"] = "LOGIN_LAST_TIMER";
  1270. })(SHAREIMG_POINT || (SHAREIMG_POINT = {}));
  1271. class DataPoint {
  1272. static shareImgPoint(shareName) {
  1273. let open_share_name = Data.getString(SHAREIMG_POINT.LOGIN_SHARE_NAME, "0");
  1274. if (shareName != null && open_share_name == "0") {
  1275. Data.setString(SHAREIMG_POINT.LOGIN_SHARE_NAME, shareName);
  1276. let date = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), 0, 0, 0, 0);
  1277. Data.setString(SHAREIMG_POINT.LOGIN_LAST_TIMER, date.getTime() + "");
  1278. Data.setString(SHAREIMG_POINT.LOGIN_FIRST_TIMER, date.getTime() + "");
  1279. Http.sharePoint(shareName + "_new", 104);
  1280. }
  1281. else if (shareName == null && open_share_name == "0") {
  1282. Data.setString(SHAREIMG_POINT.LOGIN_SHARE_NAME, "1");
  1283. }
  1284. else if (open_share_name != "0" && open_share_name != "1") {
  1285. this.check_shareImgPoint(shareName);
  1286. }
  1287. }
  1288. static check_shareImgPoint(shareName) {
  1289. let now_date = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), new Date().getHours(), new Date().getMinutes(), 0, 0);
  1290. let first_login_timer = parseInt(Data.getString(SHAREIMG_POINT.LOGIN_FIRST_TIMER, "0"));
  1291. let one_day_millisecond = 24 * 60 * 60 * 1000;
  1292. let time_distance = now_date.getTime() - first_login_timer;
  1293. let last_login_timer = parseInt(Data.getString(SHAREIMG_POINT.LOGIN_LAST_TIMER, "0"));
  1294. if (now_date.getTime() - last_login_timer > one_day_millisecond) {
  1295. let date_login = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), 0, 0, 0, 0);
  1296. if (time_distance > one_day_millisecond * 1 && time_distance < one_day_millisecond * 2) {
  1297. Data.setString(SHAREIMG_POINT.LOGIN_LAST_TIMER, date_login.getTime() + "");
  1298. Http.sharePoint(shareName + "_next", 104);
  1299. }
  1300. else if (time_distance > one_day_millisecond * 3 && time_distance < one_day_millisecond * 4) {
  1301. Data.setString(SHAREIMG_POINT.LOGIN_LAST_TIMER, date_login.getTime() + "");
  1302. Http.sharePoint(shareName + "_three", 104);
  1303. }
  1304. else if (time_distance > one_day_millisecond * 7 && time_distance < one_day_millisecond * 8) {
  1305. Data.setString(SHAREIMG_POINT.LOGIN_LAST_TIMER, date_login.getTime() + "");
  1306. Http.sharePoint(shareName + "_seven", 104);
  1307. }
  1308. }
  1309. }
  1310. }
  1311. class WXContro {
  1312. static init(layer) {
  1313. this._layer = layer;
  1314. this.show_version();
  1315. BaseData.init();
  1316. Http.getGameData();
  1317. this.onShareAppMessage();
  1318. this.login();
  1319. this.onShow();
  1320. this.onHide();
  1321. }
  1322. static show_version() {
  1323. let ver_txt = new Laya.Text();
  1324. Laya.timer.once(500, this, () => {
  1325. ver_txt.text = Consts.version;
  1326. ver_txt.color = "#ffffff";
  1327. this._layer.addChild(ver_txt);
  1328. });
  1329. }
  1330. static onShareAppMessage() {
  1331. let wx = window["wx"];
  1332. if (wx == null)
  1333. return;
  1334. WeixinAPI.onShareAppMessage(() => {
  1335. let contents = DataEntity.shareContent[LibData.getGameMode() == 0 ? 0 : 1];
  1336. let content = contents;
  1337. if (contents["length"]) {
  1338. content = contents[Math.floor(Math.random() * contents["length"])];
  1339. }
  1340. let query = "shareName=" + content.name;
  1341. if (LibData.getInAppId() == 1) {
  1342. query += "&inAppId=" + LibData.getInAppId();
  1343. }
  1344. return {
  1345. title: content.title,
  1346. imageUrl: content.image,
  1347. query: query,
  1348. };
  1349. });
  1350. WeixinAPI.showShareMenu();
  1351. WeixinAPI.updateShareMenu();
  1352. }
  1353. static login() {
  1354. WeixinAPI.login({
  1355. success: (res) => {
  1356. let code = res.code;
  1357. console.log("-> login code:" + code);
  1358. Http.getSessionKey(code, (res) => {
  1359. let jsonRes = JSON.parse(res);
  1360. if (jsonRes && jsonRes.openid && jsonRes.openid.length > 0) {
  1361. LibData.setOpenid(jsonRes.openid);
  1362. console.log("-> openid:" + LibData.getOpenid());
  1363. }
  1364. else if (LibData.getOpenid().length == 0) {
  1365. LibData.setOpenid("ms" + new Date().getTime());
  1366. console.log("-> openid:" + LibData.getOpenid());
  1367. }
  1368. LibData.setSessionKey(jsonRes.session_key);
  1369. let loginCallBack = (res) => {
  1370. console.log("-> login res:" + JSON.stringify(res));
  1371. let openid = res.query.openid;
  1372. let name = res.query.name;
  1373. let type = res.query.type;
  1374. let scene = res.scene;
  1375. if (openid != null && name != null) {
  1376. console.log("login -----------------------------");
  1377. console.log("login -> 用户 name:" + LibData.getNickname() + "(openid:" + LibData.getOpenid() + ")");
  1378. console.log("login -> 点了 name:" + name + "(openid:" + openid + ")分享的小游戏");
  1379. console.log("login -----------------------------");
  1380. }
  1381. this.getGroupID(res.shareTicket);
  1382. let weixinadinfo = res.query.weixinadinfo;
  1383. if (weixinadinfo) {
  1384. let weixinadinfoArr = weixinadinfo.split(".");
  1385. let aid = weixinadinfoArr[0];
  1386. LibData.setAID(aid);
  1387. }
  1388. let shareName = res.query.shareName;
  1389. if (shareName != null) {
  1390. DataPoint.shareImgPoint(shareName);
  1391. }
  1392. if (scene != null) {
  1393. Data.setEnterSceneID(scene);
  1394. }
  1395. else {
  1396. Data.setEnterSceneID();
  1397. }
  1398. Http.userCalcIn(res);
  1399. Http.userGameDateCheck(0, res.query.inAppId, res.scene, res.referrerInfo);
  1400. };
  1401. loginCallBack(WeixinAPI.getLaunchOptionsSync());
  1402. });
  1403. }
  1404. });
  1405. }
  1406. static getGroupID(shareTicket) {
  1407. if (!shareTicket)
  1408. return;
  1409. WeixinAPI.getShareInfo({
  1410. shareTicket: shareTicket,
  1411. success: (res) => {
  1412. let cryptoJS = window["CryptoJS"];
  1413. if (!cryptoJS)
  1414. return;
  1415. try {
  1416. if (res.errMsg == "getShareInfo:ok") {
  1417. let key = cryptoJS.enc.Base64.parse(LibData.getSessionKey());
  1418. let iv = cryptoJS.enc.Base64.parse(res.iv);
  1419. let decrypted = cryptoJS.AES.decrypt(res.encryptedData, key, {
  1420. iv: iv,
  1421. mode: cryptoJS.mode.CBC,
  1422. padding: cryptoJS.pad.Pkcs7
  1423. });
  1424. let decryptedResult = JSON.parse(decrypted.toString(cryptoJS.enc.Utf8));
  1425. LibData.setGroupID(decryptedResult.openGId);
  1426. }
  1427. return;
  1428. }
  1429. catch (error) {
  1430. console.log("解密失败!", error);
  1431. return;
  1432. }
  1433. },
  1434. fail: () => {
  1435. return;
  1436. }
  1437. });
  1438. return;
  1439. }
  1440. static onHide() {
  1441. WeixinAPI.onHide((res) => {
  1442. console.log("-> onHide ---------");
  1443. BaseData.saveData();
  1444. this.shareDone = true;
  1445. });
  1446. }
  1447. static onShow() {
  1448. WeixinAPI.onShow((res) => {
  1449. console.log("-> onShow res:" + JSON.stringify(res));
  1450. WeixinAPI.showToast({ title: '处理中', duration: 1000, mask: true, icon: 'loading' });
  1451. this.getGroupID(res.shareTicket);
  1452. let goneTime = new Date().getTime() - this.shareTime;
  1453. Laya.timer.once(1000, this, () => {
  1454. if (this.successCallBack) {
  1455. console.log("-> wx.onShow goneTime:" + goneTime);
  1456. this.shareHandle(goneTime, this.successCallBack, this.failCallBack);
  1457. this.successCallBack = null;
  1458. this.failCallBack = null;
  1459. }
  1460. });
  1461. let openid = res.query.openid;
  1462. let name = res.query.name;
  1463. if (openid != null && name != null) {
  1464. console.log("onShow -----------------------------");
  1465. console.log("onShow -> 用户 name:" + LibData.getNickname() + "(openid:" + LibData.getOpenid() + ")");
  1466. console.log("onShow -> 点了 name:" + name + "(openid:" + openid + ")分享的小游戏");
  1467. console.log("onShow -----------------------------");
  1468. }
  1469. WeixinAPI.updateManager();
  1470. Http.userGameDateCheck(1, null, res.scene, res.referrerInfo);
  1471. });
  1472. }
  1473. static shareHandle(span, successCallBack, failCallBack) {
  1474. let wx = window["wx"];
  1475. if (wx == null)
  1476. return;
  1477. let reward = false;
  1478. if (span < 1.5 * 1000) {
  1479. if (LibData.getForce() == 1) {
  1480. this.showPoint_Done = false;
  1481. WeixinAPI.showModal({
  1482. title: "提示", content: "成功分享才有奖励~", showCancel: this.share_type, success: (res) => {
  1483. if (res.confirm) {
  1484. this.sharePoint(this.pointName, true, this.share_type, successCallBack, failCallBack, this.param);
  1485. }
  1486. else if (res.cancel) {
  1487. this.sharePoint_fail(1, failCallBack);
  1488. return;
  1489. }
  1490. }
  1491. });
  1492. }
  1493. return;
  1494. }
  1495. else if (span > 10 * 1000) {
  1496. reward = true;
  1497. }
  1498. else {
  1499. if (this.shareSuccessCount == 0) {
  1500. if (span < 2 * 1000 && this.failCount < 3) {
  1501. this.showPoint_Done = false;
  1502. if (LibData.getForce() == 1) {
  1503. WeixinAPI.showModal({
  1504. title: "提示", content: "成功分享才有奖励~", showCancel: this.share_type, success: (res) => {
  1505. if (res.confirm) {
  1506. this.sharePoint(this.pointName, true, this.share_type, successCallBack, failCallBack, this.param);
  1507. }
  1508. else if (res.cancel) {
  1509. this.sharePoint_fail(1, failCallBack);
  1510. return;
  1511. }
  1512. }
  1513. });
  1514. }
  1515. }
  1516. else {
  1517. reward = true;
  1518. this.lastSuccessShareNeedTime = span;
  1519. }
  1520. }
  1521. else if (this.shareSuccessCount == 1) {
  1522. if (span < this.lastSuccessShareNeedTime && this.failCount < 3) {
  1523. this.showPoint_Done = false;
  1524. if (LibData.getForce() == 1) {
  1525. WeixinAPI.showModal({
  1526. title: "提示", content: "成功分享才有奖励~", showCancel: this.share_type, success: (res) => {
  1527. if (res.confirm) {
  1528. this.sharePoint(this.pointName, true, this.share_type, successCallBack, failCallBack, this.param);
  1529. }
  1530. else if (res.cancel) {
  1531. this.sharePoint_fail(1, failCallBack);
  1532. return;
  1533. }
  1534. }
  1535. });
  1536. }
  1537. }
  1538. else {
  1539. reward = true;
  1540. this.findGroupTime = span - this.lastSuccessShareNeedTime;
  1541. if (this.findGroupTime > 600) {
  1542. this.findGroupTime = 600;
  1543. }
  1544. this.lastSuccessShareNeedTime = span;
  1545. }
  1546. }
  1547. else if (this.shareSuccessCount > 1) {
  1548. if (span < this.lastSuccessShareNeedTime + this.findGroupTime && this.failCount < 2) {
  1549. this.showPoint_Done = false;
  1550. if (LibData.getForce() == 1) {
  1551. WeixinAPI.showModal({
  1552. title: "提示", content: "成功分享才有奖励~", showCancel: this.share_type, success: (res) => {
  1553. if (res.confirm) {
  1554. this.sharePoint(this.pointName, true, this.share_type, successCallBack, failCallBack, this.param);
  1555. }
  1556. else if (res.cancel) {
  1557. this.sharePoint_fail(1, failCallBack);
  1558. return;
  1559. }
  1560. }
  1561. });
  1562. }
  1563. }
  1564. else {
  1565. reward = true;
  1566. this.lastSuccessShareNeedTime = span;
  1567. }
  1568. }
  1569. }
  1570. if (reward) {
  1571. this.sharePoint_success(1, successCallBack);
  1572. }
  1573. else {
  1574. this.sharePoint_fail(1, failCallBack);
  1575. }
  1576. }
  1577. static sharePoint(name, isShare, type, success, fail = null, param = { type: "", img: null, title: null }) {
  1578. if (this.showPoint_Done)
  1579. return;
  1580. this.showPoint_Done = true;
  1581. this.pointName = name;
  1582. this.param = param;
  1583. this.share_type = type;
  1584. Http.sharePoint(this.pointName + "-touch", 101);
  1585. if (Consts.debug) {
  1586. this.sharePoint_success(0, success);
  1587. return;
  1588. }
  1589. if (LibData.getGameMode() == 0) {
  1590. this.sharePoint_success(0, success);
  1591. }
  1592. else if (LibData.getGameMode() == 2) {
  1593. console.log("视频");
  1594. this.showVideo(success, fail);
  1595. }
  1596. else {
  1597. if (isShare) {
  1598. console.log("分享");
  1599. this.share(success, fail, param.type, param.img, param.title);
  1600. }
  1601. else {
  1602. console.log("视频");
  1603. this.showVideo(success, fail);
  1604. }
  1605. }
  1606. }
  1607. static sharePoint_success(type, success) {
  1608. Http.sharePoint(this.pointName + "-success", 101);
  1609. this.showPoint_Done = false;
  1610. if (success) {
  1611. success();
  1612. }
  1613. if (type == 0) {
  1614. }
  1615. else if (type == 1) {
  1616. ++this.shareSuccessCount;
  1617. ++this.successCount;
  1618. this.failCount = 0;
  1619. }
  1620. else if (type == 2) {
  1621. ++this.successCount;
  1622. }
  1623. }
  1624. static sharePoint_fail(type, fail) {
  1625. Http.sharePoint(this.pointName + "-fail", 101);
  1626. this.showPoint_Done = false;
  1627. if (fail) {
  1628. fail();
  1629. }
  1630. if (type == 0) {
  1631. }
  1632. else if (type == 1) {
  1633. ++this.failCount;
  1634. }
  1635. else if (type == 2) {
  1636. }
  1637. }
  1638. static showVideo(success, fail = null) {
  1639. let wx = window["wx"];
  1640. if (wx == null) {
  1641. this.sharePoint_success(0, success);
  1642. return;
  1643. }
  1644. let videoAd = WeixinAPI.createRewardedVideoAd({ adUnitId: Consts.videoId });
  1645. if (videoAd == null) {
  1646. return;
  1647. }
  1648. this.video_num_statistics();
  1649. videoAd.load().then(() => {
  1650. videoAd.show();
  1651. BannerAd.hideBannerAd(1);
  1652. });
  1653. let closeCallBack = res => {
  1654. Laya.timer.once(1000 * 10, this, () => {
  1655. if (LibData.getBannerState()) {
  1656. BannerAd.showBannerAd();
  1657. }
  1658. });
  1659. videoAd.offClose(closeCallBack);
  1660. if (res && res.isEnded || res === undefined) {
  1661. this.sharePoint_success(2, success);
  1662. }
  1663. else {
  1664. this.sharePoint_fail(2, fail);
  1665. }
  1666. };
  1667. videoAd.onClose(closeCallBack);
  1668. videoAd.onError((res) => {
  1669. if (res.errMsg != "can't invoke load() while video-ad is showed") {
  1670. videoAd.offClose(closeCallBack);
  1671. this.video_num_statistics_fail(res.errCode);
  1672. if (LibData.getGameMode() == 1) {
  1673. this.share(success, fail);
  1674. }
  1675. else {
  1676. this.sharePoint_fail(2, fail);
  1677. }
  1678. }
  1679. });
  1680. }
  1681. static share(successCallBack, failCallBack = null, type = "", img = null, title = null) {
  1682. let wx = window["wx"];
  1683. if (wx == null) {
  1684. this.sharePoint_success(1, successCallBack);
  1685. return;
  1686. }
  1687. this.shareTime = new Date().getTime();
  1688. this.successCallBack = successCallBack;
  1689. this.failCallBack = failCallBack;
  1690. if (LibData.getGameMode() == 3) {
  1691. this.shareDone = false;
  1692. Laya.timer.once(500, this, () => {
  1693. if (!this.shareDone) {
  1694. this.showVideo(successCallBack, failCallBack);
  1695. }
  1696. });
  1697. }
  1698. let contents = DataEntity.shareContent[LibData.getGameMode() == 0 ? 0 : 1];
  1699. let content = contents;
  1700. if (contents["length"]) {
  1701. content = contents[Math.floor(Math.random() * contents["length"])];
  1702. }
  1703. let query = "photo=" + LibData.getPhoto() + "&openid=" + LibData.getOpenid() + "&name=" + LibData.getNickname() + "&type=" + type + "&shareName=" + content.name;
  1704. if (LibData.getInAppId() == 1) {
  1705. query += "&inAppId=" + LibData.getInAppId();
  1706. }
  1707. WeixinAPI.shareAppMessage({
  1708. title: title || content.title,
  1709. imageUrl: img || content.image,
  1710. query: query,
  1711. });
  1712. }
  1713. static setRankData(score) {
  1714. let wx = window["wx"];
  1715. if (wx == null)
  1716. return;
  1717. WeixinAPI.setUserCloudStorage({ KVDataList: [{ key: 'score', value: '' + score }] });
  1718. }
  1719. static navigateToMiniProgram(id) {
  1720. WeixinAPI.navigateToMiniProgram({
  1721. appId: id, success: () => {
  1722. Http.userCalcOut(id);
  1723. }
  1724. });
  1725. }
  1726. static createFeedbackButton(x, y) {
  1727. let wx = window["wx"];
  1728. if (wx == null)
  1729. return;
  1730. return WeixinAPI.createFeedbackButton({
  1731. type: 'image',
  1732. text: '投诉',
  1733. image: 'UI/feedback.png',
  1734. style: {
  1735. left: x === undefined ? 10 : x,
  1736. top: y === undefined ? wx.getSystemInfoSync().windowHeight / 2 : y,
  1737. width: 40,
  1738. height: 40,
  1739. lineHeight: 40,
  1740. color: '#ffffff',
  1741. textAlign: 'center',
  1742. fontSize: 16,
  1743. borderRadius: 4
  1744. }
  1745. });
  1746. }
  1747. static isShare() {
  1748. return this.successCount % LibData.getShareDivVedio() > 0;
  1749. }
  1750. static getUserInfo(callBack, btnPng) {
  1751. let wx = window["wx"];
  1752. if (wx == null) {
  1753. callBack({ type: null });
  1754. return;
  1755. }
  1756. WeixinAPI.getSetting({
  1757. success: (res) => {
  1758. if (res.authSetting['scope.userInfo']) {
  1759. console.log("-> 已经授权");
  1760. wx.getUserInfo({
  1761. success: (res) => {
  1762. LibData.setAuthorize();
  1763. res.userInfo.type = "authed";
  1764. callBack(res.userInfo);
  1765. }
  1766. });
  1767. }
  1768. else {
  1769. console.log("-> 没有授权");
  1770. let button = window["wx"].createUserInfoButton({
  1771. type: "image",
  1772. image: btnPng,
  1773. style: this.getAuthBtnRange()
  1774. });
  1775. button.show();
  1776. button.onTap((res) => {
  1777. if (res.errMsg == "getUserInfo:ok") {
  1778. if (res.userInfo) {
  1779. LibData.setNickname(res.userInfo.nickName);
  1780. LibData.setPhoto(res.userInfo.avatarUrl);
  1781. LibData.setAuthorize();
  1782. res.userInfo.type = "auth";
  1783. callBack(res.userInfo);
  1784. }
  1785. }
  1786. else {
  1787. callBack({ type: "authFail" });
  1788. }
  1789. button.hide();
  1790. button.destroy();
  1791. });
  1792. }
  1793. }
  1794. });
  1795. }
  1796. static getAuthBtnRange() {
  1797. let wx = window["wx"];
  1798. if (wx == null) {
  1799. return {};
  1800. }
  1801. let wxSize = wx.getSystemInfoSync();
  1802. let wxDivDesign = wxSize.windowWidth / Laya.stage.designWidth;
  1803. return {
  1804. left: 372 * wxDivDesign,
  1805. top: 877 * wxDivDesign + (Laya.stage.height - Laya.stage.designHeight) / 2 * wxDivDesign,
  1806. width: 313 * wxDivDesign,
  1807. height: 132 * wxDivDesign,
  1808. };
  1809. }
  1810. static showVideo_direct(name, success, fail = null) {
  1811. let wx = window["wx"];
  1812. if (wx == null) {
  1813. success();
  1814. return;
  1815. }
  1816. let videoAd = wx.createRewardedVideoAd({ adUnitId: Consts.videoId });
  1817. if (videoAd == null) {
  1818. return;
  1819. }
  1820. videoAd.load().then(() => {
  1821. videoAd.show();
  1822. BannerAd.hideBannerAd(1);
  1823. });
  1824. let closeCallBack = res => {
  1825. videoAd.offClose(closeCallBack);
  1826. if (res && res.isEnded || res === undefined) {
  1827. if (success) {
  1828. success();
  1829. }
  1830. }
  1831. else {
  1832. if (fail) {
  1833. fail();
  1834. }
  1835. }
  1836. };
  1837. videoAd.onClose(closeCallBack);
  1838. videoAd.onError((res) => {
  1839. videoAd.offClose(closeCallBack);
  1840. if (fail) {
  1841. fail();
  1842. }
  1843. });
  1844. }
  1845. static showShare_direct(name) {
  1846. let contents = DataEntity.shareContent[LibData.getGameMode() == 0 ? 0 : 1];
  1847. let content = contents;
  1848. if (contents["length"]) {
  1849. content = contents[Math.floor(Math.random() * contents["length"])];
  1850. }
  1851. let query = "photo=" + LibData.getPhoto() + "&openid=" + LibData.getOpenid() + "&name=" + LibData.getNickname() + "&type=" + "" + "&shareName=" + content.name;
  1852. if (LibData.getInAppId() == 1) {
  1853. query += "&inAppId=" + LibData.getInAppId();
  1854. }
  1855. WeixinAPI.shareAppMessage({
  1856. title: content.title,
  1857. imageUrl: content.image,
  1858. query: query,
  1859. });
  1860. }
  1861. static showInterstitialAd() {
  1862. let wx = window["wx"];
  1863. if (wx == null) {
  1864. return;
  1865. }
  1866. let interstitialAd = wx.createInterstitialAd({ adUnitId: Consts.screenId });
  1867. interstitialAd.show().catch((err) => {
  1868. console.error(err);
  1869. });
  1870. interstitialAd.onLoad(() => {
  1871. });
  1872. interstitialAd.onError(err => {
  1873. });
  1874. interstitialAd.onClose(res => {
  1875. });
  1876. }
  1877. static laya_to_wx_size(px) {
  1878. let pixelRatio = 0;
  1879. let wx = window["wx"];
  1880. if (wx == null)
  1881. return;
  1882. let winSize = wx.getSystemInfoSync();
  1883. if (Consts.width > Consts.height) {
  1884. pixelRatio = Consts.height / winSize.windowHeight;
  1885. }
  1886. else {
  1887. pixelRatio = Consts.width / winSize.windowWidth;
  1888. }
  1889. return px / pixelRatio;
  1890. }
  1891. static wx_to_laya_size(px) {
  1892. let pixelRatio = 0;
  1893. let wx = window["wx"];
  1894. if (wx == null)
  1895. return;
  1896. let winSize = wx.getSystemInfoSync();
  1897. if (Consts.width > Consts.height) {
  1898. pixelRatio = Consts.height / winSize.windowHeight;
  1899. }
  1900. else {
  1901. pixelRatio = Consts.width / winSize.windowWidth;
  1902. }
  1903. return px * pixelRatio;
  1904. }
  1905. static laya_to_wx_pos(x, y) {
  1906. let _x = 0;
  1907. let _y = 0;
  1908. let _offset = 0;
  1909. let wx = window["wx"];
  1910. let winSize = wx.getSystemInfoSync();
  1911. if (Consts.width > Consts.height) {
  1912. _offset = (this.wx_to_laya_size(winSize.windowWidth) - Consts.width) / 2;
  1913. _x = x + _offset;
  1914. _y = y;
  1915. }
  1916. else {
  1917. _offset = (this.wx_to_laya_size(winSize.windowHeight) - Consts.height) / 2;
  1918. _x = x;
  1919. _y = y + _offset;
  1920. }
  1921. return new Laya.Point(this.laya_to_wx_size(_x), this.laya_to_wx_size(_y));
  1922. }
  1923. static video_num_statistics() {
  1924. let video_num_timer = Data.getNumber("video_num_timer", 0);
  1925. if (new Date().getTime() - video_num_timer > 24 * 60 * 60 * 1000) {
  1926. Data.setNumber("video_num_index", 1);
  1927. let date_timer = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), 0, 0, 0, 0).getTime();
  1928. Data.setNumber("video_num_timer", date_timer);
  1929. }
  1930. else {
  1931. Data.addNumber("video_num_index", 1);
  1932. }
  1933. if (Consts.ad_data_statistics) {
  1934. let index = Data.getNumber("video_num_index", 1);
  1935. let index_str = ("000" + index).substr(-3);
  1936. Http.sharePoint("videoAD_refresh_" + index_str, 105);
  1937. }
  1938. }
  1939. static video_num_statistics_fail(errCode) {
  1940. if (!Consts.ad_data_statistics)
  1941. return;
  1942. let index = Data.getNumber("video_num_index", 1);
  1943. let index_str = ("000" + (index + 1)).substr(-3);
  1944. let point_str = "videoAD_err_" + errCode + "_" + index_str;
  1945. if (Data.getString("videoAD_refresh_errS") != point_str) {
  1946. Data.setString("videoAD_refresh_errS", point_str);
  1947. Http.sharePoint(point_str, 105);
  1948. }
  1949. }
  1950. static getLength(str) {
  1951. let length = 0;
  1952. let reg = /[\u4e00-\u9fa5]/;
  1953. for (var i = 0; i < str.length; i++) {
  1954. if (reg.test(str.charAt(i))) {
  1955. length += 2;
  1956. }
  1957. else {
  1958. length++;
  1959. }
  1960. }
  1961. return length;
  1962. }
  1963. static warning_tips(str) {
  1964. WeixinAPI.showModal({
  1965. title: "提示",
  1966. content: str,
  1967. showCancel: false,
  1968. success: (res) => {
  1969. }
  1970. });
  1971. }
  1972. }
  1973. WXContro._layer = null;
  1974. WXContro.shareTime = 0;
  1975. WXContro.successCallBack = null;
  1976. WXContro.failCallBack = null;
  1977. WXContro.successCount = 1;
  1978. WXContro.pointName = "";
  1979. WXContro.param = { type: null, img: null, title: null };
  1980. WXContro.lastSuccessShareNeedTime = 0;
  1981. WXContro.findGroupTime = 0;
  1982. WXContro.shareDone = true;
  1983. WXContro.share_type = false;
  1984. WXContro.showPoint_Done = false;
  1985. WXContro.shareSuccessCount = 0;
  1986. WXContro.failCount = 0;
  1987. class Http {
  1988. request(url, success, fail) {
  1989. console.log("-> http request url:" + url);
  1990. let http = new Laya.HttpRequest();
  1991. http.once(Laya.Event.PROGRESS, this, (res) => { });
  1992. http.once(Laya.Event.COMPLETE, this, (res) => {
  1993. if (success) {
  1994. success(res);
  1995. }
  1996. });
  1997. http.once(Laya.Event.ERROR, this, (res) => {
  1998. if (fail) {
  1999. fail(res);
  2000. }
  2001. });
  2002. http.send(url, null, 'get', 'text');
  2003. }
  2004. static getGameData(callBack = null) {
  2005. let url = Consts.host + "/game?appName=" + Consts.appName + "&action=getGameData&version=" + Consts.version;
  2006. new Http().request(url, (res) => {
  2007. LibData.setGameData(res);
  2008. console.log("GameData:" + res);
  2009. if (callBack) {
  2010. callBack();
  2011. }
  2012. });
  2013. }
  2014. static getSessionKey(code, callBack) {
  2015. let url = Consts.host + "/game?appName=" + Consts.appName + "&action=getSessionKey&appid=" + Consts.appId + "&secret=" + Consts.appSecret + "&js_code=" + code + "&grant_type=authorization_code";
  2016. new Http().request(url, (res) => {
  2017. callBack(res);
  2018. });
  2019. }
  2020. static userCalcIn(res) {
  2021. if (res == null || res.referrerInfo == null) {
  2022. return;
  2023. }
  2024. if (res.scene && res.scene == 1037 && res.referrerInfo.appId) {
  2025. let url = Consts.host + "/game?appName=" + Consts.appName + "&action=userCalc&type=1&appId=" + Consts.appId + "&relateAppId=" + res.referrerInfo.appId;
  2026. new Http().request(url);
  2027. }
  2028. }
  2029. static saveUser(enter_id, type, inAppId, scene, referrerInfo) {
  2030. scene = scene || "";
  2031. let appId = "";
  2032. if (referrerInfo && referrerInfo.appId) {
  2033. appId = referrerInfo.appId;
  2034. }
  2035. let url = Consts.host + "/game?appName=" + encodeURIComponent(Consts.appName) + "&action=saveUser&openid=" + encodeURIComponent(LibData.getOpenid()) +
  2036. "&name=" + encodeURIComponent(LibData.getNickname()) + "&avatar=" + encodeURIComponent(LibData.getPhoto()) + "&level=" + encodeURIComponent(Data.getMaxScore()) +
  2037. "&type=" + encodeURIComponent(scene) + "&appId=" + encodeURIComponent(appId) + "&inAppId=" + encodeURIComponent("1") + "&extra=" + encodeURIComponent(LibData.getExtraData());
  2038. if (enter_id == 0 && type == 0 && inAppId) {
  2039. url += "&shareInAppId=" + encodeURIComponent("1");
  2040. }
  2041. let aid = LibData.getAID();
  2042. if (enter_id == 0 && type == 0 && aid.length > 0) {
  2043. url += "&aid=" + encodeURIComponent(aid);
  2044. }
  2045. new Http().request(url, (res) => {
  2046. let data = res.replace(" ", "");
  2047. data = data.replace("\n", "");
  2048. LibData.setInAppId(res[0]);
  2049. });
  2050. }
  2051. static sharePoint(name, type) {
  2052. let url = Consts.host + "/game?appName=" + Consts.appName + "&action=addGameCount&posName=" + name + "&type=" + type;
  2053. new Http().request(url);
  2054. }
  2055. static userCalcOut(relateAppId) {
  2056. let url = Consts.host + "/game?appName=" + Consts.appName + "&action=userCalc&type=0&appId=" + Consts.appId + "&relateAppId=" + relateAppId;
  2057. new Http().request(url);
  2058. }
  2059. static getFlowIconData(callback = null) {
  2060. let url = Consts.host + "/game?appName=" + Consts.appName + "&action=getFlowIconData";
  2061. new Http().request(url, (res) => {
  2062. let listData = [];
  2063. let table = JSON.parse(res);
  2064. for (let item of table) {
  2065. let data = {};
  2066. data.appId = item.appId;
  2067. data.appName = item.cnName;
  2068. data.icon = item.cdnIcon;
  2069. listData.push(data);
  2070. }
  2071. LibData.set_FlowIcon_Data(listData);
  2072. callback();
  2073. });
  2074. }
  2075. static enterGameByShare(openid) {
  2076. let friendid = LibData.getOpenid();
  2077. let url = Consts.host + "/game?appName=" + Consts.appName + "&action=enterGameByShare&openid=" + openid + "&friendid=" + friendid + "&name=" + LibData.getNickname() + "&avatar=" + LibData.getPhoto();
  2078. new Http().request(url);
  2079. }
  2080. static getInviteFriends(callBack) {
  2081. let url = Consts.host + "/game?appName=" + Consts.appName + "&action=getInviteFriends&openid=" + LibData.getOpenid();
  2082. new Http().request(url, (friends) => {
  2083. LibData.setFriendsData(friends);
  2084. if (callBack) {
  2085. callBack(LibData.getFriendsData());
  2086. }
  2087. });
  2088. }
  2089. static getRandomUser() {
  2090. let url = Consts.host + "/game?appName=" + Consts.appName + "&action=getRandomUser&openid=" + LibData.getOpenid();
  2091. new Http().request(url, (res) => {
  2092. let table = JSON.parse(res);
  2093. if (table.name == "" || table.avatar == "" || table.openid == LibData.getOpenid()) {
  2094. this.getRandomUser();
  2095. }
  2096. else {
  2097. LibData.setMatchUser(res);
  2098. }
  2099. });
  2100. }
  2101. static getIp(callback) {
  2102. let openId = LibData.getOpenid() || "";
  2103. let url = Consts.host + "/game?appName=" + Consts.appName + "&action=getIp&openId=" + openId;
  2104. console.log("-> http request url:" + url);
  2105. new Http().request(url, (res) => {
  2106. console.log("-> http request success:" + res);
  2107. callback(res);
  2108. });
  2109. }
  2110. static getAddress(callback) {
  2111. let url = Consts.host + "/game?appName=" + Consts.appName + "&action=getAddress";
  2112. new Http().request(url, (res) => {
  2113. console.log("-> getAddress:" + res);
  2114. callback(res);
  2115. });
  2116. }
  2117. static getUsers(count) {
  2118. let url = Consts.host + "/game?appName=" + Consts.appName + "&action=getUsers&count=" + count;
  2119. new Http().request(url, (res) => {
  2120. LibData.setUsers(res);
  2121. });
  2122. }
  2123. static downloadData(table, success, fail) {
  2124. let url = "http://39.97.229.203/api/app/numerical/json/" + Consts.constName + "_" + table + ".json";
  2125. new Http().request(url, (res) => {
  2126. let json_table = JSON.parse(res);
  2127. success(json_table);
  2128. }, (res) => {
  2129. fail(res);
  2130. });
  2131. }
  2132. static userGameDateCheck(enter_id, inAppId, scene, referrerInfo) {
  2133. this.getGameUserData(enter_id, (type) => {
  2134. this.saveUser(enter_id, type, inAppId, scene, referrerInfo);
  2135. });
  2136. }
  2137. static updateGameUserData() {
  2138. let extra_str = LibData.getExtraData();
  2139. let extra_json = JSON.parse(extra_str);
  2140. extra_json["T"] = LibData.getExtraT() + 1;
  2141. extra_json["TT"] = LibData.getExtraTT();
  2142. if (WXContro.getLength(extra_str) > 1990) {
  2143. WXContro.warning_tips("上传服务器数据长度超过了指定位数 上传失败~~~");
  2144. return;
  2145. }
  2146. this.getGameUserData(-1, (type) => {
  2147. LibData.setExtraData(JSON.stringify(extra_json));
  2148. let url = Consts.host + "/game?appName=" + Consts.appName + "&action=updateUserInfo&openid=" + LibData.getOpenid()
  2149. + "&level=" + Data.getMaxScore() + "&extra=" + encodeURIComponent(LibData.getExtraData());
  2150. new Http().request(url);
  2151. });
  2152. }
  2153. static getGameUserData(enter_id, call) {
  2154. let url = Consts.host + "/game?appName=" + Consts.appName + "&action=getUserInfo&openid=" + LibData.getOpenid();
  2155. new Http().request(url, (res) => {
  2156. console.log("->extra_date:", res);
  2157. let extra_server = JSON.parse(res).extra;
  2158. let extra_local = JSON.parse(LibData.getExtraData());
  2159. if (!call)
  2160. return;
  2161. if (extra_server && extra_server.T) {
  2162. let server_dateT = extra_server.T;
  2163. let middle = new Date(2020, 4, 1, 0, 0).getTime();
  2164. if (extra_local["T"]) {
  2165. let local_dateT = extra_local["T"];
  2166. if (local_dateT > middle && server_dateT > middle) {
  2167. if (local_dateT < server_dateT) {
  2168. extra_server.T = 1;
  2169. extra_local = extra_server;
  2170. }
  2171. }
  2172. else if (local_dateT < middle && server_dateT < middle) {
  2173. if (local_dateT < server_dateT) {
  2174. extra_local = extra_server;
  2175. }
  2176. }
  2177. else if (local_dateT > middle && server_dateT < middle) {
  2178. extra_local = extra_server;
  2179. }
  2180. }
  2181. else {
  2182. if (server_dateT > middle) {
  2183. extra_server.T = 1;
  2184. }
  2185. extra_local = extra_server;
  2186. }
  2187. if (!extra_local["TT"]) {
  2188. extra_local["TT"] = new Date(2020, 4, 1, 0, 0).getTime();
  2189. }
  2190. LibData.setExtraData(JSON.stringify(extra_local));
  2191. call(1);
  2192. LibData.setUserIdentity(1);
  2193. }
  2194. else {
  2195. extra_local["T"] = 1;
  2196. extra_local["TT"] = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), 0, 0).getTime();
  2197. LibData.setExtraData(JSON.stringify(extra_local));
  2198. call(0);
  2199. LibData.setUserIdentity(0);
  2200. }
  2201. this.setExtarT();
  2202. this.setUserType();
  2203. if (enter_id == 0) {
  2204. EventHandler.getInstance().Emit("http_server_data");
  2205. }
  2206. }, (res) => {
  2207. if (enter_id == 0) {
  2208. EventHandler.getInstance().Emit("http_server_data");
  2209. }
  2210. });
  2211. }
  2212. static setExtarT() {
  2213. let extra_local = JSON.parse(LibData.getExtraData());
  2214. LibData.setExtraT(extra_local["T"]);
  2215. }
  2216. static setUserType() {
  2217. let extra_local = JSON.parse(LibData.getExtraData());
  2218. let TT = extra_local["TT"];
  2219. if (new Date().getTime() - TT < 24 * 60 * 60 * 1000) {
  2220. LibData.setUserType(0);
  2221. }
  2222. else {
  2223. LibData.setUserType(1);
  2224. }
  2225. console.log(extra_local["TT"]);
  2226. LibData.setExtraTT(extra_local["TT"]);
  2227. }
  2228. static getAllFlowIconData(callback_success = null, callback_fail = null) {
  2229. let url = Consts.host + "/game?appName=" + Consts.appName + "&action=icons";
  2230. new Http().request(url, (res) => {
  2231. let table = JSON.parse(res);
  2232. callback_success(table);
  2233. }, () => {
  2234. callback_fail();
  2235. });
  2236. }
  2237. }
  2238. class Func {
  2239. static substr(str, len, end = "") {
  2240. if (!str || !len) {
  2241. return '';
  2242. }
  2243. let a = 0;
  2244. var temp = '';
  2245. for (let i = 0; i < str.length; i++) {
  2246. if (str.charCodeAt(i) > 255) {
  2247. a += 2;
  2248. }
  2249. else {
  2250. a++;
  2251. }
  2252. if (a > len) {
  2253. break;
  2254. }
  2255. temp += str.charAt(i);
  2256. }
  2257. if (temp == str) {
  2258. return str;
  2259. }
  2260. return temp + end;
  2261. }
  2262. static playButtonClick() {
  2263. }
  2264. static playSound(sound) {
  2265. Laya.SoundManager.playSound(sound);
  2266. }
  2267. static playMusic(url, loops = 0, complete, startTime) {
  2268. if (Laya.Browser.onWeiXin) {
  2269. let wx = window["wx"];
  2270. this.bgm = wx.createInnerAudioContext();
  2271. this.bgm.autoplay = true;
  2272. this.bgm.loop = true;
  2273. this.bgm.src = url;
  2274. this.bgm.play();
  2275. wx.onShow(function () {
  2276. console.log("重新回到游戏");
  2277. Func.bgm.play();
  2278. });
  2279. }
  2280. else {
  2281. Laya.SoundManager.playMusic(url, loops, complete, startTime);
  2282. }
  2283. }
  2284. static stopMusic() {
  2285. let wx = window["wx"];
  2286. if (wx == null) {
  2287. Laya.SoundManager.stopMusic();
  2288. return;
  2289. }
  2290. this.bgm.stop();
  2291. }
  2292. static setMusicVolume(volume) {
  2293. Laya.SoundManager.setMusicVolume(volume);
  2294. }
  2295. static getTimeStamp() {
  2296. return Math.floor(new Date().getTime() / 1000);
  2297. }
  2298. static isOtherDay(timeStamp) {
  2299. if (Math.floor(this.getTimeStamp() / 86400) > Math.floor(timeStamp / 86400)) {
  2300. return true;
  2301. }
  2302. return false;
  2303. }
  2304. static getTableSize(map) {
  2305. let size = 0;
  2306. for (let i in map) {
  2307. ++size;
  2308. }
  2309. return size;
  2310. }
  2311. static sharePoint(name, type, success, fail = null, isShare = null, params = { type: "", img: null, title: null }) {
  2312. let share = isShare === null ? WXContro.isShare() : isShare;
  2313. WXContro.sharePoint(name, share, type, success, fail, params);
  2314. }
  2315. static showVideo(name, success, fail) {
  2316. WXContro.showVideo_direct(name, success, fail);
  2317. }
  2318. static showShare(name) {
  2319. WXContro.showShare_direct(name);
  2320. }
  2321. static sharePointCount(name, type) {
  2322. Http.sharePoint(name, type);
  2323. }
  2324. static downloadData(table, success, fail) {
  2325. Http.downloadData(table, success, fail);
  2326. }
  2327. static updateGameUserData() {
  2328. Http.updateGameUserData();
  2329. }
  2330. }
  2331. class MusicControl {
  2332. constructor() {
  2333. }
  2334. static playBGMusic() {
  2335. Func.playMusic(this.musicName.bgMusic, 0);
  2336. }
  2337. static btnClick() {
  2338. this.playSound(this.musicName.btnClick, 1);
  2339. }
  2340. static gameFailed() {
  2341. this.playSound(this.musicName.gameFailed, 1);
  2342. Laya.SoundManager.setMusicVolume(0.3);
  2343. Laya.timer.once(2400, this, function () {
  2344. Laya.SoundManager.setMusicVolume(1);
  2345. });
  2346. }
  2347. static getCoins() {
  2348. this.playSound(this.musicName.getCoins, 1);
  2349. }
  2350. static knifeAttackSun() {
  2351. this.playSound(this.musicName.knifeAttackSun, 1);
  2352. }
  2353. static planetDie() {
  2354. this.playSound(this.musicName.planetDie, 1);
  2355. }
  2356. static useProp() {
  2357. this.playSound(this.musicName.useProp, 1);
  2358. }
  2359. static gameSuccess() {
  2360. this.playSound(this.musicName.gameSuccess, 1);
  2361. }
  2362. static hitObstacle() {
  2363. this.playSound(this.musicName.hitObstacle, 1);
  2364. }
  2365. static playMusic(musicPath, loops) {
  2366. Laya.SoundManager.playMusic(musicPath, loops);
  2367. }
  2368. static playSound(musicPath, loops, completeHandler) {
  2369. Laya.SoundManager.playSound(musicPath, loops, completeHandler);
  2370. }
  2371. }
  2372. MusicControl.musicName = {
  2373. "bgMusic": "music/bgMusic.mp3",
  2374. "btnClick": "music/btnClick.mp3",
  2375. "gameFailed": "music/gameFailed.mp3",
  2376. "getCoins": "music/getCoins.mp3",
  2377. "knifeAttackSun": "music/knifeAttackSun.mp3",
  2378. "planetDie": "music/planetDie.mp3",
  2379. "useProp": "music/useProp.wav",
  2380. "gameSuccess": "music/gameSuccess.mp3",
  2381. "hitObstacle": "music/hitObstacle.wav"
  2382. };
  2383. class BtnEffectControl extends Laya.Component {
  2384. constructor() {
  2385. super();
  2386. Laya.timer.once(100, this, function () {
  2387. let selfOwner = this.owner;
  2388. selfOwner.on(Laya.Event.MOUSE_DOWN, selfOwner, function () {
  2389. Laya.Tween.to(selfOwner, { scaleX: 0.8, scaleY: 0.8 }, 50);
  2390. MusicControl.btnClick();
  2391. });
  2392. selfOwner.on(Laya.Event.MOUSE_UP, selfOwner, function () {
  2393. Laya.Tween.to(selfOwner, { scaleX: 1, scaleY: 1 }, 600, Laya.Ease.backOut);
  2394. });
  2395. selfOwner.on(Laya.Event.MOUSE_OUT, selfOwner, function () {
  2396. Laya.Tween.to(selfOwner, { scaleX: 1, scaleY: 1 }, 600, Laya.Ease.backOut);
  2397. });
  2398. });
  2399. }
  2400. }
  2401. var REG = Laya.ClassUtils.regClass;
  2402. var ui;
  2403. (function (ui) {
  2404. var Dialogs;
  2405. (function (Dialogs) {
  2406. class Dialog_FreelyGetPropUI extends Laya.Dialog {
  2407. constructor() {
  2408. super();
  2409. }
  2410. createChildren() {
  2411. super.createChildren();
  2412. this.createView(Dialog_FreelyGetPropUI.uiView);
  2413. }
  2414. }
  2415. Dialog_FreelyGetPropUI.uiView = { "type": "Dialog", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Sprite", "props": { "y": -140, "x": 0, "width": 720, "texture": "texture/Public/mask.jpg", "height": 1560, "alpha": 0.8 }, "compId": 19 }, { "type": "Sprite", "props": { "y": 278, "x": 95, "texture": "texture/Dialog_GetProp/dialogBG.png", "name": "bg" }, "compId": 8 }, { "type": "Button", "props": { "y": 850, "x": 360, "width": 320, "var": "btn_freeRevive", "stateNum": 1, "skin": "texture/Dialog_GetProp/btn_freeRevive.png", "pivotY": 60, "pivotX": 160, "name": "btn_freeRevive", "labelSize": 28, "labelPadding": "28", "labelColors": "#fff100", "labelBold": true, "label": "1/4", "height": 120 }, "compId": 10, "child": [{ "type": "Script", "props": { "runtime": "game/BtnEffectControl.ts" }, "compId": 20 }] }, { "type": "Text", "props": { "y": 665, "x": 0, "width": 720, "var": "text_propName", "text": "火箭", "name": "text_propName", "height": 40, "fontSize": 40, "color": "#ffe400", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 12 }, { "type": "Text", "props": { "y": 719, "x": 0, "width": 720, "var": "text_propInfo", "text": "可获得5个无撞击的无敌箭矢", "name": "text_propInfo", "height": 40, "fontSize": 28, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 21 }, { "type": "Sprite", "props": { "y": 464, "x": 279, "width": 162, "var": "icon_prop", "texture": "texture/Dialog_GetProp/rocket.png", "name": "icon_prop", "height": 190 }, "compId": 13 }, { "type": "Text", "props": { "y": 932, "x": 296, "visible": false, "var": "btn_nextTime", "text": "下次再说", "name": "btn_nextTime", "fontSize": 32, "color": "#ffffff", "runtime": "laya.display.Text" }, "compId": 18 }], "loadList": ["texture/Public/mask.jpg", "texture/Dialog_GetProp/dialogBG.png", "texture/Dialog_GetProp/btn_freeRevive.png", "texture/Dialog_GetProp/rocket.png"], "loadList3D": [] };
  2416. Dialogs.Dialog_FreelyGetPropUI = Dialog_FreelyGetPropUI;
  2417. REG("ui.Dialogs.Dialog_FreelyGetPropUI", Dialog_FreelyGetPropUI);
  2418. class Dialog_GameOverUI extends Laya.Dialog {
  2419. constructor() {
  2420. super();
  2421. }
  2422. createChildren() {
  2423. super.createChildren();
  2424. this.createView(Dialog_GameOverUI.uiView);
  2425. }
  2426. }
  2427. Dialog_GameOverUI.uiView = { "type": "Dialog", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Sprite", "props": { "y": -140, "x": 0, "width": 720, "texture": "texture/Public/mask.jpg", "height": 1560, "alpha": 0.8 }, "compId": 57 }, { "type": "Box", "props": { "y": 220, "x": 124, "var": "defeatTopUI", "name": "defeatTopUI" }, "compId": 30, "child": [{ "type": "Sprite", "props": { "x": 23, "texture": "texture/Dialog_LevelOver/light_defeat.png", "name": "light" }, "compId": 9, "child": [{ "type": "Sprite", "props": { "y": 185, "x": 94, "texture": "texture/Dialog_LevelOver/title_defeat.png", "name": "title" }, "compId": 8 }] }, { "type": "Box", "props": { "y": 366, "scaleY": 0.8, "scaleX": 0.8, "name": "blood" }, "compId": 20, "child": [{ "type": "Sprite", "props": { "texture": "texture/GameScene/progressBG_blood.png", "name": "bloodBG" }, "compId": 62 }, { "type": "Sprite", "props": { "y": 6, "x": 7, "width": 576, "var": "bloodProgressBar", "value": 0.01, "texture": "texture/GameScene/progressBar_blood.png", "name": "bloodProgressBar", "height": 20 }, "compId": 63, "child": [{ "type": "Panel", "props": { "y": 0, "x": 0, "width": 576, "var": "bloodBarMask", "renderType": "mask", "name": "bloodBarMask", "height": 20, "bgColor": "#000000" }, "compId": 64 }] }] }, { "type": "Box", "props": { "y": 422, "x": -124, "width": 720, "name": "coinAndBlood" }, "compId": 26, "child": [{ "type": "Text", "props": { "y": 6, "x": 581, "width": 91, "var": "text_bloodNum", "text": "11.44k", "strokeColor": "#e1a030", "stroke": 2, "pivotX": 91, "name": "text_bloodNum", "height": 30, "fontSize": 30, "color": "#ffffff", "bold": true, "align": "right", "runtime": "laya.display.Text" }, "compId": 21, "child": [{ "type": "Panel", "props": { "y": 15, "x": 0, "width": 170, "right": 91, "pivotY": 20, "pivotX": 170, "height": 40 }, "compId": 24, "child": [{ "type": "Sprite", "props": { "y": 0, "x": 0, "texture": "texture/GameScene/icon_blood.png" }, "compId": 65 }, { "type": "Text", "props": { "y": 8, "x": 55, "text": "剩余血量:", "fontSize": 24, "color": "#ffffff", "runtime": "laya.display.Text" }, "compId": 25 }] }] }, { "type": "Sprite", "props": { "y": 0, "x": 135, "var": "coinIcon", "texture": "texture/MainScene/TAB/icon_Coin.png", "scaleY": 0.28, "scaleX": 0.28, "name": "coinIcon" }, "compId": 22 }, { "type": "Text", "props": { "y": 6, "x": 185, "var": "text_coinNumFromCurLevel", "text": "9999", "strokeColor": "#e1a030", "stroke": 2, "name": "text_coinNumFromCurLevel", "fontSize": 30, "color": "#ffffff", "bold": true, "align": "left", "runtime": "laya.display.Text" }, "compId": 23 }] }, { "type": "Text", "props": { "y": 483, "x": -124.5, "width": 720, "var": "defeatReason", "text": "失败原因:碰到障碍物", "name": "defeatReason", "fontSize": 28, "color": "#ff0000", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 56 }] }, { "type": "Box", "props": { "y": 0, "x": 0, "width": 720, "visible": false, "var": "defeat_hasReviveChanceUI", "name": "defeat_hasReviveChanceUI", "height": 1280 }, "compId": 3, "child": [{ "type": "Text", "props": { "y": 626, "x": 0, "width": 720, "text": "复活后太阳血量减半并获得7个无敌火箭。", "name": "tip", "fontSize": 28, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 16, "child": [{ "type": "Text", "props": { "y": 35, "x": 0, "width": 720, "text": "还有机会减少太阳上的禁牌和火箭。", "name": "tip", "fontSize": 28, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 17 }, { "type": "Text", "props": { "y": -35, "x": 0, "width": 720, "text": "您获得一次复活机会,", "name": "tip", "fontSize": 28, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 15 }] }, { "type": "Button", "props": { "y": 837, "x": 360, "width": 328, "var": "btn_revive", "stateNum": 1, "skin": "texture/Dialog_LevelOver/btn_revive.png", "pivotY": 64, "pivotX": 164, "name": "btn_revive", "height": 128 }, "compId": 27, "child": [{ "type": "Script", "props": { "runtime": "game/BtnEffectControl.ts" }, "compId": 58 }] }, { "type": "Button", "props": { "y": 935, "x": 360, "width": 64, "var": "btn_giveUp", "stateNum": 1, "skin": "texture/Dialog_LevelOver/btn_giveUp.png", "pivotY": 16, "pivotX": 32, "name": "btn_giveUp", "height": 32 }, "compId": 28, "child": [{ "type": "Script", "props": { "runtime": "game/BtnEffectControl.ts" }, "compId": 59 }] }] }, { "type": "Box", "props": { "y": 757, "x": 166, "var": "receiveCoinUI", "name": "receiveCoinUI" }, "compId": 34, "child": [{ "type": "Text", "props": { "x": 128, "text": "您赚到了", "name": "tip", "fontSize": 32, "color": "#ffd972", "bold": true, "runtime": "laya.display.Text" }, "compId": 33 }, { "type": "Button", "props": { "y": 252, "x": 157, "visible": false, "var": "btn_threeTimesReceiving", "stateNum": 1, "skin": "texture/Dialog_LevelOver/btn_threeTimesReceiving.png", "pivotY": 64, "pivotX": 194, "name": "btn_threeTimesReceiving", "labelStrokeColor": "#996100", "labelStroke": 2, "labelSize": 38, "labelPadding": "5,70,20,50", "labelColors": "#ffffff", "labelBold": true }, "compId": 32, "child": [{ "type": "Script", "props": { "runtime": "game/BtnEffectControl.ts" }, "compId": 61 }] }, { "type": "Button", "props": { "y": 177.5, "x": 157, "var": "btn_receiveRightNow", "stateNum": 1, "skin": "texture/Dialog_LevelOver/btn_receiveRightNow.png", "pivotY": 69, "pivotX": 194, "name": "btn_receiveRightNow", "labelStrokeColor": "#996100", "labelStroke": 2, "labelSize": 38, "labelPadding": "7,70,20,50", "labelColors": "#ffffff", "labelBold": true, "label": "213.02K" }, "compId": 31 }] }, { "type": "Box", "props": { "y": 220, "x": 124, "var": "victoryTopUI", "name": "victoryTopUI" }, "compId": 35, "child": [{ "type": "Sprite", "props": { "x": 23, "texture": "texture/Dialog_LevelOver/light_victory.png", "name": "light" }, "compId": 36, "child": [{ "type": "Sprite", "props": { "y": 185, "x": 94, "texture": "texture/Dialog_LevelOver/title_victory.png", "name": "title" }, "compId": 37 }] }, { "type": "Sprite", "props": { "y": 319, "x": 121, "visible": false, "texture": "texture/MainScene/icon_strength.png", "name": "icon_strength" }, "compId": 52, "child": [{ "type": "Text", "props": { "y": 114, "x": 142, "var": "text_strengthNum", "text": "+5", "strokeColor": "#e1a030", "stroke": 2, "name": "text_strengthNum", "fontSize": 50, "color": "#ffffff", "bold": true, "runtime": "laya.display.Text" }, "compId": 53 }] }] }, { "type": "Box", "props": { "y": 166, "x": 0, "var": "publicUI", "name": "publicUI" }, "compId": 54, "child": [{ "type": "Text", "props": { "y": 343, "x": 360, "width": 60, "var": "text_levelNum", "text": "100", "strokeColor": "#e1a030", "stroke": 2, "pivotX": 30, "name": "text_levelNum", "height": 36, "fontSize": 36, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 10, "child": [{ "type": "Panel", "props": { "y": 0, "x": -50, "width": 35, "var": "levelNum_left", "name": "levelNum_left", "height": 36 }, "compId": 11, "child": [{ "type": "Text", "props": { "y": 4, "x": 3, "text": "第", "fontSize": 28, "color": "#ffd972", "bold": true, "runtime": "laya.display.Text" }, "compId": 12 }] }, { "type": "Panel", "props": { "y": 0, "x": 70, "width": 35, "var": "levelNum_right", "name": "levelNum_right", "height": 36 }, "compId": 13, "child": [{ "type": "Text", "props": { "y": 4, "x": 3, "text": "关", "fontSize": 28, "color": "#ffd972", "bold": true, "runtime": "laya.display.Text" }, "compId": 14 }] }] }] }], "loadList": ["texture/Public/mask.jpg", "texture/Dialog_LevelOver/light_defeat.png", "texture/Dialog_LevelOver/title_defeat.png", "texture/GameScene/progressBG_blood.png", "texture/GameScene/progressBar_blood.png", "texture/GameScene/icon_blood.png", "texture/MainScene/TAB/icon_Coin.png", "texture/Dialog_LevelOver/btn_revive.png", "texture/Dialog_LevelOver/btn_giveUp.png", "texture/Dialog_LevelOver/btn_threeTimesReceiving.png", "texture/Dialog_LevelOver/btn_receiveRightNow.png", "texture/Dialog_LevelOver/light_victory.png", "texture/Dialog_LevelOver/title_victory.png", "texture/MainScene/icon_strength.png"], "loadList3D": [] };
  2428. Dialogs.Dialog_GameOverUI = Dialog_GameOverUI;
  2429. REG("ui.Dialogs.Dialog_GameOverUI", Dialog_GameOverUI);
  2430. class Dialog_GetStrengthUI extends Laya.Dialog {
  2431. constructor() {
  2432. super();
  2433. }
  2434. createChildren() {
  2435. super.createChildren();
  2436. this.createView(Dialog_GetStrengthUI.uiView);
  2437. }
  2438. }
  2439. Dialog_GetStrengthUI.uiView = { "type": "Dialog", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Sprite", "props": { "y": -140, "x": 0, "width": 720, "texture": "texture/Public/mask.jpg", "height": 1560, "alpha": 0.8 }, "compId": 16 }, { "type": "Sprite", "props": { "y": 288, "x": 95, "texture": "texture/Dialog_CoinAndStrength/dialogBG.png", "name": "bg" }, "compId": 8 }, { "type": "Sprite", "props": { "y": 321, "x": 261, "texture": "texture/Dialog_CoinAndStrength/title_strengthRecovery.png", "name": "title" }, "compId": 9 }, { "type": "Button", "props": { "y": 797, "x": 360, "width": 330, "var": "btn_getStrength", "stateNum": 1, "skin": "texture/Dialog_CoinAndStrength/btn_getStrength.png", "pivotY": 63, "pivotX": 165, "name": "btn_getStrength", "labelSize": 28, "labelPadding": "30", "labelColors": "#fff100", "labelBold": true, "label": "30点体力", "height": 125 }, "compId": 11, "child": [{ "type": "Script", "props": { "runtime": "game/BtnEffectControl.ts" }, "compId": 17 }] }, { "type": "Button", "props": { "y": 916, "x": 360, "width": 129, "var": "btn_nextTime", "stateNum": 1, "skin": "texture/Dialog_CoinAndStrength/btn_nextTime.png", "pivotY": 15, "pivotX": 65, "name": "btn_nextTime", "height": 30 }, "compId": 12, "child": [{ "type": "Script", "props": { "runtime": "game/BtnEffectControl.ts" }, "compId": 18 }] }, { "type": "Text", "props": { "y": 677, "x": 358, "width": 267, "var": "tip", "text": "体力已经最满啦!", "pivotX": 133, "name": "tip", "height": 28, "fontSize": 28, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 13 }, { "type": "Sprite", "props": { "y": 440, "x": 256, "texture": "texture/MainScene/icon_strength.png", "name": "icon_strength" }, "compId": 15, "child": [{ "type": "Sprite", "props": { "y": 111, "x": 104, "width": 184, "visible": false, "var": "ring", "texture": "texture/Dialog_CoinAndStrength/ring.png", "pivotY": 92, "pivotX": 92, "name": "ring", "height": 184 }, "compId": 14 }] }, { "type": "Sprite", "props": { "y": 459, "x": 268, "texture": "texture/Dialog_CoinAndStrength/strengthRingBG.png", "name": "strengthRingBG" }, "compId": 21 }, { "type": "Sprite", "props": { "y": 552, "x": 360, "width": 184, "var": "strengthRingProgress", "pivotY": 92, "pivotX": 92, "name": "strengthRingProgress", "height": 184 }, "compId": 19, "child": [{ "type": "Sprite", "props": { "y": 92, "x": 92, "width": 184, "var": "strengthProgressMask", "texture": "texture/Dialog_CoinAndStrength/ring.png", "renderType": "mask", "pivotY": 92, "pivotX": 92, "name": "strengthProgressMask", "height": 184 }, "compId": 20 }] }], "loadList": ["texture/Public/mask.jpg", "texture/Dialog_CoinAndStrength/dialogBG.png", "texture/Dialog_CoinAndStrength/title_strengthRecovery.png", "texture/Dialog_CoinAndStrength/btn_getStrength.png", "texture/Dialog_CoinAndStrength/btn_nextTime.png", "texture/MainScene/icon_strength.png", "texture/Dialog_CoinAndStrength/ring.png", "texture/Dialog_CoinAndStrength/strengthRingBG.png"], "loadList3D": [] };
  2440. Dialogs.Dialog_GetStrengthUI = Dialog_GetStrengthUI;
  2441. REG("ui.Dialogs.Dialog_GetStrengthUI", Dialog_GetStrengthUI);
  2442. class Dialog_ReceiveCoinProfitUI extends Laya.Dialog {
  2443. constructor() {
  2444. super();
  2445. }
  2446. createChildren() {
  2447. super.createChildren();
  2448. this.createView(Dialog_ReceiveCoinProfitUI.uiView);
  2449. }
  2450. }
  2451. Dialog_ReceiveCoinProfitUI.uiView = { "type": "Dialog", "props": { "width": 720, "mouseThrough": true, "height": 1280 }, "compId": 2, "child": [{ "type": "Sprite", "props": { "y": -140, "x": 0, "width": 720, "texture": "texture/Public/mask.jpg", "height": 1560, "alpha": 0.8 }, "compId": 22 }, { "type": "Panel", "props": { "y": -140, "x": 0, "width": 720, "var": "touchArea", "name": "touchArea", "height": 1560 }, "compId": 20 }, { "type": "Sprite", "props": { "y": 288, "x": 95, "texture": "texture/Dialog_CoinAndStrength/dialogBG.png", "name": "bg" }, "compId": 7 }, { "type": "Sprite", "props": { "y": 321, "x": 191, "texture": "texture/Dialog_CoinAndStrength/title_profitCanBeReceived.png", "name": "title" }, "compId": 8 }, { "type": "Text", "props": { "y": 512, "x": 359, "width": 271, "var": "text_UpperLimitTime", "strokeColor": "#cc72ff", "stroke": 4, "pivotX": 135, "overflow": "visible", "name": "text_UpperLimitTime", "leading": 10, "height": 52, "fontSize": 42, "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 15, "child": [{ "type": "Text", "props": { "y": 49, "x": -20, "visible": false, "text": "收益达到上限", "strokeColor": "#cc72ff", "stroke": 4, "name": "tip", "fontSize": 42, "color": "#ffffff", "bold": true, "runtime": "laya.display.Text" }, "compId": 14 }, { "type": "Text", "props": { "y": 0, "x": 176, "visible": false, "text": "后", "strokeColor": "#cc72ff", "stroke": 4, "name": "tip", "fontSize": 42, "color": "#ffffff", "bold": true, "runtime": "laya.display.Text" }, "compId": 12 }] }, { "type": "Button", "props": { "y": 825, "x": 341, "var": "btn_clickReceive", "stateNum": 1, "skin": "texture/Dialog_CoinAndStrength/btn_clickReceive.png", "pivotY": 70, "pivotX": 198, "name": "btn_clickReceive", "labelStrokeColor": "#996100", "labelStroke": 2, "labelSize": 38, "labelPadding": "-3,70,23,50", "labelFont": "Arial", "labelColors": "#ffffff", "labelBold": true }, "compId": 18, "child": [{ "type": "Script", "props": { "runtime": "game/BtnEffectControl.ts" }, "compId": 23 }, { "type": "Text", "props": { "y": 49, "x": 197, "width": 142, "var": "text_btn_clickReceive", "text": "111.11k", "strokeColor": "#996100", "stroke": 2, "pivotY": 19, "pivotX": 63, "name": "text_btn_clickReceive", "height": 38, "fontSize": 38, "font": "Arial", "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 25 }] }, { "type": "Button", "props": { "y": 886, "x": 341, "visible": false, "var": "btn_threeTimesReceive", "stateNum": 1, "skin": "texture/Dialog_CoinAndStrength/btn_threeTimesReceiving.png", "pivotY": 70, "pivotX": 198, "name": "btn_threeTimesReceive", "labelStrokeColor": "#996100", "labelStroke": 2, "labelSize": 38, "labelPadding": "-5,70,30,50", "labelFont": "Arial", "labelColors": "#ffffff", "labelBold": true }, "compId": 19, "child": [{ "type": "Script", "props": { "runtime": "game/BtnEffectControl.ts" }, "compId": 24 }, { "type": "Text", "props": { "y": 49, "x": 197, "width": 142, "var": "text_btn_threeTimesReceive", "text": "111.11k", "strokeColor": "#996100", "stroke": 2, "pivotY": 19, "pivotX": 63, "name": "text_btn_threeTimesReceive", "height": 38, "fontSize": 38, "font": "Arial", "color": "#ffffff", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 26 }] }, { "type": "Text", "props": { "y": 621, "x": 145, "visible": false, "var": "tip_receiveLater", "text": "您已领取完,请稍后再领!", "name": "tip_receiveLater", "fontSize": 38, "color": "#ffffff", "runtime": "laya.display.Text" }, "compId": 21 }], "loadList": ["texture/Public/mask.jpg", "texture/Dialog_CoinAndStrength/dialogBG.png", "texture/Dialog_CoinAndStrength/title_profitCanBeReceived.png", "texture/Dialog_CoinAndStrength/btn_clickReceive.png", "texture/Dialog_CoinAndStrength/btn_threeTimesReceiving.png"], "loadList3D": [] };
  2452. Dialogs.Dialog_ReceiveCoinProfitUI = Dialog_ReceiveCoinProfitUI;
  2453. REG("ui.Dialogs.Dialog_ReceiveCoinProfitUI", Dialog_ReceiveCoinProfitUI);
  2454. class Dialog_SpeedUpCoinProfitUI extends Laya.Dialog {
  2455. constructor() {
  2456. super();
  2457. }
  2458. createChildren() {
  2459. super.createChildren();
  2460. this.createView(Dialog_SpeedUpCoinProfitUI.uiView);
  2461. }
  2462. }
  2463. Dialog_SpeedUpCoinProfitUI.uiView = { "type": "Dialog", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Sprite", "props": { "y": -140, "x": 0, "width": 720, "texture": "texture/Public/mask.jpg", "height": 1560, "alpha": 0.8 }, "compId": 14 }, { "type": "Sprite", "props": { "y": 278, "x": 95, "texture": "texture/Dialog_CoinAndStrength/dialogBG.png", "name": "bg" }, "compId": 7 }, { "type": "Sprite", "props": { "y": 311, "x": 260, "texture": "texture/Dialog_CoinAndStrength/title_fasterReceiving.png", "name": "title" }, "compId": 9 }, { "type": "Sprite", "props": { "y": 477, "x": 284, "texture": "texture/MainScene/TAB/icon_Coin.png", "name": "coinIcon" }, "compId": 10 }, { "type": "Button", "props": { "y": 788, "x": 360, "width": 348, "var": "btn_threeTimesFaster", "stateNum": 1, "skin": "texture/Dialog_CoinAndStrength/btn_threeTimesFaster.png", "pivotY": 64, "pivotX": 174, "name": "btn_threeTimesFaster", "height": 128 }, "compId": 11, "child": [{ "type": "Script", "props": { "runtime": "game/BtnEffectControl.ts" }, "compId": 15 }] }, { "type": "Button", "props": { "y": 886, "x": 360, "width": 129, "var": "btn_nextTime", "stateNum": 1, "skin": "texture/Dialog_CoinAndStrength/btn_nextTime.png", "pivotY": 15, "pivotX": 65, "name": "btn_nextTime", "height": 30 }, "compId": 12, "child": [{ "type": "Script", "props": { "runtime": "game/BtnEffectControl.ts" }, "compId": 16 }] }, { "type": "Text", "props": { "y": 667, "x": 217, "text": "日常金币收益加速获取", "name": "tip", "fontSize": 28, "color": "#ffffff", "bold": true, "runtime": "laya.display.Text" }, "compId": 13 }, { "type": "Sprite", "props": { "y": 742, "x": 185.5, "visible": false, "var": "fasterCountTime_bg", "texture": "texture/Dialog_CoinAndStrength/threeTimesFasterProgress/fasterCountTime_bg.png", "name": "fasterCountTime_bg" }, "compId": 19, "child": [{ "type": "Sprite", "props": { "y": 0, "x": 0, "width": 348, "texture": "texture/Dialog_CoinAndStrength/threeTimesFasterProgress/fasterCountTime_bar.png", "name": "fasterCountTime_bar", "height": 92 }, "compId": 20, "child": [{ "type": "Sprite", "props": { "y": 0, "x": -174, "width": 348, "var": "mask_fasterCountTime", "texture": "texture/Public/mask.jpg", "renderType": "mask", "name": "mask", "height": 92 }, "compId": 21 }] }, { "type": "FontClip", "props": { "y": 13, "x": 14, "width": 321, "var": "fasterCountTime", "value": "04:45", "skin": "texture/Dialog_CoinAndStrength/threeTimesFasterProgress/clip_num_fasterProfit.png", "sheet": "0123456789", "name": "fasterCountTime", "height": 35, "align": "center" }, "compId": 24 }, { "type": "Sprite", "props": { "y": 13, "x": 166, "texture": "texture/Dialog_CoinAndStrength/threeTimesFasterProgress/maohao.png" }, "compId": 25 }] }], "loadList": ["texture/Public/mask.jpg", "texture/Dialog_CoinAndStrength/dialogBG.png", "texture/Dialog_CoinAndStrength/title_fasterReceiving.png", "texture/MainScene/TAB/icon_Coin.png", "texture/Dialog_CoinAndStrength/btn_threeTimesFaster.png", "texture/Dialog_CoinAndStrength/btn_nextTime.png", "texture/Dialog_CoinAndStrength/threeTimesFasterProgress/fasterCountTime_bg.png", "texture/Dialog_CoinAndStrength/threeTimesFasterProgress/fasterCountTime_bar.png", "texture/Dialog_CoinAndStrength/threeTimesFasterProgress/clip_num_fasterProfit.png", "texture/Dialog_CoinAndStrength/threeTimesFasterProgress/maohao.png"], "loadList3D": [] };
  2464. Dialogs.Dialog_SpeedUpCoinProfitUI = Dialog_SpeedUpCoinProfitUI;
  2465. REG("ui.Dialogs.Dialog_SpeedUpCoinProfitUI", Dialog_SpeedUpCoinProfitUI);
  2466. class Dialog_UnlockPlanetUI extends Laya.Dialog {
  2467. constructor() {
  2468. super();
  2469. }
  2470. createChildren() {
  2471. super.createChildren();
  2472. this.createView(Dialog_UnlockPlanetUI.uiView);
  2473. }
  2474. }
  2475. Dialog_UnlockPlanetUI.uiView = { "type": "Dialog", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Sprite", "props": { "y": -140, "x": 0, "width": 720, "texture": "texture/Public/mask.jpg", "height": 1560, "alpha": 0.8 }, "compId": 13 }, { "type": "Sprite", "props": { "y": 278, "x": 95, "texture": "texture/Dialog_NewPlanet/dialogBG.png", "name": "bg" }, "compId": 7 }, { "type": "Button", "props": { "y": 886, "x": 360, "width": 334, "var": "btn_OK", "stateNum": 1, "skin": "texture/Dialog_NewPlanet/btn_OK.png", "pivotY": 67, "pivotX": 167, "name": "btn_OK", "height": 134 }, "compId": 8, "child": [{ "type": "Script", "props": { "runtime": "game/BtnEffectControl.ts" }, "compId": 14 }] }, { "type": "Text", "props": { "y": 669, "x": 0, "width": 720, "var": "planetName", "text": "水星", "name": "planetName", "fontSize": 40, "color": "#ffe400", "bold": true, "align": "center", "runtime": "laya.display.Text" }, "compId": 5 }, { "type": "Text", "props": { "y": 724, "x": 0, "width": 720, "var": "planetSkill", "text": "可以为太阳加血", "name": "planetSkill", "fontSize": 28, "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 4 }, { "type": "Box", "props": { "y": 549, "x": 360 }, "compId": 12, "child": [{ "type": "Sprite", "props": { "y": 0, "x": 0, "width": 240, "var": "planetIcon", "texture": "texture/Planet/Saturn.png", "pivotY": 81, "pivotX": 120, "name": "planetIcon", "height": 161 }, "compId": 11 }] }], "loadList": ["texture/Public/mask.jpg", "texture/Dialog_NewPlanet/dialogBG.png", "texture/Dialog_NewPlanet/btn_OK.png", "texture/Planet/Saturn.png"], "loadList3D": [] };
  2476. Dialogs.Dialog_UnlockPlanetUI = Dialog_UnlockPlanetUI;
  2477. REG("ui.Dialogs.Dialog_UnlockPlanetUI", Dialog_UnlockPlanetUI);
  2478. })(Dialogs = ui.Dialogs || (ui.Dialogs = {}));
  2479. })(ui || (ui = {}));
  2480. (function (ui) {
  2481. class MainSceneUI extends Laya.Scene {
  2482. constructor() { super(); }
  2483. createChildren() {
  2484. super.createChildren();
  2485. this.loadScene("MainScene");
  2486. }
  2487. }
  2488. ui.MainSceneUI = MainSceneUI;
  2489. REG("ui.MainSceneUI", MainSceneUI);
  2490. class RankUI extends Laya.View {
  2491. constructor() {
  2492. super();
  2493. }
  2494. createChildren() {
  2495. super.createChildren();
  2496. this.createView(RankUI.uiView);
  2497. }
  2498. }
  2499. RankUI.uiView = { "type": "View", "props": { "y": 0, "x": 0, "width": 720, "mouseThrough": true, "height": 1280 }, "compId": 1, "child": [{ "type": "Box", "props": { "width": 720, "mouseThrough": true, "height": 1280, "centerY": 0, "centerX": 0 }, "compId": 78, "child": [{ "type": "Box", "props": { "y": 0, "x": 0, "width": 200, "visible": false, "var": "rankTop1", "height": 120 }, "compId": 47, "child": [{ "type": "Image", "props": { "y": 35, "x": 0, "visible": false, "var": "main_rankTop1", "skin": "rank/rect1.png", "sizeGrid": "20,20,20,20", "height": 83 }, "compId": 48, "child": [{ "type": "Text", "props": { "y": -18, "x": 35, "text": "查看完整排行榜>>", "fontSize": 15, "font": "SimHei", "color": "#ffffff", "runtime": "laya.display.Text" }, "compId": 49 }] }, { "type": "Box", "props": { "y": 39, "x": 0, "width": 190, "visible": false, "var": "sub_rankTop1", "height": 83 }, "compId": 50, "child": [{ "type": "Image", "props": { "y": 2, "x": 9, "width": 70, "skin": "rank/default.png", "name": "iconHead", "height": 70 }, "compId": 51 }, { "type": "Text", "props": { "y": 0, "x": 83, "wordWrap": true, "width": 99, "text": "虚位以待", "name": "nickName", "height": 53, "fontSize": 16, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 53 }, { "type": "Text", "props": { "y": 54, "x": 83, "width": 96, "text": "得分:0", "name": "txtExp", "height": 22, "fontSize": 15, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 54 }] }] }, { "type": "Box", "props": { "y": 0, "x": 0, "width": 300, "visible": false, "var": "rankTop2", "height": 200 }, "compId": 55, "child": [{ "type": "Image", "props": { "y": 43, "x": 0, "visible": false, "var": "main_rankTop2", "skin": "rank/rect2.png" }, "compId": 56, "child": [{ "type": "Text", "props": { "y": 120, "x": 64, "text": "查看完整排行榜>>", "fontSize": 22, "font": "SimHei", "color": "#000000", "runtime": "laya.display.Text" }, "compId": 57 }] }, { "type": "Box", "props": { "y": 47, "x": -1, "width": 293, "visible": false, "var": "sub_rankTop2", "height": 135 }, "compId": 58, "child": [{ "type": "Image", "props": { "y": 11, "x": 186, "width": 90, "skin": "rank/default.png", "name": "iconHead", "height": 90 }, "compId": 59 }, { "type": "Text", "props": { "y": 39, "x": 13, "wordWrap": true, "width": 163, "text": "虚位以待", "name": "nickName", "height": 48, "fontSize": 20, "font": "Microsoft YaHei", "color": "#000000", "align": "center", "runtime": "laya.display.Text" }, "compId": 60 }, { "type": "Text", "props": { "y": 89, "x": 20, "width": 148, "text": "得分:0", "name": "txtExp", "height": 22, "fontSize": 20, "font": "Microsoft YaHei", "color": "#000000", "align": "center", "runtime": "laya.display.Text" }, "compId": 61 }, { "type": "Text", "props": { "y": 10, "x": 47, "width": 96, "text": "即将超越", "height": 27, "fontSize": 20, "font": "Microsoft YaHei", "color": "#000000", "align": "center", "runtime": "laya.display.Text" }, "compId": 62 }] }] }, { "type": "Box", "props": { "y": 0, "x": 0, "width": 720, "visible": false, "var": "rankEnd1", "height": 1280 }, "compId": 63, "child": [{ "type": "Image", "props": { "width": 580, "visible": false, "var": "main_rankEnd1", "skin": "rank/rect2.png", "sizeGrid": "20,20,20,20", "centerY": 0, "centerX": 0 }, "compId": 64, "child": [{ "type": "Text", "props": { "y": 43, "x": 31, "width": 168, "text": "即将超越", "height": 54, "fontSize": 40, "font": "Microsoft YaHei", "color": "#000000", "align": "center", "runtime": "laya.display.Text" }, "compId": 70 }] }, { "type": "Box", "props": { "width": 575, "visible": false, "var": "sub_rankEnd1", "height": 135, "centerY": 0, "centerX": 0 }, "compId": 66, "child": [{ "type": "Image", "props": { "width": 100, "skin": "rank/default.png", "name": "iconHead", "height": 100, "centerY": 0, "centerX": -22 }, "compId": 67 }, { "type": "Text", "props": { "y": 21, "x": 323, "wordWrap": true, "width": 246, "text": "虚位以待", "name": "nickName", "height": 70, "fontSize": 30, "font": "Microsoft YaHei", "color": "#000000", "align": "center", "runtime": "laya.display.Text" }, "compId": 68 }, { "type": "Text", "props": { "y": 91, "x": 345, "width": 206, "text": "得分:0", "name": "txtExp", "height": 41, "fontSize": 30, "font": "Microsoft YaHei", "color": "#000000", "align": "center", "runtime": "laya.display.Text" }, "compId": 69 }] }] }, { "type": "Box", "props": { "y": 194, "x": 604, "width": 173, "visible": false, "var": "rankRight", "height": 224 }, "compId": 71, "child": [{ "type": "Image", "props": { "y": 2, "x": 170, "visible": false, "var": "bgRankRight1", "skin": "rank/rect3.png", "scaleX": -1 }, "compId": 72, "child": [{ "type": "Image", "props": { "y": 4, "x": 76, "width": 50, "var": "rankRight1", "skin": "rank/default.png", "height": 50 }, "compId": 75 }] }, { "type": "Image", "props": { "y": 81, "x": 190, "visible": false, "var": "bgRankRight2", "skin": "rank/rect3.png", "scaleX": -1 }, "compId": 73, "child": [{ "type": "Image", "props": { "y": 4, "x": 76, "width": 50, "var": "rankRight2", "skin": "rank/default.png", "height": 50 }, "compId": 76 }] }, { "type": "Image", "props": { "y": 159, "x": 190, "visible": false, "var": "bgRankRight3", "skin": "rank/rect3.png", "scaleX": -1 }, "compId": 74, "child": [{ "type": "Image", "props": { "y": 4, "x": 76, "width": 50, "var": "rankRight3", "skin": "rank/default.png", "height": 50 }, "compId": 77 }] }] }, { "type": "Box", "props": { "y": 638, "width": 720, "visible": false, "var": "rankEnd2", "height": 229, "centerX": 0 }, "compId": 79, "child": [{ "type": "Image", "props": { "y": 33, "x": 155, "width": 100, "var": "rankEnd2Head1", "skin": "rank/default.png", "height": 100 }, "compId": 80, "child": [{ "type": "Text", "props": { "y": 107, "x": -51, "width": 206, "text": "虚位以待", "name": "name", "height": 23, "fontSize": 25, "font": "SimHei", "color": "#000000", "align": "center", "runtime": "laya.display.Text" }, "compId": 81 }, { "type": "Text", "props": { "y": 136, "x": -51, "width": 206, "text": "得分:0", "name": "score", "height": 29, "fontSize": 25, "font": "SimHei", "color": "#000000", "align": "center", "runtime": "laya.display.Text" }, "compId": 82 }] }, { "type": "Image", "props": { "y": 33, "x": 311, "width": 100, "var": "rankEnd2Head2", "skin": "rank/default.png", "height": 100 }, "compId": 86, "child": [{ "type": "Text", "props": { "y": 107, "x": -51, "width": 206, "text": "虚位以待", "name": "name", "height": 23, "fontSize": 25, "font": "SimHei", "color": "#000000", "align": "center", "runtime": "laya.display.Text" }, "compId": 87 }, { "type": "Text", "props": { "y": 136, "x": -51, "width": 206, "text": "得分:0", "name": "score", "height": 29, "fontSize": 25, "font": "SimHei", "color": "#000000", "align": "center", "runtime": "laya.display.Text" }, "compId": 88 }] }, { "type": "Image", "props": { "y": 33, "x": 467, "width": 100, "var": "rankEnd2Head3", "skin": "rank/default.png", "height": 100 }, "compId": 83, "child": [{ "type": "Text", "props": { "y": 107, "x": -51, "width": 206, "text": "虚位以待", "name": "name", "height": 23, "fontSize": 25, "font": "SimHei", "color": "#000000", "align": "center", "runtime": "laya.display.Text" }, "compId": 84 }, { "type": "Text", "props": { "y": 136, "x": -51, "width": 206, "text": "得分:0", "name": "score", "height": 29, "fontSize": 25, "font": "SimHei", "color": "#000000", "align": "center", "runtime": "laya.display.Text" }, "compId": 85 }] }] }, { "type": "Box", "props": { "y": 0, "x": 0, "width": 720, "visible": false, "var": "rankList", "mouseThrough": true, "height": 1280 }, "compId": 4, "child": [{ "type": "Image", "props": { "y": 76, "width": 560, "var": "main_rankList", "skin": "rank/bg.png", "height": 810, "centerX": 0 }, "compId": 3, "child": [{ "type": "Image", "props": { "y": 15, "x": 174, "skin": "rank/titleRank.png", "centerX": 0 }, "compId": 35 }, { "type": "Image", "props": { "y": 713, "x": 84, "var": "btnLeft", "skin": "rank/btnLeft.png" }, "compId": 43 }, { "type": "Image", "props": { "y": 713, "x": 380, "var": "btnRight", "skin": "rank/btnRight.png" }, "compId": 44 }, { "type": "Image", "props": { "y": 897, "x": 280, "width": 385, "var": "btnBack", "skin": "rank/button.png", "height": 120, "centerX": 0, "anchorY": 0.5, "anchorX": 0.5 }, "compId": 45, "child": [{ "type": "Image", "props": { "skin": "rank/txtBack.png", "centerY": -12, "centerX": 0 }, "compId": 46 }] }, { "type": "Text", "props": { "y": 213, "x": 93, "text": "一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一", "name": "line", "runtime": "laya.display.Text" }, "compId": 12 }, { "type": "Text", "props": { "y": 325, "x": 93, "text": "一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一", "name": "line", "runtime": "laya.display.Text" }, "compId": 20 }, { "type": "Text", "props": { "y": 438, "x": 93, "text": "一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一", "name": "line", "runtime": "laya.display.Text" }, "compId": 27 }, { "type": "Text", "props": { "y": 550, "x": 93, "text": "一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一一", "name": "line", "runtime": "laya.display.Text" }, "compId": 34 }] }, { "type": "Box", "props": { "y": 205, "x": 95, "width": 530, "var": "sub_rankList", "height": 434 }, "compId": 13, "child": [{ "type": "Box", "props": { "y": -7, "x": 0, "width": 530, "visible": false, "var": "rankCell0", "height": 100 }, "compId": 5, "child": [{ "type": "Image", "props": { "y": 9, "x": 79, "width": 80, "skin": "rank/default.png", "name": "iconHead", "height": 80 }, "compId": 6 }, { "type": "Image", "props": { "y": 30, "x": 28, "visible": true, "skin": "rank/rank1.png", "name": "iconRank" }, "compId": 7 }, { "type": "Text", "props": { "y": 28, "x": 172, "wordWrap": true, "width": 206, "text": "虚位以待", "name": "nickName", "height": 61, "fontSize": 25, "font": "Microsoft YaHei", "color": "#ffffff", "align": "left", "runtime": "laya.display.Text" }, "compId": 8 }, { "type": "Text", "props": { "y": 34, "x": 27, "wordWrap": false, "width": 42, "text": "1", "name": "txtRank", "height": 36, "fontSize": 25, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 9 }, { "type": "Text", "props": { "y": 28, "x": 385, "width": 128, "text": "得分:0", "name": "txtExp", "height": 33, "fontSize": 25, "font": "Microsoft YaHei", "color": "#ffffff", "align": "left", "runtime": "laya.display.Text" }, "compId": 10 }] }, { "type": "Box", "props": { "y": 105, "x": 0, "width": 530, "visible": false, "var": "rankCell1", "height": 100 }, "compId": 14, "child": [{ "type": "Image", "props": { "y": 9, "x": 79, "width": 80, "skin": "rank/default.png", "name": "iconHead", "height": 80 }, "compId": 15 }, { "type": "Image", "props": { "y": 30, "x": 28, "visible": true, "skin": "rank/rank2.png", "name": "iconRank" }, "compId": 16 }, { "type": "Text", "props": { "y": 28, "x": 172, "wordWrap": true, "width": 206, "text": "虚位以待", "name": "nickName", "height": 61, "fontSize": 25, "font": "Microsoft YaHei", "color": "#ffffff", "align": "left", "runtime": "laya.display.Text" }, "compId": 17 }, { "type": "Text", "props": { "y": 34, "x": 27, "wordWrap": false, "width": 42, "text": "2", "name": "txtRank", "height": 36, "fontSize": 25, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 18 }, { "type": "Text", "props": { "y": 28, "x": 385, "width": 128, "text": "得分:0", "name": "txtExp", "height": 33, "fontSize": 25, "font": "Microsoft YaHei", "color": "#ffffff", "align": "left", "runtime": "laya.display.Text" }, "compId": 19 }] }, { "type": "Box", "props": { "y": 218, "x": 0, "width": 530, "visible": false, "var": "rankCell2", "height": 100 }, "compId": 21, "child": [{ "type": "Image", "props": { "y": 9, "x": 79, "width": 80, "skin": "rank/default.png", "name": "iconHead", "height": 80 }, "compId": 22 }, { "type": "Image", "props": { "y": 30, "x": 28, "visible": true, "skin": "rank/rank3.png", "name": "iconRank" }, "compId": 23 }, { "type": "Text", "props": { "y": 28, "x": 172, "wordWrap": true, "width": 206, "text": "虚位以待", "name": "nickName", "height": 61, "fontSize": 25, "font": "Microsoft YaHei", "color": "#ffffff", "align": "left", "runtime": "laya.display.Text" }, "compId": 24 }, { "type": "Text", "props": { "y": 34, "x": 27, "wordWrap": false, "width": 42, "text": "3", "name": "txtRank", "height": 36, "fontSize": 25, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 25 }, { "type": "Text", "props": { "y": 28, "x": 385, "width": 128, "text": "得分:0", "name": "txtExp", "height": 33, "fontSize": 25, "font": "Microsoft YaHei", "color": "#ffffff", "align": "left", "runtime": "laya.display.Text" }, "compId": 26 }] }, { "type": "Box", "props": { "y": 330, "x": 0, "width": 530, "visible": false, "var": "rankCell3", "height": 100 }, "compId": 28, "child": [{ "type": "Image", "props": { "y": 9, "x": 79, "width": 80, "skin": "rank/default.png", "name": "iconHead", "height": 80 }, "compId": 29 }, { "type": "Image", "props": { "y": 30, "x": 28, "visible": false, "skin": "rank/rank1.png", "name": "iconRank" }, "compId": 30 }, { "type": "Text", "props": { "y": 28, "x": 172, "wordWrap": true, "width": 206, "text": "虚位以待", "name": "nickName", "height": 61, "fontSize": 25, "font": "Microsoft YaHei", "color": "#ffffff", "align": "left", "runtime": "laya.display.Text" }, "compId": 31 }, { "type": "Text", "props": { "y": 34, "x": 27, "wordWrap": false, "width": 42, "text": "4", "name": "txtRank", "height": 36, "fontSize": 25, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 32 }, { "type": "Text", "props": { "y": 28, "x": 385, "width": 128, "text": "得分:0", "name": "txtExp", "height": 33, "fontSize": 25, "font": "Microsoft YaHei", "color": "#ffffff", "align": "left", "runtime": "laya.display.Text" }, "compId": 33 }] }, { "type": "Box", "props": { "y": 463, "x": 0, "width": 530, "visible": false, "var": "rankSelf", "height": 100 }, "compId": 36, "child": [{ "type": "Image", "props": { "y": 9, "x": 79, "width": 80, "skin": "rank/default.png", "name": "iconHead", "height": 80 }, "compId": 37 }, { "type": "Image", "props": { "y": 30, "x": 28, "visible": false, "skin": "rank/rank1.png", "name": "iconRank" }, "compId": 38 }, { "type": "Text", "props": { "y": 28, "x": 172, "wordWrap": true, "width": 206, "text": "虚位以待", "name": "nickName", "height": 61, "fontSize": 25, "font": "Microsoft YaHei", "color": "#ffffff", "align": "left", "runtime": "laya.display.Text" }, "compId": 39 }, { "type": "Text", "props": { "y": 34, "x": 27, "wordWrap": false, "width": 42, "text": "4", "name": "txtRank", "height": 36, "fontSize": 25, "font": "Microsoft YaHei", "color": "#ffffff", "align": "center", "runtime": "laya.display.Text" }, "compId": 40 }, { "type": "Text", "props": { "y": 28, "x": 385, "width": 128, "text": "得分:0", "name": "txtExp", "height": 33, "fontSize": 25, "font": "Microsoft YaHei", "color": "#ffffff", "align": "left", "runtime": "laya.display.Text" }, "compId": 41 }] }] }] }] }], "loadList": ["rank/rect1.png", "rank/default.png", "rank/rect2.png", "rank/rect3.png", "rank/bg.png", "rank/titleRank.png", "rank/btnLeft.png", "rank/btnRight.png", "rank/button.png", "rank/txtBack.png", "rank/rank1.png", "rank/rank2.png", "rank/rank3.png"], "loadList3D": [] };
  2500. ui.RankUI = RankUI;
  2501. REG("ui.RankUI", RankUI);
  2502. class SunUI extends Laya.View {
  2503. constructor() {
  2504. super();
  2505. }
  2506. createChildren() {
  2507. super.createChildren();
  2508. this.createView(SunUI.uiView);
  2509. }
  2510. }
  2511. SunUI.uiView = { "type": "View", "props": { "width": 720, "height": 1280 }, "compId": 2, "child": [{ "type": "Box", "props": { "y": 411, "x": 360, "width": 350, "var": "sunNode", "pivotY": 175, "pivotX": 175, "name": "sunNode", "height": 350 }, "compId": 50, "child": [{ "type": "Box", "props": { "y": 175, "x": 175, "width": 350, "var": "sunAndKnifeNode", "pivotY": 175, "pivotX": 175, "name": "sunAndKnifeNode", "height": 350 }, "compId": 7, "child": [{ "type": "Sprite", "props": { "y": -90, "x": -90, "visible": false, "var": "sunShine", "texture": "texture/Sun/sunShine1.png", "name": "sunShine" }, "compId": 38 }, { "type": "Sprite", "props": { "y": -12, "x": -12, "texture": "texture/Sun/outerGrowOfSun.png", "name": "sunShineRing" }, "compId": 40 }, { "type": "Sprite", "props": { "y": 175, "x": 175, "width": 350, "var": "treeNode", "texture": "texture/Sun/sunBG_normal.png", "pivotY": 175, "pivotX": 175, "name": "treeNode", "height": 350 }, "compId": 27, "child": [{ "type": "Sprite", "props": { "y": 266, "x": 175, "width": 56, "visible": false, "texture": "texture/GameScene/obstacle.png", "pivotX": 28, "height": 111 }, "compId": 34 }] }, { "type": "Sprite", "props": { "y": 175, "x": 175, "width": 350, "var": "knifeNode", "texture": "texture/Sun/sunBG_normal.png", "pivotY": 175, "pivotX": 175, "name": "knifeNode", "height": 350 }, "compId": 3, "child": [{ "type": "Sprite", "props": { "y": 192, "x": 323, "visible": false, "texture": "texture/GameScene/rocket.png", "rotation": -83, "pivotX": 28 }, "compId": 81 }] }, { "type": "Sprite", "props": { "y": 174, "x": 174, "width": 445, "var": "sunBG", "texture": "texture/Sun/sunBG_normal.png", "pivotY": 194, "pivotX": 223, "name": "sunBG", "height": 387 }, "compId": 53 }, { "type": "Sprite", "props": { "y": 152.5, "x": 331.5, "width": 37, "visible": false, "texture": "texture/MainScene/btn_add.png", "name": "angle0Sign", "height": 45 }, "compId": 86 }] }, { "type": "Sprite", "props": { "y": 175, "x": 175, "var": "sunEmoji", "texture": "texture/Sun/biaoqing_kuqi.png", "pivotY": 175, "pivotX": 175, "name": "sunEmoji" }, "compId": 6 }, { "type": "Box", "props": { "y": 175, "x": 175, "width": 350, "var": "RiftNode", "pivotY": 175, "pivotX": 175, "name": "RiftNode", "height": 350 }, "compId": 55, "child": [{ "type": "Sprite", "props": { "y": 350, "x": 175, "width": 43, "visible": false, "texture": "texture/Effect/SunRift/Rift01_01.png", "rotation": 0, "pivotY": 114, "pivotX": 21.5, "height": 114 }, "compId": 56 }] }, { "type": "Sprite", "props": { "y": 330, "x": 175, "width": 56, "visible": false, "texture": "texture/GameScene/obstacle.png", "pivotX": 28, "height": 111 }, "compId": 82 }, { "type": "Text", "props": { "y": 41, "x": 109, "width": 132, "visible": false, "var": "text_sunRotation", "text": "999", "strokeColor": "#ffffff", "stroke": 3, "name": "text_sunRotation", "height": 48, "fontSize": 48, "color": "#ff0400", "align": "center", "runtime": "laya.display.Text" }, "compId": 84 }] }, { "type": "Box", "props": { "y": 0, "x": 0, "width": 720, "var": "planetOuterRingNode", "height": 1280 }, "compId": 51, "child": [{ "type": "Sprite", "props": { "y": 411, "x": 360, "width": 878, "var": "planetOuterRing", "texture": "texture/GameScene/outRing.png", "pivotY": 439, "pivotX": 439, "name": "planetOuterRing", "height": 878 }, "compId": 36 }] }, { "type": "Box", "props": { "y": 0, "x": 0, "width": 720, "var": "planetInnerRingNode", "height": 1280 }, "compId": 52, "child": [{ "type": "Sprite", "props": { "y": 411, "x": 360, "width": 588, "var": "planetInnerRing", "texture": "texture/GameScene/innerRing.png", "pivotY": 294, "pivotX": 294, "name": "planetInnerRing", "height": 588 }, "compId": 35 }] }, { "type": "Sprite", "props": { "y": 690, "x": 424, "width": 174, "visible": false, "texture": "texture/Planet/Jupiter.png", "rotation": 0, "pivotY": 88, "pivotX": 87, "height": 175 }, "compId": 48, "child": [{ "type": "Sprite", "props": { "y": 140, "x": 118, "width": 14, "visible": false, "texture": "texture/Effect/PlanetRift/Rift01.png", "rotation": -24, "pivotY": 43, "pivotX": 7, "height": 43 }, "compId": 60 }] }, { "type": "Sprite", "props": { "y": 400, "x": 360, "width": 328, "visible": false, "texture": "texture/Effect/ringEffect/add_blood.png", "pivotY": 164, "pivotX": 164, "height": 328 }, "compId": 63 }, { "type": "Box", "props": { "y": 411, "x": 360, "width": 405, "var": "shieldNode", "pivotY": 202, "pivotX": 203, "name": "shieldNode", "height": 403 }, "compId": 64 }, { "type": "Box", "props": { "width": 720, "var": "UINode", "name": "UINode", "height": 1280 }, "compId": 67, "child": [{ "type": "Panel", "props": { "y": 411, "x": 360, "width": 275, "var": "critNode", "pivotY": 110, "pivotX": 138, "name": "critNode", "height": 220 }, "compId": 80, "child": [{ "type": "Sprite", "props": { "y": 110, "x": 107, "width": 214, "var": "critBG", "texture": "texture/Effect/Crit/CritFire.png", "pivotY": 110, "pivotX": 107, "height": 220 }, "compId": 70 }, { "type": "Panel", "props": { "y": 60, "x": 0, "width": 128, "var": "critTextPanel", "height": 100 }, "compId": 73, "child": [{ "type": "Sprite", "props": { "y": 50, "x": 0, "width": 128, "texture": "texture/Effect/Crit/CritText.png", "pivotY": 28, "height": 56 }, "compId": 71 }] }, { "type": "Panel", "props": { "y": 60, "x": 128, "var": "critNumPanel", "name": "critNumPanel" }, "compId": 77, "child": [{ "type": "FontClip", "props": { "y": 8, "x": 0, "var": "critNum", "skin": "texture/Effect/Crit/clip_num_crit.png", "sheet": "0123456789", "name": "critNum" }, "compId": 79 }] }, { "type": "Panel", "props": { "y": 60, "x": 200, "width": 79, "var": "hpPanel" }, "compId": 74, "child": [{ "type": "Sprite", "props": { "y": 50, "x": 0, "width": 79, "texture": "texture/Effect/Crit/hp.png", "pivotY": 33, "height": 65 }, "compId": 76 }] }] }, { "type": "Box", "props": { "y": 411, "x": 0, "var": "normalNumBox", "pivotY": 42, "name": "normalNumBox", "height": 83 }, "compId": 89, "child": [{ "type": "FontClip", "props": { "x": 360, "visible": false, "var": "normalNum", "value": "0123", "skin": "texture/Effect/Crit/clip_num_crit.png", "sheet": "0123456789", "name": "normalNum", "height": 83 }, "compId": 94, "child": [{ "type": "Panel", "props": { "y": -8, "x": -60, "left": -60, "height": 83 }, "compId": 93, "child": [{ "type": "Sprite", "props": { "y": 0, "x": 0, "width": 44, "texture": "texture/Effect/Crit/symbol.png", "height": 83 }, "compId": 90 }] }, { "type": "Sprite", "props": { "y": 13.5, "x": -10, "visible": false, "texture": "texture/Effect/Crit/CritText.png" }, "compId": 98 }] }] }] }], "loadList": ["texture/Sun/sunShine1.png", "texture/Sun/outerGrowOfSun.png", "texture/Sun/sunBG_normal.png", "texture/GameScene/obstacle.png", "texture/GameScene/rocket.png", "texture/MainScene/btn_add.png", "texture/Sun/biaoqing_kuqi.png", "texture/Effect/SunRift/Rift01_01.png", "texture/GameScene/outRing.png", "texture/GameScene/innerRing.png", "texture/Planet/Jupiter.png", "texture/Effect/PlanetRift/Rift01.png", "texture/Effect/ringEffect/add_blood.png", "texture/Effect/Crit/CritFire.png", "texture/Effect/Crit/CritText.png", "texture/Effect/Crit/clip_num_crit.png", "texture/Effect/Crit/hp.png", "texture/Effect/Crit/symbol.png"], "loadList3D": [] };
  2512. ui.SunUI = SunUI;
  2513. REG("ui.SunUI", SunUI);
  2514. })(ui || (ui = {}));
  2515. class AnimationControl {
  2516. constructor() {
  2517. }
  2518. static playAnimation(aniConfPath, parent, posX, posY, interval, isLoop, pivotX, pivotY, callback, callbackDelay) {
  2519. let ani = Laya.Pool.getItemByClass("EffectAnimation", Laya.Animation);
  2520. parent.addChild(ani);
  2521. ani.loadAtlas(aniConfPath);
  2522. ani.interval = interval;
  2523. ani.index = 1;
  2524. ani.play(0, isLoop);
  2525. ani.pivot(pivotX, pivotY);
  2526. ani.pos(posX, posY);
  2527. ani.scaleX = 2;
  2528. ani.scaleY = 2;
  2529. if (!isLoop) {
  2530. let fun = function () {
  2531. ani.removeSelf();
  2532. Laya.Pool.recover("EffectAnimation", ani);
  2533. if (callback) {
  2534. if (callbackDelay) {
  2535. Laya.timer.once(callbackDelay, this, callback);
  2536. }
  2537. else {
  2538. callback();
  2539. }
  2540. }
  2541. ani.off(Laya.Event.COMPLETE, this, fun);
  2542. };
  2543. ani.on(Laya.Event.COMPLETE, this, fun);
  2544. }
  2545. return ani;
  2546. }
  2547. static playFingerAni() {
  2548. let aniPath = "res/atlas/texture/Effect/Finger.atlas";
  2549. let pivotX = 0;
  2550. let pivotY = 0;
  2551. let posX = 0;
  2552. let posY = 0;
  2553. return AnimationControl.playAnimation(aniPath, Laya.stage, posX, posY, 150, true, pivotX, pivotY);
  2554. }
  2555. static sunLiquidAni(knife, parent, posX, posY) {
  2556. let aniPath = "";
  2557. let num = 0;
  2558. let pivotX = 0;
  2559. let pivotY = 0;
  2560. if (knife.isInvincible == false) {
  2561. num = MainScene.gameControl.smallLiquiCount % 3 + 1;
  2562. MainScene.gameControl.smallLiquiCount += 1;
  2563. aniPath = "res/atlas/texture/Effect/SunLiquidSmall0" + num + ".atlas";
  2564. switch (num) {
  2565. case 1:
  2566. pivotX = 145;
  2567. pivotY = 142;
  2568. break;
  2569. case 2:
  2570. pivotX = 110;
  2571. pivotY = 80;
  2572. break;
  2573. case 3:
  2574. pivotX = 63;
  2575. pivotY = 90;
  2576. break;
  2577. default:
  2578. break;
  2579. }
  2580. }
  2581. else {
  2582. num = MainScene.gameControl.bigLiquiCount % 3 + 1;
  2583. MainScene.gameControl.bigLiquiCount += 1;
  2584. aniPath = "res/atlas/texture/Effect/SunLiquidBig0" + num + ".atlas";
  2585. switch (num) {
  2586. case 1:
  2587. pivotX = 185;
  2588. pivotY = 127;
  2589. break;
  2590. case 2:
  2591. pivotX = 190;
  2592. pivotY = 122;
  2593. break;
  2594. case 3:
  2595. pivotX = 182;
  2596. pivotY = 137;
  2597. break;
  2598. default:
  2599. break;
  2600. }
  2601. }
  2602. return AnimationControl.playAnimation(aniPath, parent, posX, posY, 30, false, pivotX, pivotY, null);
  2603. }
  2604. static sunDieAni(callback, callbackDelay) {
  2605. let aniPath = "res/atlas/texture/Effect/SunDieFlame.atlas";
  2606. let pivotX = 360 / 2;
  2607. let pivotY = 330 / 2;
  2608. let posX = MainScene.sun.sunNode.x;
  2609. let posY = MainScene.sun.sunNode.y;
  2610. return AnimationControl.playAnimation(aniPath, MainScene.sun, posX, posY, 30, false, pivotX, pivotY, callback, callbackDelay);
  2611. }
  2612. static reviveFireAni(callback, callbackDelay) {
  2613. let aniPath = "res/atlas/texture/Effect/ReviveFire.atlas";
  2614. let pivotX = 230 / 2;
  2615. let pivotY = 230 / 2;
  2616. let posX = MainScene.sun.sunNode.x;
  2617. let posY = MainScene.sun.sunNode.y;
  2618. return AnimationControl.playAnimation(aniPath, MainScene.sun, posX, posY, 90, false, pivotX, pivotY, callback, callbackDelay);
  2619. }
  2620. static knifeFireAni(knife) {
  2621. let aniPath = "res/atlas/texture/Effect/RocketFire.atlas";
  2622. let posX = knife.width / 2 - 5;
  2623. let posY = knife.height - 8;
  2624. let ani = new Laya.Animation();
  2625. ani.visible = true;
  2626. ani.loadAtlas(aniPath);
  2627. ani.interval = 30;
  2628. ani.index = 1;
  2629. ani.play(0, true);
  2630. ani.pivot(47 / 2, 0);
  2631. ani.pos(posX, posY);
  2632. knife.addChild(ani);
  2633. return ani;
  2634. }
  2635. static planetDieExplode(planet, completeEvent) {
  2636. let aniPath = "res/atlas/texture/Effect/PlanetExplode.atlas";
  2637. let pivotX = 115 / 2;
  2638. let pivotY = 105 / 2;
  2639. let posX = planet.planetImg.x;
  2640. let posY = planet.planetImg.y;
  2641. Laya.Tween.to(planet.planetImg, { scaleX: 1.3, scaleY: 1.3, alpha: 0 }, 300);
  2642. return AnimationControl.playAnimation(aniPath, planet.planetNode, posX, posY, 50, false, pivotX, pivotY, completeEvent);
  2643. }
  2644. static planetFireball(planet, aniConfPath) {
  2645. let pivotX = 120 / 2;
  2646. let pivotY = 310;
  2647. let posX = 0;
  2648. let posY = 0;
  2649. let innerPos = new Laya.Point(MainScene.sun.planetInnerRing.x, MainScene.sun.planetInnerRing.y + MainScene.sun.planetInnerRing.height / 2);
  2650. innerPos = MainScene.sun.planetInnerRingNode.localToGlobal(innerPos);
  2651. let outerPos = new Laya.Point(MainScene.sun.planetOuterRing.x, MainScene.sun.planetOuterRing.y + MainScene.sun.planetOuterRing.height / 2);
  2652. outerPos = MainScene.sun.planetOuterRingNode.localToGlobal(outerPos);
  2653. if (planet.orbit == 0) {
  2654. posX = innerPos.x;
  2655. posY = innerPos.y;
  2656. }
  2657. else if (planet.orbit == 1) {
  2658. posX = outerPos.x;
  2659. posY = outerPos.y;
  2660. }
  2661. let ani = AnimationControl.playAnimation(aniConfPath, Laya.stage, posX, posY, 30, false, pivotX, pivotY, null);
  2662. if (planet.orbit == 0) {
  2663. ani.scaleX = 1.5;
  2664. ani.scaleY = 1.5;
  2665. }
  2666. else if (planet.orbit == 1) {
  2667. ani.scaleX = 2;
  2668. ani.scaleY = 2;
  2669. }
  2670. ani.rotation = 0;
  2671. }
  2672. static blowUpObstacle(parent, fun) {
  2673. let aniPath = "res/atlas/texture/Effect/Planet_Mars/BlowUpRocket.atlas";
  2674. let posX = parent.width / 2;
  2675. let posY = parent.height - 10;
  2676. let pivotX = 90 / 2;
  2677. let pivotY = 90 / 2;
  2678. let ani = AnimationControl.playAnimation(aniPath, parent, posX, posY, 50, false, pivotX, pivotY, fun);
  2679. }
  2680. static planet_Jupiter_addTree(parent) {
  2681. let aniConfPath = "res/atlas/texture/Effect/Planet_Jupiter.atlas";
  2682. let posX = parent.width / 2;
  2683. let posY = parent.height + 50;
  2684. let pivotX = 105 / 2;
  2685. let pivotY = 190 / 2;
  2686. let ani = AnimationControl.playAnimation(aniConfPath, parent, posX, posY, 30, false, pivotX, pivotY, null);
  2687. ani.scaleY = -2;
  2688. }
  2689. static knifeABumpedObjB(ObjB, objBType, finishEvent) {
  2690. let redTwinklePath = "";
  2691. switch (objBType) {
  2692. case 0:
  2693. redTwinklePath = "texture/GameScene/redTwinkle.png";
  2694. break;
  2695. case 1:
  2696. redTwinklePath = "texture/GameScene/redTwinkle_propRocket.png";
  2697. break;
  2698. case 2:
  2699. redTwinklePath = "texture/GameScene/redTwinkle_tree.png";
  2700. break;
  2701. default:
  2702. break;
  2703. }
  2704. let sp_redTwinkle = new Laya.Sprite();
  2705. sp_redTwinkle.loadImage(redTwinklePath);
  2706. ObjB.addChild(sp_redTwinkle);
  2707. sp_redTwinkle.pivot(sp_redTwinkle.width / 2, sp_redTwinkle.height / 2);
  2708. sp_redTwinkle.pos(ObjB.width / 2, ObjB.height / 2);
  2709. let count = 0;
  2710. let fun = function () {
  2711. if (count < 6) {
  2712. if (count % 2 == 0) {
  2713. sp_redTwinkle.visible = false;
  2714. }
  2715. else {
  2716. sp_redTwinkle.visible = true;
  2717. }
  2718. count += 1;
  2719. }
  2720. else {
  2721. if (finishEvent)
  2722. finishEvent();
  2723. Laya.timer.clear(this, fun);
  2724. sp_redTwinkle.removeSelf;
  2725. sp_redTwinkle.destroy();
  2726. }
  2727. };
  2728. Laya.timer.loop(80, this, fun);
  2729. }
  2730. static screenShake(shakeValue, tag) {
  2731. let screen = MainScene.instance.SceneBox;
  2732. screen.pivot(screen.width / 2, screen.height / 2);
  2733. screen.pos(Laya.stage.width / 2, Laya.stage.height / 2);
  2734. let pos1 = [Laya.stage.width / 2, Laya.stage.height / 2];
  2735. let random1 = this.getRandomPos([3 * shakeValue, 8 * shakeValue], [10 * shakeValue, 20 * shakeValue]);
  2736. let random2 = [-random1[0], -random1[1]];
  2737. Laya.Tween.to(screen, { x: pos1[0] + random1[0], y: pos1[1] + random1[1] }, 50, null, Laya.Handler.create(this, function () {
  2738. Laya.Tween.to(screen, { x: pos1[0] + random2[0], y: pos1[1] + random2[1] }, 50, null, Laya.Handler.create(this, function () {
  2739. Laya.Tween.to(screen, { x: pos1[0], y: pos1[1] }, 50);
  2740. }));
  2741. }));
  2742. if (shakeValue > 1 && tag != 1) {
  2743. let newTag = 1;
  2744. Laya.timer.once(200, this, function () {
  2745. this.screenShake(shakeValue, newTag);
  2746. });
  2747. }
  2748. }
  2749. static getRandomPos(xRange, yRange) {
  2750. let xMin = xRange[0];
  2751. let xMax = xRange[1];
  2752. let randomX = Math.random() * (xMax - xMin) + xMin;
  2753. let randomXCoefficient = Math.round(Math.random()) * 2 - 1;
  2754. let yMin = xRange[0];
  2755. let yMax = xRange[1];
  2756. let randomY = Math.random() * (yMax - yMin) + yMin;
  2757. let randomYCoefficient = Math.round(Math.random()) * 2 - 1;
  2758. let randomPos = [randomX * randomXCoefficient, randomY * randomYCoefficient];
  2759. return randomPos;
  2760. }
  2761. static playAddBloodNumAni(addNum) {
  2762. let instance = MainScene.instance;
  2763. let addBloodText = instance.text_addBloodNum;
  2764. addBloodText.text = "+" + addNum;
  2765. let point = new Laya.Point(instance.iconHeart.x + instance.iconHeart.width / 2, instance.iconHeart.y + instance.iconHeart.height / 2);
  2766. let protoPos = instance.iconHeart.localToGlobal(point);
  2767. let parent = addBloodText.parent;
  2768. protoPos = instance.gameUI.globalToLocal(protoPos);
  2769. let protoY = protoPos.y;
  2770. addBloodText.pos(protoPos.x, protoPos.y);
  2771. addBloodText.alpha = 0;
  2772. addBloodText.scale(0.7, 0.7);
  2773. addBloodText.y = protoY + 20;
  2774. Laya.Tween.to(addBloodText, { alpha: 1, scaleX: 1, scaleY: 1, y: protoPos.y }, 650, Laya.Ease.linearIn, Laya.Handler.create(this, function () {
  2775. Laya.Tween.to(addBloodText, { alpha: 0, y: protoPos.y - 20 }, 350);
  2776. }));
  2777. }
  2778. static btnClickAni(btn) {
  2779. btn.scale(0.8, 0.8);
  2780. Laya.Tween.to(btn, { scaleX: 1, scaleY: 1 }, 600, Laya.Ease.backOut);
  2781. }
  2782. static startGameBtnAni() {
  2783. MainScene.instance.btn_startGame.visible = false;
  2784. let startBtnSP = MainScene.instance.startBtnSP;
  2785. let strengthSP = MainScene.instance.strengthSPUnderStartGame;
  2786. let posTP = [MainScene.instance.btn_startGame.x, MainScene.instance.btn_startGame.y];
  2787. let posSP = new Laya.Point(MainScene.instance.icon_strength.width / 2, MainScene.instance.icon_strength.height / 2);
  2788. posSP = MainScene.instance.icon_strength.localToGlobal(posSP);
  2789. posSP = MainScene.instance.homeUI.globalToLocal(posSP);
  2790. startBtnSP.pivot(startBtnSP.width / 2, startBtnSP.height / 2);
  2791. startBtnSP.pos(posTP[0], posTP[1]);
  2792. startBtnSP.scale(1, 1);
  2793. startBtnSP.visible = true;
  2794. startBtnSP.alpha = 1;
  2795. Laya.Tween.to(startBtnSP, { scaleX: 0, scaleY: 0 }, 500);
  2796. MainScene.gameControl.updateHomeUI();
  2797. AnimationControl.homeUIMoveOut();
  2798. }
  2799. static homeUIMoveOut() {
  2800. let instance = MainScene.instance;
  2801. let moveDist = 1000;
  2802. let moveTime = 500;
  2803. Laya.Tween.to(instance.topUI, { y: -moveDist }, moveTime);
  2804. Laya.Tween.to(instance.bottomUI, { y: moveDist }, moveTime);
  2805. Laya.Tween.to(instance.leftUI, { x: -moveDist }, moveTime);
  2806. Laya.Tween.to(instance.rightUI, { x: moveDist }, moveTime);
  2807. }
  2808. static gameUIMoveIn(callback) {
  2809. let instance = MainScene.instance;
  2810. instance.gameUI.visible = true;
  2811. let moveDist = 1000;
  2812. let moveTime = 800;
  2813. instance.gameLeftUI.x = -moveDist;
  2814. instance.gameRightUI.x = moveDist;
  2815. instance.gameTopUI.y = -moveDist;
  2816. let aaa = Laya.Tween.to(instance.gameTopUI, { y: 0 }, moveTime, Laya.Ease.linearNone, Laya.Handler.create(this, function (res) {
  2817. if (callback) {
  2818. callback();
  2819. }
  2820. }));
  2821. Laya.Tween.to(instance.gameLeftUI, { x: 0 }, moveTime);
  2822. Laya.Tween.to(instance.gameRightUI, { x: 0 }, moveTime);
  2823. }
  2824. static playIconPlusAni(planet, imgPath) {
  2825. let startPoint = new Laya.Point(planet.iconPlanetSkill.x, planet.iconPlanetSkill.y);
  2826. let coinsNumRange = [5, 7];
  2827. let coinsNum = Math.floor(Math.random() * (coinsNumRange[1] - coinsNumRange[0])) + coinsNumRange[0];
  2828. let MP = [0, 0];
  2829. MP[0] = Math.random() * MP[0] + startPoint.x;
  2830. MP[1] = Math.random() * MP[1] + startPoint.y;
  2831. for (let i = 0; i < coinsNum; i++) {
  2832. let effect = new EffectImg();
  2833. effect.SP = [startPoint.x, startPoint.y];
  2834. effect.MP = [MP[0], MP[1]];
  2835. effect.showPlanetIconAni(imgPath, planet);
  2836. }
  2837. }
  2838. static playCoinsFlyAni(startPoint, targetPoint) {
  2839. let imgPath = "texture/MainScene/TAB/icon_Coin.png";
  2840. let coinsNumRange = [15, 25];
  2841. let coinsNum = Math.floor(Math.random() * (coinsNumRange[1] - coinsNumRange[0])) + coinsNumRange[0];
  2842. for (let i = 0; i < coinsNum; i++) {
  2843. let effect = new EffectImg();
  2844. effect.size(62, 62);
  2845. let MP = [500, 500];
  2846. MP[0] = Math.random() * MP[0] + startPoint.x;
  2847. MP[1] = Math.random() * MP[1] + startPoint.y;
  2848. effect.SP = [startPoint.x, startPoint.y];
  2849. effect.MP = [MP[0], MP[1]];
  2850. effect.TP = [targetPoint.x, targetPoint.y];
  2851. effect.showSpreadToGatherAni(imgPath);
  2852. }
  2853. }
  2854. static playStrengthFlyAni(startPoint, targetPoint) {
  2855. let imgPath = "texture/MainScene/TAB/icon_strength.png";
  2856. let coinsNum = 5;
  2857. for (let i = 0; i < coinsNum; i++) {
  2858. let effect = new EffectImg();
  2859. effect.size(87 * 0.8, 101 * 0.8);
  2860. let MP = [0, 0];
  2861. MP[0] = Math.random() * MP[0] + startPoint.x;
  2862. MP[1] = Math.random() * MP[1] + startPoint.y;
  2863. effect.SP = [startPoint.x, startPoint.y];
  2864. effect.MP = [MP[0], MP[1]];
  2865. effect.TP = [targetPoint.x, targetPoint.y];
  2866. effect.speed = 0.013;
  2867. effect.showSpreadToGatherAni(imgPath);
  2868. }
  2869. }
  2870. static playCritNumAni(hpNum, parent, pos, scale) {
  2871. let sp_critFire = Laya.Pool.getItemByClass("sp_critFire", Laya.Sprite);
  2872. sp_critFire.loadImage("texture/Effect/Crit/CritFire.png");
  2873. let sp_critSymbol = Laya.Pool.getItemByClass("sp_critSymbol", Laya.Sprite);
  2874. sp_critSymbol.loadImage("texture/Effect/Crit/CritText.png");
  2875. let clip_num_crit = Laya.Pool.getItemByClass("clip_num_crit", Laya.FontClip);
  2876. clip_num_crit.skin = "texture/Effect/Crit/clip_num_crit.png";
  2877. clip_num_crit.sheet = "0123456789";
  2878. clip_num_crit.value = hpNum;
  2879. sp_critFire.scale(scale, scale);
  2880. let sp_hp = Laya.Pool.getItemByClass("sp_hp", Laya.Sprite);
  2881. sp_hp.loadImage("texture/Effect/Crit/hp.png");
  2882. Laya.timer.once(100, this, function () {
  2883. clip_num_crit.pivot(clip_num_crit.width / 2, clip_num_crit.height / 2);
  2884. clip_num_crit.addChild(sp_critSymbol);
  2885. sp_critSymbol.x = -sp_critSymbol.width;
  2886. parent.addChild(sp_critFire);
  2887. sp_critFire.pivot(sp_critFire.width / 2, sp_critFire.height / 2);
  2888. sp_critFire.pos(pos[0] + 30, pos[1] + 50);
  2889. sp_critFire.addChild(clip_num_crit);
  2890. clip_num_crit.pos(sp_critFire.width / 2, sp_critFire.height / 2);
  2891. clip_num_crit.addChild(sp_hp);
  2892. sp_hp.x = clip_num_crit.width;
  2893. sp_critFire.alpha = 0;
  2894. Laya.Tween.to(sp_critFire, { y: pos[1], alpha: 1 }, 150, Laya.Ease.linearIn, Laya.Handler.create(this, function () {
  2895. Laya.timer.once(500, this, function () {
  2896. Laya.Tween.to(sp_critFire, { alpha: 0 }, 100);
  2897. });
  2898. Laya.Tween.to(sp_critFire, { y: pos[1] - 50 }, 600, null, Laya.Handler.create(this, function () {
  2899. sp_critSymbol.removeSelf();
  2900. Laya.Pool.recover("sp_symbol", sp_critSymbol);
  2901. clip_num_crit.removeSelf();
  2902. Laya.Pool.recover("clip_num_crit", clip_num_crit);
  2903. sp_critFire.removeSelf();
  2904. Laya.Pool.recover("sp_critFire", sp_critFire);
  2905. sp_hp.removeSelf();
  2906. Laya.Pool.recover("sp_hp", sp_hp);
  2907. }));
  2908. }));
  2909. });
  2910. }
  2911. static playSubBloodNumAni(hpNum, parent, pos, scale) {
  2912. let sp_symbol = Laya.Pool.getItemByClass("sp_symbol", Laya.Sprite);
  2913. sp_symbol.loadImage("texture/Effect/Crit/symbol.png");
  2914. let clip_num_normal = Laya.Pool.getItemByClass("clip_num_normal", Laya.FontClip);
  2915. clip_num_normal.skin = "texture/Effect/Crit/clip_num_crit.png";
  2916. clip_num_normal.sheet = "0123456789";
  2917. clip_num_normal.value = hpNum;
  2918. clip_num_normal.scale(scale, scale);
  2919. Laya.timer.once(100, this, function () {
  2920. clip_num_normal.pivotX = clip_num_normal.width / 2;
  2921. clip_num_normal.addChild(sp_symbol);
  2922. sp_symbol.x = -sp_symbol.width;
  2923. parent.addChild(clip_num_normal);
  2924. clip_num_normal.pos(pos[0], pos[1] + 50);
  2925. clip_num_normal.alpha = 0;
  2926. Laya.Tween.to(clip_num_normal, { y: pos[1], alpha: 1 }, 150, Laya.Ease.linearIn, Laya.Handler.create(this, function () {
  2927. Laya.timer.once(500, this, function () {
  2928. Laya.Tween.to(clip_num_normal, { alpha: 0 }, 100);
  2929. });
  2930. Laya.Tween.to(clip_num_normal, { y: pos[1] - 50 }, 600, null, Laya.Handler.create(this, function () {
  2931. sp_symbol.removeSelf();
  2932. Laya.Pool.recover("sp_symbol", sp_symbol);
  2933. clip_num_normal.removeSelf();
  2934. Laya.Pool.recover("clip_num_normal", clip_num_normal);
  2935. }));
  2936. }));
  2937. });
  2938. }
  2939. static playJump(posX, posY) {
  2940. let aniPath = "res/atlas/texture/aniJump.atlas";
  2941. let pivotX = 0;
  2942. let pivotY = 0;
  2943. return AnimationControl.playAnimation(aniPath, Laya.stage, posX, posY, 40, true, pivotX, pivotY);
  2944. }
  2945. }
  2946. class EffectImg extends Laya.Sprite {
  2947. constructor() {
  2948. super(...arguments);
  2949. this.t = 0;
  2950. this.curP = [0, 0];
  2951. this.SP = [0, 0];
  2952. this.MP = [0, 0];
  2953. this.TP = [0, 0];
  2954. this.tRandom = 0;
  2955. this.speed = 0.01;
  2956. }
  2957. showPlanetIconAni(imgPath, planet) {
  2958. let texture = Laya.loader.getRes(imgPath);
  2959. this.texture = texture;
  2960. this.planet = planet;
  2961. this.planet.addChild(this);
  2962. this.pos(this.SP[0], this.SP[1]);
  2963. this.zOrder += 200;
  2964. this.scaleX = 1;
  2965. this.scaleY = 1;
  2966. this.curP = [this.SP[0], this.SP[1]];
  2967. this.tRandom = Math.random() * 0.01;
  2968. Laya.timer.frameLoop(1, this, this.timer_planetIconAni);
  2969. }
  2970. timer_planetIconAni() {
  2971. let targetPoint = new Laya.Point(MainScene.sun.sunNode.x, MainScene.sun.sunNode.y);
  2972. targetPoint = MainScene.sun.localToGlobal(targetPoint);
  2973. targetPoint = this.planet.globalToLocal(targetPoint);
  2974. let TP = [targetPoint.x, targetPoint.y];
  2975. if (this.t + 0.01 > 1) {
  2976. this.removeSelf();
  2977. this.destroy();
  2978. Laya.timer.clear(this, this.timer_planetIconAni);
  2979. return;
  2980. }
  2981. ;
  2982. this.t += (0.013 + this.tRandom);
  2983. this.scaleX = 1 - this.t / 3;
  2984. this.scaleY = 1 - this.t / 3;
  2985. this.alpha = Math.ceil(1 - this.t);
  2986. this.curP[0] = Math.pow((1 - this.t), 2) * this.SP[0] + 2 * this.t * (1 - this.t) * this.MP[0] + Math.pow(this.t, 2) * TP[0];
  2987. this.curP[1] = Math.pow((1 - this.t), 2) * this.SP[1] + 2 * this.t * (1 - this.t) * this.MP[1] + Math.pow(this.t, 2) * TP[1];
  2988. this.pos(this.curP[0], this.curP[1]);
  2989. }
  2990. showSpreadToGatherAni(imgPath) {
  2991. let texture = Laya.loader.getRes(imgPath);
  2992. this.texture = texture;
  2993. Laya.stage.addChild(this);
  2994. this.pos(this.SP[0], this.SP[1]);
  2995. this.zOrder += 200;
  2996. this.scaleX = 1;
  2997. this.scaleY = 1;
  2998. this.curP = [this.SP[0], this.SP[1]];
  2999. this.tRandom = Math.random() * 0.01;
  3000. Laya.timer.frameLoop(1, this, this.timer_SpreadToGather);
  3001. }
  3002. timer_SpreadToGather() {
  3003. if (this.t + 0.01 > 1) {
  3004. this.removeSelf();
  3005. this.destroy();
  3006. Laya.timer.clear(this, this.timer_SpreadToGather);
  3007. return;
  3008. }
  3009. ;
  3010. this.t += (this.speed + this.tRandom);
  3011. if (this.t >= 0.5) {
  3012. this.scaleX -= 0.01;
  3013. this.scaleY -= 0.01;
  3014. }
  3015. this.curP[0] = Math.pow((1 - this.t), 2) * this.SP[0] + 2 * this.t * (1 - this.t) * this.MP[0] + Math.pow(this.t, 2) * this.TP[0];
  3016. this.curP[1] = Math.pow((1 - this.t), 2) * this.SP[1] + 2 * this.t * (1 - this.t) * this.MP[1] + Math.pow(this.t, 2) * this.TP[1];
  3017. this.pos(this.curP[0], this.curP[1]);
  3018. }
  3019. }
  3020. class MathTool {
  3021. static currencyUnit(num) {
  3022. if (num != 0 && !num)
  3023. return "num_null";
  3024. let currency = num.toString();
  3025. let length = currency.length;
  3026. if (length <= 3) {
  3027. return currency;
  3028. }
  3029. let units = ['', 'k', 'm', 'b', 't'];
  3030. let letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
  3031. 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
  3032. for (let i = 0; i < 4; i++) {
  3033. if (i < 3) {
  3034. for (let j = 0; j < letters.length; j++) {
  3035. units.push(letters[i] + letters[j]);
  3036. }
  3037. }
  3038. else {
  3039. for (let j = 0; j < 13; j++) {
  3040. units.push(letters[i] + letters[j]);
  3041. }
  3042. }
  3043. }
  3044. let times = Math.floor((length - 1) / 3);
  3045. let remainder = length % 3;
  3046. remainder = remainder == 0 ? 3 : remainder;
  3047. let unit = '';
  3048. for (let i = 0; i < remainder; i++) {
  3049. unit += currency[i];
  3050. }
  3051. unit += '.';
  3052. unit += currency[remainder];
  3053. unit += currency[remainder + 1];
  3054. unit += units[times];
  3055. return unit;
  3056. }
  3057. static shuffle(arr) {
  3058. let m = arr.length;
  3059. while (m > 1) {
  3060. let index = Math.floor(Math.random() * m--);
  3061. [arr[m], arr[index]] = [arr[index], arr[m]];
  3062. }
  3063. return arr;
  3064. }
  3065. static secendToHour(timeNum) {
  3066. let hour = Math.floor(timeNum / 3600);
  3067. let minute = Math.floor((timeNum - hour * 3600) / 60);
  3068. let second = Math.floor(timeNum % 60);
  3069. let str_hour = (hour >= 10) ? (hour + "") : (hour > 0 ? ("0" + hour) : "00");
  3070. let str_minute = (minute >= 10) ? (minute + "") : (minute > 0 ? ("0" + minute) : "00");
  3071. let str_second = (second >= 10) ? (second + "") : (second > 0 ? ("0" + second) : "00");
  3072. let str = str_hour + ":" + str_minute + ":" + str_second;
  3073. return str;
  3074. }
  3075. static angleBePositive(angle) {
  3076. let aangle = angle % 360;
  3077. if (aangle < 0) {
  3078. aangle += 360;
  3079. }
  3080. return aangle;
  3081. }
  3082. static checkAngleIsInRange(angle, range) {
  3083. let min = range[0];
  3084. let max = range[1];
  3085. if (min > max) {
  3086. max += 360;
  3087. }
  3088. if (angle >= min && angle <= max) {
  3089. return true;
  3090. }
  3091. else {
  3092. return false;
  3093. }
  3094. }
  3095. }
  3096. class GameOverPage extends ui.Dialogs.Dialog_GameOverUI {
  3097. constructor() {
  3098. super();
  3099. this.isSuccessful = false;
  3100. this.stayTime = 1300;
  3101. this.init();
  3102. }
  3103. init() {
  3104. this.btn_threeTimesReceiving.on(Laya.Event.MOUSE_DOWN, this, this.onThreeTimesReceivingClick);
  3105. this.btn_revive.on(Laya.Event.MOUSE_DOWN, this, this.onReviveClick);
  3106. this.btn_giveUp.on(Laya.Event.MOUSE_DOWN, this, this.onGiveUpClick);
  3107. let ahitArea = new Laya.HitArea();
  3108. let agraphics = new Laya.Graphics();
  3109. agraphics.drawRect(-10, -10, this.btn_giveUp.width + 20, this.btn_giveUp.height + 20, "#ff9900");
  3110. ahitArea.hit = agraphics;
  3111. this.btn_giveUp.hitArea = ahitArea;
  3112. }
  3113. show_failedRevive() {
  3114. this.defeatTopUI.visible = true;
  3115. this.defeat_hasReviveChanceUI.visible = true;
  3116. this.receiveCoinUI.visible = false;
  3117. this.victoryTopUI.visible = false;
  3118. this.refreshPage();
  3119. this.isSuccessful = false;
  3120. this.btn_giveUp.visible = false;
  3121. Laya.timer.once(3000, this, function () {
  3122. this.btn_giveUp.visible = true;
  3123. });
  3124. }
  3125. show_failedRePlay() {
  3126. this.defeatTopUI.visible = true;
  3127. this.defeat_hasReviveChanceUI.visible = false;
  3128. this.receiveCoinUI.visible = true;
  3129. this.victoryTopUI.visible = false;
  3130. this.refreshPage();
  3131. this.isSuccessful = false;
  3132. MainScene.instance.updateGameState(4);
  3133. Laya.timer.once(this.stayTime, this, this.onReceiveRightNowClick);
  3134. }
  3135. show_success() {
  3136. this.defeatTopUI.visible = false;
  3137. this.defeat_hasReviveChanceUI.visible = false;
  3138. this.receiveCoinUI.visible = true;
  3139. this.victoryTopUI.visible = true;
  3140. this.refreshPage();
  3141. this.isSuccessful = true;
  3142. MainScene.instance.updateGameState(4);
  3143. Laya.timer.once(this.stayTime, this, this.onReceiveRightNowClick);
  3144. }
  3145. refreshPage() {
  3146. let coinStr = MathTool.currencyUnit(MainScene.gameControl.coinNumFromCurLevel);
  3147. this.btn_receiveRightNow.label = coinStr;
  3148. this.text_coinNumFromCurLevel.text = coinStr;
  3149. let bloodStr = MathTool.currencyUnit(MainScene.sun.curBlood);
  3150. this.text_bloodNum.text = bloodStr;
  3151. this.text_levelNum.text = MainScene.gameControl.curLevel + "";
  3152. this.text_levelNum.pivotX = this.text_levelNum.width / 2;
  3153. this.text_levelNum.x = 360;
  3154. this.levelNum_left.x = -(this.text_levelNum.pivotX + 10);
  3155. this.levelNum_right.x = this.text_levelNum.width + 10;
  3156. this.bloodBarMask.x = -(this.bloodBarMask.width * (1 - MainScene.sun.curBlood / MainScene.sun.totalBlood));
  3157. MainScene.gameControl.updateGameUI();
  3158. this.show();
  3159. }
  3160. onReceiveRightNowClick() {
  3161. Func.sharePointCount("threeTimesReceiveLevelCoins-close", 101);
  3162. MainScene.gameControl.addCoins(MainScene.gameControl.coinNumFromCurLevel);
  3163. if (this.isSuccessful) {
  3164. MainScene.gameControl.recoverEnergies(5, 1);
  3165. }
  3166. this.gameover();
  3167. let startPoint = new Laya.Point(this.btn_receiveRightNow.width / 2, this.btn_receiveRightNow.height / 2);
  3168. startPoint = this.btn_receiveRightNow.localToGlobal(startPoint);
  3169. let iconCoin = MainScene.instance.icon_coin_homeLeftTop;
  3170. let targetPoint = new Laya.Point(iconCoin.width / 2 + 1000, iconCoin.height / 2);
  3171. targetPoint = iconCoin.localToGlobal(targetPoint);
  3172. targetPoint.x = 42;
  3173. AnimationControl.playCoinsFlyAni(startPoint, targetPoint);
  3174. }
  3175. onThreeTimesReceivingClick() {
  3176. Func.sharePoint("threeTimesReceiveLevelCoins", false, this.onShare_threeTimesReceiving);
  3177. Func.sharePointCount("threeTimesReceiveLevelCoins-open", 101);
  3178. }
  3179. onShare_threeTimesReceiving() {
  3180. MainScene.gameControl.addCoins(MainScene.gameControl.coinNumFromCurLevel * 3);
  3181. let self = MainScene.instance.gameOverUI;
  3182. if (self.isSuccessful) {
  3183. MainScene.gameControl.recoverEnergies(5, 1);
  3184. }
  3185. self.gameover();
  3186. let startPoint = new Laya.Point(Laya.stage.width / 2, Laya.stage.height / 2);
  3187. let iconCoin = MainScene.instance.icon_coin_homeLeftTop;
  3188. let targetPoint = new Laya.Point(iconCoin.width / 2 + 1000, iconCoin.height / 2);
  3189. targetPoint = iconCoin.localToGlobal(targetPoint);
  3190. targetPoint.x = 42;
  3191. AnimationControl.playCoinsFlyAni(startPoint, targetPoint);
  3192. }
  3193. onReviveClick() {
  3194. Func.sharePoint("revive", false, this.onShare_revive);
  3195. Func.sharePointCount("revive-open", 101);
  3196. BannerAd.hideBannerAd();
  3197. }
  3198. onShare_revive() {
  3199. MainScene.instance.gameOverUI.close();
  3200. MainScene.gameControl.revive();
  3201. MainScene.instance.updateGameState(2);
  3202. }
  3203. onGiveUpClick() {
  3204. Func.sharePointCount("revive-close", 101);
  3205. this.show_failedRePlay();
  3206. BannerAd.hideBannerAd();
  3207. }
  3208. gameover() {
  3209. if (MainScene.gameControl.getMaxLevel() > 1) {
  3210. MainScene.gameControl.levelOver();
  3211. MainScene.sun.sunIdle();
  3212. MainScene.gameControl.levelStartInGame();
  3213. }
  3214. else {
  3215. MainScene.instance.returnHome();
  3216. }
  3217. this.close();
  3218. }
  3219. }
  3220. class SkeletonControl {
  3221. constructor() {
  3222. }
  3223. static initTemplet() {
  3224. SkeletonControl.templet_addBlood = new Laya.Templet();
  3225. SkeletonControl.templet_addBlood.loadAni("dragonBone/addBlood/add_blood.sk");
  3226. SkeletonControl.templet_addBlood.on(Laya.Event.ERROR, this, this.onError);
  3227. SkeletonControl.templet_sheild = new Laya.Templet();
  3228. SkeletonControl.templet_sheild.loadAni("dragonBone/shield/hudun.sk");
  3229. SkeletonControl.templet_sheild.on(Laya.Event.ERROR, this, this.onError);
  3230. }
  3231. static onError() {
  3232. console.log("parse error");
  3233. }
  3234. static playAddBloodAni() {
  3235. let sk;
  3236. sk = Laya.Pool.getItemByCreateFun("dbsk_add_blood", function () {
  3237. return this.templet_addBlood.buildArmature(0);
  3238. }, this);
  3239. sk.pos(MainScene.sun.minSunPoint.x, MainScene.sun.minSunPoint.y - MainScene.sun.sunNode.height);
  3240. sk.scale(2, 2);
  3241. sk.showSkinByIndex(1);
  3242. sk.play(0, true);
  3243. MainScene.instance.effectBox.addChild(sk);
  3244. let fun = function () {
  3245. sk.removeSelf();
  3246. Laya.Pool.recover("dbsk_add_blood", sk);
  3247. sk.off(Laya.Event.STOPPED, sk, fun);
  3248. };
  3249. Laya.timer.once(1500, this, fun);
  3250. }
  3251. static playAddShieldAni(planet) {
  3252. if (!MainScene.gameControl.isStartGame)
  3253. return;
  3254. let sP = planet.localToGlobal(new Laya.Point(0, 0));
  3255. let mP = [MainScene.sun.minSunPoint.x, MainScene.sun.minSunPoint.y - MainScene.sun.sunNode.height / 2];
  3256. let sk = Laya.Pool.getItemByCreateFun("hudun", function () {
  3257. return this.templet_sheild.buildArmature(0);
  3258. }, this);
  3259. sk.alpha = 1;
  3260. sk.pos(sP.x, sP.y);
  3261. sk.scale(2, 2);
  3262. sk.showSkinByIndex(1);
  3263. sk.play(SkeletonControl.shieldAniName.greenlight, false);
  3264. Laya.stage.addChild(sk);
  3265. Laya.Tween.to(sk, { x: mP[0], y: mP[1] }, 300, null, Laya.Handler.create(this, function () {
  3266. if (!MainScene.gameControl.isStartGame) {
  3267. SkeletonControl.clearSheildAni();
  3268. }
  3269. ;
  3270. sk.removeSelf();
  3271. MainScene.sun.shieldNode.addChild(sk);
  3272. sk.pos(MainScene.sun.shieldNode.width / 2, MainScene.sun.shieldNode.height / 2);
  3273. let fun = function () {
  3274. if (!MainScene.gameControl.isStartGame) {
  3275. SkeletonControl.clearSheildAni();
  3276. }
  3277. ;
  3278. if (SkeletonControl.shieldSK) {
  3279. sk.off(Laya.Event.STOPPED, sk, fun);
  3280. Laya.Pool.recover("hudun", sk);
  3281. }
  3282. else {
  3283. SkeletonControl.shieldSK = sk;
  3284. sk.off(Laya.Event.STOPPED, sk, fun);
  3285. let fun2 = function () {
  3286. if (!MainScene.gameControl.isStartGame) {
  3287. SkeletonControl.clearSheildAni();
  3288. }
  3289. ;
  3290. sk.off(Laya.Event.STOPPED, sk, fun2);
  3291. sk.play(SkeletonControl.shieldAniName.hudun, true, true, 400, 2100);
  3292. };
  3293. sk.on(Laya.Event.STOPPED, sk, fun2);
  3294. sk.play(SkeletonControl.shieldAniName.hudun, false);
  3295. }
  3296. };
  3297. sk.on(Laya.Event.STOPPED, sk, fun);
  3298. sk.play(SkeletonControl.shieldAniName.greenlight_expand, false);
  3299. }));
  3300. }
  3301. static clearSheildAni() {
  3302. let sk = this.shieldSK;
  3303. if (!sk)
  3304. return;
  3305. Laya.Tween.to(sk, { alpha: 0 }, 300, null, Laya.Handler.create(this, function () {
  3306. sk.removeSelf();
  3307. Laya.Pool.recover("hudun", sk);
  3308. this.shieldSK = null;
  3309. }));
  3310. }
  3311. static playSubBloodAni(callback) {
  3312. let sk;
  3313. sk = Laya.Pool.getItemByCreateFun("hudun", function () {
  3314. return this.templet_sheild.buildArmature(0);
  3315. }, this);
  3316. sk.alpha = 1;
  3317. sk.pos(MainScene.sun.minSunPoint.x, MainScene.sun.minSunPoint.y - MainScene.sun.sunNode.height / 2);
  3318. sk.scale(2, 2);
  3319. sk.showSkinByIndex(1);
  3320. sk.play(SkeletonControl.shieldAniName.red_light, false);
  3321. Laya.stage.addChild(sk);
  3322. let fun = function () {
  3323. if (callback)
  3324. callback();
  3325. sk.removeSelf();
  3326. Laya.Pool.recover("hudun", sk);
  3327. sk.off(Laya.Event.STOPPED, sk, fun);
  3328. };
  3329. sk.on(Laya.Event.STOPPED, sk, fun);
  3330. }
  3331. }
  3332. SkeletonControl.shieldAniName = {
  3333. "greenlight": "1_greenlight",
  3334. "greenlight_expand": "2_greenlight_expand",
  3335. "hudun": "3_hudun",
  3336. "red_light": "red_light"
  3337. };
  3338. class FreelyGetPropPage extends ui.Dialogs.Dialog_FreelyGetPropUI {
  3339. constructor() {
  3340. super();
  3341. this.freelyChance = {
  3342. "rocketChance": 4,
  3343. "slowDownChance": 4,
  3344. "subBloodChance": 4
  3345. };
  3346. this.btn_freeRevive.on(Laya.Event.MOUSE_DOWN, this, this.onClick_btn_freeRevive);
  3347. this.btn_nextTime.on(Laya.Event.MOUSE_DOWN, this, this.onClick_btn_nextTime);
  3348. }
  3349. init() {
  3350. this.freelyChance.rocketChance = 4;
  3351. this.freelyChance.slowDownChance = 4;
  3352. this.freelyChance.subBloodChance = 4;
  3353. }
  3354. onClick_btn_freeRevive() {
  3355. let gameControl = MainScene.gameControl;
  3356. switch (this.propType) {
  3357. case 0:
  3358. Func.sharePoint("freeProp", false, this.onShare_addProp_rocket);
  3359. Func.sharePointCount("freeProp-open", 101);
  3360. break;
  3361. case 1:
  3362. Func.sharePoint("freeProp", false, this.onShare_addProp_slowDown);
  3363. Func.sharePointCount("freeProp-open", 101);
  3364. break;
  3365. case 2:
  3366. Func.sharePoint("freeProp", false, this.onShare_addProp_subBlood);
  3367. Func.sharePointCount("freeProp-open", 101);
  3368. break;
  3369. default:
  3370. break;
  3371. }
  3372. this.close();
  3373. }
  3374. onShare_addProp_rocket() {
  3375. MainScene.instance.dialog_freelyGetProp.freelyChance.rocketChance -= 1;
  3376. MainScene.gameControl.usingProp_rocket();
  3377. MusicControl.useProp();
  3378. }
  3379. onShare_addProp_slowDown() {
  3380. MainScene.instance.dialog_freelyGetProp.freelyChance.slowDownChance -= 1;
  3381. MainScene.gameControl.usingProp_slowDown();
  3382. MusicControl.useProp();
  3383. }
  3384. onShare_addProp_subBlood() {
  3385. MainScene.instance.dialog_freelyGetProp.freelyChance.subBloodChance -= 1;
  3386. SkeletonControl.playSubBloodAni(MainScene.gameControl.usingProp_subBlood);
  3387. MusicControl.useProp();
  3388. }
  3389. onClick_btn_nextTime() {
  3390. this.close();
  3391. Func.sharePointCount("freeProp-close", 101);
  3392. }
  3393. showDialog(propType) {
  3394. this.setPropType(propType);
  3395. this.btn_nextTime.visible = false;
  3396. Laya.timer.once(2000, this, this.hideBtnNextTime);
  3397. super.show();
  3398. }
  3399. hideBtnNextTime() {
  3400. this.btn_nextTime.visible = true;
  3401. }
  3402. close() {
  3403. Laya.timer.clear(this, this.hideBtnNextTime);
  3404. super.close();
  3405. }
  3406. setPropType(propType) {
  3407. this.propType = propType;
  3408. switch (propType) {
  3409. case 0:
  3410. this.text_propName.text = "火箭";
  3411. this.icon_prop.loadImage("texture/Dialog_GetProp/rocket.png");
  3412. this.btn_freeRevive.label = this.freelyChance.rocketChance + "/4";
  3413. this.text_propInfo.text = "可获得5个无撞击的无敌箭矢";
  3414. break;
  3415. case 1:
  3416. this.text_propName.text = "减速";
  3417. this.icon_prop.loadImage("texture/Dialog_GetProp/slowDown.png");
  3418. this.btn_freeRevive.label = this.freelyChance.slowDownChance + "/4";
  3419. this.text_propInfo.text = "降低病毒的转动速度";
  3420. break;
  3421. case 2:
  3422. this.text_propName.text = "减血";
  3423. this.icon_prop.loadImage("texture/Dialog_GetProp/subBlood.png");
  3424. this.btn_freeRevive.label = this.freelyChance.subBloodChance + "/4";
  3425. this.text_propInfo.text = "可使病毒的血量减半";
  3426. break;
  3427. default:
  3428. break;
  3429. }
  3430. }
  3431. }
  3432. class RANK_TYPE {
  3433. }
  3434. RANK_TYPE.LIST = "rankList";
  3435. RANK_TYPE.TOP1 = "rankTop1";
  3436. RANK_TYPE.TOP2 = "rankTop2";
  3437. RANK_TYPE.END1 = "rankEnd1";
  3438. RANK_TYPE.END2 = "rankEnd2";
  3439. RANK_TYPE.RIGHT = "rankRight";
  3440. class MyWXOpenContro extends Laya.WXOpenDataViewer {
  3441. constructor() {
  3442. super();
  3443. this.is_refresh = false;
  3444. this.refresh_rate = 0;
  3445. this.sharedCanvas = null;
  3446. this.fresh_Loop = function () {
  3447. if (this.is_refresh == true) {
  3448. this.texture.bitmap.loadImageSource(this.sharedCanvas);
  3449. }
  3450. };
  3451. this.fresh_one = function () {
  3452. if (window['wx'] && this.sharedCanvas) {
  3453. Laya.timer.once(1000, this, () => {
  3454. this.texture.bitmap.loadImageSource(this.sharedCanvas);
  3455. });
  3456. }
  3457. };
  3458. }
  3459. onEnable() {
  3460. let wx = window['wx'];
  3461. if (wx) {
  3462. this.sharedCanvas = wx.getOpenDataContext().canvas;
  3463. if (this.sharedCanvas) {
  3464. this.sharedCanvas.width = Consts.width;
  3465. this.sharedCanvas.height = Consts.height;
  3466. Laya.timer.frameLoop(5, this, this.fresh_Loop);
  3467. }
  3468. }
  3469. }
  3470. onDisable() {
  3471. }
  3472. }
  3473. class RankDlg extends ui.RankUI {
  3474. constructor() {
  3475. super();
  3476. this.sharedTexture = null;
  3477. this.frameIndex = 0;
  3478. this.showRanks = {};
  3479. this.wxOpenDataViewer = null;
  3480. this.platformBoxUI = null;
  3481. this.is_show_list = false;
  3482. RankDlg.thiz = this;
  3483. this.btnBack.on(Laya.Event.CLICK, this, () => {
  3484. console.log("返回点击事件");
  3485. this.rankList.visible = false;
  3486. this.is_show_list = false;
  3487. RankDlg.list_mask.visible = false;
  3488. RankDlg.hide(RANK_TYPE.LIST);
  3489. });
  3490. this.btnLeft.on(Laya.Event.CLICK, this, () => {
  3491. let wx = window["wx"];
  3492. if (wx != null) {
  3493. RankDlg.thiz.wxOpenDataViewer.postMsg({ cmd: "left" });
  3494. }
  3495. });
  3496. this.btnRight.on(Laya.Event.CLICK, this, () => {
  3497. let wx = window["wx"];
  3498. if (wx != null) {
  3499. RankDlg.thiz.wxOpenDataViewer.postMsg({ cmd: "right" });
  3500. }
  3501. });
  3502. this.rankTop1.on(Laya.Event.CLICK, this, () => {
  3503. RankDlg.show(RANK_TYPE.LIST);
  3504. });
  3505. this.rankTop2.on(Laya.Event.CLICK, this, () => {
  3506. RankDlg.show(RANK_TYPE.LIST);
  3507. });
  3508. this.rankRight.on(Laya.Event.CLICK, this, () => {
  3509. RankDlg.show(RANK_TYPE.LIST);
  3510. });
  3511. }
  3512. isUpdate() {
  3513. for (let key in this.showRanks) {
  3514. if (this.showRanks[key]) {
  3515. return true;
  3516. }
  3517. }
  3518. return false;
  3519. }
  3520. static init(layer) {
  3521. if (RankDlg.thiz == null) {
  3522. this.init_mask(layer);
  3523. let dlg = new RankDlg();
  3524. dlg.zOrder = 0;
  3525. layer.addChild(dlg);
  3526. RankDlg.thiz.platformBoxUI = layer;
  3527. if (RankDlg.thiz.wxOpenDataViewer == null) {
  3528. RankDlg.thiz.wxOpenDataViewer = new MyWXOpenContro();
  3529. RankDlg.thiz.wxOpenDataViewer.width = Consts.width;
  3530. RankDlg.thiz.wxOpenDataViewer.height = Consts.height;
  3531. RankDlg.thiz.wxOpenDataViewer.x = 0;
  3532. RankDlg.thiz.wxOpenDataViewer.y = 0;
  3533. RankDlg.thiz.wxOpenDataViewer.mouseEnabled = false;
  3534. RankDlg.thiz.wxOpenDataViewer.mouseThrough = true;
  3535. RankDlg.thiz.wxOpenDataViewer.zOrder = 999;
  3536. RankDlg.thiz.platformBoxUI.addChild(RankDlg.thiz.wxOpenDataViewer);
  3537. RankDlg.thiz.wxOpenDataViewer.is_refresh = false;
  3538. }
  3539. }
  3540. }
  3541. static init_mask(layer) {
  3542. this.list_mask = new Laya.Image();
  3543. this.list_mask.size(1600, 1600);
  3544. this.list_mask.anchorX = 0.5;
  3545. this.list_mask.anchorY = 0.5;
  3546. this.list_mask.skin = "UI/mask.png";
  3547. this.list_mask.pos(Consts.width / 2, Consts.height / 2);
  3548. layer.addChild(this.list_mask);
  3549. this.list_mask.visible = false;
  3550. }
  3551. func(type) {
  3552. this.showRanks[type] = true;
  3553. Laya.timer.once(3000, this, () => {
  3554. if (type == RANK_TYPE.LIST) {
  3555. if (this.rankList.visible) {
  3556. this.showRanks[type] = true;
  3557. }
  3558. else {
  3559. this.showRanks[type] = false;
  3560. }
  3561. }
  3562. else {
  3563. this.showRanks[type] = false;
  3564. }
  3565. });
  3566. }
  3567. static show(type, score) {
  3568. WXContro.setRankData(Data.getMaxScore());
  3569. let wx = window["wx"];
  3570. if (wx == null)
  3571. return;
  3572. RankDlg.thiz.platformBoxUI.visible = true;
  3573. RankDlg.thiz.wxOpenDataViewer.postMsg({ cmd: "show", type: type, curScore: score === undefined ? Data.getMaxScore() : score, openid: LibData.getOpenid() });
  3574. if (type == RANK_TYPE.LIST) {
  3575. this.thiz[type].visible = true;
  3576. this.thiz.mouseThrough = false;
  3577. this.thiz.showRanks[type] = true;
  3578. this.thiz.is_show_list = true;
  3579. this.list_mask.visible = true;
  3580. }
  3581. else if (type == RANK_TYPE.TOP1) {
  3582. this.thiz[type].visible = true;
  3583. this.thiz.func(type);
  3584. if (!this.thiz.is_show_list) {
  3585. this.list_mask.visible = false;
  3586. }
  3587. }
  3588. else if (type == RANK_TYPE.TOP2) {
  3589. this.thiz[type].visible = true;
  3590. this.thiz.func(type);
  3591. if (!this.thiz.is_show_list) {
  3592. this.list_mask.visible = false;
  3593. }
  3594. }
  3595. else if (type == RANK_TYPE.END1) {
  3596. this.thiz.func(type);
  3597. }
  3598. else if (type == RANK_TYPE.END2) {
  3599. this.thiz.func(type);
  3600. this.list_mask.visible = false;
  3601. }
  3602. else if (type == RANK_TYPE.RIGHT) {
  3603. this.thiz[type].visible = true;
  3604. this.list_mask.visible = false;
  3605. this.thiz.func(type);
  3606. }
  3607. Laya.timer.clear(this, this.show_schedule_callback);
  3608. Laya.timer.clear(this, this.hide_schedule_callback);
  3609. RankDlg.thiz.wxOpenDataViewer.is_refresh = true;
  3610. if (type == RANK_TYPE.TOP2 || type == RANK_TYPE.TOP1) {
  3611. RankDlg.thiz.wxOpenDataViewer.is_refresh = false;
  3612. RankDlg.thiz.wxOpenDataViewer.fresh_one();
  3613. }
  3614. else {
  3615. Laya.timer.once(1500, this, this.show_schedule_callback);
  3616. }
  3617. }
  3618. static hide(type) {
  3619. let wx = window["wx"];
  3620. if (wx != null) {
  3621. this.list_mask.visible = false;
  3622. Laya.timer.clear(this, this.show_schedule_callback);
  3623. Laya.timer.clear(this, this.hide_schedule_callback);
  3624. RankDlg.thiz.wxOpenDataViewer.is_refresh = true;
  3625. Laya.timer.once(1500, this, this.hide_schedule_callback);
  3626. RankDlg.thiz.wxOpenDataViewer.postMsg({ cmd: "hide", type: type });
  3627. if (type == RANK_TYPE.LIST) {
  3628. this.thiz.mouseThrough = true;
  3629. }
  3630. this.thiz[type].visible = false;
  3631. this.thiz.func(type);
  3632. }
  3633. }
  3634. static show_schedule_callback() {
  3635. if (this.thiz.is_show_list == false) {
  3636. RankDlg.thiz.wxOpenDataViewer.is_refresh = false;
  3637. }
  3638. else {
  3639. RankDlg.thiz.wxOpenDataViewer.is_refresh = true;
  3640. }
  3641. }
  3642. static hide_schedule_callback() {
  3643. RankDlg.thiz.wxOpenDataViewer.is_refresh = false;
  3644. }
  3645. }
  3646. RankDlg.thiz = null;
  3647. RankDlg.list_mask = null;
  3648. class Task {
  3649. static init() {
  3650. var wx = window["wx"];
  3651. if (wx) {
  3652. var onShow = (res) => {
  3653. console.log("task start");
  3654. if (res.scene == 1037 && res.query.in == Consts.appId && !this.started) {
  3655. this.started = true;
  3656. this.query = res.query;
  3657. }
  3658. if (this.started) {
  3659. this.startTime = Date.now();
  3660. Laya.timer.clearAll(this);
  3661. Laya.timer.once(Math.max(res.query.time * 1000 - this.lastTime, 0), this, () => {
  3662. this.completed = true;
  3663. this.complete();
  3664. });
  3665. }
  3666. };
  3667. onShow(wx.getLaunchOptionsSync());
  3668. wx.onShow(onShow);
  3669. wx.onHide((res) => {
  3670. if (this.completed) {
  3671. return;
  3672. }
  3673. if (this.started) {
  3674. Laya.timer.clearAll(this);
  3675. this.lastTime += Date.now() - this.startTime;
  3676. }
  3677. });
  3678. }
  3679. }
  3680. static complete() {
  3681. let t = Date.now();
  3682. let url = Consts.host + '/task?action=complete'
  3683. + '&name=' + this.query.appName + '&id=' + this.query.openid + '&t=' + t
  3684. + "&appid=" + this.query.in
  3685. + '&s=' + md5('&ytDuy1-c&,19_' + t + 'complete' + this.query.appName + this.query.openid);
  3686. new Laya.HttpRequest().send(url);
  3687. }
  3688. }
  3689. Task.lastTime = 0;
  3690. Task.startTime = 0;
  3691. Task.started = false;
  3692. Task.completed = false;
  3693. function safe_add(x, y) {
  3694. var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  3695. var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  3696. return (msw << 16) | (lsw & 0xFFFF);
  3697. }
  3698. function rol(num, cnt) {
  3699. return (num << cnt) | (num >>> (32 - cnt));
  3700. }
  3701. function cmn(q, a, b, x, s, t) {
  3702. return safe_add(rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b);
  3703. }
  3704. function ff(a, b, c, d, x, s, t) {
  3705. return cmn((b & c) | ((~b) & d), a, b, x, s, t);
  3706. }
  3707. function gg(a, b, c, d, x, s, t) {
  3708. return cmn((b & d) | (c & (~d)), a, b, x, s, t);
  3709. }
  3710. function hh(a, b, c, d, x, s, t) {
  3711. return cmn(b ^ c ^ d, a, b, x, s, t);
  3712. }
  3713. function ii(a, b, c, d, x, s, t) {
  3714. return cmn(c ^ (b | (~d)), a, b, x, s, t);
  3715. }
  3716. function coreMD5(x) {
  3717. var a = 1732584193;
  3718. var b = -271733879;
  3719. var c = -1732584194;
  3720. var d = 271733878;
  3721. for (var i = 0; i < x.length; i += 16) {
  3722. var olda = a;
  3723. var oldb = b;
  3724. var oldc = c;
  3725. var oldd = d;
  3726. a = ff(a, b, c, d, x[i + 0], 7, -680876936);
  3727. d = ff(d, a, b, c, x[i + 1], 12, -389564586);
  3728. c = ff(c, d, a, b, x[i + 2], 17, 606105819);
  3729. b = ff(b, c, d, a, x[i + 3], 22, -1044525330);
  3730. a = ff(a, b, c, d, x[i + 4], 7, -176418897);
  3731. d = ff(d, a, b, c, x[i + 5], 12, 1200080426);
  3732. c = ff(c, d, a, b, x[i + 6], 17, -1473231341);
  3733. b = ff(b, c, d, a, x[i + 7], 22, -45705983);
  3734. a = ff(a, b, c, d, x[i + 8], 7, 1770035416);
  3735. d = ff(d, a, b, c, x[i + 9], 12, -1958414417);
  3736. c = ff(c, d, a, b, x[i + 10], 17, -42063);
  3737. b = ff(b, c, d, a, x[i + 11], 22, -1990404162);
  3738. a = ff(a, b, c, d, x[i + 12], 7, 1804603682);
  3739. d = ff(d, a, b, c, x[i + 13], 12, -40341101);
  3740. c = ff(c, d, a, b, x[i + 14], 17, -1502002290);
  3741. b = ff(b, c, d, a, x[i + 15], 22, 1236535329);
  3742. a = gg(a, b, c, d, x[i + 1], 5, -165796510);
  3743. d = gg(d, a, b, c, x[i + 6], 9, -1069501632);
  3744. c = gg(c, d, a, b, x[i + 11], 14, 643717713);
  3745. b = gg(b, c, d, a, x[i + 0], 20, -373897302);
  3746. a = gg(a, b, c, d, x[i + 5], 5, -701558691);
  3747. d = gg(d, a, b, c, x[i + 10], 9, 38016083);
  3748. c = gg(c, d, a, b, x[i + 15], 14, -660478335);
  3749. b = gg(b, c, d, a, x[i + 4], 20, -405537848);
  3750. a = gg(a, b, c, d, x[i + 9], 5, 568446438);
  3751. d = gg(d, a, b, c, x[i + 14], 9, -1019803690);
  3752. c = gg(c, d, a, b, x[i + 3], 14, -187363961);
  3753. b = gg(b, c, d, a, x[i + 8], 20, 1163531501);
  3754. a = gg(a, b, c, d, x[i + 13], 5, -1444681467);
  3755. d = gg(d, a, b, c, x[i + 2], 9, -51403784);
  3756. c = gg(c, d, a, b, x[i + 7], 14, 1735328473);
  3757. b = gg(b, c, d, a, x[i + 12], 20, -1926607734);
  3758. a = hh(a, b, c, d, x[i + 5], 4, -378558);
  3759. d = hh(d, a, b, c, x[i + 8], 11, -2022574463);
  3760. c = hh(c, d, a, b, x[i + 11], 16, 1839030562);
  3761. b = hh(b, c, d, a, x[i + 14], 23, -35309556);
  3762. a = hh(a, b, c, d, x[i + 1], 4, -1530992060);
  3763. d = hh(d, a, b, c, x[i + 4], 11, 1272893353);
  3764. c = hh(c, d, a, b, x[i + 7], 16, -155497632);
  3765. b = hh(b, c, d, a, x[i + 10], 23, -1094730640);
  3766. a = hh(a, b, c, d, x[i + 13], 4, 681279174);
  3767. d = hh(d, a, b, c, x[i + 0], 11, -358537222);
  3768. c = hh(c, d, a, b, x[i + 3], 16, -722521979);
  3769. b = hh(b, c, d, a, x[i + 6], 23, 76029189);
  3770. a = hh(a, b, c, d, x[i + 9], 4, -640364487);
  3771. d = hh(d, a, b, c, x[i + 12], 11, -421815835);
  3772. c = hh(c, d, a, b, x[i + 15], 16, 530742520);
  3773. b = hh(b, c, d, a, x[i + 2], 23, -995338651);
  3774. a = ii(a, b, c, d, x[i + 0], 6, -198630844);
  3775. d = ii(d, a, b, c, x[i + 7], 10, 1126891415);
  3776. c = ii(c, d, a, b, x[i + 14], 15, -1416354905);
  3777. b = ii(b, c, d, a, x[i + 5], 21, -57434055);
  3778. a = ii(a, b, c, d, x[i + 12], 6, 1700485571);
  3779. d = ii(d, a, b, c, x[i + 3], 10, -1894986606);
  3780. c = ii(c, d, a, b, x[i + 10], 15, -1051523);
  3781. b = ii(b, c, d, a, x[i + 1], 21, -2054922799);
  3782. a = ii(a, b, c, d, x[i + 8], 6, 1873313359);
  3783. d = ii(d, a, b, c, x[i + 15], 10, -30611744);
  3784. c = ii(c, d, a, b, x[i + 6], 15, -1560198380);
  3785. b = ii(b, c, d, a, x[i + 13], 21, 1309151649);
  3786. a = ii(a, b, c, d, x[i + 4], 6, -145523070);
  3787. d = ii(d, a, b, c, x[i + 11], 10, -1120210379);
  3788. c = ii(c, d, a, b, x[i + 2], 15, 718787259);
  3789. b = ii(b, c, d, a, x[i + 9], 21, -343485551);
  3790. a = safe_add(a, olda);
  3791. b = safe_add(b, oldb);
  3792. c = safe_add(c, oldc);
  3793. d = safe_add(d, oldd);
  3794. }
  3795. return [a, b, c, d];
  3796. }
  3797. function binl2hex(binarray) {
  3798. var hex_tab = "0123456789abcdef";
  3799. var str = "";
  3800. for (var i = 0; i < binarray.length * 4; i++) {
  3801. str += hex_tab.charAt((binarray[i >> 2] >> ((i % 4) * 8 + 4)) & 0xF) +
  3802. hex_tab.charAt((binarray[i >> 2] >> ((i % 4) * 8)) & 0xF);
  3803. }
  3804. return str;
  3805. }
  3806. function str2binl(str) {
  3807. var nblk = ((str.length + 8) >> 6) + 1;
  3808. var blks = new Array(nblk * 16);
  3809. for (var i = 0; i < nblk * 16; i++)
  3810. blks[i] = 0;
  3811. for (var i = 0; i < str.length; i++)
  3812. blks[i >> 2] |= (str.charCodeAt(i) & 0xFF) << ((i % 4) * 8);
  3813. blks[i >> 2] |= 0x80 << ((i % 4) * 8);
  3814. blks[nblk * 16 - 2] = str.length * 8;
  3815. return blks;
  3816. }
  3817. function md5(str) { return binl2hex(coreMD5(str2binl(str))); }
  3818. class PlatfromContro {
  3819. static init() {
  3820. this.layer();
  3821. Task.init();
  3822. WXContro.init(this._layer);
  3823. }
  3824. static layer() {
  3825. this._layer = new Laya.Box();
  3826. this._layer.width = Consts.width;
  3827. this._layer.height = Consts.height;
  3828. this._layer.mouseThrough = true;
  3829. this._layer.addComponent(Laya.Widget);
  3830. let widget = this._layer.getComponent(Laya.Widget);
  3831. widget.centerX = 0;
  3832. widget.centerY = 0;
  3833. this._layer.zOrder = 999;
  3834. Laya.stage.addChild(this._layer);
  3835. }
  3836. static init_rank() {
  3837. let wx = window["wx"];
  3838. if (wx) {
  3839. RankDlg.init(this._layer);
  3840. }
  3841. }
  3842. static init_banner() {
  3843. BannerAd.init(this._layer);
  3844. FlowIconMgr.init({ x: 620, y: 200, layer: this._layer }, FlowIconMgr.TYPE_V);
  3845. }
  3846. static reset_feedbackBt_pos(x, y) {
  3847. if (this.feedbackButton) {
  3848. let pos = WXContro.laya_to_wx_pos(x, y);
  3849. console.log(pos);
  3850. this.feedbackButton.style.top = pos.y;
  3851. this.feedbackButton.style.left = pos.x;
  3852. }
  3853. }
  3854. static show_feedbackButton() {
  3855. this.feedbackButton.show();
  3856. }
  3857. static hide_feedbackButton() {
  3858. this.feedbackButton.hide();
  3859. }
  3860. static reset_FlowIconMgr_pos(x, y) {
  3861. FlowIconMgr.reset_FlowIconMgr_pos(x, y);
  3862. }
  3863. static init_http_call(call) {
  3864. EventHandler.getInstance().addEvent("http_server_data", this, () => {
  3865. if (call) {
  3866. call();
  3867. }
  3868. });
  3869. }
  3870. static hideBanner() {
  3871. BannerAd.hideBannerAd();
  3872. }
  3873. static displayBanner() {
  3874. BannerAd.showBannerAd();
  3875. }
  3876. }
  3877. PlatfromContro._layer = null;
  3878. PlatfromContro.feedbackButton = null;
  3879. class WebView {
  3880. static initGame() {
  3881. uni.postMessage({
  3882. data: {
  3883. funName: "gameInit",
  3884. gameData: {}
  3885. }
  3886. });
  3887. }
  3888. static uploadInfo(gameScore, gameTime, calorieBurned) {
  3889. uni.postMessage({
  3890. data: {
  3891. funName: "uploadInfo",
  3892. gameData: {
  3893. gameScore: gameScore,
  3894. gameTime: gameTime,
  3895. calorieBurned: calorieBurned
  3896. }
  3897. }
  3898. });
  3899. }
  3900. static getAiInfo() {
  3901. uni.postMessage({
  3902. data: {
  3903. funName: "aiRandomInfo",
  3904. gameData: {}
  3905. }
  3906. });
  3907. }
  3908. static getFruitInfo(calorie) {
  3909. uni.postMessage({
  3910. data: {
  3911. funName: "fruitInfo",
  3912. gameData: {
  3913. calorie: calorie
  3914. }
  3915. }
  3916. });
  3917. }
  3918. static onBindBoxingPost() {
  3919. uni.postMessage({
  3920. data: {
  3921. funName: "bindHitBoxingPost",
  3922. gameData: {}
  3923. }
  3924. });
  3925. }
  3926. static closeGame() {
  3927. uni.postMessage({
  3928. data: {
  3929. funName: "closeGame",
  3930. gameData: {}
  3931. }
  3932. });
  3933. }
  3934. static onAddQuitModalListener() {
  3935. uni.postMessage({
  3936. data: {
  3937. funName: "addQuitModal",
  3938. gameData: {}
  3939. }
  3940. });
  3941. }
  3942. }
  3943. WebView.EVENT = {
  3944. onGameInit: "onGameInit",
  3945. onUploadInfo: "onUploadInfo",
  3946. onAiRandomInfo: "onAiRandomInfo",
  3947. onFruitInfo: "onFruitInfo",
  3948. onDeviceUpdateData: "onDeviceUpdateData",
  3949. onDeviceState: "onDeviceState",
  3950. onDeviceClose: "onDeviceClose",
  3951. onBoxingPostHit: "onBoxingPostHit",
  3952. onQuit: "onQuit",
  3953. onQuitModal: "onQuitModal"
  3954. };
  3955. window.onWebViewMessage = (data) => {
  3956. console.log("onWebViewMessage-->", data);
  3957. EventHandler.getInstance().Emit(data.funName, data.gameData);
  3958. };
  3959. class APPControl {
  3960. constructor() {
  3961. this.hitCD = 0;
  3962. }
  3963. static getInstance() {
  3964. if (this._instance == null) {
  3965. this._instance = new APPControl();
  3966. }
  3967. return this._instance;
  3968. }
  3969. init() {
  3970. EventHandler.getInstance().addEvent(WebView.EVENT.onGameInit, this, this.onInitGame);
  3971. EventHandler.getInstance().addEvent(WebView.EVENT.onAiRandomInfo, this, this.onGetAiInfo);
  3972. EventHandler.getInstance().addEvent(WebView.EVENT.onBoxingPostHit, this, this.onBoxingPostHit);
  3973. EventHandler.getInstance().addEvent(WebView.EVENT.onDeviceUpdateData, this, this.onDeviceUpdateData);
  3974. EventHandler.getInstance().addEvent(WebView.EVENT.onQuitModal, this, this.onQuitModal);
  3975. WebView.initGame();
  3976. WebView.onAddQuitModalListener();
  3977. WebView.onBindBoxingPost();
  3978. }
  3979. initGame() {
  3980. console.log("initGame");
  3981. }
  3982. getAiInfo() {
  3983. console.log("getAiInfo");
  3984. }
  3985. onInitGame(gameData) {
  3986. console.log("onInitGame", gameData);
  3987. }
  3988. onGetAiInfo(gameData) {
  3989. console.log("onGetAiInfo", gameData);
  3990. }
  3991. onGetFruitInfo(gameData) {
  3992. console.log("onGetFruitInfo", gameData);
  3993. }
  3994. onDeviceUpdateData(gameData) {
  3995. console.log("onDeviceUpdateData", gameData);
  3996. }
  3997. onBoxingPostHit(gameData) {
  3998. console.log("打击cd时间", this.hitCD);
  3999. if (this.hitCD != 0)
  4000. return;
  4001. this.hitCD = 1;
  4002. Laya.timer.once(100, this, function () {
  4003. this.hitCD = 0;
  4004. });
  4005. console.log("onBoxingPostHit", gameData);
  4006. let state = MainScene.instance.gameState;
  4007. switch (state) {
  4008. case 1:
  4009. MainScene.instance.onStartGameClick();
  4010. break;
  4011. case 2:
  4012. MainScene.gameControl.onGameStageClick();
  4013. break;
  4014. default:
  4015. break;
  4016. }
  4017. }
  4018. onQuitModal(gameData) {
  4019. if (gameData.data.confirm) {
  4020. WebView.closeGame();
  4021. }
  4022. console.log("onQuitModal", gameData);
  4023. }
  4024. }
  4025. APPControl._instance = null;
  4026. class MainScene extends ui.MainSceneUI {
  4027. constructor() {
  4028. super();
  4029. this.gameState = 1;
  4030. this.tag_knifeSystem = 0;
  4031. this.tag_critSystem = 0;
  4032. this.tag_coinSystem = 0;
  4033. MainScene.instance = this;
  4034. Laya.stage.scaleMode = Laya.Stage.SCALE_FIXED_WIDTH;
  4035. this.SceneBox.pivotY = this.SceneBox.height / 2;
  4036. this.SceneBox.y = Laya.stage.height / 2;
  4037. PlatfromContro.init();
  4038. Laya.stage.on(Laya.Event.MOUSE_MOVE, this, function () {
  4039. this.mousePos.text = Laya.stage.mouseX + "," + Laya.stage.mouseY;
  4040. });
  4041. APPControl.getInstance().init();
  4042. }
  4043. onEnable() {
  4044. this.init();
  4045. this.btn_startGame.on(Laya.Event.MOUSE_DOWN, this, this.onStartGameClick);
  4046. this.btn_knifeSystem.on(Laya.Event.MOUSE_DOWN, this, this.onKnifeSystemClick);
  4047. this.btn_critSystem.on(Laya.Event.MOUSE_DOWN, this, this.onCritSystemClick);
  4048. this.btn_coinSystem.on(Laya.Event.MOUSE_DOWN, this, this.onCoinSystemClick);
  4049. this.btn_knifeUpgradeNumNeedCoins.on(Laya.Event.MOUSE_DOWN, this, this.onKnifeUpgradeNumNeedCoinsClick);
  4050. this.btn_knifeUpgradeAttackNeedCoins.on(Laya.Event.MOUSE_DOWN, this, this.onKnifeUpgradeAttackNeedCoinsClick);
  4051. this.btn_critUpgradeAttackNeedCoins.on(Laya.Event.MOUSE_DOWN, this, this.onCritUpgradeAttackNeedCoinsClick);
  4052. this.btn_critUpgradeChanceNeedCoins.on(Laya.Event.MOUSE_DOWN, this, this.onCritUpgradeChanceNeedCoinsClick);
  4053. this.btn_coinUpgradeValueNeedCoins.on(Laya.Event.MOUSE_DOWN, this, this.onCoinUpgradeValueNeedCoinsClick);
  4054. this.btn_coinUpgradeProfitNeedCoins.on(Laya.Event.MOUSE_DOWN, this, this.onCoinUpgradeProfitNeedCoinsClick);
  4055. this.btn_addCoin.on(Laya.Event.MOUSE_DOWN, this, this.onAddCoinClick);
  4056. this.btn_addStrength.on(Laya.Event.MOUSE_DOWN, this, this.onAddStrengthClick);
  4057. this.coinProfit.on(Laya.Event.MOUSE_DOWN, this, this.onCoinProfitClick);
  4058. this.dialog_getStrength.btn_nextTime.on(Laya.Event.MOUSE_DOWN, this, this.onDialogGetStrength_NextTimeClick);
  4059. this.dialog_getStrength.btn_getStrength.on(Laya.Event.MOUSE_DOWN, this, this.onDialogGetStrength_GetStrengthClick);
  4060. this.dialog_receiveCoinProfit.touchArea.on(Laya.Event.MOUSE_DOWN, this, this.onDialogReceiveCoinProfit_TouchAreaClick);
  4061. this.dialog_receiveCoinProfit.btn_clickReceive.on(Laya.Event.MOUSE_DOWN, this, this.onDialogReceiveCoinProfit_ReceiveClick);
  4062. this.dialog_receiveCoinProfit.btn_threeTimesReceive.on(Laya.Event.MOUSE_DOWN, this, this.onDialogReceiveCoinProfit_ThreeTimesReceiveClick);
  4063. this.dialog_speedUpCoinProfit.btn_threeTimesFaster.on(Laya.Event.MOUSE_DOWN, this, this.onDialogSpeedUpCoinProfit_ThreeTimesFasterClick);
  4064. this.dialog_speedUpCoinProfit.btn_nextTime.on(Laya.Event.MOUSE_DOWN, this, this.onDialogSpeedUpCoinProfit_NextTimeClick);
  4065. this.dialog_unlockPlanet.btn_OK.on(Laya.Event.MOUSE_DOWN, this, this.onDialog_UnloackPlanet_OKClick);
  4066. this.btn_rank.on(Laya.Event.MOUSE_DOWN, this, this.onRankClick);
  4067. let ahitArea = new Laya.HitArea();
  4068. let agraphics = new Laya.Graphics();
  4069. agraphics.drawRect(-10, -10, this.dialog_getStrength.btn_nextTime.width + 20, this.dialog_getStrength.btn_nextTime.height + 20, "#ff9900");
  4070. ahitArea.hit = agraphics;
  4071. this.dialog_getStrength.btn_nextTime.hitArea = ahitArea;
  4072. let ahitArea2 = new Laya.HitArea();
  4073. let agraphics2 = new Laya.Graphics();
  4074. agraphics2.drawRect(-10, -10, this.dialog_speedUpCoinProfit.btn_nextTime.width + 20, this.dialog_speedUpCoinProfit.btn_nextTime.height + 20, "#ff9900");
  4075. ahitArea2.hit = agraphics2;
  4076. this.dialog_speedUpCoinProfit.btn_nextTime.hitArea = ahitArea2;
  4077. this.prop_rocket.visible = false;
  4078. this.prop_slowDown.visible = false;
  4079. this.prop_subBlood.visible = false;
  4080. this.btn_testPrint.visible = false;
  4081. this.btn_addStrength.visible = false;
  4082. this.btn_addCoin.visible = false;
  4083. this.strengthSPUnderStartGame.visible = false;
  4084. let jumpPoint = this.btn_startGame.localToGlobal(new Laya.Point());
  4085. this.jumpAni = AnimationControl.playJump(jumpPoint.x, jumpPoint.y);
  4086. this.jumpAni.visible = false;
  4087. this.jumpAni.zOrder = 5000;
  4088. this.showHomeUI();
  4089. this.btn_returnHome.x -= 10;
  4090. this.btn_returnHome.y += 10;
  4091. this.btn_returnHome.on(Laya.Event.MOUSE_DOWN, this, this.returnHome);
  4092. }
  4093. init() {
  4094. MusicControl.playBGMusic();
  4095. let performanceTag = false;
  4096. this.btn_showPerformance.on(Laya.Event.MOUSE_DOWN, this, function () {
  4097. if (performanceTag) {
  4098. Laya.Stat.hide();
  4099. performanceTag = false;
  4100. }
  4101. else {
  4102. Laya.Stat.show(0, 100);
  4103. performanceTag = true;
  4104. }
  4105. });
  4106. this.gameOverUI = new GameOverPage();
  4107. this.showBG();
  4108. this.closeMask();
  4109. this.dialog_speedUpCoinProfit = new ui.Dialogs.Dialog_SpeedUpCoinProfitUI();
  4110. this.dialog_getStrength = new ui.Dialogs.Dialog_GetStrengthUI();
  4111. this.dialog_receiveCoinProfit = new ui.Dialogs.Dialog_ReceiveCoinProfitUI();
  4112. this.dialog_freelyGetProp = new FreelyGetPropPage();
  4113. this.dialog_unlockPlanet = new ui.Dialogs.Dialog_UnlockPlanetUI();
  4114. this.touchArea.on(Laya.Event.MOUSE_DOWN, this, this.onTouchAreaClick);
  4115. this.text_addBloodNum.alpha = 0;
  4116. this.tipBox.visible = false;
  4117. this.tipBoxMask.blendMode = "destination-out";
  4118. this.tipMaskSprite.cacheAs = "bitmap";
  4119. this.tipBoxMask.width = this.btn_knifeSystem.width;
  4120. this.tipBoxMask.height = this.btn_knifeSystem.height;
  4121. this.tipBoxMask.pivot(this.tipBoxMask.width / 2, this.tipBoxMask.height / 2);
  4122. }
  4123. updateGameState(gameState) {
  4124. this.gameState = gameState;
  4125. let jumpPoint;
  4126. switch (gameState) {
  4127. case 1:
  4128. jumpPoint = this.btn_startGame.localToGlobal(new Laya.Point());
  4129. this.jumpAni.pos(jumpPoint.x + 200, jumpPoint.y - 80);
  4130. this.jumpAni.visible = true;
  4131. break;
  4132. case 5:
  4133. jumpPoint = this.dialog_unlockPlanet.btn_OK.localToGlobal(new Laya.Point());
  4134. this.jumpAni.pos(jumpPoint.x, jumpPoint.y);
  4135. this.jumpAni.visible = true;
  4136. default:
  4137. this.jumpAni.visible = false;
  4138. break;
  4139. }
  4140. }
  4141. onTouchAreaClick() {
  4142. this.closeKnifeSystemUI();
  4143. this.closeCritSystemUI();
  4144. this.closeCoinSystemUI();
  4145. }
  4146. showMask() {
  4147. MainScene.instance.maskBox.visible = true;
  4148. }
  4149. closeMask() {
  4150. MainScene.instance.maskBox.visible = false;
  4151. }
  4152. showBG() {
  4153. let bgArr = [];
  4154. let minY = -1000;
  4155. let totalHeight = 0;
  4156. let maxY = 0;
  4157. for (let i = 0; i < 5; i++) {
  4158. let url = "texture/BG/BG" + (i + 1) + ".jpg";
  4159. let bgSprite = new Laya.Sprite();
  4160. bgSprite.loadImage(url, Laya.Handler.create(this, () => {
  4161. this.bg.addChild(bgSprite);
  4162. totalHeight += bgSprite.height;
  4163. let posY = minY + i * 1000;
  4164. bgSprite.y = posY;
  4165. bgArr.push(bgSprite);
  4166. if (i == 4) {
  4167. let starsBrighter = this.starsBrighter;
  4168. let stars = new Laya.Sprite();
  4169. stars.loadImage("texture/BG/BG_stars.png");
  4170. this.starsBrighter.addChild(stars);
  4171. let starsAni_hide = function () {
  4172. Laya.Tween.to(stars, { alpha: 0.1 }, 2000, Laya.Ease.linearIn, Laya.Handler.create(this, starsAni_display));
  4173. Laya.Tween.to(starsBrighter, { alpha: 1 }, 500);
  4174. };
  4175. let starsAni_display = function () {
  4176. Laya.Tween.to(stars, { alpha: 1 }, 1000, Laya.Ease.linearIn, Laya.Handler.create(this, starsAni_hide));
  4177. Laya.Tween.to(starsBrighter, { alpha: 0.3 }, 1000);
  4178. };
  4179. starsAni_hide();
  4180. let halation = new Laya.Sprite();
  4181. halation.loadImage("texture/BG/BG_halation.png");
  4182. this.bgBox.addChild(halation);
  4183. let BG_planet1 = new Laya.Sprite();
  4184. BG_planet1.loadImage("texture/BG/BG_planet1.png");
  4185. this.bgBox.addChild(BG_planet1);
  4186. BG_planet1.pos(0, 344);
  4187. let planet1Ani_moveUp = function () {
  4188. Laya.Tween.to(BG_planet1, { y: BG_planet1.y + 50 }, 10000, Laya.Ease.linearIn, Laya.Handler.create(this, planet1Ani_moveDown));
  4189. };
  4190. let planet1Ani_moveDown = function () {
  4191. Laya.Tween.to(BG_planet1, { y: BG_planet1.y - 50 }, 10000, Laya.Ease.linearIn, Laya.Handler.create(this, planet1Ani_moveUp));
  4192. };
  4193. planet1Ani_moveUp();
  4194. let BG_planet2 = new Laya.Sprite();
  4195. BG_planet2.loadImage("texture/BG/BG_planet2.png");
  4196. this.bgBox.addChild(BG_planet2);
  4197. BG_planet2.pos(618, 484);
  4198. let planet2Ani_moveUp = function () {
  4199. Laya.Tween.to(BG_planet2, { y: BG_planet2.y + 50 }, 10000, Laya.Ease.linearIn, Laya.Handler.create(this, planet2Ani_moveDown));
  4200. };
  4201. let planet2Ani_moveDown = function () {
  4202. Laya.Tween.to(BG_planet2, { y: BG_planet2.y - 50 }, 10000, Laya.Ease.linearIn, Laya.Handler.create(this, planet2Ani_moveUp));
  4203. };
  4204. planet2Ani_moveUp();
  4205. maxY = bgSprite.y + bgSprite.height;
  4206. Laya.timer.frameLoop(1, this, function () {
  4207. for (let i = 0; i < bgArr.length; i++) {
  4208. let speed = 2;
  4209. bgArr[i].y += speed;
  4210. if (bgArr[i].y >= maxY) {
  4211. bgArr[i].y = -1000 + speed;
  4212. }
  4213. }
  4214. });
  4215. }
  4216. }));
  4217. }
  4218. }
  4219. onStartGameClick() {
  4220. MainScene.gameControl.levelStart();
  4221. }
  4222. onKnifeSystemClick() {
  4223. if (MainScene.gameControl.getMaxLevel() == 0)
  4224. return;
  4225. if (this.tag_knifeSystem == 0) {
  4226. this.showKnifeSystemUI();
  4227. }
  4228. else {
  4229. this.closeKnifeSystemUI();
  4230. }
  4231. }
  4232. onCritSystemClick() {
  4233. if (this.tag_critSystem == 0) {
  4234. this.showCritSystemUI();
  4235. }
  4236. else {
  4237. this.closeCritSystemUI();
  4238. }
  4239. }
  4240. onCoinSystemClick() {
  4241. if (this.tag_coinSystem == 0) {
  4242. this.showCoinSystemUI();
  4243. }
  4244. else {
  4245. this.closeCoinSystemUI();
  4246. }
  4247. }
  4248. onKnifeUpgradeNumNeedCoinsClick() {
  4249. MainScene.gameControl.upGradeKnifeNum();
  4250. }
  4251. onKnifeUpgradeAttackNeedCoinsClick() {
  4252. MainScene.gameControl.upGradeKnifeAttack();
  4253. }
  4254. onCritUpgradeAttackNeedCoinsClick() {
  4255. MainScene.gameControl.upGradeCritAttack();
  4256. }
  4257. onCritUpgradeChanceNeedCoinsClick() {
  4258. MainScene.gameControl.upGradeCritChance();
  4259. }
  4260. onCoinUpgradeValueNeedCoinsClick() {
  4261. MainScene.gameControl.upGradeCoinValue();
  4262. }
  4263. onCoinUpgradeProfitNeedCoinsClick() {
  4264. MainScene.gameControl.upGradeCoinProfit();
  4265. }
  4266. onAddCoinClick() {
  4267. if (MainScene.gameControl.maxLevel < 5) {
  4268. let text = new Laya.Text();
  4269. text.text = "金币收益还未解锁";
  4270. this.text_holdCoinsNum.addChild(text);
  4271. text.pos(220, text.height / 2);
  4272. text.fontSize = 28;
  4273. text.color = "#ffffff";
  4274. Laya.timer.once(1000, this, function () {
  4275. text.destroy();
  4276. });
  4277. }
  4278. else {
  4279. this.dialog_speedUpCoinProfit.show();
  4280. }
  4281. }
  4282. onAddStrengthClick() {
  4283. this.dialog_getStrength.show();
  4284. }
  4285. onCoinProfitClick() {
  4286. this.dialog_receiveCoinProfit.show();
  4287. let coinStr = MathTool.currencyUnit(this.coinDailyIncomeControl.availableIncome);
  4288. this.dialog_receiveCoinProfit.text_btn_clickReceive.text = coinStr;
  4289. let coinStr3 = MathTool.currencyUnit(this.coinDailyIncomeControl.availableIncome * 3);
  4290. this.dialog_receiveCoinProfit.text_btn_threeTimesReceive.text = coinStr3;
  4291. }
  4292. onRankClick() {
  4293. RankDlg.show(RANK_TYPE.LIST, MainScene.gameControl.maxLevel);
  4294. }
  4295. onRocketClick() {
  4296. MainScene.gameControl.onRocketClick();
  4297. }
  4298. onSlowDownClick() {
  4299. MainScene.gameControl.onSlowDownClick();
  4300. }
  4301. onSubBloodClick() {
  4302. MainScene.gameControl.onSubBloodClick();
  4303. }
  4304. onDialogGetStrength_NextTimeClick() {
  4305. Func.sharePointCount("getStrength-close", 101);
  4306. this.dialog_getStrength.close();
  4307. }
  4308. onDialogGetStrength_GetStrengthClick() {
  4309. Func.sharePoint("getStrength", false, this.onShare_getStrength);
  4310. Func.sharePointCount("getStrength-open", 101);
  4311. }
  4312. onShare_getStrength() {
  4313. MainScene.gameControl.recoverEnergies(30, 1);
  4314. MainScene.instance.dialog_getStrength.close();
  4315. MainScene.gameControl.updateHomeUI();
  4316. }
  4317. onDialogReceiveCoinProfit_TouchAreaClick() {
  4318. this.dialog_receiveCoinProfit.close();
  4319. }
  4320. onDialogReceiveCoinProfit_ReceiveClick() {
  4321. if (this.coinDailyIncomeControl.availableIncome >= this.coinDailyIncomeControl.incomeAtLeast) {
  4322. Func.sharePointCount("threeTimesReceiveProfit-close", 101);
  4323. this.dialog_receiveCoinProfit.close();
  4324. MainScene.gameControl.receiveCoinDailyIncome(this.coinDailyIncomeControl.availableIncome);
  4325. this.coinDailyIncomeControl.restartTimer_updateProfitCountDown();
  4326. this.coinIncomeProgress.value = 0;
  4327. let startPoint = new Laya.Point(Laya.stage.width / 2, Laya.stage.height / 2);
  4328. let iconCoin = MainScene.instance.icon_coin_homeLeftTop;
  4329. let targetPoint = new Laya.Point(iconCoin.width / 2, iconCoin.height / 2);
  4330. targetPoint = iconCoin.localToGlobal(targetPoint);
  4331. targetPoint.x = 42;
  4332. AnimationControl.playCoinsFlyAni(startPoint, targetPoint);
  4333. }
  4334. else {
  4335. this.dialog_receiveCoinProfit.tip_receiveLater.visible = true;
  4336. Laya.timer.once(2000, this, function () {
  4337. this.dialog_receiveCoinProfit.tip_receiveLater.visible = false;
  4338. });
  4339. }
  4340. }
  4341. onDialogReceiveCoinProfit_ThreeTimesReceiveClick() {
  4342. if (this.coinDailyIncomeControl.availableIncome >= this.coinDailyIncomeControl.incomeAtLeast) {
  4343. Func.sharePoint("threeTimesReceiveProfit", false, this.onShare_threeTimesReceive);
  4344. Func.sharePointCount("threeTimesReceiveProfit-open", 101);
  4345. }
  4346. else {
  4347. this.dialog_receiveCoinProfit.tip_receiveLater.visible = true;
  4348. Laya.timer.once(2000, this, function () {
  4349. this.dialog_receiveCoinProfit.tip_receiveLater.visible = false;
  4350. });
  4351. }
  4352. }
  4353. onShare_threeTimesReceive() {
  4354. let self = MainScene.instance;
  4355. self.dialog_receiveCoinProfit.close();
  4356. MainScene.gameControl.receiveCoinDailyIncome(self.coinDailyIncomeControl.availableIncome * 3);
  4357. self.coinDailyIncomeControl.restartTimer_updateProfitCountDown();
  4358. self.coinIncomeProgress.value = 0;
  4359. let startPoint = new Laya.Point(Laya.stage.width / 2, Laya.stage.height / 2);
  4360. let iconCoin = MainScene.instance.icon_coin_homeLeftTop;
  4361. let targetPoint = new Laya.Point(iconCoin.width / 2, iconCoin.height / 2);
  4362. targetPoint = iconCoin.localToGlobal(targetPoint);
  4363. targetPoint.x = 42;
  4364. AnimationControl.playCoinsFlyAni(startPoint, targetPoint);
  4365. }
  4366. onDialogSpeedUpCoinProfit_ThreeTimesFasterClick() {
  4367. Func.sharePoint("threeTimesFasterProfit", false, this.onShare_ThreeTimesFaster);
  4368. Func.sharePointCount("threeTimesFasterProfit-open", 101);
  4369. }
  4370. onShare_ThreeTimesFaster() {
  4371. MainScene.instance.coinDailyIncomeControl.ProfitFasterCountDown = 5 * 60;
  4372. MainScene.instance.coinDailyIncomeControl.threeTimesFaster();
  4373. MainScene.instance.dialog_speedUpCoinProfit.close();
  4374. MainScene.instance.coinDailyIncomeControl.saveLastFasterStartTime();
  4375. }
  4376. onDialogSpeedUpCoinProfit_NextTimeClick() {
  4377. Func.sharePointCount("threeTimesFasterProfit-close", 101);
  4378. this.dialog_speedUpCoinProfit.close();
  4379. }
  4380. onDialog_UnloackPlanet_OKClick() {
  4381. this.dialog_unlockPlanet.close();
  4382. }
  4383. showGameUI() {
  4384. this.gameUI.visible = true;
  4385. this.homeUI.visible = false;
  4386. }
  4387. showHomeUI() {
  4388. MainScene.instance.updateGameState(1);
  4389. this.gameUI.visible = false;
  4390. this.homeUI.visible = true;
  4391. this.leftUI.pos(0, 0);
  4392. this.rightUI.pos(0, 0);
  4393. this.topUI.pos(0, 0);
  4394. this.bottomUI.pos(0, 150);
  4395. this.btn_startGame.visible = true;
  4396. this.btn_knifeSystem.skin = "texture/MainScene/TAB/btn_rocket_unchecked.png";
  4397. this.btn_critSystem.skin = "texture/MainScene/TAB/btn_crit_unchecked.png";
  4398. this.btn_coinSystem.skin = "texture/MainScene/TAB/btn_coin_unchecked.png";
  4399. }
  4400. showKnifeSystemUI() {
  4401. this.tag_knifeSystem = 1;
  4402. this.knifeSystemUI.visible = true;
  4403. this.btn_knifeSystem.skin = "texture/MainScene/TAB/btn_rocket_checked.png";
  4404. this.closeCritSystemUI();
  4405. this.closeCoinSystemUI();
  4406. }
  4407. closeKnifeSystemUI() {
  4408. this.tag_knifeSystem = 0;
  4409. this.knifeSystemUI.visible = false;
  4410. this.btn_knifeSystem.skin = "texture/MainScene/TAB/btn_rocket_unchecked.png";
  4411. }
  4412. showCritSystemUI() {
  4413. this.tag_critSystem = 1;
  4414. if (MainScene.gameControl.maxLevel >= 10) {
  4415. this.critSystemUI.visible = true;
  4416. this.bubble_crit.visible = false;
  4417. }
  4418. else {
  4419. this.critSystemUI.visible = false;
  4420. this.bubble_crit.visible = true;
  4421. }
  4422. this.btn_critSystem.skin = "texture/MainScene/TAB/btn_crit_checked.png";
  4423. this.closeKnifeSystemUI();
  4424. this.closeCoinSystemUI();
  4425. }
  4426. closeCritSystemUI() {
  4427. this.tag_critSystem = 0;
  4428. this.critSystemUI.visible = false;
  4429. this.bubble_crit.visible = false;
  4430. this.btn_critSystem.skin = "texture/MainScene/TAB/btn_crit_unchecked.png";
  4431. }
  4432. showCoinSystemUI() {
  4433. this.tag_coinSystem = 1;
  4434. if (MainScene.gameControl.maxLevel >= 20) {
  4435. this.coinSystemUI.visible = true;
  4436. this.bubble_coin.visible = false;
  4437. }
  4438. else {
  4439. this.coinSystemUI.visible = false;
  4440. this.bubble_coin.visible = true;
  4441. }
  4442. this.btn_coinSystem.skin = "texture/MainScene/TAB/btn_coin_checked.png";
  4443. this.closeKnifeSystemUI();
  4444. this.closeCritSystemUI();
  4445. }
  4446. closeCoinSystemUI() {
  4447. this.tag_coinSystem = 0;
  4448. this.coinSystemUI.visible = false;
  4449. this.bubble_coin.visible = false;
  4450. this.btn_coinSystem.skin = "texture/MainScene/TAB/btn_coin_unchecked.png";
  4451. }
  4452. returnHome() {
  4453. MainScene.instance.updateGameState(1);
  4454. MainScene.gameControl.levelOver();
  4455. MainScene.instance.showHomeUI();
  4456. MainScene.gameControl.updateHomeUI();
  4457. MainScene.gameControl.checkNewPlayer();
  4458. MainScene.sun.sunIdle();
  4459. }
  4460. }
  4461. class Sun extends ui.SunUI {
  4462. constructor() {
  4463. super();
  4464. this.totalBlood = 100;
  4465. this.curBlood = 100;
  4466. this.sunRotateDirection = 1;
  4467. this.sunRotateSpeed = 0;
  4468. this.sunRotateSpeedInit = 0;
  4469. this.sunLastTime = 0;
  4470. this.shieldBlood = 0;
  4471. this.innerRotateDirection = 1;
  4472. this.innerRotateSpeed = 0;
  4473. this.outerRotateDirection = 1;
  4474. this.outerRotateSpeed = 0;
  4475. this.breatheTag = 0;
  4476. this.sunScaleAni = null;
  4477. this.bindedRiftArr = [];
  4478. this.riftInfo = [
  4479. {
  4480. "rotation": 0,
  4481. "pointX": 0,
  4482. "pointY": 0
  4483. }
  4484. ];
  4485. this.angleArr = [];
  4486. Laya.loader.load("res/atlas/texture/Effect/ringEffect.atlas", Laya.Handler.create(this, () => {
  4487. }));
  4488. Laya.loader.load("res/atlas/texture/Effect/SunRift.atlas");
  4489. Laya.timer.once(100, this, function () {
  4490. this.saveRiftInfo();
  4491. });
  4492. }
  4493. levelInit() {
  4494. this.riftInfo = [];
  4495. this.saveRiftInfo();
  4496. this.bindedRiftArr = [];
  4497. for (let i = 0; i < 6; i++) {
  4498. let rift = Laya.Pool.getItemByClass("Rift", Laya.Sprite);
  4499. rift.visible = false;
  4500. this.bindedRiftArr.push(rift);
  4501. this.RiftNode.addChild(rift);
  4502. }
  4503. this.breatheTag = 1;
  4504. if (this.sunScaleAni)
  4505. Laya.Tween.clear(this.sunScaleAni);
  4506. this.sunScaleAni = Laya.Tween.to(this.sunNode, { scaleX: 1, scaleY: 1, y: 411 }, 500, Laya.Ease.linearIn, Laya.Handler.create(this, function () {
  4507. this.breatheTag = 0;
  4508. if (!this.ringAni)
  4509. this.initRingAni();
  4510. if (!this.knifeBindPoint) {
  4511. let aPoint = new Laya.Point(this.sunNode.x, this.sunNode.y + 150);
  4512. this.knifeBindPoint = this.localToGlobal(aPoint);
  4513. this.minSunPoint = new Laya.Point(this.sunNode.width / 2, this.sunNode.height);
  4514. this.minSunPoint = this.sunNode.localToGlobal(this.minSunPoint);
  4515. }
  4516. if (!MainScene.gameControl.minKnifeY) {
  4517. MainScene.gameControl.saveMinPointY();
  4518. }
  4519. MainScene.gameControl.launchRocketTag = 0;
  4520. let knife = MainScene.gameControl.createKnife();
  4521. }));
  4522. Laya.Tween.to(MainScene.instance.bg, { scaleX: 1.2, scaleY: 1.2 }, 500);
  4523. Laya.Tween.to(MainScene.instance.starsBrighter, { scaleX: 1.2, scaleY: 1.2 }, 500);
  4524. Laya.Tween.to(MainScene.instance.bgBox, { scaleX: 1.1, scaleY: 1.1 }, 500);
  4525. this.sunRotateSpeed = this.sunRotateSpeedInit = this.getConsumedTime();
  4526. this.sunAndKnifeNode.pivotX = this.sunAndKnifeNode.width / 2;
  4527. this.sunAndKnifeNode.pivotY = this.sunAndKnifeNode.height / 2;
  4528. this.sunLastTime = Laya.Browser.now();
  4529. Laya.timer.clear(this, this.sunRotate);
  4530. Laya.timer.frameLoop(1, this, this.sunRotate);
  4531. let blood = 4 * Math.pow((MainScene.gameControl.curLevel), 3)
  4532. + 20 * (Math.pow(MainScene.gameControl.curLevel, 2)) + 100;
  4533. this.curBlood = this.totalBlood = Math.floor(blood);
  4534. this.updateUI();
  4535. this.critNode.alpha = 0;
  4536. }
  4537. sunIdle() {
  4538. this.clearRift();
  4539. this.planetInnerRingNode.visible = false;
  4540. this.planetOuterRingNode.visible = false;
  4541. this.planetInnerRingNode.alpha = 0;
  4542. this.planetOuterRingNode.alpha = 0;
  4543. this.breatheTag = 1;
  4544. if (this.sunScaleAni)
  4545. Laya.Tween.clear(this.sunScaleAni);
  4546. this.sunNode.scale(0.7, 0.7);
  4547. this.sunNode.y = 630;
  4548. this.breatheTag = 0;
  4549. this.sunRotateSpeed = this.sunRotateSpeedInit = this.getConsumedTime();
  4550. this.sunAndKnifeNode.pivotX = this.sunAndKnifeNode.width / 2;
  4551. this.sunAndKnifeNode.pivotY = this.sunAndKnifeNode.height / 2;
  4552. this.sunLastTime = Laya.Browser.now();
  4553. Laya.timer.clear(this, this.sunRotate);
  4554. Laya.timer.frameLoop(1, this, this.sunRotate);
  4555. let blood = 4 * Math.pow((MainScene.gameControl.curLevel), 3)
  4556. + 20 * (Math.pow(MainScene.gameControl.curLevel, 2)) + 100;
  4557. this.curBlood = this.totalBlood = Math.floor(blood);
  4558. this.updateUI();
  4559. this.switchEmoji(0);
  4560. this.critNode.alpha = 0;
  4561. PlatfromContro.displayBanner();
  4562. MainScene.instance.bg.scale(1, 1);
  4563. MainScene.instance.starsBrighter.scale(1, 1);
  4564. MainScene.instance.bgBox.scale(1, 1);
  4565. }
  4566. getConsumedTime() {
  4567. let levelNum = MainScene.gameControl.curLevel;
  4568. let consumedTime = 0;
  4569. if (levelNum <= 10) {
  4570. consumedTime = 5;
  4571. }
  4572. else if (levelNum >= 11 && levelNum <= 30) {
  4573. consumedTime = 4.5;
  4574. }
  4575. else if (levelNum >= 31 && levelNum <= 50) {
  4576. consumedTime = 4;
  4577. }
  4578. else if (levelNum >= 51 && levelNum <= 80) {
  4579. consumedTime = 3.75;
  4580. }
  4581. else if (levelNum >= 81 && levelNum <= 110) {
  4582. consumedTime = 3.5;
  4583. }
  4584. else if (levelNum >= 111 && levelNum <= 150) {
  4585. consumedTime = 3.25;
  4586. }
  4587. else if (levelNum >= 151) {
  4588. consumedTime = 3;
  4589. }
  4590. return consumedTime;
  4591. }
  4592. sunRotate() {
  4593. let interval = Laya.Browser.now() - this.sunLastTime;
  4594. this.sunAndKnifeNode.rotation += 360 / this.sunRotateSpeed / 1000 * interval * this.sunRotateDirection;
  4595. if (this.sunAndKnifeNode.rotation <= -360 || this.sunAndKnifeNode.rotation >= 360) {
  4596. this.sunAndKnifeNode.rotation = 0;
  4597. }
  4598. this.sunLastTime = Laya.Browser.now();
  4599. if (this.text_sunRotation) {
  4600. this.text_sunRotation.text = Math.floor(this.sunAndKnifeNode.rotation) + "";
  4601. }
  4602. }
  4603. subBlood(subNum) {
  4604. let leftoverNeedSubBlood = 0;
  4605. if (this.shieldBlood > 0) {
  4606. if (this.shieldBlood >= subNum) {
  4607. this.shieldBlood -= subNum;
  4608. }
  4609. else {
  4610. this.shieldBlood = 0;
  4611. this.stopShieldAni();
  4612. leftoverNeedSubBlood = subNum - this.shieldBlood;
  4613. }
  4614. }
  4615. else {
  4616. leftoverNeedSubBlood = subNum;
  4617. }
  4618. if (this.curBlood > 0) {
  4619. this.curBlood -= leftoverNeedSubBlood;
  4620. this.curBlood = Math.ceil(this.curBlood);
  4621. if (this.curBlood < 0) {
  4622. this.curBlood = 0;
  4623. }
  4624. }
  4625. this.updateUI();
  4626. this.checkBlood();
  4627. }
  4628. addBlood(addNum) {
  4629. if (this.curBlood + addNum > this.totalBlood) {
  4630. this.curBlood = Math.ceil(this.totalBlood);
  4631. }
  4632. else {
  4633. this.curBlood = Math.ceil(this.curBlood + addNum);
  4634. }
  4635. this.updateUI();
  4636. }
  4637. updateUI() {
  4638. let instance = MainScene.instance;
  4639. let bloodBar = instance.bloodProgressBar;
  4640. let bloodMask = instance.bloodBarMask;
  4641. let shieldBar = instance.shieldProgressBar;
  4642. let shieldMask = instance.shieldBarMask;
  4643. instance.bloodBarMask.x = -(bloodMask.width * (1 - this.curBlood / this.totalBlood));
  4644. let bloodStr = MathTool.currencyUnit(this.curBlood);
  4645. let text_bloodNum = MainScene.instance.text_bloodNum;
  4646. text_bloodNum.text = bloodStr;
  4647. text_bloodNum.pivotX = text_bloodNum.width;
  4648. if (this.shieldBlood > 0) {
  4649. shieldBar.visible = true;
  4650. if (this.shieldBlood + this.curBlood >= this.totalBlood) {
  4651. shieldBar.x = bloodBar.x + (bloodBar.width - shieldBar.width);
  4652. shieldMask.x = shieldBar.width * (1 - this.shieldBlood / (this.totalBlood * 0.2));
  4653. }
  4654. else {
  4655. shieldBar.x = bloodBar.x + (bloodMask.x + bloodBar.width);
  4656. shieldMask.x = -shieldBar.width * (1 - this.shieldBlood / (this.totalBlood * 0.2));
  4657. }
  4658. }
  4659. else {
  4660. shieldBar.visible = false;
  4661. }
  4662. }
  4663. checkBlood() {
  4664. let percent = this.getPercentOfBlood();
  4665. if (percent < 0.2 && percent > 0) {
  4666. this.switchEmoji(4);
  4667. ;
  4668. }
  4669. if (this.curBlood > 0) {
  4670. return true;
  4671. }
  4672. else {
  4673. return false;
  4674. }
  4675. }
  4676. addShield(shieldBlood) {
  4677. this.shieldBlood = shieldBlood;
  4678. this.updateUI();
  4679. }
  4680. getPercentOfBlood() {
  4681. let blood = this.curBlood;
  4682. let totalBlood = this.totalBlood;
  4683. let percent = blood / totalBlood;
  4684. return percent;
  4685. }
  4686. switchEmoji(emojiType) {
  4687. MainScene.gameControl.attackSunTime = Laya.Browser.now();
  4688. let emojiPath = "";
  4689. let sunBGPath = "";
  4690. let sunShinePath = "";
  4691. switch (emojiType) {
  4692. case 0:
  4693. emojiPath = "texture/Sun/biaoqing_tiaoxin.png";
  4694. sunBGPath = "texture/Sun/sunBG_normal.png";
  4695. sunShinePath = "texture/Sun/sunShine1.png";
  4696. break;
  4697. case 1:
  4698. emojiPath = "texture/Sun/biaoqing_baonu.png";
  4699. sunBGPath = "texture/Sun/sunBG_normal.png";
  4700. sunShinePath = "texture/Sun/sunShine1.png";
  4701. break;
  4702. case 2:
  4703. emojiPath = "texture/Sun/biaoqing_kuqi.png";
  4704. sunBGPath = "texture/Sun/sunBG_normal.png";
  4705. sunShinePath = "texture/Sun/sunShine1.png";
  4706. break;
  4707. case 3:
  4708. emojiPath = "texture/Sun/biaoqing_wuliao.png";
  4709. sunBGPath = "texture/Sun/sunBG_normal.png";
  4710. sunShinePath = "texture/Sun/sunShine1.png";
  4711. break;
  4712. case 4:
  4713. emojiPath = "texture/Sun/biaoqing_jingkong.png";
  4714. sunBGPath = "texture/Sun/sunBG_jingkong.png";
  4715. sunShinePath = "texture/Sun/sunShine1.png";
  4716. break;
  4717. case 5:
  4718. emojiPath = "texture/Sun/biaoqing_chaoxiao.png";
  4719. sunBGPath = "texture/Sun/sunBG_normal.png";
  4720. sunShinePath = "texture/Sun/sunShine1.png";
  4721. break;
  4722. case 6:
  4723. emojiPath = "texture/Sun/biaoqing_kaixin.png";
  4724. sunBGPath = "texture/Sun/sunBG_normal.png";
  4725. sunShinePath = "texture/Sun/sunShine1.png";
  4726. break;
  4727. case 7:
  4728. emojiPath = "texture/Sun/biaoqing_shuai.png";
  4729. sunBGPath = "texture/Sun/sunBG_shuai.png";
  4730. sunShinePath = "texture/Sun/sunShine2.png";
  4731. break;
  4732. default:
  4733. break;
  4734. }
  4735. this.sunEmoji.loadImage(emojiPath);
  4736. this.sunShine.loadImage(sunShinePath);
  4737. }
  4738. saveRiftInfo() {
  4739. this.riftInfo = [];
  4740. this.angleArr = [];
  4741. let angle2To3Arr_left = [150, 210];
  4742. let angle2To3Arr_right = [30, 330];
  4743. let angle2To3Arr = [angle2To3Arr_left, angle2To3Arr_right];
  4744. let angle4To6Arr_left = [120, 180, 240];
  4745. let angle4To6Arr_right = [0, 60, 300];
  4746. let angle4To6Arr = [];
  4747. let angle1 = 90;
  4748. let randomDir2 = Math.round(Math.random());
  4749. let randomIndex2 = Math.round(Math.random());
  4750. let randomIndex3 = Math.round(Math.random());
  4751. let angle2 = angle2To3Arr[randomDir2][randomIndex2];
  4752. let angle3 = angle2To3Arr[(randomDir2 + 1) % 2][randomIndex3];
  4753. angle4To6Arr_left.push(angle2To3Arr[randomDir2][(randomIndex2 + 1) % 2]);
  4754. angle4To6Arr_right.push(angle2To3Arr[(randomDir2 + 1) % 2][(randomIndex3 + 1) % 2]);
  4755. angle4To6Arr.push(angle4To6Arr_left, angle4To6Arr_right);
  4756. let randomDir4 = Math.round(Math.random());
  4757. let randomIndex4 = Math.floor(Math.random() * 4);
  4758. let angle4 = angle4To6Arr[randomDir4][randomIndex4];
  4759. let randomIndex5 = Math.floor(Math.random() * 4);
  4760. let angle5 = angle4To6Arr[(randomDir4 + 1) % 2][randomIndex5];
  4761. angle4To6Arr[(randomDir4 + 1) % 2].splice(randomIndex5, 1);
  4762. let randomIndex6 = Math.floor(Math.random() * 3);
  4763. let angle6 = angle4To6Arr[(randomDir4 + 1) % 2][randomIndex6];
  4764. this.angleArr.push(angle1, angle2, angle3, angle4, angle5, angle6);
  4765. this.riftInfo.length = this.angleArr.length;
  4766. let r = MainScene.sun.sunNode.width / 2;
  4767. for (let i = 0; i < this.angleArr.length; i++) {
  4768. let ariftInfo = {
  4769. "rotation": 0,
  4770. "pointX": 0,
  4771. "pointY": 0
  4772. };
  4773. let angle = this.angleArr[i];
  4774. let radian = Math.PI / 180 * angle;
  4775. let pointX = Math.cos(radian) * r;
  4776. let pointY = Math.sin(radian) * r;
  4777. ariftInfo.pointX = pointX;
  4778. ariftInfo.pointY = pointY;
  4779. let rotation = angle - 90;
  4780. if (rotation < 0) {
  4781. rotation += 360;
  4782. }
  4783. ariftInfo.rotation = rotation;
  4784. this.riftInfo[i] = ariftInfo;
  4785. }
  4786. }
  4787. getRiftInfo() {
  4788. let bloodPercentage = this.curBlood / this.totalBlood * 100;
  4789. let ariftInfo = {
  4790. "rotation": 0,
  4791. "pointX": 0,
  4792. "pointY": 0,
  4793. "riftUrl": "",
  4794. "bindRiftArrIndex": 0
  4795. };
  4796. let briftInfo;
  4797. if (bloodPercentage >= 90) {
  4798. return;
  4799. }
  4800. else if (bloodPercentage < 90 && bloodPercentage >= 80) {
  4801. ariftInfo.riftUrl = "texture/Effect/SunRift/Rift01_01.png";
  4802. ariftInfo.bindRiftArrIndex = 0;
  4803. briftInfo = this.riftInfo[0];
  4804. }
  4805. else if (bloodPercentage > 70) {
  4806. ariftInfo.riftUrl = "texture/Effect/SunRift/Rift02_01.png";
  4807. ariftInfo.bindRiftArrIndex = 1;
  4808. briftInfo = this.riftInfo[1];
  4809. }
  4810. else if (bloodPercentage > 60) {
  4811. ariftInfo.riftUrl = "texture/Effect/SunRift/Rift03_01.png";
  4812. ariftInfo.bindRiftArrIndex = 2;
  4813. briftInfo = this.riftInfo[2];
  4814. }
  4815. else if (bloodPercentage > 50) {
  4816. ariftInfo.riftUrl = "texture/Effect/SunRift/Rift01_02.png";
  4817. ariftInfo.bindRiftArrIndex = 0;
  4818. briftInfo = this.riftInfo[0];
  4819. }
  4820. else if (bloodPercentage > 45) {
  4821. ariftInfo.riftUrl = "texture/Effect/SunRift/Rift04.png";
  4822. ariftInfo.bindRiftArrIndex = 3;
  4823. briftInfo = this.riftInfo[3];
  4824. }
  4825. else if (bloodPercentage > 40) {
  4826. ariftInfo.riftUrl = "texture/Effect/SunRift/Rift03_02.png";
  4827. ariftInfo.bindRiftArrIndex = 2;
  4828. briftInfo = this.riftInfo[2];
  4829. }
  4830. else if (bloodPercentage > 30) {
  4831. ariftInfo.riftUrl = "texture/Effect/SunRift/Rift02_02.png";
  4832. ariftInfo.bindRiftArrIndex = 1;
  4833. briftInfo = this.riftInfo[1];
  4834. }
  4835. else if (bloodPercentage > 20) {
  4836. ariftInfo.riftUrl = "texture/Effect/SunRift/Rift05.png";
  4837. ariftInfo.bindRiftArrIndex = 4;
  4838. briftInfo = this.riftInfo[4];
  4839. }
  4840. else if (bloodPercentage > 15) {
  4841. ariftInfo.riftUrl = "texture/Effect/SunRift/Rift01_03.png";
  4842. ariftInfo.bindRiftArrIndex = 0;
  4843. briftInfo = this.riftInfo[0];
  4844. }
  4845. else if (bloodPercentage > 10) {
  4846. ariftInfo.riftUrl = "texture/Effect/SunRift/Rift06.png";
  4847. ariftInfo.bindRiftArrIndex = 5;
  4848. briftInfo = this.riftInfo[5];
  4849. }
  4850. else if (bloodPercentage > 5) {
  4851. ariftInfo.riftUrl = "texture/Effect/SunRift/Rift03_03.png";
  4852. ariftInfo.bindRiftArrIndex = 2;
  4853. briftInfo = this.riftInfo[2];
  4854. }
  4855. else {
  4856. ariftInfo.riftUrl = "texture/Effect/SunRift/Rift02_03.png";
  4857. ariftInfo.bindRiftArrIndex = 1;
  4858. briftInfo = this.riftInfo[1];
  4859. }
  4860. ariftInfo.pointX = briftInfo.pointX;
  4861. ariftInfo.pointY = briftInfo.pointY;
  4862. ariftInfo.rotation = briftInfo.rotation;
  4863. return ariftInfo;
  4864. }
  4865. addRift() {
  4866. let ariftInfo = this.getRiftInfo();
  4867. if (!ariftInfo)
  4868. return;
  4869. let rift = this.bindedRiftArr[ariftInfo.bindRiftArrIndex];
  4870. rift.texture = Laya.loader.getRes(ariftInfo.riftUrl);
  4871. let pivotX = rift.width / 2;
  4872. let pivotY = rift.height;
  4873. rift.pivotX = pivotX;
  4874. rift.pivotY = pivotY;
  4875. rift.pos(ariftInfo.pointX + this.RiftNode.width / 2, ariftInfo.pointY + this.RiftNode.height / 2);
  4876. rift.rotation = ariftInfo.rotation;
  4877. rift.visible = true;
  4878. }
  4879. clearRift() {
  4880. for (let i = 0; i < this.bindedRiftArr.length; i++) {
  4881. this.bindedRiftArr[i].removeSelf();
  4882. Laya.Pool.recover("Rift", this.bindedRiftArr[i]);
  4883. }
  4884. }
  4885. initRingAni() {
  4886. let sun = MainScene.sun;
  4887. if (!sun.ringAni_addBlood) {
  4888. sun.ringAni_addBlood = new Laya.Animation();
  4889. sun.ringAni_addBlood.loadAnimation("Animation/shoot_blood.ani");
  4890. sun.addChild(sun.ringAni_addBlood);
  4891. sun.ringAni_addBlood.pos(sun.sunNode.x, sun.sunNode.y);
  4892. sun.ringAni_addBlood.visible = false;
  4893. }
  4894. if (!sun.ringAni_fast) {
  4895. sun.ringAni_fast = new Laya.Animation();
  4896. sun.ringAni_fast.loadAnimation("Animation/shoot_blood.ani");
  4897. sun.addChild(sun.ringAni_fast);
  4898. sun.ringAni_fast.pos(sun.sunNode.x, sun.sunNode.y);
  4899. sun.ringAni_fast.visible = false;
  4900. }
  4901. }
  4902. gameover_clearAnimation() {
  4903. MainScene.sun.ringAni_addBlood.visible = false;
  4904. MainScene.sun.ringAni_fast.visible = false;
  4905. }
  4906. playRingAniFast(aniName, loop) {
  4907. if (!MainScene.gameControl.isStartGame)
  4908. return;
  4909. this.ringAni_fast.visible = true;
  4910. this.ringAni_fast.play(0, loop, aniName);
  4911. }
  4912. stopShieldAni() {
  4913. SkeletonControl.clearSheildAni();
  4914. }
  4915. }
  4916. class MyConsts {
  4917. }
  4918. MyConsts.treeThorough = 20;
  4919. MyConsts.knifeToSunCenter = 150;
  4920. MyConsts.animationName = {
  4921. "addBlood": "blood",
  4922. "fast": "fast",
  4923. };
  4924. MyConsts.imgPath = {
  4925. "iconPlus": "res/atlas/texture/Effect/Planet_Mercury.png",
  4926. "iconFast": "res/atlas/texture/Effect/Planet_Saturn.png",
  4927. };
  4928. MyConsts.growSystemGradeLimit = {
  4929. "knifeNum": 50,
  4930. "knifeAttack": 500,
  4931. "critChance": 150,
  4932. "critAttack": 50,
  4933. "coinValue": 500,
  4934. "coinProfit": 999
  4935. };
  4936. class Knife extends Laya.Sprite {
  4937. constructor() {
  4938. super();
  4939. this.isBindSun = false;
  4940. this.attack = 0;
  4941. this.attackInit = 0;
  4942. this.bindToSunTween = null;
  4943. this.isInvincible = false;
  4944. this.isBindToPlanet = false;
  4945. this.textID = new Laya.Text();
  4946. this.textID.color = "#ffff00";
  4947. this.textID.fontSize = 30;
  4948. this.textID.bold = true;
  4949. this.textID.stroke = 2;
  4950. this.textID.strokeColor = "#ffffff";
  4951. this.textID.pos(28, 150);
  4952. this.textID.visible = false;
  4953. this.knifeImg = new Laya.Sprite();
  4954. this.addChild(this.knifeImg);
  4955. this.knifeID = Laya.Browser.now() + "" + Math.floor(Math.random() * 1000);
  4956. let str = this.knifeID ? this.knifeID : "nnnnull";
  4957. str = str.substr(str.length - 5, 5);
  4958. this.textID.text = str;
  4959. }
  4960. init() {
  4961. this.isBindSun = false;
  4962. this.rotation = 0;
  4963. this.knifeImg.texture = Laya.loader.getRes("texture/GameScene/rocket.png");
  4964. this.attack = this.attackInit = MainScene.gameControl.knifeInfo.knifeAttack;
  4965. this.isBindToPlanet = false;
  4966. this.width = this.knifeImg.width;
  4967. this.height = this.knifeImg.height;
  4968. this.addChild(this.textID);
  4969. this.knifeImg.alpha = 1;
  4970. this.knifeImg.pos(0, 0);
  4971. this.alpha = 1;
  4972. }
  4973. knifeBindToSun() {
  4974. if (this.isBindSun == false) {
  4975. let gameControl = MainScene.gameControl;
  4976. let num1 = 0;
  4977. let tp = new Laya.Point(MainScene.sun.sunNode.x, MainScene.sun.sunNode.y + MyConsts.knifeToSunCenter);
  4978. tp = MainScene.sun.localToGlobal(tp);
  4979. tp = MainScene.instance.KnifeBox.globalToLocal(tp);
  4980. this.bindToSunTween = Laya.Tween.to(this, { y: tp.y - num1 }, 50, Laya.Ease.linearIn, Laya.Handler.create(this, function () {
  4981. this.isBindSun = true;
  4982. let par = this.parent ? this.parent.name : "noParent";
  4983. if (this.isBindToPlanet) {
  4984. this.stopTweenToSun(this);
  4985. return;
  4986. }
  4987. MusicControl.knifeAttackSun();
  4988. let bcollision = false;
  4989. bcollision = this.checkCollision_knife(this);
  4990. if (bcollision)
  4991. return;
  4992. bcollision = this.checkCollision_tree(this);
  4993. if (bcollision)
  4994. return;
  4995. let knifeP = new Laya.Point(this.x, this.y);
  4996. knifeP = MainScene.instance.KnifeBox.localToGlobal(knifeP);
  4997. knifeP = MainScene.sun.knifeNode.globalToLocal(knifeP);
  4998. MainScene.sun.knifeNode.addChild(this);
  4999. this.pos(knifeP.x, knifeP.y);
  5000. this.rotation = -MainScene.sun.sunAndKnifeNode.rotation;
  5001. let effectPoint = MainScene.sun.minSunPoint;
  5002. if (MainScene.sun.shieldBlood <= 0) {
  5003. AnimationControl.sunLiquidAni(this, Laya.stage, effectPoint.x, effectPoint.y);
  5004. }
  5005. gameControl.curKnifeArrivedSun(this);
  5006. let percent = MainScene.sun.getPercentOfBlood();
  5007. if (gameControl.isStartGame) {
  5008. if (percent > 0.5) {
  5009. MainScene.sun.switchEmoji(1);
  5010. }
  5011. else if (percent > 0.2) {
  5012. MainScene.sun.switchEmoji(2);
  5013. }
  5014. else if (percent > 0) {
  5015. MainScene.sun.switchEmoji(4);
  5016. }
  5017. gameControl.attackSunTime = Laya.Browser.now();
  5018. }
  5019. if (this.fireAni) {
  5020. this.fireAni.visible = false;
  5021. }
  5022. if (this.isInvincible) {
  5023. AnimationControl.screenShake(3);
  5024. }
  5025. else {
  5026. AnimationControl.screenShake(1);
  5027. }
  5028. let par2 = this.parent ? this.parent.name : "noParent";
  5029. }));
  5030. Laya.timer.loop(1, this, this.checkCollision_outerPlanet, [this]);
  5031. Laya.timer.loop(1, this, this.checkCollision_innerPlanet, [this]);
  5032. Laya.timer.loop(1, this, this.checkCollision_knife, [this]);
  5033. Laya.timer.loop(1, this, this.checkCollision_tree, [this]);
  5034. }
  5035. }
  5036. stopTweenToSun(knife) {
  5037. Laya.Tween.clear(knife.bindToSunTween);
  5038. }
  5039. playKnifeBounceAni() {
  5040. Laya.Tween.to(this, { x: 1000, y: 1500, rotation: 360 }, 200);
  5041. }
  5042. updateTexture() {
  5043. let imgPath = "";
  5044. if (this.isInvincible) {
  5045. imgPath = "texture/GameScene/invincibleRocket.png";
  5046. }
  5047. else {
  5048. imgPath = "texture/GameScene/rocket.png";
  5049. }
  5050. this.knifeImg.loadImage(imgPath);
  5051. this.width = this.knifeImg.width;
  5052. this.height = this.knifeImg.height;
  5053. this.pivotX = this.width / 2;
  5054. if (this.fireAni) {
  5055. let posX = this.width / 2 - 5;
  5056. let posY = this.height - 8;
  5057. this.fireAni.pos(posX, posY);
  5058. }
  5059. }
  5060. checkCollision_knife(curKnife) {
  5061. let gameControl = MainScene.gameControl;
  5062. if (!gameControl.isStartGame) {
  5063. this.clearCheckCollision();
  5064. this.removeSelf();
  5065. Laya.Pool.recover("Knife", this);
  5066. return;
  5067. }
  5068. let sun = MainScene.sun.sunAndKnifeNode;
  5069. if (curKnife.y > gameControl.minKnifeY)
  5070. return;
  5071. if (gameControl.bindToSunKnifeArr.length < 1)
  5072. return;
  5073. for (let i = 0; i < gameControl.bindToSunKnifeArr.length; i++) {
  5074. let targetCheckKnife = gameControl.bindToSunKnifeArr[i];
  5075. let targetKnifeRotation = (sun.rotation + targetCheckKnife.rotation) % 360;
  5076. let collisionAngle = 10;
  5077. if ((targetKnifeRotation >= -collisionAngle && targetKnifeRotation <= collisionAngle)
  5078. || (targetKnifeRotation >= (360 - collisionAngle))
  5079. || (targetKnifeRotation <= -360 + collisionAngle)) {
  5080. if (curKnife.isInvincible) {
  5081. return;
  5082. }
  5083. else {
  5084. MusicControl.hitObstacle();
  5085. this.clearCheckCollision();
  5086. curKnife.stopTweenToSun(curKnife);
  5087. curKnife.playKnifeBounceAni();
  5088. let type = 0;
  5089. if (targetCheckKnife.isInvincible)
  5090. type = 1;
  5091. gameControl.stopGame();
  5092. AnimationControl.knifeABumpedObjB(targetCheckKnife, type, function () {
  5093. MainScene.gameControl.levelFailed();
  5094. MainScene.instance.gameOverUI.defeatReason.text = "失败原因:火箭与太阳上的火箭发生了碰撞";
  5095. });
  5096. return true;
  5097. }
  5098. }
  5099. }
  5100. }
  5101. checkCollision_tree(curKnife) {
  5102. let gameControl = MainScene.gameControl;
  5103. if (!gameControl.isStartGame) {
  5104. this.clearCheckCollision();
  5105. this.removeSelf();
  5106. Laya.Pool.recover("Knife", this);
  5107. return;
  5108. }
  5109. let sun = MainScene.sun.sunAndKnifeNode;
  5110. if (curKnife.y > gameControl.minKnifeY)
  5111. return;
  5112. if (gameControl.bindToSunTreeArr.length < 1)
  5113. return;
  5114. for (let i = 0; i < gameControl.bindToSunTreeArr.length; i++) {
  5115. let targetCheckTree = gameControl.bindToSunTreeArr[i];
  5116. let targetTreeRotation = (sun.rotation + targetCheckTree.rotation) % 360;
  5117. let collisionAngle = 10;
  5118. if ((targetTreeRotation >= -collisionAngle && targetTreeRotation <= collisionAngle)
  5119. || (targetTreeRotation <= 360 && targetTreeRotation >= (360 - collisionAngle))
  5120. || (targetTreeRotation <= (-360 + collisionAngle) && targetTreeRotation >= -360)) {
  5121. if (curKnife.isInvincible) {
  5122. targetCheckTree.removeSelf();
  5123. Laya.Pool.recover("Tree", targetCheckTree);
  5124. MainScene.gameControl.bindToSunTreeArr.splice(i, 1);
  5125. return;
  5126. }
  5127. else {
  5128. MusicControl.hitObstacle();
  5129. this.clearCheckCollision();
  5130. if (MainScene.sun.sunRotateDirection == -1) {
  5131. }
  5132. curKnife.stopTweenToSun(curKnife);
  5133. curKnife.playKnifeBounceAni();
  5134. gameControl.stopGame();
  5135. AnimationControl.knifeABumpedObjB(targetCheckTree, 2, function () {
  5136. MainScene.gameControl.levelFailed();
  5137. MainScene.instance.gameOverUI.defeatReason.text = "失败原因:火箭与太阳上的禁牌发生了碰撞";
  5138. });
  5139. return true;
  5140. }
  5141. }
  5142. }
  5143. }
  5144. checkCollision_innerPlanet(curKnife) {
  5145. let gameControl = MainScene.gameControl;
  5146. if (!MainScene.gameControl.isStartGame) {
  5147. this.clearCheckCollision();
  5148. this.removeSelf();
  5149. Laya.Pool.recover("Knife", this);
  5150. return;
  5151. }
  5152. if (curKnife.y > gameControl.minInnerY)
  5153. return;
  5154. if (gameControl.innerPlanets.length < 1)
  5155. return;
  5156. for (let i = 0; i < gameControl.innerPlanets.length; i++) {
  5157. let targetCheckPlanet = gameControl.innerPlanets[i];
  5158. let targetPlanetRotation = targetCheckPlanet.angle;
  5159. if ((targetPlanetRotation >= 80 && targetPlanetRotation <= 100)
  5160. || (targetPlanetRotation >= -280 && targetPlanetRotation <= -260)) {
  5161. this.clearCheckCollision();
  5162. let r = 60;
  5163. let global_planetPoint = targetCheckPlanet.localToGlobal(new Laya.Point(0, 0));
  5164. let x_D_value = Laya.stage.width / 2 - global_planetPoint.x;
  5165. let x_D_abs = Math.abs(x_D_value);
  5166. let riftPos = [Laya.stage.width / 2, 0];
  5167. if (x_D_abs == 0) {
  5168. riftPos[1] = gameControl.minInnerY;
  5169. }
  5170. else {
  5171. let y_pow_2 = Math.pow(r, 2) - Math.pow(x_D_abs, 2);
  5172. let y = Math.sqrt(y_pow_2);
  5173. riftPos[1] = global_planetPoint.y + y;
  5174. if (targetCheckPlanet.planetType == 4) {
  5175. riftPos[0] += 5;
  5176. riftPos[1] -= 10;
  5177. }
  5178. }
  5179. let riftPoint = targetCheckPlanet.planetImg.globalToLocal(new Laya.Point(riftPos[0], riftPos[1]));
  5180. let sinA = x_D_value / r;
  5181. let radianA = Math.asin(sinA);
  5182. let angleA = radianA * (180 / Math.PI);
  5183. curKnife.isBindToPlanet = true;
  5184. curKnife.stopTweenToSun(curKnife);
  5185. targetCheckPlanet.planetImg.addChild(curKnife);
  5186. curKnife.pos(riftPoint.x, riftPoint.y);
  5187. curKnife.rotation = -targetCheckPlanet.planetImg.rotation;
  5188. Laya.Tween.to(curKnife.knifeImg, { alpha: 0 }, 500);
  5189. Laya.timer.once(500, gameControl, function () {
  5190. curKnife.alpha = 0;
  5191. curKnife.removeSelf();
  5192. Laya.Pool.recover("Knife", curKnife);
  5193. }, [curKnife]);
  5194. if (curKnife.fireAni) {
  5195. curKnife.fireAni.visible = false;
  5196. }
  5197. curKnife.knifeImg.y -= 20;
  5198. if (gameControl.knifeRestNum > 0 || gameControl.propInvincibleRocketNum > 0) {
  5199. }
  5200. else {
  5201. gameControl.levelFailed();
  5202. MainScene.instance.gameOverUI.defeatReason.text = "失败原因:火箭已用完";
  5203. }
  5204. targetCheckPlanet.onPlanetHit();
  5205. let pos = [0, -43];
  5206. let knifeAttack = gameControl.checkKnifeCrit(curKnife, targetCheckPlanet.planetNode, pos, 0.5);
  5207. targetCheckPlanet.subBlood(knifeAttack);
  5208. let isAlive = targetCheckPlanet.checkBlood();
  5209. if (!isAlive) {
  5210. let fun = function () {
  5211. targetCheckPlanet.removeSelf();
  5212. Laya.Pool.recover("Planet", targetCheckPlanet);
  5213. Laya.timer.clear(targetCheckPlanet, targetCheckPlanet.rotate);
  5214. };
  5215. MainScene.gameControl.innerPlanets.splice(i, 1);
  5216. targetCheckPlanet.die(fun, 0);
  5217. let addCoinNum = 1.5 * 2 * (Math.pow(MainScene.gameControl.curLevel, 2) + 2 * MainScene.gameControl.curLevel + MainScene.gameControl.coinInfo.coinValue);
  5218. MainScene.gameControl.coinNumFromCurLevel += Math.floor(addCoinNum);
  5219. MainScene.gameControl.updateGameUI();
  5220. }
  5221. return;
  5222. }
  5223. }
  5224. }
  5225. checkCollision_outerPlanet(curKnife) {
  5226. let gameControl = MainScene.gameControl;
  5227. if (!gameControl.isStartGame) {
  5228. this.clearCheckCollision();
  5229. this.removeSelf();
  5230. Laya.Pool.recover("Knife", this);
  5231. return;
  5232. }
  5233. let targetOuterPlanetMinY = MainScene.sun.sunNode.y + MainScene.sun.planetOuterRing.height / 2 + 43;
  5234. if (curKnife.y > gameControl.minOuterY)
  5235. return;
  5236. if (gameControl.outerPlanets.length < 1)
  5237. return;
  5238. for (let i = 0; i < gameControl.outerPlanets.length; i++) {
  5239. let targetCheckPlanet = gameControl.outerPlanets[i];
  5240. let targetPlanetRotation = targetCheckPlanet.angle;
  5241. if ((targetPlanetRotation >= 80 && targetPlanetRotation <= 100)
  5242. || (targetPlanetRotation >= -280 && targetPlanetRotation <= -260)) {
  5243. this.clearCheckCollision();
  5244. let r = 60;
  5245. let global_planetPoint = targetCheckPlanet.localToGlobal(new Laya.Point(0, 0));
  5246. let x_D_value = Laya.stage.width / 2 - global_planetPoint.x;
  5247. let x_D_abs = Math.abs(x_D_value);
  5248. let riftPos = [Laya.stage.width / 2, 0];
  5249. if (x_D_abs == 0) {
  5250. riftPos[1] = gameControl.minInnerY;
  5251. }
  5252. else {
  5253. let y_pow_2 = Math.pow(r, 2) - Math.pow(x_D_abs, 2);
  5254. let y = Math.sqrt(y_pow_2);
  5255. riftPos[1] = global_planetPoint.y + y;
  5256. if (targetCheckPlanet.planetType == 4) {
  5257. riftPos[0] += 5;
  5258. riftPos[1] -= 10;
  5259. }
  5260. }
  5261. let riftPoint = targetCheckPlanet.planetImg.globalToLocal(new Laya.Point(riftPos[0], riftPos[1]));
  5262. let sinA = x_D_value / r;
  5263. let radianA = Math.asin(sinA);
  5264. let angleA = radianA * (180 / Math.PI);
  5265. curKnife.isBindToPlanet = true;
  5266. curKnife.stopTweenToSun(curKnife);
  5267. targetCheckPlanet.planetImg.addChild(curKnife);
  5268. curKnife.pos(riftPoint.x, riftPoint.y);
  5269. curKnife.rotation = -targetCheckPlanet.planetImg.rotation;
  5270. Laya.Tween.to(curKnife.knifeImg, { alpha: 0 }, 500);
  5271. Laya.timer.once(500, gameControl, function () {
  5272. curKnife.alpha = 0;
  5273. curKnife.removeSelf();
  5274. Laya.Pool.recover("Knife", curKnife);
  5275. }, [curKnife]);
  5276. if (curKnife.fireAni) {
  5277. curKnife.fireAni.visible = false;
  5278. }
  5279. curKnife.knifeImg.y -= 20;
  5280. if (gameControl.knifeRestNum > 0 || gameControl.propInvincibleRocketNum > 0) {
  5281. }
  5282. else {
  5283. gameControl.levelFailed();
  5284. MainScene.instance.gameOverUI.defeatReason.text = "失败原因:火箭已用完";
  5285. }
  5286. targetCheckPlanet.onPlanetHit();
  5287. let pos = [0, -43];
  5288. let knifeAttack = gameControl.checkKnifeCrit(curKnife, targetCheckPlanet.planetNode, pos, 0.5);
  5289. targetCheckPlanet.subBlood(knifeAttack);
  5290. let isAlive = targetCheckPlanet.checkBlood();
  5291. if (!isAlive) {
  5292. let fun = function () {
  5293. targetCheckPlanet.removeSelf();
  5294. Laya.Pool.recover("Planet", targetCheckPlanet);
  5295. Laya.timer.clear(targetCheckPlanet, targetCheckPlanet.rotate);
  5296. };
  5297. MainScene.gameControl.outerPlanets.splice(i, 1);
  5298. targetCheckPlanet.die(fun, 0);
  5299. let addCoinNum = 1.5 * 2 * (Math.pow(MainScene.gameControl.curLevel, 2) + 2 * MainScene.gameControl.curLevel + MainScene.gameControl.coinInfo.coinValue);
  5300. MainScene.gameControl.coinNumFromCurLevel += Math.floor(addCoinNum);
  5301. MainScene.gameControl.updateGameUI();
  5302. }
  5303. return;
  5304. }
  5305. }
  5306. }
  5307. clearCheckCollision() {
  5308. Laya.timer.clear(this, this.checkCollision_innerPlanet);
  5309. Laya.timer.clear(this, this.checkCollision_outerPlanet);
  5310. Laya.timer.clear(this, this.checkCollision_knife);
  5311. Laya.timer.clear(this, this.checkCollision_tree);
  5312. }
  5313. }
  5314. class Tree extends Laya.Sprite {
  5315. constructor() {
  5316. super();
  5317. this.init();
  5318. }
  5319. init() {
  5320. this.rotation = 0;
  5321. this.texture = Laya.loader.getRes("texture/GameScene/obstacle.png");
  5322. this.width = this.texture.width;
  5323. this.height = this.texture.height;
  5324. this.pivotX = this.width / 2;
  5325. this.x = 0;
  5326. this.y = 0;
  5327. this.textID_tree = new Laya.Text();
  5328. this.textID_tree.color = "#FF0000";
  5329. this.textID_tree.fontSize = 30;
  5330. this.textID_tree.bold = true;
  5331. this.textID_tree.stroke = 2;
  5332. this.textID_tree.strokeColor = "#ffffff";
  5333. this.textID_tree.pos(this.width / 2, this.height / 2);
  5334. this.addChild(this.textID_tree);
  5335. this.textID_tree.visible = false;
  5336. }
  5337. }
  5338. class MyDispatcher {
  5339. constructor() {
  5340. }
  5341. }
  5342. MyDispatcher.eventDispatcher = new Laya.EventDispatcher();
  5343. MyDispatcher.Emit = function (InName, agv) {
  5344. MyDispatcher.eventDispatcher.event(InName, agv);
  5345. };
  5346. MyDispatcher.AddNotice = function (InName, caller, listener, arg) {
  5347. MyDispatcher.eventDispatcher.on(InName, caller, listener, (arg == null) ? null : ([arg]));
  5348. };
  5349. MyDispatcher.RemoveNotice = function (InName, caller, listener) {
  5350. MyDispatcher.eventDispatcher.off(InName, caller, listener);
  5351. };
  5352. class Planet extends Laya.Box {
  5353. constructor() {
  5354. super();
  5355. this.angle = 0;
  5356. this.radian = 0;
  5357. this.planetBreatheTime = 0;
  5358. this.skillCountDownTime = 0;
  5359. this.bindedRiftArr = [];
  5360. this.planetNode = new Laya.Box();
  5361. this.planetImg = new Laya.Sprite();
  5362. this.iconSkillNode = new Laya.Box();
  5363. this.addChild(this.planetNode);
  5364. this.planetNode.addChild(this.planetImg);
  5365. this.addChild(this.iconSkillNode);
  5366. this.textID = new Laya.Text();
  5367. this.textID.color = "#FF0000";
  5368. this.textID.fontSize = 30;
  5369. this.textID.bold = true;
  5370. this.textID.stroke = 2;
  5371. this.textID.strokeColor = "#ffffff";
  5372. this.textID.visible = false;
  5373. }
  5374. planetInit() {
  5375. if (this.bindedRiftArr.length > 0) {
  5376. let arrLength = this.bindedRiftArr.length;
  5377. for (let i = 0; i < arrLength; i++) {
  5378. let rift = this.bindedRiftArr[0];
  5379. rift.removeSelf();
  5380. this.bindedRiftArr.splice(0, 1);
  5381. }
  5382. }
  5383. let random = Math.floor(Math.random() * 10000);
  5384. this.planetID = Laya.Browser.now() + random;
  5385. this.dieNotice = this.planetID + "Die";
  5386. console.log("行星初始化,type==", this.planetType, "dieNotice===", this.dieNotice, "轨道", this.orbit);
  5387. this.hitNotice = this.planetID + "Hit";
  5388. this.planetImg.rotation = 0;
  5389. this.planetImg.alpha = 1;
  5390. this.planetImg.scale(1, 1);
  5391. let date = new Date();
  5392. this.addChild(this.textID);
  5393. Laya.timer.frameLoop(1, this, function () {
  5394. if (this.textID) {
  5395. this.textID.text = Math.floor(this.angle);
  5396. }
  5397. });
  5398. switch (this.planetType) {
  5399. case 0:
  5400. this.init_Mercury();
  5401. break;
  5402. case 1:
  5403. this.init_Venus();
  5404. break;
  5405. case 2:
  5406. this.init_Mars();
  5407. break;
  5408. case 3:
  5409. this.init_Jupiter();
  5410. break;
  5411. case 4:
  5412. this.init_Saturn();
  5413. break;
  5414. default:
  5415. break;
  5416. }
  5417. this.planetImg.pivotX = this.planetImg.width / 2;
  5418. this.planetImg.pivotY = this.planetImg.height / 2;
  5419. this.revolveCenter = [MainScene.sun.planetInnerRing.x, MainScene.sun.planetInnerRing.y];
  5420. this.lastTime = Laya.Browser.now();
  5421. Laya.timer.frameLoop(1, this, this.Revolve);
  5422. this.selfRotateSpeed = 1;
  5423. this.selfRotateDirection = 1;
  5424. if (this.orbit == 0) {
  5425. this.revolveSpeed = this.revolveSpeedInner;
  5426. }
  5427. else {
  5428. this.revolveSpeed = this.revolveSpeedOuter;
  5429. }
  5430. this.revolveSpeedInit = this.revolveSpeed;
  5431. this.planetBreatheTime = 2000;
  5432. }
  5433. init_Mercury() {
  5434. this.blood = MainScene.sun.totalBlood * (1 / 15);
  5435. this.planetImg.loadImage("texture/Planet/Mercury.png");
  5436. let skillPath = "res/atlas/texture/Effect/Planet_Mercury.png";
  5437. let pos = [20, -10];
  5438. this.addSkillImg(skillPath, pos);
  5439. let aMercurySkill = function () {
  5440. if (!MainScene.gameControl.isStartGame) {
  5441. return;
  5442. }
  5443. let sun = MainScene.sun;
  5444. let sunCurBlood = sun.curBlood;
  5445. let sunTotalBlood = sun.totalBlood;
  5446. let addNum = 5 * MainScene.gameControl.curLevel;
  5447. if (sunCurBlood < sunTotalBlood && sunCurBlood > 0) {
  5448. if (sunCurBlood + addNum > sunTotalBlood) {
  5449. addNum = sunTotalBlood - sunCurBlood;
  5450. }
  5451. sun.addBlood(addNum);
  5452. AnimationControl.playIconPlusAni(this, MyConsts.imgPath.iconPlus);
  5453. Laya.timer.once(1000, this, function () {
  5454. if (!MainScene.gameControl.isStartGame) {
  5455. return;
  5456. }
  5457. SkeletonControl.playAddBloodAni();
  5458. AnimationControl.playAddBloodNumAni(addNum);
  5459. });
  5460. }
  5461. };
  5462. Laya.timer.loop(3000, this, aMercurySkill);
  5463. let MercuryDie = function () {
  5464. Laya.timer.clear(this, aMercurySkill);
  5465. MyDispatcher.RemoveNotice(this.dieNotice, this, MercuryDie);
  5466. };
  5467. MyDispatcher.AddNotice(this.dieNotice, this, MercuryDie, null);
  5468. this.revolveSpeedInner = 2 * Math.PI / 5 / 1000;
  5469. this.revolveSpeedOuter = 2 * Math.PI / 8 / 1000;
  5470. }
  5471. init_Venus() {
  5472. this.blood = MainScene.sun.totalBlood * (1 / 20);
  5473. this.planetImg.loadImage("texture/Planet/Venus.png");
  5474. let VenusDie = function () {
  5475. MyDispatcher.RemoveNotice(this.dieNotice, this, VenusDie);
  5476. if (!MainScene.gameControl.isStartGame)
  5477. return;
  5478. MainScene.sun.addShield(MainScene.sun.totalBlood * 0.2);
  5479. Laya.timer.once(250, this, function () {
  5480. SkeletonControl.playAddShieldAni(this);
  5481. });
  5482. };
  5483. MyDispatcher.AddNotice(this.dieNotice, this, VenusDie, null);
  5484. this.revolveSpeedInner = 2 * Math.PI / 8 / 1000;
  5485. this.revolveSpeedOuter = 2 * Math.PI / 10 / 1000;
  5486. }
  5487. init_Mars() {
  5488. this.blood = MainScene.sun.totalBlood * (1 / 7);
  5489. this.planetImg.loadImage("texture/Planet/Mars.png");
  5490. let MarsDie = function () {
  5491. MyDispatcher.RemoveNotice(this.dieNotice, this, MarsDie);
  5492. MyDispatcher.RemoveNotice(this.hitNotice, this, MarsHit);
  5493. if (!MainScene.gameControl.isStartGame)
  5494. return;
  5495. Laya.timer.once(250, this, function () {
  5496. AnimationControl.planetFireball(this, "res/atlas/texture/Effect/Planet_Mars/fireball.atlas");
  5497. let num = Math.ceil(MainScene.gameControl.bindToSunKnifeArr.length / 2);
  5498. MainScene.gameControl.removeKnifeFromSun(num);
  5499. });
  5500. };
  5501. MyDispatcher.AddNotice(this.dieNotice, this, MarsDie, null);
  5502. let MarsHit = function () {
  5503. let num = 1;
  5504. MainScene.gameControl.removeTreeFromSun(num);
  5505. };
  5506. MyDispatcher.AddNotice(this.hitNotice, this, MarsHit, null);
  5507. this.revolveSpeedInner = 2 * Math.PI / 4 / 1000;
  5508. this.revolveSpeedOuter = 2 * Math.PI / 6 / 1000;
  5509. }
  5510. init_Jupiter() {
  5511. this.blood = MainScene.sun.totalBlood * (1 / 10);
  5512. this.planetImg.loadImage("texture/Planet/Jupiter.png");
  5513. let skillPath = "res/atlas/texture/Planet/other.png";
  5514. let pos = [-50, 20];
  5515. this.addSkillImg(skillPath, pos);
  5516. this.skillCountDownTime = 0;
  5517. Laya.timer.loop(100, this, this.timerJupiterSkill);
  5518. let JupiterDie = function () {
  5519. MyDispatcher.RemoveNotice(this.dieNotice, this, JupiterDie);
  5520. Laya.timer.clear(this, this.timerJupiterSkill);
  5521. };
  5522. MyDispatcher.AddNotice(this.dieNotice, this, JupiterDie, null);
  5523. this.revolveSpeedInner = 2 * Math.PI / 5 / 1000;
  5524. this.revolveSpeedOuter = 2 * Math.PI / 8 / 1000;
  5525. }
  5526. init_Saturn() {
  5527. this.blood = MainScene.sun.totalBlood * (1 / 10);
  5528. this.planetImg.loadImage("texture/Planet/Saturn.png");
  5529. let skillPath = "res/atlas/texture/Effect/Planet_Saturn.png";
  5530. let pos = [15, 5];
  5531. this.addSkillImg(skillPath, pos);
  5532. this.iconPlanetSkill.width = 72 * 0.6;
  5533. this.iconPlanetSkill.height = 102 * 0.6;
  5534. let SaturnSkillStartTime = Laya.Browser.now() / 1000;
  5535. let aSaturnSkill = function () {
  5536. let resetSpeed = function () {
  5537. MainScene.gameControl.SaturnSkillTag = 0;
  5538. let slowDownTag = MainScene.gameControl.slowDownTag;
  5539. switch (slowDownTag) {
  5540. case 0:
  5541. MainScene.sun.sunRotateSpeed = MainScene.sun.sunRotateSpeedInit;
  5542. break;
  5543. case 1:
  5544. MainScene.sun.sunRotateSpeed = 10;
  5545. break;
  5546. default:
  5547. break;
  5548. }
  5549. };
  5550. if (!MainScene.gameControl.isStartGame) {
  5551. return;
  5552. }
  5553. if (MainScene.gameControl.SaturnSkillTag == 1) {
  5554. return;
  5555. }
  5556. MainScene.sun.sunRotateSpeed = MainScene.sun.sunRotateSpeed * 0.5;
  5557. MainScene.gameControl.SaturnSkillTag = 1;
  5558. let skillTime = 4000;
  5559. let effectTag = 0;
  5560. let effectTime = 0;
  5561. for (let i = 0; i < 3; i++) {
  5562. effectTime = 4000 / 3 * i;
  5563. Laya.timer.once(effectTime, this, function () {
  5564. if (!MainScene.gameControl.isStartGame)
  5565. return;
  5566. AnimationControl.playIconPlusAni(this, MyConsts.imgPath.iconFast);
  5567. Laya.timer.once(600, this, function () {
  5568. if (!MainScene.gameControl.isStartGame) {
  5569. return;
  5570. }
  5571. MainScene.sun.playRingAniFast(MyConsts.animationName.fast, false);
  5572. });
  5573. });
  5574. }
  5575. Laya.timer.once(skillTime, this, resetSpeed);
  5576. };
  5577. Laya.timer.loop(12000, this, aSaturnSkill);
  5578. let SaturnDie = function () {
  5579. Laya.timer.clear(this, aSaturnSkill);
  5580. MyDispatcher.RemoveNotice(this.dieNotice, this, SaturnDie);
  5581. MyDispatcher.RemoveNotice(this.hitNotice, this, SaturnHit);
  5582. MainScene.gameControl.SaturnSkillTag = 0;
  5583. };
  5584. MyDispatcher.AddNotice(this.dieNotice, this, SaturnDie, null);
  5585. let SaturnHit = function () {
  5586. MainScene.sun.sunRotateDirection = -MainScene.sun.sunRotateDirection;
  5587. };
  5588. MyDispatcher.AddNotice(this.hitNotice, this, SaturnHit, null);
  5589. this.revolveSpeedInner = 2 * Math.PI / 8 / 1000;
  5590. this.revolveSpeedOuter = 2 * Math.PI / 10 / 1000;
  5591. }
  5592. timerJupiterSkill() {
  5593. if (!MainScene.gameControl.isStartGame) {
  5594. return;
  5595. }
  5596. this.skillCountDownTime += 100;
  5597. if (this.skillCountDownTime >= 10000) {
  5598. let gameControl = MainScene.gameControl;
  5599. if (gameControl.bindToSunTreeArr.length >= 24)
  5600. return;
  5601. let aa = 15 * 3 / 2;
  5602. let JupiterAngle = this.angle;
  5603. let min = MathTool.angleBePositive(JupiterAngle - aa);
  5604. let max = MathTool.angleBePositive(JupiterAngle + aa);
  5605. let range = [min, max];
  5606. let sunRotation = MathTool.angleBePositive(MainScene.sun.sunAndKnifeNode.rotation);
  5607. let existingRotationArr = gameControl.getTreeExistingRotation();
  5608. let blankPoints = gameControl.getAllBlankPoints(gameControl.allTreePoints, existingRotationArr);
  5609. let blankPointClosest = this.getClosestPointFromArr(JupiterAngle, blankPoints);
  5610. if (blankPointClosest) {
  5611. let treeRotation = MathTool.angleBePositive(blankPointClosest.rotation);
  5612. let arrAngle = sunRotation + treeRotation + 90;
  5613. arrAngle = MathTool.angleBePositive(arrAngle);
  5614. let b = MathTool.checkAngleIsInRange(arrAngle, range);
  5615. if (b) {
  5616. this.skillCountDownTime = 0;
  5617. gameControl.addTree(blankPointClosest);
  5618. }
  5619. }
  5620. }
  5621. }
  5622. getClosestPointFromArr(numA, pointArr) {
  5623. let DValue = 360;
  5624. let point = {
  5625. "x": 0,
  5626. "y": 0,
  5627. "rotation": 0
  5628. };
  5629. let anumA = MathTool.angleBePositive(numA);
  5630. let sunRotation = MathTool.angleBePositive(MainScene.sun.sunAndKnifeNode.rotation);
  5631. for (let i = 0; i < pointArr.length; i++) {
  5632. let apoint = pointArr[i];
  5633. let treeRotation = MathTool.angleBePositive(apoint.rotation);
  5634. let arrAngle = sunRotation + treeRotation + 90;
  5635. arrAngle = MathTool.angleBePositive(arrAngle);
  5636. let aa = Math.abs(arrAngle - anumA);
  5637. if (aa < DValue) {
  5638. DValue = aa;
  5639. point.x = apoint.x;
  5640. point.y = apoint.y;
  5641. point.rotation = apoint.rotation;
  5642. }
  5643. }
  5644. return point;
  5645. }
  5646. addSkillImg(imgPath, pos) {
  5647. this.iconPlanetSkill = new Laya.Sprite();
  5648. this.iconPlanetSkill.loadImage(imgPath);
  5649. this.iconSkillNode.addChild(this.iconPlanetSkill);
  5650. this.iconPlanetSkill.pos(pos[0], pos[1]);
  5651. }
  5652. planetBreathe() {
  5653. Laya.Tween.to(this, { scaleX: 0.8, scaleY: 0.8 }, this.planetBreatheTime / 2, Laya.Ease.linearIn, Laya.Handler.create(this, function () {
  5654. Laya.Tween.to(this, { scaleX: 1, scaleY: 1 }, this.planetBreatheTime / 2, Laya.Ease.linearIn);
  5655. }));
  5656. }
  5657. subBlood(subNum) {
  5658. if (this.blood - subNum >= 0) {
  5659. this.blood -= subNum;
  5660. }
  5661. else {
  5662. this.blood = 0;
  5663. }
  5664. }
  5665. checkBlood() {
  5666. if (this.blood > 0) {
  5667. return true;
  5668. }
  5669. else {
  5670. return false;
  5671. }
  5672. }
  5673. die(fun, dieReason) {
  5674. this.blood = 0;
  5675. let planetB = MainScene.gameControl.planetBReplaceA(this);
  5676. if (planetB) {
  5677. planetB.visible = false;
  5678. Laya.timer.loop(10000, planetB, function () {
  5679. planetB.visible = true;
  5680. });
  5681. }
  5682. if (dieReason == 0) {
  5683. AnimationControl.planetDieExplode(this, fun);
  5684. MusicControl.planetDie();
  5685. }
  5686. this.removeSkillIcon();
  5687. MyDispatcher.Emit(this.dieNotice, null);
  5688. }
  5689. removeSkillIcon() {
  5690. if (this.iconPlanetSkill)
  5691. this.iconPlanetSkill.removeSelf();
  5692. }
  5693. onPlanetHit() {
  5694. MyDispatcher.Emit(this.hitNotice, null);
  5695. }
  5696. Revolve() {
  5697. let interval = Laya.Browser.now() - this.lastTime;
  5698. this.radian += (this.revolveSpeed * interval * this.revolvedirection);
  5699. this.x = this.revolveCenter[0] + Math.cos(this.radian) * this.revolveCenterDistance * 1;
  5700. this.y = this.revolveCenter[1] + Math.sin(this.radian) * this.revolveCenterDistance * 1;
  5701. this.angle = Math.floor((this.radian / (Math.PI / 180)) % 360);
  5702. this.lastTime = Laya.Browser.now();
  5703. }
  5704. rotate() {
  5705. this.planetImg.rotation += this.selfRotateSpeed * this.selfRotateDirection;
  5706. if (this.planetImg.rotation <= -360 || this.planetImg.rotation >= 360) {
  5707. this.planetImg.rotation = 0;
  5708. }
  5709. }
  5710. addRift(pos, rotation) {
  5711. if (this.blood <= 0)
  5712. return;
  5713. let rift = Laya.Pool.getItemByClass("Rift", Laya.Sprite);
  5714. let random = Math.ceil(Math.random() * 3);
  5715. rift.loadImage("texture/Effect/PlanetRift/Rift0" + random + ".png");
  5716. rift.pivotX = rift.texture.width / 2;
  5717. rift.pivotY = rift.texture.height;
  5718. rift.pos(pos[0], pos[1]);
  5719. rift.rotation = rotation;
  5720. this.planetImg.addChild(rift);
  5721. this.bindedRiftArr.push(rift);
  5722. }
  5723. }
  5724. class CoinDailyIncomeControl {
  5725. constructor() {
  5726. this.timerInterval = 100;
  5727. this.fasterTag = 0;
  5728. this.incomeNormalInterval = 30;
  5729. this.incomeFasterInterval = 10;
  5730. this.incomeAtLeast = 100;
  5731. this.incomeTimeAtMost = 3 * 60 * 60;
  5732. this.incomeFasterTimeAtMost = 5 * 60;
  5733. this.fasterInit();
  5734. }
  5735. fasterInit() {
  5736. let lastOfflineTime = MainScene.gameControl.lastGameOfflineTime;
  5737. let lastFasterStartTime = this.getLastFasterStartTime();
  5738. if (lastFasterStartTime > 0) {
  5739. this.ProfitFasterCountDown = this.incomeFasterTimeAtMost - Math.floor((lastOfflineTime - lastFasterStartTime) / 1000);
  5740. if (this.ProfitFasterCountDown < 0) {
  5741. this.ProfitFasterCountDown = 0;
  5742. }
  5743. }
  5744. else {
  5745. this.ProfitFasterCountDown = 0;
  5746. }
  5747. if (this.ProfitFasterCountDown > 0) {
  5748. this.threeTimesFaster();
  5749. }
  5750. }
  5751. init() {
  5752. let onceProfit = this.getOnceIncome();
  5753. let lastOfflineTime = MainScene.gameControl.lastGameOfflineTime;
  5754. if (lastOfflineTime == 0)
  5755. lastOfflineTime = Laya.Browser.now();
  5756. let curTime = Laya.Browser.now();
  5757. let offlineTimeTotal = Math.round((curTime - lastOfflineTime) / 1000);
  5758. let lastNormalStartTime = this.getLastNormalStartTime();
  5759. if (lastNormalStartTime > 0) {
  5760. this.ProfitCountDown = this.incomeTimeAtMost - Math.floor((lastOfflineTime - lastNormalStartTime) / 1000);
  5761. }
  5762. else {
  5763. this.ProfitCountDown = this.incomeTimeAtMost;
  5764. this.saveLastNormalStartTime();
  5765. }
  5766. if (this.ProfitCountDown < 0) {
  5767. this.ProfitCountDown = 0;
  5768. }
  5769. let lastFasterStartTime = this.getLastFasterStartTime();
  5770. if (lastFasterStartTime > 0) {
  5771. this.ProfitFasterCountDown = this.incomeFasterTimeAtMost - Math.floor((lastOfflineTime - lastFasterStartTime) / 1000);
  5772. if (this.ProfitFasterCountDown < 0) {
  5773. this.ProfitFasterCountDown = 0;
  5774. }
  5775. }
  5776. else {
  5777. this.ProfitFasterCountDown = 0;
  5778. }
  5779. if (this.ProfitFasterCountDown < 0) {
  5780. this.ProfitFasterCountDown = 0;
  5781. }
  5782. this.availableIncome = this.getAvailableIncomeData();
  5783. if (!this.availableIncome) {
  5784. this.saveAvailableIncomeData(0);
  5785. }
  5786. if (this.ProfitCountDown <= offlineTimeTotal) {
  5787. if (this.ProfitFasterCountDown <= this.ProfitCountDown) {
  5788. let offlineFasterProfitTime = this.ProfitFasterCountDown;
  5789. let a = Math.floor(offlineFasterProfitTime / this.incomeFasterInterval);
  5790. let offlineFasterProfit = onceProfit * a;
  5791. this.saveAvailableIncomeData(this.availableIncome + offlineFasterProfit);
  5792. let offlineNormalProfitTime = this.ProfitCountDown - offlineFasterProfitTime;
  5793. let b = Math.floor(offlineNormalProfitTime / this.incomeNormalInterval);
  5794. let offlineNormalProfit = onceProfit * b;
  5795. this.saveAvailableIncomeData(this.availableIncome + offlineNormalProfit);
  5796. this.ProfitCountDown = 0;
  5797. this.ProfitFasterCountDown = 0;
  5798. }
  5799. else {
  5800. let offlineFasterProfitTime = this.ProfitCountDown;
  5801. let a = Math.floor(offlineFasterProfitTime / this.incomeFasterInterval);
  5802. let offlineFasterProfit = onceProfit * a;
  5803. this.saveAvailableIncomeData(this.availableIncome + offlineFasterProfit);
  5804. this.ProfitFasterCountDown = this.ProfitFasterCountDown - this.ProfitCountDown;
  5805. this.ProfitCountDown = 0;
  5806. }
  5807. }
  5808. else {
  5809. if (this.ProfitFasterCountDown <= this.ProfitCountDown) {
  5810. if (this.ProfitFasterCountDown > offlineTimeTotal) {
  5811. let offlineFasterProfitTime = offlineTimeTotal;
  5812. let a = Math.floor(offlineFasterProfitTime / this.incomeFasterInterval);
  5813. let offlineFasterProfit = onceProfit * a;
  5814. this.saveAvailableIncomeData(this.availableIncome + offlineFasterProfit);
  5815. this.ProfitCountDown -= offlineTimeTotal;
  5816. this.ProfitFasterCountDown -= offlineTimeTotal;
  5817. }
  5818. else {
  5819. let offlineFasterProfitTime = this.ProfitFasterCountDown;
  5820. let a = Math.floor(offlineFasterProfitTime / this.incomeFasterInterval);
  5821. let offlineFasterProfit = onceProfit * a;
  5822. this.saveAvailableIncomeData(this.availableIncome + offlineFasterProfit);
  5823. let offlineNormalProfitTime = offlineTimeTotal - offlineFasterProfitTime;
  5824. let b = Math.floor(offlineNormalProfitTime / this.incomeNormalInterval);
  5825. let offlineNormalProfit = onceProfit * b;
  5826. this.saveAvailableIncomeData(this.availableIncome + offlineNormalProfit);
  5827. this.ProfitCountDown -= offlineTimeTotal;
  5828. this.ProfitFasterCountDown = 0;
  5829. }
  5830. }
  5831. else {
  5832. let offlineFasterProfitTime = offlineTimeTotal;
  5833. let a = Math.floor(offlineFasterProfitTime / this.incomeFasterInterval);
  5834. let offlineFasterProfit = onceProfit * a;
  5835. this.saveAvailableIncomeData(this.availableIncome + offlineFasterProfit);
  5836. this.ProfitCountDown -= offlineTimeTotal;
  5837. this.ProfitFasterCountDown -= offlineTimeTotal;
  5838. }
  5839. }
  5840. this.updateDialogIncomeUI();
  5841. this.startTimer_updateProfitCountDown();
  5842. this.updateIncomeMostProgressUI();
  5843. }
  5844. startTimer_updateProfitCountDown() {
  5845. Laya.timer.loop(1000, this, this.timer_updateProfitCountDown);
  5846. if (this.fasterTag == 0) {
  5847. Laya.timer.loop(this.incomeNormalInterval * 1000, this, this.timer_addIncome);
  5848. this.playRingAni(this.incomeNormalInterval, 0);
  5849. }
  5850. }
  5851. stopTimer_updateProfitCountDown() {
  5852. Laya.timer.clear(this, this.timer_updateProfitCountDown);
  5853. Laya.timer.clear(this, this.timer_addIncome);
  5854. }
  5855. restartTimer_updateProfitCountDown() {
  5856. this.ProfitCountDown = this.incomeTimeAtMost;
  5857. this.stopTimer_updateProfitCountDown();
  5858. this.saveAvailableIncomeData(0);
  5859. this.startTimer_updateProfitCountDown();
  5860. this.saveLastNormalStartTime();
  5861. }
  5862. playRingAni(curInterval, elapsedTime) {
  5863. Laya.timer.clear(this, this.timer_updateRingProgress);
  5864. this.curInterval = curInterval * 1000;
  5865. this.elapsedTime = elapsedTime * 1000;
  5866. this.timerInterval = 100;
  5867. Laya.timer.loop(this.timerInterval, this, this.timer_updateRingProgress);
  5868. }
  5869. timer_updateRingProgress() {
  5870. if (this.ProfitCountDown <= 0) {
  5871. Laya.timer.clear(this, this.timer_updateRingProgress);
  5872. MainScene.instance.profitProgress.graphics.clear();
  5873. MainScene.instance.profitProgress.graphics.drawPie(38, 38, 38, 270, 270 + 360, "#fed20f");
  5874. }
  5875. else {
  5876. this.elapsedTime += this.timerInterval;
  5877. let percent = (this.elapsedTime % this.curInterval) / this.curInterval;
  5878. let angle = 360 * percent;
  5879. MainScene.instance.profitProgress.graphics.clear();
  5880. MainScene.instance.profitProgress.graphics.drawPie(38, 38, 38, 270, 270 + angle, "#fed20f");
  5881. }
  5882. }
  5883. timer_updateProfitCountDown() {
  5884. let dialog = MainScene.instance.dialog_receiveCoinProfit;
  5885. if (this.ProfitCountDown > 0) {
  5886. this.ProfitCountDown -= 1;
  5887. }
  5888. else {
  5889. dialog.text_UpperLimitTime.text = "\n收益已达上限!";
  5890. this.ProfitCountDown = 0;
  5891. this.stopTimer_updateProfitCountDown();
  5892. return;
  5893. }
  5894. let hour = Math.floor(this.ProfitCountDown / 3600);
  5895. let minute = Math.floor((this.ProfitCountDown - hour * 3600) / 60);
  5896. let second = Math.floor(this.ProfitCountDown % 60);
  5897. let str_hour = (hour >= 10) ? (hour + "") : (hour > 0 ? ("0" + hour) : "00");
  5898. let str_minute = (minute >= 10) ? (minute + "") : (minute > 0 ? ("0" + minute) : "00");
  5899. let str_second = (second >= 10) ? (second + "") : (second > 0 ? ("0" + second) : "00");
  5900. let str = str_hour + ":" + str_minute + ":" + str_second;
  5901. if (hour > 0 || minute > 0 || second > 0) {
  5902. dialog.text_UpperLimitTime.text = " " + str + "后\n" + "收益达到上限";
  5903. }
  5904. }
  5905. threeTimesFaster() {
  5906. this.fasterTag = 1;
  5907. Laya.timer.clear(this, this.timer_addIncome);
  5908. let adialog = MainScene.instance.dialog_speedUpCoinProfit;
  5909. adialog.fasterCountTime_bg.visible = true;
  5910. adialog.btn_threeTimesFaster.visible = false;
  5911. let amask = adialog.mask_fasterCountTime;
  5912. let maskW = amask.width;
  5913. amask.x -= maskW;
  5914. let interval = this.incomeFasterInterval;
  5915. let totalTime = this.ProfitFasterCountDown;
  5916. let lastedTime = this.incomeFasterTimeAtMost - totalTime;
  5917. let nextProfitTime = totalTime % interval > 0 ? totalTime % interval + lastedTime : interval + lastedTime;
  5918. this.playRingAni(nextProfitTime - lastedTime, 0);
  5919. let countNum = totalTime;
  5920. let timer_threeTimesFaster = function () {
  5921. if (countNum <= 0) {
  5922. this.fasterTag = 0;
  5923. Laya.timer.clear(this, timer_threeTimesFaster);
  5924. if (MainScene.gameControl.maxLevel >= 20) {
  5925. Laya.timer.loop(this.incomeNormalInterval * 1000, this, this.timer_addIncome);
  5926. this.playRingAni(this.incomeNormalInterval, 0);
  5927. }
  5928. adialog.fasterCountTime_bg.visible = false;
  5929. adialog.btn_threeTimesFaster.visible = true;
  5930. }
  5931. else {
  5932. countNum -= 1;
  5933. let fasterTime = this.incomeFasterTimeAtMost - countNum;
  5934. let percent = countNum / this.incomeFasterTimeAtMost;
  5935. amask.x = maskW * (-percent);
  5936. adialog.fasterCountTime.value = this.secendToHour(countNum);
  5937. if (fasterTime >= nextProfitTime) {
  5938. if (MainScene.gameControl.maxLevel >= 20) {
  5939. this.timer_addIncome();
  5940. }
  5941. nextProfitTime += interval;
  5942. this.playRingAni(interval, 0);
  5943. }
  5944. }
  5945. };
  5946. Laya.timer.loop(1000, this, timer_threeTimesFaster);
  5947. }
  5948. secendToHour(timeNum) {
  5949. let hour = Math.floor(timeNum / 3600);
  5950. let minute = Math.floor((timeNum - hour * 3600) / 60);
  5951. let second = Math.floor(timeNum % 60);
  5952. let str_hour = (hour >= 10) ? (hour + "") : (hour > 0 ? ("0" + hour) : "");
  5953. let str_minute = (minute >= 10) ? (minute + "") : (minute > 0 ? ("0" + minute) : "00");
  5954. let str_second = (second >= 10) ? (second + "") : (second > 0 ? ("0" + second) : "00");
  5955. let str = str_minute + ":" + str_second;
  5956. return str;
  5957. }
  5958. timer_addIncome() {
  5959. let onceIncome = this.getOnceIncome();
  5960. this.availableIncome += onceIncome;
  5961. this.updateDialogIncomeUI();
  5962. this.saveAvailableIncomeData(this.availableIncome);
  5963. this.updateIncomeMostProgressUI();
  5964. Laya.Tween.to(MainScene.instance.coinProfitRing, { rotation: 360 }, 800, Laya.Ease.linearIn, Laya.Handler.create(this, function () {
  5965. MainScene.instance.coinProfitRing.rotation = 0;
  5966. }));
  5967. }
  5968. updateDialogIncomeUI() {
  5969. let coinStr = MathTool.currencyUnit(this.availableIncome);
  5970. MainScene.instance.dialog_receiveCoinProfit.text_btn_clickReceive.text = coinStr;
  5971. let coinStr3 = MathTool.currencyUnit(this.availableIncome * 3);
  5972. MainScene.instance.dialog_receiveCoinProfit.text_btn_threeTimesReceive.text = coinStr3;
  5973. }
  5974. getOnceIncome() {
  5975. let onceIncome = MainScene.gameControl.coinInfo.coinProfit;
  5976. return onceIncome;
  5977. }
  5978. updateIncomeMostProgressUI() {
  5979. let instance = MainScene.instance;
  5980. let progressValue = 1 - this.ProfitCountDown / this.incomeTimeAtMost;
  5981. instance.coinIncomeProgress.value = progressValue;
  5982. }
  5983. updateRingUI() {
  5984. if (this.ProfitCountDown > 0) {
  5985. }
  5986. else {
  5987. MainScene.instance.profitProgress.graphics.clear();
  5988. MainScene.instance.profitProgress.graphics.drawPie(38, 38, 38, 270, 270 + 359, "#fed20f");
  5989. }
  5990. }
  5991. saveAvailableIncomeData(value) {
  5992. this.availableIncome = value;
  5993. Data.setNumber("AvailableIncomeData", value);
  5994. }
  5995. getAvailableIncomeData() {
  5996. return Data.getNumber("AvailableIncomeData");
  5997. }
  5998. saveLastNormalStartTime() {
  5999. let value = Laya.Browser.now();
  6000. Data.setNumber("LastNormalStartTime", value);
  6001. }
  6002. getLastNormalStartTime() {
  6003. return Data.getNumber("LastNormalStartTime");
  6004. }
  6005. saveLastFasterStartTime() {
  6006. let value = Laya.Browser.now();
  6007. Data.setNumber("LastFasterStartTime", value);
  6008. }
  6009. getLastFasterStartTime() {
  6010. return Data.getNumber("LastFasterStartTime");
  6011. }
  6012. }
  6013. class GameControl extends Laya.Script {
  6014. constructor() {
  6015. super();
  6016. this.shareOpen = true;
  6017. this.bindToSunKnifeArr = [];
  6018. this.isStartGame = false;
  6019. this.curLevel = 1;
  6020. this.maxLevel = 0;
  6021. this.holdCoinsNum = 0;
  6022. this.holdStrengthNum = 0;
  6023. this.bindToSunTreeArr = [];
  6024. this.knifeInfo = {
  6025. "knifeNumGrade": 0,
  6026. "knifeTotalNum": 0,
  6027. "knifeUpgradeNumNeedCoins": 0,
  6028. "knifeAttackGrade": 0,
  6029. "knifeAttack": 0,
  6030. "knifeUpgradeAttackNeedCoins": 0
  6031. };
  6032. this.knifeRestNum = 0;
  6033. this.critInfo = {
  6034. "critAttackGrade": 0,
  6035. "critAttack": 0,
  6036. "critUpgradeAttackNeedCoins": 0,
  6037. "critChanceGrade": 0,
  6038. "critChance": 0,
  6039. "critUpgradeChanceNeedCoins": 0
  6040. };
  6041. this.coinInfo = {
  6042. "coinValueGrade": 0,
  6043. "coinValue": 0,
  6044. "coinUpgradeValueNeedCoins": 0,
  6045. "coinProfitGrade": 0,
  6046. "coinProfit": 0,
  6047. "coinUpgradeProfitNeedCoins": 0
  6048. };
  6049. this.nextChangeDirLevel = 0;
  6050. this.planetsInfoAtCurLevel = {
  6051. "planetTotalNum": 0,
  6052. "innerRingPlanetNum": 0,
  6053. "outerRingPlanetNum": 0,
  6054. "planetCorrespondingNum": {
  6055. "Mercury": 0,
  6056. "Venus": 0,
  6057. "Mars": 0,
  6058. "Jupiter": 0,
  6059. "Saturn": 0,
  6060. }
  6061. };
  6062. this.planetsInfo = [
  6063. {
  6064. "name": "小兰",
  6065. "url": "texture/Planet/Mercury.png",
  6066. "skill": "可以为病毒加血"
  6067. },
  6068. {
  6069. "name": "小绿",
  6070. "url": "texture/Planet/Venus.png",
  6071. "skill": "消灭后会给病毒一个护盾"
  6072. },
  6073. {
  6074. "name": "小火",
  6075. "url": "texture/Planet/Mars.png",
  6076. "skill": "被攻击可减少病毒上的火箭和禁牌"
  6077. },
  6078. {
  6079. "name": "小紫",
  6080. "url": "texture/Planet/Jupiter.png",
  6081. "skill": "可以为病毒增加禁牌"
  6082. },
  6083. {
  6084. "name": "小黄",
  6085. "url": "texture/Planet/Saturn.png",
  6086. "skill": "可以为病毒加速"
  6087. }
  6088. ];
  6089. this.allPlanets = [];
  6090. this.innerPlanets = [];
  6091. this.outerPlanets = [];
  6092. this.curPlanets = [];
  6093. this.coinNumFromCurLevel = 0;
  6094. this.propInvincibleRocketNum = 0;
  6095. this.propInvincibleRocketTotalNum = 0;
  6096. this.reviveChance = 0;
  6097. this.gameStartTime = 0;
  6098. this.sunPos = [175, 175];
  6099. this.launchRocketTag = 0;
  6100. this.allTreePoints = [{
  6101. "x": 0,
  6102. "y": 0,
  6103. "rotation": 0
  6104. }];
  6105. this.allInnerPlanetPoints = [{
  6106. "x": 0,
  6107. "y": 0,
  6108. "rotation": 0
  6109. }];
  6110. this.allOuterPlanetPoints = [{
  6111. "x": 0,
  6112. "y": 0,
  6113. "rotation": 0
  6114. }];
  6115. this.smallLiquiCount = 0;
  6116. this.bigLiquiCount = 0;
  6117. this.slowDownTag = 0;
  6118. this.SaturnSkillTag = 0;
  6119. this.curKnifeArr = [];
  6120. this.leftoverPlanets = [];
  6121. this.newPlayerTag = 0;
  6122. }
  6123. onEnable() {
  6124. MainScene.gameControl = this;
  6125. this.init();
  6126. }
  6127. init() {
  6128. this.b_propTeach = this.getPropTeach();
  6129. this.lastGameOfflineTime = this.getLastOfflineTime();
  6130. this.gameStartTime = Laya.Browser.now();
  6131. let playCount = Data.getPlayCount();
  6132. if (playCount && playCount > 0) {
  6133. this.initInfoFromData();
  6134. }
  6135. else {
  6136. this.initData();
  6137. }
  6138. console.log("初始化时获取的分数", this.getMaxLevel());
  6139. Data.addPlayCount();
  6140. this.updateHomeUI();
  6141. let sun = new Sun();
  6142. MainScene.instance.SunBox.addChild(sun);
  6143. MainScene.sun = sun;
  6144. MainScene.sun.sunIdle();
  6145. Laya.timer.loop(1000, this, this.setThisOfflineTime);
  6146. MainScene.instance.coinDailyIncomeControl = new CoinDailyIncomeControl();
  6147. if (this.maxLevel >= 5) {
  6148. MainScene.instance.coinDailyIncomeControl.init();
  6149. MainScene.instance.coinProfit.visible = true;
  6150. }
  6151. else {
  6152. MainScene.instance.coinProfit.visible = false;
  6153. }
  6154. SkeletonControl.initTemplet();
  6155. MainScene.instance.btn_testEffect.on(Laya.Event.MOUSE_DOWN, this, function () {
  6156. MusicControl.gameFailed();
  6157. });
  6158. this.getOfflineStrength();
  6159. this.initTipUpperLimitAni();
  6160. this.allTreePoints = [];
  6161. this.allInnerPlanetPoints = [];
  6162. this.allOuterPlanetPoints = [];
  6163. let sunTreeNode = sun.treeNode;
  6164. let rSub = MyConsts.treeThorough;
  6165. this.allTreePoints = this.getAllPoints(sunTreeNode.width / 2 - rSub, 15);
  6166. let innerNode = sun.planetInnerRingNode;
  6167. this.allInnerPlanetPoints = this.getAllPoints(innerNode.width / 2, 30);
  6168. let outerNode = sun.planetOuterRingNode;
  6169. this.allOuterPlanetPoints = this.getAllPoints(outerNode.width / 2, 30);
  6170. this.fingerAni = AnimationControl.playFingerAni();
  6171. this.fingerAni.scale(1, 1);
  6172. this.fingerAni.visible = false;
  6173. this.checkNewPlayer();
  6174. }
  6175. initInfoFromData() {
  6176. this.coinInfo = this.getCoinInfo();
  6177. this.critInfo = this.getCritInfo();
  6178. this.knifeInfo = this.getKnifeInfo();
  6179. this.maxLevel = this.getMaxLevel();
  6180. this.holdCoinsNum = this.getHoldCoinsNum();
  6181. this.holdStrengthNum = this.getHoldStrengthNum();
  6182. }
  6183. initData() {
  6184. this.growthSystemInit();
  6185. this.setMaxLevel(0);
  6186. this.setHoldCoinsNum(5000);
  6187. this.setHoldStrengthNum(100);
  6188. this.setPlayCount(0);
  6189. }
  6190. getAllPoints(r, angleRestriction) {
  6191. let allPoints = [];
  6192. let totalPointNum = 360 / angleRestriction;
  6193. for (let i = 0; i < totalPointNum; i++) {
  6194. let pointInfo = {
  6195. "x": 0,
  6196. "y": 0,
  6197. "rotation": 0
  6198. };
  6199. let angle = angleRestriction * i;
  6200. let radian = Math.PI / 180 * angle;
  6201. let pointX = Math.cos(radian) * r;
  6202. let pointY = Math.sin(radian) * r;
  6203. pointInfo.rotation = MathTool.angleBePositive(angleRestriction * i - 90);
  6204. pointInfo.x = pointX;
  6205. pointInfo.y = pointY;
  6206. allPoints.push(pointInfo);
  6207. }
  6208. return allPoints;
  6209. }
  6210. getAllBlankPoints(totalPointArr, existingRotation) {
  6211. let allBlankPoints = [{
  6212. "x": 0,
  6213. "y": 0,
  6214. "rotation": 0
  6215. }];
  6216. allBlankPoints = [];
  6217. for (let i = 0; i < totalPointArr.length; i++) {
  6218. let point = {
  6219. "x": 0,
  6220. "y": 0,
  6221. "rotation": 0
  6222. };
  6223. let apoint = totalPointArr[i];
  6224. point.x = apoint.x;
  6225. point.y = apoint.y;
  6226. point.rotation = apoint.rotation;
  6227. allBlankPoints.push(point);
  6228. }
  6229. for (let i = 0; i < existingRotation.length; i++) {
  6230. let a_existingRotation = existingRotation[i];
  6231. for (let j = 0; j < allBlankPoints.length; j++) {
  6232. let apoint = allBlankPoints[j];
  6233. if (a_existingRotation == apoint.rotation) {
  6234. allBlankPoints.splice(j, 1);
  6235. break;
  6236. }
  6237. }
  6238. }
  6239. return allBlankPoints;
  6240. }
  6241. addCoins(addNum) {
  6242. MainScene.gameControl.setHoldCoinsNum(MainScene.gameControl.holdCoinsNum + addNum);
  6243. MusicControl.getCoins();
  6244. }
  6245. receiveCoinDailyIncome(coinNum) {
  6246. this.addCoins(coinNum);
  6247. this.updateHomeUI();
  6248. }
  6249. recoverEnergies(strengthNum, type) {
  6250. switch (type) {
  6251. case 0:
  6252. if (this.holdStrengthNum >= 100)
  6253. return;
  6254. if (this.holdStrengthNum + strengthNum >= 100) {
  6255. this.setHoldStrengthNum(100);
  6256. }
  6257. else {
  6258. this.setHoldStrengthNum(this.holdStrengthNum + strengthNum);
  6259. }
  6260. let ring = MainScene.instance.dialog_getStrength.ring;
  6261. Laya.Tween.to(ring, { rotation: 360 }, 800, Laya.Ease.linearIn, Laya.Handler.create(this, function () {
  6262. ring.rotation = 0;
  6263. }));
  6264. break;
  6265. case 1:
  6266. this.setHoldStrengthNum(this.holdStrengthNum + strengthNum);
  6267. break;
  6268. default:
  6269. break;
  6270. }
  6271. MainScene.gameControl.updateHomeUI();
  6272. }
  6273. getOfflineStrength() {
  6274. if (this.holdStrengthNum < 100) {
  6275. let astartTime = this.getRecoverStrengthCountDownStartTime();
  6276. if (astartTime < 1 || !astartTime) {
  6277. this.saveRecoverStrengthCountDownStartTime(-1);
  6278. }
  6279. let lastStartTime = this.recoverStrengthCountDownStartTime = this.getRecoverStrengthCountDownStartTime();
  6280. let curTime = Laya.Browser.now();
  6281. let offlineTimeTotal = Math.round((curTime - lastStartTime) / 1000);
  6282. let offlineStrength = Math.floor(offlineTimeTotal / 60 / 5);
  6283. let elapsedTime = Math.floor((curTime - lastStartTime) / 1000);
  6284. if (this.holdStrengthNum < 100) {
  6285. if (this.holdStrengthNum + offlineStrength >= 100) {
  6286. this.setHoldStrengthNum(100);
  6287. this.saveRecoverStrengthCountDownStartTime(-1);
  6288. }
  6289. else {
  6290. this.setHoldStrengthNum(this.holdStrengthNum + offlineStrength);
  6291. this.strengthCountDown = 60 * 5 - elapsedTime;
  6292. this.updateHomeUI();
  6293. }
  6294. }
  6295. }
  6296. else {
  6297. this.saveRecoverStrengthCountDownStartTime(-1);
  6298. }
  6299. Laya.timer.loop(1000, this, this.timerCountDownStrength);
  6300. }
  6301. timerCountDownStrength() {
  6302. if (this.holdStrengthNum < 100) {
  6303. if (this.recoverStrengthCountDownStartTime > 0) {
  6304. this.strengthCountDown -= 1;
  6305. if (this.strengthCountDown <= 0) {
  6306. this.recoverEnergies(1, 0);
  6307. if (this.holdStrengthNum < 100) {
  6308. this.strengthCountDown = 5 * 60;
  6309. this.saveRecoverStrengthCountDownStartTime();
  6310. }
  6311. else {
  6312. this.saveRecoverStrengthCountDownStartTime(-1);
  6313. }
  6314. }
  6315. }
  6316. else {
  6317. this.strengthCountDown = 5 * 60;
  6318. this.saveRecoverStrengthCountDownStartTime();
  6319. }
  6320. }
  6321. else {
  6322. this.strengthCountDown = 5 * 60;
  6323. this.saveRecoverStrengthCountDownStartTime(-1);
  6324. }
  6325. this.updateStrengthUI();
  6326. }
  6327. updateStrengthUI() {
  6328. let interval = 5 * 60;
  6329. let dialog = MainScene.instance.dialog_getStrength;
  6330. if (this.holdStrengthNum < 100) {
  6331. let countDown = this.strengthCountDown;
  6332. let angle = 360 * ((interval - countDown) / (interval));
  6333. dialog.strengthRingProgress.graphics.clear();
  6334. dialog.strengthRingProgress.graphics.drawPie(92, 92, 92, 270, 270 + angle, "#fed20f");
  6335. let minute = Math.floor(countDown / 60);
  6336. let second = countDown % 60;
  6337. let str_minute = (minute >= 10) ? (minute + "") : (minute > 0 ? ("0" + minute) : "00");
  6338. let str_second = (second >= 10) ? (second + "") : (second > 0 ? ("0" + second) : "00");
  6339. dialog.tip.text = str_minute + ":" + str_second + " 后恢复1点体力";
  6340. }
  6341. else {
  6342. dialog.tip.text = "体力已经最满啦!";
  6343. let angle = 360;
  6344. dialog.strengthRingProgress.graphics.clear();
  6345. dialog.strengthRingProgress.graphics.drawPie(92, 92, 92, 270, 270 + angle, "#fed20f");
  6346. }
  6347. }
  6348. growthSystemInit() {
  6349. this.knifeInfo.knifeNumGrade = 1;
  6350. this.knifeInfo.knifeTotalNum = 4;
  6351. this.knifeInfo.knifeUpgradeNumNeedCoins = 50;
  6352. this.knifeInfo.knifeAttackGrade = 1;
  6353. this.knifeInfo.knifeAttack = 40;
  6354. this.knifeInfo.knifeUpgradeAttackNeedCoins = 30;
  6355. this.setKnifeInfo(this.knifeInfo);
  6356. this.critInfo.critAttackGrade = 0;
  6357. this.critInfo.critAttack = 0;
  6358. this.critInfo.critUpgradeAttackNeedCoins = 0;
  6359. this.critInfo.critChanceGrade = 0;
  6360. this.critInfo.critChance = 0;
  6361. this.critInfo.critUpgradeChanceNeedCoins = 0;
  6362. Data.setCritInfo(this.critInfo);
  6363. this.coinInfo.coinValueGrade = 0;
  6364. this.coinInfo.coinValue = 0;
  6365. this.coinInfo.coinUpgradeValueNeedCoins = 0;
  6366. this.coinInfo.coinProfitGrade = 0;
  6367. this.coinInfo.coinProfit = 0;
  6368. this.coinInfo.coinUpgradeProfitNeedCoins = 0;
  6369. Data.setCoinInfo(this.coinInfo);
  6370. }
  6371. critSystemInit() {
  6372. this.critInfo.critAttackGrade = 1;
  6373. this.critInfo.critAttack = Math.round(4 * this.critInfo.critAttackGrade / (this.critInfo.critAttackGrade + 6) * 100) / 100 - 0.57;
  6374. this.critInfo.critUpgradeAttackNeedCoins = this.critInfo.critAttackGrade * 15;
  6375. this.critInfo.critChanceGrade = 1;
  6376. this.critInfo.critChance = Math.round((this.critInfo.critChanceGrade / (3 * this.critInfo.critChanceGrade + 50)) * 100) / 100;
  6377. this.critInfo.critUpgradeChanceNeedCoins = this.critInfo.critChanceGrade * 10;
  6378. Data.setCritInfo(this.critInfo);
  6379. }
  6380. coinSystemInit() {
  6381. this.coinInfo.coinValueGrade = 1;
  6382. this.coinInfo.coinValue = 10;
  6383. this.coinInfo.coinUpgradeValueNeedCoins = 70;
  6384. this.coinInfo.coinProfitGrade = 1;
  6385. this.coinInfo.coinProfit = 20;
  6386. this.coinInfo.coinUpgradeProfitNeedCoins = 60;
  6387. Data.setCoinInfo(this.coinInfo);
  6388. }
  6389. onGameStageClick() {
  6390. if (!this.isStartGame)
  6391. return;
  6392. if (this.launchRocketTag == 1)
  6393. return;
  6394. if (!this.curBeReadyKnife) {
  6395. return;
  6396. }
  6397. if (!this.curBeReadyKnife.beReadyToLaunch)
  6398. return;
  6399. if ((this.knifeRestNum > 0 || this.propInvincibleRocketNum > 0) && this.launchRocketTag == 0) {
  6400. this.launchRocketTag = 1;
  6401. this.updateGameUI();
  6402. this.curBeReadyKnife.knifeBindToSun();
  6403. this.curBeReadyKnife = null;
  6404. this.deductKnifeNum();
  6405. this.createKnife();
  6406. }
  6407. }
  6408. initTipUpperLimitAni() {
  6409. let text_upperLimit = this.upperLimit = new Laya.Text();
  6410. text_upperLimit.text = "该道具本局获取次数已达上限";
  6411. text_upperLimit.color = "#ffffff";
  6412. text_upperLimit.fontSize = 38;
  6413. text_upperLimit.alpha = 0;
  6414. text_upperLimit.pivot(text_upperLimit.width / 2, text_upperLimit.height / 2);
  6415. Laya.stage.addChild(text_upperLimit);
  6416. text_upperLimit.pos(Laya.stage.width / 2, Laya.stage.height / 2);
  6417. }
  6418. showTipUpperLimit() {
  6419. let aniY = Laya.stage.height / 2;
  6420. MainScene.gameControl.upperLimit.y = aniY + 50;
  6421. Laya.Tween.to(MainScene.gameControl.upperLimit, { y: aniY, alpha: 1 }, 500, null, null, 0.1, true);
  6422. Laya.timer.once(500, MainScene.gameControl, function () {
  6423. Laya.Tween.to(MainScene.gameControl.upperLimit, { y: aniY - 50, alpha: 0 }, 800, null, null, 0.1, true);
  6424. });
  6425. }
  6426. onRocketClick() {
  6427. if (MainScene.instance.dialog_freelyGetProp.freelyChance.rocketChance > 0) {
  6428. MainScene.instance.dialog_freelyGetProp.showDialog(0);
  6429. }
  6430. else {
  6431. this.showTipUpperLimit();
  6432. }
  6433. }
  6434. usingProp_rocket() {
  6435. if (!MainScene.gameControl.isStartGame)
  6436. return;
  6437. if (!MainScene.gameControl.curBeReadyKnife)
  6438. return;
  6439. MainScene.gameControl.propInvincibleRocketNum += 5;
  6440. MainScene.gameControl.propInvincibleRocketTotalNum += 5;
  6441. MainScene.gameControl.curBeReadyKnife.isInvincible = true;
  6442. MainScene.gameControl.curBeReadyKnife.updateTexture();
  6443. MainScene.gameControl.updateGameUI();
  6444. }
  6445. onSlowDownClick() {
  6446. if (this.slowDownTag == 1)
  6447. return;
  6448. if (MainScene.instance.dialog_freelyGetProp.freelyChance.slowDownChance > 0) {
  6449. MainScene.instance.dialog_freelyGetProp.showDialog(1);
  6450. }
  6451. else {
  6452. this.showTipUpperLimit();
  6453. }
  6454. this.updateGameUI();
  6455. }
  6456. usingProp_slowDown() {
  6457. MainScene.gameControl.slowDownTag = 1;
  6458. MainScene.sun.sunRotateSpeed = 10;
  6459. let innerPlanetsNum = MainScene.gameControl.innerPlanets.length;
  6460. for (let i = 0; i < innerPlanetsNum; i++) {
  6461. let planet = MainScene.gameControl.innerPlanets[i];
  6462. planet.revolveSpeed -= (planet.revolveSpeed * 0.5);
  6463. }
  6464. let outerPlanetsNum = MainScene.gameControl.outerPlanets.length;
  6465. for (let i = 0; i < outerPlanetsNum; i++) {
  6466. let planet = MainScene.gameControl.outerPlanets[i];
  6467. planet.revolveSpeed -= (planet.revolveSpeed * 0.5);
  6468. }
  6469. let sp = new Laya.Sprite();
  6470. sp.loadImage("texture/GameScene/radialLine.png");
  6471. sp.pivot(sp.width / 2, sp.height);
  6472. let spP = new Laya.Point(MainScene.gameControl.curBeReadyKnife.x, MainScene.gameControl.curBeReadyKnife.y);
  6473. spP = MainScene.instance.KnifeBox.localToGlobal(spP);
  6474. sp.pos(spP.x, spP.y);
  6475. Laya.stage.addChild(sp);
  6476. let isStopSlowDown = false;
  6477. let stopSlowDown = function () {
  6478. isStopSlowDown = true;
  6479. sp.removeSelf();
  6480. sp.destroy();
  6481. MainScene.gameControl.slowDownTag = 0;
  6482. MainScene.sun.sunRotateSpeed = MainScene.sun.sunRotateSpeedInit;
  6483. let innerPlanetsNum2 = MainScene.gameControl.innerPlanets.length;
  6484. for (let i = 0; i < innerPlanetsNum2; i++) {
  6485. let planet = MainScene.gameControl.innerPlanets[i];
  6486. planet.revolveSpeed = planet.revolveSpeedInit;
  6487. }
  6488. let outerPlanetsNum2 = MainScene.gameControl.outerPlanets.length;
  6489. for (let i = 0; i < outerPlanetsNum2; i++) {
  6490. let planet = MainScene.gameControl.outerPlanets[i];
  6491. planet.revolveSpeed = planet.revolveSpeedInit;
  6492. }
  6493. };
  6494. Laya.timer.once(15000, MainScene.gameControl, function () {
  6495. if (!isStopSlowDown) {
  6496. stopSlowDown();
  6497. }
  6498. });
  6499. let stopSlowDownAfterGameOver = function () {
  6500. if (!MainScene.gameControl.isStartGame) {
  6501. if (!isStopSlowDown) {
  6502. stopSlowDown();
  6503. }
  6504. Laya.timer.clear(MainScene.gameControl, stopSlowDownAfterGameOver);
  6505. }
  6506. };
  6507. Laya.timer.frameLoop(1, MainScene.gameControl, stopSlowDownAfterGameOver);
  6508. }
  6509. onSubBloodClick() {
  6510. if (MainScene.instance.dialog_freelyGetProp.freelyChance.subBloodChance > 0) {
  6511. MainScene.instance.dialog_freelyGetProp.showDialog(2);
  6512. }
  6513. else {
  6514. this.showTipUpperLimit();
  6515. }
  6516. }
  6517. usingProp_subBlood() {
  6518. let subHP = Math.floor(MainScene.sun.curBlood * 0.5);
  6519. AnimationControl.playSubBloodNumAni(subHP + "", MainScene.sun.normalNumBox, [360, 0], 1);
  6520. MainScene.sun.subBlood(subHP);
  6521. let innerPlanetsNum = MainScene.gameControl.innerPlanets.length;
  6522. for (let i = 0; i < innerPlanetsNum; i++) {
  6523. let planet = MainScene.gameControl.innerPlanets[i];
  6524. planet.subBlood(planet.blood * 0.5);
  6525. }
  6526. let outerPlanetsNum = MainScene.gameControl.outerPlanets.length;
  6527. for (let i = 0; i < outerPlanetsNum; i++) {
  6528. let planet = MainScene.gameControl.outerPlanets[i];
  6529. planet.subBlood(planet.blood * 0.5);
  6530. }
  6531. MainScene.gameControl.updateGameUI();
  6532. }
  6533. curKnifeArrivedSun(knife) {
  6534. let gameControl = MainScene.gameControl;
  6535. if (!gameControl.isStartGame)
  6536. return;
  6537. gameControl.bindToSunKnifeArr.push(knife);
  6538. knife.clearCheckCollision();
  6539. let knifeAttack = gameControl.checkKnifeCrit(knife, MainScene.sun.normalNumBox, [360, 0], 1);
  6540. MainScene.sun.subBlood(knifeAttack);
  6541. if (MainScene.gameControl.knifeRestNum == 1 && !MainScene.gameControl.b_propTeach) {
  6542. }
  6543. if (knife.attack > MainScene.sun.shieldBlood) {
  6544. MainScene.sun.addRift();
  6545. }
  6546. let addCoinNum = 1.5 * (Math.pow(gameControl.curLevel, 2) + 2 * gameControl.curLevel + gameControl.coinInfo.coinValue);
  6547. gameControl.coinNumFromCurLevel += Math.floor(addCoinNum);
  6548. gameControl.updateGameUI();
  6549. let isSunAlive = MainScene.sun.checkBlood();
  6550. if (isSunAlive) {
  6551. if (gameControl.knifeRestNum <= 0 && gameControl.propInvincibleRocketNum <= 0) {
  6552. gameControl.stopGame();
  6553. gameControl.levelFailed();
  6554. MainScene.instance.gameOverUI.defeatReason.text = "失败原因:火箭已用完";
  6555. }
  6556. }
  6557. else {
  6558. gameControl.levelSuccessful();
  6559. }
  6560. }
  6561. clearCurKnifeArr() {
  6562. let num = this.curKnifeArr.length;
  6563. if (this.curKnifeArr && num > 0) {
  6564. for (let i = 0; i < num; i++) {
  6565. this.curKnifeArr[0].removeSelf();
  6566. this.curKnifeArr.splice(0, 1);
  6567. }
  6568. ;
  6569. }
  6570. }
  6571. createKnife() {
  6572. if (!MainScene.gameControl.isStartGame)
  6573. return;
  6574. if (MainScene.gameControl.knifeRestNum <= 0 && MainScene.gameControl.propInvincibleRocketNum <= 0) {
  6575. return;
  6576. }
  6577. let knife = Laya.Pool.getItemByClass("Knife", Knife);
  6578. knife.beReadyToLaunch = false;
  6579. knife.pivotX = knife.width / 2;
  6580. knife.init();
  6581. MainScene.instance.KnifeBox.addChild(knife);
  6582. MainScene.gameControl.curBeReadyKnife = knife;
  6583. if (MainScene.gameControl.propInvincibleRocketNum > 0) {
  6584. knife.isInvincible = true;
  6585. knife.updateTexture();
  6586. }
  6587. else {
  6588. knife.isInvincible = false;
  6589. knife.updateTexture();
  6590. }
  6591. if (knife.fireAni) {
  6592. knife.fireAni.visible = true;
  6593. let posX = knife.width / 2 - 5;
  6594. let posY = knife.height - 8;
  6595. knife.fireAni.pos(posX, posY);
  6596. }
  6597. else {
  6598. knife.fireAni = AnimationControl.knifeFireAni(knife);
  6599. }
  6600. knife.pos(360, 1800);
  6601. let targetY = MainScene.instance.exampleKnife.y;
  6602. let flySpeed = 200;
  6603. let knifeFly = function () {
  6604. if (knife.y - flySpeed <= targetY) {
  6605. knife.y = targetY;
  6606. Laya.timer.clear(this, knifeFly);
  6607. MainScene.gameControl.launchRocketTag = 0;
  6608. knife.beReadyToLaunch = true;
  6609. }
  6610. else {
  6611. knife.y -= flySpeed;
  6612. }
  6613. };
  6614. Laya.timer.frameLoop(1, this, knifeFly);
  6615. return knife;
  6616. }
  6617. deductKnifeNum() {
  6618. if (MainScene.gameControl.propInvincibleRocketNum > 0) {
  6619. MainScene.gameControl.propInvincibleRocketNum -= 1;
  6620. }
  6621. else {
  6622. if (MainScene.gameControl.knifeRestNum > 0) {
  6623. MainScene.gameControl.knifeRestNum -= 1;
  6624. }
  6625. }
  6626. }
  6627. saveMinPointY() {
  6628. let knifeHeight = 124;
  6629. let treeHeight = 111;
  6630. let minKnifePoint = new Laya.Point(360, MainScene.sun.sunNode.y + MyConsts.knifeToSunCenter + knifeHeight);
  6631. minKnifePoint = MainScene.sun.localToGlobal(minKnifePoint);
  6632. minKnifePoint = MainScene.instance.KnifeBox.globalToLocal(minKnifePoint);
  6633. this.minKnifeY = minKnifePoint.y;
  6634. let minInnerPlanetPoint = new Laya.Point(360, MainScene.sun.sunNode.y + MainScene.sun.planetInnerRing.height / 2 + 60);
  6635. minInnerPlanetPoint = MainScene.sun.localToGlobal(minInnerPlanetPoint);
  6636. minInnerPlanetPoint = MainScene.instance.KnifeBox.globalToLocal(minInnerPlanetPoint);
  6637. this.minInnerY = minInnerPlanetPoint.y;
  6638. let minOuterPlanetPoint = new Laya.Point(360, MainScene.sun.sunNode.y + MainScene.sun.planetOuterRing.height / 2 + 60);
  6639. minOuterPlanetPoint = MainScene.sun.localToGlobal(minOuterPlanetPoint);
  6640. minOuterPlanetPoint = MainScene.instance.KnifeBox.globalToLocal(minOuterPlanetPoint);
  6641. this.minOuterY = minOuterPlanetPoint.y;
  6642. }
  6643. getTreesNum() {
  6644. let random = Math.random();
  6645. let treeNum = 0;
  6646. let a = 0;
  6647. let b = 0;
  6648. let s = 0;
  6649. if (this.curLevel <= 29) {
  6650. s = 5;
  6651. a = this.curLevel % (s * 3);
  6652. b = Math.floor(this.curLevel / 15);
  6653. if (this.curLevel >= 5 && this.curLevel <= 9) {
  6654. if (random <= 0.1) {
  6655. treeNum = b;
  6656. }
  6657. else if (random > 0.1 && random <= 0.7) {
  6658. treeNum = b + 1;
  6659. }
  6660. else {
  6661. treeNum = b + 2;
  6662. }
  6663. }
  6664. else {
  6665. if (a < s) {
  6666. if (random <= 0.3) {
  6667. treeNum = b;
  6668. }
  6669. else {
  6670. treeNum = b + 1;
  6671. }
  6672. }
  6673. else if (a >= s && a < (s * 2)) {
  6674. if (random <= 0.3) {
  6675. treeNum = b;
  6676. }
  6677. else if (random > 0.3 && random <= 0.8) {
  6678. treeNum = b + 1;
  6679. }
  6680. else {
  6681. treeNum = b + 2;
  6682. }
  6683. }
  6684. else {
  6685. if (random <= 0.1) {
  6686. treeNum = b;
  6687. }
  6688. else if (random > 0.1 && random <= 0.6) {
  6689. treeNum = b + 1;
  6690. }
  6691. else {
  6692. treeNum = b + 2;
  6693. }
  6694. }
  6695. }
  6696. }
  6697. else {
  6698. s = 15;
  6699. a = (this.curLevel - 29) % (s * 3);
  6700. b = Math.floor((this.curLevel - 29) / 45) + 2;
  6701. if (a > 0 && a <= s) {
  6702. if (random <= 0.3) {
  6703. treeNum = b;
  6704. }
  6705. else {
  6706. treeNum = b + 1;
  6707. }
  6708. }
  6709. else if (a > s && a <= (s * 2)) {
  6710. if (random <= 0.3) {
  6711. treeNum = b;
  6712. }
  6713. else if (random > 0.3 && random <= 0.8) {
  6714. treeNum = b + 1;
  6715. }
  6716. else {
  6717. treeNum = b + 2;
  6718. }
  6719. }
  6720. else {
  6721. if (random <= 0.1) {
  6722. treeNum = b;
  6723. }
  6724. else if (random > 0.1 && random <= 0.6) {
  6725. treeNum = b + 1;
  6726. }
  6727. else {
  6728. treeNum = b + 2;
  6729. }
  6730. }
  6731. }
  6732. return treeNum;
  6733. }
  6734. getTreeExistingRotation() {
  6735. let existingRotation = [];
  6736. for (let i = 0; i < this.bindToSunTreeArr.length; i++) {
  6737. existingRotation.push(this.bindToSunTreeArr[i].rotation);
  6738. }
  6739. return existingRotation;
  6740. }
  6741. getInnerPlanetExistingRotation() {
  6742. let existingRotation = [];
  6743. for (let i = 0; i < this.innerPlanets.length; i++) {
  6744. existingRotation.push(this.innerPlanets[i].rotationSun);
  6745. }
  6746. return existingRotation;
  6747. }
  6748. getOuterPlanetExistingRotation() {
  6749. let existingRotation = [];
  6750. for (let i = 0; i < this.outerPlanets.length; i++) {
  6751. existingRotation.push(this.outerPlanets[i].rotationSun);
  6752. }
  6753. return existingRotation;
  6754. }
  6755. generateTrees(treeNum, treePoint) {
  6756. let sun = MainScene.sun.treeNode;
  6757. let rSub = MyConsts.treeThorough;
  6758. let TreeExistingRotation = this.getTreeExistingRotation();
  6759. if (TreeExistingRotation.length >= 24)
  6760. return;
  6761. let treeInfo = this.getRandomPoint2(treeNum, sun.width / 2 - rSub, TreeExistingRotation, 15);
  6762. let newTree = [];
  6763. for (let i = 0; i < treeNum; i++) {
  6764. let tree = Laya.Pool.getItemByClass("tree", Tree);
  6765. sun.addChild(tree);
  6766. if (treePoint) {
  6767. let point = [treePoint.x + this.sunPos[0], treePoint.y + this.sunPos[1]];
  6768. tree.pos(point[0], point[1]);
  6769. tree.rotation = treePoint.rotation;
  6770. }
  6771. else {
  6772. let point = [treeInfo[0][i][0] + this.sunPos[0], treeInfo[0][i][1] + this.sunPos[1]];
  6773. let rotation = treeInfo[1][i];
  6774. tree.pos(point[0], point[1]);
  6775. tree.rotation = rotation;
  6776. }
  6777. tree.textID_tree.text = tree.rotation + "";
  6778. this.bindToSunTreeArr.push(tree);
  6779. newTree.push(tree);
  6780. }
  6781. return newTree;
  6782. }
  6783. getRandomPoint(targetNum, r, existingRotation) {
  6784. if (existingRotation.length > 12)
  6785. return;
  6786. let s = Math.sqrt(3);
  6787. let pointArr = [
  6788. [0, 1], [-0.5, 0.5 * s], [-0.5 * s, 0.5],
  6789. [-1, 0], [-0.5 * s, -0.5], [-0.5, -0.5 * s],
  6790. [0, -1], [0.5, -0.5 * s], [0.5 * s, -0.5],
  6791. [1, 0], [0.5 * s, 0.5], [0.5, 0.5 * s]
  6792. ];
  6793. let treeInfo = [];
  6794. let treePoint = [];
  6795. let treeRotation = [];
  6796. treeInfo.push(treePoint);
  6797. treeInfo.push(treeRotation);
  6798. let curArr = [];
  6799. for (let i = 0; i < existingRotation.length; i++) {
  6800. curArr.push(existingRotation[i] / 30);
  6801. }
  6802. let numArr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
  6803. for (let i = 0; i < curArr.length; i++) {
  6804. for (let j = 0; j < numArr.length; j++) {
  6805. if (curArr[i] == numArr[j]) {
  6806. numArr.splice(j, 1);
  6807. }
  6808. }
  6809. }
  6810. if (numArr.length == 0)
  6811. return;
  6812. for (let i = 0; i < targetNum; i++) {
  6813. let randomNum = Math.floor(Math.random() * numArr.length);
  6814. let random = numArr[randomNum];
  6815. let point = [pointArr[random][0] * r, pointArr[random][1] * r];
  6816. treePoint.push(point);
  6817. treeRotation.push(30 * random);
  6818. numArr.splice(randomNum, 1);
  6819. }
  6820. return treeInfo;
  6821. }
  6822. getRandomPoint2(targetNum, r, existingRotation, angleRestriction) {
  6823. let totalPointNum = 360 / angleRestriction;
  6824. if (existingRotation.length > totalPointNum)
  6825. return;
  6826. let pointArr = [];
  6827. for (let i = 0; i < totalPointNum; i++) {
  6828. let angle = angleRestriction * i;
  6829. let radian = Math.PI / 180 * angle;
  6830. let pointX = Math.cos(radian) * r;
  6831. let pointY = Math.sin(radian) * r;
  6832. pointArr.push([pointX, pointY]);
  6833. }
  6834. let treeInfo = [];
  6835. let treePoint = [];
  6836. let treeRotation = [];
  6837. treeInfo.push(treePoint);
  6838. treeInfo.push(treeRotation);
  6839. let curArr = [];
  6840. for (let i = 0; i < existingRotation.length; i++) {
  6841. let rotation2 = existingRotation[i] + 90;
  6842. if (rotation2 >= 360) {
  6843. rotation2 -= 360;
  6844. }
  6845. curArr.push(rotation2 / angleRestriction);
  6846. }
  6847. let numArr = [];
  6848. for (let i = 0; i < totalPointNum; i++) {
  6849. numArr.push(i);
  6850. }
  6851. for (let i = 0; i < curArr.length; i++) {
  6852. for (let j = 0; j < numArr.length; j++) {
  6853. if (curArr[i] == numArr[j]) {
  6854. numArr.splice(j, 1);
  6855. }
  6856. }
  6857. }
  6858. if (numArr.length == 0)
  6859. return;
  6860. for (let i = 0; i < targetNum; i++) {
  6861. let randomNum = Math.floor(Math.random() * numArr.length);
  6862. let random = numArr[randomNum];
  6863. let point = [pointArr[random][0], pointArr[random][1]];
  6864. treePoint.push(point);
  6865. let rotation2 = angleRestriction * random - 90;
  6866. if (rotation2 < 0) {
  6867. rotation2 += 360;
  6868. }
  6869. rotation2 = MathTool.angleBePositive(rotation2);
  6870. treeRotation.push(rotation2);
  6871. numArr.splice(randomNum, 1);
  6872. }
  6873. return treeInfo;
  6874. }
  6875. generatePlanet(planetNums) {
  6876. let randomDirection = Math.round(Math.random());
  6877. for (let i = 0; i < planetNums.length; i++) {
  6878. let planetNum = planetNums[i];
  6879. if (planetNum > 0) {
  6880. for (let j = 0; j < planetNum; j++) {
  6881. let planet = Laya.Pool.getItemByClass("Planet", Planet);
  6882. planet.planetType = i;
  6883. this.allPlanets.push(planet);
  6884. }
  6885. }
  6886. }
  6887. this.allPlanets = MathTool.shuffle(this.allPlanets);
  6888. let planetTotalNum = this.planetsInfoAtCurLevel.planetTotalNum = this.allPlanets.length;
  6889. if (planetTotalNum <= 3) {
  6890. for (let i = 0; i < planetTotalNum; i++) {
  6891. this.allPlanets[i].orbit = 0;
  6892. this.planetsInfoAtCurLevel.innerRingPlanetNum = planetTotalNum;
  6893. this.planetsInfoAtCurLevel.outerRingPlanetNum = 0;
  6894. this.innerPlanets.push(this.allPlanets[i]);
  6895. }
  6896. }
  6897. else if (planetTotalNum > 3) {
  6898. for (let i = 0; i < planetTotalNum; i++) {
  6899. if (i < 10) {
  6900. let random = Math.round(Math.random());
  6901. let innerRingPlanetNum = this.planetsInfoAtCurLevel.innerRingPlanetNum;
  6902. let outerRingPlanetNum = this.planetsInfoAtCurLevel.outerRingPlanetNum;
  6903. if (innerRingPlanetNum >= 5) {
  6904. this.allPlanets[i].orbit = 1;
  6905. this.planetsInfoAtCurLevel.outerRingPlanetNum += 1;
  6906. this.outerPlanets.push(this.allPlanets[i]);
  6907. }
  6908. else {
  6909. if (random == 1) {
  6910. if (outerRingPlanetNum + 1 > innerRingPlanetNum) {
  6911. this.allPlanets[i].orbit = 0;
  6912. this.planetsInfoAtCurLevel.innerRingPlanetNum += 1;
  6913. this.innerPlanets.push(this.allPlanets[i]);
  6914. }
  6915. else {
  6916. this.allPlanets[i].orbit = 1;
  6917. this.planetsInfoAtCurLevel.outerRingPlanetNum += 1;
  6918. this.outerPlanets.push(this.allPlanets[i]);
  6919. }
  6920. }
  6921. else {
  6922. this.allPlanets[i].orbit = 0;
  6923. this.planetsInfoAtCurLevel.innerRingPlanetNum += 1;
  6924. this.innerPlanets.push(this.allPlanets[i]);
  6925. }
  6926. }
  6927. }
  6928. else {
  6929. this.leftoverPlanets.push(this.allPlanets[i]);
  6930. }
  6931. }
  6932. }
  6933. let innerNode = MainScene.sun.planetInnerRingNode;
  6934. let outerNode = MainScene.sun.planetOuterRingNode;
  6935. let innerRingPlanetNum = this.innerPlanets.length;
  6936. let outerRingPlanetNum = this.outerPlanets.length;
  6937. let InnerPlanetExistingRotation = this.getInnerPlanetExistingRotation();
  6938. let OuterPlanetExistingRotation = this.getInnerPlanetExistingRotation();
  6939. let pointInfo_innerRing = this.getRandomPoint(innerRingPlanetNum, innerNode.width / 2, InnerPlanetExistingRotation);
  6940. let pointInfo_outerRing = this.getRandomPoint(outerRingPlanetNum, outerNode.width / 2, OuterPlanetExistingRotation);
  6941. for (let i = 0; i < innerRingPlanetNum; i++) {
  6942. let planet = this.innerPlanets[i];
  6943. planet.planetInit();
  6944. innerNode.addChild(planet);
  6945. planet.rotationSun = pointInfo_innerRing[1][i];
  6946. planet.radian = Math.PI / 180 * pointInfo_innerRing[1][i];
  6947. planet.revolveCenterDistance = MainScene.sun.planetInnerRing.width / 2;
  6948. planet.revolvedirection = (randomDirection == 0) ? 1 : -1;
  6949. planet.pos(planet.revolveCenter[0] + Math.cos(planet.angle) * planet.revolveCenterDistance, planet.revolveCenter[1] + Math.sin(planet.angle) * planet.revolveCenterDistance);
  6950. }
  6951. for (let i = 0; i < outerRingPlanetNum; i++) {
  6952. let planet = this.outerPlanets[i];
  6953. planet.planetInit();
  6954. outerNode.addChild(planet);
  6955. planet.rotationSun = pointInfo_outerRing[1][i];
  6956. planet.radian = Math.PI / 180 * pointInfo_outerRing[1][i];
  6957. planet.revolveCenterDistance = MainScene.sun.planetOuterRing.width / 2;
  6958. planet.revolvedirection = (randomDirection == 0) ? -1 : 1;
  6959. planet.pos(planet.revolveCenter[0] + Math.cos(planet.angle) * planet.revolveCenterDistance, planet.revolveCenter[1] + Math.sin(planet.angle) * planet.revolveCenterDistance);
  6960. }
  6961. let sun = MainScene.sun;
  6962. if (this.innerPlanets.length > 0) {
  6963. sun.planetInnerRingNode.visible = true;
  6964. Laya.Tween.to(sun.planetInnerRingNode, { alpha: 1 }, 500);
  6965. }
  6966. if (this.outerPlanets.length > 0) {
  6967. sun.planetOuterRingNode.visible = true;
  6968. Laya.Tween.to(sun.planetOuterRingNode, { alpha: 1 }, 500);
  6969. }
  6970. }
  6971. planetBReplaceA(planetA) {
  6972. if (this.leftoverPlanets.length <= 0)
  6973. return;
  6974. let planetB = this.leftoverPlanets[0];
  6975. this.leftoverPlanets.splice(0, 1);
  6976. planetB.orbit = planetA.orbit;
  6977. planetB.planetInit();
  6978. planetA.parent.addChild(planetB);
  6979. planetB.radian = planetA.radian;
  6980. planetB.revolveCenterDistance = planetA.revolveCenterDistance;
  6981. planetB.revolvedirection = planetA.revolvedirection;
  6982. planetB.pos(planetA.x, planetA.y);
  6983. switch (planetB.orbit) {
  6984. case 0:
  6985. this.innerPlanets.push(planetB);
  6986. break;
  6987. case 1:
  6988. this.outerPlanets.push(planetB);
  6989. break;
  6990. default:
  6991. break;
  6992. }
  6993. return planetB;
  6994. }
  6995. getGeneratePlanetNums() {
  6996. let planetNums = [0, 0, 0, 0, 0];
  6997. let levelNum = this.curLevel;
  6998. let isBossLevel = levelNum % 5;
  6999. let bossLevelPlanetNum = Math.floor(levelNum / 5);
  7000. if (levelNum <= 34) {
  7001. if (isBossLevel == 0) {
  7002. if (levelNum == 30) {
  7003. bossLevelPlanetNum = 5;
  7004. }
  7005. for (let i = 0; i < bossLevelPlanetNum; i++) {
  7006. planetNums[i] = 1;
  7007. }
  7008. }
  7009. else {
  7010. if (levelNum <= 4 || levelNum == 6 || levelNum == 7) {
  7011. planetNums = [0, 0, 0, 0, 0];
  7012. }
  7013. else if (levelNum == 8 || levelNum == 9) {
  7014. planetNums = [1, 0, 0, 0, 0];
  7015. }
  7016. else if (levelNum >= 11 && levelNum < 25) {
  7017. let targetPlanetNum = bossLevelPlanetNum - 1;
  7018. planetNums = this.getPlanetFromUnloackedPlanet(targetPlanetNum, bossLevelPlanetNum);
  7019. }
  7020. else if (levelNum >= 26 && levelNum <= 29) {
  7021. planetNums = this.getPlanetFromUnloackedPlanet(3, 5);
  7022. }
  7023. else if (levelNum >= 31 && levelNum <= 34) {
  7024. planetNums = this.getPlanetFromUnloackedPlanet(4, 5);
  7025. }
  7026. }
  7027. }
  7028. else if (levelNum >= 35 && levelNum <= 59) {
  7029. if (isBossLevel == 0) {
  7030. planetNums = this.getPlanetFromUnloackedPlanet(6, 5);
  7031. }
  7032. else {
  7033. planetNums = [1, 1, 1, 1, 1];
  7034. }
  7035. }
  7036. else {
  7037. if (isBossLevel == 0) {
  7038. let targetPlanetNum = Math.floor((this.curLevel - 60) / 30) + 7;
  7039. planetNums = this.getPlanetFromUnloackedPlanet(targetPlanetNum, 5);
  7040. }
  7041. else {
  7042. let targetPlanetNum = Math.floor((this.curLevel - 60) / 30) + 6;
  7043. planetNums = this.getPlanetFromUnloackedPlanet(targetPlanetNum, 5);
  7044. }
  7045. }
  7046. return planetNums;
  7047. }
  7048. getPlanetFromUnloackedPlanet(targetPlanetNum, unlockedPlanetNum) {
  7049. let planetNums = [0, 0, 0, 0, 0];
  7050. let unlockedPlanetArr = [];
  7051. for (let i = 0; i < unlockedPlanetNum; i++) {
  7052. unlockedPlanetArr[i] = i;
  7053. }
  7054. for (let i = 0; i < targetPlanetNum; i++) {
  7055. if (unlockedPlanetArr.length == 0) {
  7056. for (let i = 0; i < unlockedPlanetNum; i++) {
  7057. unlockedPlanetArr[i] = i;
  7058. }
  7059. }
  7060. let a = Math.random();
  7061. let b = a * unlockedPlanetArr.length;
  7062. let c = Math.floor(b);
  7063. planetNums[unlockedPlanetArr[c]] += 1;
  7064. unlockedPlanetArr.splice(c, 1);
  7065. }
  7066. return planetNums;
  7067. }
  7068. checkNewPlanet() {
  7069. let planet = 0;
  7070. if (this.curLevel <= 25 && this.curLevel % 5 == 0) {
  7071. planet = this.curLevel / 5;
  7072. }
  7073. return planet;
  7074. }
  7075. levelStart() {
  7076. let levelNum = MainScene.gameControl.maxLevel + 1;
  7077. MainScene.instance.updateGameState(2);
  7078. this.isStartGame = true;
  7079. if (this.curBeReadyKnife) {
  7080. this.curBeReadyKnife.alpha = 0;
  7081. this.curBeReadyKnife.removeSelf();
  7082. Laya.Pool.recover("Knife", this.curBeReadyKnife);
  7083. }
  7084. this.clearCurKnifeArr();
  7085. let startFun = function () {
  7086. let gamecontrol = MainScene.gameControl;
  7087. gamecontrol.curLevel = levelNum;
  7088. gamecontrol.knifeRestNum = gamecontrol.knifeInfo.knifeTotalNum;
  7089. gamecontrol.bindToSunKnifeArr = [];
  7090. gamecontrol.bindToSunTreeArr = [];
  7091. gamecontrol.planetsInfoAtCurLevel.innerRingPlanetNum = 0;
  7092. gamecontrol.planetsInfoAtCurLevel.outerRingPlanetNum = 0;
  7093. gamecontrol.allPlanets = [];
  7094. gamecontrol.innerPlanets = [];
  7095. gamecontrol.outerPlanets = [];
  7096. gamecontrol.leftoverPlanets = [];
  7097. gamecontrol.coinNumFromCurLevel = 0;
  7098. gamecontrol.reviveChance = 1;
  7099. gamecontrol.propInvincibleRocketNum = 0;
  7100. gamecontrol.propInvincibleRocketTotalNum = 0;
  7101. gamecontrol.launchRocketTag = 1;
  7102. MainScene.instance.dialog_freelyGetProp.init();
  7103. MainScene.sun.shieldBlood = 0;
  7104. gamecontrol.updateGameUI();
  7105. if (gamecontrol.nextChangeDirLevel <= gamecontrol.curLevel) {
  7106. let levelNum = Math.ceil(Math.random() * 3) + gamecontrol.curLevel;
  7107. gamecontrol.nextChangeDirLevel = levelNum;
  7108. MainScene.sun.sunRotateDirection = -MainScene.sun.sunRotateDirection;
  7109. }
  7110. let treeNum = gamecontrol.getTreesNum();
  7111. if (treeNum > 0)
  7112. gamecontrol.generateTrees(treeNum);
  7113. let planetNums = gamecontrol.getGeneratePlanetNums();
  7114. let planetType = gamecontrol.checkNewPlanet();
  7115. if (planetType >= 1 && planetType <= 5) {
  7116. let dialogUnlockPlanet = MainScene.instance.dialog_unlockPlanet;
  7117. dialogUnlockPlanet.planetIcon.loadImage(gamecontrol.planetsInfo[planetType - 1].url);
  7118. dialogUnlockPlanet.planetIcon.width = dialogUnlockPlanet.planetIcon.texture.width;
  7119. dialogUnlockPlanet.planetIcon.height = dialogUnlockPlanet.planetIcon.texture.height;
  7120. dialogUnlockPlanet.planetIcon.pivotX = dialogUnlockPlanet.planetIcon.width / 2;
  7121. dialogUnlockPlanet.planetIcon.pivotY = dialogUnlockPlanet.planetIcon.height / 2;
  7122. dialogUnlockPlanet.planetIcon.pos(0, 0);
  7123. dialogUnlockPlanet.planetName.text = gamecontrol.planetsInfo[planetType - 1].name;
  7124. dialogUnlockPlanet.planetSkill.text = gamecontrol.planetsInfo[planetType - 1].skill;
  7125. dialogUnlockPlanet.show();
  7126. }
  7127. Laya.timer.once(500, gamecontrol, () => {
  7128. gamecontrol.generatePlanet(planetNums);
  7129. });
  7130. Laya.timer.once(100, gamecontrol, function () {
  7131. MainScene.instance.touchArea.on(Laya.Event.MOUSE_DOWN, gamecontrol, gamecontrol.onGameStageClick);
  7132. });
  7133. MainScene.sun.levelInit();
  7134. gamecontrol.attackSunTime = Laya.Browser.now();
  7135. Laya.timer.loop(1000, gamecontrol, gamecontrol.checkSunAttack);
  7136. };
  7137. PlatfromContro.hideBanner();
  7138. AnimationControl.startGameBtnAni();
  7139. Laya.timer.once(1000, this, function () {
  7140. startFun();
  7141. AnimationControl.gameUIMoveIn();
  7142. });
  7143. }
  7144. levelStartInGame() {
  7145. let levelNum = MainScene.gameControl.maxLevel + 1;
  7146. MainScene.instance.updateGameState(2);
  7147. this.isStartGame = true;
  7148. if (this.curBeReadyKnife) {
  7149. this.curBeReadyKnife.alpha = 0;
  7150. this.curBeReadyKnife.removeSelf();
  7151. Laya.Pool.recover("Knife", this.curBeReadyKnife);
  7152. }
  7153. this.clearCurKnifeArr();
  7154. let startFun = function () {
  7155. let gamecontrol = MainScene.gameControl;
  7156. gamecontrol.curLevel = levelNum;
  7157. gamecontrol.knifeRestNum = gamecontrol.knifeInfo.knifeTotalNum;
  7158. gamecontrol.bindToSunKnifeArr = [];
  7159. gamecontrol.bindToSunTreeArr = [];
  7160. gamecontrol.planetsInfoAtCurLevel.innerRingPlanetNum = 0;
  7161. gamecontrol.planetsInfoAtCurLevel.outerRingPlanetNum = 0;
  7162. gamecontrol.allPlanets = [];
  7163. gamecontrol.innerPlanets = [];
  7164. gamecontrol.outerPlanets = [];
  7165. gamecontrol.leftoverPlanets = [];
  7166. gamecontrol.coinNumFromCurLevel = 0;
  7167. gamecontrol.reviveChance = 1;
  7168. gamecontrol.propInvincibleRocketNum = 0;
  7169. gamecontrol.propInvincibleRocketTotalNum = 0;
  7170. gamecontrol.launchRocketTag = 1;
  7171. MainScene.instance.dialog_freelyGetProp.init();
  7172. MainScene.sun.shieldBlood = 0;
  7173. gamecontrol.updateGameUI();
  7174. if (gamecontrol.nextChangeDirLevel <= gamecontrol.curLevel) {
  7175. let levelNum = Math.ceil(Math.random() * 3) + gamecontrol.curLevel;
  7176. gamecontrol.nextChangeDirLevel = levelNum;
  7177. MainScene.sun.sunRotateDirection = -MainScene.sun.sunRotateDirection;
  7178. }
  7179. let treeNum = gamecontrol.getTreesNum();
  7180. if (treeNum > 0)
  7181. gamecontrol.generateTrees(treeNum);
  7182. let planetNums = gamecontrol.getGeneratePlanetNums();
  7183. let planetType = gamecontrol.checkNewPlanet();
  7184. if (planetType >= 1 && planetType <= 5) {
  7185. let dialogUnlockPlanet = MainScene.instance.dialog_unlockPlanet;
  7186. dialogUnlockPlanet.planetIcon.loadImage(gamecontrol.planetsInfo[planetType - 1].url);
  7187. dialogUnlockPlanet.planetIcon.width = dialogUnlockPlanet.planetIcon.texture.width;
  7188. dialogUnlockPlanet.planetIcon.height = dialogUnlockPlanet.planetIcon.texture.height;
  7189. dialogUnlockPlanet.planetIcon.pivotX = dialogUnlockPlanet.planetIcon.width / 2;
  7190. dialogUnlockPlanet.planetIcon.pivotY = dialogUnlockPlanet.planetIcon.height / 2;
  7191. dialogUnlockPlanet.planetIcon.pos(0, 0);
  7192. dialogUnlockPlanet.planetName.text = gamecontrol.planetsInfo[planetType - 1].name;
  7193. dialogUnlockPlanet.planetSkill.text = gamecontrol.planetsInfo[planetType - 1].skill;
  7194. dialogUnlockPlanet.show();
  7195. }
  7196. Laya.timer.once(500, gamecontrol, () => {
  7197. gamecontrol.generatePlanet(planetNums);
  7198. });
  7199. Laya.timer.once(100, gamecontrol, function () {
  7200. MainScene.instance.touchArea.on(Laya.Event.MOUSE_DOWN, gamecontrol, gamecontrol.onGameStageClick);
  7201. });
  7202. MainScene.sun.levelInit();
  7203. gamecontrol.attackSunTime = Laya.Browser.now();
  7204. Laya.timer.loop(1000, gamecontrol, gamecontrol.checkSunAttack);
  7205. };
  7206. startFun();
  7207. }
  7208. checkSunAttack() {
  7209. let curTime = Laya.Browser.now();
  7210. if ((curTime - this.attackSunTime) / 1000 >= 5) {
  7211. if (this.isStartGame == true) {
  7212. MainScene.sun.switchEmoji(3);
  7213. }
  7214. }
  7215. }
  7216. stopGame() {
  7217. MainScene.instance.updateGameState(3);
  7218. this.isStartGame = false;
  7219. this.launchRocketTag = 1;
  7220. this.clearCurKnifeArr();
  7221. Laya.timer.clear(this, this.checkSunAttack);
  7222. if (this.curBeReadyKnife) {
  7223. this.curBeReadyKnife.removeSelf();
  7224. Laya.Pool.recover("Knife", this.curBeReadyKnife);
  7225. this.curBeReadyKnife = null;
  7226. }
  7227. }
  7228. levelOver() {
  7229. this.stopGame();
  7230. Laya.timer.clear(this, MainScene.sun.checkBlood);
  7231. let knifeNum = this.bindToSunKnifeArr.length;
  7232. for (let i = 0; i < knifeNum; i++) {
  7233. this.bindToSunKnifeArr[0].alpha = 0;
  7234. this.bindToSunKnifeArr[0].knifeImg.alpha = 0;
  7235. this.bindToSunKnifeArr[0].removeSelf();
  7236. Laya.Pool.recover("Knife", this.bindToSunKnifeArr[0]);
  7237. MainScene.gameControl.bindToSunKnifeArr.splice(0, 1);
  7238. }
  7239. let treeNum = this.bindToSunTreeArr.length;
  7240. for (let i = 0; i < treeNum; i++) {
  7241. this.bindToSunTreeArr[0].removeSelf();
  7242. Laya.Pool.recover("Tree", this.bindToSunTreeArr[0]);
  7243. MainScene.gameControl.bindToSunTreeArr.splice(0, 1);
  7244. }
  7245. Laya.stage.off(Laya.Event.MOUSE_DOWN, this, this.onGameStageClick);
  7246. for (let i = this.innerPlanets.length - 1; i >= 0; i--) {
  7247. let planet = this.innerPlanets[i];
  7248. planet.die(null, 1);
  7249. planet.removeSelf();
  7250. Laya.Pool.recover("Planet", planet);
  7251. Laya.timer.clear(planet, planet.rotate);
  7252. MainScene.gameControl.innerPlanets.splice(i, 1);
  7253. }
  7254. for (let i = this.outerPlanets.length - 1; i >= 0; i--) {
  7255. let planet = this.outerPlanets[i];
  7256. planet.die(null, 1);
  7257. planet.removeSelf();
  7258. Laya.Pool.recover("Planet", planet);
  7259. Laya.timer.clear(planet, planet.rotate);
  7260. MainScene.gameControl.outerPlanets.splice(i, 1);
  7261. }
  7262. Laya.timer.clear(this, this.checkSunAttack);
  7263. MainScene.sun.stopShieldAni();
  7264. MainScene.sun.gameover_clearAnimation();
  7265. }
  7266. levelFailed() {
  7267. this.stopGame();
  7268. this.clearCurKnifeArr();
  7269. this.launchRocketTag = 1;
  7270. let fun = function () {
  7271. MusicControl.gameFailed();
  7272. this.levelFailedHasNoReviveChance();
  7273. };
  7274. let percent = MainScene.sun.getPercentOfBlood();
  7275. if (percent > 0.5) {
  7276. MainScene.sun.switchEmoji(5);
  7277. Laya.timer.once(1000, this, fun);
  7278. }
  7279. else {
  7280. MainScene.sun.switchEmoji(6);
  7281. Laya.timer.once(1000, this, fun);
  7282. }
  7283. if (LibData.getGameMode()) {
  7284. BannerAd.showBannerAd();
  7285. }
  7286. }
  7287. levelFailedHasReviveChance() {
  7288. this.stopGame();
  7289. MainScene.instance.gameOverUI.show_failedRevive();
  7290. }
  7291. levelFailedHasNoReviveChance() {
  7292. this.stopGame();
  7293. MainScene.instance.gameOverUI.show_failedRePlay();
  7294. }
  7295. revive() {
  7296. this.attackSunTime = Laya.Browser.now();
  7297. Laya.timer.loop(1000, this, this.checkSunAttack);
  7298. this.launchRocketTag = 0;
  7299. if (this.curBeReadyKnife) {
  7300. this.curBeReadyKnife.alpha = 0;
  7301. this.curBeReadyKnife.removeSelf();
  7302. Laya.Pool.recover("Knife", this.curBeReadyKnife);
  7303. }
  7304. this.isStartGame = true;
  7305. this.reviveAni();
  7306. }
  7307. reviveAni_callback() {
  7308. let gameControl = MainScene.gameControl;
  7309. gameControl.propInvincibleRocketNum += 7;
  7310. gameControl.propInvincibleRocketTotalNum += 7;
  7311. MainScene.sun.subBlood(MainScene.sun.curBlood * 0.5);
  7312. let knifeNum = gameControl.bindToSunKnifeArr.length;
  7313. let treeNum = gameControl.bindToSunTreeArr.length;
  7314. if (knifeNum + treeNum <= 10) {
  7315. gameControl.removeKnifeFromSun(knifeNum);
  7316. gameControl.removeTreeFromSun(treeNum);
  7317. }
  7318. else {
  7319. let knifeP = knifeNum / (knifeNum + treeNum);
  7320. let knifeSubNum = Math.floor(10 * knifeP);
  7321. let treeSubNum = 10 - knifeSubNum;
  7322. gameControl.removeKnifeFromSun(knifeSubNum);
  7323. gameControl.removeTreeFromSun(treeSubNum);
  7324. }
  7325. gameControl.createKnife();
  7326. gameControl.updateGameUI();
  7327. }
  7328. reviveAni(callback) {
  7329. let aknifeSP = Laya.Pool.getItemByClass("aknifeSP", Laya.Sprite);
  7330. aknifeSP.loadImage("texture/GameScene/invincibleRocket.png");
  7331. aknifeSP.pivot(aknifeSP.width / 2, 0);
  7332. let startY = MainScene.instance.exampleKnife.y;
  7333. aknifeSP.pos(Laya.stage.width / 2, startY);
  7334. MainScene.instance.KnifeBox.addChild(aknifeSP);
  7335. let tp = new Laya.Point(MainScene.sun.sunNode.x, MainScene.sun.sunNode.y + MyConsts.knifeToSunCenter);
  7336. tp = MainScene.sun.localToGlobal(tp);
  7337. tp = MainScene.instance.KnifeBox.globalToLocal(tp);
  7338. let targetY = tp.y;
  7339. Laya.Tween.to(aknifeSP, { y: targetY }, 200, null, Laya.Handler.create(this, function () {
  7340. aknifeSP.removeSelf();
  7341. Laya.Pool.recover("aknifeSP", aknifeSP);
  7342. AnimationControl.reviveFireAni(MainScene.gameControl.reviveAni_callback);
  7343. }));
  7344. }
  7345. levelSuccessful() {
  7346. let addCoinNum = 1.5 * (2 * Math.pow(MainScene.gameControl.curLevel, 2) + 10 * MainScene.gameControl.curLevel + 10 * MainScene.gameControl.coinInfo.coinValue);
  7347. MainScene.gameControl.coinNumFromCurLevel += Math.floor(addCoinNum);
  7348. MainScene.gameControl.updateGameUI();
  7349. MainScene.gameControl.isStartGame = false;
  7350. MainScene.sun.switchEmoji(7);
  7351. MainScene.sun.clearRift();
  7352. let completeEvent = function () {
  7353. if (MainScene.gameControl.curLevel > MainScene.gameControl.maxLevel) {
  7354. let curLevel = MainScene.gameControl.curLevel;
  7355. MainScene.gameControl.setMaxLevel(curLevel);
  7356. if (curLevel == 10) {
  7357. MainScene.gameControl.critSystemInit();
  7358. }
  7359. else if (curLevel == 5) {
  7360. MainScene.gameControl.coinSystemInit();
  7361. MainScene.instance.coinDailyIncomeControl.init();
  7362. MainScene.instance.coinProfit.visible = true;
  7363. }
  7364. }
  7365. MainScene.instance.gameOverUI.show_success();
  7366. MusicControl.gameSuccess();
  7367. };
  7368. AnimationControl.sunDieAni(completeEvent, 1000);
  7369. if (LibData.getGameMode()) {
  7370. BannerAd.showBannerAd();
  7371. }
  7372. }
  7373. updateGameUI() {
  7374. let instance = MainScene.instance;
  7375. instance.text_levelNum.text = this.curLevel.toString();
  7376. if (this.propInvincibleRocketNum > 0) {
  7377. instance.invincibleRocketNum.visible = true;
  7378. instance.text_invincibleRocketNum.text = this.propInvincibleRocketNum + "/" + this.propInvincibleRocketTotalNum;
  7379. }
  7380. else {
  7381. instance.invincibleRocketNum.visible = false;
  7382. }
  7383. instance.text_rocketNum.text = this.knifeRestNum + "/" + this.knifeInfo.knifeTotalNum;
  7384. let coinStr = MathTool.currencyUnit(this.coinNumFromCurLevel);
  7385. instance.text_coinNumFromCurLevel.text = coinStr;
  7386. MainScene.sun.updateUI();
  7387. }
  7388. updateHomeUI() {
  7389. let instance = MainScene.instance;
  7390. let coinStr = MathTool.currencyUnit(this.holdCoinsNum);
  7391. instance.text_holdCoinsNum.text = coinStr;
  7392. let strengthStr = MathTool.currencyUnit(this.holdStrengthNum);
  7393. instance.text_holdStrengthNum.text = strengthStr;
  7394. let maxLevelNum = MainScene.gameControl.maxLevel;
  7395. if (maxLevelNum && maxLevelNum > 0) {
  7396. instance.sp_lastPassedLevelNum.visible = true;
  7397. instance.text_lastPassedLevelNum.text = MainScene.gameControl.maxLevel + "";
  7398. }
  7399. else {
  7400. instance.sp_lastPassedLevelNum.visible = false;
  7401. }
  7402. instance.text_lastPassedLevelNum.text = MainScene.gameControl.maxLevel + "";
  7403. instance.text_currentUnlockedLevelNum.text = MainScene.gameControl.maxLevel + 1 + "";
  7404. instance.text_nextLockedLevelNum.text = MainScene.gameControl.maxLevel + 2 + "";
  7405. instance.text_lastPassedLevelNum.pivotX = instance.text_lastPassedLevelNum.width / 2;
  7406. instance.text_currentUnlockedLevelNum.pivotX = instance.text_currentUnlockedLevelNum.width / 2;
  7407. instance.text_nextLockedLevelNum.pivotX = instance.text_nextLockedLevelNum.width / 2;
  7408. instance.text_knifeNumGrade.text = "[lv" + this.knifeInfo.knifeNumGrade + "]";
  7409. instance.text_knifeNum.text = "" + this.knifeInfo.knifeTotalNum;
  7410. let knifeUpgradeNumNeedCoinsStr = MathTool.currencyUnit(this.knifeInfo.knifeUpgradeNumNeedCoins);
  7411. instance.text_knifeUpgradeNumNeedCoins.text = knifeUpgradeNumNeedCoinsStr;
  7412. instance.text_knifeAttackGrade.text = "[lv" + this.knifeInfo.knifeAttackGrade + "]";
  7413. let knifeAttackStr = MathTool.currencyUnit(this.knifeInfo.knifeAttack);
  7414. instance.text_knifeAttack.text = knifeAttackStr;
  7415. let knifeUpgradeAttackNeedCoinsStr = MathTool.currencyUnit(this.knifeInfo.knifeUpgradeAttackNeedCoins);
  7416. instance.text_knifeUpgradeAttackNeedCoins.text = knifeUpgradeAttackNeedCoinsStr;
  7417. let upgradeTip = false;
  7418. if (this.holdCoinsNum < this.knifeInfo.knifeUpgradeNumNeedCoins) {
  7419. instance.btn_knifeUpgradeNumNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png";
  7420. }
  7421. else {
  7422. instance.btn_knifeUpgradeNumNeedCoins.skin = "texture/MainScene/TAB/btn_optional.png";
  7423. }
  7424. if (this.holdCoinsNum < this.knifeInfo.knifeUpgradeAttackNeedCoins) {
  7425. instance.btn_knifeUpgradeAttackNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png";
  7426. }
  7427. else {
  7428. instance.btn_knifeUpgradeAttackNeedCoins.skin = "texture/MainScene/TAB/btn_optional.png";
  7429. }
  7430. if (this.knifeInfo.knifeNumGrade < MyConsts.growSystemGradeLimit.knifeNum &&
  7431. this.holdCoinsNum >= this.knifeInfo.knifeUpgradeNumNeedCoins) {
  7432. upgradeTip = true;
  7433. }
  7434. if (this.knifeInfo.knifeAttackGrade < MyConsts.growSystemGradeLimit.knifeAttack &&
  7435. this.holdCoinsNum >= this.knifeInfo.knifeUpgradeAttackNeedCoins) {
  7436. upgradeTip = true;
  7437. }
  7438. if (this.knifeInfo.knifeNumGrade >= MyConsts.growSystemGradeLimit.knifeNum &&
  7439. this.knifeInfo.knifeAttackGrade >= MyConsts.growSystemGradeLimit.knifeAttack) {
  7440. upgradeTip = false;
  7441. }
  7442. if (MainScene.gameControl.getMaxLevel() < 1) {
  7443. upgradeTip = false;
  7444. }
  7445. instance.upgradeTip_knife.visible = upgradeTip;
  7446. instance.text_critChanceGrade.text = "[lv" + this.critInfo.critChanceGrade + "]";
  7447. instance.text_critChance.text = this.critInfo.critChance + "%";
  7448. let critUpgradeChanceNeedCoinsStr = MathTool.currencyUnit(this.critInfo.critUpgradeChanceNeedCoins);
  7449. instance.text_critUpgradeChanceNeedCoins.text = critUpgradeChanceNeedCoinsStr;
  7450. instance.text_critAttackGrade.text = "[lv" + this.critInfo.critAttackGrade + "]";
  7451. instance.text_critAttack.text = "" + this.critInfo.critAttack + "倍";
  7452. let critUpgradeAttackNeedCoinsStr = MathTool.currencyUnit(this.critInfo.critUpgradeAttackNeedCoins);
  7453. instance.text_critUpgradeAttackNeedCoins.text = critUpgradeAttackNeedCoinsStr;
  7454. upgradeTip = false;
  7455. if (this.holdCoinsNum < this.critInfo.critUpgradeChanceNeedCoins) {
  7456. instance.btn_critUpgradeChanceNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png";
  7457. }
  7458. else {
  7459. instance.btn_critUpgradeChanceNeedCoins.skin = "texture/MainScene/TAB/btn_optional.png";
  7460. }
  7461. if (this.holdCoinsNum < this.critInfo.critUpgradeAttackNeedCoins) {
  7462. instance.btn_critUpgradeAttackNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png";
  7463. }
  7464. else {
  7465. instance.btn_critUpgradeAttackNeedCoins.skin = "texture/MainScene/TAB/btn_optional.png";
  7466. }
  7467. if (this.critInfo.critChanceGrade < MyConsts.growSystemGradeLimit.critChance &&
  7468. this.holdCoinsNum >= this.critInfo.critUpgradeChanceNeedCoins) {
  7469. upgradeTip = true;
  7470. }
  7471. if (this.critInfo.critAttackGrade < MyConsts.growSystemGradeLimit.critAttack &&
  7472. this.holdCoinsNum >= this.critInfo.critUpgradeAttackNeedCoins) {
  7473. upgradeTip = true;
  7474. }
  7475. if (this.critInfo.critChanceGrade >= MyConsts.growSystemGradeLimit.critChance &&
  7476. this.critInfo.critAttackGrade >= MyConsts.growSystemGradeLimit.critAttack) {
  7477. upgradeTip = false;
  7478. }
  7479. if (this.maxLevel < 10)
  7480. upgradeTip = false;
  7481. instance.upgradeTip_crit.visible = upgradeTip;
  7482. instance.text_coinValueGrade.text = "[lv" + this.coinInfo.coinValueGrade + "]";
  7483. let coinValueStr = MathTool.currencyUnit(this.coinInfo.coinValue);
  7484. instance.text_coinValue.text = coinValueStr;
  7485. let coinUpgradeValueNeedCoinsStr = MathTool.currencyUnit(this.coinInfo.coinUpgradeValueNeedCoins);
  7486. instance.text_coinUpgradeValueNeedCoins.text = coinUpgradeValueNeedCoinsStr;
  7487. instance.text_coinProfitGrade.text = "[lv" + this.coinInfo.coinProfitGrade + "]";
  7488. let coinProfitStr = MathTool.currencyUnit(this.coinInfo.coinProfit);
  7489. instance.text_coinProfit.text = coinProfitStr;
  7490. let coinUpgradeProfitNeedCoinsStr = MathTool.currencyUnit(this.coinInfo.coinUpgradeProfitNeedCoins);
  7491. instance.text_coinUpgradeProfitNeedCoins.text = coinUpgradeProfitNeedCoinsStr;
  7492. upgradeTip = false;
  7493. if (this.holdCoinsNum < this.coinInfo.coinUpgradeValueNeedCoins) {
  7494. instance.btn_coinUpgradeValueNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png";
  7495. }
  7496. else {
  7497. instance.btn_coinUpgradeValueNeedCoins.skin = "texture/MainScene/TAB/btn_optional.png";
  7498. }
  7499. if (this.holdCoinsNum < this.coinInfo.coinUpgradeProfitNeedCoins) {
  7500. instance.btn_coinUpgradeProfitNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png";
  7501. }
  7502. else {
  7503. instance.btn_coinUpgradeProfitNeedCoins.skin = "texture/MainScene/TAB/btn_optional.png";
  7504. }
  7505. if (this.coinInfo.coinValueGrade < MyConsts.growSystemGradeLimit.coinValue &&
  7506. this.holdCoinsNum >= this.coinInfo.coinUpgradeValueNeedCoins) {
  7507. upgradeTip = true;
  7508. }
  7509. if (this.coinInfo.coinProfitGrade < MyConsts.growSystemGradeLimit.coinProfit &&
  7510. this.holdCoinsNum >= this.coinInfo.coinUpgradeProfitNeedCoins) {
  7511. upgradeTip = true;
  7512. }
  7513. if (this.coinInfo.coinValueGrade >= MyConsts.growSystemGradeLimit.coinValue &&
  7514. this.coinInfo.coinProfitGrade >= MyConsts.growSystemGradeLimit.coinProfit) {
  7515. upgradeTip = false;
  7516. }
  7517. if (this.maxLevel < 20)
  7518. upgradeTip = false;
  7519. instance.upgradeTip_coin.visible = upgradeTip;
  7520. this.updateGrowSystemUI();
  7521. }
  7522. checkNewPlayer() {
  7523. if (this.maxLevel == 1 && this.newPlayerTag == 0) {
  7524. MainScene.instance.updateGameState(3);
  7525. this.newPlayerTag = 1;
  7526. let instance = MainScene.instance;
  7527. instance.tipBox.visible = true;
  7528. let knifeBtn = instance.btn_knifeSystem;
  7529. let btnKnifePoint = knifeBtn.localToGlobal(new Laya.Point(knifeBtn.width / 2, knifeBtn.height / 2));
  7530. instance.tipBoxMask.pos(btnKnifePoint.x + 15, btnKnifePoint.y);
  7531. let point1 = instance.tipBoxMask.localToGlobal(new Laya.Point(50, 20));
  7532. this.fingerAni.pos(point1.x, point1.y);
  7533. this.fingerAni.visible = true;
  7534. instance.tipBoxMask.on(Laya.Event.MOUSE_DOWN, this, function () {
  7535. let upgradeBtn = instance.btn_knifeUpgradeAttackNeedCoins;
  7536. let btnUpgradePoint = upgradeBtn.localToGlobal(new Laya.Point(upgradeBtn.width / 2, upgradeBtn.height / 2));
  7537. instance.tipBoxMask.pos(btnUpgradePoint.x - 35, btnUpgradePoint.y + 10);
  7538. instance.tipBoxMask.width = upgradeBtn.width;
  7539. instance.tipBoxMask.height = upgradeBtn.height;
  7540. instance.showKnifeSystemUI();
  7541. let point2 = instance.btn_knifeUpgradeAttackNeedCoins.localToGlobal(new Laya.Point(100, 0));
  7542. this.fingerAni.pos(point2.x, point2.y);
  7543. Laya.timer.once(100, this, function () {
  7544. instance.tipBoxMask.on(Laya.Event.MOUSE_DOWN, this, function () {
  7545. instance.onKnifeUpgradeAttackNeedCoinsClick();
  7546. this.fingerAni.visible = false;
  7547. instance.tipBox.visible = false;
  7548. MainScene.instance.updateGameState(1);
  7549. upgradeBtn.scale(1, 1);
  7550. Laya.Tween.to(upgradeBtn, { scaleX: 0.8, scaleY: 0.8 }, 50);
  7551. Laya.timer.once(50, this, function () {
  7552. Laya.Tween.to(upgradeBtn, { scaleX: 1, scaleY: 1 }, 600);
  7553. });
  7554. MusicControl.btnClick();
  7555. });
  7556. });
  7557. });
  7558. }
  7559. }
  7560. checkLastKnifeAttack() {
  7561. let sun = MainScene.sun;
  7562. let gameControl = MainScene.gameControl;
  7563. let attack = gameControl.knifeInfo.knifeAttack;
  7564. if (attack < (sun.curBlood + sun.shieldBlood)) {
  7565. let instance = MainScene.instance;
  7566. let prop = instance.prop_rocket;
  7567. let point1 = prop.localToGlobal(new Laya.Point(prop.width / 2, prop.height / 2));
  7568. gameControl.fingerAni.pos(point1.x + 45, point1.y - 80);
  7569. gameControl.fingerAni.visible = true;
  7570. gameControl.fingerAni.scaleX = -1;
  7571. instance.tipBoxMask.pos(point1.x + 40, point1.y - 5);
  7572. instance.tipBoxMask.width = prop.width + 20;
  7573. instance.tipBoxMask.height = prop.height + 20;
  7574. instance.tipBox.visible = true;
  7575. instance.tipBoxMask.on(Laya.Event.MOUSE_DOWN, gameControl, function () {
  7576. gameControl.onRocketClick();
  7577. gameControl.fingerAni.destroy();
  7578. instance.tipBox.destroy();
  7579. gameControl.setPropTeach(true);
  7580. });
  7581. }
  7582. }
  7583. updateGrowSystemUI() {
  7584. let instance = MainScene.instance;
  7585. if (this.knifeInfo.knifeNumGrade >= MyConsts.growSystemGradeLimit.knifeNum) {
  7586. instance.btn_knifeUpgradeNumNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png";
  7587. instance.text_knifeUpgradeNumNeedCoins.text = "MAX";
  7588. }
  7589. if (this.knifeInfo.knifeAttackGrade >= MyConsts.growSystemGradeLimit.knifeAttack) {
  7590. instance.btn_knifeUpgradeAttackNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png";
  7591. instance.text_knifeUpgradeAttackNeedCoins.text = "MAX";
  7592. }
  7593. if (this.critInfo.critChanceGrade >= MyConsts.growSystemGradeLimit.critChance) {
  7594. instance.btn_critUpgradeChanceNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png";
  7595. instance.text_critUpgradeChanceNeedCoins.text = "MAX";
  7596. }
  7597. if (this.critInfo.critAttackGrade >= MyConsts.growSystemGradeLimit.critAttack) {
  7598. instance.btn_critUpgradeAttackNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png";
  7599. instance.text_critUpgradeAttackNeedCoins.text = "MAX";
  7600. }
  7601. if (this.coinInfo.coinValueGrade >= MyConsts.growSystemGradeLimit.coinValue) {
  7602. instance.btn_coinUpgradeValueNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png";
  7603. instance.text_coinUpgradeValueNeedCoins.text = "MAX";
  7604. }
  7605. if (this.coinInfo.coinProfitGrade >= MyConsts.growSystemGradeLimit.coinProfit) {
  7606. instance.btn_coinUpgradeProfitNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png";
  7607. instance.text_coinUpgradeProfitNeedCoins.text = "MAX";
  7608. }
  7609. }
  7610. upGradeKnifeNum() {
  7611. if (this.holdCoinsNum < this.knifeInfo.knifeUpgradeNumNeedCoins) {
  7612. if (this.maxLevel >= 5) {
  7613. MainScene.instance.dialog_speedUpCoinProfit.show();
  7614. }
  7615. return;
  7616. }
  7617. if (this.knifeInfo.knifeNumGrade >= MyConsts.growSystemGradeLimit.knifeNum)
  7618. return;
  7619. this.holdCoinsNum -= this.knifeInfo.knifeUpgradeNumNeedCoins;
  7620. this.setHoldCoinsNum(this.holdCoinsNum);
  7621. this.knifeInfo.knifeNumGrade += 1;
  7622. this.knifeInfo.knifeTotalNum += 1;
  7623. this.knifeInfo.knifeUpgradeNumNeedCoins += (65 * this.knifeInfo.knifeNumGrade);
  7624. this.setKnifeInfo(this.knifeInfo);
  7625. this.updateHomeUI();
  7626. if (this.critInfo.critChanceGrade >= MyConsts.growSystemGradeLimit.critChance) {
  7627. MainScene.instance.btn_critUpgradeChanceNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png";
  7628. }
  7629. }
  7630. upGradeKnifeAttack() {
  7631. if (this.holdCoinsNum < this.knifeInfo.knifeUpgradeAttackNeedCoins) {
  7632. if (this.maxLevel >= 5) {
  7633. MainScene.instance.dialog_speedUpCoinProfit.show();
  7634. }
  7635. return;
  7636. }
  7637. if (this.knifeInfo.knifeAttackGrade >= MyConsts.growSystemGradeLimit.knifeAttack)
  7638. return;
  7639. this.holdCoinsNum -= this.knifeInfo.knifeUpgradeAttackNeedCoins;
  7640. this.setHoldCoinsNum(this.holdCoinsNum);
  7641. this.knifeInfo.knifeAttackGrade += 1;
  7642. this.knifeInfo.knifeAttack += (10 * this.knifeInfo.knifeAttackGrade);
  7643. this.knifeInfo.knifeUpgradeAttackNeedCoins += (35 * this.knifeInfo.knifeAttackGrade);
  7644. this.setKnifeInfo(this.knifeInfo);
  7645. this.updateHomeUI();
  7646. if (this.knifeInfo.knifeAttackGrade >= MyConsts.growSystemGradeLimit.knifeAttack) {
  7647. MainScene.instance.btn_knifeUpgradeAttackNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png";
  7648. }
  7649. }
  7650. upGradeCritAttack() {
  7651. if (this.holdCoinsNum < this.critInfo.critUpgradeAttackNeedCoins) {
  7652. if (this.maxLevel >= 5) {
  7653. MainScene.instance.dialog_speedUpCoinProfit.show();
  7654. }
  7655. return;
  7656. }
  7657. if (this.critInfo.critAttackGrade >= MyConsts.growSystemGradeLimit.critAttack)
  7658. return;
  7659. this.holdCoinsNum -= this.critInfo.critUpgradeAttackNeedCoins;
  7660. this.setHoldCoinsNum(this.holdCoinsNum);
  7661. this.critInfo.critAttackGrade += 1;
  7662. this.critInfo.critAttack = Math.round((4 * this.critInfo.critAttackGrade / (this.critInfo.critAttackGrade + 6) - 0.57) * 100) / 100;
  7663. this.critInfo.critUpgradeAttackNeedCoins = 15 * this.critInfo.critAttackGrade;
  7664. this.setCritInfo(this.critInfo);
  7665. this.updateHomeUI();
  7666. if (this.critInfo.critAttackGrade >= MyConsts.growSystemGradeLimit.critAttack) {
  7667. MainScene.instance.btn_critUpgradeAttackNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png";
  7668. }
  7669. }
  7670. upGradeCritChance() {
  7671. if (this.holdCoinsNum < this.critInfo.critUpgradeChanceNeedCoins) {
  7672. if (this.maxLevel >= 5) {
  7673. MainScene.instance.dialog_speedUpCoinProfit.show();
  7674. }
  7675. return;
  7676. }
  7677. if (this.critInfo.critChanceGrade >= MyConsts.growSystemGradeLimit.critChance)
  7678. return;
  7679. this.holdCoinsNum -= this.critInfo.critUpgradeChanceNeedCoins;
  7680. this.setHoldCoinsNum(this.holdCoinsNum);
  7681. this.critInfo.critChanceGrade += 1;
  7682. this.critInfo.critChance = Math.round((this.critInfo.critChanceGrade / (3 * this.critInfo.critChanceGrade + 50)) * 10000) / 100;
  7683. this.critInfo.critUpgradeChanceNeedCoins = 35 * this.critInfo.critChanceGrade;
  7684. this.setCritInfo(this.critInfo);
  7685. this.updateHomeUI();
  7686. if (this.critInfo.critChanceGrade >= MyConsts.growSystemGradeLimit.critChance) {
  7687. MainScene.instance.btn_critUpgradeChanceNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png";
  7688. }
  7689. }
  7690. upGradeCoinValue() {
  7691. if (this.holdCoinsNum < this.coinInfo.coinUpgradeValueNeedCoins) {
  7692. if (this.maxLevel >= 5) {
  7693. MainScene.instance.dialog_speedUpCoinProfit.show();
  7694. }
  7695. return;
  7696. }
  7697. if (this.coinInfo.coinValueGrade >= MyConsts.growSystemGradeLimit.coinValue)
  7698. return;
  7699. this.holdCoinsNum -= this.coinInfo.coinUpgradeValueNeedCoins;
  7700. this.setHoldCoinsNum(this.holdCoinsNum);
  7701. this.coinInfo.coinValueGrade += 1;
  7702. this.coinInfo.coinValue += 2;
  7703. this.coinInfo.coinUpgradeValueNeedCoins += 75;
  7704. this.setCoinInfo(this.coinInfo);
  7705. this.updateHomeUI();
  7706. if (this.coinInfo.coinValueGrade >= MyConsts.growSystemGradeLimit.coinValue) {
  7707. MainScene.instance.btn_coinUpgradeValueNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png";
  7708. }
  7709. }
  7710. upGradeCoinProfit() {
  7711. if (this.holdCoinsNum < this.coinInfo.coinUpgradeProfitNeedCoins) {
  7712. if (this.maxLevel >= 5) {
  7713. MainScene.instance.dialog_speedUpCoinProfit.show();
  7714. }
  7715. return;
  7716. }
  7717. if (this.coinInfo.coinProfitGrade >= MyConsts.growSystemGradeLimit.coinProfit)
  7718. return;
  7719. this.holdCoinsNum -= this.coinInfo.coinUpgradeProfitNeedCoins;
  7720. this.setHoldCoinsNum(this.holdCoinsNum);
  7721. this.coinInfo.coinProfitGrade += 1;
  7722. this.coinInfo.coinProfit += 2;
  7723. this.coinInfo.coinUpgradeProfitNeedCoins += 63;
  7724. this.setCoinInfo(this.coinInfo);
  7725. this.updateHomeUI();
  7726. if (this.coinInfo.coinProfitGrade >= MyConsts.growSystemGradeLimit.coinProfit) {
  7727. MainScene.instance.btn_coinUpgradeProfitNeedCoins.skin = "texture/MainScene/TAB/btn_notOptional.png";
  7728. }
  7729. }
  7730. removeKnifeFromSun(knifeNum) {
  7731. for (let i = 0; i < knifeNum; i++) {
  7732. if (this.bindToSunKnifeArr[i]) {
  7733. let gameControl = MainScene.gameControl;
  7734. let knife = gameControl.bindToSunKnifeArr[i];
  7735. AnimationControl.blowUpObstacle(knife);
  7736. Laya.Tween.to(knife.knifeImg, { alpha: 0 }, 300);
  7737. }
  7738. }
  7739. let gameControl = MainScene.gameControl;
  7740. Laya.timer.once(300, gameControl, function () {
  7741. for (let j = 0; j < knifeNum; j++) {
  7742. let knife = gameControl.bindToSunKnifeArr[0];
  7743. knife.alpha = 0;
  7744. knife.removeSelf();
  7745. Laya.Pool.recover("Knife", knife);
  7746. gameControl.bindToSunKnifeArr.splice(0, 1);
  7747. this.clearCurKnifeArr();
  7748. }
  7749. });
  7750. }
  7751. removeTreeFromSun(treeNum) {
  7752. if (treeNum < 1)
  7753. return;
  7754. for (let i = 0; i < treeNum; i++) {
  7755. if (this.bindToSunTreeArr[i]) {
  7756. let tree = this.bindToSunTreeArr[i];
  7757. AnimationControl.blowUpObstacle(tree);
  7758. }
  7759. }
  7760. let gameControl = MainScene.gameControl;
  7761. Laya.timer.once(300, gameControl, function () {
  7762. for (let j = 0; j < treeNum; j++) {
  7763. let tree = gameControl.bindToSunTreeArr[0];
  7764. if (tree) {
  7765. tree.removeSelf();
  7766. Laya.Pool.recover("Tree", tree);
  7767. gameControl.bindToSunTreeArr.splice(0, 1);
  7768. }
  7769. }
  7770. });
  7771. }
  7772. addTree(treePoint) {
  7773. let newTree = this.generateTrees(1, treePoint);
  7774. if (!newTree)
  7775. return;
  7776. for (let i = 0; i < newTree.length; i++) {
  7777. AnimationControl.planet_Jupiter_addTree(newTree[i]);
  7778. }
  7779. }
  7780. checkKnifeCrit(knife, parent, pos, scale) {
  7781. let knifeAttack = knife.attack;
  7782. let critChance = this.critInfo.critChance / 100;
  7783. let random = Math.random();
  7784. if (random <= critChance && this.critInfo.critAttack > 0) {
  7785. knifeAttack = knife.attack * this.critInfo.critAttack;
  7786. let attackNum = Math.floor(knifeAttack) + "";
  7787. AnimationControl.playCritNumAni(attackNum, parent, pos, scale);
  7788. }
  7789. else {
  7790. let attackNum = Math.floor(knife.attack) + "";
  7791. AnimationControl.playSubBloodNumAni(attackNum, parent, pos, scale);
  7792. }
  7793. return knifeAttack;
  7794. }
  7795. getPlayCount() {
  7796. return Data.getPlayCount();
  7797. }
  7798. setPlayCount(value) {
  7799. this.playCount = value;
  7800. Data.setPlayCount(value);
  7801. }
  7802. getMaxLevel() {
  7803. return Data.getMaxScore();
  7804. }
  7805. setMaxLevel(value) {
  7806. this.maxLevel = value;
  7807. Data.setMaxScore(value);
  7808. }
  7809. getHoldCoinsNum() {
  7810. return Data.getHoldCoinsNum();
  7811. }
  7812. setHoldCoinsNum(value) {
  7813. this.holdCoinsNum = value;
  7814. Data.setHoldCoinsNum(value);
  7815. }
  7816. getHoldStrengthNum() {
  7817. return Data.getHoldStrengthNum();
  7818. }
  7819. setHoldStrengthNum(value) {
  7820. this.holdStrengthNum = value;
  7821. Data.setHoldStrengthNum(value);
  7822. }
  7823. getKnifeInfo() {
  7824. let aknifeInfo = {
  7825. "knifeNumGrade": 0,
  7826. "knifeTotalNum": 0,
  7827. "knifeUpgradeNumNeedCoins": 0,
  7828. "knifeAttackGrade": 0,
  7829. "knifeAttack": 0,
  7830. "knifeUpgradeAttackNeedCoins": 0
  7831. };
  7832. let dataKnifeInfo = Data.getKnifeInfo();
  7833. aknifeInfo.knifeNumGrade = dataKnifeInfo.knifeNumGrade;
  7834. aknifeInfo.knifeTotalNum = dataKnifeInfo.knifeTotalNum;
  7835. aknifeInfo.knifeUpgradeNumNeedCoins = dataKnifeInfo.knifeUpgradeNumNeedCoins;
  7836. aknifeInfo.knifeAttackGrade = dataKnifeInfo.knifeAttackGrade;
  7837. aknifeInfo.knifeAttack = dataKnifeInfo.knifeAttack;
  7838. aknifeInfo.knifeUpgradeAttackNeedCoins = dataKnifeInfo.knifeUpgradeAttackNeedCoins;
  7839. return aknifeInfo;
  7840. }
  7841. setKnifeInfo(value) {
  7842. this.knifeInfo = value;
  7843. let aknifeInfo = {
  7844. "knifeNumGrade": value.knifeNumGrade,
  7845. "knifeTotalNum": value.knifeTotalNum,
  7846. "knifeUpgradeNumNeedCoins": value.knifeUpgradeNumNeedCoins,
  7847. "knifeAttackGrade": value.knifeAttackGrade,
  7848. "knifeAttack": value.knifeAttack,
  7849. "knifeUpgradeAttackNeedCoins": value.knifeUpgradeAttackNeedCoins
  7850. };
  7851. Data.setKnifeInfo(aknifeInfo);
  7852. }
  7853. getCritInfo() {
  7854. let aCritInfo = {
  7855. "critAttackGrade": 0,
  7856. "critAttack": 0,
  7857. "critUpgradeAttackNeedCoins": 0,
  7858. "critChanceGrade": 0,
  7859. "critChance": 0,
  7860. "critUpgradeChanceNeedCoins": 0
  7861. };
  7862. let dataCritInfo = Data.getCritInfo();
  7863. aCritInfo.critAttackGrade = dataCritInfo.critAttackGrade;
  7864. aCritInfo.critAttack = dataCritInfo.critAttack;
  7865. aCritInfo.critUpgradeAttackNeedCoins = dataCritInfo.critUpgradeAttackNeedCoins;
  7866. aCritInfo.critChanceGrade = dataCritInfo.critChanceGrade;
  7867. aCritInfo.critChance = dataCritInfo.critChance;
  7868. aCritInfo.critUpgradeChanceNeedCoins = dataCritInfo.critUpgradeChanceNeedCoins;
  7869. return aCritInfo;
  7870. }
  7871. setCritInfo(value) {
  7872. this.critInfo = value;
  7873. let acritInfo = {
  7874. "critAttackGrade": value.critAttackGrade,
  7875. "critAttack": value.critAttack,
  7876. "critUpgradeAttackNeedCoins": value.critUpgradeAttackNeedCoins,
  7877. "critChanceGrade": value.critChanceGrade,
  7878. "critChance": value.critChance,
  7879. "critUpgradeChanceNeedCoins": value.critUpgradeChanceNeedCoins
  7880. };
  7881. Data.setCritInfo(acritInfo);
  7882. }
  7883. getCoinInfo() {
  7884. let aCoinInfo = {
  7885. "coinValueGrade": 0,
  7886. "coinValue": 0,
  7887. "coinUpgradeValueNeedCoins": 0,
  7888. "coinProfitGrade": 0,
  7889. "coinProfit": 0,
  7890. "coinUpgradeProfitNeedCoins": 0
  7891. };
  7892. let dataCoinInfo = Data.getCoinInfo();
  7893. aCoinInfo.coinValueGrade = dataCoinInfo.coinValueGrade;
  7894. aCoinInfo.coinValue = dataCoinInfo.coinValue;
  7895. aCoinInfo.coinUpgradeValueNeedCoins = dataCoinInfo.coinUpgradeValueNeedCoins;
  7896. aCoinInfo.coinProfitGrade = dataCoinInfo.coinProfitGrade;
  7897. aCoinInfo.coinProfit = dataCoinInfo.coinProfit;
  7898. aCoinInfo.coinUpgradeProfitNeedCoins = dataCoinInfo.coinUpgradeProfitNeedCoins;
  7899. return aCoinInfo;
  7900. }
  7901. setCoinInfo(value) {
  7902. this.coinInfo = value;
  7903. let aCoinInfo = {
  7904. "coinValueGrade": value.coinValueGrade,
  7905. "coinValue": value.coinValue,
  7906. "coinUpgradeValueNeedCoins": value.coinUpgradeValueNeedCoins,
  7907. "coinProfitGrade": value.coinProfitGrade,
  7908. "coinProfit": value.coinProfit,
  7909. "coinUpgradeProfitNeedCoins": value.coinUpgradeProfitNeedCoins
  7910. };
  7911. Data.setCoinInfo(aCoinInfo);
  7912. }
  7913. getLastOfflineTime() {
  7914. return Data.getLastOfflineTime();
  7915. }
  7916. setThisOfflineTime() {
  7917. Data.setThisOfflineTime(Laya.Browser.now());
  7918. }
  7919. getRecoverStrengthCountDownStartTime() {
  7920. return Data.getRecoverStrengthCountDownStartTime();
  7921. }
  7922. saveRecoverStrengthCountDownStartTime(num) {
  7923. let startTime = num ? num : Laya.Browser.now();
  7924. this.recoverStrengthCountDownStartTime = startTime;
  7925. Data.setRecoverStrengthCountDownStartTime(startTime);
  7926. }
  7927. getPropTeach() {
  7928. return Data.getPropTeach();
  7929. }
  7930. setPropTeach(value) {
  7931. MainScene.gameControl.b_propTeach = value;
  7932. Data.setPropTeach(value);
  7933. }
  7934. }
  7935. class GameConfig {
  7936. constructor() {
  7937. }
  7938. static init() {
  7939. var reg = Laya.ClassUtils.regClass;
  7940. reg("game/BtnEffectControl.ts", BtnEffectControl);
  7941. reg("game/MainScene.ts", MainScene);
  7942. reg("game/GameControl.ts", GameControl);
  7943. }
  7944. }
  7945. GameConfig.width = 720;
  7946. GameConfig.height = 1280;
  7947. GameConfig.scaleMode = "fixedwidth";
  7948. GameConfig.screenMode = "vertical";
  7949. GameConfig.alignV = "middle";
  7950. GameConfig.alignH = "left";
  7951. GameConfig.startScene = "MainScene.scene";
  7952. GameConfig.sceneRoot = "";
  7953. GameConfig.debug = false;
  7954. GameConfig.stat = false;
  7955. GameConfig.physicsDebug = true;
  7956. GameConfig.exportSceneToJson = true;
  7957. GameConfig.init();
  7958. class Main {
  7959. constructor() {
  7960. if (window["Laya3D"])
  7961. Laya3D.init(GameConfig.width, GameConfig.height);
  7962. else
  7963. Laya.init(GameConfig.width, GameConfig.height, Laya["WebGL"]);
  7964. Laya["Physics"] && Laya["Physics"].enable();
  7965. Laya["DebugPanel"] && Laya["DebugPanel"].enable();
  7966. Laya.stage.scaleMode = GameConfig.scaleMode;
  7967. Laya.stage.screenMode = GameConfig.screenMode;
  7968. Laya.stage.alignV = GameConfig.alignV;
  7969. Laya.stage.alignH = GameConfig.alignH;
  7970. Laya.URL.exportSceneToJson = GameConfig.exportSceneToJson;
  7971. if (GameConfig.debug || Laya.Utils.getQueryString("debug") == "true")
  7972. Laya.enableDebugPanel();
  7973. if (GameConfig.physicsDebug && Laya["PhysicsDebugDraw"])
  7974. Laya["PhysicsDebugDraw"].enable();
  7975. if (GameConfig.stat)
  7976. Laya.Stat.show();
  7977. Laya.alertGlobalError = true;
  7978. Laya.ResourceVersion.enable("version.json", Laya.Handler.create(this, this.onVersionLoaded), Laya.ResourceVersion.FILENAME_VERSION);
  7979. }
  7980. onVersionLoaded() {
  7981. Laya.AtlasInfoManager.enable("fileconfig.json", Laya.Handler.create(this, this.onConfigLoaded));
  7982. }
  7983. onConfigLoaded() {
  7984. let wx = window["wx"];
  7985. if (wx) {
  7986. GameConfig.startScene && Laya.Scene.open(GameConfig.startScene);
  7987. }
  7988. else {
  7989. GameConfig.startScene && Laya.Scene.open(GameConfig.startScene);
  7990. }
  7991. }
  7992. }
  7993. new Main();
  7994. }());