bundle.js 288 KB

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