bundle.js 252 KB

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