game.min.js 177 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021
  1. function ImagesPreloader() {
  2. function e() {
  3. var n = 0,
  4. r = 0,
  5. i;
  6. for (i in t.loadedImages) t.loadedImages[i].complete && n++, r++;
  7. n >= r ? t.endCallback && t.endCallback(t.loadedImages) : (t.processCallback && t.processCallback(Math.floor(n / r * 100)), setTimeout(e, 50))
  8. }
  9. var t = this;
  10. this.curItem = -1;
  11. this.loadedImages = {};
  12. this.processCallback = this.endCallback = this.data = null;
  13. this.load = function(t, n, r) {
  14. this.data = t;
  15. this.endCallback = n;
  16. this.processCallback = r;
  17. for (t = 0; t < this.data.length; t++) n = this.data[t], r = new Image, r.src = n.src, this.loadedImages[n.name] = r;
  18. e()
  19. }
  20. }
  21. function Sprite(e, t, n, r, i) {
  22. this.uid = 0;
  23. this.stage = null;
  24. this.y = this.x = 0;
  25. this.width = t;
  26. this.height = n;
  27. this.offset = {
  28. left: 0,
  29. top: 0
  30. };
  31. this.anchor = {
  32. x: 0,
  33. y: 0
  34. };
  35. this.scaleY = this.scaleX = 1;
  36. this.zIndex = this.rotation = 0;
  37. this.visible = !0;
  38. this.opacity = 1;
  39. this.ignoreViewport = this["static"] = !1;
  40. this.animated = !0;
  41. this.currentFrame = 0;
  42. this.totalFrames = Math.max(1, ~~r);
  43. 1 >= this.totalFrames && (this.animated = !1);
  44. this.currentLayer = 0;
  45. this.totalLayers = Math.max(1, ~~i);
  46. this.bitmap = e;
  47. this.mask = null;
  48. this.destroy = this.fillColor = !1;
  49. this.animStep = 0;
  50. this.animDelay = 1;
  51. this.dragged = this.drawAlways = !1;
  52. this.dragY = this.dragX = 0;
  53. this.getX = function() {
  54. return Math.round(this.x * Utils.globalScale)
  55. };
  56. this.getY = function() {
  57. return Math.round(this.y * Utils.globalScale)
  58. };
  59. this.getWidth = function() {
  60. return this.width * Math.abs(this.scaleX) * Utils.globalScale
  61. };
  62. this.getHeight = function() {
  63. return this.height * Math.abs(this.scaleY) * Utils.globalScale
  64. };
  65. this.startDrag = function(e, t) {
  66. this.dragged = !0;
  67. this.dragX = e;
  68. this.dragY = t
  69. };
  70. this.stopDrag = function() {
  71. this.dragged = !1;
  72. this.dragY = this.dragX = 0
  73. };
  74. this.play = function() {
  75. this.animated = !0
  76. };
  77. this.stop = function() {
  78. this.animated = !1
  79. };
  80. this.gotoAndStop = function(e) {
  81. this.currentFrame = e;
  82. this.stop()
  83. };
  84. this.gotoAndPlay = function(e) {
  85. this.currentFrame = e;
  86. this.play()
  87. };
  88. this.removeTweens = function() {
  89. this.stage && this.stage.clearObjectTweens(this)
  90. };
  91. this.addTween = function(e, t, n, r, i, s) {
  92. if (this.stage) {
  93. var o = this[e];
  94. if (!isNaN(o)) return e = stage.createTween(this, e, o, t, n, r), e.onchange = s, e.onfinish = i, e
  95. }
  96. };
  97. this.moveTo = function(e, t, n, r, i, s) {
  98. n = ~~n;
  99. 0 >= n ? this.setPosition(e, t) : ((e = this.addTween("x", e, n, r, i, s)) && e.play(), (t = this.addTween("y", t, n, r, e ? null : i, e ? null : s)) && t.play());
  100. return this
  101. };
  102. this.moveBy = function(e, t, n, r, i, s) {
  103. return this.moveTo(this.x + e, this.y + t, n, r, i, s)
  104. };
  105. this.fadeTo = function(e, t, n, r, i) {
  106. t = ~~t;
  107. 0 >= t ? this.opacity = e : (e = this.addTween("opacity", e, t, n, r, i)) && e.play();
  108. return this
  109. };
  110. this.fadeBy = function(e, t, n, r, i) {
  111. e = Math.max(0, Math.min(1, this.opacity + e));
  112. return this.fadeTo(e, t, n, r, i)
  113. };
  114. this.rotateTo = function(e, t, n, r, i) {
  115. t = ~~t;
  116. 0 >= t ? this.rotation = e : (e = this.addTween("rotation", e, t, n, r, i)) && e.play();
  117. return this
  118. };
  119. this.rotateBy = function(e, t, n, r, i) {
  120. return this.rotateTo(this.rotation + e, t, n, r, i)
  121. };
  122. this.scaleTo = function(e, t, n, r, i) {
  123. t = ~~t;
  124. if (0 >= t) this.scaleX = this.scaleY = e;
  125. else {
  126. var s = this.addTween("scaleX", e, t, n, r, i);
  127. s && s.play();
  128. (e = this.addTween("scaleY", e, t, n, s ? null : r, s ? null : i)) && e.play()
  129. }
  130. return this
  131. };
  132. this.nextFrame = function() {
  133. this.dispatchEvent("enterframe", {
  134. target: this
  135. });
  136. this.animated && (this.animStep++, this.animStep >= this.animDelay && (this.currentFrame++, this.animStep = 0), this.currentFrame >= this.totalFrames && (this.currentFrame = 0))
  137. };
  138. this.eventsWhenInvisible = !1;
  139. this.onbox2dsync = this.onremove = this.onadd = this.onrender = this.onprerender = this.onenterframe = this.onmousemove = this.oncontextmenu = this.onclick = this.onmouseup = this.onmousedown = this.onmouseout = this.onmouseover = null;
  140. this.mouseOn = !1;
  141. this.getPosition = function() {
  142. return {
  143. x: this.x,
  144. y: this.y
  145. }
  146. };
  147. this.setPosition = function(e, t) {
  148. if ("undefined" == typeof t && "undefined" != typeof e.x && "undefined" != typeof e.y) return this.setPosition(e.x, e.y);
  149. this.x = parseFloat(e);
  150. this.y = parseFloat(t)
  151. };
  152. this.getAnchor = function() {
  153. return this.anchor
  154. };
  155. this.setAnchor = function(e, t) {
  156. if ("undefined" == typeof t && "undefined" != typeof e.x && "undefined" != typeof e.y) return this.setAnchor(e.x, e.y);
  157. this.anchor.x = parseFloat(e);
  158. this.anchor.y = parseFloat(t)
  159. };
  160. this.alignAnchor = function(e, t) {
  161. e = parseInt(e);
  162. isNaN(e) && (e = ANCHOR_ALIGN_CENTER);
  163. 0 > e && (e = ANCHOR_ALIGN_LEFT);
  164. 0 < e && (e = ANCHOR_ALIGN_RIGHT);
  165. t = parseInt(t);
  166. isNaN(t) && (t = ANCHOR_VALIGN_MIDDLE);
  167. 0 > t && (t = ANCHOR_VALIGN_TOP);
  168. 0 < t && (t = ANCHOR_VALIGN_BOTTOM);
  169. this.anchor.x = this.width * e / 2;
  170. this.anchor.y = this.height * t / 2;
  171. return this.getAnchor()
  172. };
  173. this.getAbsoluteAnchor = function() {
  174. return this.getPosition()
  175. };
  176. this.getRelativeCenter = function() {
  177. var e = this.getAnchor();
  178. if (0 == e.x && 0 == e.y) return e;
  179. e = new Vector(-e.x * this.scaleX, -e.y * this.scaleY);
  180. e.rotate(-this.rotation);
  181. return e
  182. };
  183. this.getAbsoluteCenter = function() {
  184. var e = this.getRelativeCenter(),
  185. e = {
  186. x: e.x,
  187. y: e.y
  188. };
  189. e.x += this.x;
  190. e.y += this.y;
  191. return e
  192. };
  193. this.getCenter = function() {
  194. return this.getAbsoluteCenter()
  195. };
  196. this.getDrawRectangle = function() {
  197. var e = this.getCenter(),
  198. t = new Rectangle(0, 0, this.width * Math.abs(this.scaleX), this.height * Math.abs(this.scaleY), this.rotation);
  199. t.move(e.x, e.y);
  200. return t
  201. };
  202. this.getAABBRectangle = function() {
  203. var e = this.getDrawRectangle(),
  204. t = e.AABB[1].x - e.AABB[0].x,
  205. n = e.AABB[1].y - e.AABB[0].y;
  206. return new Rectangle(e.AABB[0].x + t / 2, e.AABB[0].y + n / 2, t, n, 0)
  207. };
  208. this.localToGlobal = function(e, t) {
  209. var n = "object" == typeof e && "undefined" != typeof e.x && "undefined" != typeof e.y ? new Vector(e.x + 0, e.y + 0) : new Vector(e, t);
  210. n.rotate(this.rotation).add(this.getPosition());
  211. return n
  212. };
  213. this.globalToLocal = function(e, t) {
  214. var n = "object" == typeof e && "undefined" != typeof e.x && "undefined" != typeof e.y ? new Vector(e.x + 0, e.y + 0) : new Vector(e, t);
  215. n.subtract(this.getPosition()).rotate(-this.rotation);
  216. return n
  217. };
  218. this.allowDebugDrawing = !0;
  219. this.debugDraw = function() {
  220. if (this.visible && this.allowDebugDrawing) {
  221. var e = this.getPosition(),
  222. t = this.getCenter(),
  223. n = this.getDrawRectangle(),
  224. r = this.getAABBRectangle();
  225. stage.drawCircle(e.x, e.y, 1, 1, "rgba(255,0,0,0.9)");
  226. stage.drawCircle(t.x, t.y, 1, 1, "rgba(0,255,0,0.9)");
  227. stage.drawLine(e.x, e.y, t.x, t.y, 1, "rgba(255,255,255,0.5)");
  228. stage.drawPolygon(n.vertices, .5, "rgba(255,0,255,0.5)", 1);
  229. stage.drawLine(r.vertices[0].x, r.vertices[0].y, r.vertices[2].x, r.vertices[2].y, .1, "rgba(255,255,255,0.5)");
  230. stage.drawLine(r.vertices[2].x, r.vertices[0].y, r.vertices[0].x, r.vertices[2].y, .1, "rgba(255,255,255,0.5)");
  231. stage.drawPolygon(r.vertices, .5, "rgba(255,255,255,0.5)")
  232. }
  233. };
  234. this.setZIndex = function(e) {
  235. this.zIndex = ~~e;
  236. this.stage && this.stage.setZIndex(this, ~~e)
  237. };
  238. this.eventsListeners = [];
  239. this.addEventListener = function(e, t) {
  240. EventsManager.addEvent(this, e, t)
  241. };
  242. this.removeEventListener = function(e, t) {
  243. EventsManager.removeEvent(this, e, t)
  244. };
  245. this.dispatchEvent = function(e, t) {
  246. return EventsManager.dispatchEvent(this, e, t)
  247. };
  248. this.hitTestPoint = function(e, t, n, r, i) {
  249. return this.stage ? this.stage.hitTestPointObject(this, e, t, n, r, i) : !1
  250. }
  251. }
  252. function Tween(e, t, n, r, i, s) {
  253. var o = this;
  254. "object" != typeof e && (e = null);
  255. if (e) {
  256. if ("undefined" == typeof e[t]) throw Error('Trying to tween undefined property "' + t + '"');
  257. if (isNaN(e[t])) throw Error("Tweened value can not be " + typeof e[t])
  258. } else if (isNaN(t)) throw Error("Tweened value can not be " + typeof t);
  259. "function" != typeof s && (s = Easing.linear.easeIn);
  260. this.obj = e;
  261. this.prop = t;
  262. this.onfinish = this.onchange = null;
  263. this.start = n;
  264. this.end = r;
  265. this.duration = ~~i;
  266. this.callback = s;
  267. this.playing = !1;
  268. this._pos = -1;
  269. this.play = function() {
  270. o.playing = !0;
  271. o.tick()
  272. };
  273. this.pause = function() {
  274. o.playing = !1
  275. };
  276. this.rewind = function() {
  277. o._pos = -1
  278. };
  279. this.forward = function() {
  280. o._pos = this.duration
  281. };
  282. this.stop = function() {
  283. o.rewind();
  284. o.tick();
  285. o.pause()
  286. };
  287. this.updateValue = function(e) {
  288. o.obj ? o.obj[o.prop] = e : o.prop = e
  289. };
  290. this.tick = function() {
  291. if (!o.playing) return !1;
  292. o._pos++;
  293. if (0 > o._pos) return !1;
  294. if (o._pos > o.duration) return o.finish();
  295. var e = o.callback,
  296. e = e(o._pos, o.start, o.end - o.start, o.duration);
  297. this.updateValue(e);
  298. o.dispatchEvent("change", {
  299. target: o,
  300. value: e
  301. });
  302. return !1
  303. };
  304. this.finish = function() {
  305. o.stop();
  306. o.updateValue(o.end);
  307. return o.dispatchEvent("finish", {
  308. target: o,
  309. value: o.end
  310. })
  311. };
  312. this.eventsListeners = [];
  313. this.addEventListener = function(e, t) {
  314. EventsManager.addEvent(this, e, t)
  315. };
  316. this.removeEventListener = function(e, t) {
  317. EventsManager.removeEvent(this, e, t)
  318. };
  319. this.dispatchEvent = function(e, t) {
  320. return EventsManager.dispatchEvent(this, e, t)
  321. }
  322. }
  323. function StageTimer(a, c, d) {
  324. this.repeat = d;
  325. this.timeout = this.initialTimeout = c;
  326. this.callback = a;
  327. this.paused = !1;
  328. this.update = function() {
  329. if (!this.paused) {
  330. this.timeout--;
  331. if (0 >= this.timeout)
  332. if ("function" == typeof this.callback && this.callback(), "string" == typeof this.callback && eval(this.callback), this.repeat) this.timeout = this.initialTimeout;
  333. else return !0;
  334. return !1
  335. }
  336. };
  337. this.resume = function() {
  338. this.paused = !1
  339. };
  340. this.pause = function() {
  341. this.paused = !0
  342. }
  343. }
  344. function Stage(e, t, n) {
  345. function r() {
  346. s.lastFPS = s.fps;
  347. s.fps = 0;
  348. s.started && (s.tmFPS = setTimeout(r, 1e3))
  349. }
  350. function i() {
  351. clearTimeout(s.tmMain);
  352. var e = (new Date).getTime();
  353. s.updateTweens();
  354. s.updateTimers();
  355. s.dispatchEvent("pretick");
  356. s.drawScene(s.canvas, !1);
  357. s.showFPS && (s.setTextStyle("sans-serif", 10, "bold", "#fff", "#000"), s.drawText("FPS: " + s.lastFPS, 2, 10, 1, !0));
  358. s.dispatchEvent("posttick");
  359. e = (new Date).getTime() - e;
  360. e = s.delay - e - 1;
  361. 1 > e && (e = 1);
  362. s.fps++;
  363. s.started && (s.tmMain = setTimeout(i, e))
  364. }
  365. var s = this;
  366. this.canvas = null;
  367. e && (this.canvas = document.getElementById(e), this.canvas.ctx = this.canvas.getContext("2d"));
  368. this.backBuffer = null;
  369. this.screenWidth = t;
  370. this.screenHeight = n;
  371. this.viewport = {
  372. x: 0,
  373. y: 0
  374. };
  375. this.objects = [];
  376. this.objectsCounter = 0;
  377. try {
  378. this.buffer = document.createElement("canvas"), this.buffer.width = t * Utils.globalScale, this.buffer.height = n * Utils.globalScale, this.buffer.ctx = this.buffer.getContext("2d")
  379. } catch (o) {
  380. this.buffer = this.canvas
  381. }
  382. this.delay = 40;
  383. this.started = this.fillColor = !1;
  384. this.lastFPS = this.fps = 0;
  385. this.ceilSizes = this.pixelMouseMoveEvent = this.pixelMouseDownEvent = this.pixelMouseUpEvent = this.pixelClickEvent = this.showFPS = !1;
  386. this.tmMain;
  387. this.tmFPS;
  388. this.clearLock = !1;
  389. this.destroy = function() {
  390. clearTimeout(this.tmMain);
  391. clearTimeout(this.tmFPS);
  392. this.stop();
  393. this.clear();
  394. this.clearScreen(this.canvas)
  395. };
  396. this.clearScreen = function(e) {
  397. this.clearLock || e.ctx.clearRect(0, 0, this.screenWidth * Utils.globalScale * Utils.globalPixelScale, this.screenHeight * Utils.globalScale * Utils.globalPixelScale)
  398. };
  399. this.findMaxZIndex = function() {
  400. for (var e = -1, t = !1, n = 0; n < this.objects.length; n++) this.objects[n].zIndex > e && (e = this.objects[n].zIndex, t = n);
  401. return {
  402. index: t,
  403. zIndex: e
  404. }
  405. };
  406. this.findMinZIndex = function() {
  407. for (var e = -1, t = !1, n = 0; n < this.objects.length; n++) 0 == n && (e = this.objects[n].zIndex, t = 0), this.objects[n].zIndex < e && (e = this.objects[n].zIndex, t = n);
  408. return {
  409. index: t,
  410. zIndex: e
  411. }
  412. };
  413. this.addChild = function(e) {
  414. var t = this.findMaxZIndex(),
  415. n = e.zIndex;
  416. e.zIndex = !1 !== t.index ? t.zIndex + 1 : 0;
  417. this.objectsCounter++;
  418. e.uid = this.objectsCounter;
  419. e.stage = this;
  420. this.objects.push(e);
  421. 0 != n && this.setZIndex(e, ~~n);
  422. e.dispatchEvent("add", {
  423. target: e
  424. });
  425. return e
  426. };
  427. this.removeChild = function(e) {
  428. e && (this.clearObjectTweens(e), e.dispatchEvent("remove", {
  429. target: e
  430. }), e.stage = null, this.objects = Utils.removeFromArray(this.objects, e))
  431. };
  432. this.setZIndex = function(e, t) {
  433. e.zIndex = t;
  434. this.objects = this.objects.sort(function(e, t) {
  435. return e.zIndex == t.zIndex ? e.uid > t.uid ? 1 : -1 : e.zIndex > t.zIndex ? 1 : -1
  436. })
  437. };
  438. this.hitTestPointObject = function(e, t, n, r, i, s) {
  439. var o, u, a, f, l, c;
  440. a = e.width * Math.abs(e.scaleX);
  441. f = e.height * Math.abs(e.scaleY);
  442. o = e.x - a / 2;
  443. u = e.y - f / 2;
  444. l = t;
  445. c = n;
  446. e.ignoreViewport || (l += this.viewport.x, c += this.viewport.y);
  447. s = !1;
  448. 0 == e.rotation ? o <= l && u <= c && o + a >= l && u + f >= c && (s = !0) : (o = e.getDrawRectangle(), o.hitTestPoint(new Vector(l, c)) && (s = !0));
  449. s && r && (this.buffer.width = this.screenWidth * Utils.globalScale * Utils.globalPixelScale, this.buffer.height = this.screenHeight * Utils.globalScale * Utils.globalPixelScale, this.clearScreen(this.buffer), this.renderObject(this.buffer, e), t = this.buffer.ctx.getImageData(Math.floor(t * Utils.globalScale * Utils.globalPixelScale), Math.floor(n * Utils.globalScale * Utils.globalPixelScale), 1, 1), 0 == t.data[3] && (s = !1));
  450. !s && i && e.dragged && (s = !0);
  451. return s
  452. };
  453. this.getObjectsStackByCoord = function(e, t, n, r, i) {
  454. for (var s, o = [], u = 0; u < this.objects.length; u++)
  455. if (this.objects[u].visible || this.objects[u].eventsWhenInvisible) s = this.objects[u], this.hitTestPointObject(s, e, t, n, r, i) && o.push(s);
  456. return o
  457. };
  458. this.getMaxZIndexInStack = function(e) {
  459. for (var t = -1, n = 0, r = 0; r < e.length; r++) e[r].zIndex > t && (t = e[r].zIndex, n = r);
  460. return n
  461. };
  462. this.sortStack = function(e, t) {
  463. for (var n = !0, r, i; n;)
  464. for (n = !1, i = 0; i < e.length - 1; i++) r = !1, e[i].zIndex < e[i + 1].zIndex && !t && (r = !0), e[i].zIndex > e[i + 1].zIndex && t && (r = !0), r && (n = e[i], e[i] = e[i + 1], e[i + 1] = n, n = !0);
  465. return e
  466. };
  467. this.finalizeMouseCoords = function(e, t) {
  468. if (!e) return t;
  469. var n = this.prepareMouseCoord(t.x),
  470. r = this.prepareMouseCoord(t.y);
  471. e.ignoreViewport || (n += this.viewport.x, r += this.viewport.y);
  472. n -= e.x;
  473. r -= e.y;
  474. return {
  475. x: n,
  476. y: r
  477. }
  478. };
  479. this.prepareMouseCoord = function(e) {
  480. return e / Utils.globalScale / Utils.globalPixelScale
  481. };
  482. this.checkClick = function(e) {
  483. e = Utils.getMouseCoord(e, this.inputController);
  484. var t = this.getObjectsStackByCoord(this.prepareMouseCoord(e.x), this.prepareMouseCoord(e.y), this.pixelClickEvent, !1, !0),
  485. n;
  486. if (0 < t.length)
  487. for (var t = this.sortStack(t), r = 0; r < t.length && (n = this.finalizeMouseCoords(t[r], e), n = t[r].dispatchEvent("click", {
  488. target: t[r],
  489. x: n.x,
  490. y: n.y
  491. }), !1 !== n); r++);
  492. };
  493. this.checkContextMenu = function(e) {
  494. e = Utils.getMouseCoord(e, this.inputController);
  495. var t = this.getObjectsStackByCoord(this.prepareMouseCoord(e.x), this.prepareMouseCoord(e.y), this.pixelClickEvent),
  496. n;
  497. if (0 < t.length)
  498. for (var t = this.sortStack(t), r = 0; r < t.length && (n = this.finalizeMouseCoords(t[r], e), n = t[r].dispatchEvent("contextmenu", {
  499. target: t[r],
  500. x: n.x,
  501. y: n.y
  502. }), !1 !== n); r++);
  503. };
  504. this.checkMouseMove = function(e) {
  505. e = Utils.getMouseCoord(e, this.inputController);
  506. for (r = 0; r < this.objects.length; r++)
  507. if (this.objects[r].dragged) {
  508. var t = e.x / Utils.globalScale / Utils.globalPixelScale,
  509. n = e.y / Utils.globalScale / Utils.globalPixelScale;
  510. this.objects[r].ignoreViewport || (t += this.viewport.x, n += this.viewport.y);
  511. this.objects[r].x = t - this.objects[r].dragX;
  512. this.objects[r].y = n - this.objects[r].dragY
  513. }
  514. var t = this.getObjectsStackByCoord(this.prepareMouseCoord(e.x), this.prepareMouseCoord(e.y), this.pixelMouseMoveEvent),
  515. r, i, s, n = [];
  516. if (0 < t.length) {
  517. t = this.sortStack(t);
  518. for (r = 0; r < t.length && (n.push(t[r]), s = this.finalizeMouseCoords(t[r], e), t[r].mouseOn || (i = t[r].dispatchEvent("mouseover", {
  519. target: t[r],
  520. x: s.x,
  521. y: s.y
  522. })), t[r].mouseOn = !0, !1 !== i); r++);
  523. for (r = 0; r < t.length && (s = this.finalizeMouseCoords(t[r], e), i = t[r].dispatchEvent("mousemove", {
  524. target: t[r],
  525. x: s.x,
  526. y: s.y
  527. }), !1 !== i); r++);
  528. }
  529. for (r = 0; r < this.objects.length; r++)
  530. if (this.objects[r].mouseOn) {
  531. s = !1;
  532. for (i = 0; i < n.length; i++) n[i] == this.objects[r] && (s = !0);
  533. if (!s && (this.objects[r].mouseOn = !1, s = this.finalizeMouseCoords(t[r], e), i = this.objects[r].dispatchEvent("mouseout", {
  534. target: this.objects[r],
  535. x: s.x,
  536. y: s.y
  537. }), !1 === i)) break
  538. }
  539. };
  540. this.checkMouseDown = function(e) {
  541. e = Utils.getMouseCoord(e, this.inputController);
  542. var t = this.getObjectsStackByCoord(this.prepareMouseCoord(e.x), this.prepareMouseCoord(e.y), this.pixelMouseDownEvent),
  543. n;
  544. if (0 < t.length)
  545. for (var t = this.sortStack(t), r = 0; r < t.length && (n = this.finalizeMouseCoords(t[r], e), n = t[r].dispatchEvent("mousedown", {
  546. target: t[r],
  547. x: n.x,
  548. y: n.y
  549. }), !1 !== n); r++);
  550. };
  551. this.checkMouseUp = function(e) {
  552. e = Utils.getMouseCoord(e, this.inputController);
  553. var t = this.getObjectsStackByCoord(this.prepareMouseCoord(e.x), this.prepareMouseCoord(e.y), this.pixelMouseUpEvent, !0),
  554. n;
  555. if (0 < t.length)
  556. for (var t = this.sortStack(t), r = 0; r < t.length && (n = this.finalizeMouseCoords(t[r], e), n = t[r].dispatchEvent("mouseup", {
  557. target: t[r],
  558. x: n.x,
  559. y: n.y
  560. }), !1 !== n); r++);
  561. };
  562. this.clear = function() {
  563. for (var e = 0; e < this.objects.length; e++) this.objects[e].dispatchEvent("remove", {
  564. target: this.objects[e]
  565. });
  566. this.objects = [];
  567. this.tweens = [];
  568. this.timers = [];
  569. this.eventsListeners = [];
  570. this.objectsCounter = 0
  571. };
  572. this.hitTest = function(e, t) {
  573. if (0 == e.rotation && 0 == t.rotation) {
  574. var n = e.getX() - e.getWidth() / 2,
  575. r = e.getY() - e.getHeight() / 2,
  576. i = t.getX() - t.getWidth() / 2,
  577. s = t.getY() - t.getHeight() / 2,
  578. o = Math.max(r, s),
  579. u = Math.max(n, i),
  580. n = Math.min(n + e.getWidth(), i + t.getWidth()),
  581. r = Math.min(r + e.getHeight(), s + t.getHeight()) - o;
  582. return 0 < n - u && 0 < r ? !0 : !1
  583. }
  584. u = e.getDrawRectangle();
  585. r = t.getDrawRectangle();
  586. return u.hitTestRectangle(r)
  587. };
  588. this.drawRectangle = function(e, t, n, r, i, s, o, u) {
  589. var a = this.canvas;
  590. a.ctx.globalAlpha = "undefined" != typeof o ? o : 1;
  591. a.ctx.fillStyle = i;
  592. a.ctx.strokeStyle = i;
  593. u || (e -= this.viewport.x, t -= this.viewport.y);
  594. e = e * Utils.globalScale * Utils.globalPixelScale;
  595. t = t * Utils.globalScale * Utils.globalPixelScale;
  596. n = n * Utils.globalScale * Utils.globalPixelScale;
  597. r = r * Utils.globalScale * Utils.globalPixelScale;
  598. s ? a.ctx.fillRect(e - n / 2, t - r / 2, n, r) : a.ctx.strokeRect(e - n / 2, t - r / 2, n, r)
  599. };
  600. this.drawCircle = function(e, t, n, r, i, s, o) {
  601. this.drawArc(e, t, n, 0, 2 * Math.PI, !1, r, i, s, o)
  602. };
  603. this.drawArc = function(e, t, n, r, i, s, o, u, a, f) {
  604. var l = this.canvas,
  605. c = l.ctx.lineWidth;
  606. "undefined" == typeof u && (u = "#000");
  607. l.ctx.strokeStyle = u;
  608. "undefined" == typeof o && (o = 1);
  609. l.ctx.lineWidth = o * Utils.globalScale * Utils.globalPixelScale;
  610. "undefined" == typeof a && (a = 1);
  611. l.ctx.globalAlpha = a;
  612. f || (e -= this.viewport.x, t -= this.viewport.y);
  613. e = e * Utils.globalScale * Utils.globalPixelScale;
  614. t = t * Utils.globalScale * Utils.globalPixelScale;
  615. n = n * Utils.globalScale * Utils.globalPixelScale;
  616. l.ctx.beginPath();
  617. l.ctx.arc(e, t, n, r, i, s);
  618. l.ctx.stroke();
  619. l.ctx.lineWidth = c
  620. };
  621. this.drawPolygon = function(e, t, n, r, i) {
  622. if ("object" == typeof e && e instanceof Array && !(2 > e.length)) {
  623. for (var s = 0; s < e.length - 1; s++) this.drawLine(e[s].x, e[s].y, e[s + 1].x, e[s + 1].y, t, n, r, i);
  624. this.drawLine(e[s].x, e[s].y, e[0].x, e[0].y, t, n, r, i)
  625. }
  626. };
  627. this.drawLine = function(e, t, n, r, i, s, o, u) {
  628. var a = this.canvas,
  629. f = a.ctx.lineWidth;
  630. a.ctx.strokeStyle = s ? s : "#000";
  631. a.ctx.lineWidth = i ? i * Utils.globalScale * Utils.globalPixelScale : 1 * Utils.globalScale * Utils.globalPixelScale;
  632. a.ctx.globalAlpha = o ? o : 1;
  633. u || (e -= this.viewport.x, t -= this.viewport.y, n -= this.viewport.x, r -= this.viewport.y);
  634. e = e * Utils.globalScale * Utils.globalPixelScale;
  635. t = t * Utils.globalScale * Utils.globalPixelScale;
  636. n = n * Utils.globalScale * Utils.globalPixelScale;
  637. r = r * Utils.globalScale * Utils.globalPixelScale;
  638. a.ctx.beginPath();
  639. a.ctx.moveTo(e, t);
  640. a.ctx.lineTo(n, r);
  641. a.ctx.stroke();
  642. a.ctx.lineWidth = f
  643. };
  644. this.start = function() {
  645. this.started || (this.started = !0, r(), i())
  646. };
  647. this.forceRender = function() {
  648. this.started && i()
  649. };
  650. this.stop = function() {
  651. this.started = !1
  652. };
  653. this.setTextStyle = function(e, t, n, r, i, s) {
  654. s = s ? s : this.canvas;
  655. s.ctx.fillStyle = r;
  656. s.ctx.strokeStyle = i;
  657. r = "";
  658. n && (r += n + " ");
  659. t && (r += Math.floor(t * Utils.globalScale * Utils.globalPixelScale) + "px ");
  660. e && (r += e);
  661. s.ctx.font = r
  662. };
  663. this.drawText = function(e, t, n, r, i, s, o) {
  664. o = o ? o : this.canvas;
  665. o.ctx.globalAlpha = "undefined" == typeof r ? 1 : r;
  666. i || (t -= this.viewport.x, n -= this.viewport.y);
  667. t = t * Utils.globalScale * Utils.globalPixelScale;
  668. n = n * Utils.globalScale * Utils.globalPixelScale;
  669. s && (t -= this.getTextWidth(e) / 2);
  670. o.ctx.fillText(e, t, n)
  671. };
  672. this.strokeText = function(e, t, n, r, i, s, o) {
  673. o = o ? o : this.canvas;
  674. o.ctx.globalAlpha = "undefined" == typeof r ? 1 : r;
  675. i || (t -= this.viewport.x, n -= this.viewport.y);
  676. t = t * Utils.globalScale * Utils.globalPixelScale;
  677. n = n * Utils.globalScale * Utils.globalPixelScale;
  678. s && (t -= this.getTextWidth(e) / 2);
  679. o.ctx.strokeText(e, t, n)
  680. };
  681. this.getTextWidth = function(e, t) {
  682. return (t ? t : this.canvas).ctx.measureText(e).width
  683. };
  684. this.allowStaticDebugDrawing = this.allowDebugDrawing = !1;
  685. this.renderObject = function(e, t) {
  686. if (!1 !== t.dispatchEvent("prerender", {
  687. target: t,
  688. canvas: e
  689. })) {
  690. var n = t.getAbsoluteCenter();
  691. ow = t.width * Utils.globalScale;
  692. oh = t.height * Utils.globalScale;
  693. ox = n.x * Utils.globalPixelScale * Utils.globalScale - Math.floor(ow / 2);
  694. oy = n.y * Utils.globalPixelScale * Utils.globalScale - Math.floor(oh / 2);
  695. or = t.rotation;
  696. scX = t.scaleX * Utils.globalPixelScale;
  697. scY = t.scaleY * Utils.globalPixelScale;
  698. canvasMod = Boolean(0 != or || 1 != scX || 1 != scY);
  699. t.ignoreViewport || (ox -= this.viewport.x * Utils.globalPixelScale * Utils.globalScale, oy -= this.viewport.y * Utils.globalPixelScale * Utils.globalScale);
  700. canvasMod && (e.ctx.save(), e.ctx.translate(ox + Math.floor(ow / 2), oy + Math.floor(oh / 2)), e.ctx.rotate(or), e.ctx.scale(scX, scY), ox = -Math.floor(ow / 2), oy = -Math.floor(oh / 2));
  701. e.ctx.globalAlpha = t.opacity;
  702. this.ceilSizes && (ow = Math.ceil(ow), oh = Math.ceil(oh));
  703. t.fillColor && (e.ctx.fillStyle = t.fillColor, e.ctx.strokeStyle = t.fillColor, e.ctx.fillRect(ox, oy, ow, oh));
  704. if (t.bitmap) {
  705. var n = t.bitmap.width,
  706. r = t.bitmap.height,
  707. i = t.currentLayer * ow + t.offset.left * Utils.globalScale,
  708. s = t.currentFrame * oh + t.offset.top * Utils.globalScale;
  709. if (i < n && s < r) {
  710. var o = ow,
  711. u = oh,
  712. a = !1;
  713. i + o > n && (o = n - i);
  714. s + u > r && (u = r - s);
  715. t.mask && (this.buffer.ctx.save(), this.buffer.ctx.clearRect(0, 0, o, u), this.buffer.ctx.drawImage(t.bitmap, i, s, o, u, 0, 0, o, u), this.buffer.ctx.globalCompositeOperation = "destination-in", this.buffer.ctx.drawImage(t.mask, 0, 0), s = i = 0, a = !0);
  716. try {
  717. e.ctx.drawImage(a ? this.buffer : t.bitmap, ~~i, ~~s, ~~o, ~~u, ~~ox, ~~oy, ~~ow, ~~oh)
  718. } catch (f) {}
  719. a && this.buffer.ctx.restore()
  720. }
  721. }
  722. canvasMod && e.ctx.restore();
  723. this.allowDebugDrawing && t.allowDebugDrawing && (!this.allowStaticDebugDrawing && t.static || t.debugDraw());
  724. t.dispatchEvent("render", {
  725. target: t,
  726. canvas: e
  727. })
  728. }
  729. };
  730. this.drawBackAlways = Utils.mobileCheckBrokenGalaxyPhones();
  731. this.drawBackBuffer = function(e, t) {
  732. !t && this.backBuffer && this.drawBackAlways && e.ctx.drawImage(this.backBuffer, 0, 0, e.width, e.height)
  733. };
  734. this.drawScene = function(e, t) {
  735. var n, r;
  736. e && !e.ctx && (e.ctx = e.getContext("2d"));
  737. this.fillColor ? (e.ctx.fillStyle = this.fillColor, e.ctx.fillRect(0, 0, this.screenWidth * Utils.globalScale * Utils.globalPixelScale, this.screenHeight * Utils.globalScale * Utils.globalPixelScale), this.drawBackBuffer(e, t)) : this.clearLock || (this.clearScreen(e), this.drawBackBuffer(e, t));
  738. for (var i = 0; i < this.objects.length; i++) n = this.objects[i], r = !1, t || n["static"] || (r = !0), t && n["static"] && (r = !0), r && (n.destroy ? (this.removeChild(n), i--) : (n.nextFrame(), n.visible && this.renderObject(e, n)));
  739. t && (this.backBuffer = e)
  740. };
  741. this.tweens = [];
  742. this.createTween = function(e, t, n, r, i, o) {
  743. e = new Tween(e, t, n, r, i, o);
  744. s.tweens.push(e);
  745. return e
  746. };
  747. this.removeTween = function(e) {
  748. var t = null;
  749. if (isNaN(e))
  750. for (var n = 0; n < s.tweens.length; n++) {
  751. if (s.tweens[n] === e) {
  752. t = n;
  753. break
  754. }
  755. } else t = e;
  756. s.tweens[t].pause();
  757. s.tweens.splice(t, 1);
  758. return t
  759. };
  760. this.clearObjectTweens = function(e) {
  761. for (var t = 0; t < s.tweens.length; t++) s.tweens[t].obj === e && (t = s.removeTween(t), t--)
  762. };
  763. this.updateTweens = function() {
  764. for (var e = 0; e < s.tweens.length; e++) s.tweens[e].tick() && (e = s.removeTween(e))
  765. };
  766. this.timers = [];
  767. this.setTimeout = function(e, t) {
  768. var n = new StageTimer(e, t);
  769. this.timers.push(n);
  770. return n
  771. };
  772. this.clearTimeout = function(e) {
  773. this.timers = Utils.removeFromArray(this.timers, e)
  774. };
  775. this.setInterval = function(e, t) {
  776. var n = new StageTimer(e, t, !0);
  777. this.timers.push(n);
  778. return n
  779. };
  780. this.clearInterval = function(e) {
  781. this.clearTimeout(e)
  782. };
  783. this.updateTimers = function() {
  784. for (var e = 0; e < this.timers.length; e++) this.timers[e].update() && (this.clearTimeout(this.timers[e]), e--)
  785. };
  786. this.box2dSync = function(e) {
  787. for (b = e.m_bodyList; b; b = b.m_next) b.sprite && (b.sprite.rotation = b.GetRotation(), e = b.GetPosition(), b.sprite.x = e.x, b.sprite.y = e.y, b.sprite.dispatchEvent("box2dsync", {
  788. target: b.sprite
  789. }))
  790. };
  791. this.processTouchEvent = function(e, t) {
  792. for (var n = 0; n < e.length; n++) s[t]({
  793. clientX: e[n].clientX,
  794. clientY: e[n].clientY
  795. })
  796. };
  797. this.inputController = null;
  798. this.addInputListeners = function(e) {
  799. -1 != navigator.userAgent.toLowerCase().indexOf("firefox") && navigator.userAgent.toLowerCase().indexOf("mobile");
  800. this.inputController = e;
  801. "ontouchstart" in e ? (e.ontouchstart = function(e) {
  802. s.processTouchEvent(e.touches, "checkMouseDown");
  803. s.processTouchEvent(e.touches, "checkClick")
  804. }, e.ontouchmove = function(e) {
  805. s.processTouchEvent(e.touches, "checkMouseMove")
  806. }, e.ontouchend = function(e) {
  807. s.processTouchEvent(e.changedTouches, "checkMouseUp")
  808. }) : (e.onclick = function(e) {
  809. s.checkClick(e)
  810. }, e.onmousemove = function(e) {
  811. s.checkMouseMove(e)
  812. }, e.onmousedown = function(e) {
  813. 0 == e.button && s.checkMouseDown(e)
  814. }, e.onmouseup = function(e) {
  815. 0 == e.button && s.checkMouseUp(e)
  816. }, e.oncontextmenu = function(e) {
  817. s.checkContextMenu(e)
  818. })
  819. };
  820. this.canvas && this.addInputListeners(this.canvas);
  821. this.onposttick = this.onpretick = null;
  822. this.eventsListeners = [];
  823. this.addEventListener = function(e, t) {
  824. EventsManager.addEvent(this, e, t)
  825. };
  826. this.removeEventListener = function(e, t) {
  827. EventsManager.removeEvent(this, e, t)
  828. };
  829. this.dispatchEvent = function(e, t) {
  830. return EventsManager.dispatchEvent(this, e, t)
  831. }
  832. }
  833. function Vector(e, t) {
  834. "undefined" == typeof e && (e = 0);
  835. this.x = e;
  836. "undefined" == typeof t && (t = 0);
  837. this.y = t;
  838. this.isZero = function() {
  839. return 0 == this.x && 0 == this.y
  840. };
  841. this.clone = function() {
  842. return new Vector(this.x, this.y)
  843. };
  844. this.add = function(e) {
  845. this.x += e.x;
  846. this.y += e.y;
  847. return this
  848. };
  849. this.subtract = function(e) {
  850. this.x -= e.x;
  851. this.y -= e.y;
  852. return this
  853. };
  854. this.mult = function(e) {
  855. this.x *= e;
  856. this.y *= e;
  857. return this
  858. };
  859. this.invert = function() {
  860. this.mult(-1);
  861. return this
  862. };
  863. this.rotate = function(e, t) {
  864. "undefined" == typeof t && (t = new Vector(0, 0));
  865. var n = this.clone();
  866. n.subtract(t);
  867. n.x = this.x * Math.cos(e) + this.y * Math.sin(e);
  868. n.y = this.x * -Math.sin(e) + this.y * Math.cos(e);
  869. n.add(t);
  870. this.x = n.x;
  871. this.y = n.y;
  872. return this
  873. };
  874. this.normalize = function(e, t) {
  875. "undefined" == typeof t && (t = new Vector(0, 0));
  876. this.subtract(t);
  877. this.rotate(-e);
  878. return this
  879. };
  880. this.getLength = function() {
  881. return Math.sqrt(this.x * this.x + this.y * this.y)
  882. };
  883. this.distanceTo = function(e) {
  884. p2 = this.clone();
  885. p2.subtract(e);
  886. return p2.getLength()
  887. }
  888. }
  889. function ChainFinder(e, t, n, r) {
  890. "undefined" == typeof e && (e = []);
  891. t = Math.max(2, ~~t);
  892. n = Math.max(1, ~~n);
  893. "undefined" == typeof r && (r = !1);
  894. this.items = e;
  895. this.length = t;
  896. this.cols = n;
  897. this.rows = Math.floor(e.length / n);
  898. this.diagonal = r;
  899. this.chains = !1;
  900. this.inField = function(e) {
  901. return 0 > e || e >= this.items.length ? !1 : !0
  902. };
  903. this.idInChain = function(e) {
  904. for (var t = 0; t < this.chains.length; t++)
  905. if (0 <= this.chains[t].indexOf(e)) return t;
  906. return -1
  907. };
  908. this.isNeighbour = function(e, t) {
  909. if (!this.inField(t) || 0 <= this.idInChain(e)) return !1;
  910. var n = Math.floor(e / this.cols),
  911. r = Math.floor(t / this.cols),
  912. i = Math.abs(e % this.cols - t % this.cols),
  913. n = Math.abs(n - r);
  914. return this.diagonal ? 0 < i + n && 2 > i && 2 > n : 1 == i + n
  915. };
  916. this.getNeighbours = function(e, t) {
  917. "undefined" == typeof t && (t = !1);
  918. var n = [e - 1, e + 1, e - this.cols, e + this.cols];
  919. this.diagonal && (n.push(e - (this.cols - 1)), n.push(e - (this.cols + 1)), n.push(e + (this.cols - 1)), n.push(e + (this.cols + 1)));
  920. for (var r = []; 0 < n.length;) {
  921. var i = n.shift();
  922. this.isNeighbour(e, i) && (t && 0 > this.ids.indexOf(i) || r.push(i))
  923. }
  924. return r
  925. };
  926. this.checkChainLength = function(e) {
  927. return e ? e.length >= this.length : !1
  928. };
  929. this.ids = [];
  930. this.prepare = function() {
  931. this.ids = [];
  932. this.chains = [];
  933. for (var e = 0; e < this.items.length; e++) 0 <= this.idInChain(e) || this.ids.push(e)
  934. };
  935. this.findChains = function() {
  936. this.prepare();
  937. if (0 == this.items.length) return this.chains;
  938. for (; 0 < this.ids.length;) {
  939. var e = this.ids.shift(),
  940. e = this.getChain(e);
  941. this.checkChainLength(e) && this.chains.push(e)
  942. }
  943. return this.chains
  944. };
  945. this.getChain = function(e, t) {
  946. "undefined" == typeof t && (t = []);
  947. 0 > t.indexOf(e) && t.push(e);
  948. for (var n = this.getNeighbours(e, !0); 0 < n.length;) {
  949. var r = n.shift();
  950. this.empty(this.items[r]) || 0 <= t.indexOf(r) || !this.compare(this.items[r], this.items[e]) || (this.ids.splice(this.ids.indexOf(r), 1), t = this.getChain(r, t))
  951. }
  952. return t
  953. };
  954. this.findPossibleChains = function(e) {
  955. this.prepare();
  956. var t = this.items[e];
  957. if (!this.inField(e)) return !1;
  958. for (var n = {}, r = this.getNeighbours(e, !0); 0 < r.length;) {
  959. this.prepare();
  960. var i = r.shift(),
  961. s = this.items[i];
  962. this.empty(s) || (this.items[e] = s, n[s] || (n[s] = []), n[s] = this.getChain(i, n[s]))
  963. }
  964. this.items[e] = t;
  965. return n
  966. };
  967. this.findMaxPossibleChain = function(e) {
  968. e = this.findPossibleChains(e);
  969. if (!e) return !1;
  970. var t = !1,
  971. n = -1,
  972. r;
  973. for (r in e) this.checkChainLength(e[r]) && ~~r > n && (t = e[r], n = ~~r);
  974. return t
  975. };
  976. this.findMinPossibleChain = function(e) {
  977. e = this.findPossibleChains(e);
  978. if (!e) return !1;
  979. var t = !1,
  980. n = Number.MAX_VALUE,
  981. r;
  982. for (r in e) this.checkChainLength(e[r]) && r < n && (t = e[r], n = r);
  983. return t
  984. };
  985. this.findLongestPossibleChain = function(e) {
  986. e = this.findPossibleChains(e);
  987. if (!e) return !1;
  988. var t = !1,
  989. n = -1,
  990. r;
  991. for (r in e) this.checkChainLength(e[r]) && e[r].length > n && (t = e[r], n = r);
  992. return t
  993. };
  994. this.findShortestPossibleChain = function(e) {
  995. e = this.findPossibleChains(e);
  996. if (!e) return !1;
  997. var t = !1,
  998. n = Number.MAX_VALUE,
  999. r;
  1000. for (r in e) this.checkChainLength(e[r]) && e[r].length < n && (t = e[r], n = r);
  1001. return t
  1002. };
  1003. this.getChainType = function(e) {
  1004. if (!1 === e) return 0;
  1005. for (var t = 0; t < e.length; t++)
  1006. if (!this.empty(e[t])) return this.items[e[t]];
  1007. return 0
  1008. };
  1009. this.compare_callback = null;
  1010. this.compare = function(e, t) {
  1011. return this.compare_callback ? this.compare_callback(e, t) : e == t
  1012. };
  1013. this.empty_callback = null;
  1014. this.empty = function(e) {
  1015. return this.empty_callback ? this.empty_callback(e) : 0 == ~~e
  1016. }
  1017. }
  1018. function AudioPlayer() {
  1019. var e = this;
  1020. this.disabled = !1;
  1021. this.basePath = "";
  1022. this.mp3Support = !0;
  1023. this.delayPlay = this.webAudioSupport = !1;
  1024. this.audioWrapper = null;
  1025. this.busy = this.locked = !1;
  1026. this.startPlayTime = 0;
  1027. this.onend = null;
  1028. this.createNewAudio = function() {
  1029. if (this.webAudioSupport) {
  1030. var e = AudioMixer.waContext.createBufferSource();
  1031. e.connect(AudioMixer.waContext.destination);
  1032. return e
  1033. }
  1034. return document.createElement("audio")
  1035. };
  1036. this.init = function(e, t) {
  1037. this.webAudioSupport = t;
  1038. this.basePath = e ? e : "";
  1039. this.delayPlay = "ontouchstart" in window;
  1040. this.audioWrapper = this.createNewAudio();
  1041. var n = document.createElement("audio");
  1042. n.canPlayType ? this.mp3Support = "" != n.canPlayType("audio/mpeg") : this.disabled = !0;
  1043. return !this.disabled
  1044. };
  1045. this.play = function(e, t) {
  1046. if (this.disabled) return !1;
  1047. var n = this.basePath + "/" + e + (this.mp3Support ? ".mp3" : ".ogg");
  1048. this.stop();
  1049. this.audioWrapper = this.createNewAudio();
  1050. this.audioWrapper.doLoop = t ? !0 : !1;
  1051. if (this.webAudioSupport) {
  1052. var r = this;
  1053. this.loadSound(n, function(e) {
  1054. r.audioWrapper.buffer = e;
  1055. r.audioWrapper.noteOn(0);
  1056. r.startPlayTime = (new Date).getTime();
  1057. r.audioWrapper.loop = t;
  1058. r.waCheckInterval = setInterval(function() {
  1059. r.audioWrapper ? r.audioWrapper.playbackState == r.audioWrapper.FINISHED_STATE && r.controlPlay() : clearInterval(r.waCheckInterval)
  1060. }, 100)
  1061. })
  1062. } else this.audioWrapper.src = n, this.audioWrapper.type = this.mp3Support ? "audio/mpeg" : "audio/ogg", this.audioWrapper.loop = !1, this.audioWrapper.preload = "auto", this.audioWrapper.load(), this.delayPlay ? this.audioWrapper.addEventListener("canplay", this.readyToPlay) : this.audioWrapper.play(), this.audioWrapper.addEventListener("ended", this.controlPlay, !1);
  1063. this.busy = !0;
  1064. this.startPlayTime = (new Date).getTime()
  1065. };
  1066. this.loadSound = function(e, t) {
  1067. if (AudioMixer.buffer[e]) t && t(AudioMixer.buffer[e]);
  1068. else {
  1069. var n = new XMLHttpRequest;
  1070. n.open("GET.html", e, !0);
  1071. n.responseType = "arraybuffer";
  1072. n.onload = function() {
  1073. AudioMixer.waContext.decodeAudioData(this.response, function(n) {
  1074. AudioMixer.buffer[e] = n;
  1075. t && t(n)
  1076. })
  1077. }
  1078. }
  1079. };
  1080. this.readyToPlay = function(e) {
  1081. e.currentTarget.play()
  1082. };
  1083. this.stop = function() {
  1084. this.busy = !1;
  1085. try {
  1086. this.webAudioSupport ? this.audioWrapper.noteOff(0) : (this.audioWrapper.removeEventListener("canplay", this.readyToPlay), this.audioWrapper.pause(), this.audioWrapper.currentTime = 0), this.audioWrapper = null
  1087. } catch (e) {}
  1088. };
  1089. this.pause = function() {
  1090. this.webAudioSupport ? e.audioWrapper && e.audioWrapper.disconnect() : this.audioWrapper.pause()
  1091. };
  1092. this.resume = function() {
  1093. this.webAudioSupport ? e.audioWrapper && e.audioWrapper.connect(AudioMixer.waContext.destination) : this.audioWrapper.play()
  1094. };
  1095. this.controlPlay = function() {
  1096. if (e.audioWrapper.doLoop) this.webAudioSupport || (e.audioWrapper.pause(), e.audioWrapper.currentTime = 0, e.audioWrapper.play());
  1097. else {
  1098. e.busy = !1;
  1099. if ("function" == typeof e.onend) e.onend();
  1100. this.waCheckInterval && clearInterval(this.waCheckInterval)
  1101. }
  1102. };
  1103. this.getPosition = function() {
  1104. if (this.webAudioSupport) {
  1105. if (!this.startPlayTime) return 0;
  1106. var e = this.getDuration();
  1107. if (!e) return 0;
  1108. var t = ((new Date).getTime() - this.startPlayTime) / 1e3;
  1109. return t <= e ? t : this.audioWrapper.doLoop ? t - Math.floor(t / e) * e : e
  1110. }
  1111. return this.audioWrapper.currentTime ? this.audioWrapper.currentTime : 0
  1112. };
  1113. this.getDuration = function() {
  1114. return this.webAudioSupport ? this.audioWrapper.buffer ? this.audioWrapper.buffer.duration : 0 : this.audioWrapper.duration ? this.audioWrapper.duration : 0
  1115. }
  1116. }
  1117. function AudioMixer(e, t) {
  1118. this.singleChannelMode = this.webAudioSupport = !1;
  1119. this.channels = [];
  1120. this.init = function(e, t) {
  1121. if (this.webAudioSupport = "webkitAudioContext" in window) {
  1122. AudioMixer.waContext = new webkitAudioContext;
  1123. var n = AudioMixer.waContext.createBuffer(1, 1, 22050);
  1124. sound = AudioMixer.waContext.createBufferSource();
  1125. sound.buffer = n;
  1126. sound.connect(AudioMixer.waContext.destination)
  1127. }
  1128. this.webAudioSupport || -1 == navigator.userAgent.toLowerCase().indexOf("mac") || (this.singleChannelMode = !0, t = 1);
  1129. this.path = e;
  1130. this.channels = [];
  1131. for (n = 0; n < t; n++) this.channels[n] = new AudioPlayer, this.channels[n].init(e, this.webAudioSupport);
  1132. var r, i;
  1133. "undefined" !== typeof document.hidden ? (r = "hidden", i = "visibilitychange") : "undefined" !== typeof document.mozHidden ? (r = "mozHidden", i = "mozvisibilitychange") : "undefined" !== typeof document.msHidden ? (r = "msHidden", i = "msvisibilitychange") : "undefined" !== typeof document.webkitHidden && (r = "webkitHidden", i = "webkitvisibilitychange");
  1134. var s = this;
  1135. document.addEventListener(i, function() {
  1136. if (document[r])
  1137. for (var e = 0; e < s.channels.length; e++) s.channels[e].pause();
  1138. else
  1139. for (e = 0; e < s.channels.length; e++) s.channels[e].resume()
  1140. }, !1)
  1141. };
  1142. this.play = function(e, t, n, r) {
  1143. var i = -1,
  1144. i = "number" == typeof r ? r : this.getFreeChannel(n);
  1145. 0 <= i && i < this.channels.length && (this.channels[i].stop(), this.channels[i].play(e, t));
  1146. return this.channels[i]
  1147. };
  1148. this.stop = function(e) {
  1149. 0 <= e && e < this.channels.length && this.channels[e].stop()
  1150. };
  1151. this.getFreeChannel = function(e) {
  1152. for (var t = -1, n = [], r = -1, i = 0, s = 0; s < this.channels.length; s++) this.channels[s].locked || (this.channels[s].busy ? (i = (new Date).getTime(), i -= this.channels[s].startPlayTime, i > r && (r = i)) : n.push(s));
  1153. 0 == n.length ? !e && 0 <= r && (t = r) : t = n[0];
  1154. return t
  1155. };
  1156. this.init(e, t)
  1157. }
  1158. function gameButton(e, t, n) {
  1159. var r = library.getSprite(e);
  1160. r.x = t;
  1161. r.y = n;
  1162. r.gotoAndStop(1);
  1163. r.onmousedown = function() {
  1164. r.gotoAndStop(0)
  1165. };
  1166. r.onmouseout = function() {
  1167. r.gotoAndStop(1)
  1168. };
  1169. r.onmouseup = function() {
  1170. r.gotoAndStop(1);
  1171. 0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("button_click", !1, !1, 0)
  1172. };
  1173. return r
  1174. }
  1175. function startLoad() {
  1176. var e = Utils.getMobileScreenResolution(landscape);
  1177. Utils.globalScale = e.scale;
  1178. Utils.createLayout(document.getElementById("main_container"), e, landscape);
  1179. Utils.addEventListener("fitlayout", function() {
  1180. stage && (stage.drawScene(document.getElementById("screen")), buildBackground());
  1181. setBackgroundScale()
  1182. });
  1183. Utils.addEventListener("lockscreen", function() {
  1184. stage && stage.started && stage.stop()
  1185. });
  1186. Utils.addEventListener("unlockscreen", function() {
  1187. stage && !stage.started && stage.start()
  1188. });
  1189. Utils.mobileHideAddressBar();
  1190. Utils.checkOrientation(landscape);
  1191. mixer = new AudioMixer("music", 1);
  1192. mixer2 = new AudioMixer("music", 1);
  1193. library = new AssetsLibrary("images", Utils.globalScale, assets);
  1194. TTLoader.create(loadImagesEnd, !0);
  1195. library.load(TTLoader.loadComplete, TTLoader.showLoadProgress)
  1196. }
  1197. function loadImagesEnd(e) {
  1198. document.getElementById("progress_container").style.display = "none";
  1199. document.getElementById("screen_container").style.display = "block";
  1200. document.getElementById("screen_background_container").style.display = "block";
  1201. FontManager.registerFont("baveuse", Charset.latin, 9, 14);
  1202. gameState = STATE_MENU;
  1203. iosMode = -1 != navigator.userAgent.toLowerCase().indexOf("mac");
  1204. android = -1 != navigator.userAgent.toLowerCase().indexOf("android");
  1205. createScene()
  1206. }
  1207. function showMenu() {
  1208. gameState = STATE_MENU;
  1209. createScene()
  1210. }
  1211. function createStage() {
  1212. stage && (stage.destroy(), stage.stop());
  1213. stage = new Stage("screen", 320, 480, !1);
  1214. stage.delay = 1e3 / fps;
  1215. stage.ceilSizes = !0;
  1216. stage.onpretick = preTick;
  1217. stage.onposttick = postTick;
  1218. stage.showFPS = !1
  1219. }
  1220. function createScene() {
  1221. createStage();
  1222. gameState == STATE_MENU && createMenu();
  1223. gameState == STATE_SELECT_DIFFICULTY && selectDifficulty();
  1224. gameState == STATE_MISSION_INFO && showMissionInfo();
  1225. gameState == STATE_GAME && createGame();
  1226. gameState == STATE_VICTORY && showVictoryScreen();
  1227. gameState == STATE_DEFEAT && showDefeatScreen();
  1228. gameState == STATE_HIGHSCORES ;
  1229. gameState == STATE_CREDITS && showEvolution();
  1230. gameState == STATE_TUTORIAL && showTutorialMenu();
  1231. setBackground("#FFFFFF url('images/" + Utils.globalScale + "/gme-bg.jpg')");
  1232. buildBackground();
  1233. stage.start()
  1234. }
  1235. function setBackground(e) {
  1236. e !== lastBackground && (document.getElementById("screen_background_container").style.background = e, document.getElementById("screen_background_container").style.backgroundRepeat = "no-repeat", document.getElementById("screen_background_container").style.backgroundPosition = "center top", lastBackground = e, setBackgroundScale())
  1237. }
  1238. function setBackgroundScale() {
  1239. var e = Utils.globalScale * Utils.globalPixelScale;
  1240. document.getElementById("screen_background_container").style.backgroundSize = 870 * e + "px " + 480 * e + "px"
  1241. }
  1242. function showDefeatScreen() {
  1243. stage.addChild(library.getSprite("null", {
  1244. x: 160,
  1245. y: 240,
  1246. "static": !0,
  1247. onmouseup: function() {
  1248. gameState = STATE_GAME;
  1249. createScene()
  1250. }
  1251. }));
  1252. stage.addChild(library.getSprite("popup_loose", {
  1253. x: 160,
  1254. y: 180
  1255. }));
  1256. var e = new gameButton("menu", 160, 455);
  1257. e.addEventListener("mouseup", function() {
  1258. showMenu();
  1259. return !1
  1260. });
  1261. stage.addChild(e);
  1262. checkAndSetHighscores()
  1263. }
  1264. function createMenu() {
  1265. stage.addChild(library.getSprite("field-main-logo", {
  1266. x: 160,
  1267. y: 80
  1268. }));
  1269. stage.addChild(library.getSprite("field-main-btn-bg", {
  1270. x: 160,
  1271. y: 280
  1272. }));
  1273. var e = new gameButton("play", 158, 201);
  1274. e.addEventListener("mouseup", function(e) {
  1275. gameState = STATE_SELECT_DIFFICULTY;
  1276. createScene();
  1277. return !1
  1278. });
  1279. stage.addChild(e);
  1280. e = new gameButton("highscores", 171, 302);
  1281. e.addEventListener("mouseup", function(e) {
  1282. gameState = STATE_HIGHSCORES;
  1283. createScene()
  1284. });
  1285. stage.addChild(e);
  1286. e = new gameButton("credits", 145, 375);
  1287. e.addEventListener("mouseup", function(e) {
  1288. gameState = STATE_CREDITS;
  1289. createScene()
  1290. });
  1291. stage.addChild(e);
  1292. e = new gameButton("qmark", 55, 450);
  1293. e.addEventListener("mouseup", function(e) {
  1294. gameState = STATE_TUTORIAL;
  1295. createScene()
  1296. });
  1297. stage.addChild(e);
  1298. 1 == Utils.getCookie("soundOn") || ignoreMenuTheme || mixer2.play("main_theme", !0, !1, 0);
  1299. addSoundIcon()
  1300. }
  1301. function testChance() {
  1302. var e = rouletteProbability,
  1303. t = 0,
  1304. n;
  1305. for (n in e) t += e[n].n;
  1306. t = Math.floor(Math.random() * t);
  1307. for (n in e)
  1308. if (t -= e[n].n, 0 >= t) return e[n].v;
  1309. return 1
  1310. }
  1311. function playRoulette() {
  1312. for (var e = [], t = [], n = 0; 3 > n; n++) {
  1313. t.push(testChance());
  1314. var r = new GameElement(t[n]);
  1315. r.x = 102 + 58 * n;
  1316. r.y = 219;
  1317. r.isRoulette = !0;
  1318. e.push(r);
  1319. r = library.getSprite("coin_rotate");
  1320. r.x = 102 + 58 * n;
  1321. r.y = 219;
  1322. r.animDelay = 1;
  1323. r.isRoulette = !0;
  1324. r.gotoAndPlay(0);
  1325. tempRouletteArray.push(r);
  1326. stage.addChild(r)
  1327. }
  1328. setTimeout(function() {
  1329. tempRouletteArray[0].onenterframe = function(t) {
  1330. 8 == t.target.currentFrame && (tempRouletteArray[0].destroy = !0, stage.addChild(e[0]), 0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("roulette_popup", !1, !1, 0))
  1331. }
  1332. }, 2e3);
  1333. setTimeout(function() {
  1334. tempRouletteArray[1].onenterframe = function(t) {
  1335. 8 == t.target.currentFrame && (tempRouletteArray[1].destroy = !0, stage.addChild(e[1]), 0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("roulette_popup", !1, !1, 0))
  1336. }
  1337. }, 4e3);
  1338. setTimeout(function() {
  1339. tempRouletteArray[2].onenterframe = function(t) {
  1340. 8 == t.target.currentFrame && (tempRouletteArray[2].destroy = !0, stage.addChild(e[2]), 0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("roulette_popup", !1, !1, 0))
  1341. };
  1342. setTimeout(function() {
  1343. checkIfRouletteWon(t)
  1344. }, 1e3)
  1345. }, 6e3)
  1346. }
  1347. function checkIfRouletteWon(e) {
  1348. if (e[0] == e[1] && e[0] != e[2] || e[0] == e[2] && e[0] != e[1] || e[1] == e[2] && e[0] != e[1]) 0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("roulette_nice", !1, !1, 0);
  1349. e[0] == e[1] && e[0] == e[2] ? (coinsInc(), setUserCoins(), stage.addChild(library.getSprite("text2", {
  1350. x: 160,
  1351. y: 260
  1352. })), drawHighscores(1, 140, 285), 0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("roulette_super_nice", !1, !1, 0)) : (stage.addChild(library.getSprite("text3", {
  1353. x: 160,
  1354. y: 260
  1355. })), drawHighscores(0, 140, 285), 0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("roulette_not_nice", !1, !1, 0));
  1356. stage.addChild(library.getSprite("text1", {
  1357. x: 170,
  1358. y: 285
  1359. }))
  1360. }
  1361. function showVictoryScreen() {
  1362. 0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("victory", !1, !1, 0);
  1363. var e, t = "ultimate" == currentDifficulty ? !0 : !1,
  1364. n;
  1365. if (t && maxUnlockedItem.newUnlocked) maxUnlockedItem.newUnlocked && (e = 240, stage.addChild(library.getSprite("back_field_win_3", {
  1366. x: 160,
  1367. y: e - 40
  1368. })), e += 43, drawLevelScore(143), playRoulette());
  1369. else {
  1370. 0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("victory", !1, !1, 0);
  1371. n = LEVELS[current_game_mode].upgrades;
  1372. n = t ? maxUnlockedItem.t : n[n.length - 1];
  1373. e = 240;
  1374. stage.addChild(library.getSprite("back_field_win", {
  1375. x: 160,
  1376. y: e - 40
  1377. }));
  1378. var r = library.getSprite("light_win");
  1379. r.x = 160;
  1380. r.y = 200;
  1381. stage.addChild(r);
  1382. stage.setInterval(function() {
  1383. r.rotateBy(Math.PI / 160)
  1384. }, 2);
  1385. n = new GameElement(n, t);
  1386. n.setPosition(160, 205);
  1387. stage.addChild(n);
  1388. drawLevelScore(265)
  1389. }
  1390. n = new gameButton("win_next", 243, e + 18);
  1391. n.addEventListener("mouseup", function(e) {
  1392. gameState = STATE_SELECT_DIFFICULTY;
  1393. createScene()
  1394. });
  1395. stage.addChild(n);
  1396. e = new gameButton("win_replay", 76, e + 18);
  1397. e.addEventListener("mouseup", function(e) {
  1398. gameState = STATE_GAME;
  1399. createScene()
  1400. });
  1401. stage.addChild(e);
  1402. t || levelCompleted();
  1403. checkAndSetHighscores()
  1404. }
  1405. function addSoundIcon() {
  1406. ignoreMenuTheme = !0;
  1407. sound = library.getSprite("sound");
  1408. sound.x = 275;
  1409. sound.y = 455;
  1410. 1 == Utils.getCookie("soundOn") ? (sound.gotoAndStop(0), soundOn = !1) : (sound.gotoAndStop(1), soundOn = !0);
  1411. sound.state = 1;
  1412. sound.onmouseup = soundIconOnChange;
  1413. stage.addChild(sound)
  1414. }
  1415. function showHighscores() {
  1416. stage.addChild(library.getSprite("field_highscore", {
  1417. x: 160,
  1418. y: 240,
  1419. "static": !0
  1420. }));
  1421. var e = new gameButton("menu", 160, 400);
  1422. e.addEventListener("mouseup", showMenu);
  1423. stage.addChild(e);
  1424. addSoundIcon();
  1425. for (var e = [], t = 1; 11 > t; t++) {
  1426. var n = Utils.getCookie("maxScore" + t),
  1427. n = null == n ? 0 : n,
  1428. n = parseInt(n);
  1429. e.push(n)
  1430. }
  1431. e.sort(function(e, t) {
  1432. return e > t ? -1 : e < t ? 1 : 0
  1433. });
  1434. t = 0;
  1435. for (n = e.length; t < n; t++) drawHighscores(t + 1, 60, 92 + 30 * t, "numbers"), drawHighscores(e[t], 265, 92 + 30 * t)
  1436. }
  1437. function drawHighscores(e, t, n, r) {
  1438. var i = library.getAsset("font1", !0).bitmap;
  1439. e += "";
  1440. if ("numbers" == r)
  1441. for (r = 0; r < e.length; r++) mc = new Sprite(i, 12, 20, 10), mc.gotoAndStop(e.substr(r, 1)), mc.x = t + 12 * r, mc.y = n, stage.addChild(mc);
  1442. else
  1443. for (r = e.length; 0 < r; r--) mc = new Sprite(i, 12, 20, 10), mc.gotoAndStop(e.substr(e.length - r, 1)), mc.x = t - 12 * r, mc.y = n, stage.addChild(mc)
  1444. }
  1445. function checkAndSetHighscores() { /*updateShare(current_game_mode,gameScore);Play68.setRankingScoreDesc(gameScore);*/
  1446. for (var e = [], t = 1; 11 > t; t++) {
  1447. var n = Utils.getCookie("maxScore" + t);
  1448. void 0 != n && e.push(n)
  1449. }
  1450. t = e.length;
  1451. if (10 > t) t++, Utils.setCookie("maxScore" + t, gameScore);
  1452. else
  1453. for (t = 0; 10 > t; t++)
  1454. if (e[t] < gameScore) {
  1455. t++;
  1456. Utils.setCookie("maxScore" + t, gameScore);
  1457. break
  1458. }
  1459. }
  1460. function moveIconsVert(e, t) {
  1461. for (var n, r = 0, i = stage.objects.length; r < i; r++) {
  1462. var s = stage.objects[r];
  1463. s.first && (n = s, 0 < e && 110 <= s.y + e && (e = 110 - s.y, t && (t[0].visible = !1)), 0 > e && -660 >= s.y + e && (e = -660 - s.y, t && (t[1].visible = !1)));
  1464. if (s.first && 110 <= s.y && 0 < e) return t && (t[0].visible = !1), !1;
  1465. if (s.first && -660 >= s.y && 0 > e) return t && (t[1].visible = !1), !1;
  1466. if (s.isMovable) {
  1467. s.y += e;
  1468. var o = s.y;
  1469. s.visible = 90 >= o || 390 <= o ? !1 : !0;
  1470. s.opacity = 90 < o && 110 >= o ? (o - 90) / 20 : 360 <= o && 390 > o ? Math.abs(390 - o) / 30 : 1
  1471. }
  1472. }
  1473. t && (t[0].visible = !0, t[1].visible = !0);
  1474. 110 <= n.y && t && (t[0].visible = !1); - 660 >= n.y && t && (t[1].visible = !1)
  1475. }
  1476. function showEvolution() {
  1477. scrollLocked = !1;
  1478. var e = new Sprite(null, 320, 480);
  1479. e.x = 160;
  1480. e.y = 240;
  1481. e.static = !0;
  1482. e.onmousedown = function() {
  1483. startScrollPosition = window.event.pageY;
  1484. scrollLocked = !0
  1485. };
  1486. e.onmouseup = function() {
  1487. scrollLocked = !1
  1488. };
  1489. e.onmousemove = function() {
  1490. if (scrollLocked) {
  1491. var e = window.event.pageY;
  1492. moveIconsVert((e - startScrollPosition) / 1.85, [t, n]);
  1493. startScrollPosition = e
  1494. }
  1495. };
  1496. stage.addChild(e);
  1497. stage.addChild(library.getSprite("back", {
  1498. x: 160,
  1499. y: 235
  1500. }));
  1501. e = library.getSprite("evol_back", {
  1502. x: 160,
  1503. y: 230
  1504. });
  1505. stage.setZIndex(e, 100);
  1506. stage.addChild(e);
  1507. var t = new Sprite(library.getSprite("arrow_up").bitmap, 31, 12);
  1508. t.x = 160;
  1509. t.y = 70;
  1510. t.onclick = function() {
  1511. moveIconsVert(85, [t, n])
  1512. };
  1513. t.visible = !1;
  1514. stage.setZIndex(t, 150);
  1515. stage.addChild(t);
  1516. var n = new Sprite(library.getSprite("arrow_down").bitmap, 31, 12);
  1517. n.x = 160;
  1518. n.y = 405;
  1519. n.onclick = function() {
  1520. moveIconsVert(-85, [t, n])
  1521. };
  1522. stage.setZIndex(n, 150);
  1523. stage.addChild(n);
  1524. e = new gameButton("menu", 160, 450);
  1525. e.addEventListener("mousedown", function() {
  1526. clickForbidden = !1
  1527. });
  1528. e.addEventListener("mouseup", function() {
  1529. clickForbidden || (showMenu(), clickForbidden = !0)
  1530. });
  1531. stage.addChild(e);
  1532. addSoundIcon();
  1533. sound.addEventListener("mousedown", function() {
  1534. clickForbidden = !1
  1535. });
  1536. sound.onmouseup = function(e) {
  1537. clickForbidden || (clickForbidden = !0, soundIconOnChange())
  1538. };
  1539. stage.addChild(library.getSprite("Amoeba", {
  1540. x: 160,
  1541. y: 110,
  1542. isMovable: !0,
  1543. first: !0
  1544. }));
  1545. stage.addChild(library.getSprite("Jellyfish", {
  1546. x: 160,
  1547. y: 195,
  1548. isMovable: !0
  1549. }));
  1550. stage.addChild(library.getSprite("Fish", {
  1551. x: 160,
  1552. y: 280,
  1553. isMovable: !0
  1554. }));
  1555. e = Utils.getCookie("icon4ul") ? "lizard" : "Unknown";
  1556. stage.addChild(library.getSprite(e, {
  1557. x: 160,
  1558. y: 365,
  1559. isMovable: !0
  1560. }));
  1561. e = Utils.getCookie("icon5ul") ? "wolf" : "Unknown";
  1562. stage.addChild(library.getSprite(e, {
  1563. x: 160,
  1564. y: 450,
  1565. isMovable: !0
  1566. }));
  1567. e = Utils.getCookie("icon6ul") ? "ape" : "Unknown";
  1568. stage.addChild(library.getSprite(e, {
  1569. x: 160,
  1570. y: 535,
  1571. isMovable: !0
  1572. }));
  1573. e = Utils.getCookie("icon7ul") ? "human" : "Unknown";
  1574. stage.addChild(library.getSprite(e, {
  1575. x: 160,
  1576. y: 620,
  1577. isMovable: !0
  1578. }));
  1579. e = Utils.getCookie("icon11ul") ? "humanoid" : "Unknown";
  1580. stage.addChild(library.getSprite(e, {
  1581. x: 160,
  1582. y: 705,
  1583. isMovable: !0
  1584. }));
  1585. e = Utils.getCookie("icon12ul") ? "superhuman" : "Unknown";
  1586. stage.addChild(library.getSprite(e, {
  1587. x: 160,
  1588. y: 790,
  1589. isMovable: !0
  1590. }));
  1591. e = Utils.getCookie("icon13ul") ? "cyborg" : "Unknown";
  1592. stage.addChild(library.getSprite(e, {
  1593. x: 160,
  1594. y: 875,
  1595. isMovable: !0
  1596. }));
  1597. e = Utils.getCookie("icon14ul") ? "geek" : "Unknown";
  1598. stage.addChild(library.getSprite(e, {
  1599. x: 160,
  1600. y: 960,
  1601. isMovable: !0
  1602. }));
  1603. e = Utils.getCookie("icon15ul") ? "zombie" : "Unknown";
  1604. stage.addChild(library.getSprite(e, {
  1605. x: 160,
  1606. y: 1045,
  1607. isMovable: !0
  1608. }));
  1609. e = Utils.getCookie("icon16ul") ? "superbrains" : "Unknown";
  1610. stage.addChild(library.getSprite(e, {
  1611. x: 160,
  1612. y: 1130,
  1613. isMovable: !0
  1614. }));
  1615. moveIconsVert(0)
  1616. }
  1617. function setDifficulty(e) {
  1618. e = ~~e.target.mode;
  1619. gameState = STATE_MISSION_INFO;
  1620. current_game_mode = e = Math.max(0, Math.min(LEVELS.length, ~~e));
  1621. createScene()
  1622. }
  1623. function selectDifficulty() {
  1624. stage.addChild(library.getSprite("field-select-level-bg", {
  1625. x: 161,
  1626. y: 240
  1627. }));
  1628. var e = new gameButton("menu", 160, 455);
  1629. e.addEventListener("mouseup", showMenu);
  1630. stage.addChild(e);
  1631. addLevelIcon("easy");
  1632. addLevelIcon("medium");
  1633. addLevelIcon("hard");
  1634. addLevelIcon("expert");
  1635. addLevelIcon("ultimate");
  1636. addSoundIcon();
  1637. showUnlockAnimation && (addUnlockAnimation(), showUnlockAnimation = !1)
  1638. }
  1639. function addUnlockAnimation() {
  1640. var e;
  1641. switch (currentDifficulty) {
  1642. case "easy":
  1643. e = 175;
  1644. break;
  1645. case "medium":
  1646. e = 245;
  1647. break;
  1648. case "hard":
  1649. e = 315;
  1650. break;
  1651. case "expert":
  1652. e = 385
  1653. }
  1654. var t = library.getSprite("lock");
  1655. t.x = 230;
  1656. t.y = e;
  1657. t.animDelay = 3;
  1658. t.onenterframe = function(e) {
  1659. 10 == e.target.currentFrame && (e.target.destroy = !0)
  1660. };
  1661. stage.addChild(t)
  1662. }
  1663. function addLevelIcon(e) {
  1664. var t = library.getSprite(e);
  1665. t.x = 160;
  1666. switch (e) {
  1667. case "easy":
  1668. t.y = 105;
  1669. t.mode = D_SIMPLE;
  1670. t.gotoAndStop(0);
  1671. t.onmouseup = function(e) {
  1672. currentDifficulty = "easy";
  1673. setDifficulty(e)
  1674. };
  1675. break;
  1676. case "medium":
  1677. t.y = 175;
  1678. t.mode = D_NORMAL;
  1679. void 0 == Utils.getCookie("easy_level_completed") ? t.gotoAndStop(0) : (t.gotoAndStop(1), t.onmouseup = function(e) {
  1680. currentDifficulty = "medium";
  1681. setDifficulty(e)
  1682. });
  1683. break;
  1684. case "hard":
  1685. t.y = 245;
  1686. t.mode = D_HARD;
  1687. void 0 == Utils.getCookie("medium_level_completed") ? t.gotoAndStop(0) : (t.gotoAndStop(1), t.onmouseup = function(e) {
  1688. currentDifficulty = "hard";
  1689. setDifficulty(e)
  1690. });
  1691. break;
  1692. case "expert":
  1693. t.y = 315;
  1694. t.mode = D_EXPERT;
  1695. void 0 == Utils.getCookie("hard_level_completed") ? t.gotoAndStop(1) : (t.gotoAndStop(0), t.onmouseup = function(e) {
  1696. currentDifficulty = "expert";
  1697. setDifficulty(e)
  1698. });
  1699. break;
  1700. case "ultimate":
  1701. t.y = 385, t.mode = D_ULTIMATE, void 0 == Utils.getCookie("expert_level_completed") ? t.gotoAndStop(1) : (t.gotoAndStop(0), t.onmouseup = function(e) {
  1702. currentDifficulty = "ultimate";
  1703. setDifficulty(e)
  1704. })
  1705. }
  1706. stage.addChild(t)
  1707. }
  1708. function levelCompleted() {
  1709. Utils.getCookie(currentDifficulty + "_level_completed") || (Utils.setCookie(currentDifficulty + "_level_completed", !0), showUnlockAnimation = !0, "easy" == currentDifficulty && Utils.setCookie("icon4ul", !0), "medium" == currentDifficulty && Utils.setCookie("icon5ul", !0), "hard" == currentDifficulty && Utils.setCookie("icon6ul", !0), "expert" == currentDifficulty && Utils.setCookie("icon7ul", !0))
  1710. }
  1711. function createGame() {
  1712. if (gameState != STATE_GAME) return !1;
  1713. clearGame();
  1714. stage.addChild(library.getSprite("field-play-playingfield", {
  1715. x: 161,
  1716. y: 260,
  1717. tatic: !0
  1718. }));
  1719. stage.addChild(library.getSprite("field-play-score-bg", {
  1720. x: 145,
  1721. y: 111,
  1722. "static": !0
  1723. }));
  1724. var e = new gameButton("menu", 80, 30);
  1725. e.addEventListener("mouseup", showMenu);
  1726. stage.addChild(e);
  1727. e = new gameButton("replay", 240, 30);
  1728. e.addEventListener("mouseup", createScene);
  1729. stage.addChild(e);
  1730. addSoundIcon();
  1731. e = new gameButton("plus", 281, 106);
  1732. e.addEventListener("mouseup", function() {
  1733. tutorialActivated || showShop();
  1734. tutorialActivated && tut14completed && (showShop(), tutDone())
  1735. });
  1736. stage.addChild(e);
  1737. field = new GameField(LEVELS[current_game_mode]);
  1738. field.create()
  1739. }
  1740. function clearGame() {
  1741. score = field = null;
  1742. maxUnlockedItem = {
  1743. t: 3,
  1744. newUnlocked: !1
  1745. }
  1746. }
  1747. function showShop() {
  1748. field.locked = !0;
  1749. var e = new Sprite(null, 320, 480);
  1750. e.x = 160;
  1751. e.y = 240;
  1752. e.isShopElement = !0;
  1753. e.onmouseup = function() {
  1754. destroyShop();
  1755. return !1
  1756. };
  1757. stage.addChild(e);
  1758. e = library.getSprite("popup_bg");
  1759. e.x = 160;
  1760. e.y = 240;
  1761. e.isShopElement = !0;
  1762. e.onmouseup = function() {
  1763. return !1
  1764. };
  1765. stage.addChild(e);
  1766. drawText("coins", 200, 180);
  1767. e = library.getSprite("ether");
  1768. e.x = 125;
  1769. e.y = 217;
  1770. e.isShopElement = !0;
  1771. e.gametype = T_ETHER;
  1772. e.onmouseup = buyItem;
  1773. stage.addChild(e);
  1774. e = library.getSprite("fire");
  1775. e.x = 195;
  1776. e.y = 217;
  1777. e.gametype = T_FIRE;
  1778. e.isShopElement = !0;
  1779. e.onmouseup = buyItem;
  1780. stage.addChild(e);
  1781. e = new gameButton("buy", 160, 290);
  1782. e.onmouseup = buyCoins;
  1783. e.isShopElement = !0;
  1784. stage.addChild(e)
  1785. }
  1786. function buyCoins() {}
  1787. function coinsInc() {
  1788. coins++;
  1789. 0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("coin_add", !1, !1, 0)
  1790. }
  1791. function addCoins() {
  1792. usedPoints -= 1e6;
  1793. coinsInc();
  1794. var e = library.getSprite("light_win");
  1795. e.x = 281;
  1796. e.y = 106;
  1797. stage.addChild(e);
  1798. var t = stage.setInterval(function() {
  1799. e.rotateBy(Math.PI / 160)
  1800. }, 3);
  1801. setTimeout(function() {
  1802. stage.clearInterval(t);
  1803. e.destroy = !0
  1804. }, 3500);
  1805. setUserCoins();
  1806. var n = library.getSprite("coin_rotate12");
  1807. n.x = 160;
  1808. n.y = 83;
  1809. n.animDelay = 2;
  1810. n.gotoAndPlay(0);
  1811. n.onenterframe = function(e) {
  1812. 17 == e.target.currentFrame && (n.destroy = !0)
  1813. };
  1814. stage.addChild(n)
  1815. }
  1816. function buyItem(e) {
  1817. var t = e.target.gametype;
  1818. if (!(t == T_ETHER && 3 > coins || t == T_FIRE && 1 > coins)) {
  1819. var n = new GameElement(t);
  1820. n.setPosition(e.target.x, e.target.y);
  1821. var r = new GameElement(field.storedElement.gametype);
  1822. r.setPosition(field.storedElement.x, field.storedElement.y);
  1823. stage.addChild(n);
  1824. field.locked = !0;
  1825. n.moveTo(field.storedElement.x, field.storedElement.y, 6, Easing.cubic.easeIn, function(e) {
  1826. field.storedElement.setType(e.target.obj.gametype);
  1827. field.storedElement.visible = !0;
  1828. stage.removeChild(e.target.obj);
  1829. field.locked = !1
  1830. });
  1831. r.gametype > T_EMPTY && (field.storedElement.visible = !1, stage.removeChild(e.target.obj));
  1832. coins -= t == T_ETHER ? 3 : 1;
  1833. setUserCoins();
  1834. drawText("coins", 200, 180)
  1835. }
  1836. }
  1837. function destroyShop() {
  1838. for (var e = stage.objects.length, t = 0, e = stage.objects.length; t < e; t++) {
  1839. var n = stage.objects[t];
  1840. n.isShopElement && (n.destroy = !0)
  1841. }
  1842. field.locked = !1
  1843. }
  1844. function checkIfNeedPopup(e) {
  1845. if (3 >= field.upgradeType || 8 == field.upgradeType || Utils.getCookie("icon" + field.upgradeType + "ul")) return e(), !1;
  1846. if ("number" == typeof field.upgradeType) showEvolutionPopup(field.upgradeType, e);
  1847. else return e(), !0
  1848. }
  1849. function showEvolutionPopup(e, t) {
  1850. field.locked = !0;
  1851. var n = new Sprite(null, 320, 480);
  1852. n.setPosition(160, 240);
  1853. n.onmouseup = function() {
  1854. n.destroy = !0;
  1855. r.destroy = !0;
  1856. s.destroy = !0;
  1857. field.locked = !1;
  1858. t();
  1859. return !1
  1860. };
  1861. stage.addChild(n);
  1862. var r = new Sprite(library.getAsset("back_field-evolution-popup").bitmap, 411, 313);
  1863. r.setPosition(160, 240);
  1864. stage.addChild(r);
  1865. var i;
  1866. switch (e) {
  1867. case 4:
  1868. i = "lizard";
  1869. break;
  1870. case 5:
  1871. i = "wolf";
  1872. break;
  1873. case 6:
  1874. i = "ape";
  1875. break;
  1876. case 7:
  1877. i = "human";
  1878. break;
  1879. case 11:
  1880. i = "humanoid";
  1881. break;
  1882. case 12:
  1883. i = "superhuman";
  1884. break;
  1885. case 13:
  1886. i = "cyborg";
  1887. break;
  1888. case 14:
  1889. i = "geek";
  1890. break;
  1891. case 15:
  1892. i = "zombie";
  1893. break;
  1894. case 16:
  1895. i = "superbrains"
  1896. }
  1897. var s = new Sprite(library.getSprite(i).bitmap, 256, 80);
  1898. s.setPosition(r.x + 6, r.y + 8);
  1899. stage.addChild(s);
  1900. Utils.setCookie("icon" + field.upgradeType + "ul", !0)
  1901. }
  1902. function shuffle(e) {
  1903. for (var t, n, r = e.length; r; t = parseInt(Math.random() * r), n = e[--r], e[r] = e[t], e[t] = n);
  1904. }
  1905. function initializeUserScore() {
  1906. var e = Utils.getCookie("coins");
  1907. void 0 != e && (coins = parseInt(e));
  1908. gameScore = usedPoints = 0
  1909. }
  1910. function setUserCoins() {
  1911. Utils.setCookie("coins", coins)
  1912. }
  1913. function getScore() {
  1914. return score ? ~~score.getString() : 0
  1915. }
  1916. function setScore(e, t, n, r) {
  1917. gameScore += e;
  1918. usedPoints += e;
  1919. 1e6 <= usedPoints && addCoins();
  1920. drawText("gameScore", 150, 110);
  1921. void 0 != t && (t = ~~t, r = ~~r, 0 != t && (e = new GUIString("baveuse", !1, {
  1922. align: STR_ALIGN_CENTER,
  1923. valign: STR_VALIGN_MIDDLE,
  1924. x: ~~n,
  1925. y: r
  1926. }), e.write((0 < t ? "+" : "") + t), t = stage.createTween(e, "y", r, r - 30, 12, Easing.linear.easeIn), r = stage.createTween(e, "opacity", 1, 0, 18, Easing.linear.easeIn), t.onchange = function(e) {
  1927. e.target.obj.setParams({
  1928. y: e.target.obj.y
  1929. })
  1930. }, r.onchange = function(e) {
  1931. e.target.obj.setParams({
  1932. opacity: e.target.obj.opacity
  1933. })
  1934. }, r.onfinish = function(e) {
  1935. e.target.obj.write("");
  1936. e.target.obj = null
  1937. }, t.play(), r.play()))
  1938. }
  1939. function buildBackground() {
  1940. stage.drawScene(document.getElementById("screen_background"), !0)
  1941. }
  1942. function submitScores() {
  1943. ExternalAPI.check() && ExternalAPI.checkUserLoggedIn() && insertScores()
  1944. }
  1945. function insertScores() {
  1946. ExternalAPI.check() && ExternalAPI.submitScores(gameScore, function() {})
  1947. }
  1948. function preTick() {}
  1949. function postTick() {}
  1950. function Text(e, t, n) {
  1951. this.ALIGN_LEFT = 0;
  1952. this.ALIGN_RIGHT = 1;
  1953. this.ALIGN_CENTER = 2;
  1954. this.font = e;
  1955. this.y = this.x = 0;
  1956. this.width = t;
  1957. this.height = n;
  1958. this.align = this.ALIGN_LEFT;
  1959. this.rotation = 0;
  1960. this.static = !1;
  1961. this.charMap = "0123456789:+".split("");
  1962. this.sprites = [];
  1963. this.text = "";
  1964. this.manageSprites = function(e) {
  1965. var t, n = e.length,
  1966. r = this.sprites.length;
  1967. if (r < n)
  1968. for (e = 0; e < n - r; e++) t = new Sprite(this.font, this.width, this.height, this.charMap.length), this.sprites.push(t), stage.addChild(t);
  1969. if (r > n) {
  1970. for (e = 0; e < r - n; e++) stage.removeChild(this.sprites[e]);
  1971. this.sprites.splice(0, r - n)
  1972. }
  1973. };
  1974. this.write = function(e) {
  1975. var t, n, r, i;
  1976. this.text = e += "";
  1977. this.manageSprites(e);
  1978. t = this.x;
  1979. this.align == this.ALIGN_CENTER && (t = this.x - (e.length - 1) / 2 * this.width);
  1980. this.align == this.ALIGN_RIGHT && (t = this.x - (e.length - 1) * this.width);
  1981. r = new Vector(t - this.x, 0);
  1982. r.rotate(-this.rotation);
  1983. t = r.x + this.x;
  1984. n = r.y + this.y;
  1985. r = new Vector(0, 0);
  1986. for (var s = 0; s < e.length; s++) this.sprites[s].visible = !0, i = this.charMap.indexOf(e.substr(s, 1)), 0 > i ? this.sprites[s].visible = !1 : (this.sprites[s].gotoAndStop(i), i = r.clone(), i.rotate(-this.rotation), this.sprites[s].x = i.x + t, this.sprites[s].y = i.y + n, this.sprites[s].rotation = this.rotation, this.sprites[s].static = this.static, r.x += this.width)
  1987. }
  1988. }
  1989. function clearText(e) {
  1990. for (var t = 0, n = stage.objects.length; t < n; t++) {
  1991. var r = stage.objects[t];
  1992. r[e] && (r.destroy = !0)
  1993. }
  1994. }
  1995. function drawLevelScore(e) {
  1996. var t = 160,
  1997. n = library.getAsset("font1", !0).bitmap;
  1998. gameScore += "";
  1999. for (var t = t - (gameScore.length - 1) / 2 * 12, r = 0; r < gameScore.length; r++) {
  2000. var i = new Sprite(n, 12, 20, 10);
  2001. i.gotoAndStop(gameScore.substr(r, 1));
  2002. i.x = t + 12 * r;
  2003. i.y = e;
  2004. stage.addChild(i)
  2005. }
  2006. }
  2007. function soundIconOnChange() {
  2008. 1 == Utils.getCookie("soundOn") ? (soundOn = !1, sound.gotoAndStop(1), mixer2.play("main_theme", !0, !1, 0), Utils.setCookie("soundOn", 0)) : (soundOn = !0, sound.gotoAndStop(0), mixer2.stop(0), Utils.setCookie("soundOn", 1))
  2009. }
  2010. function drawText(e, t, n) {
  2011. clearText(e);
  2012. var r = library.getAsset("font1", !0).bitmap,
  2013. i = "coins" == e ? coins : gameScore,
  2014. i = i + "";
  2015. t -= (i.length - 1) / 2 * 12;
  2016. for (var s = 0; s < i.length; s++) mc = new Sprite(r, 12, 20, 10), mc[e] = !0, "coins" == e && (mc.isShopElement = !0), mc.gotoAndStop(i.substr(s, 1)), mc.x = t + 12 * s, mc.y = n, stage.addChild(mc)
  2017. }
  2018. function moveIconsHor(e) {
  2019. for (var t = 320 * (slidesNumber - 1) - 160, n = 0, r = stage.objects.length; n < r; n++) {
  2020. var i = stage.objects[n];
  2021. if (0 == i.id && i.x <= -t - 20 && 0 < e || 0 == i.id && 180 <= i.x && 0 > e) return !1;
  2022. i.isMovable && (i.x -= e)
  2023. }
  2024. }
  2025. function checkClosestFigure() {
  2026. for (var e = Number.POSITIVE_INFINITY, t = 0, n, r = 0, i = stage.objects.length; r < i; r++) {
  2027. var s = stage.objects[r],
  2028. o = Math.abs(s.x - 160);
  2029. s.isMovable && o <= e && (e = o, n = s.id, t = s.x - 160)
  2030. }
  2031. return {
  2032. l: t,
  2033. n: n
  2034. }
  2035. }
  2036. function moveSelector(e, t) {
  2037. e.x = 160 - 8 * slidesNumber / 2 + 8 * t
  2038. }
  2039. function showTutorialMenu() {
  2040. var e = new Sprite(library.getAsset("arrow_prev", !0).bitmap, 12, 31);
  2041. e.x = 10;
  2042. e.y = 285;
  2043. e.visible = !1;
  2044. e.onclick = function() {
  2045. if (e.visible) {
  2046. moveIconsHor(-320);
  2047. showArrows(e, t);
  2048. var n = checkClosestFigure();
  2049. moveSelector(i, n.n)
  2050. }
  2051. };
  2052. stage.addChild(e);
  2053. var t = new Sprite(library.getAsset("arrow_frwd", !0).bitmap, 12, 31);
  2054. t.x = 310;
  2055. t.y = 285;
  2056. t.onclick = function() {
  2057. if (t.visible) {
  2058. moveIconsHor(320);
  2059. showArrows(e, t);
  2060. var n = checkClosestFigure();
  2061. moveSelector(i, n.n)
  2062. }
  2063. };
  2064. stage.addChild(t);
  2065. var n = new Sprite(null, 300, 480);
  2066. n.x = 160;
  2067. n.y = 240;
  2068. n.static = !0;
  2069. n.onmousedown = function() {
  2070. startScrollPosition = window.event.pageX;
  2071. scrollLocked = !0
  2072. };
  2073. n.onmouseup = function() {
  2074. scrollLocked = !1;
  2075. var n = checkClosestFigure();
  2076. moveIconsHor(n.l);
  2077. moveSelector(i, n.n);
  2078. showArrows(e, t)
  2079. };
  2080. n.onmousemove = function() {
  2081. if (scrollLocked) {
  2082. var n = window.event.pageX;
  2083. moveIconsHor(.8 * (startScrollPosition - n));
  2084. startScrollPosition = n;
  2085. t.visible = e.visible = !1
  2086. }
  2087. };
  2088. n.onmouseout = function() {
  2089. scrollLocked = !1;
  2090. var n = checkClosestFigure();
  2091. moveIconsHor(n.l);
  2092. moveSelector(i, n.n);
  2093. showArrows(e, t)
  2094. };
  2095. stage.addChild(n);
  2096. n = new gameButton("menu", 160, 450);
  2097. n.addEventListener("mouseup", showMenu);
  2098. stage.addChild(n);
  2099. addSoundIcon();
  2100. slidesNumber = 4;
  2101. n = new Sprite(library.getAsset("Help1", !0).bitmap, 320, 480);
  2102. n.x = 160;
  2103. n.y = 240;
  2104. n.isMovable = !0;
  2105. n.id = 0;
  2106. showTutorialMenu.firstPage = n;
  2107. stage.addChild(n);
  2108. stage.addChild(library.getSprite("Help2", {
  2109. x: 480,
  2110. y: 240,
  2111. isMovable: !0,
  2112. id: 1
  2113. }));
  2114. stage.addChild(library.getSprite("Help3", {
  2115. x: 800,
  2116. y: 240,
  2117. isMovable: !0,
  2118. id: 2
  2119. }));
  2120. stage.addChild(library.getSprite("Help4", {
  2121. x: 1120,
  2122. y: 240,
  2123. isMovable: !0,
  2124. id: 3
  2125. }));
  2126. for (var n = 160 - 8 * slidesNumber / 2, r = 0; r < slidesNumber; r++) stage.addChild(library.getSprite("r1", {
  2127. x: n + 8 * r,
  2128. y: 473
  2129. }));
  2130. var i = new Sprite(library.getAsset("r2", !0).bitmap, 6, 6);
  2131. i.x = n;
  2132. i.y = 473;
  2133. stage.addChild(i)
  2134. }
  2135. function showArrows(e, t) {
  2136. var n = showTutorialMenu.firstPage.x;
  2137. e.visible = 150 > n ? !0 : !1;
  2138. t.visible = n <= 180 - 320 * (slidesNumber - 1) ? !1 : !0
  2139. }
  2140. function showTutorial(e, t) {
  2141. "easy" == currentDifficulty && (t[0].setType(22), t[1].setType(22), t[4].setType(22), t[21].setType(22), t[19].setType(1), t[5].setType(1), t[20].setType(1), t[15].setType(1), t[13].setType(2), t[16].setType(3), showTutorial_1());
  2142. "medium" == currentDifficulty && (t[2].setType(22), t[10].setType(22), t[23].setType(22), t[9].setType(22), t[0].setType(1), t[8].setType(1), t[22].setType(1), t[16].setType(2), t[17].setType(2), showTutorial_10());
  2143. "hard" == currentDifficulty && (t[23].setType(22), t[19].setType(22), t[5].setType(22), t[16].setType(1), t[17].setType(1), t[3].setType(1), t[6].setType(2), showTutorial_11());
  2144. "ultimate" == currentDifficulty && showTutorial_14()
  2145. }
  2146. function fadeOut(e) {
  2147. e.opacity = 1;
  2148. e = e.addTween("opacity", 0, 10, Easing.linear.out, null, null);
  2149. setTimeout(e.play, 100)
  2150. }
  2151. function clearTutorialSprites() {
  2152. for (var e = 0, t = tutArray.length; e < t; e++) fadeOut(tutArray[e]);
  2153. tutArray = []
  2154. }
  2155. function showTutorial_1() {
  2156. var e = library.getSprite("txt_17");
  2157. e.x = 170;
  2158. e.y = 380;
  2159. e.opacity = 0;
  2160. stage.addChild(e);
  2161. var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
  2162. setTimeout(t.play, 100);
  2163. setTimeout(function() {
  2164. fadeOut(e)
  2165. }, 2e3);
  2166. var n = library.getSprite("txt_18");
  2167. n.x = 120;
  2168. n.y = 170;
  2169. n.opacity = 0;
  2170. stage.addChild(n);
  2171. t = n.addTween("opacity", 1, 10, Easing.linear.out, null, null);
  2172. setTimeout(t.play, 3e3);
  2173. setTimeout(function() {
  2174. fadeOut(n)
  2175. }, 5e3);
  2176. t = library.getSprite("txt_16");
  2177. t.x = 95;
  2178. t.y = 175;
  2179. t.opacity = 0;
  2180. stage.addChild(t);
  2181. var r = t.addTween("opacity", 1, 10, Easing.linear.out, null, null);
  2182. setTimeout(r.play, 6e3);
  2183. tutArray.push(t);
  2184. t = library.getSprite("txt_12");
  2185. t.x = 215;
  2186. t.y = 280;
  2187. t.opacity = 0;
  2188. stage.addChild(t);
  2189. tutArray.push(t);
  2190. fillGameElementArray();
  2191. var i = t.addTween("opacity", 1, 10, Easing.linear.out, null, null);
  2192. setTimeout(function() {
  2193. i.play();
  2194. gameElementArray[18].addEventListener("mouseup", tutDone)
  2195. }, 8e3)
  2196. }
  2197. function tutDone() {
  2198. clearTutorialSprites();
  2199. tut01completed ? tut02completed ? tut04completed ? tut05completed ? tut06completed ? tut07completed ? tut08completed ? checkTurorial() : showTutorial_8() : checkTurorial() : checkTurorial() : (tut05completed = !0, showTutorial_5_1()) : (tut04completed = !0, checkTurorial()) : (tut02completed = !0, checkTurorial()) : (tut01completed = !0, checkTurorial())
  2200. }
  2201. function fillGameElementArray() {
  2202. gameElementArray = [];
  2203. for (var e = 0, t = stage.objects.length; e < t; e++) "gameCell" == stage.objects[e].type && gameElementArray.push(stage.objects[e])
  2204. }
  2205. function showTutorial_2() {
  2206. var e = library.getSprite("txt_2");
  2207. e.x = 160;
  2208. e.y = 200;
  2209. e.opacity = 0;
  2210. stage.addChild(e);
  2211. var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
  2212. setTimeout(t.play, 100);
  2213. tutArray.push(e);
  2214. e = library.getSprite("txt_11");
  2215. e.x = 160;
  2216. e.y = 280;
  2217. e.opacity = 0;
  2218. stage.addChild(e);
  2219. tutArray.push(e);
  2220. var n = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
  2221. setTimeout(function() {
  2222. n.play();
  2223. gameElementArray[17].addEventListener("mouseup", tutDone)
  2224. }, 3e3)
  2225. }
  2226. function showTutorial_3() {
  2227. var e = library.getSprite("txt_7");
  2228. e.x = 265;
  2229. e.y = 130;
  2230. e.opacity = 0;
  2231. stage.addChild(e);
  2232. var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
  2233. setTimeout(t.play, 100);
  2234. setTimeout(function() {
  2235. fadeOut(e)
  2236. }, 2500);
  2237. tut03completed = !0;
  2238. setTimeout(checkTurorial, 2500)
  2239. }
  2240. function showTutorial_4() {
  2241. var e = library.getSprite("txt_6");
  2242. e.x = 120;
  2243. e.y = 170;
  2244. e.opacity = 0;
  2245. stage.addChild(e);
  2246. var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
  2247. setTimeout(t.play, 100);
  2248. tutArray.push(e);
  2249. e = library.getSprite("txt_10");
  2250. e.x = 190;
  2251. e.y = 230;
  2252. e.opacity = 0;
  2253. stage.addChild(e);
  2254. var n = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
  2255. tutArray.push(e);
  2256. setTimeout(function() {
  2257. n.play();
  2258. gameElementArray[4].addEventListener("mouseup", tutDone)
  2259. }, 3e3)
  2260. }
  2261. function showTutorial_5() {
  2262. var e = library.getSprite("txt_20");
  2263. e.x = 180;
  2264. e.y = 200;
  2265. e.opacity = 0;
  2266. stage.addChild(e);
  2267. var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
  2268. setTimeout(t.play, 100);
  2269. tutArray.push(e)
  2270. }
  2271. function showTutorial_5_1() {
  2272. var e = library.getSprite("txt_13");
  2273. e.x = 160;
  2274. e.y = 195;
  2275. e.opacity = 0;
  2276. stage.addChild(e);
  2277. var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
  2278. tutArray.push(e);
  2279. setTimeout(function() {
  2280. t.play();
  2281. gameElementArray[7].addEventListener("mouseup", tutDone)
  2282. }, 100)
  2283. }
  2284. function showTutorial_6() {
  2285. var e = library.getSprite("txt_13");
  2286. e.x = 210;
  2287. e.y = 200;
  2288. e.opacity = 0;
  2289. stage.addChild(e);
  2290. var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
  2291. setTimeout(function() {
  2292. t.play();
  2293. gameElementArray[8].addEventListener("mouseup", tutDone)
  2294. }, 100);
  2295. tutArray.push(e)
  2296. }
  2297. function showTutorial_7() {
  2298. var e = library.getSprite("txt_14");
  2299. e.x = 170;
  2300. e.y = 180;
  2301. e.opacity = 0;
  2302. stage.addChild(e);
  2303. var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
  2304. setTimeout(t.play, 100);
  2305. tutArray.push(e)
  2306. }
  2307. function showTutorial_8() {
  2308. var e = library.getSprite("txt_13");
  2309. e.x = 160;
  2310. e.y = 250;
  2311. e.opacity = 0;
  2312. stage.addChild(e);
  2313. var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
  2314. tutArray.push(e);
  2315. setTimeout(function() {
  2316. t.play();
  2317. gameElementArray[12].addEventListener("mouseup", checkTurorial)
  2318. }, 100)
  2319. }
  2320. function checkTurorial() {
  2321. if ("easy" == currentDifficulty) {
  2322. if (!tut01completed) {
  2323. showTutorial_1();
  2324. return
  2325. }
  2326. if (!tut02completed) {
  2327. gameElementArray[18].removeEventListener("mouseup", tutDone);
  2328. blockForTutorial = !1;
  2329. gameElementArray[18].dispatchEvent("mouseup", {
  2330. target: gameElementArray[18]
  2331. });
  2332. blockForTutorial = !0;
  2333. showTutorial_2();
  2334. return
  2335. }
  2336. if (!tut03completed) {
  2337. gameElementArray[17].removeEventListener("mouseup", tutDone);
  2338. blockForTutorial = !1;
  2339. gameElementArray[17].dispatchEvent("mouseup", {
  2340. target: gameElementArray[17]
  2341. });
  2342. blockForTutorial = !0;
  2343. setTimeout(showTutorial_3, 2500);
  2344. return
  2345. }
  2346. if (!tut04completed) {
  2347. showTutorial_4();
  2348. return
  2349. }
  2350. if (!tut05completed) {
  2351. gameElementArray[4].removeEventListener("mouseup", tutDone);
  2352. blockForTutorial = !1;
  2353. gameElementArray[4].dispatchEvent("mouseup", {
  2354. target: gameElementArray[4]
  2355. });
  2356. blockForTutorial = !0;
  2357. showTutorial_5();
  2358. return
  2359. }
  2360. if (!tut06completed) {
  2361. gameElementArray[7].removeEventListener("mouseup", tutDone);
  2362. blockForTutorial = !1;
  2363. gameElementArray[7].dispatchEvent("mouseup", {
  2364. target: gameElementArray[7]
  2365. });
  2366. tut06completed = blockForTutorial = !0;
  2367. showTutorial_6();
  2368. return
  2369. }
  2370. if (!tut07completed) {
  2371. gameElementArray[8].removeEventListener("mouseup", tutDone);
  2372. blockForTutorial = !1;
  2373. gameElementArray[8].dispatchEvent("mouseup", {
  2374. target: gameElementArray[8]
  2375. });
  2376. tut07completed = blockForTutorial = !0;
  2377. showTutorial_7();
  2378. return
  2379. }
  2380. if (!tut08completed) {
  2381. clearTutorialSprites();
  2382. gameElementArray[12].removeEventListener("mouseup", checkTurorial);
  2383. blockForTutorial = !1;
  2384. gameElementArray[12].dispatchEvent("mouseup", {
  2385. target: gameElementArray[12]
  2386. });
  2387. tutorialActivated = !1;
  2388. tut08completed = !0;
  2389. levelTutorialCompleted();
  2390. return
  2391. }
  2392. }
  2393. if ("medium" != currentDifficulty || tut10completed) {
  2394. if ("hard" == currentDifficulty) {
  2395. if (!tut11completed) {
  2396. tut11completed = !0;
  2397. gameElementArray[18].removeEventListener("mouseup", tutDone);
  2398. blockForTutorial = !1;
  2399. gameElementArray[18].dispatchEvent("mouseup", {
  2400. target: gameElementArray[18]
  2401. });
  2402. blockForTutorial = !0;
  2403. showTutorial_12();
  2404. return
  2405. }
  2406. if (!tut12completed) {
  2407. gameElementArray[13].removeEventListener("mouseup", tutDone);
  2408. blockForTutorial = !1;
  2409. gameElementArray[13].dispatchEvent("mouseup", {
  2410. target: gameElementArray[13]
  2411. });
  2412. tut12completed = blockForTutorial = !0;
  2413. showTutorial_12_1();
  2414. return
  2415. }
  2416. if (!tut12_1completed) {
  2417. gameElementArray[18].removeEventListener("mouseup", tutDone);
  2418. blockForTutorial = !1;
  2419. gameElementArray[18].dispatchEvent("mouseup", {
  2420. target: gameElementArray[18]
  2421. });
  2422. tut12_1completed = blockForTutorial = !0;
  2423. showTutorial_13();
  2424. return
  2425. }
  2426. if (!tut13completed) {
  2427. gameElementArray[24].removeEventListener("mouseup", tutDone);
  2428. blockForTutorial = !1;
  2429. gameElementArray[24].dispatchEvent("mouseup", {
  2430. target: gameElementArray[24]
  2431. });
  2432. tutorialActivated = !1;
  2433. tut13completed = !0;
  2434. levelTutorialCompleted();
  2435. return
  2436. }
  2437. }
  2438. "ultimate" != currentDifficulty || tut15completed || (tutorialActivated = blockForTutorial = !1, tut15completed = !0, showTutorial_15(), levelTutorialCompleted())
  2439. } else gameElementArray[18].removeEventListener("mouseup", tutDone), blockForTutorial = !1, gameElementArray[18].dispatchEvent("mouseup", {
  2440. target: gameElementArray[18]
  2441. }), tutorialActivated = !1, tut10completed = !0, showTutorial_9(), levelTutorialCompleted()
  2442. }
  2443. function levelTutorialCompleted() {
  2444. Utils.setCookie(currentDifficulty + "_tutorial_completed", !0)
  2445. }
  2446. function resetTutorialVariables() {
  2447. tut01completed = tut02completed = tut03completed = tut04completed = tut05completed = tut06completed = tut07completed = tut08completed = tut09completed = tut10completed = tut11completed = tut12completed = tut12_1completed = tut13completed = tut14completed = tut15completed = blockForTutorial = !1
  2448. }
  2449. function checkDifficulty() {
  2450. resetTutorialVariables();
  2451. "easy" == currentDifficulty && void 0 == Utils.getCookie(currentDifficulty + "_tutorial_completed") ? blockForTutorial = tutorialActivated = !0 : "medium" == currentDifficulty && void 0 == Utils.getCookie(currentDifficulty + "_tutorial_completed") ? tut01completed = tut02completed = tut03completed = tut04completed = tut05completed = tut06completed = tut07completed = tut08completed = blockForTutorial = tutorialActivated = !0 : "hard" == currentDifficulty && void 0 == Utils.getCookie(currentDifficulty + "_tutorial_completed") ? tut01completed = tut02completed = tut03completed = tut04completed = tut05completed = tut06completed = tut07completed = tut08completed = tut09completed = tut10completed = blockForTutorial = tutorialActivated = !0 : ("expert" == currentDifficulty && void 0 == Utils.getCookie(currentDifficulty + "_tutorial_completed") && (tut01completed = tut02completed = tut03completed = tut04completed = tut05completed = tut06completed = tut07completed = tut08completed = tut09completed = tut10completed = tut11completed = tut12completed = tut12_1completed = tut13completed = !0), "ultimate" == currentDifficulty && void 0 == Utils.getCookie(currentDifficulty + "_tutorial_completed") ? (tut01completed = tut02completed = tut03completed = tut04completed = tut05completed = tut06completed = tut07completed = tut08completed = tut09completed = tut10completed = tut11completed = tut12completed = tut12_1completed = tut13completed = tutorialActivated = !0, coins++) : tutorialActivated = !1)
  2452. }
  2453. function showTutorial_10() {
  2454. var e = library.getSprite("txt_5");
  2455. e.x = 95;
  2456. e.y = 192;
  2457. e.opacity = 0;
  2458. stage.addChild(e);
  2459. var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
  2460. setTimeout(t.play, 100);
  2461. tutArray.push(e);
  2462. e = library.getSprite("txt_13");
  2463. e.x = 210;
  2464. e.y = 295;
  2465. e.opacity = 0;
  2466. stage.addChild(e);
  2467. fillGameElementArray();
  2468. var n = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
  2469. setTimeout(function() {
  2470. n.play();
  2471. gameElementArray[18].addEventListener("mouseup", tutDone)
  2472. }, 3e3);
  2473. tutArray.push(e)
  2474. }
  2475. function showTutorial_9() {
  2476. var e = library.getSprite("txt_3");
  2477. e.x = 160;
  2478. e.y = 220;
  2479. e.opacity = 0;
  2480. stage.addChild(e);
  2481. var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
  2482. setTimeout(t.play, 100);
  2483. setTimeout(function() {
  2484. fadeOut(e)
  2485. }, 5e3)
  2486. }
  2487. function showTutorial_11() {
  2488. var e = library.getSprite("txt_4");
  2489. e.x = 120;
  2490. e.y = 178;
  2491. e.opacity = 0;
  2492. stage.addChild(e);
  2493. var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
  2494. setTimeout(t.play, 100);
  2495. tutArray.push(e);
  2496. e = library.getSprite("txt_13");
  2497. e.x = 210;
  2498. e.y = 295;
  2499. e.opacity = 0;
  2500. stage.addChild(e);
  2501. fillGameElementArray();
  2502. var n = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
  2503. setTimeout(function() {
  2504. n.play();
  2505. gameElementArray[18].addEventListener("mouseup", tutDone)
  2506. }, 3e3);
  2507. tutArray.push(e)
  2508. }
  2509. function showTutorial_12() {
  2510. var e = library.getSprite("txt_8");
  2511. e.x = 105;
  2512. e.y = 320;
  2513. e.opacity = 0;
  2514. stage.addChild(e);
  2515. var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
  2516. setTimeout(t.play, 100);
  2517. tutArray.push(e);
  2518. e = library.getSprite("txt_13");
  2519. e.x = 210;
  2520. e.y = 250;
  2521. e.opacity = 0;
  2522. stage.addChild(e);
  2523. var n = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
  2524. setTimeout(function() {
  2525. n.play();
  2526. gameElementArray[13].addEventListener("mouseup", tutDone)
  2527. }, 3e3);
  2528. tutArray.push(e)
  2529. }
  2530. function showTutorial_12_1() {
  2531. var e = library.getSprite("txt_13");
  2532. e.x = 210;
  2533. e.y = 300;
  2534. e.opacity = 0;
  2535. stage.addChild(e);
  2536. var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
  2537. setTimeout(function() {
  2538. t.play();
  2539. gameElementArray[18].addEventListener("mouseup", tutDone)
  2540. }, 1e3);
  2541. tutArray.push(e)
  2542. }
  2543. function showTutorial_13() {
  2544. var e = library.getSprite("txt_1");
  2545. e.x = 155;
  2546. e.y = 192;
  2547. e.opacity = 0;
  2548. stage.addChild(e);
  2549. var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
  2550. setTimeout(t.play, 100);
  2551. tutArray.push(e);
  2552. e = library.getSprite("txt_9");
  2553. e.x = 195;
  2554. e.y = 330;
  2555. e.opacity = 0;
  2556. stage.addChild(e);
  2557. var n = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
  2558. setTimeout(function() {
  2559. n.play();
  2560. gameElementArray[24].addEventListener("mouseup", tutDone)
  2561. }, 3e3);
  2562. tutArray.push(e)
  2563. }
  2564. function showTutorial_14() {
  2565. blockForTutorial = !0;
  2566. var e = library.getSprite("txt_19");
  2567. e.x = 165;
  2568. e.y = 175;
  2569. e.opacity = 0;
  2570. stage.addChild(e);
  2571. var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
  2572. setTimeout(t.play, 1e3);
  2573. tutArray.push(e);
  2574. tut14completed = !0
  2575. }
  2576. function showTutorial_15() {
  2577. var e = library.getSprite("txt_9");
  2578. e.x = 130;
  2579. e.y = 150;
  2580. e.opacity = 0;
  2581. stage.addChild(e);
  2582. var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
  2583. setTimeout(t.play, 1e3);
  2584. setTimeout(clearTutorialSprites, 3e3);
  2585. tutArray.push(e)
  2586. }
  2587. function showMissionInfo() {
  2588. stage.stop();
  2589. var e = new Sprite(null, 320, 480);
  2590. e.x = 160;
  2591. e.y = 240;
  2592. e.isMissionElement = !0;
  2593. e.onmouseup = function() {
  2594. gameState = STATE_GAME;
  2595. createScene();
  2596. return !1
  2597. };
  2598. stage.addChild(e);
  2599. stage.addChild(library.getSprite("mission_bg", {
  2600. x: 160,
  2601. y: 240,
  2602. isMissionElement: !0
  2603. }));
  2604. stage.addChild(library.getSprite("unicellar", {
  2605. x: 55,
  2606. y: 240,
  2607. isMissionElement: !0,
  2608. first: !0
  2609. }));
  2610. stage.addChild(library.getSprite("meduze", {
  2611. x: 120,
  2612. y: 240,
  2613. isMissionElement: !0
  2614. }));
  2615. stage.addChild(library.getSprite("fish", {
  2616. x: 185,
  2617. y: 240,
  2618. isMissionElement: !0
  2619. }));
  2620. stage.addChild(library.getSprite("arrow", {
  2621. x: 87,
  2622. y: 240,
  2623. isMissionElement: !0
  2624. }));
  2625. stage.addChild(library.getSprite("arrow", {
  2626. x: 152,
  2627. y: 240,
  2628. isMissionElement: !0
  2629. }));
  2630. stage.addChild(library.getSprite("arrow", {
  2631. x: 217,
  2632. y: 240,
  2633. isMissionElement: !0
  2634. }));
  2635. stage.addChild(library.getSprite("arrow", {
  2636. x: 282,
  2637. y: 240,
  2638. isMissionElement: !0
  2639. }));
  2640. stage.addChild(library.getSprite("arrow", {
  2641. x: 37,
  2642. y: 295,
  2643. isMissionElement: !0
  2644. }));
  2645. stage.addChild(library.getSprite("arrow", {
  2646. x: 102,
  2647. y: 295,
  2648. isMissionElement: !0
  2649. }));
  2650. stage.addChild(library.getSprite("arrow", {
  2651. x: 167,
  2652. y: 295,
  2653. isMissionElement: !0
  2654. }));
  2655. stage.addChild(library.getSprite("arrow", {
  2656. x: 232,
  2657. y: 295,
  2658. isMissionElement: !0
  2659. }));
  2660. "easy" == currentDifficulty ? (stage.addChild(library.getSprite("mission_untitled_b", {
  2661. x: 250,
  2662. y: 240,
  2663. isMissionElement: !0
  2664. })), stage.addChild(library.getSprite("mission_untitled_a", {
  2665. x: 70,
  2666. y: 295,
  2667. isMissionElement: !0
  2668. })), stage.addChild(library.getSprite("mission_untitled_a", {
  2669. x: 135,
  2670. y: 295,
  2671. isMissionElement: !0
  2672. })), stage.addChild(library.getSprite("mission_untitled_a", {
  2673. x: 200,
  2674. y: 295,
  2675. isMissionElement: !0
  2676. })), stage.addChild(library.getSprite("mission_create_1", {
  2677. x: 160,
  2678. y: 335,
  2679. isMissionElement: !0
  2680. })), stage.addChild(library.getSprite("mission_untitled_a", {
  2681. x: 265,
  2682. y: 295,
  2683. isMissionElement: !0
  2684. }))) : "medium" == currentDifficulty ? (stage.addChild(library.getSprite("pangolin", {
  2685. x: 250,
  2686. y: 240,
  2687. isMissionElement: !0
  2688. })), stage.addChild(library.getSprite("mission_untitled_b", {
  2689. x: 70,
  2690. y: 295,
  2691. isMissionElement: !0
  2692. })), stage.addChild(library.getSprite("mission_untitled_a", {
  2693. x: 135,
  2694. y: 295,
  2695. isMissionElement: !0
  2696. })), stage.addChild(library.getSprite("mission_untitled_a", {
  2697. x: 200,
  2698. y: 295,
  2699. isMissionElement: !0
  2700. })), stage.addChild(library.getSprite("mission_create_2", {
  2701. x: 160,
  2702. y: 335,
  2703. isMissionElement: !0
  2704. })), stage.addChild(library.getSprite("mission_untitled_a", {
  2705. x: 265,
  2706. y: 295,
  2707. isMissionElement: !0
  2708. }))) : "hard" == currentDifficulty ? (stage.addChild(library.getSprite("pangolin", {
  2709. x: 250,
  2710. y: 240,
  2711. isMissionElement: !0
  2712. })), stage.addChild(library.getSprite("mammal", {
  2713. x: 70,
  2714. y: 295,
  2715. isMissionElement: !0
  2716. })), stage.addChild(library.getSprite("mission_untitled_b", {
  2717. x: 135,
  2718. y: 295,
  2719. isMissionElement: !0
  2720. })), stage.addChild(library.getSprite("mission_untitled_a", {
  2721. x: 200,
  2722. y: 295,
  2723. isMissionElement: !0
  2724. })), stage.addChild(library.getSprite("mission_create_3", {
  2725. x: 160,
  2726. y: 335,
  2727. isMissionElement: !0
  2728. })), stage.addChild(library.getSprite("mission_untitled_a", {
  2729. x: 265,
  2730. y: 295,
  2731. isMissionElement: !0
  2732. }))) : "expert" == currentDifficulty ? (stage.addChild(library.getSprite("pangolin", {
  2733. x: 250,
  2734. y: 240,
  2735. isMissionElement: !0
  2736. })), stage.addChild(library.getSprite("mammal", {
  2737. x: 70,
  2738. y: 295,
  2739. isMissionElement: !0
  2740. })), stage.addChild(library.getSprite("people", {
  2741. x: 135,
  2742. y: 295,
  2743. isMissionElement: !0
  2744. })), stage.addChild(library.getSprite("mission_untitled_b", {
  2745. x: 200,
  2746. y: 295,
  2747. isMissionElement: !0
  2748. })), stage.addChild(library.getSprite("mission_create_4", {
  2749. x: 160,
  2750. y: 335,
  2751. isMissionElement: !0
  2752. })), stage.addChild(library.getSprite("mission_untitled_a", {
  2753. x: 265,
  2754. y: 295,
  2755. isMissionElement: !0
  2756. }))) : "ultimate" == currentDifficulty && (stage.addChild(library.getSprite("pangolin", {
  2757. x: 250,
  2758. y: 240,
  2759. isMissionElement: !0
  2760. })), stage.addChild(library.getSprite("mammal", {
  2761. x: 70,
  2762. y: 295,
  2763. isMissionElement: !0
  2764. })), stage.addChild(library.getSprite("people", {
  2765. x: 135,
  2766. y: 295,
  2767. isMissionElement: !0
  2768. })), stage.addChild(library.getSprite("uslon", {
  2769. x: 200,
  2770. y: 295,
  2771. isMissionElement: !0
  2772. })), stage.addChild(library.getSprite("mission_create_5", {
  2773. x: 160,
  2774. y: 335,
  2775. isMissionElement: !0
  2776. })), stage.addChild(library.getSprite("mission_untitled_b", {
  2777. x: 265,
  2778. y: 295,
  2779. isMissionElement: !0
  2780. })))
  2781. }
  2782. function checkIfNeedLaunchTutorial(e, t) {
  2783. if ("easy" == currentDifficulty && tutorialActivated || "medium" == currentDifficulty && tutorialActivated || "hard" == currentDifficulty && tutorialActivated) return showTutorial(e, t), !0;
  2784. if ("ultimate" == currentDifficulty && tutorialActivated) return showTutorial(e, t), !1
  2785. }
  2786. var CRENDER_DEBUG = !1;
  2787. var Utils = {
  2788. touchScreen: "ontouchstart" in window,
  2789. globalScale: 1,
  2790. setCookie: function(e, t) {
  2791. try {
  2792. window.localStorage.setItem(e, t)
  2793. } catch (n) {
  2794. var r = new Date;
  2795. r.setDate(r.getDate() + 3650);
  2796. document.cookie = e + "=" + t + "; expires=" + r.toUTCString()
  2797. }
  2798. },
  2799. getCookie: function(e) {
  2800. var t;
  2801. try {
  2802. t = window.localStorage.getItem(e)
  2803. } catch (n) {
  2804. e += "=";
  2805. t = document.cookie.indexOf(e);
  2806. if (-1 == t) return null;
  2807. var r = document.cookie.indexOf(";", t + e.length); - 1 == r && (r = document.cookie.length);
  2808. t = unescape(document.cookie.substring(t + e.length, r))
  2809. }
  2810. return t
  2811. },
  2812. bindEvent: function(e, t, n) {
  2813. e.addEventListener ? e.addEventListener(t, n, !1) : e.attachEvent && e.attachEvent("on" + t, n)
  2814. },
  2815. getObjectLeft: function(e) {
  2816. var t = e.offsetLeft;
  2817. e.offsetParent && (t += Utils.getObjectLeft(e.offsetParent));
  2818. return t
  2819. },
  2820. getObjectTop: function(e) {
  2821. var t = e.offsetTop;
  2822. e.offsetParent && (t += Utils.getObjectTop(e.offsetParent));
  2823. return t
  2824. },
  2825. parseGet: function() {
  2826. var e = {},
  2827. t = new String(window.location),
  2828. n = t.indexOf("?");
  2829. if (-1 != n)
  2830. for (var t = t.substr(n + 1, t.length), n = t.split("&"), r = 0; r < n.length; r++) t = n[r].split("="), e[t[0]] = t[1];
  2831. return e
  2832. },
  2833. globalPixelScale: 1,
  2834. getMouseCoord: function(e, t) {
  2835. var n = e || window.event;
  2836. n.touches && (n = n.touches[0]);
  2837. if (!n) return {
  2838. x: 0,
  2839. y: 0
  2840. };
  2841. var r = 0,
  2842. i = 0,
  2843. s = 0,
  2844. o = 0;
  2845. t && (r = Utils.getObjectLeft(t), i = Utils.getObjectTop(t));
  2846. if (n.pageX || n.pageY) s = n.pageX, o = n.pageY;
  2847. else if (n.clientX || n.clientY) s = n.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft, o = n.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
  2848. return {
  2849. x: s - r,
  2850. y: o - i
  2851. }
  2852. },
  2853. extend: function(e, t) {
  2854. var n = function() {};
  2855. n.prototype = t.prototype;
  2856. e.prototype = new n;
  2857. e.prototype.constructor = e;
  2858. e.superclass = t.prototype
  2859. },
  2860. removeFromArray: function(e, t) {
  2861. for (var n = [], r = 0; r < e.length; r++) e[r] != t && n.push(e[r]);
  2862. return n
  2863. },
  2864. showLoadProgress: function(e) {
  2865. var t = Utils.globalScale,
  2866. n;
  2867. n = "Loading: " + e + "%<br><br>";
  2868. n += '<div style="display: block; background: #000; width: ' + e * t * 2 + "px; height: " + 10 * t + 'px;">&nbsp;</div>';
  2869. document.getElementById("progress").innerHTML = n
  2870. },
  2871. hideAddressBarLock: !1,
  2872. mobileHideAddressBar: function() {
  2873. Utils.hideAddressBarLock || window.scrollTo(0, 1)
  2874. },
  2875. mobileCheckIphone4: function() {
  2876. return window.devicePixelRatio && -1 != navigator.userAgent.indexOf("iPhone") && 2 == window.devicePixelRatio ? !0 : !1
  2877. },
  2878. mobileCheckBrokenGalaxyPhones: function() {
  2879. return !window.devicePixelRatio || -1 == navigator.userAgent.indexOf("GT-I9300") && -1 == navigator.userAgent.indexOf("GT-I8190") && -1 == navigator.userAgent.indexOf("Android 4.") ? !1 : !0
  2880. },
  2881. checkSpilgamesEnvironment: function() {
  2882. return "undefined" != typeof ExternalAPI && "Spilgames" == ExternalAPI.type && ExternalAPI.check()
  2883. },
  2884. mobileCorrectPixelRatio: function() {
  2885. var e = document.createElement("meta");
  2886. e.name = "viewport";
  2887. var t = "target-densitydpi=device-dpi, user-scalable=0",
  2888. t = Utils.checkSpilgamesEnvironment() ? 1 < window.devicePixelRatio ? t + ", initial-scale=0.5, maximum-scale=0.5, minimum-scale=0.5" : t + ", initial-scale=1, maximum-scale=1, minimum-scale=1" : Utils.mobileCheckIphone4() ? t + ", initial-scale=0.5, maximum-scale=0.5, minimum-scale=0.5" : t + ", initial-scale=1, maximum-scale=1, minimum-scale=1";
  2889. e.content = t;
  2890. document.getElementsByTagName("head")[0].appendChild(e)
  2891. },
  2892. getMobileScreenResolution: function(e) {
  2893. var t = 1,
  2894. n = [{
  2895. scale: 1,
  2896. width: 320,
  2897. height: 480
  2898. }, {
  2899. scale: 1.5,
  2900. width: 480,
  2901. height: 720
  2902. }, {
  2903. scale: 2,
  2904. width: 640,
  2905. height: 960
  2906. }],
  2907. r = {
  2908. width: 0,
  2909. height: 0
  2910. },
  2911. i = "";
  2912. Utils.touchScreen ? (r.width = Math.min(window.innerWidth, window.innerHeight), r.height = Math.max(window.innerWidth, window.innerHeight)) : (r.width = window.innerWidth, r.height = window.innerHeight);
  2913. for (var i = "height", s = Number.MAX_VALUE, o = 0; o < n.length; o++) {
  2914. var u = Math.abs(r[i] - n[o][i]);
  2915. s > u && (s = u, t = n[o].scale)
  2916. }
  2917. return Utils.getScaleScreenResolution(t, e)
  2918. },
  2919. getScaleScreenResolution: function(e, t) {
  2920. var n, r;
  2921. n = Math.round(320 * e);
  2922. r = Math.round(480 * e);
  2923. if (t) {
  2924. var i = n;
  2925. n = r;
  2926. r = i
  2927. }
  2928. return {
  2929. width: n,
  2930. height: r,
  2931. scale: e
  2932. }
  2933. },
  2934. imagesRoot: "images",
  2935. initialResolution: {
  2936. width: 320,
  2937. height: 480,
  2938. scale: 1
  2939. },
  2940. createLayout: function(e, t, n, r) {
  2941. var i = Utils.globalScale;
  2942. Utils.initialResolution = t;
  2943. n = window.innerHeight;
  2944. "orientation" in window ? n = 2048 : document.body.style.overflow = "hidden";
  2945. i = "" + ('<div id="progress_container" align="center" style="width: 100%; height: ' + n + 'px; display: block; width: 100%; position: absolute; left: 0px; top: 0px;">') + ('<table cellspacing="0" cellpadding="0"><tr><td id="progress" align="center" valign="middle" style="width: ' + t.width + "px; height: " + t.height + "px; color: #000; background: #fff; font-weight: bold; font-family: Verdana; font-size: " + 12 * i + 'px; vertical-align: middle;"></td></tr></table>');
  2946. i += "</div>";
  2947. i += '<div id="screen_background_container" align="center" style="width: 100%; height: ' + n + 'px; position: absolute; left: 0px; top: 0px; display: none; z-index: 2;">';
  2948. i += '<div id="screen_background_wrapper" style="width: ' + t.width + "px; height: " + t.height + 'px; overflow: hidden; position: relative;">';
  2949. r || (i += '<canvas id="screen_background" width="' + t.width + '" height="' + t.height + '"></canvas>');
  2950. i += "</div>";
  2951. i += "</div>";
  2952. i += '<div id="screen_container" align="center" style="width: 100%; height: ' + n + 'px; position: absolute; left: 0px; top: 0px; display: none; z-index: 3;">';
  2953. i += '<div id="screen_wrapper" width="' + t.width + '" height="' + t.height + '" style="width: ' + t.width + "px; height: " + t.height + 'px; overflow: hidden; position: relative;">';
  2954. r || (i += '<canvas id="screen" style="position: absolute; left: 0px; top: 0px; z-index: 100;" width="' + t.width + '" height="' + t.height + '">You browser does not support this application :(</canvas>');
  2955. i += "</div>";
  2956. i += "</div>";
  2957. e.innerHTML = i;
  2958. e = document.createElement("div");
  2959. e.setAttribute("id", "p2l_container");
  2960. e.setAttribute("align", "center");
  2961. t = t.width;
  2962. e.setAttribute("style", "width: 100%; height: " + n + "px; position: absolute; left: 0px; top: 0px; display: none; z-index: 10; background: #fff;");
  2963. e.innerHTML = '<img id="p2l" src="' + Utils.imagesRoot + '/p2l.jpg" style="padding-top: ' + (t - 240) / 2 + 'px" />';
  2964. document.body.appendChild(e)
  2965. },
  2966. preventEvent: function(e) {
  2967. e.preventDefault();
  2968. e.stopPropagation();
  2969. e.cancelBubble = !0;
  2970. return e.returnValue = !1
  2971. },
  2972. addMobileListeners: function(e, t) {
  2973. !t && navigator.userAgent.match(/(iPad|iPhone|iPod).*CPU.*OS 7_\d/i) || Utils.bindEvent(document.getElementById("main_container"), "touchstart", Utils.preventEvent);
  2974. Utils.bindEvent(window, "scroll", function(e) {
  2975. setTimeout(Utils.mobileHideAddressBar, 300)
  2976. });
  2977. setInterval("Utils.checkOrientation(" + (e ? "true" : "false") + ")", 500);
  2978. setTimeout(Utils.mobileHideAddressBar, 500)
  2979. },
  2980. storeOrient: null,
  2981. noCheckOrient: !1,
  2982. checkOrientation: function(e) {
  2983. if (Utils.touchScreen && document.getElementById("screen_container")) {
  2984. var t = Utils.parseGet();
  2985. if (!Utils.noCheckOrient && 1 != t.nocheckorient) {
  2986. t = !1;
  2987. if (window == window.parent) t = window.innerWidth > window.innerHeight;
  2988. else var n = Math.max(screen.width, screen.height),
  2989. t = Math.min(screen.width, screen.height),
  2990. n = Math.abs(window.innerWidth - n),
  2991. t = Math.abs(window.innerWidth - t),
  2992. t = n < t;
  2993. Utils.storeOrient !== t && (Utils.storeOrient = t, t != e ? (Utils.dispatchEvent("lockscreen"), document.getElementById("p2l_container").style.display = "block", document.getElementById("screen_background_container").style.display = "none", document.getElementById("screen_container").style.display = "none") : (Utils.dispatchEvent("unlockscreen"), document.getElementById("p2l_container").style.display = "none", document.getElementById("screen_background_container").style.display = "block", document.getElementById("screen_container").style.display = "block"), Utils.checkSpilgamesEnvironment() && (document.getElementById("p2l_container").style.display = "none"), setTimeout(Utils.mobileHideAddressBar, 1e3), setTimeout(Utils.fitLayoutToScreen, 1e3))
  2994. }
  2995. }
  2996. },
  2997. fitLayoutTimer: null,
  2998. addFitLayoutListeners: function() {
  2999. Utils.fitLayoutTimer = setInterval(Utils.fitLayoutToScreen, 500)
  3000. },
  3001. removeFitLayoutListeners: function() {
  3002. clearInterval(Utils.fitLayoutTimer)
  3003. },
  3004. fitLayoutLock: !1,
  3005. fitLayoutCorrectHeight: 0,
  3006. fitLayoutToScreen: function(e) {
  3007. if (!Utils.fitLayoutLock) {
  3008. var t, n, r;
  3009. "object" == typeof e && e.width || (n = window.innerWidth, r = window.innerHeight, Utils.checkSpilgamesEnvironment() && (r -= 25), r += Utils.fitLayoutCorrectHeight, e = {
  3010. width: n,
  3011. height: r
  3012. });
  3013. if (t = document.getElementById("screen_wrapper")) {
  3014. t.initWidth || (t.initWidth = Utils.initialResolution.width, t.initHeight = Utils.initialResolution.height);
  3015. n = t.initWidth;
  3016. r = t.initHeight;
  3017. var i = 1,
  3018. i = e.width / n;
  3019. e = e.height / r;
  3020. i = i < e ? i : e;
  3021. Utils.globalPixelScale = i;
  3022. n = Math.floor(n * i);
  3023. r = Math.floor(r * i);
  3024. if (t.lastWidth != n || t.lastHeight != r) {
  3025. t.lastWidth = n;
  3026. t.lastHeight = r;
  3027. Utils.resizeElement("screen", n, r);
  3028. Utils.resizeElement("screen_background", n, r);
  3029. if (t = document.getElementById("progress")) t.style.width = ~~n + "px", t.style.height = ~~r + "px";
  3030. if (t = document.getElementById("screen_wrapper")) t.style.width = ~~n + "px", t.style.height = ~~r + "px";
  3031. if (t = document.getElementById("screen_background_wrapper")) t.style.width = ~~n + "px", t.style.height = ~~r + "px";
  3032. if (t = document.getElementById("p2l_container")) t.style.width = ~~window.innerWidth + "px", t.style.height = "2048px";
  3033. Utils.dispatchEvent("fitlayout");
  3034. setTimeout(Utils.mobileHideAddressBar, 50)
  3035. }
  3036. }
  3037. }
  3038. },
  3039. resizeElement: function(e, t, n) {
  3040. if (e = document.getElementById(e)) e.setAttribute("width", t), e.setAttribute("height", n)
  3041. },
  3042. drawIphoneLimiter: function(e, t) {
  3043. t ? e.drawRectangle(240, 295, 480, 54, "#f00", !0, .5, !0) : e.drawRectangle(160, 448, 320, 64, "#f00", !0, .5, !0)
  3044. },
  3045. drawGrid: function(e, t, n) {
  3046. "undefined" == typeof t && (t = !1);
  3047. "undefined" == typeof n && (n = "#FFF");
  3048. var r = 1 / Utils.globalScale / Utils.globalPixelScale,
  3049. i = t ? 480 : 320;
  3050. t = t ? 320 : 480;
  3051. for (var s = 10; s < i; s += 10) {
  3052. var o = .1 + (s - 10) / 10 % 10 * .1;
  3053. e.drawLine(s, 0, s, t, r, n, o)
  3054. }
  3055. for (s = 10; s < t; s += 10) o = .1 + (s - 10) / 10 % 10 * .1, e.drawLine(0, s, i, s, r, n, o)
  3056. },
  3057. drawScaleFix: function(e, t) {.75 == Utils.globalScale && (t ? e.drawRectangle(507, 160, 54, 320, "#000", !0, 1, !0) : e.drawRectangle(160, 507, 320, 54, "#000", !0, 1, !0));
  3058. 1.5 == Utils.globalScale && (t ? e.drawRectangle(510, 160, 60, 320, "#000", !0, 1, !0) : e.drawRectangle(160, 510, 320, 60, "#000", !0, 1, !0))
  3059. },
  3060. grad2radian: function(e) {
  3061. return e / (180 / Math.PI)
  3062. },
  3063. radian2grad: function(e) {
  3064. return 180 / Math.PI * e
  3065. },
  3066. eventsListeners: [],
  3067. onlockscreen: null,
  3068. onunlockscreen: null,
  3069. onfitlayout: null,
  3070. addEventListener: function(e, t) {
  3071. EventsManager.addEvent(Utils, e, t)
  3072. },
  3073. removeEventListener: function(e, t) {
  3074. EventsManager.removeEvent(Utils, e, t)
  3075. },
  3076. dispatchEvent: function(e, t) {
  3077. return EventsManager.dispatchEvent(Utils, e, t)
  3078. }
  3079. },
  3080. EventsManager = {
  3081. addEvent: function(e, t, n) {
  3082. if (e.eventsListeners) {
  3083. for (var r = 0; r < e.eventsListeners.length; r++)
  3084. if (e.eventsListeners[r].type === t && e.eventsListeners[r].callback === n) return;
  3085. e.eventsListeners.push({
  3086. type: t,
  3087. callback: n
  3088. })
  3089. }
  3090. },
  3091. removeEvent: function(e, t, n) {
  3092. if (e.eventsListeners)
  3093. for (var r = 0; r < e.eventsListeners.length; r++)
  3094. if (e.eventsListeners[r].type === t && e.eventsListeners[r].callback === n) {
  3095. e.eventsListeners = Utils.removeFromArray(e.eventsListeners, e.eventsListeners[r]);
  3096. break
  3097. }
  3098. },
  3099. dispatchEvent: function(e, t, n) {
  3100. if (e.eventsListeners) {
  3101. var r;
  3102. if ("function" == typeof e["on" + t] && (r = e["on" + t](n), !1 === r)) return !1;
  3103. for (var i = 0; i < e.eventsListeners.length; i++)
  3104. if (e.eventsListeners[i].type === t && (r = e.eventsListeners[i].callback(n), !1 === r)) return !1
  3105. }
  3106. }
  3107. },
  3108. ANCHOR_ALIGN_LEFT = -1,
  3109. ANCHOR_ALIGN_CENTER = 0,
  3110. ANCHOR_ALIGN_RIGHT = 1,
  3111. ANCHOR_VALIGN_TOP = -1,
  3112. ANCHOR_VALIGN_MIDDLE = 0,
  3113. ANCHOR_VALIGN_BOTTOM = 1;
  3114. var Easing = {
  3115. back: {
  3116. easeIn: function(e, t, n, r) {
  3117. return n * (e /= r) * e * (2.70158 * e - 1.70158) + t
  3118. },
  3119. easeOut: function(e, t, n, r) {
  3120. return n * ((e = e / r - 1) * e * (2.70158 * e + 1.70158) + 1) + t
  3121. },
  3122. easeInOut: function(e, t, n, r) {
  3123. var i = 1.70158;
  3124. return 1 > (e /= r / 2) ? n / 2 * e * e * (((i *= 1.525) + 1) * e - i) + t : n / 2 * ((e -= 2) * e * (((i *= 1.525) + 1) * e + i) + 2) + t
  3125. }
  3126. },
  3127. bounce: {
  3128. easeIn: function(e, t, n, r) {
  3129. return n - Easing.bounce.easeOut(r - e, 0, n, r) + t
  3130. },
  3131. easeOut: function(e, t, n, r) {
  3132. return (e /= r) < 1 / 2.75 ? 7.5625 * n * e * e + t : e < 2 / 2.75 ? n * (7.5625 * (e -= 1.5 / 2.75) * e + .75) + t : e < 2.5 / 2.75 ? n * (7.5625 * (e -= 2.25 / 2.75) * e + .9375) + t : n * (7.5625 * (e -= 2.625 / 2.75) * e + .984375) + t
  3133. },
  3134. easeInOut: function(e, t, n, r) {
  3135. return e < r / 2 ? .5 * Easing.bounce.easeIn(2 * e, 0, n, r) + t : .5 * Easing.bounce.easeOut(2 * e - r, 0, n, r) + .5 * n + t
  3136. }
  3137. },
  3138. circular: {
  3139. easeIn: function(e, t, n, r) {
  3140. return -n * (Math.sqrt(1 - (e /= r) * e) - 1) + t
  3141. },
  3142. easeOut: function(e, t, n, r) {
  3143. return n * Math.sqrt(1 - (e = e / r - 1) * e) + t
  3144. },
  3145. easeInOut: function(e, t, n, r) {
  3146. return 1 > (e /= r / 2) ? -n / 2 * (Math.sqrt(1 - e * e) - 1) + t : n / 2 * (Math.sqrt(1 - (e -= 2) * e) + 1) + t
  3147. }
  3148. },
  3149. cubic: {
  3150. easeIn: function(e, t, n, r) {
  3151. return n * (e /= r) * e * e + t
  3152. },
  3153. easeOut: function(e, t, n, r) {
  3154. return n * ((e = e / r - 1) * e * e + 1) + t
  3155. },
  3156. easeInOut: function(e, t, n, r) {
  3157. return 1 > (e /= r / 2) ? n / 2 * e * e * e + t : n / 2 * ((e -= 2) * e * e + 2) + t
  3158. }
  3159. },
  3160. exponential: {
  3161. easeIn: function(e, t, n, r) {
  3162. return 0 == e ? t : n * Math.pow(2, 10 * (e / r - 1)) + t
  3163. },
  3164. easeOut: function(e, t, n, r) {
  3165. return e == r ? t + n : n * (-Math.pow(2, -10 * e / r) + 1) + t
  3166. },
  3167. easeInOut: function(e, t, n, r) {
  3168. return 0 == e ? t : e == r ? t + n : 1 > (e /= r / 2) ? n / 2 * Math.pow(2, 10 * (e - 1)) + t : n / 2 * (-Math.pow(2, -10 * --e) + 2) + t
  3169. }
  3170. },
  3171. linear: {
  3172. easeIn: function(e, t, n, r) {
  3173. return n * e / r + t
  3174. },
  3175. easeOut: function(e, t, n, r) {
  3176. return n * e / r + t
  3177. },
  3178. easeInOut: function(e, t, n, r) {
  3179. return n * e / r + t
  3180. }
  3181. },
  3182. quadratic: {
  3183. easeIn: function(e, t, n, r) {
  3184. return n * (e /= r) * e + t
  3185. },
  3186. easeOut: function(e, t, n, r) {
  3187. return -n * (e /= r) * (e - 2) + t
  3188. },
  3189. easeInOut: function(e, t, n, r) {
  3190. return 1 > (e /= r / 2) ? n / 2 * e * e + t : -n / 2 * (--e * (e - 2) - 1) + t
  3191. }
  3192. },
  3193. quartic: {
  3194. easeIn: function(e, t, n, r) {
  3195. return n * (e /= r) * e * e * e + t
  3196. },
  3197. easeOut: function(e, t, n, r) {
  3198. return -n * ((e = e / r - 1) * e * e * e - 1) + t
  3199. },
  3200. easeInOut: function(e, t, n, r) {
  3201. return 1 > (e /= r / 2) ? n / 2 * e * e * e * e + t : -n / 2 * ((e -= 2) * e * e * e - 2) + t
  3202. }
  3203. },
  3204. quintic: {
  3205. easeIn: function(e, t, n, r) {
  3206. return n * (e /= r) * e * e * e * e + t
  3207. },
  3208. easeOut: function(e, t, n, r) {
  3209. return n * ((e = e / r - 1) * e * e * e * e + 1) + t
  3210. },
  3211. easeInOut: function(e, t, n, r) {
  3212. return 1 > (e /= r / 2) ? n / 2 * e * e * e * e * e + t : n / 2 * ((e -= 2) * e * e * e * e + 2) + t
  3213. }
  3214. },
  3215. sine: {
  3216. easeIn: function(e, t, n, r) {
  3217. return -n * Math.cos(e / r * (Math.PI / 2)) + n + t
  3218. },
  3219. easeOut: function(e, t, n, r) {
  3220. return n * Math.sin(e / r * (Math.PI / 2)) + t
  3221. },
  3222. easeInOut: function(e, t, n, r) {
  3223. return -n / 2 * (Math.cos(Math.PI * e / r) - 1) + t
  3224. }
  3225. }
  3226. };
  3227. var Rectangle = function(e, t, n, r, i) {
  3228. this.center = new Vector(e, t);
  3229. this.width = n;
  3230. this.height = r;
  3231. this.angle = i;
  3232. this.vertices = [];
  3233. this.AABB = [];
  3234. this.clone = function() {
  3235. return new Rectangle(this.center.x, this.center.y, this.width, this.height, this.angle)
  3236. };
  3237. this.refreshVertices = function() {
  3238. var e = this.width / 2,
  3239. t = this.height / 2;
  3240. this.vertices = [];
  3241. this.vertices.push(new Vector(-e, t));
  3242. this.vertices.push(new Vector(e, t));
  3243. this.vertices.push(new Vector(e, -t));
  3244. this.vertices.push(new Vector(-e, -t));
  3245. this.AABB = [this.center.clone(), this.center.clone()];
  3246. for (e = 0; 4 > e; e++) this.vertices[e].rotate(-this.angle, this.center), this.vertices[e].x < this.AABB[0].x && (this.AABB[0].x = this.vertices[e].x), this.vertices[e].x > this.AABB[1].x && (this.AABB[1].x = this.vertices[e].x), this.vertices[e].y < this.AABB[0].y && (this.AABB[0].y = this.vertices[e].y), this.vertices[e].y > this.AABB[1].y && (this.AABB[1].y = this.vertices[e].y)
  3247. };
  3248. this.move = function(e, t) {
  3249. this.center.add(new Vector(e, t));
  3250. this.refreshVertices()
  3251. };
  3252. this.rotate = function(e) {
  3253. this.angle += e;
  3254. this.refreshVertices()
  3255. };
  3256. this.hitTestPoint = function(e) {
  3257. e = e.clone();
  3258. e.normalize(-this.angle, this.center);
  3259. return Math.abs(e.x) <= this.width / 2 && Math.abs(e.y) <= this.height / 2
  3260. };
  3261. this.hitTestRectangle = function(e) {
  3262. var t = this.clone();
  3263. e = e.clone();
  3264. var n, r, i;
  3265. t.move(-this.center.x, -this.center.y);
  3266. e.move(-this.center.x, -this.center.y);
  3267. e.center.rotate(this.angle);
  3268. t.rotate(-this.angle);
  3269. e.rotate(-this.angle);
  3270. n = Math.max(t.AABB[0].x, t.AABB[1].x, e.AABB[0].x, e.AABB[1].x) - Math.min(t.AABB[0].x, t.AABB[1].x, e.AABB[0].x, e.AABB[1].x);
  3271. r = t.AABB[1].x - t.AABB[0].x;
  3272. i = e.AABB[1].x - e.AABB[0].x;
  3273. if (n > r + i) return !1;
  3274. n = Math.max(t.AABB[0].y, t.AABB[1].y, e.AABB[0].y, e.AABB[1].y) - Math.min(t.AABB[0].y, t.AABB[1].y, e.AABB[0].y, e.AABB[1].y);
  3275. r = t.AABB[1].y - t.AABB[0].y;
  3276. i = e.AABB[1].y - e.AABB[0].y;
  3277. if (n > r + i) return !1;
  3278. t.move(-e.center.x, -e.center.y);
  3279. e.move(-e.center.x, -e.center.y);
  3280. t.center.rotate(e.angle);
  3281. t.refreshVertices();
  3282. t.rotate(-e.angle);
  3283. e.rotate(-e.angle);
  3284. n = Math.max(t.AABB[0].x, t.AABB[1].x, e.AABB[0].x, e.AABB[1].x) - Math.min(t.AABB[0].x, t.AABB[1].x, e.AABB[0].x, e.AABB[1].x);
  3285. r = t.AABB[1].x - t.AABB[0].x;
  3286. i = e.AABB[1].x - e.AABB[0].x;
  3287. if (n > r + i) return !1;
  3288. n = Math.max(t.AABB[0].y, t.AABB[1].y, e.AABB[0].y, e.AABB[1].y) - Math.min(t.AABB[0].y, t.AABB[1].y, e.AABB[0].y, e.AABB[1].y);
  3289. r = t.AABB[1].y - t.AABB[0].y;
  3290. i = e.AABB[1].y - e.AABB[0].y;
  3291. return n > r + i ? !1 : !0
  3292. };
  3293. this.refreshVertices()
  3294. },
  3295. Asset = function(e, t, n, r, i, s) {
  3296. this.name = e + "";
  3297. this.src = t + "";
  3298. this.width = n;
  3299. this.height = r;
  3300. this.frames = i;
  3301. this.layers = s;
  3302. this.object = this.bitmap = null;
  3303. this.ready = this.width && this.height;
  3304. this.detectSize = function() {
  3305. if (!this.bitmap) return !1;
  3306. try {
  3307. isNaN(this.width) && (this.width = this.bitmap.width ? parseInt(this.bitmap.width) : 0), isNaN(this.height) && (this.height = this.bitmap.height ? parseInt(this.bitmap.height) : 0)
  3308. } catch (e) {
  3309. CRENDER_DEBUG && console.log(e)
  3310. }
  3311. return !isNaN(this.width) && !isNaN(this.height)
  3312. };
  3313. this.normalize = function(e) {
  3314. if (!this.ready && this.detectSize()) {
  3315. if (isNaN(this.frames) || 1 > this.frames) this.frames = 1;
  3316. if (isNaN(this.layers) || 1 > this.layers) this.layers = 1;
  3317. this.width = Math.ceil(this.width / this.layers / e);
  3318. this.height = Math.ceil(this.height / this.frames / e);
  3319. this.ready = !0
  3320. }
  3321. }
  3322. },
  3323. AssetsLibrary = function(e, t, n) {
  3324. var r = this;
  3325. this.path = "images";
  3326. this.scale = 1;
  3327. this.items = {};
  3328. this.bitmaps = {};
  3329. this.loaded = !1;
  3330. this.onloadprogress = this.onload = null;
  3331. this.spriteClass = Sprite;
  3332. this.init = function(e, t) {
  3333. "undefined" != typeof e && (this.path = e + "");
  3334. "undefined" != typeof t && (this.scale = parseFloat(t), isNaN(this.scale) && (this.scale = 1))
  3335. };
  3336. this.addAssets = function(e) {
  3337. if ("undefined" != typeof e && "object" == typeof e)
  3338. for (var t = 0; t < e.length; t++) {
  3339. var n = e[t];
  3340. n.noscale = "undefined" == typeof n.noscale ? !1 : n.noscale;
  3341. n.noscale || (n.src = "%SCALE%/" + n.src);
  3342. this.addAsset(n.src, n.name, n.width, n.height, n.frames, n.layers)
  3343. }
  3344. };
  3345. this.addAsset = function(e, t, n, r, i, s) {
  3346. e = e.replace("%SCALE%", "%PATH%/" + this.scale);
  3347. e = e.replace("%PATH%", this.path);
  3348. "undefined" == typeof t && (t = e.split("http://resource.duopao.com/"), t = t.pop(), t = t.split("."), t = t.shift() + "");
  3349. e = new Asset(t, e, n, r, i, s);
  3350. return this.items[t] = e
  3351. };
  3352. this.addObject = function(e) {
  3353. var t = this.addAsset("%SCALE%/" + e.image, e.name, e.width * this.scale, e.height * this.scale, e.frames, e.layers);
  3354. t && (t.object = e);
  3355. return t
  3356. };
  3357. this.load = function(e, t) {
  3358. this.onload = e;
  3359. this.onloadprogress = t;
  3360. var n = new ImagesPreloader,
  3361. i = [],
  3362. s;
  3363. for (s in this.items) i.push(this.items[s]);
  3364. n.load(i, r.onLoadHandler, r.onLoadProgressHandler)
  3365. };
  3366. this.onLoadProgressHandler = function(e) {
  3367. if ("function" == typeof r.onloadprogress) r.onloadprogress(e)
  3368. };
  3369. this.onLoadHandler = function(e) {
  3370. r.loaded = !0;
  3371. for (var t in e) {
  3372. var n = r.items[t];
  3373. n.bitmap = e[t];
  3374. n.normalize(r.scale)
  3375. }
  3376. if ("function" == typeof r.onload) r.onload(r.items)
  3377. };
  3378. this.getAsset = function(e, t) {
  3379. var n = null;
  3380. "undefined" != typeof this.items[e] && this.items[e].bitmap && (n = "undefined" != typeof t && !t || this.items[e].ready ? this.items[e] : null);
  3381. if (!n) throw Error('Trying to get undefined asset "' + e + '"');
  3382. return n
  3383. };
  3384. this.getSprite = function(e, t) {
  3385. var n = null;
  3386. try {
  3387. var r = this.getAsset(e, !0),
  3388. n = new this.spriteClass(r.bitmap, r.width, r.height, r.frames, r.layers)
  3389. } catch (i) {
  3390. n = new this.spriteClass(null, 1, 1, 1, 1)
  3391. }
  3392. if ("object" == typeof t)
  3393. for (var s in t) n[s] = t[s];
  3394. return n
  3395. };
  3396. this.getBitmap = function(e) {
  3397. try {
  3398. return this.getAsset(e, !0).bitmap
  3399. } catch (t) {
  3400. return null
  3401. }
  3402. };
  3403. this.init(e, t);
  3404. this.addAssets(n)
  3405. };
  3406. "undefined" == typeof console && (console = {
  3407. log: function() {}
  3408. });
  3409. var TTLoader = {
  3410. endCallback: null,
  3411. loadedData: null,
  3412. landscapeMode: !1,
  3413. skipPlayButton: !1,
  3414. create: function(e, t, n) {
  3415. TTLoader.endCallback = e;
  3416. TTLoader.landscapeMode = t;
  3417. TTLoader.skipPlayButton = n;
  3418. TTLoader.fillLogo();
  3419. document.getElementById("progress_container").style.background = "#E9573F";
  3420. document.getElementById("progress_container").style.zIndex = "100";
  3421. e = document.getElementById("progress");
  3422. e.setAttribute("valign", "top");
  3423. e.style.verticalAlign = "top";
  3424. e.style.background = "#E9573F";
  3425. t = document.createElement("div");
  3426. n = document.createElement("a");
  3427. n.setAttribute("id", "tt_load_logo_c");
  3428. // n.setAttribute("href", "http://play68.com/");
  3429. n.setAttribute("target", "_blank");
  3430. var r = new Image;
  3431. r.setAttribute("id", "tt_load_logo");
  3432. r.setAttribute("border", "");
  3433. r.src = TTLoader.logoSrc[0];
  3434. r.style.cursor = "pointer";
  3435. n.appendChild(r);
  3436. t.appendChild(n);
  3437. e.appendChild(t);
  3438. t = document.createElement("div");
  3439. t.setAttribute("id", "tt_load_progress_cont");
  3440. t.setAttribute("align", "left");
  3441. t.setAttribute("style", "padding: 1px; border: 2px solid #0478b8; background: #fff");
  3442. n = document.createElement("div");
  3443. n.setAttribute("id", "tt_load_progress");
  3444. n.setAttribute("style", "width: 0px; background: #0088cd;");
  3445. n.innerHTML = "&nbsp;";
  3446. t.appendChild(n);
  3447. e.appendChild(t);
  3448. t = document.createElement("div");
  3449. t.setAttribute("id", "tt_load_play");
  3450. n = new Image;
  3451. n.setAttribute("id", "tt_load_button");
  3452. n.src = TTLoader.buttonDisabledSrc;
  3453. t.appendChild(n);
  3454. e.appendChild(t);
  3455. Utils.addEventListener("fitlayout", TTLoader.setSizes);
  3456. TTLoader.setSizes();
  3457. TTLoader.animateLogo()
  3458. },
  3459. setSizes: function() {
  3460. document.getElementById("progress_container").style.width = window.innerWidth + "px";
  3461. document.getElementById("progress_container").style.height = "2048px";
  3462. var e = Utils.globalScale * Utils.globalPixelScale;
  3463. TTLoader.landscapeMode || (document.getElementById("progress").style.paddingTop = Math.floor(80 * e) + "px");
  3464. document.getElementById("tt_load_progress_cont").style.width = Math.floor(200 * e) + "px";
  3465. document.getElementById("tt_load_progress").style.height = Math.floor(12 * e) + "px";
  3466. document.getElementById("tt_load_progress").style.width = e * TTLoader.progressVal * 2 + "px";
  3467. document.getElementById("tt_load_logo").setAttribute("width", Math.floor(180 * e) + "px");
  3468. document.getElementById("tt_load_logo").setAttribute("height", Math.floor(180 * e) + "px");
  3469. document.getElementById("tt_load_button").setAttribute("height", Math.floor(29 * e) + "px");
  3470. document.getElementById("tt_load_button").style.marginTop = Math.floor(20 * e) + "px"
  3471. },
  3472. progressVal: 0,
  3473. showLoadProgress: function(e) {
  3474. TTLoader.progressVal = e;
  3475. TTLoader.setSizes()
  3476. },
  3477. loadComplete: function(e) {
  3478. TTLoader.showLoadProgress(100);
  3479. TTLoader.loadedData = e;
  3480. e = document.getElementById("tt_load_button");
  3481. Utils.touchScreen ? (document.getElementById("main_container").removeEventListener("touchstart", Utils.preventEvent), e.ontouchstart = TTLoader.close) : e.onclick = TTLoader.close;
  3482. e.style.cursor = "pointer";
  3483. e.src = TTLoader.buttonSrc;
  3484. e = document.getElementById("tt_load_progress");
  3485. e.style.background = "transparent";
  3486. e = document.getElementById("tt_load_progress_cont");
  3487. e.style.border = "2px solid transparent";
  3488. e.style.background = "transparent";
  3489. document.getElementById("tt_load_button").style.display = "block";
  3490. TTLoader.skipPlayButton && TTLoader.close()
  3491. },
  3492. close: function() {
  3493. TTLoader.endCallback(TTLoader.loadedData);
  3494. Utils.touchScreen && document.getElementById("main_container").addEventListener("touchstart", Utils.preventEvent, !1)
  3495. },
  3496. logoSrc: [],
  3497. currentLogoFrame: 0,
  3498. logoOpacity: 0,
  3499. animateLogo: function() {
  3500. 1 > TTLoader.logoOpacity && (TTLoader.logoOpacity += .33, document.getElementById("tt_load_logo").style.opacity = TTLoader.logoOpacity, document.getElementById("tt_load_logo").style.filter = "alpha(opacity=" + 10 * TTLoader.logoOpacity + ")");
  3501. 1 <= TTLoader.logoOpacity && (document.getElementById("tt_load_logo").src = TTLoader.logoSrc[TTLoader.currentLogoFrame], TTLoader.currentLogoFrame++, TTLoader.currentLogoFrame >= TTLoader.logoSrc.length && (TTLoader.currentLogoFrame = TTLoader.logoSrc.length - 1));
  3502. setTimeout(TTLoader.animateLogo, 100)
  3503. },
  3504. fillLogo: function() {
  3505. var e = [];
  3506. e.push("logo.png");
  3507. TTLoader.logoSrc = e
  3508. },
  3509. buttonDisabledSrc: "tt_load_buttondisabled.png",
  3510. buttonSrc: "tt_load_button.png"
  3511. };
  3512. var STR_ALIGN_LEFT = "left",
  3513. STR_ALIGN_CENTER = "center",
  3514. STR_ALIGN_RIGHT = "right",
  3515. STR_VALIGN_TOP = "top",
  3516. STR_VALIGN_MIDDLE = "middle",
  3517. STR_VALIGN_BOTTOM = "bottom",
  3518. GUIFont = function(e) {
  3519. this.animated = !1;
  3520. this.fontProperties = e;
  3521. this.charmap = this.fontProperties.charmap;
  3522. GUIFont.superclass.constructor.call(this, this.fontProperties.image.bitmap, this.fontProperties.image.width, this.fontProperties.image.height, this.fontProperties.image.frames, this.fontProperties.image.layers);
  3523. GUIFont.prototype.validChar = function(e) {
  3524. return 0 <= this.fontProperties.charmap.indexOf(e.toString())
  3525. };
  3526. GUIFont.prototype.setChar = function(e) {
  3527. e = this.fontProperties.charmap.indexOf(e.toString());
  3528. 0 > e || (this.currentLayer = e % this.totalLayers, this.gotoAndStop(Math.floor(e / this.totalLayers)))
  3529. };
  3530. GUIFont.prototype.getChar = function() {
  3531. return this.fontProperties.charmap[this.currentLayer + this.currentFrame * this.totalLayers]
  3532. }
  3533. };
  3534. Utils.extend(GUIFont, Sprite);
  3535. var GUIString = function(e, t, n) {
  3536. this.font = FontManager.getFont(e);
  3537. if (!this.font) throw Error("Font '" + e + "' not found!");
  3538. this.strings = [];
  3539. this.chars = [];
  3540. this.align = STR_ALIGN_CENTER;
  3541. this.valign = STR_VALIGN_MIDDLE;
  3542. e = new this.font;
  3543. this.charWidth = e.fontProperties["char"].width;
  3544. this.charHeight = e.fontProperties["char"].height;
  3545. delete e;
  3546. this.visible = !0;
  3547. this.rotation = this.zIndex = this.y = this.x = 0;
  3548. this.opacity = 1;
  3549. this.width = this.height = 0;
  3550. this["static"] = "undefined" == typeof t ? !1 : t;
  3551. this.getString = function() {
  3552. return this.strings.join("\n")
  3553. };
  3554. this.getParams = function() {
  3555. return {
  3556. visible: this.visible,
  3557. x: this.x,
  3558. y: this.y,
  3559. zIndex: this.zIndex,
  3560. rotation: this.rotation,
  3561. opacity: this.opacity,
  3562. align: this.align,
  3563. valign: this.valign,
  3564. letterSpacing: this.charWidth,
  3565. lineHeight: this.charHeight
  3566. }
  3567. };
  3568. this.setParams = function(e, t) {
  3569. "object" != typeof e && (e = {});
  3570. "undefined" == typeof t && (t = !1);
  3571. "undefined" == typeof e.visible && (e.visible = this.visible);
  3572. "undefined" == typeof e.letterSpacing && (e.letterSpacing = this.charWidth);
  3573. "undefined" == typeof e.lineHeight && (e.lineHeight = this.charHeight);
  3574. "undefined" == typeof e.align && (e.align = this.align);
  3575. "undefined" == typeof e.valign && (e.valign = this.valign);
  3576. "undefined" == typeof e.x && (e.x = this.x);
  3577. e.x = parseInt(e.x);
  3578. isNaN(e.x) && (e.x = this.x);
  3579. "undefined" == typeof e.y && (e.y = this.y);
  3580. e.y = parseInt(e.y);
  3581. isNaN(e.y) && (e.y = this.y);
  3582. "undefined" == typeof e.zIndex && (e.zIndex = this.zIndex);
  3583. e.zIndex = parseInt(e.zIndex);
  3584. isNaN(e.zIndex) && (e.zIndex = this.zIndex);
  3585. "undefined" == typeof e.rotation && (e.rotation = this.rotation);
  3586. e.rotation = parseFloat(e.rotation);
  3587. isNaN(e.rotation) && (e.rotation = this.rotation);
  3588. "undefined" == typeof e.opacity && (e.opacity = this.opacity);
  3589. e.opacity = parseFloat(e.opacity);
  3590. isNaN(e.opacity) && (e.opacity = this.opacity);
  3591. if (e.letterSpacing != this.charWidth || e.lineHeight != this.charHeight) this._setSpacing(e.letterSpacing, e.lineHeight), t = !0;
  3592. if (e.align != this.align || e.valign != this.valign) this._setAlign(e.align, e.valign), t = !0;
  3593. if (e.x != this.x || e.y != this.y || e.rotation != this.rotation || t) this._refreshSize(), this._setPosition(e.x, e.y), this._setRotation(e.rotation), this._setOpacity(e.opacity);
  3594. e.zIndex != this.zIndex && this._setZIndex(e.zIndex);
  3595. e.visible != this.visible && this._setVisible(e.visible)
  3596. };
  3597. this.refresh = function() {
  3598. this.setParams(this.getParams())
  3599. };
  3600. this.write = function(e, t, n, r, i, s, o, u) {
  3601. this.strings = e = this._prepareString(e);
  3602. this._createStageChars();
  3603. e = {
  3604. align: r,
  3605. valign: i,
  3606. x: t,
  3607. y: n,
  3608. rotation: s,
  3609. letterSpacing: o,
  3610. lineHeight: u
  3611. };
  3612. 0 < this.chars.length && (e.zIndex = 0 < this.zIndex ? this.zIndex : this.chars[0].zIndex);
  3613. for (n = t = 0; n < this.strings.length; n++)
  3614. for (r = 0; r < this.strings[n].length; r++) i = this.chars[t++], i["static"] = this["static"], i.setChar(this.strings[n].substring(r, r + 1));
  3615. this.setParams(e, !0)
  3616. };
  3617. this.clear = function() {
  3618. this.write("")
  3619. };
  3620. this._setVisible = function(e) {
  3621. this.visible = e;
  3622. for (e = 0; e < this.chars.length; e++) this.chars[e] && (this.chars[e].visible = this.visible)
  3623. };
  3624. this._setOpacity = function(e) {
  3625. this.opacity = e;
  3626. for (e = 0; e < this.chars.length; e++) this.chars[e] && (this.chars[e].opacity = this.opacity)
  3627. };
  3628. this._setZIndex = function(e) {
  3629. "undefined" == typeof e && (e = this.zIndex);
  3630. e = ~~e;
  3631. if (e != this.zIndex) {
  3632. this.zIndex = ~~e;
  3633. for (var t = 0; t < this.chars.length; t++) this.chars[t] && this.chars[t].setZIndex(e)
  3634. }
  3635. };
  3636. this._setSpacing = function(e, t) {
  3637. "undefined" == typeof e && (e = this.charWidth);
  3638. this.charWidth = ~~e;
  3639. "undefined" == typeof t && (t = this.charHeight);
  3640. this.charHeight = ~~t
  3641. };
  3642. this._setAlign = function(e, t) {
  3643. "undefined" == typeof e && (e = this.align);
  3644. this.align = e.toString().toLowerCase();
  3645. "undefined" == typeof t && (t = this.valign);
  3646. this.valign = t.toString().toLowerCase()
  3647. };
  3648. this._setPosition = function(e, t) {
  3649. this.x = e;
  3650. this.y = t;
  3651. var n = Math.round(this.charHeight / 2);
  3652. this.valign == STR_VALIGN_MIDDLE && (n -= Math.round(this.height / 2));
  3653. this.valign == STR_VALIGN_BOTTOM && (n -= this.height);
  3654. for (var r = 0, i = 0; i < this.strings.length; i++) {
  3655. var s = this.charWidth * this.strings[i].length,
  3656. o = -Math.round(this.charWidth / 2);
  3657. this.align == STR_ALIGN_CENTER && (o -= Math.round(s / 2));
  3658. this.align == STR_ALIGN_RIGHT && (o -= s);
  3659. for (s = 0; s < this.strings[i].length; s++) {
  3660. var u = this.chars[r++];
  3661. u && (o += this.charWidth, u.x = this.x + o, u.y = this.y + n)
  3662. }
  3663. n += this.charHeight
  3664. }
  3665. };
  3666. this._setRotation = function(e) {
  3667. e >= 2 * Math.PI && (e -= 2 * Math.PI);
  3668. 0 > e && (e += 2 * Math.PI);
  3669. this.rotation = e;
  3670. if (0 != this.chars.length)
  3671. for (e = 0; e < this.chars.length; e++)
  3672. if (this.chars[e]) {
  3673. var t = new Vector(this.chars[e].x - this.x, this.chars[e].y - this.y);
  3674. t.rotate(-this.rotation);
  3675. this.chars[e].x = this.x + t.x;
  3676. this.chars[e].y = this.y + t.y;
  3677. this.chars[e].rotation = this.rotation
  3678. }
  3679. };
  3680. this._validateString = function(e) {
  3681. e = e.toString();
  3682. for (var t = "", n = new this.font, r = 0; r < e.length; r++) {
  3683. var i = e.substring(r, r + 1);
  3684. n.validChar(i) && (t += i)
  3685. }
  3686. return t
  3687. };
  3688. this._refreshSize = function() {
  3689. for (var e = 0, t = 0; t < this.strings.length; t++) e = Math.max(e, this.strings[t].length);
  3690. this.width = this.charWidth * e;
  3691. this.height = this.charHeight * this.strings.length
  3692. };
  3693. this._createStageChars = function() {
  3694. var e = this.strings.join("").length,
  3695. e = this.chars.length - e;
  3696. if (0 != e) {
  3697. for (; 0 != e;) {
  3698. var t;
  3699. 0 > e ? (t = new this.font, t = stage.addChild(t), t.visible = this.visible, this.chars.push(t)) : (t = this.chars.pop(), stage.removeChild(t));
  3700. e += 0 > e ? 1 : -1
  3701. }
  3702. this._refreshSize()
  3703. }
  3704. };
  3705. this._prepareString = function(e) {
  3706. e = String(e).split("\n");
  3707. for (var t = 0; t < e.length; t++) e[t] = this._validateString(e[t]);
  3708. return e
  3709. };
  3710. this.debugDraw = function(e) {
  3711. "undefined" == typeof e && (e = "#FFF");
  3712. this._debugDrawAnchor(e);
  3713. this._debugDrawBox(e)
  3714. };
  3715. this._debugDrawBox = function(e) {};
  3716. this._debugDrawAnchor = function(e) {
  3717. stage.drawRectangle(this.x, this.y, 3, 3, e, !0, .8)
  3718. };
  3719. "object" == typeof n && this.setParams(n)
  3720. },
  3721. Charset = {
  3722. getByName: function(e) {
  3723. if ("undefined" == typeof Charset[e]) throw Error("Character set ' " + e + " ' is not defined!");
  3724. return Charset[e]
  3725. },
  3726. digits: '0123456789+-.,*/=()<>#$%&:;|№@~"'.split(""),
  3727. full: " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ЁЂЃЄЅІЇЈЉЊЋЌЎЏАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя№ёђѓєѕіїјљњћќ§ўџŠŽšžŸ¢£¥§©«®µ»ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ".split(""),
  3728. latin: " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ".split("")
  3729. },
  3730. FontManager = {
  3731. _fonts: {},
  3732. defaultCharmap: Charset.full,
  3733. fontNameFromBitmap: function(e) {
  3734. e = "string" == typeof e ? e : e.src;
  3735. e = e.replace("\\", "http://resource.duopao.com/").split("http://resource.duopao.com/").pop();
  3736. return e = e.split(".").shift()
  3737. },
  3738. createAssetFromSprite: function(e, t) {
  3739. var n = new Asset(e, t.bitmap.src, t.width, t.height, t.totalFrames, t.totalLayers);
  3740. n.bitmap = t.bitmap;
  3741. return n
  3742. },
  3743. createFontAsset: function(e, t, n, r) {
  3744. var i, s;
  3745. if ("string" == typeof e) {
  3746. if ("undefined" == typeof library) throw Error("Bitmaps access by name works only with AssetsLibrary");
  3747. try {
  3748. s = e, i = library.getAsset(s)
  3749. } catch (o) {
  3750. throw Error("Sprite not found for font '" + s + "'")
  3751. }
  3752. } else if ("object" == typeof e) {
  3753. i = ["bitmap", "width", "height", "totalFrames", "totalLayers"];
  3754. for (s = 0; s < i.length; s++)
  3755. if ("undefined" == typeof e[i[s]]) throw Error("Invalid image. Instance of Sprite expected.");
  3756. s = FontManager.fontNameFromBitmap(e.bitmap);
  3757. i = FontManager.createAssetFromSprite(s, e)
  3758. } else throw Error("Invalid image. Asset name or instance of Sprite expected.");
  3759. i = new GUIFontAsset(s, i, t);
  3760. n = ~~n;
  3761. r = ~~r;
  3762. 0 < n && (i["char"].width = n);
  3763. 0 < r && (i["char"].height = r);
  3764. return i
  3765. },
  3766. registerFont: function(e, t, n, r) {
  3767. "string" == typeof t && (t = Charset.getByName(t));
  3768. var i = FontManager.createFontAsset(e, t, n, r),
  3769. s = function() {
  3770. s.superclass.constructor.call(this, i)
  3771. };
  3772. Utils.extend(s, GUIFont);
  3773. FontManager._fonts[i.name] = s;
  3774. return i.name
  3775. },
  3776. getFont: function(e) {
  3777. "undefined" == typeof FontManager._fonts[e] && FontManager.registerFont(e, FontManager.defaultCharmap);
  3778. return FontManager._fonts[e]
  3779. }
  3780. },
  3781. GUIFontAsset = function(e, t, n) {
  3782. this.name = e;
  3783. this.image = t;
  3784. this.charmap = n;
  3785. this["char"] = {
  3786. width: t.width,
  3787. height: t.height
  3788. }
  3789. },
  3790. ExternalAPI = {
  3791. type: "Spilgames",
  3792. init: function(e) {
  3793. ExternalAPI.check() ? SpilGames.Events.subscribe("gamecontainer.resize", Utils.fitLayoutToScreen) : Utils.addFitLayoutListeners()
  3794. },
  3795. check: function() {
  3796. return "undefined" != typeof SpilGames
  3797. },
  3798. checkUserLoggedIn: function() {
  3799. return "NOT_AUTHENTICATED" == SpilGames.Auth.getAuthState() ? !1 : !0
  3800. },
  3801. getUserInfo: function() {},
  3802. addChangeLocaleListener: function(e) {
  3803. SpilGames.Events.subscribe("game.language.change", e)
  3804. },
  3805. showLoginForm: function(e) {
  3806. e || (e = function() {});
  3807. SpilGames.Portal.forceAuthentication(e)
  3808. },
  3809. showScoreboard: function(e) {
  3810. e || (e = function() {});
  3811. SpilGames.Portal.showScoreboard(e)
  3812. },
  3813. submitScores: function(e, t) {
  3814. t || (t = function() {});
  3815. SpilGames.Highscores.insert({
  3816. score: e
  3817. }, t)
  3818. }
  3819. };
  3820. if (!ExternalAPI.check()) var SpilGames;
  3821. AudioMixer.buffer = {};
  3822. AudioMixer.waContext = null;
  3823. var stage, landscape = !1,
  3824. fps = 24,
  3825. bitmaps, GET, iosMode = !1,
  3826. android = !1,
  3827. usedPoints = 0,
  3828. gameScore = 0,
  3829. coins = 0,
  3830. showUnlockAnimation = !1,
  3831. ignoreMenuTheme = !1,
  3832. soundOn, mixer2, STATE_LOAD = 0,
  3833. STATE_LOGO = 1,
  3834. STATE_MENU = 2,
  3835. STATE_GAME = 3,
  3836. STATE_SELECT_DIFFICULTY = 4,
  3837. STATE_VICTORY = 5,
  3838. STATE_DEFEAT = 6,
  3839. STATE_HIGHSCORES = 7,
  3840. STATE_CREDITS = 8,
  3841. STATE_TUTORIAL = 9,
  3842. STATE_MISSION_INFO = 10,
  3843. D_SIMPLE = 0,
  3844. D_NORMAL = 1,
  3845. D_HARD = 2,
  3846. D_EXPERT = 3,
  3847. D_ULTIMATE = 4,
  3848. currentDifficulty, gameState = STATE_LOAD,
  3849. T_EMPTY = 0,
  3850. T_AMOEBA = 1,
  3851. T_JELLYFISH = 2,
  3852. T_SMARTFISH = 3,
  3853. T_LIZARD = 4,
  3854. T_WOLF = 5,
  3855. T_APE = 6,
  3856. T_HOMOSAPIENS = 7,
  3857. T_UNKNOWN = 8,
  3858. T_ETHER = 20,
  3859. T_FIRE = 21,
  3860. T_ICE = 22,
  3861. T_UFO = 23,
  3862. easy_level = {
  3863. init: {},
  3864. elements: {},
  3865. upgrades: [T_AMOEBA, T_JELLYFISH, T_SMARTFISH, T_LIZARD],
  3866. field: {
  3867. x: 5,
  3868. y: 5
  3869. },
  3870. name: "easy"
  3871. };
  3872. easy_level.init[T_AMOEBA] = 4;
  3873. easy_level.init[T_JELLYFISH] = 1;
  3874. easy_level.init[T_SMARTFISH] = 1;
  3875. easy_level.init[T_ICE] = 6;
  3876. easy_level.elements[T_AMOEBA] = 30;
  3877. easy_level.elements[T_JELLYFISH] = 20;
  3878. easy_level.elements[T_FIRE] = 10;
  3879. easy_level.elements[T_ICE] = 10;
  3880. var medium_level = {
  3881. init: {},
  3882. elements: {},
  3883. upgrades: [T_AMOEBA, T_JELLYFISH, T_SMARTFISH, T_LIZARD, T_WOLF],
  3884. field: {
  3885. x: 5,
  3886. y: 5
  3887. },
  3888. name: "medium"
  3889. };
  3890. medium_level.init[T_AMOEBA] = 3;
  3891. medium_level.init[T_JELLYFISH] = 1;
  3892. medium_level.init[T_ICE] = 3;
  3893. medium_level.elements[T_AMOEBA] = 40;
  3894. medium_level.elements[T_JELLYFISH] = 30;
  3895. medium_level.elements[T_FIRE] = 10;
  3896. medium_level.elements[T_ICE] = 10;
  3897. medium_level.elements[T_ETHER] = 5;
  3898. var hard_level = {
  3899. init: {},
  3900. elements: {},
  3901. upgrades: [T_AMOEBA, T_JELLYFISH, T_SMARTFISH, T_LIZARD, T_WOLF, T_APE],
  3902. field: {
  3903. x: 5,
  3904. y: 5
  3905. },
  3906. name: "hard"
  3907. };
  3908. hard_level.init[T_AMOEBA] = 3;
  3909. hard_level.init[T_JELLYFISH] = 1;
  3910. hard_level.init[T_ICE] = 3;
  3911. hard_level.elements[T_AMOEBA] = 30;
  3912. hard_level.elements[T_JELLYFISH] = 20;
  3913. hard_level.elements[T_SMARTFISH] = 10;
  3914. hard_level.elements[T_FIRE] = 10;
  3915. hard_level.elements[T_ICE] = 5;
  3916. hard_level.elements[T_UFO] = 10;
  3917. var expert_level = {
  3918. init: {},
  3919. elements: {},
  3920. upgrades: [T_AMOEBA, T_JELLYFISH, T_SMARTFISH, T_LIZARD, T_WOLF, T_APE, T_HOMOSAPIENS],
  3921. field: {
  3922. x: 5,
  3923. y: 5
  3924. },
  3925. name: "expert"
  3926. };
  3927. expert_level.init[T_AMOEBA] = 5;
  3928. expert_level.init[T_JELLYFISH] = 3;
  3929. expert_level.init[T_ICE] = 3;
  3930. expert_level.elements[T_AMOEBA] = 30;
  3931. expert_level.elements[T_JELLYFISH] = 20;
  3932. expert_level.elements[T_SMARTFISH] = 10;
  3933. expert_level.elements[T_LIZARD] = 5;
  3934. expert_level.elements[T_WOLF] = 2;
  3935. expert_level.elements[T_APE] = 1;
  3936. expert_level.elements[T_FIRE] = 10;
  3937. expert_level.elements[T_ICE] = 5;
  3938. expert_level.elements[T_UFO] = 10;
  3939. var ultimate_level = {
  3940. init: {},
  3941. elements: {},
  3942. upgrades: [T_AMOEBA, T_JELLYFISH, T_SMARTFISH, T_LIZARD, T_WOLF, T_APE, T_HOMOSAPIENS, T_UNKNOWN],
  3943. field: {
  3944. x: 5,
  3945. y: 5
  3946. },
  3947. name: "ultimate"
  3948. };
  3949. ultimate_level.init[T_AMOEBA] = 2;
  3950. ultimate_level.init[T_JELLYFISH] = 2;
  3951. ultimate_level.init[T_SMARTFISH] = 3;
  3952. ultimate_level.init[T_ICE] = 4;
  3953. ultimate_level.elements[T_AMOEBA] = 10;
  3954. ultimate_level.elements[T_JELLYFISH] = 25;
  3955. ultimate_level.elements[T_SMARTFISH] = 15;
  3956. ultimate_level.elements[T_LIZARD] = 10;
  3957. ultimate_level.elements[T_WOLF] = 5;
  3958. ultimate_level.elements[T_APE] = 4;
  3959. ultimate_level.elements[T_FIRE] = 8;
  3960. ultimate_level.elements[T_ICE] = 9;
  3961. ultimate_level.elements[T_UFO] = 8;
  3962. ultimate_level.elements[T_HOMOSAPIENS] = 1;
  3963. var LEVELS = [easy_level, medium_level, hard_level, expert_level, ultimate_level],
  3964. EL_BMP = {};
  3965. EL_BMP[T_EMPTY] = "element";
  3966. EL_BMP[T_AMOEBA] = "unicellar";
  3967. EL_BMP[T_JELLYFISH] = "meduze";
  3968. EL_BMP[T_SMARTFISH] = "fish";
  3969. EL_BMP[T_LIZARD] = "pangolin";
  3970. EL_BMP[T_WOLF] = "mammal";
  3971. EL_BMP[T_APE] = "people";
  3972. EL_BMP[T_HOMOSAPIENS] = "uslon";
  3973. EL_BMP[T_UNKNOWN] = "unknown";
  3974. EL_BMP[T_ETHER] = "ether";
  3975. EL_BMP[T_FIRE] = "fire";
  3976. EL_BMP[T_ICE] = "ice";
  3977. EL_BMP[T_UFO] = "ufo";
  3978. var EL_SCORE = {};
  3979. EL_SCORE[T_EMPTY] = 0;
  3980. EL_SCORE[T_AMOEBA] = 0;
  3981. EL_SCORE[T_JELLYFISH] = 100;
  3982. EL_SCORE[T_SMARTFISH] = 500;
  3983. EL_SCORE[T_LIZARD] = 3e3;
  3984. EL_SCORE[T_WOLF] = 15e3;
  3985. EL_SCORE[T_APE] = 3e4;
  3986. EL_SCORE[T_HOMOSAPIENS] = 1e5;
  3987. EL_SCORE[T_UNKNOWN] = 5e5;
  3988. EL_SCORE[T_ETHER] = 0;
  3989. EL_SCORE[T_FIRE] = 0;
  3990. EL_SCORE[T_ICE] = 0;
  3991. EL_SCORE[T_UFO] = 0;
  3992. var FIELD_SIZE = {
  3993. x: 5,
  3994. y: 5
  3995. },
  3996. CHAIN_LENGTH = 3,
  3997. assets = [{
  3998. name: "field-select-level-bg",
  3999. src: "field-select-level-bg.png",
  4000. width: 301,
  4001. height: 432
  4002. }, {
  4003. name: "easy",
  4004. src: "easy.png",
  4005. width: 248,
  4006. height: 66,
  4007. frames: 2
  4008. }, {
  4009. name: "medium",
  4010. src: "medium.png",
  4011. width: 248,
  4012. height: 66,
  4013. frames: 2
  4014. }, {
  4015. name: "hard",
  4016. src: "hard.png",
  4017. width: 248,
  4018. height: 66,
  4019. frames: 2
  4020. }, {
  4021. name: "expert",
  4022. src: "expert.png",
  4023. width: 248,
  4024. height: 66,
  4025. frames: 2
  4026. }, {
  4027. name: "ultimate",
  4028. src: "ultimate.png",
  4029. width: 248,
  4030. height: 66,
  4031. frames: 2
  4032. }, {
  4033. name: "field-play-playingfield",
  4034. src: "field-play-playingfield.png",
  4035. width: 306,
  4036. height: 378
  4037. }, {
  4038. name: "buy",
  4039. src: "buy.png",
  4040. width: 78,
  4041. height: 24,
  4042. frames: 2
  4043. }, {
  4044. name: "replay",
  4045. src: "replay.png",
  4046. width: 122,
  4047. height: 46
  4048. }, {
  4049. name: "menu",
  4050. src: "menu.png",
  4051. width: 122,
  4052. height: 46
  4053. }, {
  4054. name: "plus",
  4055. src: "plus.png",
  4056. width: 27,
  4057. height: 26,
  4058. frames: 2
  4059. }, {
  4060. name: "field-play-score-bg",
  4061. src: "field-play-score-bg.png",
  4062. width: 135,
  4063. height: 54
  4064. }, {
  4065. name: "field_highscore",
  4066. src: "field-highscore-bg.png",
  4067. width: 301,
  4068. height: 431
  4069. }, {
  4070. name: "highscores",
  4071. src: "highscores.png",
  4072. width: 226,
  4073. height: 78,
  4074. frames: 2
  4075. }, {
  4076. name: "popup_bg",
  4077. src: "popup_bg.png",
  4078. width: 165,
  4079. height: 194
  4080. }, {
  4081. name: "lock",
  4082. src: "lock.png",
  4083. width: 61,
  4084. height: 56,
  4085. frames: 11
  4086. }, {
  4087. name: "evol_back",
  4088. src: "evol_back.png",
  4089. width: 302,
  4090. height: 427
  4091. }, {
  4092. name: "back_field-evolution-popup",
  4093. src: "back_field-evolution-popup.png",
  4094. width: 411,
  4095. height: 313
  4096. }, {
  4097. name: "light_win",
  4098. src: "light_win.png",
  4099. width: 101,
  4100. height: 101
  4101. }, {
  4102. name: "ether",
  4103. src: "field-play-card-ether1.png",
  4104. width: 50,
  4105. height: 50
  4106. }, {
  4107. name: "fire",
  4108. src: "field-play-card-fire.png",
  4109. width: 50,
  4110. height: 50
  4111. }, {
  4112. name: "fish",
  4113. src: "field-play-card-fish.png",
  4114. width: 50,
  4115. height: 50
  4116. }, {
  4117. name: "font1",
  4118. src: "Numbers.png",
  4119. width: 12,
  4120. height: 200,
  4121. frames: 10
  4122. }, {
  4123. name: "ice",
  4124. src: "field-play-card-ice.png",
  4125. width: 50,
  4126. height: 50
  4127. }, {
  4128. name: "mammal",
  4129. src: "field-play-card-wolf.png",
  4130. width: 50,
  4131. height: 50
  4132. }, {
  4133. name: "meduze",
  4134. src: "field-play-card-jellyfish.png",
  4135. width: 50,
  4136. height: 50
  4137. }, {
  4138. name: "pangolin",
  4139. src: "field-play-card-lizard.png",
  4140. width: 50,
  4141. height: 50
  4142. }, {
  4143. name: "people",
  4144. src: "field-play-card-monkey.png",
  4145. width: 50,
  4146. height: 50
  4147. }, {
  4148. name: "uslon",
  4149. src: "field-play-card-human.png",
  4150. width: 50,
  4151. height: 50
  4152. }, {
  4153. name: "popup_loose",
  4154. src: "popup_loose.png",
  4155. width: 316,
  4156. height: 186
  4157. }, {
  4158. name: "ufo",
  4159. src: "field-play-card-ufo.png",
  4160. width: 50,
  4161. height: 50
  4162. }, {
  4163. name: "unicellar",
  4164. src: "field-play-card-amoeba.png",
  4165. width: 50,
  4166. height: 50
  4167. }, {
  4168. name: "baveuse",
  4169. src: "fonts/baveuse_white.png",
  4170. frames: 6,
  4171. layers: 16,
  4172. width: 15,
  4173. height: 15
  4174. }, {
  4175. name: "field-main-logo",
  4176. src: "field-main-logo.png",
  4177. width: 319,
  4178. height: 141
  4179. }, {
  4180. name: "field-main-btn-bg",
  4181. src: "field-main-btn-bg.png",
  4182. width: 261,
  4183. height: 298
  4184. }, {
  4185. name: "play",
  4186. src: "play.png",
  4187. width: 227,
  4188. height: 120,
  4189. frames: 2
  4190. }, {
  4191. name: "light",
  4192. src: "gme-bg-light.png",
  4193. width: 320,
  4194. height: 480
  4195. }, {
  4196. name: "credits",
  4197. src: "credits.png",
  4198. width: 205,
  4199. height: 69,
  4200. frames: 2
  4201. }, {
  4202. name: "sound",
  4203. src: "sound.png",
  4204. width: 56,
  4205. height: 54,
  4206. frames: 2
  4207. }, {
  4208. name: "txt_1",
  4209. src: "txt_1.png",
  4210. width: 251,
  4211. height: 47
  4212. }, {
  4213. name: "txt_2",
  4214. src: "txt_2.png",
  4215. width: 200,
  4216. height: 49
  4217. }, {
  4218. name: "txt_3",
  4219. src: "txt_3.png",
  4220. width: 190,
  4221. height: 152
  4222. }, {
  4223. name: "txt_4",
  4224. src: "txt_4.png",
  4225. width: 198,
  4226. height: 79
  4227. }, {
  4228. name: "txt_5",
  4229. src: "txt_5.png",
  4230. width: 149,
  4231. height: 104
  4232. }, {
  4233. name: "txt_6",
  4234. src: "txt_6.png",
  4235. width: 179,
  4236. height: 87
  4237. }, {
  4238. name: "txt_7",
  4239. src: "txt_7.png",
  4240. width: 108,
  4241. height: 94
  4242. }, {
  4243. name: "txt_8",
  4244. src: "txt_8.png",
  4245. width: 174,
  4246. height: 71
  4247. }, {
  4248. name: "txt_9",
  4249. src: "txt_9.png",
  4250. width: 125,
  4251. height: 111
  4252. }, {
  4253. name: "txt_10",
  4254. src: "txt_10.png",
  4255. width: 156,
  4256. height: 82
  4257. }, {
  4258. name: "txt_11",
  4259. src: "txt_11.png",
  4260. width: 122,
  4261. height: 115
  4262. }, {
  4263. name: "txt_12",
  4264. src: "txt_12.png",
  4265. width: 135,
  4266. height: 113
  4267. }, {
  4268. name: "txt_13",
  4269. src: "txt_13.png",
  4270. width: 102,
  4271. height: 69
  4272. }, {
  4273. name: "txt_14",
  4274. src: "txt_14.png",
  4275. width: 167,
  4276. height: 107
  4277. }, {
  4278. name: "txt_15",
  4279. src: "txt_15.png",
  4280. width: 200,
  4281. height: 78
  4282. }, {
  4283. name: "txt_16",
  4284. src: "txt_16.png",
  4285. width: 151,
  4286. height: 92
  4287. }, {
  4288. name: "txt_17",
  4289. src: "txt_17.png",
  4290. width: 178,
  4291. height: 53
  4292. }, {
  4293. name: "txt_18",
  4294. src: "txt_18.png",
  4295. width: 189,
  4296. height: 71
  4297. }, {
  4298. name: "txt_19",
  4299. src: "txt_19.png",
  4300. width: 240,
  4301. height: 133
  4302. }, {
  4303. name: "txt_20",
  4304. src: "txt_20.png",
  4305. width: 187,
  4306. height: 169
  4307. }, {
  4308. name: "win_next",
  4309. src: "win_next.png",
  4310. width: 50,
  4311. height: 50,
  4312. frames: 2
  4313. }, {
  4314. name: "win_replay",
  4315. src: "win_replay.png",
  4316. width: 50,
  4317. height: 50,
  4318. frames: 2
  4319. }, {
  4320. name: "back_field_win",
  4321. src: "back_field_win.png",
  4322. width: 300,
  4323. height: 195
  4324. }, {
  4325. name: "unknown1",
  4326. src: "unknown1.png",
  4327. width: 49,
  4328. height: 50
  4329. }, {
  4330. name: "unknown2",
  4331. src: "unknown2.png",
  4332. width: 49,
  4333. height: 50
  4334. }, {
  4335. name: "unknown3",
  4336. src: "unknown3.png",
  4337. width: 49,
  4338. height: 50
  4339. }, {
  4340. name: "unknown4",
  4341. src: "unknown4.png",
  4342. width: 49,
  4343. height: 50
  4344. }, {
  4345. name: "unknown5",
  4346. src: "unknown5.png",
  4347. width: 49,
  4348. height: 50
  4349. }, {
  4350. name: "unknown6",
  4351. src: "unknown6.png",
  4352. width: 49,
  4353. height: 50
  4354. }, {
  4355. name: "arrow",
  4356. src: "arrow.png",
  4357. width: 13,
  4358. height: 28
  4359. }, {
  4360. name: "mission_bg",
  4361. src: "mission-bg.png",
  4362. width: 279,
  4363. height: 256
  4364. }, {
  4365. name: "mission_create_1",
  4366. src: "mission-create-1.png",
  4367. width: 150,
  4368. height: 16
  4369. }, {
  4370. name: "mission_create_2",
  4371. src: "mission-create-2.png",
  4372. width: 138,
  4373. height: 16
  4374. }, {
  4375. name: "mission_create_3",
  4376. src: "mission-create-3.png",
  4377. width: 126,
  4378. height: 16
  4379. }, {
  4380. name: "mission_create_4",
  4381. src: "mission-create-4.png",
  4382. width: 150,
  4383. height: 16
  4384. }, {
  4385. name: "mission_create_5",
  4386. src: "mission-create-5.png",
  4387. width: 103,
  4388. height: 16
  4389. }, {
  4390. name: "mission_untitled_a",
  4391. src: "mission-untitled-a.png",
  4392. width: 48,
  4393. height: 48
  4394. }, {
  4395. name: "mission_untitled_b",
  4396. src: "mission-untitled-b.png",
  4397. width: 48,
  4398. height: 48
  4399. }, {
  4400. name: "r1",
  4401. src: "r1.png",
  4402. width: 6,
  4403. height: 6
  4404. }, {
  4405. name: "r2",
  4406. src: "r2.png",
  4407. width: 6,
  4408. height: 6
  4409. }, {
  4410. name: "qmark",
  4411. src: "qmark.png",
  4412. width: 51,
  4413. height: 57,
  4414. frames: 2
  4415. }, {
  4416. name: "coin_rotate",
  4417. src: "coin_rotate.png",
  4418. width: 46,
  4419. height: 46,
  4420. frames: 9
  4421. }, {
  4422. name: "coin_rotate12",
  4423. src: "coin_rotate12.png",
  4424. width: 48,
  4425. height: 24,
  4426. frames: 18
  4427. }, {
  4428. name: "Help1",
  4429. src: "Help1.png",
  4430. width: 320,
  4431. height: 480
  4432. }, {
  4433. name: "Help2",
  4434. src: "Help2.png",
  4435. width: 320,
  4436. height: 480
  4437. }, {
  4438. name: "Help3",
  4439. src: "Help3.png",
  4440. width: 320,
  4441. height: 480
  4442. }, {
  4443. name: "Help4",
  4444. src: "Help4.png",
  4445. width: 320,
  4446. height: 480
  4447. }, {
  4448. name: "arrow_frwd",
  4449. src: "arrow_frwd.png",
  4450. width: 12,
  4451. height: 31
  4452. }, {
  4453. name: "arrow_prev",
  4454. src: "arrow_prev.png",
  4455. width: 12,
  4456. height: 31
  4457. }, {
  4458. name: "arrow_down",
  4459. src: "arrow_down.png",
  4460. width: 31,
  4461. height: 12
  4462. }, {
  4463. name: "arrow_up",
  4464. src: "arrow_up.png",
  4465. width: 31,
  4466. height: 12
  4467. }, {
  4468. name: "back_field_win_3",
  4469. src: "back_field-win-3.png",
  4470. width: 300,
  4471. height: 344
  4472. }, {
  4473. name: "text1",
  4474. src: "text1.png",
  4475. width: 55,
  4476. height: 18
  4477. }, {
  4478. name: "text2",
  4479. src: "text2.png",
  4480. width: 157,
  4481. height: 18
  4482. }, {
  4483. name: "text3",
  4484. src: "text3.png",
  4485. width: 88,
  4486. height: 18
  4487. }, {
  4488. name: "Fish",
  4489. src: "Fish.png",
  4490. width: 256,
  4491. height: 80
  4492. }, {
  4493. name: "geek",
  4494. src: "geek.png",
  4495. width: 256,
  4496. height: 80
  4497. }, {
  4498. name: "human",
  4499. src: "human.png",
  4500. width: 256,
  4501. height: 80
  4502. }, {
  4503. name: "humanoid",
  4504. src: "humanoid.png",
  4505. width: 256,
  4506. height: 80
  4507. }, {
  4508. name: "Jellyfish",
  4509. src: "Jellyfish.png",
  4510. width: 256,
  4511. height: 80
  4512. }, {
  4513. name: "lizard",
  4514. src: "lizard.png",
  4515. width: 256,
  4516. height: 80
  4517. }, {
  4518. name: "superbrains",
  4519. src: "superbrains.png",
  4520. width: 256,
  4521. height: 80
  4522. }, {
  4523. name: "superhuman",
  4524. src: "superhuman.png",
  4525. width: 256,
  4526. height: 80
  4527. }, {
  4528. name: "Unknown",
  4529. src: "Unknown.png",
  4530. width: 256,
  4531. height: 80
  4532. }, {
  4533. name: "wolf",
  4534. src: "wolf.png",
  4535. width: 256,
  4536. height: 80
  4537. }, {
  4538. name: "zombie",
  4539. src: "zombie.png",
  4540. width: 256,
  4541. height: 80
  4542. }, {
  4543. name: "cyborg",
  4544. src: "cyborg.png",
  4545. width: 256,
  4546. height: 80
  4547. }, {
  4548. name: "ape",
  4549. src: "ape.png",
  4550. width: 256,
  4551. height: 80
  4552. }, {
  4553. name: "Amoeba",
  4554. src: "Amoeba.png",
  4555. width: 256,
  4556. height: 80
  4557. }, {
  4558. name: "back",
  4559. src: "back.png",
  4560. width: 257,
  4561. height: 355
  4562. }];
  4563. window.onload = function() {
  4564. GET = Utils.parseGet();
  4565. Utils.addMobileListeners();
  4566. ExternalAPI.init();
  4567. setTimeout(startLoad, 600)
  4568. };
  4569. var current_game_mode = 0;
  4570. var lastBackground = null;
  4571. var tempRouletteArray = [],
  4572. rouletteProbability = {
  4573. T_AMOEBA: {
  4574. n: 30,
  4575. v: 1
  4576. },
  4577. T_JELLYFISH: {
  4578. n: 20,
  4579. v: 2
  4580. },
  4581. T_SMARTFISH: {
  4582. n: 17,
  4583. v: 3
  4584. },
  4585. T_LIZARD: {
  4586. n: 13,
  4587. v: 4
  4588. },
  4589. T_WOLF: {
  4590. n: 10,
  4591. v: 5
  4592. },
  4593. T_APE: {
  4594. n: 7,
  4595. v: 6
  4596. },
  4597. T_HOMOSAPIENS: {
  4598. n: 3,
  4599. v: 7
  4600. }
  4601. };
  4602. var startScrollPosition, scrollLocked = !1,
  4603. clickForbidden = !0;
  4604. var field;
  4605. var maxUnlockedItem = {
  4606. t: 3,
  4607. newUnlocked: !1
  4608. },
  4609. GameElement = function(e, t) {
  4610. var n = this;
  4611. e = ~~e;
  4612. "ultimate" == currentDifficulty && e > maxUnlockedItem.t && 10 > e && !maxUnlockedItem.newUnlocked && (maxUnlockedItem.t = e);
  4613. if (8 == e) {
  4614. var r = Math.ceil(6 * Math.random());
  4615. maxUnlockedItem.t = r;
  4616. maxUnlockedItem.newUnlocked = !0;
  4617. EL_BMP[T_UNKNOWN] = "unknown" + r;
  4618. Utils.getCookie("icon1" + r + "ul") || (Utils.setCookie("icon1" + r + "ul", !0), field.upgradeType = 10 + r, stage.setTimeout(function() {
  4619. showEvolutionPopup(10 + r, function() {})
  4620. }, 5))
  4621. }
  4622. var i = e == T_EMPTY ? new Sprite(null, 45, 45, 1, 1) : library.getAsset(EL_BMP[e]);
  4623. t && maxUnlockedItem.newUnlocked && (i = library.getAsset(EL_BMP[T_UNKNOWN]));
  4624. GameElement.superclass.constructor.call(this, i.bitmap, ~~i.width, ~~i.height, ~~i.frames, ~~i.layers);
  4625. this.gametype = e;
  4626. this.currentLayer = this.currentFrame = 0;
  4627. this.moved = !1;
  4628. this.setType = function(e) {
  4629. var t = e == T_EMPTY ? new Sprite(null, 45, 45, 1, 1) : library.getAsset(EL_BMP[~~e]);
  4630. this.gametype = ~~e;
  4631. this.bitmap = t.bitmap;
  4632. this.width = ~~t.width;
  4633. this.height = ~~t.height;
  4634. this.totalFrames = ~~t.frames;
  4635. this.totalLayers = ~~t.layers;
  4636. this.currentLayer = this.currentFrame = 0
  4637. };
  4638. this.blink = function() {
  4639. n.fadeTo(.3, 6, Easing.cubic.easeOut, function(e) {
  4640. n.fadeTo(1, 1, Easing.linear.easeIn)
  4641. })
  4642. }
  4643. };
  4644. Utils.extend(GameElement, Sprite);
  4645. var GameField = function(e) {
  4646. var t = this;
  4647. GameField.superclass.constructor.call(this);
  4648. this.level = e;
  4649. this.size = e.field;
  4650. this.nextElement = new GameElement;
  4651. this.storedElement = new GameElement(T_EMPTY);
  4652. this.getTypes = function() {
  4653. for (var e = [], t = 0; t < this.length; t++) e.push(this[t].gametype);
  4654. return e
  4655. };
  4656. this.setTypes = function(e) {
  4657. for (var t = 0; t < e.length; t++) t < this.length && this[t].setType(~~e[t])
  4658. };
  4659. this.getElementId = function(e) {
  4660. for (var t = 0; t < this.length; t++)
  4661. if (this[t] === e) return t
  4662. };
  4663. this.create = function() {
  4664. for (var e = new Sprite(null, 45, 45, 1, 1), e = new Vector(e.width + 6, e.height + 6), n = new Vector(160 - t.size.x * e.x / 2 + e.x / 2, 282 - t.size.y * e.y / 2 + e.y / 2), r = 0; r < t.size.y; r++)
  4665. for (var i = 0; i < t.size.x; i++) {
  4666. var s = new GameElement;
  4667. this.push(s);
  4668. s.type = "gameCell";
  4669. s.x = n.x + e.x * i;
  4670. s.y = n.y + e.y * r;
  4671. s.onmouseup = t.clickHandler;
  4672. stage.addChild(s)
  4673. }
  4674. t.init();
  4675. e = t.generateNextType();
  4676. t.nextElement = new GameElement(e);
  4677. t.nextElement.setPosition(57, 118);
  4678. t.nextElement.onmouseup = function() {
  4679. if (tutorialActivated) return !1;
  4680. t.swapStack()
  4681. };
  4682. stage.addChild(t.nextElement);
  4683. t.storedElement = new GameElement(T_EMPTY);
  4684. t.storedElement.setPosition(235, 118);
  4685. t.storedElement.onmouseup = function() {
  4686. tutorialActivated || t.swapStack();
  4687. if (tutorialActivated && (tut04completed && !tut05completed || tut07completed && !tut08completed)) return t.swapStack(), tutDone(), !0
  4688. };
  4689. stage.addChild(t.storedElement);
  4690. checkIfNeedLaunchTutorial(t.size.x * t.size.y, t)
  4691. };
  4692. this.init = function() {
  4693. var e = t.size.x * t.size.y;
  4694. initializeUserScore();
  4695. currentDifficulty = t.level.name;
  4696. checkDifficulty();
  4697. if ("easy" != currentDifficulty || !tutorialActivated)
  4698. if ("medium" != currentDifficulty || !tutorialActivated)
  4699. if ("hard" != currentDifficulty || !tutorialActivated)
  4700. for (var n in t.level.init)
  4701. for (var r = t.level.init[n]; 0 < r;) {
  4702. for (var i = Math.floor(Math.random() * e); t[i].gametype > T_EMPTY;) i = Math.floor(Math.random() * e);
  4703. t[i].setType(n);
  4704. r--
  4705. }
  4706. };
  4707. this.generateNextType = function() {
  4708. if (tutorialActivated) return tut02completed || "easy" != currentDifficulty ? tut03completed || "easy" != currentDifficulty ? tut06completed && !tut07completed && "easy" == currentDifficulty ? T_ICE : tut10completed || "medium" != currentDifficulty ? tut11completed || "hard" != currentDifficulty ? tut12completed || "hard" != currentDifficulty ? tut13completed || "hard" != currentDifficulty ? T_AMOEBA : T_UFO : T_FIRE : T_UFO : T_ETHER : T_FIRE : T_AMOEBA;
  4709. var e = t.level.elements,
  4710. n = 0,
  4711. r;
  4712. for (r in e) n += e[r];
  4713. n = Math.floor(Math.random() * n);
  4714. for (r in e)
  4715. if (n -= e[r], 0 >= n) return r;
  4716. return T_AMOEBA
  4717. };
  4718. this.getUpgradeType = function(e) {
  4719. for (var n = t.level.upgrades, r = 0; r < n.length; r++)
  4720. if (n[r] == e) return field.upgradeType = n[r + 1], ++r < n.length ? n[r] : 0;
  4721. return 0
  4722. };
  4723. this.locked = !1;
  4724. this.swapStack = function(e) {
  4725. if (t.locked || t.nextElement.gametype == T_UFO) return !1;
  4726. e = new GameElement(t.nextElement.gametype);
  4727. e.setPosition(t.nextElement.x, t.nextElement.y);
  4728. var n = new GameElement(t.storedElement.gametype);
  4729. n.setPosition(t.storedElement.x, t.storedElement.y);
  4730. t.nextElement.visible = !1;
  4731. stage.addChild(e);
  4732. t.locked = !0;
  4733. e.moveTo(t.storedElement.x, t.storedElement.y, 6, Easing.cubic.easeIn, function(e) {
  4734. t.storedElement.setType(e.target.obj.gametype);
  4735. t.storedElement.visible = !0;
  4736. stage.removeChild(e.target.obj);
  4737. t.locked = !1
  4738. });
  4739. n.gametype > T_EMPTY ? (t.storedElement.visible = !1, stage.addChild(n), n.moveTo(t.nextElement.x, t.nextElement.y, 6, Easing.cubic.easeIn, function(e) {
  4740. t.nextElement.setType(e.target.obj.gametype);
  4741. t.nextElement.visible = !0;
  4742. stage.removeChild(e.target.obj)
  4743. })) : (e = t.generateNextType(), t.nextElement.setType(e), t.nextElement.visible = !0);
  4744. 0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("swap_stack", !1, !1, 0)
  4745. };
  4746. this.clickHandler = function(e) {
  4747. if (blockForTutorial) return !0;
  4748. if (t.locked) return !1;
  4749. var n = e.target;
  4750. e = new GameElement(t.nextElement.gametype);
  4751. e.setPosition(t.nextElement.x, t.nextElement.y);
  4752. var r = !1;
  4753. switch (n.gametype) {
  4754. case T_EMPTY:
  4755. if (e.gametype == T_FIRE) {
  4756. n.blink();
  4757. break
  4758. }
  4759. if (e.gametype == T_ETHER) {
  4760. var r = t.getTypes(),
  4761. r = new ChainFinder(r, CHAIN_LENGTH, t.size.x, !1),
  4762. i = t.getElementId(n),
  4763. i = r.findPossibleChains(i),
  4764. s = -1;
  4765. if (i)
  4766. for (var o in i) r.checkChainLength(i[o]) && ~~o > s && 0 < t.getUpgradeType(~~o) && (s = ~~o);
  4767. e.gametype = 1 > s ? T_ICE : s
  4768. }
  4769. t.locked = !0;
  4770. stage.addChild(e);
  4771. e.moveTo(n.x, n.y, 12, Easing.circular.easeOut, function(e) {
  4772. n.setType(e.target.obj.gametype);
  4773. e.target.obj.removeTweens();
  4774. stage.removeChild(e.target.obj);
  4775. t.locked = !1;
  4776. t.upgradeChains(n)
  4777. });
  4778. r = !0;
  4779. e.gametype == T_ICE ? 0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("ice_add", !1, !1, 0) : 0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("element_add", !1, !1, 0);
  4780. break;
  4781. default:
  4782. e.gametype == T_FIRE ? (stage.addChild(e), t.locked = !0, e.moveTo(n.x, n.y, 6, Easing.linear.easeOut, function(e) {
  4783. e.target.obj.removeTweens();
  4784. e.target.obj.fadeTo(0, 12, Easing.circular.easeOut, function(e) {
  4785. stage.removeChild(e.target.obj)
  4786. });
  4787. t.locked = !1;
  4788. n.gametype == T_UFO ? (n.setType(T_EMPTY), e = new GameElement(T_UFO), e.setPosition(n.x, n.y), stage.addChild(e), t.nextElement.fadeTo(0, 12, Easing.linear.easeIn), e.moveTo(t.nextElement.x, t.nextElement.y, 12, Easing.cubic.easeOut, function(e) {
  4789. e.target.obj.fadeTo(0, 12, Easing.linear.easeIn, function(e) {
  4790. stage.removeChild(e.target.obj);
  4791. t.moveAliens()
  4792. });
  4793. t.nextElement.setType(T_ETHER);
  4794. t.nextElement.fadeTo(1, 12, Easing.linear.easeIn)
  4795. }), 0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("alien_death", !1, !1, 0)) : (n.setType(T_EMPTY), 0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("element_burn", !1, !1, 0));
  4796. t.moveAliens()
  4797. }), r = !0) : n.blink()
  4798. }
  4799. r && t.nextElement.setType(t.generateNextType())
  4800. };
  4801. this.upgradeChains = function(e) {
  4802. t.locked = !0;
  4803. for (var n = t.getTypes(), n = (new ChainFinder(n, CHAIN_LENGTH, t.size.x, !1)).findChains(), r = 0, i = 0; i < n.length; i++) {
  4804. var s = n[i];
  4805. if (!(0 > s.indexOf(t.getElementId(e)))) {
  4806. var o = t.getUpgradeType(e.gametype);
  4807. if (!(1 > o)) {
  4808. 8 == o ? 0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("new_superhuman", !1, !1, 0) : 0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("new_element", !1, !1, 0);
  4809. r++;
  4810. for (var u = 0; u < s.length; u++) {
  4811. var a = s[u];
  4812. if (t[a] !== e) {
  4813. var f = new GameElement(t[a].gametype);
  4814. f.setPosition(t[a].x, t[a].y);
  4815. stage.addChild(f);
  4816. t[a].setType(T_EMPTY);
  4817. f.moveTo(e.x, e.y, 6, Easing.linear.easeIn, function(e) {
  4818. e.target.obj.removeTweens();
  4819. stage.removeChild(e.target.obj)
  4820. })
  4821. }
  4822. }
  4823. s = new GameElement(o);
  4824. s.setPosition(e.x, e.y);
  4825. s.opacity = 0;
  4826. stage.addChild(s);
  4827. s.fadeTo(1, 12, Easing.linear.easeIn, function(n) {
  4828. e.setType(n.target.obj.gametype);
  4829. n.target.obj.removeTweens();
  4830. stage.removeChild(n.target.obj);
  4831. var r = getScore() + ~~EL_SCORE[e.gametype];
  4832. checkIfNeedPopup(function() {
  4833. setScore(r, ~~EL_SCORE[e.gametype], e.x, e.y);
  4834. t.upgradeChains(e)
  4835. })
  4836. })
  4837. }
  4838. }
  4839. }
  4840. 1 > r && (t.locked = !1, t.moveAliens())
  4841. };
  4842. this.moveAliens = function() {
  4843. t.locked = !0;
  4844. var e = function() {
  4845. for (var e = 0; e < t.length; e++)
  4846. if (t[e].gametype == T_UFO && !t[e].moved) return e;
  4847. return -1
  4848. }();
  4849. if (0 > e) {
  4850. for (e = 0; e < t.length; e++) t[e].gametype == T_UFO && (t[e].moved = !1);
  4851. t.locked = !1;
  4852. return t.checkGameOver()
  4853. }
  4854. var n = function(e, n) {
  4855. var r = e % t.size.x,
  4856. i = Math.floor(e / t.size.y),
  4857. s = [];
  4858. 0 < r && (n && t[e - 1].gametype !== T_EMPTY || s.push(e - 1));
  4859. r + 1 < t.size.x && (n && t[e + 1].gametype !== T_EMPTY || s.push(e + 1));
  4860. 0 < i && (n && t[e - t.size.y].gametype !== T_EMPTY || s.push(e - t.size.y));
  4861. i + 1 < t.size.y && (n && t[e + t.size.y].gametype !== T_EMPTY || s.push(e + t.size.y));
  4862. return s
  4863. }(e, !0);
  4864. if (1 > n.length) {
  4865. t[e].setType(T_EMPTY);
  4866. var r = new GameElement(T_UFO);
  4867. r.setPosition(t[e].x, t[e].y);
  4868. stage.addChild(r);
  4869. t.nextElement.fadeTo(0, 12, Easing.linear.easeIn);
  4870. r.moveTo(t.nextElement.x, t.nextElement.y, 12, Easing.cubic.easeOut, function(e) {
  4871. e.target.obj.fadeTo(0, 12, Easing.linear.easeIn, function(e) {
  4872. stage.removeChild(e.target.obj);
  4873. t.moveAliens()
  4874. });
  4875. t.nextElement.setType(T_ETHER);
  4876. t.nextElement.fadeTo(1, 12, Easing.linear.easeIn)
  4877. })
  4878. } else {
  4879. var i = Math.floor(Math.random() * n.length);
  4880. t[n[i]].gametype = null;
  4881. t[e].setType(T_EMPTY);
  4882. r = new GameElement(T_UFO);
  4883. r.setPosition(t[e].x, t[e].y);
  4884. stage.addChild(r);
  4885. r.targetID = n[i];
  4886. r.moveTo(t[n[i]].x, t[n[i]].y, 6, Easing.linear.easeIn, function(e) {
  4887. t[e.target.obj.targetID].setType(T_UFO);
  4888. t[e.target.obj.targetID].moved = !0;
  4889. stage.removeChild(e.target.obj);
  4890. t.moveAliens()
  4891. })
  4892. }
  4893. 0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("alien_move", !1, !1, 0)
  4894. };
  4895. this.checkGameOver = function() {
  4896. for (var e = current_game_mode == D_ULTIMATE, n = t.level.upgrades[t.level.upgrades.length - 1], r = t.length, i = 0; i < t.length; i++) {
  4897. if (t[i].gametype === n && !e) {
  4898. gameState = STATE_VICTORY;
  4899. createScene();
  4900. return
  4901. }
  4902. t[i].gametype !== T_EMPTY && r--
  4903. }
  4904. 1 > r && (gameState = e ? STATE_VICTORY : STATE_DEFEAT, createScene())
  4905. }
  4906. };
  4907. Utils.extend(GameField, Array);
  4908. var score;
  4909. var slidesNumber = 0;
  4910. var tutorialActivated = !1,
  4911. tut01completed = !1,
  4912. tut02completed = !1,
  4913. tut03completed = !1,
  4914. tut04completed = !1,
  4915. tut05completed = !1,
  4916. tut06completed = !1,
  4917. tut07completed = !1,
  4918. tut08completed = !1,
  4919. tut09completed = !1,
  4920. tut10completed = !1,
  4921. tut11completed = !1,
  4922. tut12completed = !1,
  4923. tut12_1completed = !1,
  4924. tut13completed = !1,
  4925. tut14completed = !1,
  4926. tut15completed = !1,
  4927. blockForTutorial = !1,
  4928. tutArray = [],
  4929. gameElementArray = [];