12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021 |
- function ImagesPreloader() {
- function e() {
- var n = 0,
- r = 0,
- i;
- for (i in t.loadedImages) t.loadedImages[i].complete && n++, r++;
- n >= r ? t.endCallback && t.endCallback(t.loadedImages) : (t.processCallback && t.processCallback(Math.floor(n / r * 100)), setTimeout(e, 50))
- }
- var t = this;
- this.curItem = -1;
- this.loadedImages = {};
- this.processCallback = this.endCallback = this.data = null;
- this.load = function(t, n, r) {
- this.data = t;
- this.endCallback = n;
- this.processCallback = r;
- for (t = 0; t < this.data.length; t++) n = this.data[t], r = new Image, r.src = n.src, this.loadedImages[n.name] = r;
- e()
- }
- }
- function Sprite(e, t, n, r, i) {
- this.uid = 0;
- this.stage = null;
- this.y = this.x = 0;
- this.width = t;
- this.height = n;
- this.offset = {
- left: 0,
- top: 0
- };
- this.anchor = {
- x: 0,
- y: 0
- };
- this.scaleY = this.scaleX = 1;
- this.zIndex = this.rotation = 0;
- this.visible = !0;
- this.opacity = 1;
- this.ignoreViewport = this["static"] = !1;
- this.animated = !0;
- this.currentFrame = 0;
- this.totalFrames = Math.max(1, ~~r);
- 1 >= this.totalFrames && (this.animated = !1);
- this.currentLayer = 0;
- this.totalLayers = Math.max(1, ~~i);
- this.bitmap = e;
- this.mask = null;
- this.destroy = this.fillColor = !1;
- this.animStep = 0;
- this.animDelay = 1;
- this.dragged = this.drawAlways = !1;
- this.dragY = this.dragX = 0;
- this.getX = function() {
- return Math.round(this.x * Utils.globalScale)
- };
- this.getY = function() {
- return Math.round(this.y * Utils.globalScale)
- };
- this.getWidth = function() {
- return this.width * Math.abs(this.scaleX) * Utils.globalScale
- };
- this.getHeight = function() {
- return this.height * Math.abs(this.scaleY) * Utils.globalScale
- };
- this.startDrag = function(e, t) {
- this.dragged = !0;
- this.dragX = e;
- this.dragY = t
- };
- this.stopDrag = function() {
- this.dragged = !1;
- this.dragY = this.dragX = 0
- };
- this.play = function() {
- this.animated = !0
- };
- this.stop = function() {
- this.animated = !1
- };
- this.gotoAndStop = function(e) {
- this.currentFrame = e;
- this.stop()
- };
- this.gotoAndPlay = function(e) {
- this.currentFrame = e;
- this.play()
- };
- this.removeTweens = function() {
- this.stage && this.stage.clearObjectTweens(this)
- };
- this.addTween = function(e, t, n, r, i, s) {
- if (this.stage) {
- var o = this[e];
- if (!isNaN(o)) return e = stage.createTween(this, e, o, t, n, r), e.onchange = s, e.onfinish = i, e
- }
- };
- this.moveTo = function(e, t, n, r, i, s) {
- n = ~~n;
- 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());
- return this
- };
- this.moveBy = function(e, t, n, r, i, s) {
- return this.moveTo(this.x + e, this.y + t, n, r, i, s)
- };
- this.fadeTo = function(e, t, n, r, i) {
- t = ~~t;
- 0 >= t ? this.opacity = e : (e = this.addTween("opacity", e, t, n, r, i)) && e.play();
- return this
- };
- this.fadeBy = function(e, t, n, r, i) {
- e = Math.max(0, Math.min(1, this.opacity + e));
- return this.fadeTo(e, t, n, r, i)
- };
- this.rotateTo = function(e, t, n, r, i) {
- t = ~~t;
- 0 >= t ? this.rotation = e : (e = this.addTween("rotation", e, t, n, r, i)) && e.play();
- return this
- };
- this.rotateBy = function(e, t, n, r, i) {
- return this.rotateTo(this.rotation + e, t, n, r, i)
- };
- this.scaleTo = function(e, t, n, r, i) {
- t = ~~t;
- if (0 >= t) this.scaleX = this.scaleY = e;
- else {
- var s = this.addTween("scaleX", e, t, n, r, i);
- s && s.play();
- (e = this.addTween("scaleY", e, t, n, s ? null : r, s ? null : i)) && e.play()
- }
- return this
- };
- this.nextFrame = function() {
- this.dispatchEvent("enterframe", {
- target: this
- });
- this.animated && (this.animStep++, this.animStep >= this.animDelay && (this.currentFrame++, this.animStep = 0), this.currentFrame >= this.totalFrames && (this.currentFrame = 0))
- };
- this.eventsWhenInvisible = !1;
- 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;
- this.mouseOn = !1;
- this.getPosition = function() {
- return {
- x: this.x,
- y: this.y
- }
- };
- this.setPosition = function(e, t) {
- if ("undefined" == typeof t && "undefined" != typeof e.x && "undefined" != typeof e.y) return this.setPosition(e.x, e.y);
- this.x = parseFloat(e);
- this.y = parseFloat(t)
- };
- this.getAnchor = function() {
- return this.anchor
- };
- this.setAnchor = function(e, t) {
- if ("undefined" == typeof t && "undefined" != typeof e.x && "undefined" != typeof e.y) return this.setAnchor(e.x, e.y);
- this.anchor.x = parseFloat(e);
- this.anchor.y = parseFloat(t)
- };
- this.alignAnchor = function(e, t) {
- e = parseInt(e);
- isNaN(e) && (e = ANCHOR_ALIGN_CENTER);
- 0 > e && (e = ANCHOR_ALIGN_LEFT);
- 0 < e && (e = ANCHOR_ALIGN_RIGHT);
- t = parseInt(t);
- isNaN(t) && (t = ANCHOR_VALIGN_MIDDLE);
- 0 > t && (t = ANCHOR_VALIGN_TOP);
- 0 < t && (t = ANCHOR_VALIGN_BOTTOM);
- this.anchor.x = this.width * e / 2;
- this.anchor.y = this.height * t / 2;
- return this.getAnchor()
- };
- this.getAbsoluteAnchor = function() {
- return this.getPosition()
- };
- this.getRelativeCenter = function() {
- var e = this.getAnchor();
- if (0 == e.x && 0 == e.y) return e;
- e = new Vector(-e.x * this.scaleX, -e.y * this.scaleY);
- e.rotate(-this.rotation);
- return e
- };
- this.getAbsoluteCenter = function() {
- var e = this.getRelativeCenter(),
- e = {
- x: e.x,
- y: e.y
- };
- e.x += this.x;
- e.y += this.y;
- return e
- };
- this.getCenter = function() {
- return this.getAbsoluteCenter()
- };
- this.getDrawRectangle = function() {
- var e = this.getCenter(),
- t = new Rectangle(0, 0, this.width * Math.abs(this.scaleX), this.height * Math.abs(this.scaleY), this.rotation);
- t.move(e.x, e.y);
- return t
- };
- this.getAABBRectangle = function() {
- var e = this.getDrawRectangle(),
- t = e.AABB[1].x - e.AABB[0].x,
- n = e.AABB[1].y - e.AABB[0].y;
- return new Rectangle(e.AABB[0].x + t / 2, e.AABB[0].y + n / 2, t, n, 0)
- };
- this.localToGlobal = function(e, t) {
- 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);
- n.rotate(this.rotation).add(this.getPosition());
- return n
- };
- this.globalToLocal = function(e, t) {
- 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);
- n.subtract(this.getPosition()).rotate(-this.rotation);
- return n
- };
- this.allowDebugDrawing = !0;
- this.debugDraw = function() {
- if (this.visible && this.allowDebugDrawing) {
- var e = this.getPosition(),
- t = this.getCenter(),
- n = this.getDrawRectangle(),
- r = this.getAABBRectangle();
- stage.drawCircle(e.x, e.y, 1, 1, "rgba(255,0,0,0.9)");
- stage.drawCircle(t.x, t.y, 1, 1, "rgba(0,255,0,0.9)");
- stage.drawLine(e.x, e.y, t.x, t.y, 1, "rgba(255,255,255,0.5)");
- stage.drawPolygon(n.vertices, .5, "rgba(255,0,255,0.5)", 1);
- 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)");
- 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)");
- stage.drawPolygon(r.vertices, .5, "rgba(255,255,255,0.5)")
- }
- };
- this.setZIndex = function(e) {
- this.zIndex = ~~e;
- this.stage && this.stage.setZIndex(this, ~~e)
- };
- this.eventsListeners = [];
- this.addEventListener = function(e, t) {
- EventsManager.addEvent(this, e, t)
- };
- this.removeEventListener = function(e, t) {
- EventsManager.removeEvent(this, e, t)
- };
- this.dispatchEvent = function(e, t) {
- return EventsManager.dispatchEvent(this, e, t)
- };
- this.hitTestPoint = function(e, t, n, r, i) {
- return this.stage ? this.stage.hitTestPointObject(this, e, t, n, r, i) : !1
- }
- }
- function Tween(e, t, n, r, i, s) {
- var o = this;
- "object" != typeof e && (e = null);
- if (e) {
- if ("undefined" == typeof e[t]) throw Error('Trying to tween undefined property "' + t + '"');
- if (isNaN(e[t])) throw Error("Tweened value can not be " + typeof e[t])
- } else if (isNaN(t)) throw Error("Tweened value can not be " + typeof t);
- "function" != typeof s && (s = Easing.linear.easeIn);
- this.obj = e;
- this.prop = t;
- this.onfinish = this.onchange = null;
- this.start = n;
- this.end = r;
- this.duration = ~~i;
- this.callback = s;
- this.playing = !1;
- this._pos = -1;
- this.play = function() {
- o.playing = !0;
- o.tick()
- };
- this.pause = function() {
- o.playing = !1
- };
- this.rewind = function() {
- o._pos = -1
- };
- this.forward = function() {
- o._pos = this.duration
- };
- this.stop = function() {
- o.rewind();
- o.tick();
- o.pause()
- };
- this.updateValue = function(e) {
- o.obj ? o.obj[o.prop] = e : o.prop = e
- };
- this.tick = function() {
- if (!o.playing) return !1;
- o._pos++;
- if (0 > o._pos) return !1;
- if (o._pos > o.duration) return o.finish();
- var e = o.callback,
- e = e(o._pos, o.start, o.end - o.start, o.duration);
- this.updateValue(e);
- o.dispatchEvent("change", {
- target: o,
- value: e
- });
- return !1
- };
- this.finish = function() {
- o.stop();
- o.updateValue(o.end);
- return o.dispatchEvent("finish", {
- target: o,
- value: o.end
- })
- };
- this.eventsListeners = [];
- this.addEventListener = function(e, t) {
- EventsManager.addEvent(this, e, t)
- };
- this.removeEventListener = function(e, t) {
- EventsManager.removeEvent(this, e, t)
- };
- this.dispatchEvent = function(e, t) {
- return EventsManager.dispatchEvent(this, e, t)
- }
- }
- function StageTimer(a, c, d) {
- this.repeat = d;
- this.timeout = this.initialTimeout = c;
- this.callback = a;
- this.paused = !1;
- this.update = function() {
- if (!this.paused) {
- this.timeout--;
- if (0 >= this.timeout)
- if ("function" == typeof this.callback && this.callback(), "string" == typeof this.callback && eval(this.callback), this.repeat) this.timeout = this.initialTimeout;
- else return !0;
- return !1
- }
- };
- this.resume = function() {
- this.paused = !1
- };
- this.pause = function() {
- this.paused = !0
- }
- }
- function Stage(e, t, n) {
- function r() {
- s.lastFPS = s.fps;
- s.fps = 0;
- s.started && (s.tmFPS = setTimeout(r, 1e3))
- }
- function i() {
- clearTimeout(s.tmMain);
- var e = (new Date).getTime();
- s.updateTweens();
- s.updateTimers();
- s.dispatchEvent("pretick");
- s.drawScene(s.canvas, !1);
- s.showFPS && (s.setTextStyle("sans-serif", 10, "bold", "#fff", "#000"), s.drawText("FPS: " + s.lastFPS, 2, 10, 1, !0));
- s.dispatchEvent("posttick");
- e = (new Date).getTime() - e;
- e = s.delay - e - 1;
- 1 > e && (e = 1);
- s.fps++;
- s.started && (s.tmMain = setTimeout(i, e))
- }
- var s = this;
- this.canvas = null;
- e && (this.canvas = document.getElementById(e), this.canvas.ctx = this.canvas.getContext("2d"));
- this.backBuffer = null;
- this.screenWidth = t;
- this.screenHeight = n;
- this.viewport = {
- x: 0,
- y: 0
- };
- this.objects = [];
- this.objectsCounter = 0;
- try {
- this.buffer = document.createElement("canvas"), this.buffer.width = t * Utils.globalScale, this.buffer.height = n * Utils.globalScale, this.buffer.ctx = this.buffer.getContext("2d")
- } catch (o) {
- this.buffer = this.canvas
- }
- this.delay = 40;
- this.started = this.fillColor = !1;
- this.lastFPS = this.fps = 0;
- this.ceilSizes = this.pixelMouseMoveEvent = this.pixelMouseDownEvent = this.pixelMouseUpEvent = this.pixelClickEvent = this.showFPS = !1;
- this.tmMain;
- this.tmFPS;
- this.clearLock = !1;
- this.destroy = function() {
- clearTimeout(this.tmMain);
- clearTimeout(this.tmFPS);
- this.stop();
- this.clear();
- this.clearScreen(this.canvas)
- };
- this.clearScreen = function(e) {
- this.clearLock || e.ctx.clearRect(0, 0, this.screenWidth * Utils.globalScale * Utils.globalPixelScale, this.screenHeight * Utils.globalScale * Utils.globalPixelScale)
- };
- this.findMaxZIndex = function() {
- 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);
- return {
- index: t,
- zIndex: e
- }
- };
- this.findMinZIndex = function() {
- 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);
- return {
- index: t,
- zIndex: e
- }
- };
- this.addChild = function(e) {
- var t = this.findMaxZIndex(),
- n = e.zIndex;
- e.zIndex = !1 !== t.index ? t.zIndex + 1 : 0;
- this.objectsCounter++;
- e.uid = this.objectsCounter;
- e.stage = this;
- this.objects.push(e);
- 0 != n && this.setZIndex(e, ~~n);
- e.dispatchEvent("add", {
- target: e
- });
- return e
- };
- this.removeChild = function(e) {
- e && (this.clearObjectTweens(e), e.dispatchEvent("remove", {
- target: e
- }), e.stage = null, this.objects = Utils.removeFromArray(this.objects, e))
- };
- this.setZIndex = function(e, t) {
- e.zIndex = t;
- this.objects = this.objects.sort(function(e, t) {
- return e.zIndex == t.zIndex ? e.uid > t.uid ? 1 : -1 : e.zIndex > t.zIndex ? 1 : -1
- })
- };
- this.hitTestPointObject = function(e, t, n, r, i, s) {
- var o, u, a, f, l, c;
- a = e.width * Math.abs(e.scaleX);
- f = e.height * Math.abs(e.scaleY);
- o = e.x - a / 2;
- u = e.y - f / 2;
- l = t;
- c = n;
- e.ignoreViewport || (l += this.viewport.x, c += this.viewport.y);
- s = !1;
- 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));
- 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));
- !s && i && e.dragged && (s = !0);
- return s
- };
- this.getObjectsStackByCoord = function(e, t, n, r, i) {
- for (var s, o = [], u = 0; u < this.objects.length; u++)
- if (this.objects[u].visible || this.objects[u].eventsWhenInvisible) s = this.objects[u], this.hitTestPointObject(s, e, t, n, r, i) && o.push(s);
- return o
- };
- this.getMaxZIndexInStack = function(e) {
- for (var t = -1, n = 0, r = 0; r < e.length; r++) e[r].zIndex > t && (t = e[r].zIndex, n = r);
- return n
- };
- this.sortStack = function(e, t) {
- for (var n = !0, r, i; n;)
- 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);
- return e
- };
- this.finalizeMouseCoords = function(e, t) {
- if (!e) return t;
- var n = this.prepareMouseCoord(t.x),
- r = this.prepareMouseCoord(t.y);
- e.ignoreViewport || (n += this.viewport.x, r += this.viewport.y);
- n -= e.x;
- r -= e.y;
- return {
- x: n,
- y: r
- }
- };
- this.prepareMouseCoord = function(e) {
- return e / Utils.globalScale / Utils.globalPixelScale
- };
- this.checkClick = function(e) {
- e = Utils.getMouseCoord(e, this.inputController);
- var t = this.getObjectsStackByCoord(this.prepareMouseCoord(e.x), this.prepareMouseCoord(e.y), this.pixelClickEvent, !1, !0),
- n;
- if (0 < t.length)
- for (var t = this.sortStack(t), r = 0; r < t.length && (n = this.finalizeMouseCoords(t[r], e), n = t[r].dispatchEvent("click", {
- target: t[r],
- x: n.x,
- y: n.y
- }), !1 !== n); r++);
- };
- this.checkContextMenu = function(e) {
- e = Utils.getMouseCoord(e, this.inputController);
- var t = this.getObjectsStackByCoord(this.prepareMouseCoord(e.x), this.prepareMouseCoord(e.y), this.pixelClickEvent),
- n;
- if (0 < t.length)
- for (var t = this.sortStack(t), r = 0; r < t.length && (n = this.finalizeMouseCoords(t[r], e), n = t[r].dispatchEvent("contextmenu", {
- target: t[r],
- x: n.x,
- y: n.y
- }), !1 !== n); r++);
- };
- this.checkMouseMove = function(e) {
- e = Utils.getMouseCoord(e, this.inputController);
- for (r = 0; r < this.objects.length; r++)
- if (this.objects[r].dragged) {
- var t = e.x / Utils.globalScale / Utils.globalPixelScale,
- n = e.y / Utils.globalScale / Utils.globalPixelScale;
- this.objects[r].ignoreViewport || (t += this.viewport.x, n += this.viewport.y);
- this.objects[r].x = t - this.objects[r].dragX;
- this.objects[r].y = n - this.objects[r].dragY
- }
- var t = this.getObjectsStackByCoord(this.prepareMouseCoord(e.x), this.prepareMouseCoord(e.y), this.pixelMouseMoveEvent),
- r, i, s, n = [];
- if (0 < t.length) {
- t = this.sortStack(t);
- for (r = 0; r < t.length && (n.push(t[r]), s = this.finalizeMouseCoords(t[r], e), t[r].mouseOn || (i = t[r].dispatchEvent("mouseover", {
- target: t[r],
- x: s.x,
- y: s.y
- })), t[r].mouseOn = !0, !1 !== i); r++);
- for (r = 0; r < t.length && (s = this.finalizeMouseCoords(t[r], e), i = t[r].dispatchEvent("mousemove", {
- target: t[r],
- x: s.x,
- y: s.y
- }), !1 !== i); r++);
- }
- for (r = 0; r < this.objects.length; r++)
- if (this.objects[r].mouseOn) {
- s = !1;
- for (i = 0; i < n.length; i++) n[i] == this.objects[r] && (s = !0);
- if (!s && (this.objects[r].mouseOn = !1, s = this.finalizeMouseCoords(t[r], e), i = this.objects[r].dispatchEvent("mouseout", {
- target: this.objects[r],
- x: s.x,
- y: s.y
- }), !1 === i)) break
- }
- };
- this.checkMouseDown = function(e) {
- e = Utils.getMouseCoord(e, this.inputController);
- var t = this.getObjectsStackByCoord(this.prepareMouseCoord(e.x), this.prepareMouseCoord(e.y), this.pixelMouseDownEvent),
- n;
- if (0 < t.length)
- for (var t = this.sortStack(t), r = 0; r < t.length && (n = this.finalizeMouseCoords(t[r], e), n = t[r].dispatchEvent("mousedown", {
- target: t[r],
- x: n.x,
- y: n.y
- }), !1 !== n); r++);
- };
- this.checkMouseUp = function(e) {
- e = Utils.getMouseCoord(e, this.inputController);
- var t = this.getObjectsStackByCoord(this.prepareMouseCoord(e.x), this.prepareMouseCoord(e.y), this.pixelMouseUpEvent, !0),
- n;
- if (0 < t.length)
- for (var t = this.sortStack(t), r = 0; r < t.length && (n = this.finalizeMouseCoords(t[r], e), n = t[r].dispatchEvent("mouseup", {
- target: t[r],
- x: n.x,
- y: n.y
- }), !1 !== n); r++);
- };
- this.clear = function() {
- for (var e = 0; e < this.objects.length; e++) this.objects[e].dispatchEvent("remove", {
- target: this.objects[e]
- });
- this.objects = [];
- this.tweens = [];
- this.timers = [];
- this.eventsListeners = [];
- this.objectsCounter = 0
- };
- this.hitTest = function(e, t) {
- if (0 == e.rotation && 0 == t.rotation) {
- var n = e.getX() - e.getWidth() / 2,
- r = e.getY() - e.getHeight() / 2,
- i = t.getX() - t.getWidth() / 2,
- s = t.getY() - t.getHeight() / 2,
- o = Math.max(r, s),
- u = Math.max(n, i),
- n = Math.min(n + e.getWidth(), i + t.getWidth()),
- r = Math.min(r + e.getHeight(), s + t.getHeight()) - o;
- return 0 < n - u && 0 < r ? !0 : !1
- }
- u = e.getDrawRectangle();
- r = t.getDrawRectangle();
- return u.hitTestRectangle(r)
- };
- this.drawRectangle = function(e, t, n, r, i, s, o, u) {
- var a = this.canvas;
- a.ctx.globalAlpha = "undefined" != typeof o ? o : 1;
- a.ctx.fillStyle = i;
- a.ctx.strokeStyle = i;
- u || (e -= this.viewport.x, t -= this.viewport.y);
- e = e * Utils.globalScale * Utils.globalPixelScale;
- t = t * Utils.globalScale * Utils.globalPixelScale;
- n = n * Utils.globalScale * Utils.globalPixelScale;
- r = r * Utils.globalScale * Utils.globalPixelScale;
- s ? a.ctx.fillRect(e - n / 2, t - r / 2, n, r) : a.ctx.strokeRect(e - n / 2, t - r / 2, n, r)
- };
- this.drawCircle = function(e, t, n, r, i, s, o) {
- this.drawArc(e, t, n, 0, 2 * Math.PI, !1, r, i, s, o)
- };
- this.drawArc = function(e, t, n, r, i, s, o, u, a, f) {
- var l = this.canvas,
- c = l.ctx.lineWidth;
- "undefined" == typeof u && (u = "#000");
- l.ctx.strokeStyle = u;
- "undefined" == typeof o && (o = 1);
- l.ctx.lineWidth = o * Utils.globalScale * Utils.globalPixelScale;
- "undefined" == typeof a && (a = 1);
- l.ctx.globalAlpha = a;
- f || (e -= this.viewport.x, t -= this.viewport.y);
- e = e * Utils.globalScale * Utils.globalPixelScale;
- t = t * Utils.globalScale * Utils.globalPixelScale;
- n = n * Utils.globalScale * Utils.globalPixelScale;
- l.ctx.beginPath();
- l.ctx.arc(e, t, n, r, i, s);
- l.ctx.stroke();
- l.ctx.lineWidth = c
- };
- this.drawPolygon = function(e, t, n, r, i) {
- if ("object" == typeof e && e instanceof Array && !(2 > e.length)) {
- 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);
- this.drawLine(e[s].x, e[s].y, e[0].x, e[0].y, t, n, r, i)
- }
- };
- this.drawLine = function(e, t, n, r, i, s, o, u) {
- var a = this.canvas,
- f = a.ctx.lineWidth;
- a.ctx.strokeStyle = s ? s : "#000";
- a.ctx.lineWidth = i ? i * Utils.globalScale * Utils.globalPixelScale : 1 * Utils.globalScale * Utils.globalPixelScale;
- a.ctx.globalAlpha = o ? o : 1;
- u || (e -= this.viewport.x, t -= this.viewport.y, n -= this.viewport.x, r -= this.viewport.y);
- e = e * Utils.globalScale * Utils.globalPixelScale;
- t = t * Utils.globalScale * Utils.globalPixelScale;
- n = n * Utils.globalScale * Utils.globalPixelScale;
- r = r * Utils.globalScale * Utils.globalPixelScale;
- a.ctx.beginPath();
- a.ctx.moveTo(e, t);
- a.ctx.lineTo(n, r);
- a.ctx.stroke();
- a.ctx.lineWidth = f
- };
- this.start = function() {
- this.started || (this.started = !0, r(), i())
- };
- this.forceRender = function() {
- this.started && i()
- };
- this.stop = function() {
- this.started = !1
- };
- this.setTextStyle = function(e, t, n, r, i, s) {
- s = s ? s : this.canvas;
- s.ctx.fillStyle = r;
- s.ctx.strokeStyle = i;
- r = "";
- n && (r += n + " ");
- t && (r += Math.floor(t * Utils.globalScale * Utils.globalPixelScale) + "px ");
- e && (r += e);
- s.ctx.font = r
- };
- this.drawText = function(e, t, n, r, i, s, o) {
- o = o ? o : this.canvas;
- o.ctx.globalAlpha = "undefined" == typeof r ? 1 : r;
- i || (t -= this.viewport.x, n -= this.viewport.y);
- t = t * Utils.globalScale * Utils.globalPixelScale;
- n = n * Utils.globalScale * Utils.globalPixelScale;
- s && (t -= this.getTextWidth(e) / 2);
- o.ctx.fillText(e, t, n)
- };
- this.strokeText = function(e, t, n, r, i, s, o) {
- o = o ? o : this.canvas;
- o.ctx.globalAlpha = "undefined" == typeof r ? 1 : r;
- i || (t -= this.viewport.x, n -= this.viewport.y);
- t = t * Utils.globalScale * Utils.globalPixelScale;
- n = n * Utils.globalScale * Utils.globalPixelScale;
- s && (t -= this.getTextWidth(e) / 2);
- o.ctx.strokeText(e, t, n)
- };
- this.getTextWidth = function(e, t) {
- return (t ? t : this.canvas).ctx.measureText(e).width
- };
- this.allowStaticDebugDrawing = this.allowDebugDrawing = !1;
- this.renderObject = function(e, t) {
- if (!1 !== t.dispatchEvent("prerender", {
- target: t,
- canvas: e
- })) {
- var n = t.getAbsoluteCenter();
- ow = t.width * Utils.globalScale;
- oh = t.height * Utils.globalScale;
- ox = n.x * Utils.globalPixelScale * Utils.globalScale - Math.floor(ow / 2);
- oy = n.y * Utils.globalPixelScale * Utils.globalScale - Math.floor(oh / 2);
- or = t.rotation;
- scX = t.scaleX * Utils.globalPixelScale;
- scY = t.scaleY * Utils.globalPixelScale;
- canvasMod = Boolean(0 != or || 1 != scX || 1 != scY);
- t.ignoreViewport || (ox -= this.viewport.x * Utils.globalPixelScale * Utils.globalScale, oy -= this.viewport.y * Utils.globalPixelScale * Utils.globalScale);
- 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));
- e.ctx.globalAlpha = t.opacity;
- this.ceilSizes && (ow = Math.ceil(ow), oh = Math.ceil(oh));
- t.fillColor && (e.ctx.fillStyle = t.fillColor, e.ctx.strokeStyle = t.fillColor, e.ctx.fillRect(ox, oy, ow, oh));
- if (t.bitmap) {
- var n = t.bitmap.width,
- r = t.bitmap.height,
- i = t.currentLayer * ow + t.offset.left * Utils.globalScale,
- s = t.currentFrame * oh + t.offset.top * Utils.globalScale;
- if (i < n && s < r) {
- var o = ow,
- u = oh,
- a = !1;
- i + o > n && (o = n - i);
- s + u > r && (u = r - s);
- 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);
- try {
- e.ctx.drawImage(a ? this.buffer : t.bitmap, ~~i, ~~s, ~~o, ~~u, ~~ox, ~~oy, ~~ow, ~~oh)
- } catch (f) {}
- a && this.buffer.ctx.restore()
- }
- }
- canvasMod && e.ctx.restore();
- this.allowDebugDrawing && t.allowDebugDrawing && (!this.allowStaticDebugDrawing && t.static || t.debugDraw());
- t.dispatchEvent("render", {
- target: t,
- canvas: e
- })
- }
- };
- this.drawBackAlways = Utils.mobileCheckBrokenGalaxyPhones();
- this.drawBackBuffer = function(e, t) {
- !t && this.backBuffer && this.drawBackAlways && e.ctx.drawImage(this.backBuffer, 0, 0, e.width, e.height)
- };
- this.drawScene = function(e, t) {
- var n, r;
- e && !e.ctx && (e.ctx = e.getContext("2d"));
- 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));
- 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)));
- t && (this.backBuffer = e)
- };
- this.tweens = [];
- this.createTween = function(e, t, n, r, i, o) {
- e = new Tween(e, t, n, r, i, o);
- s.tweens.push(e);
- return e
- };
- this.removeTween = function(e) {
- var t = null;
- if (isNaN(e))
- for (var n = 0; n < s.tweens.length; n++) {
- if (s.tweens[n] === e) {
- t = n;
- break
- }
- } else t = e;
- s.tweens[t].pause();
- s.tweens.splice(t, 1);
- return t
- };
- this.clearObjectTweens = function(e) {
- for (var t = 0; t < s.tweens.length; t++) s.tweens[t].obj === e && (t = s.removeTween(t), t--)
- };
- this.updateTweens = function() {
- for (var e = 0; e < s.tweens.length; e++) s.tweens[e].tick() && (e = s.removeTween(e))
- };
- this.timers = [];
- this.setTimeout = function(e, t) {
- var n = new StageTimer(e, t);
- this.timers.push(n);
- return n
- };
- this.clearTimeout = function(e) {
- this.timers = Utils.removeFromArray(this.timers, e)
- };
- this.setInterval = function(e, t) {
- var n = new StageTimer(e, t, !0);
- this.timers.push(n);
- return n
- };
- this.clearInterval = function(e) {
- this.clearTimeout(e)
- };
- this.updateTimers = function() {
- for (var e = 0; e < this.timers.length; e++) this.timers[e].update() && (this.clearTimeout(this.timers[e]), e--)
- };
- this.box2dSync = function(e) {
- 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", {
- target: b.sprite
- }))
- };
- this.processTouchEvent = function(e, t) {
- for (var n = 0; n < e.length; n++) s[t]({
- clientX: e[n].clientX,
- clientY: e[n].clientY
- })
- };
- this.inputController = null;
- this.addInputListeners = function(e) {
- -1 != navigator.userAgent.toLowerCase().indexOf("firefox") && navigator.userAgent.toLowerCase().indexOf("mobile");
- this.inputController = e;
- "ontouchstart" in e ? (e.ontouchstart = function(e) {
- s.processTouchEvent(e.touches, "checkMouseDown");
- s.processTouchEvent(e.touches, "checkClick")
- }, e.ontouchmove = function(e) {
- s.processTouchEvent(e.touches, "checkMouseMove")
- }, e.ontouchend = function(e) {
- s.processTouchEvent(e.changedTouches, "checkMouseUp")
- }) : (e.onclick = function(e) {
- s.checkClick(e)
- }, e.onmousemove = function(e) {
- s.checkMouseMove(e)
- }, e.onmousedown = function(e) {
- 0 == e.button && s.checkMouseDown(e)
- }, e.onmouseup = function(e) {
- 0 == e.button && s.checkMouseUp(e)
- }, e.oncontextmenu = function(e) {
- s.checkContextMenu(e)
- })
- };
- this.canvas && this.addInputListeners(this.canvas);
- this.onposttick = this.onpretick = null;
- this.eventsListeners = [];
- this.addEventListener = function(e, t) {
- EventsManager.addEvent(this, e, t)
- };
- this.removeEventListener = function(e, t) {
- EventsManager.removeEvent(this, e, t)
- };
- this.dispatchEvent = function(e, t) {
- return EventsManager.dispatchEvent(this, e, t)
- }
- }
- function Vector(e, t) {
- "undefined" == typeof e && (e = 0);
- this.x = e;
- "undefined" == typeof t && (t = 0);
- this.y = t;
- this.isZero = function() {
- return 0 == this.x && 0 == this.y
- };
- this.clone = function() {
- return new Vector(this.x, this.y)
- };
- this.add = function(e) {
- this.x += e.x;
- this.y += e.y;
- return this
- };
- this.subtract = function(e) {
- this.x -= e.x;
- this.y -= e.y;
- return this
- };
- this.mult = function(e) {
- this.x *= e;
- this.y *= e;
- return this
- };
- this.invert = function() {
- this.mult(-1);
- return this
- };
- this.rotate = function(e, t) {
- "undefined" == typeof t && (t = new Vector(0, 0));
- var n = this.clone();
- n.subtract(t);
- n.x = this.x * Math.cos(e) + this.y * Math.sin(e);
- n.y = this.x * -Math.sin(e) + this.y * Math.cos(e);
- n.add(t);
- this.x = n.x;
- this.y = n.y;
- return this
- };
- this.normalize = function(e, t) {
- "undefined" == typeof t && (t = new Vector(0, 0));
- this.subtract(t);
- this.rotate(-e);
- return this
- };
- this.getLength = function() {
- return Math.sqrt(this.x * this.x + this.y * this.y)
- };
- this.distanceTo = function(e) {
- p2 = this.clone();
- p2.subtract(e);
- return p2.getLength()
- }
- }
- function ChainFinder(e, t, n, r) {
- "undefined" == typeof e && (e = []);
- t = Math.max(2, ~~t);
- n = Math.max(1, ~~n);
- "undefined" == typeof r && (r = !1);
- this.items = e;
- this.length = t;
- this.cols = n;
- this.rows = Math.floor(e.length / n);
- this.diagonal = r;
- this.chains = !1;
- this.inField = function(e) {
- return 0 > e || e >= this.items.length ? !1 : !0
- };
- this.idInChain = function(e) {
- for (var t = 0; t < this.chains.length; t++)
- if (0 <= this.chains[t].indexOf(e)) return t;
- return -1
- };
- this.isNeighbour = function(e, t) {
- if (!this.inField(t) || 0 <= this.idInChain(e)) return !1;
- var n = Math.floor(e / this.cols),
- r = Math.floor(t / this.cols),
- i = Math.abs(e % this.cols - t % this.cols),
- n = Math.abs(n - r);
- return this.diagonal ? 0 < i + n && 2 > i && 2 > n : 1 == i + n
- };
- this.getNeighbours = function(e, t) {
- "undefined" == typeof t && (t = !1);
- var n = [e - 1, e + 1, e - this.cols, e + this.cols];
- 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)));
- for (var r = []; 0 < n.length;) {
- var i = n.shift();
- this.isNeighbour(e, i) && (t && 0 > this.ids.indexOf(i) || r.push(i))
- }
- return r
- };
- this.checkChainLength = function(e) {
- return e ? e.length >= this.length : !1
- };
- this.ids = [];
- this.prepare = function() {
- this.ids = [];
- this.chains = [];
- for (var e = 0; e < this.items.length; e++) 0 <= this.idInChain(e) || this.ids.push(e)
- };
- this.findChains = function() {
- this.prepare();
- if (0 == this.items.length) return this.chains;
- for (; 0 < this.ids.length;) {
- var e = this.ids.shift(),
- e = this.getChain(e);
- this.checkChainLength(e) && this.chains.push(e)
- }
- return this.chains
- };
- this.getChain = function(e, t) {
- "undefined" == typeof t && (t = []);
- 0 > t.indexOf(e) && t.push(e);
- for (var n = this.getNeighbours(e, !0); 0 < n.length;) {
- var r = n.shift();
- 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))
- }
- return t
- };
- this.findPossibleChains = function(e) {
- this.prepare();
- var t = this.items[e];
- if (!this.inField(e)) return !1;
- for (var n = {}, r = this.getNeighbours(e, !0); 0 < r.length;) {
- this.prepare();
- var i = r.shift(),
- s = this.items[i];
- this.empty(s) || (this.items[e] = s, n[s] || (n[s] = []), n[s] = this.getChain(i, n[s]))
- }
- this.items[e] = t;
- return n
- };
- this.findMaxPossibleChain = function(e) {
- e = this.findPossibleChains(e);
- if (!e) return !1;
- var t = !1,
- n = -1,
- r;
- for (r in e) this.checkChainLength(e[r]) && ~~r > n && (t = e[r], n = ~~r);
- return t
- };
- this.findMinPossibleChain = function(e) {
- e = this.findPossibleChains(e);
- if (!e) return !1;
- var t = !1,
- n = Number.MAX_VALUE,
- r;
- for (r in e) this.checkChainLength(e[r]) && r < n && (t = e[r], n = r);
- return t
- };
- this.findLongestPossibleChain = function(e) {
- e = this.findPossibleChains(e);
- if (!e) return !1;
- var t = !1,
- n = -1,
- r;
- for (r in e) this.checkChainLength(e[r]) && e[r].length > n && (t = e[r], n = r);
- return t
- };
- this.findShortestPossibleChain = function(e) {
- e = this.findPossibleChains(e);
- if (!e) return !1;
- var t = !1,
- n = Number.MAX_VALUE,
- r;
- for (r in e) this.checkChainLength(e[r]) && e[r].length < n && (t = e[r], n = r);
- return t
- };
- this.getChainType = function(e) {
- if (!1 === e) return 0;
- for (var t = 0; t < e.length; t++)
- if (!this.empty(e[t])) return this.items[e[t]];
- return 0
- };
- this.compare_callback = null;
- this.compare = function(e, t) {
- return this.compare_callback ? this.compare_callback(e, t) : e == t
- };
- this.empty_callback = null;
- this.empty = function(e) {
- return this.empty_callback ? this.empty_callback(e) : 0 == ~~e
- }
- }
- function AudioPlayer() {
- var e = this;
- this.disabled = !1;
- this.basePath = "";
- this.mp3Support = !0;
- this.delayPlay = this.webAudioSupport = !1;
- this.audioWrapper = null;
- this.busy = this.locked = !1;
- this.startPlayTime = 0;
- this.onend = null;
- this.createNewAudio = function() {
- if (this.webAudioSupport) {
- var e = AudioMixer.waContext.createBufferSource();
- e.connect(AudioMixer.waContext.destination);
- return e
- }
- return document.createElement("audio")
- };
- this.init = function(e, t) {
- this.webAudioSupport = t;
- this.basePath = e ? e : "";
- this.delayPlay = "ontouchstart" in window;
- this.audioWrapper = this.createNewAudio();
- var n = document.createElement("audio");
- n.canPlayType ? this.mp3Support = "" != n.canPlayType("audio/mpeg") : this.disabled = !0;
- return !this.disabled
- };
- this.play = function(e, t) {
- if (this.disabled) return !1;
- var n = this.basePath + "/" + e + (this.mp3Support ? ".mp3" : ".ogg");
- this.stop();
- this.audioWrapper = this.createNewAudio();
- this.audioWrapper.doLoop = t ? !0 : !1;
- if (this.webAudioSupport) {
- var r = this;
- this.loadSound(n, function(e) {
- r.audioWrapper.buffer = e;
- r.audioWrapper.noteOn(0);
- r.startPlayTime = (new Date).getTime();
- r.audioWrapper.loop = t;
- r.waCheckInterval = setInterval(function() {
- r.audioWrapper ? r.audioWrapper.playbackState == r.audioWrapper.FINISHED_STATE && r.controlPlay() : clearInterval(r.waCheckInterval)
- }, 100)
- })
- } 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);
- this.busy = !0;
- this.startPlayTime = (new Date).getTime()
- };
- this.loadSound = function(e, t) {
- if (AudioMixer.buffer[e]) t && t(AudioMixer.buffer[e]);
- else {
- var n = new XMLHttpRequest;
- n.open("GET.html", e, !0);
- n.responseType = "arraybuffer";
- n.onload = function() {
- AudioMixer.waContext.decodeAudioData(this.response, function(n) {
- AudioMixer.buffer[e] = n;
- t && t(n)
- })
- }
- }
- };
- this.readyToPlay = function(e) {
- e.currentTarget.play()
- };
- this.stop = function() {
- this.busy = !1;
- try {
- this.webAudioSupport ? this.audioWrapper.noteOff(0) : (this.audioWrapper.removeEventListener("canplay", this.readyToPlay), this.audioWrapper.pause(), this.audioWrapper.currentTime = 0), this.audioWrapper = null
- } catch (e) {}
- };
- this.pause = function() {
- this.webAudioSupport ? e.audioWrapper && e.audioWrapper.disconnect() : this.audioWrapper.pause()
- };
- this.resume = function() {
- this.webAudioSupport ? e.audioWrapper && e.audioWrapper.connect(AudioMixer.waContext.destination) : this.audioWrapper.play()
- };
- this.controlPlay = function() {
- if (e.audioWrapper.doLoop) this.webAudioSupport || (e.audioWrapper.pause(), e.audioWrapper.currentTime = 0, e.audioWrapper.play());
- else {
- e.busy = !1;
- if ("function" == typeof e.onend) e.onend();
- this.waCheckInterval && clearInterval(this.waCheckInterval)
- }
- };
- this.getPosition = function() {
- if (this.webAudioSupport) {
- if (!this.startPlayTime) return 0;
- var e = this.getDuration();
- if (!e) return 0;
- var t = ((new Date).getTime() - this.startPlayTime) / 1e3;
- return t <= e ? t : this.audioWrapper.doLoop ? t - Math.floor(t / e) * e : e
- }
- return this.audioWrapper.currentTime ? this.audioWrapper.currentTime : 0
- };
- this.getDuration = function() {
- return this.webAudioSupport ? this.audioWrapper.buffer ? this.audioWrapper.buffer.duration : 0 : this.audioWrapper.duration ? this.audioWrapper.duration : 0
- }
- }
- function AudioMixer(e, t) {
- this.singleChannelMode = this.webAudioSupport = !1;
- this.channels = [];
- this.init = function(e, t) {
- if (this.webAudioSupport = "webkitAudioContext" in window) {
- AudioMixer.waContext = new webkitAudioContext;
- var n = AudioMixer.waContext.createBuffer(1, 1, 22050);
- sound = AudioMixer.waContext.createBufferSource();
- sound.buffer = n;
- sound.connect(AudioMixer.waContext.destination)
- }
- this.webAudioSupport || -1 == navigator.userAgent.toLowerCase().indexOf("mac") || (this.singleChannelMode = !0, t = 1);
- this.path = e;
- this.channels = [];
- for (n = 0; n < t; n++) this.channels[n] = new AudioPlayer, this.channels[n].init(e, this.webAudioSupport);
- var r, i;
- "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");
- var s = this;
- document.addEventListener(i, function() {
- if (document[r])
- for (var e = 0; e < s.channels.length; e++) s.channels[e].pause();
- else
- for (e = 0; e < s.channels.length; e++) s.channels[e].resume()
- }, !1)
- };
- this.play = function(e, t, n, r) {
- var i = -1,
- i = "number" == typeof r ? r : this.getFreeChannel(n);
- 0 <= i && i < this.channels.length && (this.channels[i].stop(), this.channels[i].play(e, t));
- return this.channels[i]
- };
- this.stop = function(e) {
- 0 <= e && e < this.channels.length && this.channels[e].stop()
- };
- this.getFreeChannel = function(e) {
- 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));
- 0 == n.length ? !e && 0 <= r && (t = r) : t = n[0];
- return t
- };
- this.init(e, t)
- }
- function gameButton(e, t, n) {
- var r = library.getSprite(e);
- r.x = t;
- r.y = n;
- r.gotoAndStop(1);
- r.onmousedown = function() {
- r.gotoAndStop(0)
- };
- r.onmouseout = function() {
- r.gotoAndStop(1)
- };
- r.onmouseup = function() {
- r.gotoAndStop(1);
- 0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("button_click", !1, !1, 0)
- };
- return r
- }
- function startLoad() {
- var e = Utils.getMobileScreenResolution(landscape);
- Utils.globalScale = e.scale;
- Utils.createLayout(document.getElementById("main_container"), e, landscape);
- Utils.addEventListener("fitlayout", function() {
- stage && (stage.drawScene(document.getElementById("screen")), buildBackground());
- setBackgroundScale()
- });
- Utils.addEventListener("lockscreen", function() {
- stage && stage.started && stage.stop()
- });
- Utils.addEventListener("unlockscreen", function() {
- stage && !stage.started && stage.start()
- });
- Utils.mobileHideAddressBar();
- Utils.checkOrientation(landscape);
- mixer = new AudioMixer("music", 1);
- mixer2 = new AudioMixer("music", 1);
- library = new AssetsLibrary("images", Utils.globalScale, assets);
- TTLoader.create(loadImagesEnd, !0);
- library.load(TTLoader.loadComplete, TTLoader.showLoadProgress)
- }
- function loadImagesEnd(e) {
- document.getElementById("progress_container").style.display = "none";
- document.getElementById("screen_container").style.display = "block";
- document.getElementById("screen_background_container").style.display = "block";
- FontManager.registerFont("baveuse", Charset.latin, 9, 14);
- gameState = STATE_MENU;
- iosMode = -1 != navigator.userAgent.toLowerCase().indexOf("mac");
- android = -1 != navigator.userAgent.toLowerCase().indexOf("android");
- createScene()
- }
- function showMenu() {
- gameState = STATE_MENU;
- createScene()
- }
- function createStage() {
- stage && (stage.destroy(), stage.stop());
- stage = new Stage("screen", 320, 480, !1);
- stage.delay = 1e3 / fps;
- stage.ceilSizes = !0;
- stage.onpretick = preTick;
- stage.onposttick = postTick;
- stage.showFPS = !1
- }
- function createScene() {
- createStage();
- gameState == STATE_MENU && createMenu();
- gameState == STATE_SELECT_DIFFICULTY && selectDifficulty();
- gameState == STATE_MISSION_INFO && showMissionInfo();
- gameState == STATE_GAME && createGame();
- gameState == STATE_VICTORY && showVictoryScreen();
- gameState == STATE_DEFEAT && showDefeatScreen();
- gameState == STATE_HIGHSCORES ;
- gameState == STATE_CREDITS && showEvolution();
- gameState == STATE_TUTORIAL && showTutorialMenu();
- setBackground("#FFFFFF url('images/" + Utils.globalScale + "/gme-bg.jpg')");
- buildBackground();
- stage.start()
- }
- function setBackground(e) {
- 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())
- }
- function setBackgroundScale() {
- var e = Utils.globalScale * Utils.globalPixelScale;
- document.getElementById("screen_background_container").style.backgroundSize = 870 * e + "px " + 480 * e + "px"
- }
- function showDefeatScreen() {
- stage.addChild(library.getSprite("null", {
- x: 160,
- y: 240,
- "static": !0,
- onmouseup: function() {
- gameState = STATE_GAME;
- createScene()
- }
- }));
- stage.addChild(library.getSprite("popup_loose", {
- x: 160,
- y: 180
- }));
- var e = new gameButton("menu", 160, 455);
- e.addEventListener("mouseup", function() {
- showMenu();
- return !1
- });
- stage.addChild(e);
- checkAndSetHighscores()
- }
- function createMenu() {
- stage.addChild(library.getSprite("field-main-logo", {
- x: 160,
- y: 80
- }));
- stage.addChild(library.getSprite("field-main-btn-bg", {
- x: 160,
- y: 280
- }));
- var e = new gameButton("play", 158, 201);
- e.addEventListener("mouseup", function(e) {
- gameState = STATE_SELECT_DIFFICULTY;
- createScene();
- return !1
- });
- stage.addChild(e);
- e = new gameButton("highscores", 171, 302);
- e.addEventListener("mouseup", function(e) {
- gameState = STATE_HIGHSCORES;
- createScene()
- });
- stage.addChild(e);
- e = new gameButton("credits", 145, 375);
- e.addEventListener("mouseup", function(e) {
- gameState = STATE_CREDITS;
- createScene()
- });
- stage.addChild(e);
- e = new gameButton("qmark", 55, 450);
- e.addEventListener("mouseup", function(e) {
- gameState = STATE_TUTORIAL;
- createScene()
- });
- stage.addChild(e);
- 1 == Utils.getCookie("soundOn") || ignoreMenuTheme || mixer2.play("main_theme", !0, !1, 0);
- addSoundIcon()
- }
- function testChance() {
- var e = rouletteProbability,
- t = 0,
- n;
- for (n in e) t += e[n].n;
- t = Math.floor(Math.random() * t);
- for (n in e)
- if (t -= e[n].n, 0 >= t) return e[n].v;
- return 1
- }
- function playRoulette() {
- for (var e = [], t = [], n = 0; 3 > n; n++) {
- t.push(testChance());
- var r = new GameElement(t[n]);
- r.x = 102 + 58 * n;
- r.y = 219;
- r.isRoulette = !0;
- e.push(r);
- r = library.getSprite("coin_rotate");
- r.x = 102 + 58 * n;
- r.y = 219;
- r.animDelay = 1;
- r.isRoulette = !0;
- r.gotoAndPlay(0);
- tempRouletteArray.push(r);
- stage.addChild(r)
- }
- setTimeout(function() {
- tempRouletteArray[0].onenterframe = function(t) {
- 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))
- }
- }, 2e3);
- setTimeout(function() {
- tempRouletteArray[1].onenterframe = function(t) {
- 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))
- }
- }, 4e3);
- setTimeout(function() {
- tempRouletteArray[2].onenterframe = function(t) {
- 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))
- };
- setTimeout(function() {
- checkIfRouletteWon(t)
- }, 1e3)
- }, 6e3)
- }
- function checkIfRouletteWon(e) {
- 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);
- e[0] == e[1] && e[0] == e[2] ? (coinsInc(), setUserCoins(), stage.addChild(library.getSprite("text2", {
- x: 160,
- y: 260
- })), drawHighscores(1, 140, 285), 0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("roulette_super_nice", !1, !1, 0)) : (stage.addChild(library.getSprite("text3", {
- x: 160,
- y: 260
- })), drawHighscores(0, 140, 285), 0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("roulette_not_nice", !1, !1, 0));
- stage.addChild(library.getSprite("text1", {
- x: 170,
- y: 285
- }))
- }
- function showVictoryScreen() {
- 0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("victory", !1, !1, 0);
- var e, t = "ultimate" == currentDifficulty ? !0 : !1,
- n;
- if (t && maxUnlockedItem.newUnlocked) maxUnlockedItem.newUnlocked && (e = 240, stage.addChild(library.getSprite("back_field_win_3", {
- x: 160,
- y: e - 40
- })), e += 43, drawLevelScore(143), playRoulette());
- else {
- 0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("victory", !1, !1, 0);
- n = LEVELS[current_game_mode].upgrades;
- n = t ? maxUnlockedItem.t : n[n.length - 1];
- e = 240;
- stage.addChild(library.getSprite("back_field_win", {
- x: 160,
- y: e - 40
- }));
- var r = library.getSprite("light_win");
- r.x = 160;
- r.y = 200;
- stage.addChild(r);
- stage.setInterval(function() {
- r.rotateBy(Math.PI / 160)
- }, 2);
- n = new GameElement(n, t);
- n.setPosition(160, 205);
- stage.addChild(n);
- drawLevelScore(265)
- }
- n = new gameButton("win_next", 243, e + 18);
- n.addEventListener("mouseup", function(e) {
- gameState = STATE_SELECT_DIFFICULTY;
- createScene()
- });
- stage.addChild(n);
- e = new gameButton("win_replay", 76, e + 18);
- e.addEventListener("mouseup", function(e) {
- gameState = STATE_GAME;
- createScene()
- });
- stage.addChild(e);
- t || levelCompleted();
- checkAndSetHighscores()
- }
- function addSoundIcon() {
- ignoreMenuTheme = !0;
- sound = library.getSprite("sound");
- sound.x = 275;
- sound.y = 455;
- 1 == Utils.getCookie("soundOn") ? (sound.gotoAndStop(0), soundOn = !1) : (sound.gotoAndStop(1), soundOn = !0);
- sound.state = 1;
- sound.onmouseup = soundIconOnChange;
- stage.addChild(sound)
- }
- function showHighscores() {
- stage.addChild(library.getSprite("field_highscore", {
- x: 160,
- y: 240,
- "static": !0
- }));
- var e = new gameButton("menu", 160, 400);
- e.addEventListener("mouseup", showMenu);
- stage.addChild(e);
- addSoundIcon();
- for (var e = [], t = 1; 11 > t; t++) {
- var n = Utils.getCookie("maxScore" + t),
- n = null == n ? 0 : n,
- n = parseInt(n);
- e.push(n)
- }
- e.sort(function(e, t) {
- return e > t ? -1 : e < t ? 1 : 0
- });
- t = 0;
- for (n = e.length; t < n; t++) drawHighscores(t + 1, 60, 92 + 30 * t, "numbers"), drawHighscores(e[t], 265, 92 + 30 * t)
- }
- function drawHighscores(e, t, n, r) {
- var i = library.getAsset("font1", !0).bitmap;
- e += "";
- if ("numbers" == r)
- 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);
- else
- 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)
- }
- function checkAndSetHighscores() { /*updateShare(current_game_mode,gameScore);Play68.setRankingScoreDesc(gameScore);*/
- for (var e = [], t = 1; 11 > t; t++) {
- var n = Utils.getCookie("maxScore" + t);
- void 0 != n && e.push(n)
- }
- t = e.length;
- if (10 > t) t++, Utils.setCookie("maxScore" + t, gameScore);
- else
- for (t = 0; 10 > t; t++)
- if (e[t] < gameScore) {
- t++;
- Utils.setCookie("maxScore" + t, gameScore);
- break
- }
- }
- function moveIconsVert(e, t) {
- for (var n, r = 0, i = stage.objects.length; r < i; r++) {
- var s = stage.objects[r];
- 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)));
- if (s.first && 110 <= s.y && 0 < e) return t && (t[0].visible = !1), !1;
- if (s.first && -660 >= s.y && 0 > e) return t && (t[1].visible = !1), !1;
- if (s.isMovable) {
- s.y += e;
- var o = s.y;
- s.visible = 90 >= o || 390 <= o ? !1 : !0;
- s.opacity = 90 < o && 110 >= o ? (o - 90) / 20 : 360 <= o && 390 > o ? Math.abs(390 - o) / 30 : 1
- }
- }
- t && (t[0].visible = !0, t[1].visible = !0);
- 110 <= n.y && t && (t[0].visible = !1); - 660 >= n.y && t && (t[1].visible = !1)
- }
- function showEvolution() {
- scrollLocked = !1;
- var e = new Sprite(null, 320, 480);
- e.x = 160;
- e.y = 240;
- e.static = !0;
- e.onmousedown = function() {
- startScrollPosition = window.event.pageY;
- scrollLocked = !0
- };
- e.onmouseup = function() {
- scrollLocked = !1
- };
- e.onmousemove = function() {
- if (scrollLocked) {
- var e = window.event.pageY;
- moveIconsVert((e - startScrollPosition) / 1.85, [t, n]);
- startScrollPosition = e
- }
- };
- stage.addChild(e);
- stage.addChild(library.getSprite("back", {
- x: 160,
- y: 235
- }));
- e = library.getSprite("evol_back", {
- x: 160,
- y: 230
- });
- stage.setZIndex(e, 100);
- stage.addChild(e);
- var t = new Sprite(library.getSprite("arrow_up").bitmap, 31, 12);
- t.x = 160;
- t.y = 70;
- t.onclick = function() {
- moveIconsVert(85, [t, n])
- };
- t.visible = !1;
- stage.setZIndex(t, 150);
- stage.addChild(t);
- var n = new Sprite(library.getSprite("arrow_down").bitmap, 31, 12);
- n.x = 160;
- n.y = 405;
- n.onclick = function() {
- moveIconsVert(-85, [t, n])
- };
- stage.setZIndex(n, 150);
- stage.addChild(n);
- e = new gameButton("menu", 160, 450);
- e.addEventListener("mousedown", function() {
- clickForbidden = !1
- });
- e.addEventListener("mouseup", function() {
- clickForbidden || (showMenu(), clickForbidden = !0)
- });
- stage.addChild(e);
- addSoundIcon();
- sound.addEventListener("mousedown", function() {
- clickForbidden = !1
- });
- sound.onmouseup = function(e) {
- clickForbidden || (clickForbidden = !0, soundIconOnChange())
- };
- stage.addChild(library.getSprite("Amoeba", {
- x: 160,
- y: 110,
- isMovable: !0,
- first: !0
- }));
- stage.addChild(library.getSprite("Jellyfish", {
- x: 160,
- y: 195,
- isMovable: !0
- }));
- stage.addChild(library.getSprite("Fish", {
- x: 160,
- y: 280,
- isMovable: !0
- }));
- e = Utils.getCookie("icon4ul") ? "lizard" : "Unknown";
- stage.addChild(library.getSprite(e, {
- x: 160,
- y: 365,
- isMovable: !0
- }));
- e = Utils.getCookie("icon5ul") ? "wolf" : "Unknown";
- stage.addChild(library.getSprite(e, {
- x: 160,
- y: 450,
- isMovable: !0
- }));
- e = Utils.getCookie("icon6ul") ? "ape" : "Unknown";
- stage.addChild(library.getSprite(e, {
- x: 160,
- y: 535,
- isMovable: !0
- }));
- e = Utils.getCookie("icon7ul") ? "human" : "Unknown";
- stage.addChild(library.getSprite(e, {
- x: 160,
- y: 620,
- isMovable: !0
- }));
- e = Utils.getCookie("icon11ul") ? "humanoid" : "Unknown";
- stage.addChild(library.getSprite(e, {
- x: 160,
- y: 705,
- isMovable: !0
- }));
- e = Utils.getCookie("icon12ul") ? "superhuman" : "Unknown";
- stage.addChild(library.getSprite(e, {
- x: 160,
- y: 790,
- isMovable: !0
- }));
- e = Utils.getCookie("icon13ul") ? "cyborg" : "Unknown";
- stage.addChild(library.getSprite(e, {
- x: 160,
- y: 875,
- isMovable: !0
- }));
- e = Utils.getCookie("icon14ul") ? "geek" : "Unknown";
- stage.addChild(library.getSprite(e, {
- x: 160,
- y: 960,
- isMovable: !0
- }));
- e = Utils.getCookie("icon15ul") ? "zombie" : "Unknown";
- stage.addChild(library.getSprite(e, {
- x: 160,
- y: 1045,
- isMovable: !0
- }));
- e = Utils.getCookie("icon16ul") ? "superbrains" : "Unknown";
- stage.addChild(library.getSprite(e, {
- x: 160,
- y: 1130,
- isMovable: !0
- }));
- moveIconsVert(0)
- }
- function setDifficulty(e) {
- e = ~~e.target.mode;
- gameState = STATE_MISSION_INFO;
- current_game_mode = e = Math.max(0, Math.min(LEVELS.length, ~~e));
- createScene()
- }
- function selectDifficulty() {
- stage.addChild(library.getSprite("field-select-level-bg", {
- x: 161,
- y: 240
- }));
- var e = new gameButton("menu", 160, 455);
- e.addEventListener("mouseup", showMenu);
- stage.addChild(e);
- addLevelIcon("easy");
- addLevelIcon("medium");
- addLevelIcon("hard");
- addLevelIcon("expert");
- addLevelIcon("ultimate");
- addSoundIcon();
- showUnlockAnimation && (addUnlockAnimation(), showUnlockAnimation = !1)
- }
- function addUnlockAnimation() {
- var e;
- switch (currentDifficulty) {
- case "easy":
- e = 175;
- break;
- case "medium":
- e = 245;
- break;
- case "hard":
- e = 315;
- break;
- case "expert":
- e = 385
- }
- var t = library.getSprite("lock");
- t.x = 230;
- t.y = e;
- t.animDelay = 3;
- t.onenterframe = function(e) {
- 10 == e.target.currentFrame && (e.target.destroy = !0)
- };
- stage.addChild(t)
- }
- function addLevelIcon(e) {
- var t = library.getSprite(e);
- t.x = 160;
- switch (e) {
- case "easy":
- t.y = 105;
- t.mode = D_SIMPLE;
- t.gotoAndStop(0);
- t.onmouseup = function(e) {
- currentDifficulty = "easy";
- setDifficulty(e)
- };
- break;
- case "medium":
- t.y = 175;
- t.mode = D_NORMAL;
- void 0 == Utils.getCookie("easy_level_completed") ? t.gotoAndStop(0) : (t.gotoAndStop(1), t.onmouseup = function(e) {
- currentDifficulty = "medium";
- setDifficulty(e)
- });
- break;
- case "hard":
- t.y = 245;
- t.mode = D_HARD;
- void 0 == Utils.getCookie("medium_level_completed") ? t.gotoAndStop(0) : (t.gotoAndStop(1), t.onmouseup = function(e) {
- currentDifficulty = "hard";
- setDifficulty(e)
- });
- break;
- case "expert":
- t.y = 315;
- t.mode = D_EXPERT;
- void 0 == Utils.getCookie("hard_level_completed") ? t.gotoAndStop(1) : (t.gotoAndStop(0), t.onmouseup = function(e) {
- currentDifficulty = "expert";
- setDifficulty(e)
- });
- break;
- case "ultimate":
- t.y = 385, t.mode = D_ULTIMATE, void 0 == Utils.getCookie("expert_level_completed") ? t.gotoAndStop(1) : (t.gotoAndStop(0), t.onmouseup = function(e) {
- currentDifficulty = "ultimate";
- setDifficulty(e)
- })
- }
- stage.addChild(t)
- }
- function levelCompleted() {
- 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))
- }
- function createGame() {
- if (gameState != STATE_GAME) return !1;
- clearGame();
- stage.addChild(library.getSprite("field-play-playingfield", {
- x: 161,
- y: 260,
- tatic: !0
- }));
- stage.addChild(library.getSprite("field-play-score-bg", {
- x: 145,
- y: 111,
- "static": !0
- }));
- var e = new gameButton("menu", 80, 30);
- e.addEventListener("mouseup", showMenu);
- stage.addChild(e);
- e = new gameButton("replay", 240, 30);
- e.addEventListener("mouseup", createScene);
- stage.addChild(e);
- addSoundIcon();
- e = new gameButton("plus", 281, 106);
- e.addEventListener("mouseup", function() {
- tutorialActivated || showShop();
- tutorialActivated && tut14completed && (showShop(), tutDone())
- });
- stage.addChild(e);
- field = new GameField(LEVELS[current_game_mode]);
- field.create()
- }
- function clearGame() {
- score = field = null;
- maxUnlockedItem = {
- t: 3,
- newUnlocked: !1
- }
- }
- function showShop() {
- field.locked = !0;
- var e = new Sprite(null, 320, 480);
- e.x = 160;
- e.y = 240;
- e.isShopElement = !0;
- e.onmouseup = function() {
- destroyShop();
- return !1
- };
- stage.addChild(e);
- e = library.getSprite("popup_bg");
- e.x = 160;
- e.y = 240;
- e.isShopElement = !0;
- e.onmouseup = function() {
- return !1
- };
- stage.addChild(e);
- drawText("coins", 200, 180);
- e = library.getSprite("ether");
- e.x = 125;
- e.y = 217;
- e.isShopElement = !0;
- e.gametype = T_ETHER;
- e.onmouseup = buyItem;
- stage.addChild(e);
- e = library.getSprite("fire");
- e.x = 195;
- e.y = 217;
- e.gametype = T_FIRE;
- e.isShopElement = !0;
- e.onmouseup = buyItem;
- stage.addChild(e);
- e = new gameButton("buy", 160, 290);
- e.onmouseup = buyCoins;
- e.isShopElement = !0;
- stage.addChild(e)
- }
- function buyCoins() {}
- function coinsInc() {
- coins++;
- 0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("coin_add", !1, !1, 0)
- }
- function addCoins() {
- usedPoints -= 1e6;
- coinsInc();
- var e = library.getSprite("light_win");
- e.x = 281;
- e.y = 106;
- stage.addChild(e);
- var t = stage.setInterval(function() {
- e.rotateBy(Math.PI / 160)
- }, 3);
- setTimeout(function() {
- stage.clearInterval(t);
- e.destroy = !0
- }, 3500);
- setUserCoins();
- var n = library.getSprite("coin_rotate12");
- n.x = 160;
- n.y = 83;
- n.animDelay = 2;
- n.gotoAndPlay(0);
- n.onenterframe = function(e) {
- 17 == e.target.currentFrame && (n.destroy = !0)
- };
- stage.addChild(n)
- }
- function buyItem(e) {
- var t = e.target.gametype;
- if (!(t == T_ETHER && 3 > coins || t == T_FIRE && 1 > coins)) {
- var n = new GameElement(t);
- n.setPosition(e.target.x, e.target.y);
- var r = new GameElement(field.storedElement.gametype);
- r.setPosition(field.storedElement.x, field.storedElement.y);
- stage.addChild(n);
- field.locked = !0;
- n.moveTo(field.storedElement.x, field.storedElement.y, 6, Easing.cubic.easeIn, function(e) {
- field.storedElement.setType(e.target.obj.gametype);
- field.storedElement.visible = !0;
- stage.removeChild(e.target.obj);
- field.locked = !1
- });
- r.gametype > T_EMPTY && (field.storedElement.visible = !1, stage.removeChild(e.target.obj));
- coins -= t == T_ETHER ? 3 : 1;
- setUserCoins();
- drawText("coins", 200, 180)
- }
- }
- function destroyShop() {
- for (var e = stage.objects.length, t = 0, e = stage.objects.length; t < e; t++) {
- var n = stage.objects[t];
- n.isShopElement && (n.destroy = !0)
- }
- field.locked = !1
- }
- function checkIfNeedPopup(e) {
- if (3 >= field.upgradeType || 8 == field.upgradeType || Utils.getCookie("icon" + field.upgradeType + "ul")) return e(), !1;
- if ("number" == typeof field.upgradeType) showEvolutionPopup(field.upgradeType, e);
- else return e(), !0
- }
- function showEvolutionPopup(e, t) {
- field.locked = !0;
- var n = new Sprite(null, 320, 480);
- n.setPosition(160, 240);
- n.onmouseup = function() {
- n.destroy = !0;
- r.destroy = !0;
- s.destroy = !0;
- field.locked = !1;
- t();
- return !1
- };
- stage.addChild(n);
- var r = new Sprite(library.getAsset("back_field-evolution-popup").bitmap, 411, 313);
- r.setPosition(160, 240);
- stage.addChild(r);
- var i;
- switch (e) {
- case 4:
- i = "lizard";
- break;
- case 5:
- i = "wolf";
- break;
- case 6:
- i = "ape";
- break;
- case 7:
- i = "human";
- break;
- case 11:
- i = "humanoid";
- break;
- case 12:
- i = "superhuman";
- break;
- case 13:
- i = "cyborg";
- break;
- case 14:
- i = "geek";
- break;
- case 15:
- i = "zombie";
- break;
- case 16:
- i = "superbrains"
- }
- var s = new Sprite(library.getSprite(i).bitmap, 256, 80);
- s.setPosition(r.x + 6, r.y + 8);
- stage.addChild(s);
- Utils.setCookie("icon" + field.upgradeType + "ul", !0)
- }
- function shuffle(e) {
- for (var t, n, r = e.length; r; t = parseInt(Math.random() * r), n = e[--r], e[r] = e[t], e[t] = n);
- }
- function initializeUserScore() {
- var e = Utils.getCookie("coins");
- void 0 != e && (coins = parseInt(e));
- gameScore = usedPoints = 0
- }
- function setUserCoins() {
- Utils.setCookie("coins", coins)
- }
- function getScore() {
- return score ? ~~score.getString() : 0
- }
- function setScore(e, t, n, r) {
- gameScore += e;
- usedPoints += e;
- 1e6 <= usedPoints && addCoins();
- drawText("gameScore", 150, 110);
- void 0 != t && (t = ~~t, r = ~~r, 0 != t && (e = new GUIString("baveuse", !1, {
- align: STR_ALIGN_CENTER,
- valign: STR_VALIGN_MIDDLE,
- x: ~~n,
- y: r
- }), 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) {
- e.target.obj.setParams({
- y: e.target.obj.y
- })
- }, r.onchange = function(e) {
- e.target.obj.setParams({
- opacity: e.target.obj.opacity
- })
- }, r.onfinish = function(e) {
- e.target.obj.write("");
- e.target.obj = null
- }, t.play(), r.play()))
- }
- function buildBackground() {
- stage.drawScene(document.getElementById("screen_background"), !0)
- }
- function submitScores() {
- ExternalAPI.check() && ExternalAPI.checkUserLoggedIn() && insertScores()
- }
- function insertScores() {
- ExternalAPI.check() && ExternalAPI.submitScores(gameScore, function() {})
- }
- function preTick() {}
- function postTick() {}
- function Text(e, t, n) {
- this.ALIGN_LEFT = 0;
- this.ALIGN_RIGHT = 1;
- this.ALIGN_CENTER = 2;
- this.font = e;
- this.y = this.x = 0;
- this.width = t;
- this.height = n;
- this.align = this.ALIGN_LEFT;
- this.rotation = 0;
- this.static = !1;
- this.charMap = "0123456789:+".split("");
- this.sprites = [];
- this.text = "";
- this.manageSprites = function(e) {
- var t, n = e.length,
- r = this.sprites.length;
- if (r < n)
- 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);
- if (r > n) {
- for (e = 0; e < r - n; e++) stage.removeChild(this.sprites[e]);
- this.sprites.splice(0, r - n)
- }
- };
- this.write = function(e) {
- var t, n, r, i;
- this.text = e += "";
- this.manageSprites(e);
- t = this.x;
- this.align == this.ALIGN_CENTER && (t = this.x - (e.length - 1) / 2 * this.width);
- this.align == this.ALIGN_RIGHT && (t = this.x - (e.length - 1) * this.width);
- r = new Vector(t - this.x, 0);
- r.rotate(-this.rotation);
- t = r.x + this.x;
- n = r.y + this.y;
- r = new Vector(0, 0);
- 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)
- }
- }
- function clearText(e) {
- for (var t = 0, n = stage.objects.length; t < n; t++) {
- var r = stage.objects[t];
- r[e] && (r.destroy = !0)
- }
- }
- function drawLevelScore(e) {
- var t = 160,
- n = library.getAsset("font1", !0).bitmap;
- gameScore += "";
- for (var t = t - (gameScore.length - 1) / 2 * 12, r = 0; r < gameScore.length; r++) {
- var i = new Sprite(n, 12, 20, 10);
- i.gotoAndStop(gameScore.substr(r, 1));
- i.x = t + 12 * r;
- i.y = e;
- stage.addChild(i)
- }
- }
- function soundIconOnChange() {
- 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))
- }
- function drawText(e, t, n) {
- clearText(e);
- var r = library.getAsset("font1", !0).bitmap,
- i = "coins" == e ? coins : gameScore,
- i = i + "";
- t -= (i.length - 1) / 2 * 12;
- 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)
- }
- function moveIconsHor(e) {
- for (var t = 320 * (slidesNumber - 1) - 160, n = 0, r = stage.objects.length; n < r; n++) {
- var i = stage.objects[n];
- if (0 == i.id && i.x <= -t - 20 && 0 < e || 0 == i.id && 180 <= i.x && 0 > e) return !1;
- i.isMovable && (i.x -= e)
- }
- }
- function checkClosestFigure() {
- for (var e = Number.POSITIVE_INFINITY, t = 0, n, r = 0, i = stage.objects.length; r < i; r++) {
- var s = stage.objects[r],
- o = Math.abs(s.x - 160);
- s.isMovable && o <= e && (e = o, n = s.id, t = s.x - 160)
- }
- return {
- l: t,
- n: n
- }
- }
- function moveSelector(e, t) {
- e.x = 160 - 8 * slidesNumber / 2 + 8 * t
- }
- function showTutorialMenu() {
- var e = new Sprite(library.getAsset("arrow_prev", !0).bitmap, 12, 31);
- e.x = 10;
- e.y = 285;
- e.visible = !1;
- e.onclick = function() {
- if (e.visible) {
- moveIconsHor(-320);
- showArrows(e, t);
- var n = checkClosestFigure();
- moveSelector(i, n.n)
- }
- };
- stage.addChild(e);
- var t = new Sprite(library.getAsset("arrow_frwd", !0).bitmap, 12, 31);
- t.x = 310;
- t.y = 285;
- t.onclick = function() {
- if (t.visible) {
- moveIconsHor(320);
- showArrows(e, t);
- var n = checkClosestFigure();
- moveSelector(i, n.n)
- }
- };
- stage.addChild(t);
- var n = new Sprite(null, 300, 480);
- n.x = 160;
- n.y = 240;
- n.static = !0;
- n.onmousedown = function() {
- startScrollPosition = window.event.pageX;
- scrollLocked = !0
- };
- n.onmouseup = function() {
- scrollLocked = !1;
- var n = checkClosestFigure();
- moveIconsHor(n.l);
- moveSelector(i, n.n);
- showArrows(e, t)
- };
- n.onmousemove = function() {
- if (scrollLocked) {
- var n = window.event.pageX;
- moveIconsHor(.8 * (startScrollPosition - n));
- startScrollPosition = n;
- t.visible = e.visible = !1
- }
- };
- n.onmouseout = function() {
- scrollLocked = !1;
- var n = checkClosestFigure();
- moveIconsHor(n.l);
- moveSelector(i, n.n);
- showArrows(e, t)
- };
- stage.addChild(n);
- n = new gameButton("menu", 160, 450);
- n.addEventListener("mouseup", showMenu);
- stage.addChild(n);
- addSoundIcon();
- slidesNumber = 4;
- n = new Sprite(library.getAsset("Help1", !0).bitmap, 320, 480);
- n.x = 160;
- n.y = 240;
- n.isMovable = !0;
- n.id = 0;
- showTutorialMenu.firstPage = n;
- stage.addChild(n);
- stage.addChild(library.getSprite("Help2", {
- x: 480,
- y: 240,
- isMovable: !0,
- id: 1
- }));
- stage.addChild(library.getSprite("Help3", {
- x: 800,
- y: 240,
- isMovable: !0,
- id: 2
- }));
- stage.addChild(library.getSprite("Help4", {
- x: 1120,
- y: 240,
- isMovable: !0,
- id: 3
- }));
- for (var n = 160 - 8 * slidesNumber / 2, r = 0; r < slidesNumber; r++) stage.addChild(library.getSprite("r1", {
- x: n + 8 * r,
- y: 473
- }));
- var i = new Sprite(library.getAsset("r2", !0).bitmap, 6, 6);
- i.x = n;
- i.y = 473;
- stage.addChild(i)
- }
- function showArrows(e, t) {
- var n = showTutorialMenu.firstPage.x;
- e.visible = 150 > n ? !0 : !1;
- t.visible = n <= 180 - 320 * (slidesNumber - 1) ? !1 : !0
- }
- function showTutorial(e, t) {
- "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());
- "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());
- "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());
- "ultimate" == currentDifficulty && showTutorial_14()
- }
- function fadeOut(e) {
- e.opacity = 1;
- e = e.addTween("opacity", 0, 10, Easing.linear.out, null, null);
- setTimeout(e.play, 100)
- }
- function clearTutorialSprites() {
- for (var e = 0, t = tutArray.length; e < t; e++) fadeOut(tutArray[e]);
- tutArray = []
- }
- function showTutorial_1() {
- var e = library.getSprite("txt_17");
- e.x = 170;
- e.y = 380;
- e.opacity = 0;
- stage.addChild(e);
- var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
- setTimeout(t.play, 100);
- setTimeout(function() {
- fadeOut(e)
- }, 2e3);
- var n = library.getSprite("txt_18");
- n.x = 120;
- n.y = 170;
- n.opacity = 0;
- stage.addChild(n);
- t = n.addTween("opacity", 1, 10, Easing.linear.out, null, null);
- setTimeout(t.play, 3e3);
- setTimeout(function() {
- fadeOut(n)
- }, 5e3);
- t = library.getSprite("txt_16");
- t.x = 95;
- t.y = 175;
- t.opacity = 0;
- stage.addChild(t);
- var r = t.addTween("opacity", 1, 10, Easing.linear.out, null, null);
- setTimeout(r.play, 6e3);
- tutArray.push(t);
- t = library.getSprite("txt_12");
- t.x = 215;
- t.y = 280;
- t.opacity = 0;
- stage.addChild(t);
- tutArray.push(t);
- fillGameElementArray();
- var i = t.addTween("opacity", 1, 10, Easing.linear.out, null, null);
- setTimeout(function() {
- i.play();
- gameElementArray[18].addEventListener("mouseup", tutDone)
- }, 8e3)
- }
- function tutDone() {
- clearTutorialSprites();
- 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())
- }
- function fillGameElementArray() {
- gameElementArray = [];
- for (var e = 0, t = stage.objects.length; e < t; e++) "gameCell" == stage.objects[e].type && gameElementArray.push(stage.objects[e])
- }
- function showTutorial_2() {
- var e = library.getSprite("txt_2");
- e.x = 160;
- e.y = 200;
- e.opacity = 0;
- stage.addChild(e);
- var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
- setTimeout(t.play, 100);
- tutArray.push(e);
- e = library.getSprite("txt_11");
- e.x = 160;
- e.y = 280;
- e.opacity = 0;
- stage.addChild(e);
- tutArray.push(e);
- var n = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
- setTimeout(function() {
- n.play();
- gameElementArray[17].addEventListener("mouseup", tutDone)
- }, 3e3)
- }
- function showTutorial_3() {
- var e = library.getSprite("txt_7");
- e.x = 265;
- e.y = 130;
- e.opacity = 0;
- stage.addChild(e);
- var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
- setTimeout(t.play, 100);
- setTimeout(function() {
- fadeOut(e)
- }, 2500);
- tut03completed = !0;
- setTimeout(checkTurorial, 2500)
- }
- function showTutorial_4() {
- var e = library.getSprite("txt_6");
- e.x = 120;
- e.y = 170;
- e.opacity = 0;
- stage.addChild(e);
- var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
- setTimeout(t.play, 100);
- tutArray.push(e);
- e = library.getSprite("txt_10");
- e.x = 190;
- e.y = 230;
- e.opacity = 0;
- stage.addChild(e);
- var n = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
- tutArray.push(e);
- setTimeout(function() {
- n.play();
- gameElementArray[4].addEventListener("mouseup", tutDone)
- }, 3e3)
- }
- function showTutorial_5() {
- var e = library.getSprite("txt_20");
- e.x = 180;
- e.y = 200;
- e.opacity = 0;
- stage.addChild(e);
- var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
- setTimeout(t.play, 100);
- tutArray.push(e)
- }
- function showTutorial_5_1() {
- var e = library.getSprite("txt_13");
- e.x = 160;
- e.y = 195;
- e.opacity = 0;
- stage.addChild(e);
- var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
- tutArray.push(e);
- setTimeout(function() {
- t.play();
- gameElementArray[7].addEventListener("mouseup", tutDone)
- }, 100)
- }
- function showTutorial_6() {
- var e = library.getSprite("txt_13");
- e.x = 210;
- e.y = 200;
- e.opacity = 0;
- stage.addChild(e);
- var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
- setTimeout(function() {
- t.play();
- gameElementArray[8].addEventListener("mouseup", tutDone)
- }, 100);
- tutArray.push(e)
- }
- function showTutorial_7() {
- var e = library.getSprite("txt_14");
- e.x = 170;
- e.y = 180;
- e.opacity = 0;
- stage.addChild(e);
- var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
- setTimeout(t.play, 100);
- tutArray.push(e)
- }
- function showTutorial_8() {
- var e = library.getSprite("txt_13");
- e.x = 160;
- e.y = 250;
- e.opacity = 0;
- stage.addChild(e);
- var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
- tutArray.push(e);
- setTimeout(function() {
- t.play();
- gameElementArray[12].addEventListener("mouseup", checkTurorial)
- }, 100)
- }
- function checkTurorial() {
- if ("easy" == currentDifficulty) {
- if (!tut01completed) {
- showTutorial_1();
- return
- }
- if (!tut02completed) {
- gameElementArray[18].removeEventListener("mouseup", tutDone);
- blockForTutorial = !1;
- gameElementArray[18].dispatchEvent("mouseup", {
- target: gameElementArray[18]
- });
- blockForTutorial = !0;
- showTutorial_2();
- return
- }
- if (!tut03completed) {
- gameElementArray[17].removeEventListener("mouseup", tutDone);
- blockForTutorial = !1;
- gameElementArray[17].dispatchEvent("mouseup", {
- target: gameElementArray[17]
- });
- blockForTutorial = !0;
- setTimeout(showTutorial_3, 2500);
- return
- }
- if (!tut04completed) {
- showTutorial_4();
- return
- }
- if (!tut05completed) {
- gameElementArray[4].removeEventListener("mouseup", tutDone);
- blockForTutorial = !1;
- gameElementArray[4].dispatchEvent("mouseup", {
- target: gameElementArray[4]
- });
- blockForTutorial = !0;
- showTutorial_5();
- return
- }
- if (!tut06completed) {
- gameElementArray[7].removeEventListener("mouseup", tutDone);
- blockForTutorial = !1;
- gameElementArray[7].dispatchEvent("mouseup", {
- target: gameElementArray[7]
- });
- tut06completed = blockForTutorial = !0;
- showTutorial_6();
- return
- }
- if (!tut07completed) {
- gameElementArray[8].removeEventListener("mouseup", tutDone);
- blockForTutorial = !1;
- gameElementArray[8].dispatchEvent("mouseup", {
- target: gameElementArray[8]
- });
- tut07completed = blockForTutorial = !0;
- showTutorial_7();
- return
- }
- if (!tut08completed) {
- clearTutorialSprites();
- gameElementArray[12].removeEventListener("mouseup", checkTurorial);
- blockForTutorial = !1;
- gameElementArray[12].dispatchEvent("mouseup", {
- target: gameElementArray[12]
- });
- tutorialActivated = !1;
- tut08completed = !0;
- levelTutorialCompleted();
- return
- }
- }
- if ("medium" != currentDifficulty || tut10completed) {
- if ("hard" == currentDifficulty) {
- if (!tut11completed) {
- tut11completed = !0;
- gameElementArray[18].removeEventListener("mouseup", tutDone);
- blockForTutorial = !1;
- gameElementArray[18].dispatchEvent("mouseup", {
- target: gameElementArray[18]
- });
- blockForTutorial = !0;
- showTutorial_12();
- return
- }
- if (!tut12completed) {
- gameElementArray[13].removeEventListener("mouseup", tutDone);
- blockForTutorial = !1;
- gameElementArray[13].dispatchEvent("mouseup", {
- target: gameElementArray[13]
- });
- tut12completed = blockForTutorial = !0;
- showTutorial_12_1();
- return
- }
- if (!tut12_1completed) {
- gameElementArray[18].removeEventListener("mouseup", tutDone);
- blockForTutorial = !1;
- gameElementArray[18].dispatchEvent("mouseup", {
- target: gameElementArray[18]
- });
- tut12_1completed = blockForTutorial = !0;
- showTutorial_13();
- return
- }
- if (!tut13completed) {
- gameElementArray[24].removeEventListener("mouseup", tutDone);
- blockForTutorial = !1;
- gameElementArray[24].dispatchEvent("mouseup", {
- target: gameElementArray[24]
- });
- tutorialActivated = !1;
- tut13completed = !0;
- levelTutorialCompleted();
- return
- }
- }
- "ultimate" != currentDifficulty || tut15completed || (tutorialActivated = blockForTutorial = !1, tut15completed = !0, showTutorial_15(), levelTutorialCompleted())
- } else gameElementArray[18].removeEventListener("mouseup", tutDone), blockForTutorial = !1, gameElementArray[18].dispatchEvent("mouseup", {
- target: gameElementArray[18]
- }), tutorialActivated = !1, tut10completed = !0, showTutorial_9(), levelTutorialCompleted()
- }
- function levelTutorialCompleted() {
- Utils.setCookie(currentDifficulty + "_tutorial_completed", !0)
- }
- function resetTutorialVariables() {
- tut01completed = tut02completed = tut03completed = tut04completed = tut05completed = tut06completed = tut07completed = tut08completed = tut09completed = tut10completed = tut11completed = tut12completed = tut12_1completed = tut13completed = tut14completed = tut15completed = blockForTutorial = !1
- }
- function checkDifficulty() {
- resetTutorialVariables();
- "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)
- }
- function showTutorial_10() {
- var e = library.getSprite("txt_5");
- e.x = 95;
- e.y = 192;
- e.opacity = 0;
- stage.addChild(e);
- var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
- setTimeout(t.play, 100);
- tutArray.push(e);
- e = library.getSprite("txt_13");
- e.x = 210;
- e.y = 295;
- e.opacity = 0;
- stage.addChild(e);
- fillGameElementArray();
- var n = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
- setTimeout(function() {
- n.play();
- gameElementArray[18].addEventListener("mouseup", tutDone)
- }, 3e3);
- tutArray.push(e)
- }
- function showTutorial_9() {
- var e = library.getSprite("txt_3");
- e.x = 160;
- e.y = 220;
- e.opacity = 0;
- stage.addChild(e);
- var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
- setTimeout(t.play, 100);
- setTimeout(function() {
- fadeOut(e)
- }, 5e3)
- }
- function showTutorial_11() {
- var e = library.getSprite("txt_4");
- e.x = 120;
- e.y = 178;
- e.opacity = 0;
- stage.addChild(e);
- var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
- setTimeout(t.play, 100);
- tutArray.push(e);
- e = library.getSprite("txt_13");
- e.x = 210;
- e.y = 295;
- e.opacity = 0;
- stage.addChild(e);
- fillGameElementArray();
- var n = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
- setTimeout(function() {
- n.play();
- gameElementArray[18].addEventListener("mouseup", tutDone)
- }, 3e3);
- tutArray.push(e)
- }
- function showTutorial_12() {
- var e = library.getSprite("txt_8");
- e.x = 105;
- e.y = 320;
- e.opacity = 0;
- stage.addChild(e);
- var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
- setTimeout(t.play, 100);
- tutArray.push(e);
- e = library.getSprite("txt_13");
- e.x = 210;
- e.y = 250;
- e.opacity = 0;
- stage.addChild(e);
- var n = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
- setTimeout(function() {
- n.play();
- gameElementArray[13].addEventListener("mouseup", tutDone)
- }, 3e3);
- tutArray.push(e)
- }
- function showTutorial_12_1() {
- var e = library.getSprite("txt_13");
- e.x = 210;
- e.y = 300;
- e.opacity = 0;
- stage.addChild(e);
- var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
- setTimeout(function() {
- t.play();
- gameElementArray[18].addEventListener("mouseup", tutDone)
- }, 1e3);
- tutArray.push(e)
- }
- function showTutorial_13() {
- var e = library.getSprite("txt_1");
- e.x = 155;
- e.y = 192;
- e.opacity = 0;
- stage.addChild(e);
- var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
- setTimeout(t.play, 100);
- tutArray.push(e);
- e = library.getSprite("txt_9");
- e.x = 195;
- e.y = 330;
- e.opacity = 0;
- stage.addChild(e);
- var n = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
- setTimeout(function() {
- n.play();
- gameElementArray[24].addEventListener("mouseup", tutDone)
- }, 3e3);
- tutArray.push(e)
- }
- function showTutorial_14() {
- blockForTutorial = !0;
- var e = library.getSprite("txt_19");
- e.x = 165;
- e.y = 175;
- e.opacity = 0;
- stage.addChild(e);
- var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
- setTimeout(t.play, 1e3);
- tutArray.push(e);
- tut14completed = !0
- }
- function showTutorial_15() {
- var e = library.getSprite("txt_9");
- e.x = 130;
- e.y = 150;
- e.opacity = 0;
- stage.addChild(e);
- var t = e.addTween("opacity", 1, 10, Easing.linear.out, null, null);
- setTimeout(t.play, 1e3);
- setTimeout(clearTutorialSprites, 3e3);
- tutArray.push(e)
- }
- function showMissionInfo() {
- stage.stop();
- var e = new Sprite(null, 320, 480);
- e.x = 160;
- e.y = 240;
- e.isMissionElement = !0;
- e.onmouseup = function() {
- gameState = STATE_GAME;
- createScene();
- return !1
- };
- stage.addChild(e);
- stage.addChild(library.getSprite("mission_bg", {
- x: 160,
- y: 240,
- isMissionElement: !0
- }));
- stage.addChild(library.getSprite("unicellar", {
- x: 55,
- y: 240,
- isMissionElement: !0,
- first: !0
- }));
- stage.addChild(library.getSprite("meduze", {
- x: 120,
- y: 240,
- isMissionElement: !0
- }));
- stage.addChild(library.getSprite("fish", {
- x: 185,
- y: 240,
- isMissionElement: !0
- }));
- stage.addChild(library.getSprite("arrow", {
- x: 87,
- y: 240,
- isMissionElement: !0
- }));
- stage.addChild(library.getSprite("arrow", {
- x: 152,
- y: 240,
- isMissionElement: !0
- }));
- stage.addChild(library.getSprite("arrow", {
- x: 217,
- y: 240,
- isMissionElement: !0
- }));
- stage.addChild(library.getSprite("arrow", {
- x: 282,
- y: 240,
- isMissionElement: !0
- }));
- stage.addChild(library.getSprite("arrow", {
- x: 37,
- y: 295,
- isMissionElement: !0
- }));
- stage.addChild(library.getSprite("arrow", {
- x: 102,
- y: 295,
- isMissionElement: !0
- }));
- stage.addChild(library.getSprite("arrow", {
- x: 167,
- y: 295,
- isMissionElement: !0
- }));
- stage.addChild(library.getSprite("arrow", {
- x: 232,
- y: 295,
- isMissionElement: !0
- }));
- "easy" == currentDifficulty ? (stage.addChild(library.getSprite("mission_untitled_b", {
- x: 250,
- y: 240,
- isMissionElement: !0
- })), stage.addChild(library.getSprite("mission_untitled_a", {
- x: 70,
- y: 295,
- isMissionElement: !0
- })), stage.addChild(library.getSprite("mission_untitled_a", {
- x: 135,
- y: 295,
- isMissionElement: !0
- })), stage.addChild(library.getSprite("mission_untitled_a", {
- x: 200,
- y: 295,
- isMissionElement: !0
- })), stage.addChild(library.getSprite("mission_create_1", {
- x: 160,
- y: 335,
- isMissionElement: !0
- })), stage.addChild(library.getSprite("mission_untitled_a", {
- x: 265,
- y: 295,
- isMissionElement: !0
- }))) : "medium" == currentDifficulty ? (stage.addChild(library.getSprite("pangolin", {
- x: 250,
- y: 240,
- isMissionElement: !0
- })), stage.addChild(library.getSprite("mission_untitled_b", {
- x: 70,
- y: 295,
- isMissionElement: !0
- })), stage.addChild(library.getSprite("mission_untitled_a", {
- x: 135,
- y: 295,
- isMissionElement: !0
- })), stage.addChild(library.getSprite("mission_untitled_a", {
- x: 200,
- y: 295,
- isMissionElement: !0
- })), stage.addChild(library.getSprite("mission_create_2", {
- x: 160,
- y: 335,
- isMissionElement: !0
- })), stage.addChild(library.getSprite("mission_untitled_a", {
- x: 265,
- y: 295,
- isMissionElement: !0
- }))) : "hard" == currentDifficulty ? (stage.addChild(library.getSprite("pangolin", {
- x: 250,
- y: 240,
- isMissionElement: !0
- })), stage.addChild(library.getSprite("mammal", {
- x: 70,
- y: 295,
- isMissionElement: !0
- })), stage.addChild(library.getSprite("mission_untitled_b", {
- x: 135,
- y: 295,
- isMissionElement: !0
- })), stage.addChild(library.getSprite("mission_untitled_a", {
- x: 200,
- y: 295,
- isMissionElement: !0
- })), stage.addChild(library.getSprite("mission_create_3", {
- x: 160,
- y: 335,
- isMissionElement: !0
- })), stage.addChild(library.getSprite("mission_untitled_a", {
- x: 265,
- y: 295,
- isMissionElement: !0
- }))) : "expert" == currentDifficulty ? (stage.addChild(library.getSprite("pangolin", {
- x: 250,
- y: 240,
- isMissionElement: !0
- })), stage.addChild(library.getSprite("mammal", {
- x: 70,
- y: 295,
- isMissionElement: !0
- })), stage.addChild(library.getSprite("people", {
- x: 135,
- y: 295,
- isMissionElement: !0
- })), stage.addChild(library.getSprite("mission_untitled_b", {
- x: 200,
- y: 295,
- isMissionElement: !0
- })), stage.addChild(library.getSprite("mission_create_4", {
- x: 160,
- y: 335,
- isMissionElement: !0
- })), stage.addChild(library.getSprite("mission_untitled_a", {
- x: 265,
- y: 295,
- isMissionElement: !0
- }))) : "ultimate" == currentDifficulty && (stage.addChild(library.getSprite("pangolin", {
- x: 250,
- y: 240,
- isMissionElement: !0
- })), stage.addChild(library.getSprite("mammal", {
- x: 70,
- y: 295,
- isMissionElement: !0
- })), stage.addChild(library.getSprite("people", {
- x: 135,
- y: 295,
- isMissionElement: !0
- })), stage.addChild(library.getSprite("uslon", {
- x: 200,
- y: 295,
- isMissionElement: !0
- })), stage.addChild(library.getSprite("mission_create_5", {
- x: 160,
- y: 335,
- isMissionElement: !0
- })), stage.addChild(library.getSprite("mission_untitled_b", {
- x: 265,
- y: 295,
- isMissionElement: !0
- })))
- }
- function checkIfNeedLaunchTutorial(e, t) {
- if ("easy" == currentDifficulty && tutorialActivated || "medium" == currentDifficulty && tutorialActivated || "hard" == currentDifficulty && tutorialActivated) return showTutorial(e, t), !0;
- if ("ultimate" == currentDifficulty && tutorialActivated) return showTutorial(e, t), !1
- }
- var CRENDER_DEBUG = !1;
- var Utils = {
- touchScreen: "ontouchstart" in window,
- globalScale: 1,
- setCookie: function(e, t) {
- try {
- window.localStorage.setItem(e, t)
- } catch (n) {
- var r = new Date;
- r.setDate(r.getDate() + 3650);
- document.cookie = e + "=" + t + "; expires=" + r.toUTCString()
- }
- },
- getCookie: function(e) {
- var t;
- try {
- t = window.localStorage.getItem(e)
- } catch (n) {
- e += "=";
- t = document.cookie.indexOf(e);
- if (-1 == t) return null;
- var r = document.cookie.indexOf(";", t + e.length); - 1 == r && (r = document.cookie.length);
- t = unescape(document.cookie.substring(t + e.length, r))
- }
- return t
- },
- bindEvent: function(e, t, n) {
- e.addEventListener ? e.addEventListener(t, n, !1) : e.attachEvent && e.attachEvent("on" + t, n)
- },
- getObjectLeft: function(e) {
- var t = e.offsetLeft;
- e.offsetParent && (t += Utils.getObjectLeft(e.offsetParent));
- return t
- },
- getObjectTop: function(e) {
- var t = e.offsetTop;
- e.offsetParent && (t += Utils.getObjectTop(e.offsetParent));
- return t
- },
- parseGet: function() {
- var e = {},
- t = new String(window.location),
- n = t.indexOf("?");
- if (-1 != n)
- 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];
- return e
- },
- globalPixelScale: 1,
- getMouseCoord: function(e, t) {
- var n = e || window.event;
- n.touches && (n = n.touches[0]);
- if (!n) return {
- x: 0,
- y: 0
- };
- var r = 0,
- i = 0,
- s = 0,
- o = 0;
- t && (r = Utils.getObjectLeft(t), i = Utils.getObjectTop(t));
- if (n.pageX || n.pageY) s = n.pageX, o = n.pageY;
- 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;
- return {
- x: s - r,
- y: o - i
- }
- },
- extend: function(e, t) {
- var n = function() {};
- n.prototype = t.prototype;
- e.prototype = new n;
- e.prototype.constructor = e;
- e.superclass = t.prototype
- },
- removeFromArray: function(e, t) {
- for (var n = [], r = 0; r < e.length; r++) e[r] != t && n.push(e[r]);
- return n
- },
- showLoadProgress: function(e) {
- var t = Utils.globalScale,
- n;
- n = "Loading: " + e + "%<br><br>";
- n += '<div style="display: block; background: #000; width: ' + e * t * 2 + "px; height: " + 10 * t + 'px;"> </div>';
- document.getElementById("progress").innerHTML = n
- },
- hideAddressBarLock: !1,
- mobileHideAddressBar: function() {
- Utils.hideAddressBarLock || window.scrollTo(0, 1)
- },
- mobileCheckIphone4: function() {
- return window.devicePixelRatio && -1 != navigator.userAgent.indexOf("iPhone") && 2 == window.devicePixelRatio ? !0 : !1
- },
- mobileCheckBrokenGalaxyPhones: function() {
- return !window.devicePixelRatio || -1 == navigator.userAgent.indexOf("GT-I9300") && -1 == navigator.userAgent.indexOf("GT-I8190") && -1 == navigator.userAgent.indexOf("Android 4.") ? !1 : !0
- },
- checkSpilgamesEnvironment: function() {
- return "undefined" != typeof ExternalAPI && "Spilgames" == ExternalAPI.type && ExternalAPI.check()
- },
- mobileCorrectPixelRatio: function() {
- var e = document.createElement("meta");
- e.name = "viewport";
- var t = "target-densitydpi=device-dpi, user-scalable=0",
- 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";
- e.content = t;
- document.getElementsByTagName("head")[0].appendChild(e)
- },
- getMobileScreenResolution: function(e) {
- var t = 1,
- n = [{
- scale: 1,
- width: 320,
- height: 480
- }, {
- scale: 1.5,
- width: 480,
- height: 720
- }, {
- scale: 2,
- width: 640,
- height: 960
- }],
- r = {
- width: 0,
- height: 0
- },
- i = "";
- 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);
- for (var i = "height", s = Number.MAX_VALUE, o = 0; o < n.length; o++) {
- var u = Math.abs(r[i] - n[o][i]);
- s > u && (s = u, t = n[o].scale)
- }
- return Utils.getScaleScreenResolution(t, e)
- },
- getScaleScreenResolution: function(e, t) {
- var n, r;
- n = Math.round(320 * e);
- r = Math.round(480 * e);
- if (t) {
- var i = n;
- n = r;
- r = i
- }
- return {
- width: n,
- height: r,
- scale: e
- }
- },
- imagesRoot: "images",
- initialResolution: {
- width: 320,
- height: 480,
- scale: 1
- },
- createLayout: function(e, t, n, r) {
- var i = Utils.globalScale;
- Utils.initialResolution = t;
- n = window.innerHeight;
- "orientation" in window ? n = 2048 : document.body.style.overflow = "hidden";
- 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>');
- i += "</div>";
- 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;">';
- i += '<div id="screen_background_wrapper" style="width: ' + t.width + "px; height: " + t.height + 'px; overflow: hidden; position: relative;">';
- r || (i += '<canvas id="screen_background" width="' + t.width + '" height="' + t.height + '"></canvas>');
- i += "</div>";
- i += "</div>";
- i += '<div id="screen_container" align="center" style="width: 100%; height: ' + n + 'px; position: absolute; left: 0px; top: 0px; display: none; z-index: 3;">';
- i += '<div id="screen_wrapper" width="' + t.width + '" height="' + t.height + '" style="width: ' + t.width + "px; height: " + t.height + 'px; overflow: hidden; position: relative;">';
- 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>');
- i += "</div>";
- i += "</div>";
- e.innerHTML = i;
- e = document.createElement("div");
- e.setAttribute("id", "p2l_container");
- e.setAttribute("align", "center");
- t = t.width;
- e.setAttribute("style", "width: 100%; height: " + n + "px; position: absolute; left: 0px; top: 0px; display: none; z-index: 10; background: #fff;");
- e.innerHTML = '<img id="p2l" src="' + Utils.imagesRoot + '/p2l.jpg" style="padding-top: ' + (t - 240) / 2 + 'px" />';
- document.body.appendChild(e)
- },
- preventEvent: function(e) {
- e.preventDefault();
- e.stopPropagation();
- e.cancelBubble = !0;
- return e.returnValue = !1
- },
- addMobileListeners: function(e, t) {
- !t && navigator.userAgent.match(/(iPad|iPhone|iPod).*CPU.*OS 7_\d/i) || Utils.bindEvent(document.getElementById("main_container"), "touchstart", Utils.preventEvent);
- Utils.bindEvent(window, "scroll", function(e) {
- setTimeout(Utils.mobileHideAddressBar, 300)
- });
- setInterval("Utils.checkOrientation(" + (e ? "true" : "false") + ")", 500);
- setTimeout(Utils.mobileHideAddressBar, 500)
- },
- storeOrient: null,
- noCheckOrient: !1,
- checkOrientation: function(e) {
- if (Utils.touchScreen && document.getElementById("screen_container")) {
- var t = Utils.parseGet();
- if (!Utils.noCheckOrient && 1 != t.nocheckorient) {
- t = !1;
- if (window == window.parent) t = window.innerWidth > window.innerHeight;
- else var n = Math.max(screen.width, screen.height),
- t = Math.min(screen.width, screen.height),
- n = Math.abs(window.innerWidth - n),
- t = Math.abs(window.innerWidth - t),
- t = n < t;
- 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))
- }
- }
- },
- fitLayoutTimer: null,
- addFitLayoutListeners: function() {
- Utils.fitLayoutTimer = setInterval(Utils.fitLayoutToScreen, 500)
- },
- removeFitLayoutListeners: function() {
- clearInterval(Utils.fitLayoutTimer)
- },
- fitLayoutLock: !1,
- fitLayoutCorrectHeight: 0,
- fitLayoutToScreen: function(e) {
- if (!Utils.fitLayoutLock) {
- var t, n, r;
- "object" == typeof e && e.width || (n = window.innerWidth, r = window.innerHeight, Utils.checkSpilgamesEnvironment() && (r -= 25), r += Utils.fitLayoutCorrectHeight, e = {
- width: n,
- height: r
- });
- if (t = document.getElementById("screen_wrapper")) {
- t.initWidth || (t.initWidth = Utils.initialResolution.width, t.initHeight = Utils.initialResolution.height);
- n = t.initWidth;
- r = t.initHeight;
- var i = 1,
- i = e.width / n;
- e = e.height / r;
- i = i < e ? i : e;
- Utils.globalPixelScale = i;
- n = Math.floor(n * i);
- r = Math.floor(r * i);
- if (t.lastWidth != n || t.lastHeight != r) {
- t.lastWidth = n;
- t.lastHeight = r;
- Utils.resizeElement("screen", n, r);
- Utils.resizeElement("screen_background", n, r);
- if (t = document.getElementById("progress")) t.style.width = ~~n + "px", t.style.height = ~~r + "px";
- if (t = document.getElementById("screen_wrapper")) t.style.width = ~~n + "px", t.style.height = ~~r + "px";
- if (t = document.getElementById("screen_background_wrapper")) t.style.width = ~~n + "px", t.style.height = ~~r + "px";
- if (t = document.getElementById("p2l_container")) t.style.width = ~~window.innerWidth + "px", t.style.height = "2048px";
- Utils.dispatchEvent("fitlayout");
- setTimeout(Utils.mobileHideAddressBar, 50)
- }
- }
- }
- },
- resizeElement: function(e, t, n) {
- if (e = document.getElementById(e)) e.setAttribute("width", t), e.setAttribute("height", n)
- },
- drawIphoneLimiter: function(e, t) {
- t ? e.drawRectangle(240, 295, 480, 54, "#f00", !0, .5, !0) : e.drawRectangle(160, 448, 320, 64, "#f00", !0, .5, !0)
- },
- drawGrid: function(e, t, n) {
- "undefined" == typeof t && (t = !1);
- "undefined" == typeof n && (n = "#FFF");
- var r = 1 / Utils.globalScale / Utils.globalPixelScale,
- i = t ? 480 : 320;
- t = t ? 320 : 480;
- for (var s = 10; s < i; s += 10) {
- var o = .1 + (s - 10) / 10 % 10 * .1;
- e.drawLine(s, 0, s, t, r, n, o)
- }
- for (s = 10; s < t; s += 10) o = .1 + (s - 10) / 10 % 10 * .1, e.drawLine(0, s, i, s, r, n, o)
- },
- 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));
- 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))
- },
- grad2radian: function(e) {
- return e / (180 / Math.PI)
- },
- radian2grad: function(e) {
- return 180 / Math.PI * e
- },
- eventsListeners: [],
- onlockscreen: null,
- onunlockscreen: null,
- onfitlayout: null,
- addEventListener: function(e, t) {
- EventsManager.addEvent(Utils, e, t)
- },
- removeEventListener: function(e, t) {
- EventsManager.removeEvent(Utils, e, t)
- },
- dispatchEvent: function(e, t) {
- return EventsManager.dispatchEvent(Utils, e, t)
- }
- },
- EventsManager = {
- addEvent: function(e, t, n) {
- if (e.eventsListeners) {
- for (var r = 0; r < e.eventsListeners.length; r++)
- if (e.eventsListeners[r].type === t && e.eventsListeners[r].callback === n) return;
- e.eventsListeners.push({
- type: t,
- callback: n
- })
- }
- },
- removeEvent: function(e, t, n) {
- if (e.eventsListeners)
- for (var r = 0; r < e.eventsListeners.length; r++)
- if (e.eventsListeners[r].type === t && e.eventsListeners[r].callback === n) {
- e.eventsListeners = Utils.removeFromArray(e.eventsListeners, e.eventsListeners[r]);
- break
- }
- },
- dispatchEvent: function(e, t, n) {
- if (e.eventsListeners) {
- var r;
- if ("function" == typeof e["on" + t] && (r = e["on" + t](n), !1 === r)) return !1;
- for (var i = 0; i < e.eventsListeners.length; i++)
- if (e.eventsListeners[i].type === t && (r = e.eventsListeners[i].callback(n), !1 === r)) return !1
- }
- }
- },
- ANCHOR_ALIGN_LEFT = -1,
- ANCHOR_ALIGN_CENTER = 0,
- ANCHOR_ALIGN_RIGHT = 1,
- ANCHOR_VALIGN_TOP = -1,
- ANCHOR_VALIGN_MIDDLE = 0,
- ANCHOR_VALIGN_BOTTOM = 1;
- var Easing = {
- back: {
- easeIn: function(e, t, n, r) {
- return n * (e /= r) * e * (2.70158 * e - 1.70158) + t
- },
- easeOut: function(e, t, n, r) {
- return n * ((e = e / r - 1) * e * (2.70158 * e + 1.70158) + 1) + t
- },
- easeInOut: function(e, t, n, r) {
- var i = 1.70158;
- 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
- }
- },
- bounce: {
- easeIn: function(e, t, n, r) {
- return n - Easing.bounce.easeOut(r - e, 0, n, r) + t
- },
- easeOut: function(e, t, n, r) {
- 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
- },
- easeInOut: function(e, t, n, r) {
- 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
- }
- },
- circular: {
- easeIn: function(e, t, n, r) {
- return -n * (Math.sqrt(1 - (e /= r) * e) - 1) + t
- },
- easeOut: function(e, t, n, r) {
- return n * Math.sqrt(1 - (e = e / r - 1) * e) + t
- },
- easeInOut: function(e, t, n, r) {
- return 1 > (e /= r / 2) ? -n / 2 * (Math.sqrt(1 - e * e) - 1) + t : n / 2 * (Math.sqrt(1 - (e -= 2) * e) + 1) + t
- }
- },
- cubic: {
- easeIn: function(e, t, n, r) {
- return n * (e /= r) * e * e + t
- },
- easeOut: function(e, t, n, r) {
- return n * ((e = e / r - 1) * e * e + 1) + t
- },
- easeInOut: function(e, t, n, r) {
- return 1 > (e /= r / 2) ? n / 2 * e * e * e + t : n / 2 * ((e -= 2) * e * e + 2) + t
- }
- },
- exponential: {
- easeIn: function(e, t, n, r) {
- return 0 == e ? t : n * Math.pow(2, 10 * (e / r - 1)) + t
- },
- easeOut: function(e, t, n, r) {
- return e == r ? t + n : n * (-Math.pow(2, -10 * e / r) + 1) + t
- },
- easeInOut: function(e, t, n, r) {
- 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
- }
- },
- linear: {
- easeIn: function(e, t, n, r) {
- return n * e / r + t
- },
- easeOut: function(e, t, n, r) {
- return n * e / r + t
- },
- easeInOut: function(e, t, n, r) {
- return n * e / r + t
- }
- },
- quadratic: {
- easeIn: function(e, t, n, r) {
- return n * (e /= r) * e + t
- },
- easeOut: function(e, t, n, r) {
- return -n * (e /= r) * (e - 2) + t
- },
- easeInOut: function(e, t, n, r) {
- return 1 > (e /= r / 2) ? n / 2 * e * e + t : -n / 2 * (--e * (e - 2) - 1) + t
- }
- },
- quartic: {
- easeIn: function(e, t, n, r) {
- return n * (e /= r) * e * e * e + t
- },
- easeOut: function(e, t, n, r) {
- return -n * ((e = e / r - 1) * e * e * e - 1) + t
- },
- easeInOut: function(e, t, n, r) {
- return 1 > (e /= r / 2) ? n / 2 * e * e * e * e + t : -n / 2 * ((e -= 2) * e * e * e - 2) + t
- }
- },
- quintic: {
- easeIn: function(e, t, n, r) {
- return n * (e /= r) * e * e * e * e + t
- },
- easeOut: function(e, t, n, r) {
- return n * ((e = e / r - 1) * e * e * e * e + 1) + t
- },
- easeInOut: function(e, t, n, r) {
- return 1 > (e /= r / 2) ? n / 2 * e * e * e * e * e + t : n / 2 * ((e -= 2) * e * e * e * e + 2) + t
- }
- },
- sine: {
- easeIn: function(e, t, n, r) {
- return -n * Math.cos(e / r * (Math.PI / 2)) + n + t
- },
- easeOut: function(e, t, n, r) {
- return n * Math.sin(e / r * (Math.PI / 2)) + t
- },
- easeInOut: function(e, t, n, r) {
- return -n / 2 * (Math.cos(Math.PI * e / r) - 1) + t
- }
- }
- };
- var Rectangle = function(e, t, n, r, i) {
- this.center = new Vector(e, t);
- this.width = n;
- this.height = r;
- this.angle = i;
- this.vertices = [];
- this.AABB = [];
- this.clone = function() {
- return new Rectangle(this.center.x, this.center.y, this.width, this.height, this.angle)
- };
- this.refreshVertices = function() {
- var e = this.width / 2,
- t = this.height / 2;
- this.vertices = [];
- this.vertices.push(new Vector(-e, t));
- this.vertices.push(new Vector(e, t));
- this.vertices.push(new Vector(e, -t));
- this.vertices.push(new Vector(-e, -t));
- this.AABB = [this.center.clone(), this.center.clone()];
- 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)
- };
- this.move = function(e, t) {
- this.center.add(new Vector(e, t));
- this.refreshVertices()
- };
- this.rotate = function(e) {
- this.angle += e;
- this.refreshVertices()
- };
- this.hitTestPoint = function(e) {
- e = e.clone();
- e.normalize(-this.angle, this.center);
- return Math.abs(e.x) <= this.width / 2 && Math.abs(e.y) <= this.height / 2
- };
- this.hitTestRectangle = function(e) {
- var t = this.clone();
- e = e.clone();
- var n, r, i;
- t.move(-this.center.x, -this.center.y);
- e.move(-this.center.x, -this.center.y);
- e.center.rotate(this.angle);
- t.rotate(-this.angle);
- e.rotate(-this.angle);
- 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);
- r = t.AABB[1].x - t.AABB[0].x;
- i = e.AABB[1].x - e.AABB[0].x;
- if (n > r + i) return !1;
- 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);
- r = t.AABB[1].y - t.AABB[0].y;
- i = e.AABB[1].y - e.AABB[0].y;
- if (n > r + i) return !1;
- t.move(-e.center.x, -e.center.y);
- e.move(-e.center.x, -e.center.y);
- t.center.rotate(e.angle);
- t.refreshVertices();
- t.rotate(-e.angle);
- e.rotate(-e.angle);
- 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);
- r = t.AABB[1].x - t.AABB[0].x;
- i = e.AABB[1].x - e.AABB[0].x;
- if (n > r + i) return !1;
- 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);
- r = t.AABB[1].y - t.AABB[0].y;
- i = e.AABB[1].y - e.AABB[0].y;
- return n > r + i ? !1 : !0
- };
- this.refreshVertices()
- },
- Asset = function(e, t, n, r, i, s) {
- this.name = e + "";
- this.src = t + "";
- this.width = n;
- this.height = r;
- this.frames = i;
- this.layers = s;
- this.object = this.bitmap = null;
- this.ready = this.width && this.height;
- this.detectSize = function() {
- if (!this.bitmap) return !1;
- try {
- 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)
- } catch (e) {
- CRENDER_DEBUG && console.log(e)
- }
- return !isNaN(this.width) && !isNaN(this.height)
- };
- this.normalize = function(e) {
- if (!this.ready && this.detectSize()) {
- if (isNaN(this.frames) || 1 > this.frames) this.frames = 1;
- if (isNaN(this.layers) || 1 > this.layers) this.layers = 1;
- this.width = Math.ceil(this.width / this.layers / e);
- this.height = Math.ceil(this.height / this.frames / e);
- this.ready = !0
- }
- }
- },
- AssetsLibrary = function(e, t, n) {
- var r = this;
- this.path = "images";
- this.scale = 1;
- this.items = {};
- this.bitmaps = {};
- this.loaded = !1;
- this.onloadprogress = this.onload = null;
- this.spriteClass = Sprite;
- this.init = function(e, t) {
- "undefined" != typeof e && (this.path = e + "");
- "undefined" != typeof t && (this.scale = parseFloat(t), isNaN(this.scale) && (this.scale = 1))
- };
- this.addAssets = function(e) {
- if ("undefined" != typeof e && "object" == typeof e)
- for (var t = 0; t < e.length; t++) {
- var n = e[t];
- n.noscale = "undefined" == typeof n.noscale ? !1 : n.noscale;
- n.noscale || (n.src = "%SCALE%/" + n.src);
- this.addAsset(n.src, n.name, n.width, n.height, n.frames, n.layers)
- }
- };
- this.addAsset = function(e, t, n, r, i, s) {
- e = e.replace("%SCALE%", "%PATH%/" + this.scale);
- e = e.replace("%PATH%", this.path);
- "undefined" == typeof t && (t = e.split("http://resource.duopao.com/"), t = t.pop(), t = t.split("."), t = t.shift() + "");
- e = new Asset(t, e, n, r, i, s);
- return this.items[t] = e
- };
- this.addObject = function(e) {
- var t = this.addAsset("%SCALE%/" + e.image, e.name, e.width * this.scale, e.height * this.scale, e.frames, e.layers);
- t && (t.object = e);
- return t
- };
- this.load = function(e, t) {
- this.onload = e;
- this.onloadprogress = t;
- var n = new ImagesPreloader,
- i = [],
- s;
- for (s in this.items) i.push(this.items[s]);
- n.load(i, r.onLoadHandler, r.onLoadProgressHandler)
- };
- this.onLoadProgressHandler = function(e) {
- if ("function" == typeof r.onloadprogress) r.onloadprogress(e)
- };
- this.onLoadHandler = function(e) {
- r.loaded = !0;
- for (var t in e) {
- var n = r.items[t];
- n.bitmap = e[t];
- n.normalize(r.scale)
- }
- if ("function" == typeof r.onload) r.onload(r.items)
- };
- this.getAsset = function(e, t) {
- var n = null;
- "undefined" != typeof this.items[e] && this.items[e].bitmap && (n = "undefined" != typeof t && !t || this.items[e].ready ? this.items[e] : null);
- if (!n) throw Error('Trying to get undefined asset "' + e + '"');
- return n
- };
- this.getSprite = function(e, t) {
- var n = null;
- try {
- var r = this.getAsset(e, !0),
- n = new this.spriteClass(r.bitmap, r.width, r.height, r.frames, r.layers)
- } catch (i) {
- n = new this.spriteClass(null, 1, 1, 1, 1)
- }
- if ("object" == typeof t)
- for (var s in t) n[s] = t[s];
- return n
- };
- this.getBitmap = function(e) {
- try {
- return this.getAsset(e, !0).bitmap
- } catch (t) {
- return null
- }
- };
- this.init(e, t);
- this.addAssets(n)
- };
- "undefined" == typeof console && (console = {
- log: function() {}
- });
- var TTLoader = {
- endCallback: null,
- loadedData: null,
- landscapeMode: !1,
- skipPlayButton: !1,
- create: function(e, t, n) {
- TTLoader.endCallback = e;
- TTLoader.landscapeMode = t;
- TTLoader.skipPlayButton = n;
- TTLoader.fillLogo();
- document.getElementById("progress_container").style.background = "#E9573F";
- document.getElementById("progress_container").style.zIndex = "100";
- e = document.getElementById("progress");
- e.setAttribute("valign", "top");
- e.style.verticalAlign = "top";
- e.style.background = "#E9573F";
- t = document.createElement("div");
- n = document.createElement("a");
- n.setAttribute("id", "tt_load_logo_c");
- // n.setAttribute("href", "http://play68.com/");
- n.setAttribute("target", "_blank");
- var r = new Image;
- r.setAttribute("id", "tt_load_logo");
- r.setAttribute("border", "");
- r.src = TTLoader.logoSrc[0];
- r.style.cursor = "pointer";
- n.appendChild(r);
- t.appendChild(n);
- e.appendChild(t);
- t = document.createElement("div");
- t.setAttribute("id", "tt_load_progress_cont");
- t.setAttribute("align", "left");
- t.setAttribute("style", "padding: 1px; border: 2px solid #0478b8; background: #fff");
- n = document.createElement("div");
- n.setAttribute("id", "tt_load_progress");
- n.setAttribute("style", "width: 0px; background: #0088cd;");
- n.innerHTML = " ";
- t.appendChild(n);
- e.appendChild(t);
- t = document.createElement("div");
- t.setAttribute("id", "tt_load_play");
- n = new Image;
- n.setAttribute("id", "tt_load_button");
- n.src = TTLoader.buttonDisabledSrc;
- t.appendChild(n);
- e.appendChild(t);
- Utils.addEventListener("fitlayout", TTLoader.setSizes);
- TTLoader.setSizes();
- TTLoader.animateLogo()
- },
- setSizes: function() {
- document.getElementById("progress_container").style.width = window.innerWidth + "px";
- document.getElementById("progress_container").style.height = "2048px";
- var e = Utils.globalScale * Utils.globalPixelScale;
- TTLoader.landscapeMode || (document.getElementById("progress").style.paddingTop = Math.floor(80 * e) + "px");
- document.getElementById("tt_load_progress_cont").style.width = Math.floor(200 * e) + "px";
- document.getElementById("tt_load_progress").style.height = Math.floor(12 * e) + "px";
- document.getElementById("tt_load_progress").style.width = e * TTLoader.progressVal * 2 + "px";
- document.getElementById("tt_load_logo").setAttribute("width", Math.floor(180 * e) + "px");
- document.getElementById("tt_load_logo").setAttribute("height", Math.floor(180 * e) + "px");
- document.getElementById("tt_load_button").setAttribute("height", Math.floor(29 * e) + "px");
- document.getElementById("tt_load_button").style.marginTop = Math.floor(20 * e) + "px"
- },
- progressVal: 0,
- showLoadProgress: function(e) {
- TTLoader.progressVal = e;
- TTLoader.setSizes()
- },
- loadComplete: function(e) {
- TTLoader.showLoadProgress(100);
- TTLoader.loadedData = e;
- e = document.getElementById("tt_load_button");
- Utils.touchScreen ? (document.getElementById("main_container").removeEventListener("touchstart", Utils.preventEvent), e.ontouchstart = TTLoader.close) : e.onclick = TTLoader.close;
- e.style.cursor = "pointer";
- e.src = TTLoader.buttonSrc;
- e = document.getElementById("tt_load_progress");
- e.style.background = "transparent";
- e = document.getElementById("tt_load_progress_cont");
- e.style.border = "2px solid transparent";
- e.style.background = "transparent";
- document.getElementById("tt_load_button").style.display = "block";
- TTLoader.skipPlayButton && TTLoader.close()
- },
- close: function() {
- TTLoader.endCallback(TTLoader.loadedData);
- Utils.touchScreen && document.getElementById("main_container").addEventListener("touchstart", Utils.preventEvent, !1)
- },
- logoSrc: [],
- currentLogoFrame: 0,
- logoOpacity: 0,
- animateLogo: function() {
- 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 + ")");
- 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));
- setTimeout(TTLoader.animateLogo, 100)
- },
- fillLogo: function() {
- var e = [];
- e.push("logo.png");
- TTLoader.logoSrc = e
- },
- buttonDisabledSrc: "tt_load_buttondisabled.png",
- buttonSrc: "tt_load_button.png"
- };
- var STR_ALIGN_LEFT = "left",
- STR_ALIGN_CENTER = "center",
- STR_ALIGN_RIGHT = "right",
- STR_VALIGN_TOP = "top",
- STR_VALIGN_MIDDLE = "middle",
- STR_VALIGN_BOTTOM = "bottom",
- GUIFont = function(e) {
- this.animated = !1;
- this.fontProperties = e;
- this.charmap = this.fontProperties.charmap;
- 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);
- GUIFont.prototype.validChar = function(e) {
- return 0 <= this.fontProperties.charmap.indexOf(e.toString())
- };
- GUIFont.prototype.setChar = function(e) {
- e = this.fontProperties.charmap.indexOf(e.toString());
- 0 > e || (this.currentLayer = e % this.totalLayers, this.gotoAndStop(Math.floor(e / this.totalLayers)))
- };
- GUIFont.prototype.getChar = function() {
- return this.fontProperties.charmap[this.currentLayer + this.currentFrame * this.totalLayers]
- }
- };
- Utils.extend(GUIFont, Sprite);
- var GUIString = function(e, t, n) {
- this.font = FontManager.getFont(e);
- if (!this.font) throw Error("Font '" + e + "' not found!");
- this.strings = [];
- this.chars = [];
- this.align = STR_ALIGN_CENTER;
- this.valign = STR_VALIGN_MIDDLE;
- e = new this.font;
- this.charWidth = e.fontProperties["char"].width;
- this.charHeight = e.fontProperties["char"].height;
- delete e;
- this.visible = !0;
- this.rotation = this.zIndex = this.y = this.x = 0;
- this.opacity = 1;
- this.width = this.height = 0;
- this["static"] = "undefined" == typeof t ? !1 : t;
- this.getString = function() {
- return this.strings.join("\n")
- };
- this.getParams = function() {
- return {
- visible: this.visible,
- x: this.x,
- y: this.y,
- zIndex: this.zIndex,
- rotation: this.rotation,
- opacity: this.opacity,
- align: this.align,
- valign: this.valign,
- letterSpacing: this.charWidth,
- lineHeight: this.charHeight
- }
- };
- this.setParams = function(e, t) {
- "object" != typeof e && (e = {});
- "undefined" == typeof t && (t = !1);
- "undefined" == typeof e.visible && (e.visible = this.visible);
- "undefined" == typeof e.letterSpacing && (e.letterSpacing = this.charWidth);
- "undefined" == typeof e.lineHeight && (e.lineHeight = this.charHeight);
- "undefined" == typeof e.align && (e.align = this.align);
- "undefined" == typeof e.valign && (e.valign = this.valign);
- "undefined" == typeof e.x && (e.x = this.x);
- e.x = parseInt(e.x);
- isNaN(e.x) && (e.x = this.x);
- "undefined" == typeof e.y && (e.y = this.y);
- e.y = parseInt(e.y);
- isNaN(e.y) && (e.y = this.y);
- "undefined" == typeof e.zIndex && (e.zIndex = this.zIndex);
- e.zIndex = parseInt(e.zIndex);
- isNaN(e.zIndex) && (e.zIndex = this.zIndex);
- "undefined" == typeof e.rotation && (e.rotation = this.rotation);
- e.rotation = parseFloat(e.rotation);
- isNaN(e.rotation) && (e.rotation = this.rotation);
- "undefined" == typeof e.opacity && (e.opacity = this.opacity);
- e.opacity = parseFloat(e.opacity);
- isNaN(e.opacity) && (e.opacity = this.opacity);
- if (e.letterSpacing != this.charWidth || e.lineHeight != this.charHeight) this._setSpacing(e.letterSpacing, e.lineHeight), t = !0;
- if (e.align != this.align || e.valign != this.valign) this._setAlign(e.align, e.valign), t = !0;
- 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);
- e.zIndex != this.zIndex && this._setZIndex(e.zIndex);
- e.visible != this.visible && this._setVisible(e.visible)
- };
- this.refresh = function() {
- this.setParams(this.getParams())
- };
- this.write = function(e, t, n, r, i, s, o, u) {
- this.strings = e = this._prepareString(e);
- this._createStageChars();
- e = {
- align: r,
- valign: i,
- x: t,
- y: n,
- rotation: s,
- letterSpacing: o,
- lineHeight: u
- };
- 0 < this.chars.length && (e.zIndex = 0 < this.zIndex ? this.zIndex : this.chars[0].zIndex);
- for (n = t = 0; n < this.strings.length; n++)
- 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));
- this.setParams(e, !0)
- };
- this.clear = function() {
- this.write("")
- };
- this._setVisible = function(e) {
- this.visible = e;
- for (e = 0; e < this.chars.length; e++) this.chars[e] && (this.chars[e].visible = this.visible)
- };
- this._setOpacity = function(e) {
- this.opacity = e;
- for (e = 0; e < this.chars.length; e++) this.chars[e] && (this.chars[e].opacity = this.opacity)
- };
- this._setZIndex = function(e) {
- "undefined" == typeof e && (e = this.zIndex);
- e = ~~e;
- if (e != this.zIndex) {
- this.zIndex = ~~e;
- for (var t = 0; t < this.chars.length; t++) this.chars[t] && this.chars[t].setZIndex(e)
- }
- };
- this._setSpacing = function(e, t) {
- "undefined" == typeof e && (e = this.charWidth);
- this.charWidth = ~~e;
- "undefined" == typeof t && (t = this.charHeight);
- this.charHeight = ~~t
- };
- this._setAlign = function(e, t) {
- "undefined" == typeof e && (e = this.align);
- this.align = e.toString().toLowerCase();
- "undefined" == typeof t && (t = this.valign);
- this.valign = t.toString().toLowerCase()
- };
- this._setPosition = function(e, t) {
- this.x = e;
- this.y = t;
- var n = Math.round(this.charHeight / 2);
- this.valign == STR_VALIGN_MIDDLE && (n -= Math.round(this.height / 2));
- this.valign == STR_VALIGN_BOTTOM && (n -= this.height);
- for (var r = 0, i = 0; i < this.strings.length; i++) {
- var s = this.charWidth * this.strings[i].length,
- o = -Math.round(this.charWidth / 2);
- this.align == STR_ALIGN_CENTER && (o -= Math.round(s / 2));
- this.align == STR_ALIGN_RIGHT && (o -= s);
- for (s = 0; s < this.strings[i].length; s++) {
- var u = this.chars[r++];
- u && (o += this.charWidth, u.x = this.x + o, u.y = this.y + n)
- }
- n += this.charHeight
- }
- };
- this._setRotation = function(e) {
- e >= 2 * Math.PI && (e -= 2 * Math.PI);
- 0 > e && (e += 2 * Math.PI);
- this.rotation = e;
- if (0 != this.chars.length)
- for (e = 0; e < this.chars.length; e++)
- if (this.chars[e]) {
- var t = new Vector(this.chars[e].x - this.x, this.chars[e].y - this.y);
- t.rotate(-this.rotation);
- this.chars[e].x = this.x + t.x;
- this.chars[e].y = this.y + t.y;
- this.chars[e].rotation = this.rotation
- }
- };
- this._validateString = function(e) {
- e = e.toString();
- for (var t = "", n = new this.font, r = 0; r < e.length; r++) {
- var i = e.substring(r, r + 1);
- n.validChar(i) && (t += i)
- }
- return t
- };
- this._refreshSize = function() {
- for (var e = 0, t = 0; t < this.strings.length; t++) e = Math.max(e, this.strings[t].length);
- this.width = this.charWidth * e;
- this.height = this.charHeight * this.strings.length
- };
- this._createStageChars = function() {
- var e = this.strings.join("").length,
- e = this.chars.length - e;
- if (0 != e) {
- for (; 0 != e;) {
- var t;
- 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));
- e += 0 > e ? 1 : -1
- }
- this._refreshSize()
- }
- };
- this._prepareString = function(e) {
- e = String(e).split("\n");
- for (var t = 0; t < e.length; t++) e[t] = this._validateString(e[t]);
- return e
- };
- this.debugDraw = function(e) {
- "undefined" == typeof e && (e = "#FFF");
- this._debugDrawAnchor(e);
- this._debugDrawBox(e)
- };
- this._debugDrawBox = function(e) {};
- this._debugDrawAnchor = function(e) {
- stage.drawRectangle(this.x, this.y, 3, 3, e, !0, .8)
- };
- "object" == typeof n && this.setParams(n)
- },
- Charset = {
- getByName: function(e) {
- if ("undefined" == typeof Charset[e]) throw Error("Character set ' " + e + " ' is not defined!");
- return Charset[e]
- },
- digits: '0123456789+-.,*/=()<>#$%&:;|№@~"'.split(""),
- full: " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ЁЂЃЄЅІЇЈЉЊЋЌЎЏАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыьэюя№ёђѓєѕіїјљњћќ§ўџŠŽšžŸ¢£¥§©«®µ»ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ".split(""),
- latin: " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ".split("")
- },
- FontManager = {
- _fonts: {},
- defaultCharmap: Charset.full,
- fontNameFromBitmap: function(e) {
- e = "string" == typeof e ? e : e.src;
- e = e.replace("\\", "http://resource.duopao.com/").split("http://resource.duopao.com/").pop();
- return e = e.split(".").shift()
- },
- createAssetFromSprite: function(e, t) {
- var n = new Asset(e, t.bitmap.src, t.width, t.height, t.totalFrames, t.totalLayers);
- n.bitmap = t.bitmap;
- return n
- },
- createFontAsset: function(e, t, n, r) {
- var i, s;
- if ("string" == typeof e) {
- if ("undefined" == typeof library) throw Error("Bitmaps access by name works only with AssetsLibrary");
- try {
- s = e, i = library.getAsset(s)
- } catch (o) {
- throw Error("Sprite not found for font '" + s + "'")
- }
- } else if ("object" == typeof e) {
- i = ["bitmap", "width", "height", "totalFrames", "totalLayers"];
- for (s = 0; s < i.length; s++)
- if ("undefined" == typeof e[i[s]]) throw Error("Invalid image. Instance of Sprite expected.");
- s = FontManager.fontNameFromBitmap(e.bitmap);
- i = FontManager.createAssetFromSprite(s, e)
- } else throw Error("Invalid image. Asset name or instance of Sprite expected.");
- i = new GUIFontAsset(s, i, t);
- n = ~~n;
- r = ~~r;
- 0 < n && (i["char"].width = n);
- 0 < r && (i["char"].height = r);
- return i
- },
- registerFont: function(e, t, n, r) {
- "string" == typeof t && (t = Charset.getByName(t));
- var i = FontManager.createFontAsset(e, t, n, r),
- s = function() {
- s.superclass.constructor.call(this, i)
- };
- Utils.extend(s, GUIFont);
- FontManager._fonts[i.name] = s;
- return i.name
- },
- getFont: function(e) {
- "undefined" == typeof FontManager._fonts[e] && FontManager.registerFont(e, FontManager.defaultCharmap);
- return FontManager._fonts[e]
- }
- },
- GUIFontAsset = function(e, t, n) {
- this.name = e;
- this.image = t;
- this.charmap = n;
- this["char"] = {
- width: t.width,
- height: t.height
- }
- },
- ExternalAPI = {
- type: "Spilgames",
- init: function(e) {
- ExternalAPI.check() ? SpilGames.Events.subscribe("gamecontainer.resize", Utils.fitLayoutToScreen) : Utils.addFitLayoutListeners()
- },
- check: function() {
- return "undefined" != typeof SpilGames
- },
- checkUserLoggedIn: function() {
- return "NOT_AUTHENTICATED" == SpilGames.Auth.getAuthState() ? !1 : !0
- },
- getUserInfo: function() {},
- addChangeLocaleListener: function(e) {
- SpilGames.Events.subscribe("game.language.change", e)
- },
- showLoginForm: function(e) {
- e || (e = function() {});
- SpilGames.Portal.forceAuthentication(e)
- },
- showScoreboard: function(e) {
- e || (e = function() {});
- SpilGames.Portal.showScoreboard(e)
- },
- submitScores: function(e, t) {
- t || (t = function() {});
- SpilGames.Highscores.insert({
- score: e
- }, t)
- }
- };
- if (!ExternalAPI.check()) var SpilGames;
- AudioMixer.buffer = {};
- AudioMixer.waContext = null;
- var stage, landscape = !1,
- fps = 24,
- bitmaps, GET, iosMode = !1,
- android = !1,
- usedPoints = 0,
- gameScore = 0,
- coins = 0,
- showUnlockAnimation = !1,
- ignoreMenuTheme = !1,
- soundOn, mixer2, STATE_LOAD = 0,
- STATE_LOGO = 1,
- STATE_MENU = 2,
- STATE_GAME = 3,
- STATE_SELECT_DIFFICULTY = 4,
- STATE_VICTORY = 5,
- STATE_DEFEAT = 6,
- STATE_HIGHSCORES = 7,
- STATE_CREDITS = 8,
- STATE_TUTORIAL = 9,
- STATE_MISSION_INFO = 10,
- D_SIMPLE = 0,
- D_NORMAL = 1,
- D_HARD = 2,
- D_EXPERT = 3,
- D_ULTIMATE = 4,
- currentDifficulty, gameState = STATE_LOAD,
- T_EMPTY = 0,
- T_AMOEBA = 1,
- T_JELLYFISH = 2,
- T_SMARTFISH = 3,
- T_LIZARD = 4,
- T_WOLF = 5,
- T_APE = 6,
- T_HOMOSAPIENS = 7,
- T_UNKNOWN = 8,
- T_ETHER = 20,
- T_FIRE = 21,
- T_ICE = 22,
- T_UFO = 23,
- easy_level = {
- init: {},
- elements: {},
- upgrades: [T_AMOEBA, T_JELLYFISH, T_SMARTFISH, T_LIZARD],
- field: {
- x: 5,
- y: 5
- },
- name: "easy"
- };
- easy_level.init[T_AMOEBA] = 4;
- easy_level.init[T_JELLYFISH] = 1;
- easy_level.init[T_SMARTFISH] = 1;
- easy_level.init[T_ICE] = 6;
- easy_level.elements[T_AMOEBA] = 30;
- easy_level.elements[T_JELLYFISH] = 20;
- easy_level.elements[T_FIRE] = 10;
- easy_level.elements[T_ICE] = 10;
- var medium_level = {
- init: {},
- elements: {},
- upgrades: [T_AMOEBA, T_JELLYFISH, T_SMARTFISH, T_LIZARD, T_WOLF],
- field: {
- x: 5,
- y: 5
- },
- name: "medium"
- };
- medium_level.init[T_AMOEBA] = 3;
- medium_level.init[T_JELLYFISH] = 1;
- medium_level.init[T_ICE] = 3;
- medium_level.elements[T_AMOEBA] = 40;
- medium_level.elements[T_JELLYFISH] = 30;
- medium_level.elements[T_FIRE] = 10;
- medium_level.elements[T_ICE] = 10;
- medium_level.elements[T_ETHER] = 5;
- var hard_level = {
- init: {},
- elements: {},
- upgrades: [T_AMOEBA, T_JELLYFISH, T_SMARTFISH, T_LIZARD, T_WOLF, T_APE],
- field: {
- x: 5,
- y: 5
- },
- name: "hard"
- };
- hard_level.init[T_AMOEBA] = 3;
- hard_level.init[T_JELLYFISH] = 1;
- hard_level.init[T_ICE] = 3;
- hard_level.elements[T_AMOEBA] = 30;
- hard_level.elements[T_JELLYFISH] = 20;
- hard_level.elements[T_SMARTFISH] = 10;
- hard_level.elements[T_FIRE] = 10;
- hard_level.elements[T_ICE] = 5;
- hard_level.elements[T_UFO] = 10;
- var expert_level = {
- init: {},
- elements: {},
- upgrades: [T_AMOEBA, T_JELLYFISH, T_SMARTFISH, T_LIZARD, T_WOLF, T_APE, T_HOMOSAPIENS],
- field: {
- x: 5,
- y: 5
- },
- name: "expert"
- };
- expert_level.init[T_AMOEBA] = 5;
- expert_level.init[T_JELLYFISH] = 3;
- expert_level.init[T_ICE] = 3;
- expert_level.elements[T_AMOEBA] = 30;
- expert_level.elements[T_JELLYFISH] = 20;
- expert_level.elements[T_SMARTFISH] = 10;
- expert_level.elements[T_LIZARD] = 5;
- expert_level.elements[T_WOLF] = 2;
- expert_level.elements[T_APE] = 1;
- expert_level.elements[T_FIRE] = 10;
- expert_level.elements[T_ICE] = 5;
- expert_level.elements[T_UFO] = 10;
- var ultimate_level = {
- init: {},
- elements: {},
- upgrades: [T_AMOEBA, T_JELLYFISH, T_SMARTFISH, T_LIZARD, T_WOLF, T_APE, T_HOMOSAPIENS, T_UNKNOWN],
- field: {
- x: 5,
- y: 5
- },
- name: "ultimate"
- };
- ultimate_level.init[T_AMOEBA] = 2;
- ultimate_level.init[T_JELLYFISH] = 2;
- ultimate_level.init[T_SMARTFISH] = 3;
- ultimate_level.init[T_ICE] = 4;
- ultimate_level.elements[T_AMOEBA] = 10;
- ultimate_level.elements[T_JELLYFISH] = 25;
- ultimate_level.elements[T_SMARTFISH] = 15;
- ultimate_level.elements[T_LIZARD] = 10;
- ultimate_level.elements[T_WOLF] = 5;
- ultimate_level.elements[T_APE] = 4;
- ultimate_level.elements[T_FIRE] = 8;
- ultimate_level.elements[T_ICE] = 9;
- ultimate_level.elements[T_UFO] = 8;
- ultimate_level.elements[T_HOMOSAPIENS] = 1;
- var LEVELS = [easy_level, medium_level, hard_level, expert_level, ultimate_level],
- EL_BMP = {};
- EL_BMP[T_EMPTY] = "element";
- EL_BMP[T_AMOEBA] = "unicellar";
- EL_BMP[T_JELLYFISH] = "meduze";
- EL_BMP[T_SMARTFISH] = "fish";
- EL_BMP[T_LIZARD] = "pangolin";
- EL_BMP[T_WOLF] = "mammal";
- EL_BMP[T_APE] = "people";
- EL_BMP[T_HOMOSAPIENS] = "uslon";
- EL_BMP[T_UNKNOWN] = "unknown";
- EL_BMP[T_ETHER] = "ether";
- EL_BMP[T_FIRE] = "fire";
- EL_BMP[T_ICE] = "ice";
- EL_BMP[T_UFO] = "ufo";
- var EL_SCORE = {};
- EL_SCORE[T_EMPTY] = 0;
- EL_SCORE[T_AMOEBA] = 0;
- EL_SCORE[T_JELLYFISH] = 100;
- EL_SCORE[T_SMARTFISH] = 500;
- EL_SCORE[T_LIZARD] = 3e3;
- EL_SCORE[T_WOLF] = 15e3;
- EL_SCORE[T_APE] = 3e4;
- EL_SCORE[T_HOMOSAPIENS] = 1e5;
- EL_SCORE[T_UNKNOWN] = 5e5;
- EL_SCORE[T_ETHER] = 0;
- EL_SCORE[T_FIRE] = 0;
- EL_SCORE[T_ICE] = 0;
- EL_SCORE[T_UFO] = 0;
- var FIELD_SIZE = {
- x: 5,
- y: 5
- },
- CHAIN_LENGTH = 3,
- assets = [{
- name: "field-select-level-bg",
- src: "field-select-level-bg.png",
- width: 301,
- height: 432
- }, {
- name: "easy",
- src: "easy.png",
- width: 248,
- height: 66,
- frames: 2
- }, {
- name: "medium",
- src: "medium.png",
- width: 248,
- height: 66,
- frames: 2
- }, {
- name: "hard",
- src: "hard.png",
- width: 248,
- height: 66,
- frames: 2
- }, {
- name: "expert",
- src: "expert.png",
- width: 248,
- height: 66,
- frames: 2
- }, {
- name: "ultimate",
- src: "ultimate.png",
- width: 248,
- height: 66,
- frames: 2
- }, {
- name: "field-play-playingfield",
- src: "field-play-playingfield.png",
- width: 306,
- height: 378
- }, {
- name: "buy",
- src: "buy.png",
- width: 78,
- height: 24,
- frames: 2
- }, {
- name: "replay",
- src: "replay.png",
- width: 122,
- height: 46
- }, {
- name: "menu",
- src: "menu.png",
- width: 122,
- height: 46
- }, {
- name: "plus",
- src: "plus.png",
- width: 27,
- height: 26,
- frames: 2
- }, {
- name: "field-play-score-bg",
- src: "field-play-score-bg.png",
- width: 135,
- height: 54
- }, {
- name: "field_highscore",
- src: "field-highscore-bg.png",
- width: 301,
- height: 431
- }, {
- name: "highscores",
- src: "highscores.png",
- width: 226,
- height: 78,
- frames: 2
- }, {
- name: "popup_bg",
- src: "popup_bg.png",
- width: 165,
- height: 194
- }, {
- name: "lock",
- src: "lock.png",
- width: 61,
- height: 56,
- frames: 11
- }, {
- name: "evol_back",
- src: "evol_back.png",
- width: 302,
- height: 427
- }, {
- name: "back_field-evolution-popup",
- src: "back_field-evolution-popup.png",
- width: 411,
- height: 313
- }, {
- name: "light_win",
- src: "light_win.png",
- width: 101,
- height: 101
- }, {
- name: "ether",
- src: "field-play-card-ether1.png",
- width: 50,
- height: 50
- }, {
- name: "fire",
- src: "field-play-card-fire.png",
- width: 50,
- height: 50
- }, {
- name: "fish",
- src: "field-play-card-fish.png",
- width: 50,
- height: 50
- }, {
- name: "font1",
- src: "Numbers.png",
- width: 12,
- height: 200,
- frames: 10
- }, {
- name: "ice",
- src: "field-play-card-ice.png",
- width: 50,
- height: 50
- }, {
- name: "mammal",
- src: "field-play-card-wolf.png",
- width: 50,
- height: 50
- }, {
- name: "meduze",
- src: "field-play-card-jellyfish.png",
- width: 50,
- height: 50
- }, {
- name: "pangolin",
- src: "field-play-card-lizard.png",
- width: 50,
- height: 50
- }, {
- name: "people",
- src: "field-play-card-monkey.png",
- width: 50,
- height: 50
- }, {
- name: "uslon",
- src: "field-play-card-human.png",
- width: 50,
- height: 50
- }, {
- name: "popup_loose",
- src: "popup_loose.png",
- width: 316,
- height: 186
- }, {
- name: "ufo",
- src: "field-play-card-ufo.png",
- width: 50,
- height: 50
- }, {
- name: "unicellar",
- src: "field-play-card-amoeba.png",
- width: 50,
- height: 50
- }, {
- name: "baveuse",
- src: "fonts/baveuse_white.png",
- frames: 6,
- layers: 16,
- width: 15,
- height: 15
- }, {
- name: "field-main-logo",
- src: "field-main-logo.png",
- width: 319,
- height: 141
- }, {
- name: "field-main-btn-bg",
- src: "field-main-btn-bg.png",
- width: 261,
- height: 298
- }, {
- name: "play",
- src: "play.png",
- width: 227,
- height: 120,
- frames: 2
- }, {
- name: "light",
- src: "gme-bg-light.png",
- width: 320,
- height: 480
- }, {
- name: "credits",
- src: "credits.png",
- width: 205,
- height: 69,
- frames: 2
- }, {
- name: "sound",
- src: "sound.png",
- width: 56,
- height: 54,
- frames: 2
- }, {
- name: "txt_1",
- src: "txt_1.png",
- width: 251,
- height: 47
- }, {
- name: "txt_2",
- src: "txt_2.png",
- width: 200,
- height: 49
- }, {
- name: "txt_3",
- src: "txt_3.png",
- width: 190,
- height: 152
- }, {
- name: "txt_4",
- src: "txt_4.png",
- width: 198,
- height: 79
- }, {
- name: "txt_5",
- src: "txt_5.png",
- width: 149,
- height: 104
- }, {
- name: "txt_6",
- src: "txt_6.png",
- width: 179,
- height: 87
- }, {
- name: "txt_7",
- src: "txt_7.png",
- width: 108,
- height: 94
- }, {
- name: "txt_8",
- src: "txt_8.png",
- width: 174,
- height: 71
- }, {
- name: "txt_9",
- src: "txt_9.png",
- width: 125,
- height: 111
- }, {
- name: "txt_10",
- src: "txt_10.png",
- width: 156,
- height: 82
- }, {
- name: "txt_11",
- src: "txt_11.png",
- width: 122,
- height: 115
- }, {
- name: "txt_12",
- src: "txt_12.png",
- width: 135,
- height: 113
- }, {
- name: "txt_13",
- src: "txt_13.png",
- width: 102,
- height: 69
- }, {
- name: "txt_14",
- src: "txt_14.png",
- width: 167,
- height: 107
- }, {
- name: "txt_15",
- src: "txt_15.png",
- width: 200,
- height: 78
- }, {
- name: "txt_16",
- src: "txt_16.png",
- width: 151,
- height: 92
- }, {
- name: "txt_17",
- src: "txt_17.png",
- width: 178,
- height: 53
- }, {
- name: "txt_18",
- src: "txt_18.png",
- width: 189,
- height: 71
- }, {
- name: "txt_19",
- src: "txt_19.png",
- width: 240,
- height: 133
- }, {
- name: "txt_20",
- src: "txt_20.png",
- width: 187,
- height: 169
- }, {
- name: "win_next",
- src: "win_next.png",
- width: 50,
- height: 50,
- frames: 2
- }, {
- name: "win_replay",
- src: "win_replay.png",
- width: 50,
- height: 50,
- frames: 2
- }, {
- name: "back_field_win",
- src: "back_field_win.png",
- width: 300,
- height: 195
- }, {
- name: "unknown1",
- src: "unknown1.png",
- width: 49,
- height: 50
- }, {
- name: "unknown2",
- src: "unknown2.png",
- width: 49,
- height: 50
- }, {
- name: "unknown3",
- src: "unknown3.png",
- width: 49,
- height: 50
- }, {
- name: "unknown4",
- src: "unknown4.png",
- width: 49,
- height: 50
- }, {
- name: "unknown5",
- src: "unknown5.png",
- width: 49,
- height: 50
- }, {
- name: "unknown6",
- src: "unknown6.png",
- width: 49,
- height: 50
- }, {
- name: "arrow",
- src: "arrow.png",
- width: 13,
- height: 28
- }, {
- name: "mission_bg",
- src: "mission-bg.png",
- width: 279,
- height: 256
- }, {
- name: "mission_create_1",
- src: "mission-create-1.png",
- width: 150,
- height: 16
- }, {
- name: "mission_create_2",
- src: "mission-create-2.png",
- width: 138,
- height: 16
- }, {
- name: "mission_create_3",
- src: "mission-create-3.png",
- width: 126,
- height: 16
- }, {
- name: "mission_create_4",
- src: "mission-create-4.png",
- width: 150,
- height: 16
- }, {
- name: "mission_create_5",
- src: "mission-create-5.png",
- width: 103,
- height: 16
- }, {
- name: "mission_untitled_a",
- src: "mission-untitled-a.png",
- width: 48,
- height: 48
- }, {
- name: "mission_untitled_b",
- src: "mission-untitled-b.png",
- width: 48,
- height: 48
- }, {
- name: "r1",
- src: "r1.png",
- width: 6,
- height: 6
- }, {
- name: "r2",
- src: "r2.png",
- width: 6,
- height: 6
- }, {
- name: "qmark",
- src: "qmark.png",
- width: 51,
- height: 57,
- frames: 2
- }, {
- name: "coin_rotate",
- src: "coin_rotate.png",
- width: 46,
- height: 46,
- frames: 9
- }, {
- name: "coin_rotate12",
- src: "coin_rotate12.png",
- width: 48,
- height: 24,
- frames: 18
- }, {
- name: "Help1",
- src: "Help1.png",
- width: 320,
- height: 480
- }, {
- name: "Help2",
- src: "Help2.png",
- width: 320,
- height: 480
- }, {
- name: "Help3",
- src: "Help3.png",
- width: 320,
- height: 480
- }, {
- name: "Help4",
- src: "Help4.png",
- width: 320,
- height: 480
- }, {
- name: "arrow_frwd",
- src: "arrow_frwd.png",
- width: 12,
- height: 31
- }, {
- name: "arrow_prev",
- src: "arrow_prev.png",
- width: 12,
- height: 31
- }, {
- name: "arrow_down",
- src: "arrow_down.png",
- width: 31,
- height: 12
- }, {
- name: "arrow_up",
- src: "arrow_up.png",
- width: 31,
- height: 12
- }, {
- name: "back_field_win_3",
- src: "back_field-win-3.png",
- width: 300,
- height: 344
- }, {
- name: "text1",
- src: "text1.png",
- width: 55,
- height: 18
- }, {
- name: "text2",
- src: "text2.png",
- width: 157,
- height: 18
- }, {
- name: "text3",
- src: "text3.png",
- width: 88,
- height: 18
- }, {
- name: "Fish",
- src: "Fish.png",
- width: 256,
- height: 80
- }, {
- name: "geek",
- src: "geek.png",
- width: 256,
- height: 80
- }, {
- name: "human",
- src: "human.png",
- width: 256,
- height: 80
- }, {
- name: "humanoid",
- src: "humanoid.png",
- width: 256,
- height: 80
- }, {
- name: "Jellyfish",
- src: "Jellyfish.png",
- width: 256,
- height: 80
- }, {
- name: "lizard",
- src: "lizard.png",
- width: 256,
- height: 80
- }, {
- name: "superbrains",
- src: "superbrains.png",
- width: 256,
- height: 80
- }, {
- name: "superhuman",
- src: "superhuman.png",
- width: 256,
- height: 80
- }, {
- name: "Unknown",
- src: "Unknown.png",
- width: 256,
- height: 80
- }, {
- name: "wolf",
- src: "wolf.png",
- width: 256,
- height: 80
- }, {
- name: "zombie",
- src: "zombie.png",
- width: 256,
- height: 80
- }, {
- name: "cyborg",
- src: "cyborg.png",
- width: 256,
- height: 80
- }, {
- name: "ape",
- src: "ape.png",
- width: 256,
- height: 80
- }, {
- name: "Amoeba",
- src: "Amoeba.png",
- width: 256,
- height: 80
- }, {
- name: "back",
- src: "back.png",
- width: 257,
- height: 355
- }];
- window.onload = function() {
- GET = Utils.parseGet();
- Utils.addMobileListeners();
- ExternalAPI.init();
- setTimeout(startLoad, 600)
- };
- var current_game_mode = 0;
- var lastBackground = null;
- var tempRouletteArray = [],
- rouletteProbability = {
- T_AMOEBA: {
- n: 30,
- v: 1
- },
- T_JELLYFISH: {
- n: 20,
- v: 2
- },
- T_SMARTFISH: {
- n: 17,
- v: 3
- },
- T_LIZARD: {
- n: 13,
- v: 4
- },
- T_WOLF: {
- n: 10,
- v: 5
- },
- T_APE: {
- n: 7,
- v: 6
- },
- T_HOMOSAPIENS: {
- n: 3,
- v: 7
- }
- };
- var startScrollPosition, scrollLocked = !1,
- clickForbidden = !0;
- var field;
- var maxUnlockedItem = {
- t: 3,
- newUnlocked: !1
- },
- GameElement = function(e, t) {
- var n = this;
- e = ~~e;
- "ultimate" == currentDifficulty && e > maxUnlockedItem.t && 10 > e && !maxUnlockedItem.newUnlocked && (maxUnlockedItem.t = e);
- if (8 == e) {
- var r = Math.ceil(6 * Math.random());
- maxUnlockedItem.t = r;
- maxUnlockedItem.newUnlocked = !0;
- EL_BMP[T_UNKNOWN] = "unknown" + r;
- Utils.getCookie("icon1" + r + "ul") || (Utils.setCookie("icon1" + r + "ul", !0), field.upgradeType = 10 + r, stage.setTimeout(function() {
- showEvolutionPopup(10 + r, function() {})
- }, 5))
- }
- var i = e == T_EMPTY ? new Sprite(null, 45, 45, 1, 1) : library.getAsset(EL_BMP[e]);
- t && maxUnlockedItem.newUnlocked && (i = library.getAsset(EL_BMP[T_UNKNOWN]));
- GameElement.superclass.constructor.call(this, i.bitmap, ~~i.width, ~~i.height, ~~i.frames, ~~i.layers);
- this.gametype = e;
- this.currentLayer = this.currentFrame = 0;
- this.moved = !1;
- this.setType = function(e) {
- var t = e == T_EMPTY ? new Sprite(null, 45, 45, 1, 1) : library.getAsset(EL_BMP[~~e]);
- this.gametype = ~~e;
- this.bitmap = t.bitmap;
- this.width = ~~t.width;
- this.height = ~~t.height;
- this.totalFrames = ~~t.frames;
- this.totalLayers = ~~t.layers;
- this.currentLayer = this.currentFrame = 0
- };
- this.blink = function() {
- n.fadeTo(.3, 6, Easing.cubic.easeOut, function(e) {
- n.fadeTo(1, 1, Easing.linear.easeIn)
- })
- }
- };
- Utils.extend(GameElement, Sprite);
- var GameField = function(e) {
- var t = this;
- GameField.superclass.constructor.call(this);
- this.level = e;
- this.size = e.field;
- this.nextElement = new GameElement;
- this.storedElement = new GameElement(T_EMPTY);
- this.getTypes = function() {
- for (var e = [], t = 0; t < this.length; t++) e.push(this[t].gametype);
- return e
- };
- this.setTypes = function(e) {
- for (var t = 0; t < e.length; t++) t < this.length && this[t].setType(~~e[t])
- };
- this.getElementId = function(e) {
- for (var t = 0; t < this.length; t++)
- if (this[t] === e) return t
- };
- this.create = function() {
- 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++)
- for (var i = 0; i < t.size.x; i++) {
- var s = new GameElement;
- this.push(s);
- s.type = "gameCell";
- s.x = n.x + e.x * i;
- s.y = n.y + e.y * r;
- s.onmouseup = t.clickHandler;
- stage.addChild(s)
- }
- t.init();
- e = t.generateNextType();
- t.nextElement = new GameElement(e);
- t.nextElement.setPosition(57, 118);
- t.nextElement.onmouseup = function() {
- if (tutorialActivated) return !1;
- t.swapStack()
- };
- stage.addChild(t.nextElement);
- t.storedElement = new GameElement(T_EMPTY);
- t.storedElement.setPosition(235, 118);
- t.storedElement.onmouseup = function() {
- tutorialActivated || t.swapStack();
- if (tutorialActivated && (tut04completed && !tut05completed || tut07completed && !tut08completed)) return t.swapStack(), tutDone(), !0
- };
- stage.addChild(t.storedElement);
- checkIfNeedLaunchTutorial(t.size.x * t.size.y, t)
- };
- this.init = function() {
- var e = t.size.x * t.size.y;
- initializeUserScore();
- currentDifficulty = t.level.name;
- checkDifficulty();
- if ("easy" != currentDifficulty || !tutorialActivated)
- if ("medium" != currentDifficulty || !tutorialActivated)
- if ("hard" != currentDifficulty || !tutorialActivated)
- for (var n in t.level.init)
- for (var r = t.level.init[n]; 0 < r;) {
- for (var i = Math.floor(Math.random() * e); t[i].gametype > T_EMPTY;) i = Math.floor(Math.random() * e);
- t[i].setType(n);
- r--
- }
- };
- this.generateNextType = function() {
- 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;
- var e = t.level.elements,
- n = 0,
- r;
- for (r in e) n += e[r];
- n = Math.floor(Math.random() * n);
- for (r in e)
- if (n -= e[r], 0 >= n) return r;
- return T_AMOEBA
- };
- this.getUpgradeType = function(e) {
- for (var n = t.level.upgrades, r = 0; r < n.length; r++)
- if (n[r] == e) return field.upgradeType = n[r + 1], ++r < n.length ? n[r] : 0;
- return 0
- };
- this.locked = !1;
- this.swapStack = function(e) {
- if (t.locked || t.nextElement.gametype == T_UFO) return !1;
- e = new GameElement(t.nextElement.gametype);
- e.setPosition(t.nextElement.x, t.nextElement.y);
- var n = new GameElement(t.storedElement.gametype);
- n.setPosition(t.storedElement.x, t.storedElement.y);
- t.nextElement.visible = !1;
- stage.addChild(e);
- t.locked = !0;
- e.moveTo(t.storedElement.x, t.storedElement.y, 6, Easing.cubic.easeIn, function(e) {
- t.storedElement.setType(e.target.obj.gametype);
- t.storedElement.visible = !0;
- stage.removeChild(e.target.obj);
- t.locked = !1
- });
- 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) {
- t.nextElement.setType(e.target.obj.gametype);
- t.nextElement.visible = !0;
- stage.removeChild(e.target.obj)
- })) : (e = t.generateNextType(), t.nextElement.setType(e), t.nextElement.visible = !0);
- 0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("swap_stack", !1, !1, 0)
- };
- this.clickHandler = function(e) {
- if (blockForTutorial) return !0;
- if (t.locked) return !1;
- var n = e.target;
- e = new GameElement(t.nextElement.gametype);
- e.setPosition(t.nextElement.x, t.nextElement.y);
- var r = !1;
- switch (n.gametype) {
- case T_EMPTY:
- if (e.gametype == T_FIRE) {
- n.blink();
- break
- }
- if (e.gametype == T_ETHER) {
- var r = t.getTypes(),
- r = new ChainFinder(r, CHAIN_LENGTH, t.size.x, !1),
- i = t.getElementId(n),
- i = r.findPossibleChains(i),
- s = -1;
- if (i)
- for (var o in i) r.checkChainLength(i[o]) && ~~o > s && 0 < t.getUpgradeType(~~o) && (s = ~~o);
- e.gametype = 1 > s ? T_ICE : s
- }
- t.locked = !0;
- stage.addChild(e);
- e.moveTo(n.x, n.y, 12, Easing.circular.easeOut, function(e) {
- n.setType(e.target.obj.gametype);
- e.target.obj.removeTweens();
- stage.removeChild(e.target.obj);
- t.locked = !1;
- t.upgradeChains(n)
- });
- r = !0;
- 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);
- break;
- default:
- e.gametype == T_FIRE ? (stage.addChild(e), t.locked = !0, e.moveTo(n.x, n.y, 6, Easing.linear.easeOut, function(e) {
- e.target.obj.removeTweens();
- e.target.obj.fadeTo(0, 12, Easing.circular.easeOut, function(e) {
- stage.removeChild(e.target.obj)
- });
- t.locked = !1;
- 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) {
- e.target.obj.fadeTo(0, 12, Easing.linear.easeIn, function(e) {
- stage.removeChild(e.target.obj);
- t.moveAliens()
- });
- t.nextElement.setType(T_ETHER);
- t.nextElement.fadeTo(1, 12, Easing.linear.easeIn)
- }), 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));
- t.moveAliens()
- }), r = !0) : n.blink()
- }
- r && t.nextElement.setType(t.generateNextType())
- };
- this.upgradeChains = function(e) {
- t.locked = !0;
- for (var n = t.getTypes(), n = (new ChainFinder(n, CHAIN_LENGTH, t.size.x, !1)).findChains(), r = 0, i = 0; i < n.length; i++) {
- var s = n[i];
- if (!(0 > s.indexOf(t.getElementId(e)))) {
- var o = t.getUpgradeType(e.gametype);
- if (!(1 > o)) {
- 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);
- r++;
- for (var u = 0; u < s.length; u++) {
- var a = s[u];
- if (t[a] !== e) {
- var f = new GameElement(t[a].gametype);
- f.setPosition(t[a].x, t[a].y);
- stage.addChild(f);
- t[a].setType(T_EMPTY);
- f.moveTo(e.x, e.y, 6, Easing.linear.easeIn, function(e) {
- e.target.obj.removeTweens();
- stage.removeChild(e.target.obj)
- })
- }
- }
- s = new GameElement(o);
- s.setPosition(e.x, e.y);
- s.opacity = 0;
- stage.addChild(s);
- s.fadeTo(1, 12, Easing.linear.easeIn, function(n) {
- e.setType(n.target.obj.gametype);
- n.target.obj.removeTweens();
- stage.removeChild(n.target.obj);
- var r = getScore() + ~~EL_SCORE[e.gametype];
- checkIfNeedPopup(function() {
- setScore(r, ~~EL_SCORE[e.gametype], e.x, e.y);
- t.upgradeChains(e)
- })
- })
- }
- }
- }
- 1 > r && (t.locked = !1, t.moveAliens())
- };
- this.moveAliens = function() {
- t.locked = !0;
- var e = function() {
- for (var e = 0; e < t.length; e++)
- if (t[e].gametype == T_UFO && !t[e].moved) return e;
- return -1
- }();
- if (0 > e) {
- for (e = 0; e < t.length; e++) t[e].gametype == T_UFO && (t[e].moved = !1);
- t.locked = !1;
- return t.checkGameOver()
- }
- var n = function(e, n) {
- var r = e % t.size.x,
- i = Math.floor(e / t.size.y),
- s = [];
- 0 < r && (n && t[e - 1].gametype !== T_EMPTY || s.push(e - 1));
- r + 1 < t.size.x && (n && t[e + 1].gametype !== T_EMPTY || s.push(e + 1));
- 0 < i && (n && t[e - t.size.y].gametype !== T_EMPTY || s.push(e - t.size.y));
- i + 1 < t.size.y && (n && t[e + t.size.y].gametype !== T_EMPTY || s.push(e + t.size.y));
- return s
- }(e, !0);
- if (1 > n.length) {
- t[e].setType(T_EMPTY);
- var r = new GameElement(T_UFO);
- r.setPosition(t[e].x, t[e].y);
- stage.addChild(r);
- t.nextElement.fadeTo(0, 12, Easing.linear.easeIn);
- r.moveTo(t.nextElement.x, t.nextElement.y, 12, Easing.cubic.easeOut, function(e) {
- e.target.obj.fadeTo(0, 12, Easing.linear.easeIn, function(e) {
- stage.removeChild(e.target.obj);
- t.moveAliens()
- });
- t.nextElement.setType(T_ETHER);
- t.nextElement.fadeTo(1, 12, Easing.linear.easeIn)
- })
- } else {
- var i = Math.floor(Math.random() * n.length);
- t[n[i]].gametype = null;
- t[e].setType(T_EMPTY);
- r = new GameElement(T_UFO);
- r.setPosition(t[e].x, t[e].y);
- stage.addChild(r);
- r.targetID = n[i];
- r.moveTo(t[n[i]].x, t[n[i]].y, 6, Easing.linear.easeIn, function(e) {
- t[e.target.obj.targetID].setType(T_UFO);
- t[e.target.obj.targetID].moved = !0;
- stage.removeChild(e.target.obj);
- t.moveAliens()
- })
- }
- 0 != Utils.getCookie("soundOn") || iosMode || android || mixer.play("alien_move", !1, !1, 0)
- };
- this.checkGameOver = function() {
- 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++) {
- if (t[i].gametype === n && !e) {
- gameState = STATE_VICTORY;
- createScene();
- return
- }
- t[i].gametype !== T_EMPTY && r--
- }
- 1 > r && (gameState = e ? STATE_VICTORY : STATE_DEFEAT, createScene())
- }
- };
- Utils.extend(GameField, Array);
- var score;
- var slidesNumber = 0;
- var tutorialActivated = !1,
- tut01completed = !1,
- tut02completed = !1,
- tut03completed = !1,
- tut04completed = !1,
- tut05completed = !1,
- tut06completed = !1,
- tut07completed = !1,
- tut08completed = !1,
- tut09completed = !1,
- tut10completed = !1,
- tut11completed = !1,
- tut12completed = !1,
- tut12_1completed = !1,
- tut13completed = !1,
- tut14completed = !1,
- tut15completed = !1,
- blockForTutorial = !1,
- tutArray = [],
- gameElementArray = [];
|