main.js 136 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163
  1. var com;
  2. (function(a) {
  3. (function(d) {
  4. var c = (function() {
  5. function e() {
  6. }
  7. e.init = function() {
  8. };
  9. e.clear = function() {
  10. };
  11. return e
  12. })();
  13. d.TextureCache = c
  14. })(a.goldenratio || (a.goldenratio = {}));
  15. var b = a.goldenratio
  16. })(com || (com = {}));
  17. var com;
  18. (function(a) {
  19. (function(d) {
  20. var c = (function() {
  21. function e(f) {
  22. this.type = f
  23. }
  24. e.LAUNCH_GAME = "com.goldenratio.GameEvent.LAUNCH_GAME";
  25. e.GAME_OVER = "com.goldenratio.GameEvent.GAME_OVER";
  26. e.GAME_OVER_BUTTON_READY = "com.goldenratio.GameEvent.GAME_OVER_BUTTON_READY";
  27. e.SOUND_LOADED = "com.goldenratio.GameEvent.SOUND_LOADED";
  28. e.SOUND_ERROR = "com.goldenratio.GameEvent.SOUND_ERROR";
  29. e.BUTTON_UP = "com.goldenratio.GameEvent.BUTTON_UP";
  30. e.BUTTON_DOWN = "com.goldenratio.GameEvent.BUTTON_DOWN";
  31. e.TOGGLE_PAUSE = "com.goldenratio.GameEvent.TOGGLE_PAUSE";
  32. e.START_GAME = "com.goldenratio.GameEvent.START_GAME";
  33. e.CANVAS_MOUSE_DOOWN = "com.goldenratio.GameEvent.CANVAS_MOUSE_DOOWN";
  34. e.EGG_OUTOFF_BASKET = "com.goldenratio.GameEvent.EGG_OUTOFF_BASKET";
  35. e.EGG_INSIDE_BASKET = "com.goldenratio.GameEvent.EGG_INSIDE_BASKET";
  36. e.EGG_DIED = "com.goldenratio.GameEvent.EGG_DIED";
  37. e.SCREEN_TRANSITION_SHOW_SCREEN = "com.goldenratio.GameEvent.SCREEN_TRANSITION_SHOW_SCREEN";
  38. e.SCREEN_TRANSITION_HIDE_SCREEN = "com.goldenratio.GameEvent.SCREEN_TRANSITION_HIDE_SCREEN";
  39. e.PLAY_AGAIN_CLICK = "com.goldenratio.GameEvent.PLAY_AGAIN_CLICK";
  40. return e
  41. })();
  42. d.GameEvent = c
  43. })(a.goldenratio || (a.goldenratio = {}));
  44. var b = a.goldenratio
  45. })(com || (com = {}));
  46. var com;
  47. (function(a) {
  48. (function(d) {
  49. var c = (function() {
  50. function e() {
  51. }
  52. e.supportsDeviceOrientation = function() {
  53. if ("ondeviceorientation" in window) {
  54. return true
  55. }
  56. return false
  57. };
  58. e.isTouchDevice = function() {
  59. if ("ontouchstart" in window || window.navigator.msMaxTouchPoints > 0 || window.navigator.maxTouchPoints > 0) {
  60. return true
  61. }
  62. return false
  63. };
  64. e.isMobileDevice = function() {
  65. if (navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/Windows Phone/i) || navigator.userAgent.match(/Mobile/i) || navigator.userAgent.match(/Tablet/i) || navigator.userAgent.match(/Silk/i)) {
  66. return true
  67. }
  68. return false
  69. };
  70. e.isChrome = function() {
  71. if (navigator.userAgent.match(/Chrome/i)) {
  72. return true
  73. }
  74. return false
  75. };
  76. e.isFirefox = function() {
  77. if (navigator.userAgent.match(/Firefox/i)) {
  78. return true
  79. }
  80. return false
  81. };
  82. e.isFirefoxForAndroid = function() {
  83. return e.isAndroid() && e.isFirefox()
  84. };
  85. e.isFirefoxOS = function() {
  86. return (("mozApps") in navigator) && (navigator.userAgent.search("Mobile") != -1)
  87. };
  88. e.isOpera = function() {
  89. if (navigator.userAgent.match(/Opera/i) || navigator.userAgent.match(/OPR/i)) {
  90. return true
  91. }
  92. return false
  93. };
  94. e.isIE11 = function() {
  95. if (navigator.userAgent.match(/Trident/i)) {
  96. return true
  97. }
  98. return false
  99. };
  100. e.isAndroid = function() {
  101. if (navigator.userAgent.match(/Android/i)) {
  102. return true
  103. }
  104. return false
  105. };
  106. e.isLinux = function() {
  107. if (navigator.userAgent.match(/Linux/i)) {
  108. return true
  109. }
  110. return false
  111. };
  112. e.isWindows = function() {
  113. if (navigator.userAgent.match(/Windows/i)) {
  114. return true
  115. }
  116. return false
  117. };
  118. e.isMac = function() {
  119. if (navigator.userAgent.match(/Mac/i)) {
  120. return true
  121. }
  122. return false
  123. };
  124. e.getAndroidVersion = function() {
  125. var f = navigator.userAgent;
  126. if (f.indexOf("Android") >= 0) {
  127. return parseFloat(f.slice(f.indexOf("Android") + 8))
  128. }
  129. return 0
  130. };
  131. e.renderInWebGL = function() {
  132. if (e.isFirefox() && e.isLinux()) {
  133. return false
  134. }
  135. return true
  136. };
  137. e.lockScreenToPortrait = function() {
  138. var f = ["portrait-primary"];
  139. if (window.screen.mozLockOrientation) {
  140. return window.screen.mozLockOrientation(f)
  141. }
  142. if (window.screen.msLockOrientation) {
  143. return window.screen.msLockOrientation(f)
  144. }
  145. if (window.screen.lockOrientation) {
  146. return window.screen.lockOrientation(f)
  147. }
  148. return false
  149. };
  150. e.lockScreenToLandscape = function() {
  151. var f = ["landscape-primary"];
  152. if (window.screen.mozLockOrientation) {
  153. return window.screen.mozLockOrientation(f)
  154. }
  155. if (window.screen.msLockOrientation) {
  156. return window.screen.msLockOrientation(f)
  157. }
  158. if (window.screen.lockOrientation) {
  159. return window.screen.lockOrientation(f)
  160. }
  161. return false
  162. };
  163. e.isLandscapeMode = function() {
  164. if (window.orientation == 90 || window.orientation == -90) {
  165. return e.isMobileDevice()
  166. }
  167. if (window.orientation == null || window.orientation == 0) {
  168. return (window.innerWidth > window.innerHeight) && e.isMobileDevice()
  169. }
  170. return false
  171. };
  172. e.isGamepadSupported = function() {
  173. return !!navigator.webkitGetGamepads || !!navigator.webkitGamepads || (navigator.userAgent.indexOf("Firefox/") != -1)
  174. };
  175. return e
  176. })();
  177. d.DeviceUtils = c
  178. })(a.goldenratio || (a.goldenratio = {}));
  179. var b = a.goldenratio
  180. })(com || (com = {}));
  181. var __extends = this.__extends || function(f, a) {
  182. for (var e in a) {
  183. if (a.hasOwnProperty(e)) {
  184. f[e] = a[e]
  185. }
  186. }
  187. function c() {
  188. this.constructor = f
  189. }
  190. c.prototype = a.prototype;
  191. f.prototype = new c()
  192. };
  193. var com;
  194. (function(a) {
  195. (function(d) {
  196. var c = (function(e) {
  197. __extends(f, e);
  198. function f() {
  199. e.call(this);
  200. this.loaderContainer = document.getElementById("loader-container");
  201. this.loadProgressContainer = document.getElementById("loader-progress");
  202. this.loadCompleteContainer = document.getElementById("loader-complete");
  203. this.loaderTapToPlay = document.getElementById("loader-tap-to-play");
  204. this.fullscreenCheckboxContainer = document.getElementById("fullscreen-option");
  205. this.showFullscreenCheckbox(false);
  206. this.loaderContainer.style.display = "block";
  207. this.loadProgressContainer.style.display = "block";
  208. this.mapBinds()
  209. }
  210. f.prototype.showFullscreenCheckbox = function(g) {
  211. this.fullscreenCheckbox = null;
  212. if (fullscreenEnabled && g && isMobileDevice) {
  213. this.fullscreenCheckboxContainer.style.display = "block";
  214. this.fullscreenCheckbox = document.getElementById("fullscreen-opt")
  215. } else {
  216. this.fullscreenCheckboxContainer.style.display = "none"
  217. }
  218. };
  219. f.prototype.mapBinds = function() {
  220. this.onLoaderTapToPlayClickHL = this.onLoaderTapToPlayClickHL.bind(this)
  221. };
  222. f.prototype.updateViewPort = function(g, h) {
  223. this.loaderContainer.style.width = g + "px";
  224. this.loaderContainer.style.height = h-40 + "px";
  225. if (g < window.innerWidth && this.fullscreenCheckbox == null && d.DeviceUtils.isLandscapeMode() == false) {
  226. this.showFullscreenCheckbox(true)
  227. }
  228. };
  229. f.prototype.onLoadComplete = function() {
  230. this.loadProgressContainer.style.display = "none";
  231. this.loadCompleteContainer.style.display = "block";
  232. this.addLoaderListeners(true);
  233. this.launchGame();
  234. // if (f.SHOW_TAP_TO_PLAY == false) {
  235. // this.launchGame()
  236. // }
  237. };
  238. f.prototype.addLoaderListeners = function(g) {
  239. this.loaderTapToPlay.removeEventListener("click", this.onLoaderTapToPlayClickHL, false);
  240. if (g) {
  241. this.loaderTapToPlay.addEventListener("click", this.onLoaderTapToPlayClickHL, false)
  242. }
  243. };
  244. f.prototype.onLoaderTapToPlayClickHL = function(g) {
  245. this.launchGame();
  246. g.preventDefault();
  247. g.stopPropagation()
  248. };
  249. f.prototype.launchGame = function() {
  250. this.loaderContainer.style.display = "none";
  251. this.addLoaderListeners(false);
  252. if (fullscreenEnabled) {
  253. if (this.fullscreenCheckbox && this.fullscreenCheckbox.checked == true) {
  254. triggerFullscreen()
  255. }
  256. }
  257. this.dispatchEvent(new d.GameEvent(d.GameEvent.LAUNCH_GAME))
  258. };
  259. f.SHOW_TAP_TO_PLAY = true;
  260. return f
  261. })(PIXI.EventTarget);
  262. d.LoaderScreen = c
  263. })(a.goldenratio || (a.goldenratio = {}));
  264. var b = a.goldenratio
  265. })(com || (com = {}));
  266. var com;
  267. (function(a) {
  268. (function(d) {
  269. var c = (function() {
  270. function e(h, g, i, f) {
  271. this.type = h;
  272. this.startTime = g;
  273. this.duration = i;
  274. this.loop = f
  275. }
  276. e.CLICK = new e("click", 0, 261.2244897959184, false);
  277. e.EGG_FALL = new e("egg_fall", 2000, 789.4784580498869, false);
  278. e.EGG_SUCCESS = new e("egg_success", 4000, 1732.154195011338, false);
  279. e.LEVEL_COMPLETE = new e("level_complete", 7000, 1500, false);
  280. e.WOOD_TAP = new e("wood_tap", 10000, 624.9886621315195, false);
  281. e.HOWLER_DATA = {click: [0, 261.2244897959184],egg_fall: [2000, 789.4784580498869],egg_success: [4000, 1732.154195011338],level_complete: [7000, 1500],wood_tap: [10000, 624.9886621315195]};
  282. return e
  283. })();
  284. d.AudioSpriteData = c
  285. })(a.goldenratio || (a.goldenratio = {}));
  286. var b = a.goldenratio
  287. })(com || (com = {}));
  288. var com;
  289. (function(a) {
  290. (function(e) {
  291. var d = (function() {
  292. function f(g) {
  293. this.type = g
  294. }
  295. f.CLICK = new f(e.AudioSpriteData.CLICK.type);
  296. f.WOOD_TAP = new f(e.AudioSpriteData.WOOD_TAP.type);
  297. f.EGG_FALL = new f(e.AudioSpriteData.EGG_FALL.type);
  298. f.EGG_SUCCESS = new f(e.AudioSpriteData.EGG_SUCCESS.type);
  299. f.LEVEL_COMPLETE = new f(e.AudioSpriteData.LEVEL_COMPLETE.type);
  300. return f
  301. })();
  302. e.SFXType = d;
  303. var c = (function() {
  304. function f() {
  305. }
  306. f.init = function() {
  307. if (f.isSFXLoaded == true) {
  308. return
  309. }
  310. if (f.isSFXLoadError == true) {
  311. return
  312. }
  313. f.loadSFX();
  314. window.addEventListener("blur", f.onWindowBlur, false);
  315. window.addEventListener("focus", f.onWindowFocus, false);
  316. document.addEventListener(visibilityChange, f.handleVisibilityChange, false)
  317. };
  318. f.onWindowBlur = function(g) {
  319. f.mute(true)
  320. };
  321. f.onWindowFocus = function(g) {
  322. if (f.userMuteState == false) {
  323. f.mute(false)
  324. }
  325. };
  326. f.handleVisibilityChange = function() {
  327. if (document[hidden]) {
  328. f.mute(true)
  329. } else {
  330. if (f.userMuteState == false) {
  331. f.mute(false)
  332. }
  333. }
  334. };
  335. f.loadSFX = function() {
  336. this._sfx = new Howl({urls: ["mp3/70/sfx.ogg", "mp3/70/sfx.mp3"],sprite: e.AudioSpriteData.HOWLER_DATA,onplay: function() {
  337. f.isSFXLoaded = false;
  338. f.isSFXPlaying = true
  339. },onend: function() {
  340. f.isSFXLoaded = false;
  341. f.isSFXPlaying = false
  342. },onload: function() {
  343. f.isSFXLoaded = true;
  344. f.event.dispatchEvent(new e.GameEvent(e.GameEvent.SOUND_LOADED))
  345. },onloaderror: function() {
  346. f.isSFXLoaded = false;
  347. f.isSFXLoadError = true;
  348. f.event.dispatchEvent(new e.GameEvent(e.GameEvent.SOUND_ERROR))
  349. }});
  350. f.isSFXLoaded = false;
  351. f.isSFXLoadError = true;
  352. f.event.dispatchEvent(new e.GameEvent(e.GameEvent.SOUND_ERROR))
  353. };
  354. f.canPlaySFX = function(g) {
  355. return f.isSFXLoaded && (f.muteState == false || g)
  356. };
  357. f.playSFX = function(g, h) {
  358. if (typeof h === "undefined") {
  359. h = false
  360. }
  361. if (f.canPlaySFX(h) == true) {
  362. this._sfx.play(g.type)
  363. }
  364. };
  365. f.mute = function(g) {
  366. f.muteState = g;
  367. if (g) {
  368. Howler.mute()
  369. } else {
  370. Howler.unmute()
  371. }
  372. };
  373. f.toggleUserMute = function() {
  374. f.userMuteState = !f.userMuteState;
  375. f.mute(f.userMuteState)
  376. };
  377. f.setUserMute = function(g) {
  378. if (f.userMuteState != g) {
  379. f.userMuteState = g;
  380. f.mute(g)
  381. }
  382. };
  383. f.event = new PIXI.EventTarget();
  384. f.isSFXPlaying = false;
  385. f.isSFXLoaded = false;
  386. f.isSFXLoadError = false;
  387. f.muteState = false;
  388. f.userMuteState = false;
  389. return f
  390. })();
  391. e.SoundManager = c
  392. })(a.goldenratio || (a.goldenratio = {}));
  393. var b = a.goldenratio
  394. })(com || (com = {}));
  395. var com;
  396. (function(a) {
  397. (function(d) {
  398. var c = (function() {
  399. function e() {
  400. this.id_basket_01 = "basket_01";
  401. this.id_basket_02 = "basket_02";
  402. this.id_bg = "bg";
  403. this.id_button_credits = "button_credits";
  404. this.id_button_mainmenu = "button_mainmenu";
  405. this.id_button_moregames = "button_moregames";
  406. this.id_button_playagain = "button_playagain";
  407. this.id_button_startgame = "button_startgame";
  408. this.id_credits_panel = "credits_panel";
  409. this.id_egg = "egg";
  410. this.id_egg_life = "egg_life";
  411. this.id_egg_nolife = "egg_nolife";
  412. this.id_egg_title = "egg_title";
  413. this.id_labrat_copyright = "labrat_copyright";
  414. this.id_medal_bronze_1 = "medal_bronze_1";
  415. this.id_medal_gold_1 = "medal_gold_1";
  416. this.id_medal_gold_2 = "medal_gold_2";
  417. this.id_medal_gold_3 = "medal_gold_3";
  418. this.id_medal_gold_4 = "medal_gold_4";
  419. this.id_medal_none = "medal_none";
  420. this.id_medal_silver_1 = "medal_silver_1";
  421. this.id_medal_silver_2 = "medal_silver_2";
  422. this.id_medal_silver_3 = "medal_silver_3";
  423. this.id_medal_silver_4 = "medal_silver_4";
  424. this.id_number_0 = "number_0";
  425. this.id_number_1 = "number_1";
  426. this.id_number_2 = "number_2";
  427. this.id_number_3 = "number_3";
  428. this.id_number_4 = "number_4";
  429. this.id_number_5 = "number_5";
  430. this.id_number_6 = "number_6";
  431. this.id_number_7 = "number_7";
  432. this.id_number_8 = "number_8";
  433. this.id_number_9 = "number_9";
  434. this.id_pause_play_button = "pause_play_button";
  435. this.id_score_new = "score_new";
  436. this.id_score_panel = "score_panel";
  437. this.id_tap_hand_01 = "tap_hand_01";
  438. this.id_tap_hand_02 = "tap_hand_02";
  439. this.id_tap_left = "tap_left";
  440. this.id_tap_right = "tap_right";
  441. this.id_text_0 = "text_0";
  442. this.id_text_1 = "text_1";
  443. this.id_text_2 = "text_2";
  444. this.id_text_3 = "text_3";
  445. this.id_text_4 = "text_4";
  446. this.id_text_5 = "text_5";
  447. this.id_text_6 = "text_6";
  448. this.id_text_7 = "text_7";
  449. this.id_text_8 = "text_8";
  450. this.id_text_9 = "text_9";
  451. this.id_text_gameover = "text_gameover";
  452. this.id_text_paused = "text_paused";
  453. this.id_trans = "trans";
  454. this.id_volume_off = "volume_off";
  455. this.id_volume_on = "volume_on"
  456. }
  457. e.prototype.basket_01 = function() {
  458. return PIXI.Sprite.fromFrame("basket_01")
  459. };
  460. e.prototype.basket_02 = function() {
  461. return PIXI.Sprite.fromFrame("basket_02")
  462. };
  463. e.prototype.bg = function() {
  464. return PIXI.Sprite.fromFrame("bg")
  465. };
  466. e.prototype.button_credits = function() {
  467. return PIXI.Sprite.fromFrame("button_credits")
  468. };
  469. e.prototype.button_mainmenu = function() {
  470. return PIXI.Sprite.fromFrame("button_mainmenu")
  471. };
  472. e.prototype.button_moregames = function() {
  473. return PIXI.Sprite.fromFrame("button_moregames")
  474. };
  475. e.prototype.button_playagain = function() {
  476. return PIXI.Sprite.fromFrame("button_playagain")
  477. };
  478. e.prototype.button_startgame = function() {
  479. return PIXI.Sprite.fromFrame("button_startgame")
  480. };
  481. e.prototype.credits_panel = function() {
  482. return PIXI.Sprite.fromFrame("credits_panel")
  483. };
  484. e.prototype.egg = function() {
  485. return PIXI.Sprite.fromFrame("egg")
  486. };
  487. e.prototype.egg_life = function() {
  488. return PIXI.Sprite.fromFrame("egg_life")
  489. };
  490. e.prototype.egg_nolife = function() {
  491. return PIXI.Sprite.fromFrame("egg_nolife")
  492. };
  493. e.prototype.egg_title = function() {
  494. return PIXI.Sprite.fromFrame("egg_title")
  495. };
  496. e.prototype.labrat_copyright = function() {
  497. return PIXI.Sprite.fromFrame("labrat_copyright")
  498. };
  499. e.prototype.medal_bronze_1 = function() {
  500. return PIXI.Sprite.fromFrame("medal_bronze_1")
  501. };
  502. e.prototype.medal_gold_1 = function() {
  503. return PIXI.Sprite.fromFrame("medal_gold_1")
  504. };
  505. e.prototype.medal_gold_2 = function() {
  506. return PIXI.Sprite.fromFrame("medal_gold_2")
  507. };
  508. e.prototype.medal_gold_3 = function() {
  509. return PIXI.Sprite.fromFrame("medal_gold_3")
  510. };
  511. e.prototype.medal_gold_4 = function() {
  512. return PIXI.Sprite.fromFrame("medal_gold_4")
  513. };
  514. e.prototype.medal_none = function() {
  515. return PIXI.Sprite.fromFrame("medal_none")
  516. };
  517. e.prototype.medal_silver_1 = function() {
  518. return PIXI.Sprite.fromFrame("medal_silver_1")
  519. };
  520. e.prototype.medal_silver_2 = function() {
  521. return PIXI.Sprite.fromFrame("medal_silver_2")
  522. };
  523. e.prototype.medal_silver_3 = function() {
  524. return PIXI.Sprite.fromFrame("medal_silver_3")
  525. };
  526. e.prototype.medal_silver_4 = function() {
  527. return PIXI.Sprite.fromFrame("medal_silver_4")
  528. };
  529. e.prototype.number_0 = function() {
  530. return PIXI.Sprite.fromFrame("number_0")
  531. };
  532. e.prototype.number_1 = function() {
  533. return PIXI.Sprite.fromFrame("number_1")
  534. };
  535. e.prototype.number_2 = function() {
  536. return PIXI.Sprite.fromFrame("number_2")
  537. };
  538. e.prototype.number_3 = function() {
  539. return PIXI.Sprite.fromFrame("number_3")
  540. };
  541. e.prototype.number_4 = function() {
  542. return PIXI.Sprite.fromFrame("number_4")
  543. };
  544. e.prototype.number_5 = function() {
  545. return PIXI.Sprite.fromFrame("number_5")
  546. };
  547. e.prototype.number_6 = function() {
  548. return PIXI.Sprite.fromFrame("number_6")
  549. };
  550. e.prototype.number_7 = function() {
  551. return PIXI.Sprite.fromFrame("number_7")
  552. };
  553. e.prototype.number_8 = function() {
  554. return PIXI.Sprite.fromFrame("number_8")
  555. };
  556. e.prototype.number_9 = function() {
  557. return PIXI.Sprite.fromFrame("number_9")
  558. };
  559. e.prototype.pause_play_button = function() {
  560. return PIXI.Sprite.fromFrame("pause_play_button")
  561. };
  562. e.prototype.score_new = function() {
  563. return PIXI.Sprite.fromFrame("score_new")
  564. };
  565. e.prototype.score_panel = function() {
  566. return PIXI.Sprite.fromFrame("score_panel")
  567. };
  568. e.prototype.tap_hand_01 = function() {
  569. return PIXI.Sprite.fromFrame("tap_hand_01")
  570. };
  571. e.prototype.tap_hand_02 = function() {
  572. return PIXI.Sprite.fromFrame("tap_hand_02")
  573. };
  574. e.prototype.tap_left = function() {
  575. return PIXI.Sprite.fromFrame("tap_left")
  576. };
  577. e.prototype.tap_right = function() {
  578. return PIXI.Sprite.fromFrame("tap_right")
  579. };
  580. e.prototype.text_0 = function() {
  581. return PIXI.Sprite.fromFrame("text_0")
  582. };
  583. e.prototype.text_1 = function() {
  584. return PIXI.Sprite.fromFrame("text_1")
  585. };
  586. e.prototype.text_2 = function() {
  587. return PIXI.Sprite.fromFrame("text_2")
  588. };
  589. e.prototype.text_3 = function() {
  590. return PIXI.Sprite.fromFrame("text_3")
  591. };
  592. e.prototype.text_4 = function() {
  593. return PIXI.Sprite.fromFrame("text_4")
  594. };
  595. e.prototype.text_5 = function() {
  596. return PIXI.Sprite.fromFrame("text_5")
  597. };
  598. e.prototype.text_6 = function() {
  599. return PIXI.Sprite.fromFrame("text_6")
  600. };
  601. e.prototype.text_7 = function() {
  602. return PIXI.Sprite.fromFrame("text_7")
  603. };
  604. e.prototype.text_8 = function() {
  605. return PIXI.Sprite.fromFrame("text_8")
  606. };
  607. e.prototype.text_9 = function() {
  608. return PIXI.Sprite.fromFrame("text_9")
  609. };
  610. e.prototype.text_gameover = function() {
  611. return PIXI.Sprite.fromFrame("text_gameover")
  612. };
  613. e.prototype.text_paused = function() {
  614. return PIXI.Sprite.fromFrame("text_paused")
  615. };
  616. e.prototype.trans = function() {
  617. return PIXI.Sprite.fromFrame("trans")
  618. };
  619. e.prototype.volume_off = function() {
  620. return PIXI.Sprite.fromFrame("volume_off")
  621. };
  622. e.prototype.volume_on = function() {
  623. return PIXI.Sprite.fromFrame("volume_on")
  624. };
  625. return e
  626. })();
  627. d.Frame = c
  628. })(a.goldenratio || (a.goldenratio = {}));
  629. var b = a.goldenratio
  630. })(com || (com = {}));
  631. var com;
  632. (function(a) {
  633. (function(d) {
  634. var c = (function() {
  635. function e() {
  636. }
  637. e.frame = new d.Frame();
  638. return e
  639. })();
  640. d.Res = c
  641. })(a.goldenratio || (a.goldenratio = {}));
  642. var b = a.goldenratio
  643. })(com || (com = {}));
  644. var com;
  645. (function(a) {
  646. (function(d) {
  647. var c = (function() {
  648. function e() {
  649. }
  650. e.removeAllChildren = function(g) {
  651. if (g == null) {
  652. return
  653. }
  654. for (var f = g.children.length - 1; f >= 0; f--) {
  655. g.removeChild(g.children[f])
  656. }
  657. };
  658. e.removeFromParent = function(f) {
  659. if (f && f.parent) {
  660. f.parent.removeChild(f)
  661. }
  662. };
  663. e.removeList = function(f) {
  664. for (var g = f.length - 1; g >= 0; g--) {
  665. this.removeFromParent(f[g]);
  666. f[g] = null
  667. }
  668. };
  669. return e
  670. })();
  671. d.DisplayObjectUtils = c
  672. })(a.goldenratio || (a.goldenratio = {}));
  673. var b = a.goldenratio
  674. })(com || (com = {}));
  675. var com;
  676. (function(a) {
  677. (function(g) {
  678. var f = (function() {
  679. function h(i) {
  680. this._bucketType = i
  681. }
  682. h.prototype.toString = function() {
  683. return "{type: " + this._bucketType + "}"
  684. };
  685. h.MOVE_NONE = new h("MOVE_NONE");
  686. h.MOVE_LEFT_RIGHT = new h("MOVE_LEFT_RIGHT");
  687. h.MOVE_RIGHT_LEFT = new h("MOVE_RIGHT_LEFT");
  688. return h
  689. })();
  690. g.BucketAnimationType = f;
  691. var c = (function() {
  692. function h(i) {
  693. this._type = i
  694. }
  695. h.prototype.toString = function() {
  696. return "{type: " + this._type + "}"
  697. };
  698. h.STATIC = new h("static");
  699. h.FALLING = new h("falling");
  700. return h
  701. })();
  702. g.BucketType = c;
  703. var d = (function() {
  704. function h(i, j) {
  705. this.value = j;
  706. this._type = i
  707. }
  708. h.SLOW = new h("SLOW", 1);
  709. h.MEDIUM = new h("MEDIUM", 2);
  710. h.FAST = new h("FAST", 3);
  711. return h
  712. })();
  713. g.BucketSpeed = d;
  714. var e = (function() {
  715. function h(i, j) {
  716. this._rect = new PIXI.Rectangle(0, 0, 0, 0);
  717. this._eggPosition = new PIXI.Point(0, 0);
  718. this._isBounce = false;
  719. this._bounceCount = 0;
  720. this._animationType = f.MOVE_NONE;
  721. this._speed = d.SLOW;
  722. this._id = -1;
  723. this._direction = 1;
  724. this._isBlinkStart = false;
  725. this._blinkCount = 0;
  726. this._isFirstBlink = false;
  727. this._isSecondBlink = false;
  728. this._canDropBasket = false;
  729. this._canDropEgg = false;
  730. this.onBlinkComplete = this.onBlinkComplete.bind(this);
  731. this.dropBasket = this.dropBasket.bind(this);
  732. if (i == c.STATIC) {
  733. this._gfx = g.Res.frame.basket_01()
  734. } else {
  735. if (i == c.FALLING) {
  736. this._gfx = g.Res.frame.basket_02()
  737. }
  738. }
  739. this._type = i;
  740. this._id = j;
  741. this._gfx.pivot.x = this._gfx.width >> 1;
  742. this._gfx.pivot.y = this._gfx.height >> 1;
  743. this._gfx.scale.x = this._gfx.scale.y = 0.5;
  744. this._rect.width = this._gfx.width;
  745. this._rect.height = this._gfx.height-40
  746. }
  747. h.prototype.setAnimationType = function(i) {
  748. this._animationType = i;
  749. if (this._animationType == f.MOVE_RIGHT_LEFT) {
  750. this._direction = -1
  751. }
  752. if (this._animationType == f.MOVE_LEFT_RIGHT) {
  753. this._direction = 1
  754. }
  755. };
  756. Object.defineProperty(h.prototype, "animationType", {get: function() {
  757. return this._animationType
  758. },enumerable: true,configurable: true});
  759. h.prototype.setSpeed = function(i) {
  760. this._speed = i
  761. };
  762. h.prototype.setPosition = function(j, i) {
  763. this._rect.x = j;
  764. this._rect.y = i;
  765. this.updateRect()
  766. };
  767. h.prototype.updateRect = function() {
  768. this._eggPosition.x = this._rect.x + (this._rect.width >> 1);
  769. this._eggPosition.y = this._rect.y + (this._rect.height >> 1) - 10;
  770. this._gfx.position.x = this._rect.x + (this._rect.width >> 1);
  771. this._gfx.position.y = this._rect.y + (this._rect.height >> 1)
  772. };
  773. Object.defineProperty(h.prototype, "id", {get: function() {
  774. return this._id
  775. },enumerable: true,configurable: true});
  776. Object.defineProperty(h.prototype, "type", {get: function() {
  777. return this._type
  778. },enumerable: true,configurable: true});
  779. Object.defineProperty(h.prototype, "canDropEgg", {get: function() {
  780. return this._canDropEgg
  781. },enumerable: true,configurable: true});
  782. h.prototype.bounce = function() {
  783. if (this._isBounce == false) {
  784. this._rect.y += 2;
  785. this._isBounce = true;
  786. this.updateRect()
  787. }
  788. };
  789. h.prototype.onEggJumpedOffBasket = function() {
  790. this.bounce();
  791. this._isBlinkStart = false;
  792. this._isFirstBlink = false;
  793. this._isSecondBlink = false;
  794. this._blinkCount = 0
  795. };
  796. h.prototype.onEggLanded = function() {
  797. this.bounce();
  798. if (this._type == c.FALLING) {
  799. this._isBlinkStart = true;
  800. this._isFirstBlink = true
  801. }
  802. };
  803. h.prototype.reset = function() {
  804. this._isBlinkStart = false;
  805. this._isFirstBlink = false;
  806. this._isSecondBlink = false;
  807. this._canDropBasket = false;
  808. this._canDropEgg = false;
  809. this._blinkCount = 0;
  810. var i = this;
  811. this._tween = new TWEEN.Tween({alpha: this._gfx.alpha}).to({alpha: 1}, 200).easing(TWEEN.Easing.Linear.None).onUpdate(function() {
  812. if (i._gfx) {
  813. i._gfx.alpha = this.alpha
  814. }
  815. }).start()
  816. };
  817. h.prototype.update = function(i) {
  818. if (this._isBounce) {
  819. this._bounceCount++;
  820. if (this._bounceCount >= 8) {
  821. this._isBounce = false;
  822. this._bounceCount = 0;
  823. this._rect.y -= 2;
  824. this.updateRect()
  825. }
  826. }
  827. if (this._animationType && this._rect) {
  828. if (this._animationType == f.MOVE_LEFT_RIGHT || this._animationType == f.MOVE_RIGHT_LEFT) {
  829. this._rect.x -= this._speed.value * i * this._direction;
  830. if (this._rect.x <= 0) {
  831. this._rect.x = 0;
  832. this._direction *= -1
  833. } else {
  834. if (this._rect.x >= (320 - this._rect.width)) {
  835. this._rect.x = (320 - this._rect.width);
  836. this._direction *= -1
  837. }
  838. }
  839. this.updateRect()
  840. }
  841. }
  842. if (this._isBlinkStart) {
  843. this._blinkCount++;
  844. if (this._blinkCount >= 80 && this._isFirstBlink == true) {
  845. this._isFirstBlink = false;
  846. this.blinkBucket(false)
  847. }
  848. if (this._blinkCount >= 80 && this._isSecondBlink == true) {
  849. this._isSecondBlink = false;
  850. this.blinkBucket(true)
  851. }
  852. }
  853. };
  854. h.prototype.blinkBucket = function(j) {
  855. this._isBlinkStart = false;
  856. this._canDropBasket = j;
  857. var i = this;
  858. this._tween = new TWEEN.Tween({alpha: 1}).to({alpha: 0.3}, 600).repeat(3).yoyo(true).easing(TWEEN.Easing.Linear.None).onUpdate(function() {
  859. if (i._gfx) {
  860. i._gfx.alpha = this.alpha
  861. }
  862. }).onComplete(this.onBlinkComplete).start()
  863. };
  864. h.prototype.onBlinkComplete = function() {
  865. if (this._canDropBasket) {
  866. var i = this;
  867. this._tween = new TWEEN.Tween({alpha: 1}).to({alpha: 0}, 300).easing(TWEEN.Easing.Linear.None).onUpdate(function() {
  868. if (i._gfx) {
  869. i._gfx.alpha = this.alpha
  870. }
  871. }).onComplete(this.dropBasket).start();
  872. return
  873. }
  874. this._blinkCount = 0;
  875. this._isBlinkStart = true;
  876. this._isSecondBlink = true
  877. };
  878. h.prototype.dropBasket = function() {
  879. this._canDropEgg = true
  880. };
  881. Object.defineProperty(h.prototype, "gfx", {get: function() {
  882. return this._gfx
  883. },enumerable: true,configurable: true});
  884. Object.defineProperty(h.prototype, "rect", {get: function() {
  885. return this._rect
  886. },enumerable: true,configurable: true});
  887. Object.defineProperty(h.prototype, "eggPosition", {get: function() {
  888. return this._eggPosition
  889. },enumerable: true,configurable: true});
  890. h.prototype.dispose = function() {
  891. if (this._tween) {
  892. this._tween = null
  893. }
  894. g.DisplayObjectUtils.removeFromParent(this._gfx);
  895. this._gfx = null;
  896. this._rect = null;
  897. this._eggPosition = null;
  898. this._animationType = null;
  899. this._speed = null;
  900. this._type = null
  901. };
  902. return h
  903. })();
  904. g.Bucket = e
  905. })(a.goldenratio || (a.goldenratio = {}));
  906. var b = a.goldenratio
  907. })(com || (com = {}));
  908. var com;
  909. (function(a) {
  910. (function(d) {
  911. var c = (function() {
  912. function e(g) {
  913. this._list = [];
  914. this._container = g;
  915. var k = 999;
  916. var n = 115;
  917. var l = -50;
  918. var t = new d.Bucket(d.BucketType.STATIC, 0);
  919. t.setPosition(n, l);
  920. t.setAnimationType(d.BucketAnimationType.MOVE_NONE);
  921. this._list.push(t);
  922. l -= 180;
  923. var s = new d.Bucket(d.BucketType.STATIC, 1);
  924. s.setPosition(n, l);
  925. s.setAnimationType(d.BucketAnimationType.MOVE_NONE);
  926. this._list.push(s);
  927. k -= 2;
  928. var o = 0;
  929. for (var m = 0; m < k; m++) {
  930. l -= 180;
  931. var j = (Math.random() * 50) | 0;
  932. var f = this.getRandomBucketType(j);
  933. var h = this.getRandomAnimationType(j);
  934. var q = d.BucketSpeed.MEDIUM;
  935. if (f == d.BucketType.STATIC) {
  936. q = this.getRandomBucketSpeed(j)
  937. }
  938. if (m > 0) {
  939. var p = this._list[(m + 2) - 1];
  940. if (p.animationType == d.BucketAnimationType.MOVE_LEFT_RIGHT && h == d.BucketAnimationType.MOVE_LEFT_RIGHT) {
  941. h = d.BucketAnimationType.MOVE_NONE
  942. } else {
  943. if (p.animationType == d.BucketAnimationType.MOVE_RIGHT_LEFT && h == d.BucketAnimationType.MOVE_RIGHT_LEFT) {
  944. h = d.BucketAnimationType.MOVE_NONE
  945. }
  946. }
  947. if ((p.animationType == d.BucketAnimationType.MOVE_LEFT_RIGHT || p.animationType == d.BucketAnimationType.MOVE_RIGHT_LEFT) && h == d.BucketAnimationType.MOVE_NONE) {
  948. n = (Math.random() * 230) | 0
  949. }
  950. }
  951. if (f == d.BucketType.STATIC && h == d.BucketAnimationType.MOVE_NONE) {
  952. o++
  953. }
  954. if (o >= 4) {
  955. o = 0;
  956. h = d.BucketAnimationType.MOVE_RIGHT_LEFT
  957. }
  958. var r = new d.Bucket(f, m + 2);
  959. if (h == d.BucketAnimationType.MOVE_NONE) {
  960. r.setPosition(n, l)
  961. } else {
  962. r.setPosition((Math.random() * 230) | 0, l)
  963. }
  964. r.setAnimationType(h);
  965. r.setSpeed(q);
  966. this._list.push(r)
  967. }
  968. this._list.reverse();
  969. this._firstBasket = this._list[this._list.length - 1]
  970. }
  971. e.prototype.getRandomAnimationType = function(f) {
  972. if (f > 16 && f <= 32) {
  973. return d.BucketAnimationType.MOVE_LEFT_RIGHT
  974. } else {
  975. if (f > 32) {
  976. return d.BucketAnimationType.MOVE_RIGHT_LEFT
  977. }
  978. }
  979. return d.BucketAnimationType.MOVE_NONE
  980. };
  981. e.prototype.getRandomBucketSpeed = function(f) {
  982. if (f >= 0 && f <= 20) {
  983. return d.BucketSpeed.SLOW
  984. }
  985. return d.BucketSpeed.MEDIUM
  986. };
  987. e.prototype.getRandomBucketType = function(f) {
  988. if (f >= 30) {
  989. return d.BucketType.FALLING
  990. }
  991. return d.BucketType.STATIC
  992. };
  993. e.prototype.updateCurrentBasket = function(g) {
  994. this._nextBasket = null;
  995. this._currentBasket = null;
  996. if (this._firstBasket && !this._firstBasket.gfx.parent) {
  997. this._container.addChild(this._firstBasket.gfx)
  998. }
  999. for (var f = this._list.length - 1; f >= 0; f--) {
  1000. if (this._list[f].id == g) {
  1001. this._currentBasket = this._list[f];
  1002. if (!this._currentBasket.gfx.parent) {
  1003. this._container.addChild(this._currentBasket.gfx)
  1004. }
  1005. if (this._list[f - 1]) {
  1006. this._nextBasket = this._list[f - 1];
  1007. if (!this._nextBasket.gfx.parent) {
  1008. this._container.addChild(this._nextBasket.gfx)
  1009. }
  1010. }
  1011. if (this._list[f - 2]) {
  1012. this._list[f - 2].gfx.visible = true;
  1013. if (!this._list[f - 2].gfx.parent) {
  1014. this._container.addChild(this._list[f - 2].gfx)
  1015. }
  1016. }
  1017. return
  1018. }
  1019. }
  1020. };
  1021. Object.defineProperty(e.prototype, "currentBasket", {get: function() {
  1022. return this._currentBasket
  1023. },enumerable: true,configurable: true});
  1024. Object.defineProperty(e.prototype, "nextBasket", {get: function() {
  1025. return this._nextBasket
  1026. },enumerable: true,configurable: true});
  1027. Object.defineProperty(e.prototype, "firstBasket", {get: function() {
  1028. return this._firstBasket
  1029. },enumerable: true,configurable: true});
  1030. e.prototype.update = function(j) {
  1031. var h = this._list.length;
  1032. var f = (h - 3);
  1033. if (f < 0) {
  1034. f = 0
  1035. }
  1036. for (var g = h - 1; g >= f; g--) {
  1037. this._list[g].update(j)
  1038. }
  1039. };
  1040. e.prototype.onEggLanded = function() {
  1041. };
  1042. e.prototype.onContainerScrollComplete = function() {
  1043. for (var f = this._list.length - 1; f >= 0; f--) {
  1044. if (this._list[f].id < this._currentBasket.id) {
  1045. var g = this._list[f];
  1046. if (g) {
  1047. g.dispose();
  1048. g = null;
  1049. this._list.splice(f, 1)
  1050. }
  1051. } else {
  1052. break
  1053. }
  1054. }
  1055. this._firstBasket = this._list[this._list.length - 1]
  1056. };
  1057. e.prototype.dispose = function() {
  1058. for (var f = 0; f < this._list.length; f++) {
  1059. this._list[f].dispose();
  1060. this._list[f] = null
  1061. }
  1062. this._list.length = 0;
  1063. this._list = null;
  1064. this._currentBasket = null;
  1065. this._nextBasket = null;
  1066. this._firstBasket = null;
  1067. this._container = null
  1068. };
  1069. return e
  1070. })();
  1071. d.BucketManager = c
  1072. })(a.goldenratio || (a.goldenratio = {}));
  1073. var b = a.goldenratio
  1074. })(com || (com = {}));
  1075. var com;
  1076. (function(a) {
  1077. (function(d) {
  1078. var c = (function() {
  1079. function e() {
  1080. }
  1081. e.distanceBetweenTwoPoints = function(h, g, f, i) {
  1082. return Math.sqrt(Math.pow(f - h, 2) + Math.pow(i - g, 2))
  1083. };
  1084. e.degreesToRadians = function(f) {
  1085. return f * Math.PI / 180
  1086. };
  1087. e.radiansToDegrees = function(f) {
  1088. return f * 180 / Math.PI
  1089. };
  1090. return e
  1091. })();
  1092. d.MathUtils = c
  1093. })(a.goldenratio || (a.goldenratio = {}));
  1094. var b = a.goldenratio
  1095. })(com || (com = {}));
  1096. var com;
  1097. (function(a) {
  1098. (function(e) {
  1099. var d = (function() {
  1100. function f() {
  1101. }
  1102. f.SPEED = 5;
  1103. f.MAX_HEIGHT = 240;
  1104. f.ROTATION_SPEED = 15;
  1105. return f
  1106. })();
  1107. e.EggConf = d;
  1108. var c = (function(g) {
  1109. __extends(f, g);
  1110. function f() {
  1111. g.call(this);
  1112. this._rect = new PIXI.Rectangle(0, 0, 0, 0);
  1113. this._position = new PIXI.Point(0, 0);
  1114. this._rotation = 0;
  1115. this._isJump = false;
  1116. this._destinationPosition = new PIXI.Point(0, 0);
  1117. this._initialPosition = new PIXI.Point(0, 0);
  1118. this._fallFlag = false;
  1119. this._basketID = -1;
  1120. this._fallFriction = 1;
  1121. this._raiseFriction = 1;
  1122. this._isFreeFall = false;
  1123. this._swapDepthFlag = false;
  1124. this._swapDepthInsideFlag = false;
  1125. this._canLandInNextBasket = false;
  1126. this._isAlive = true;
  1127. this._hasFallenOffScreen = false;
  1128. this._gfx = e.Res.frame.egg();
  1129. this._gfx.pivot.x = this._gfx.width >> 1;
  1130. this._gfx.pivot.y = this._gfx.height >> 1;
  1131. this._gfx.scale.x = this._gfx.scale.y = 0.5;
  1132. this._rect.width = this._gfx.width;
  1133. this._rect.height = this._gfx.height-40
  1134. }
  1135. f.prototype.resetFlags = function() {
  1136. this._fallFlag = false;
  1137. this._isJump = false;
  1138. this._initialPosition.x = 0;
  1139. this._initialPosition.y = 0;
  1140. this._destinationPosition.x = 0;
  1141. this._destinationPosition.y = 0;
  1142. this._rotation = 0;
  1143. this._canLandInNextBasket = false
  1144. };
  1145. f.prototype.setPosition = function(i, h) {
  1146. this._position.x = i;
  1147. this._position.y = h;
  1148. this.updateRect()
  1149. };
  1150. f.prototype.updateRect = function() {
  1151. this._rect.x = this._position.x - (this._rect.width >> 1);
  1152. this._rect.y = this._position.y - (this._rect.height >> 1);
  1153. this._gfx.position.x = this._position.x;
  1154. this._gfx.position.y = this._position.y;
  1155. this._gfx.rotation = e.MathUtils.degreesToRadians(this._rotation)
  1156. };
  1157. f.prototype.setJump = function(h) {
  1158. if (this._isJump != h) {
  1159. this._isJump = h;
  1160. if (this._isJump) {
  1161. this._fallFlag = false;
  1162. this._fallFriction = 0;
  1163. this._raiseFriction = 1;
  1164. this._isFreeFall = false;
  1165. this._swapDepthFlag = false;
  1166. this._swapDepthInsideFlag = false;
  1167. this._initialPosition.y = this._position.y;
  1168. this._destinationPosition.y = (this._position.y - d.MAX_HEIGHT) >> 0
  1169. }
  1170. }
  1171. };
  1172. Object.defineProperty(f.prototype, "gfx", {get: function() {
  1173. return this._gfx
  1174. },enumerable: true,configurable: true});
  1175. Object.defineProperty(f.prototype, "rect", {get: function() {
  1176. return this._rect
  1177. },enumerable: true,configurable: true});
  1178. Object.defineProperty(f.prototype, "isJumping", {get: function() {
  1179. return this._isJump
  1180. },enumerable: true,configurable: true});
  1181. Object.defineProperty(f.prototype, "hasFallenOffScreen", {get: function() {
  1182. return this._hasFallenOffScreen
  1183. },enumerable: true,configurable: true});
  1184. Object.defineProperty(f.prototype, "canLandInNextBasket", {get: function() {
  1185. return this._canLandInNextBasket
  1186. },enumerable: true,configurable: true});
  1187. Object.defineProperty(f.prototype, "isFalling", {get: function() {
  1188. return this._fallFlag
  1189. },enumerable: true,configurable: true});
  1190. f.prototype.setBasketID = function(h) {
  1191. this._basketID = h;
  1192. this.resetFlags()
  1193. };
  1194. Object.defineProperty(f.prototype, "basketID", {get: function() {
  1195. return this._basketID
  1196. },enumerable: true,configurable: true});
  1197. f.prototype.update = function(k, i, h, j) {
  1198. if (this._hasFallenOffScreen) {
  1199. return
  1200. }
  1201. if (this._isJump) {
  1202. if (!this._fallFlag) {
  1203. this._fallFlag = (this._position.y <= this._destinationPosition.y)
  1204. }
  1205. if (this._fallFlag) {
  1206. if (this._fallFriction < 1) {
  1207. this._fallFriction += 0.05
  1208. }
  1209. if (this._fallFriction > 1) {
  1210. this._fallFriction = 1
  1211. }
  1212. this._position.y += d.SPEED * this._fallFriction
  1213. } else {
  1214. if (this._isFreeFall) {
  1215. if (this._raiseFriction > 0) {
  1216. this._raiseFriction -= 0.05
  1217. }
  1218. if (this._raiseFriction < 0) {
  1219. this._raiseFriction = 0
  1220. }
  1221. this._position.y -= d.SPEED * this._raiseFriction
  1222. } else {
  1223. this._position.y -= d.SPEED
  1224. }
  1225. }
  1226. if (Math.abs(this._destinationPosition.y - this._position.y) > 40) {
  1227. this._rotation += d.ROTATION_SPEED;
  1228. this._isFreeFall = false
  1229. } else {
  1230. this._rotation = 270;
  1231. this._isFreeFall = true
  1232. }
  1233. if (this._rotation >= 360) {
  1234. this._rotation = 0
  1235. }
  1236. if (this._swapDepthFlag == false && (this._position.y <= (this._initialPosition.y - 60))) {
  1237. this._swapDepthFlag = true;
  1238. this.dispatchEvent(new e.GameEvent(e.GameEvent.EGG_OUTOFF_BASKET))
  1239. }
  1240. if (this._fallFlag && h) {
  1241. if ((this._position.x > h.rect.x + 10) && (this._position.x < (h.rect.x + h.rect.width - 10))) {
  1242. if (this._swapDepthInsideFlag == false && (this._position.y >= h.rect.y - 15) && (this._position.y <= h.rect.y)) {
  1243. this._swapDepthInsideFlag = true;
  1244. this.dispatchEvent(new e.GameEvent(e.GameEvent.EGG_INSIDE_BASKET))
  1245. }
  1246. if (this._canLandInNextBasket == false && (this._position.y >= h.rect.y - 5) && (this._position.y <= h.rect.y)) {
  1247. this._canLandInNextBasket = true
  1248. }
  1249. }
  1250. if (this._hasFallenOffScreen == false && this._position.y >= (j.rect.y + j.rect.height + 100)) {
  1251. this._hasFallenOffScreen = true;
  1252. this.dispatchEvent(new e.GameEvent(e.GameEvent.GAME_OVER));
  1253. return
  1254. }
  1255. }
  1256. } else {
  1257. if (i) {
  1258. if (i.canDropEgg == false) {
  1259. this._position.x = i.eggPosition.x;
  1260. this._position.y = i.eggPosition.y
  1261. } else {
  1262. if (this._hasFallenOffScreen == false && this._position.y >= (j.rect.y + j.rect.height + 100)) {
  1263. this._hasFallenOffScreen = true;
  1264. this.dispatchEvent(new e.GameEvent(e.GameEvent.GAME_OVER));
  1265. return
  1266. }
  1267. this._position.y += 6 * k;
  1268. if (this._isAlive) {
  1269. this._isAlive = false;
  1270. this.dispatchEvent(new e.GameEvent(e.GameEvent.EGG_DIED))
  1271. }
  1272. }
  1273. }
  1274. }
  1275. this.updateRect()
  1276. };
  1277. f.prototype.reset = function() {
  1278. this.resetFlags();
  1279. this._hasFallenOffScreen = false;
  1280. this._fallFlag = false;
  1281. this._fallFriction = 0;
  1282. this._raiseFriction = 1;
  1283. this._isFreeFall = false;
  1284. this._swapDepthFlag = false;
  1285. this._swapDepthInsideFlag = false
  1286. };
  1287. f.prototype.dispose = function() {
  1288. e.DisplayObjectUtils.removeFromParent(this._gfx);
  1289. this._gfx = null;
  1290. this._rect = null;
  1291. this._position = null;
  1292. this._destinationPosition = null;
  1293. this._initialPosition = null
  1294. };
  1295. return f
  1296. })(PIXI.EventTarget);
  1297. e.Egg = c
  1298. })(a.goldenratio || (a.goldenratio = {}));
  1299. var b = a.goldenratio
  1300. })(com || (com = {}));
  1301. var com;
  1302. (function(a) {
  1303. (function(d) {
  1304. var c = (function() {
  1305. function e() {
  1306. }
  1307. e.hideMouse = function(f) {
  1308. f.style.cursor = "none"
  1309. };
  1310. e.showMouse = function(f) {
  1311. f.style.cursor = "default"
  1312. };
  1313. e.getMouseX = function(i, f, h) {
  1314. var g = h.offsetX ? h.offsetX : h.clientX - i.left;
  1315. return ((g / i.width) * f) >> 0
  1316. };
  1317. e.getMouseY = function(h, i, g) {
  1318. var f = g.offsetY ? g.offsetY : g.clientY - h.top;
  1319. return ((f / h.height) * i) >> 0
  1320. };
  1321. e.getTouchX = function(i, f, h) {
  1322. var j = h.touches[0];
  1323. var g = j.clientX - i.left;
  1324. return ((g / i.width) * f) >> 0
  1325. };
  1326. e.getTouchY = function(h, i, g) {
  1327. var j = g.touches[0];
  1328. var f = j.clientY - h.top;
  1329. return ((f / h.height) * i) >> 0
  1330. };
  1331. return e
  1332. })();
  1333. d.MouseUtils = c
  1334. })(a.goldenratio || (a.goldenratio = {}));
  1335. var b = a.goldenratio
  1336. })(com || (com = {}));
  1337. var com;
  1338. (function(a) {
  1339. (function(d) {
  1340. var c = (function(f) {
  1341. __extends(e, f);
  1342. function e() {
  1343. f.call(this);
  1344. this.isSoundButtonPressed = false;
  1345. this.isPlayAgainPressed = false;
  1346. this.isMoreGamesPressed = false;
  1347. this.isStartGamePressed = false;
  1348. this.isCreditPressed = false;
  1349. this.isMainMenuPressed = false;
  1350. this.isPauseButtonPressed = false;
  1351. this._isGamePaused = false;
  1352. this.mapBinds();
  1353. this.setEnable(false)
  1354. }
  1355. e.prototype.mapBinds = function() {
  1356. this.onMouseDownHL = this.onMouseDownHL.bind(this);
  1357. this.onMouseUpHL = this.onMouseUpHL.bind(this);
  1358. this.onTouchStartHL = this.onTouchStartHL.bind(this);
  1359. this.onTouchEndHL = this.onTouchEndHL.bind(this)
  1360. };
  1361. e.prototype.setSoundButtonRect = function(g) {
  1362. this._soundRect = g
  1363. };
  1364. e.prototype.setStartGameRect = function(g) {
  1365. this._startGameRect = g
  1366. };
  1367. e.prototype.setCreditsRect = function(g) {
  1368. this._creditsRect = g
  1369. };
  1370. e.prototype.setMainMenuRect = function(g) {
  1371. this._mainMenuRect = g
  1372. };
  1373. e.prototype.setPlayAgainRect = function(g) {
  1374. this._playAgainRect = g
  1375. };
  1376. e.prototype.setMoreGamesRect = function(g) {
  1377. this._moreGamesRect = g
  1378. };
  1379. e.prototype.setPauseButtonRect = function(g) {
  1380. this._pauseButtonRect = g
  1381. };
  1382. e.prototype.setGamePaused = function(g) {
  1383. this._isGamePaused = g
  1384. };
  1385. e.prototype.setEnable = function(g) {
  1386. gameContainer.removeEventListener("touchstart", this.onTouchStartHL, false);
  1387. gameContainer.removeEventListener("touchend", this.onTouchEndHL, false);
  1388. gameContainer.removeEventListener("mousedown", this.onMouseDownHL, false);
  1389. gameContainer.removeEventListener("mouseup", this.onMouseUpHL, false);
  1390. if (g) {
  1391. gameContainer.addEventListener("touchstart", this.onTouchStartHL, false);
  1392. gameContainer.addEventListener("touchend", this.onTouchEndHL, false);
  1393. gameContainer.addEventListener("mousedown", this.onMouseDownHL, false);
  1394. gameContainer.addEventListener("mouseup", this.onMouseUpHL, false)
  1395. }
  1396. };
  1397. e.prototype.onMouseUpHL = function(g) {
  1398. g.stopPropagation();
  1399. g.preventDefault();
  1400. this.handleUPState()
  1401. };
  1402. e.prototype.onTouchEndHL = function(g) {
  1403. g.stopPropagation();
  1404. g.preventDefault();
  1405. this.handleUPState()
  1406. };
  1407. e.prototype.onTouchStartHL = function(j) {
  1408. j.stopPropagation();
  1409. j.preventDefault();
  1410. var i = gameContainer.getBoundingClientRect();
  1411. var h = d.MouseUtils.getTouchX(i, d.Main.GAME_DIMENSION.width, j);
  1412. var g = d.MouseUtils.getTouchY(i, d.Main.GAME_DIMENSION.height, j);
  1413. this.checkButtonHit(h, g)
  1414. };
  1415. e.prototype.onMouseDownHL = function(j) {
  1416. j.stopPropagation();
  1417. j.preventDefault();
  1418. var i = gameContainer.getBoundingClientRect();
  1419. var h = d.MouseUtils.getMouseX(i, d.Main.GAME_DIMENSION.width, j);
  1420. var g = d.MouseUtils.getMouseY(i, d.Main.GAME_DIMENSION.height, j);
  1421. this.checkButtonHit(h, g)
  1422. };
  1423. e.prototype.checkButtonHit = function(h, g) {
  1424. if (!this._isGamePaused) {
  1425. if (this._soundRect && this._soundRect.contains(h, g)) {
  1426. this.isSoundButtonPressed = true;
  1427. this.dispatchEvent(new d.GameEvent(d.GameEvent.BUTTON_DOWN))
  1428. } else {
  1429. if (this._playAgainRect && this._playAgainRect.contains(h, g)) {
  1430. this.isPlayAgainPressed = true;
  1431. this.dispatchEvent(new d.GameEvent(d.GameEvent.BUTTON_DOWN))
  1432. } else {
  1433. if (this._moreGamesRect && this._moreGamesRect.contains(h, g)) {
  1434. this.isMoreGamesPressed = true;
  1435. this.dispatchEvent(new d.GameEvent(d.GameEvent.BUTTON_DOWN))
  1436. } else {
  1437. if (this._startGameRect && this._startGameRect.contains(h, g)) {
  1438. this.isStartGamePressed = true;
  1439. this.dispatchEvent(new d.GameEvent(d.GameEvent.BUTTON_DOWN))
  1440. } else {
  1441. if (this._creditsRect && this._creditsRect.contains(h, g)) {
  1442. this.isCreditPressed = true;
  1443. this.dispatchEvent(new d.GameEvent(d.GameEvent.BUTTON_DOWN))
  1444. } else {
  1445. if (this._mainMenuRect && this._mainMenuRect.contains(h, g)) {
  1446. this.isMainMenuPressed = true;
  1447. this.dispatchEvent(new d.GameEvent(d.GameEvent.BUTTON_DOWN))
  1448. } else {
  1449. this.dispatchEggJump()
  1450. }
  1451. }
  1452. }
  1453. }
  1454. }
  1455. }
  1456. } else {
  1457. if (this._pauseButtonRect && this._pauseButtonRect.contains(h, g)) {
  1458. this.isPauseButtonPressed = true;
  1459. this.dispatchEvent(new d.GameEvent(d.GameEvent.BUTTON_DOWN))
  1460. }
  1461. }
  1462. };
  1463. e.prototype.handleUPState = function() {
  1464. if (this.isSoundButtonPressed) {
  1465. this.dispatchEvent(new d.GameEvent(d.GameEvent.BUTTON_UP));
  1466. this.isSoundButtonPressed = false
  1467. } else {
  1468. if (this.isPlayAgainPressed) {
  1469. this.dispatchEvent(new d.GameEvent(d.GameEvent.BUTTON_UP));
  1470. this.isPlayAgainPressed = false
  1471. } else {
  1472. if (this.isMoreGamesPressed) {
  1473. this.dispatchEvent(new d.GameEvent(d.GameEvent.BUTTON_UP));
  1474. this.isMoreGamesPressed = false
  1475. } else {
  1476. if (this.isStartGamePressed) {
  1477. this.dispatchEvent(new d.GameEvent(d.GameEvent.BUTTON_UP));
  1478. this.isStartGamePressed = false
  1479. } else {
  1480. if (this.isCreditPressed) {
  1481. this.dispatchEvent(new d.GameEvent(d.GameEvent.BUTTON_UP));
  1482. this.isCreditPressed = false
  1483. } else {
  1484. if (this.isMainMenuPressed) {
  1485. this.dispatchEvent(new d.GameEvent(d.GameEvent.BUTTON_UP));
  1486. this.isMainMenuPressed = false
  1487. } else {
  1488. if (this.isPauseButtonPressed) {
  1489. this.dispatchEvent(new d.GameEvent(d.GameEvent.BUTTON_UP));
  1490. this.isPauseButtonPressed = false
  1491. }
  1492. }
  1493. }
  1494. }
  1495. }
  1496. }
  1497. }
  1498. };
  1499. e.prototype.dispatchEggJump = function() {
  1500. this.dispatchEvent(new d.GameEvent(d.GameEvent.CANVAS_MOUSE_DOOWN))
  1501. };
  1502. e.prototype.dispose = function() {
  1503. this.setEnable(false);
  1504. this._soundRect = null;
  1505. this._playAgainRect = null;
  1506. this._moreGamesRect = null;
  1507. this._startGameRect = null;
  1508. this._creditsRect = null;
  1509. this._pauseButtonRect = null
  1510. };
  1511. return e
  1512. })(PIXI.EventTarget);
  1513. d.InputControl = c
  1514. })(a.goldenratio || (a.goldenratio = {}));
  1515. var b = a.goldenratio
  1516. })(com || (com = {}));
  1517. var com;
  1518. (function(a) {
  1519. (function(e) {
  1520. var c = (function() {
  1521. function f() {
  1522. }
  1523. f.SOUND_KEY = "com.labrat.egg.sound_key";
  1524. f.SCORE = "com.labrat.egg.score";
  1525. return f
  1526. })();
  1527. e.LocalKey = c;
  1528. var d = (function() {
  1529. function f() {
  1530. }
  1531. f.save = function(g, i) {
  1532. localStorage.setItem(g, i);
  1533. try {
  1534. var k = f.convertValueToHash(i);
  1535. var h = g + "_data";
  1536. localStorage.setItem(h, k.toString())
  1537. } catch (j) {
  1538. }
  1539. };
  1540. f.convertValueToHash = function(h) {
  1541. var g = h + f.HASH;
  1542. return CryptoJS.MD5(g).toString()
  1543. };
  1544. f.get = function(i, g) {
  1545. var j = localStorage.getItem(i);
  1546. var h = localStorage.getItem(i + "_data");
  1547. var k = j;
  1548. if (j != null && h != null) {
  1549. try {
  1550. var m = f.convertValueToHash(k.toString());
  1551. if (m != h) {
  1552. k = null
  1553. }
  1554. } catch (l) {
  1555. }
  1556. }
  1557. if (k == null && g != null) {
  1558. k = g
  1559. }
  1560. return k
  1561. };
  1562. f.getNumber = function(i, g) {
  1563. var j = 0;
  1564. var h = f.get(i);
  1565. if (h) {
  1566. j = parseInt(h);
  1567. if (isNaN(j)) {
  1568. if (!isNaN(g)) {
  1569. j = g
  1570. } else {
  1571. j = 0
  1572. }
  1573. }
  1574. } else {
  1575. if (!isNaN(g)) {
  1576. j = g
  1577. }
  1578. }
  1579. return j
  1580. };
  1581. f.getBoolean = function(i, g) {
  1582. var h = f.get(i);
  1583. if (h == "true" || h == "1") {
  1584. return true
  1585. }
  1586. if (h == "false" || h == "0") {
  1587. return false
  1588. }
  1589. if (typeof g !== "undefined") {
  1590. return g
  1591. }
  1592. return false
  1593. };
  1594. f.HASH = "xPBUEYnZpWrjlACCKDXh";
  1595. return f
  1596. })();
  1597. e.LocalStorageUtils = d
  1598. })(a.goldenratio || (a.goldenratio = {}));
  1599. var b = a.goldenratio
  1600. })(com || (com = {}));
  1601. var com;
  1602. (function(a) {
  1603. (function(d) {
  1604. var c = (function() {
  1605. function e() {
  1606. }
  1607. e.getMedalGfxFromScore = function(f) {
  1608. if (f <= 0) {
  1609. return d.Res.frame.medal_none()
  1610. }
  1611. if (f >= 1 && f < 10) {
  1612. return d.Res.frame.medal_bronze_1()
  1613. }
  1614. if (f >= 10 && f < 30) {
  1615. return d.Res.frame.medal_silver_1()
  1616. }
  1617. if (f >= 30 && f < 50) {
  1618. return d.Res.frame.medal_silver_2()
  1619. }
  1620. if (f >= 50 && f < 70) {
  1621. return d.Res.frame.medal_silver_3()
  1622. }
  1623. if (f >= 70 && f < 90) {
  1624. return d.Res.frame.medal_silver_4()
  1625. }
  1626. if (f >= 90 && f < 120) {
  1627. return d.Res.frame.medal_gold_1()
  1628. }
  1629. if (f >= 120 && f < 150) {
  1630. return d.Res.frame.medal_gold_2()
  1631. }
  1632. if (f >= 150 && f < 180) {
  1633. return d.Res.frame.medal_gold_3()
  1634. }
  1635. if (f >= 180) {
  1636. return d.Res.frame.medal_gold_4()
  1637. }
  1638. return d.Res.frame.medal_none()
  1639. };
  1640. return e
  1641. })();
  1642. d.MedalData = c
  1643. })(a.goldenratio || (a.goldenratio = {}));
  1644. var b = a.goldenratio
  1645. })(com || (com = {}));
  1646. var com;
  1647. (function(a) {
  1648. (function(e) {
  1649. var c = (function(g) {
  1650. __extends(f, g);
  1651. function f(h) {
  1652. g.call(this);
  1653. this._gameOverContainer = new PIXI.DisplayObjectContainer();
  1654. h.addChild(this._gameOverContainer);
  1655. this.showScorePanel = this.showScorePanel.bind(this);
  1656. this.populateScoreData = this.populateScoreData.bind(this);
  1657. this.showButtons = this.showButtons.bind(this);
  1658. this.dispatchButtonReadyEvent = this.dispatchButtonReadyEvent.bind(this)
  1659. }
  1660. f.prototype.show = function(i) {
  1661. this._score = i;
  1662. this._gameOverText = e.Res.frame.text_gameover();
  1663. this._gameOverText.anchor.x = 0.5;
  1664. this._gameOverText.anchor.y = 0.5;
  1665. this._gameOverText.scale.x = 0;
  1666. this._gameOverText.scale.y = 0;
  1667. this._gameOverText.position.x = 160;
  1668. this._gameOverText.position.y = 80;
  1669. this._gameOverContainer.addChild(this._gameOverText);
  1670. var h = this;
  1671. this._tween = new TWEEN.Tween({scale: this._gameOverText.scale.x}).to({scale: 0.5}, 600).easing(TWEEN.Easing.Bounce.Out).onUpdate(function() {
  1672. if (h._gameOverText) {
  1673. h._gameOverText.scale.x = this.scale;
  1674. h._gameOverText.scale.y = this.scale
  1675. }
  1676. }).onComplete(h.showScorePanel).start()
  1677. //var titlex = "鸡妈妈感谢你拯救了"+this._score+"颗蛋!分享到朋友圈告诉朋友一起来帮助鸡妈妈~~";
  1678. var score = this._score;
  1679. //btGame.playScoreMsg(titlex);
  1680. dp_submitScore(parseInt(score));
  1681. };
  1682. f.prototype.showScorePanel = function() {
  1683. this._scorePanelGfx = e.Res.frame.score_panel();
  1684. this._scorePanelGfx.scale.x = 1;
  1685. this._scorePanelGfx.scale.y = 1;
  1686. this._scorePanelGfx.anchor.x = 0.5;
  1687. this._scorePanelGfx.anchor.y = 0.5;
  1688. this._scorePanelGfx.position.x = 160;
  1689. this._scorePanelGfx.position.y = 520;
  1690. this._gameOverContainer.addChild(this._scorePanelGfx);
  1691. var h = this;
  1692. this._tween = new TWEEN.Tween({y: this._scorePanelGfx.position.y}).to({y: 190}, 400).easing(TWEEN.Easing.Back.Out).onUpdate(function() {
  1693. if (h._scorePanelGfx) {
  1694. h._scorePanelGfx.position.y = this.y;
  1695. h._scorePanelGfx.position.y = this.y
  1696. }
  1697. }).onComplete(h.populateScoreData).start()
  1698. };
  1699. f.prototype.populateScoreData = function() {
  1700. var m = new d(this._score.toString());
  1701. m.position.x = 272;
  1702. m.position.y = 155;
  1703. m.alpha = 0;
  1704. this._gameOverContainer.addChild(m);
  1705. var h = e.LocalStorageUtils.getNumber(e.LocalKey.SCORE, 0);
  1706. var k;
  1707. if (this._score > h) {
  1708. h = this._score;
  1709. e.LocalStorageUtils.save(e.LocalKey.SCORE, h.toString());
  1710. k = e.Res.frame.score_new()
  1711. }
  1712. var l = new d(h.toString());
  1713. l.position.x = 272;
  1714. l.position.y = 220;
  1715. l.alpha = 0;
  1716. this._gameOverContainer.addChild(l);
  1717. var j = e.MedalData.getMedalGfxFromScore(this._score);
  1718. if (j) {
  1719. j.position.x = 50;
  1720. j.position.y = 155;
  1721. j.scale.x = 0.8;
  1722. j.scale.y = 0.8;
  1723. j.alpha = 0;
  1724. this._gameOverContainer.addChild(j)
  1725. }
  1726. if (k) {
  1727. k.position.x = 180;
  1728. k.position.y = 195;
  1729. k.alpha = 0;
  1730. this._gameOverContainer.addChild(k)
  1731. }
  1732. var i = this;
  1733. this._tween = new TWEEN.Tween({alpha: 0}).to({alpha: 1}, 200).easing(TWEEN.Easing.Linear.None).onUpdate(function() {
  1734. if (m) {
  1735. m.alpha = this.alpha
  1736. }
  1737. if (l) {
  1738. l.alpha = this.alpha
  1739. }
  1740. if (j) {
  1741. j.alpha = this.alpha
  1742. }
  1743. if (k) {
  1744. k.alpha = this.alpha
  1745. }
  1746. }).onComplete(i.showButtons).start()
  1747. };
  1748. f.getScoreText = function(h) {
  1749. if (h == "0") {
  1750. return e.Res.frame.number_0()
  1751. }
  1752. if (h == "1") {
  1753. return e.Res.frame.number_1()
  1754. }
  1755. if (h == "2") {
  1756. return e.Res.frame.number_2()
  1757. }
  1758. if (h == "3") {
  1759. return e.Res.frame.number_3()
  1760. }
  1761. if (h == "4") {
  1762. return e.Res.frame.number_4()
  1763. }
  1764. if (h == "5") {
  1765. return e.Res.frame.number_5()
  1766. }
  1767. if (h == "6") {
  1768. return e.Res.frame.number_6()
  1769. }
  1770. if (h == "7") {
  1771. return e.Res.frame.number_7()
  1772. }
  1773. if (h == "8") {
  1774. return e.Res.frame.number_8()
  1775. }
  1776. if (h == "9") {
  1777. return e.Res.frame.number_9()
  1778. }
  1779. };
  1780. f.prototype.showButtons = function() {
  1781. this._playAgainButton = e.Res.frame.button_playagain();
  1782. this._playAgainButton.position.x = (320 - this._playAgainButton.width) >> 1;
  1783. this._playAgainButton.position.y = 300;
  1784. this._playAgainButton.alpha = 0;
  1785. this._playAgainRect = new PIXI.Rectangle(this._playAgainButton.position.x, this._playAgainButton.position.y, this._playAgainButton.width, this._playAgainButton.height);
  1786. this._moreGamesButton = e.Res.frame.button_moregames();
  1787. this._moreGamesButton.position.x = (320 - this._moreGamesButton.width) >> 1;
  1788. this._moreGamesButton.position.y = 320;
  1789. this._moreGamesButton.alpha = 0;
  1790. this._moreGamesRect = new PIXI.Rectangle(this._moreGamesButton.position.x, 350, this._moreGamesButton.width, this._moreGamesButton.height);
  1791. this._gameOverContainer.addChild(this._moreGamesButton);
  1792. this._gameOverContainer.addChild(this._playAgainButton);
  1793. var h = this;
  1794. this._tween = new TWEEN.Tween({alpha: 0}).to({alpha: 1}, 200).easing(TWEEN.Easing.Linear.None).onUpdate(function() {
  1795. if (h._playAgainButton) {
  1796. h._playAgainButton.alpha = this.alpha
  1797. }
  1798. }).start();
  1799. var i = new TWEEN.Tween({alpha: 0,y: 320}).to({alpha: 1,y: 350}, 200).delay(100).easing(TWEEN.Easing.Back.Out).onUpdate(function() {
  1800. if (h._moreGamesButton) {
  1801. h._moreGamesButton.alpha = this.alpha;
  1802. h._moreGamesButton.position.y = this.y
  1803. }
  1804. }).onComplete(h.dispatchButtonReadyEvent).start()
  1805. };
  1806. f.prototype.dispatchButtonReadyEvent = function() {
  1807. this.dispatchEvent(new e.GameEvent(e.GameEvent.GAME_OVER_BUTTON_READY))
  1808. };
  1809. f.prototype.setPlayAgainButtonState = function(h) {
  1810. if (h == 1) {
  1811. this._playAgainButton.position.y += 2;
  1812. e.SoundManager.playSFX(e.SFXType.CLICK)
  1813. } else {
  1814. if (h == 2) {
  1815. this._playAgainButton.position.y -= 2
  1816. }
  1817. }
  1818. };
  1819. f.prototype.setMoreGamesButtonState = function(h) {
  1820. if (h == 1) {
  1821. this._moreGamesButton.position.y += 2;
  1822. e.SoundManager.playSFX(e.SFXType.CLICK)
  1823. } else {
  1824. if (h == 2) {
  1825. this._moreGamesButton.position.y -= 2
  1826. }
  1827. }
  1828. };
  1829. Object.defineProperty(f.prototype, "playAgainRect", {get: function() {
  1830. return this._playAgainRect
  1831. },enumerable: true,configurable: true});
  1832. Object.defineProperty(f.prototype, "moreGamesRect", {get: function() {
  1833. return this._moreGamesRect
  1834. },enumerable: true,configurable: true});
  1835. f.prototype.update = function(h) {
  1836. };
  1837. f.prototype.dispose = function() {
  1838. if (this._tween) {
  1839. this._tween.stop();
  1840. this._tween = null
  1841. }
  1842. if (this._gameOverContainer) {
  1843. e.DisplayObjectUtils.removeAllChildren(this._gameOverContainer);
  1844. e.DisplayObjectUtils.removeFromParent(this._gameOverContainer);
  1845. this._gameOverContainer = null
  1846. }
  1847. this._gameOverText = null;
  1848. this._scorePanelGfx = null;
  1849. this._playAgainButton = null;
  1850. this._playAgainRect = null;
  1851. this._moreGamesButton = null;
  1852. this._moreGamesRect = null
  1853. };
  1854. return f
  1855. })(PIXI.EventTarget);
  1856. e.GameOverScreen = c;
  1857. var d = (function(g) {
  1858. __extends(f, g);
  1859. function f(l) {
  1860. g.call(this);
  1861. var j = new PIXI.DisplayObjectContainer();
  1862. var h = 0;
  1863. for (var k = l.length - 1; k >= 0; k--) {
  1864. var m = c.getScoreText(l.charAt(k));
  1865. m.position.x = h - m.width;
  1866. j.addChild(m);
  1867. h -= m.width - 5
  1868. }
  1869. this.addChild(j)
  1870. }
  1871. return f
  1872. })(PIXI.DisplayObjectContainer);
  1873. e.ScoreText = d
  1874. })(a.goldenratio || (a.goldenratio = {}));
  1875. var b = a.goldenratio
  1876. })(com || (com = {}));
  1877. var com;
  1878. (function(a) {
  1879. (function(d) {
  1880. var c = (function() {
  1881. function e(j, k) {
  1882. this._list = [];
  1883. this._listBG = [];
  1884. this._lifeLeft = 5;
  1885. this._container = j;
  1886. this._lifeLeft = k;
  1887. var h = 12;
  1888. var f = 14;
  1889. var m;
  1890. for (m = 0; m < this._lifeLeft; m++) {
  1891. var l = d.Res.frame.egg_nolife();
  1892. l.scale.x = 0.6;
  1893. l.scale.y = 0.6;
  1894. l.anchor.x = 0.5;
  1895. l.anchor.y = 0.5;
  1896. l.position.x = h;
  1897. l.position.y = f;
  1898. l.visible = false;
  1899. j.addChild(l);
  1900. this._listBG.push(l);
  1901. h += l.width + 3;
  1902. if ((m + 1) % 5 == 0) {
  1903. h = 12;
  1904. f += 21
  1905. }
  1906. }
  1907. h = 12;
  1908. f = 14;
  1909. for (m = 0; m < this._lifeLeft; m++) {
  1910. var g = d.Res.frame.egg_life();
  1911. g.scale.x = 0.6;
  1912. g.scale.y = 0.6;
  1913. g.anchor.x = 0.5;
  1914. g.anchor.y = 0.5;
  1915. g.position.x = h;
  1916. g.position.y = f;
  1917. j.addChild(g);
  1918. h += g.width + 3;
  1919. this._list.push(g);
  1920. if ((m + 1) % 5 == 0) {
  1921. h = 12;
  1922. f += 21
  1923. }
  1924. }
  1925. }
  1926. e.prototype.reduceLife = function() {
  1927. this._lifeLeft -= 1;
  1928. var f = this._list[this._lifeLeft];
  1929. if (f) {
  1930. this._listBG[this._lifeLeft].visible = true;
  1931. this._tween = new TWEEN.Tween({scaleValue: f.scale.x}).to({scaleValue: 0}, 200).easing(TWEEN.Easing.Quadratic.Out).onUpdate(function() {
  1932. if (f) {
  1933. f.scale.x = this.scaleValue;
  1934. f.scale.y = this.scaleValue
  1935. }
  1936. }).onComplete(function() {
  1937. f.visible = false
  1938. }).start()
  1939. }
  1940. };
  1941. e.prototype.dispose = function() {
  1942. this._container = null;
  1943. this._tween = null;
  1944. if (this._list) {
  1945. d.DisplayObjectUtils.removeList(this._list);
  1946. this._list = null
  1947. }
  1948. if (this._listBG) {
  1949. d.DisplayObjectUtils.removeList(this._listBG);
  1950. this._listBG = null
  1951. }
  1952. };
  1953. return e
  1954. })();
  1955. d.LifeLeftDisplay = c
  1956. })(a.goldenratio || (a.goldenratio = {}));
  1957. var b = a.goldenratio
  1958. })(com || (com = {}));
  1959. var com;
  1960. (function(a) {
  1961. (function(d) {
  1962. var c = (function() {
  1963. function e(f) {
  1964. this._container = f;
  1965. this._scoreContainer = new PIXI.DisplayObjectContainer();
  1966. this._container.addChild(this._scoreContainer)
  1967. }
  1968. e.getScoreText = function(f) {
  1969. if (f == "0") {
  1970. return d.Res.frame.text_0()
  1971. }
  1972. if (f == "1") {
  1973. return d.Res.frame.text_1()
  1974. }
  1975. if (f == "2") {
  1976. return d.Res.frame.text_2()
  1977. }
  1978. if (f == "3") {
  1979. return d.Res.frame.text_3()
  1980. }
  1981. if (f == "4") {
  1982. return d.Res.frame.text_4()
  1983. }
  1984. if (f == "5") {
  1985. return d.Res.frame.text_5()
  1986. }
  1987. if (f == "6") {
  1988. return d.Res.frame.text_6()
  1989. }
  1990. if (f == "7") {
  1991. return d.Res.frame.text_7()
  1992. }
  1993. if (f == "8") {
  1994. return d.Res.frame.text_8()
  1995. }
  1996. if (f == "9") {
  1997. return d.Res.frame.text_9()
  1998. }
  1999. };
  2000. e.prototype.setScore = function(k) {
  2001. d.DisplayObjectUtils.removeAllChildren(this._scoreContainer);
  2002. var j = k.toString();
  2003. var g = 0;
  2004. for (var h = 0; h < j.length; h++) {
  2005. var f = e.getScoreText(j.charAt(h));
  2006. f.scale.x = 0.5;
  2007. f.scale.y = 0.5;
  2008. f.position.x = g;
  2009. this._scoreContainer.addChild(f);
  2010. g += f.width - 6
  2011. }
  2012. this._scoreContainer.position.x = (320 - g + 6) >> 1;
  2013. this._scoreContainer.position.y = -4
  2014. };
  2015. e.prototype.hide = function() {
  2016. var f = this;
  2017. this._tween = new TWEEN.Tween({alpha: 1}).to({alpha: 0}, 200).easing(TWEEN.Easing.Linear.None).onUpdate(function() {
  2018. if (f._scoreContainer) {
  2019. f._scoreContainer.alpha = this.alpha
  2020. }
  2021. }).start()
  2022. };
  2023. e.prototype.dispose = function() {
  2024. this._container = null;
  2025. if (this._tween) {
  2026. this._tween.stop();
  2027. this._tween = null
  2028. }
  2029. if (this._scoreContainer) {
  2030. d.DisplayObjectUtils.removeAllChildren(this._scoreContainer);
  2031. d.DisplayObjectUtils.removeFromParent(this._scoreContainer);
  2032. this._scoreContainer = null
  2033. }
  2034. };
  2035. return e
  2036. })();
  2037. d.ScoreDisplay = c
  2038. })(a.goldenratio || (a.goldenratio = {}));
  2039. var b = a.goldenratio
  2040. })(com || (com = {}));
  2041. var com;
  2042. (function(a) {
  2043. (function(d) {
  2044. var c = (function() {
  2045. function e(f) {
  2046. this._onState = true;
  2047. this._container = f;
  2048. this._soundOn = d.Res.frame.volume_on();
  2049. this._soundOn.scale.x = 0.5;
  2050. this._soundOn.scale.y = 0.5;
  2051. this._soundOn.position.x = 320 - this._soundOn.width - 4;
  2052. this._soundOn.position.y = 2;
  2053. this._soundOn.visible = false;
  2054. this._container.addChild(this._soundOn);
  2055. this._soundRect = new PIXI.Rectangle(this._soundOn.position.x, this._soundOn.position.y, this._soundOn.width, this._soundOn.height);
  2056. this._soundOff = d.Res.frame.volume_off();
  2057. this._soundOff.scale.x = 0.5;
  2058. this._soundOff.scale.y = 0.5;
  2059. this._soundOff.position.x = 320 - this._soundOff.width - 4;
  2060. this._soundOff.position.y = 2;
  2061. this._soundOff.visible = false;
  2062. this._container.addChild(this._soundOff);
  2063. var g = d.LocalStorageUtils.getBoolean(d.LocalKey.SOUND_KEY, true);
  2064. d.SoundManager.setUserMute(!g);
  2065. this.setSoundOn(g)
  2066. }
  2067. e.prototype.setSoundOn = function(f) {
  2068. this._onState = f;
  2069. this.update()
  2070. };
  2071. e.prototype.toggleSound = function() {
  2072. this._onState = !this._onState;
  2073. d.SoundManager.setUserMute(!this._onState);
  2074. d.LocalStorageUtils.save(d.LocalKey.SOUND_KEY, this._onState.toString());
  2075. this.update()
  2076. };
  2077. e.prototype.buttonDown = function() {
  2078. this._soundOn.position.y += 2;
  2079. this._soundOff.position.y += 2;
  2080. d.SoundManager.playSFX(d.SFXType.CLICK)
  2081. };
  2082. e.prototype.buttonUp = function() {
  2083. this._soundOn.position.y -= 2;
  2084. this._soundOff.position.y -= 2
  2085. };
  2086. e.prototype.update = function() {
  2087. this.clear();
  2088. if (this._onState) {
  2089. this._soundOn.visible = true
  2090. } else {
  2091. this._soundOff.visible = true
  2092. }
  2093. };
  2094. e.prototype.clear = function() {
  2095. this._soundOff.visible = false;
  2096. this._soundOn.visible = false
  2097. };
  2098. Object.defineProperty(e.prototype, "soundRect", {get: function() {
  2099. return this._soundRect
  2100. },enumerable: true,configurable: true});
  2101. Object.defineProperty(e.prototype, "onState", {get: function() {
  2102. return this._onState
  2103. },enumerable: true,configurable: true});
  2104. e.prototype.dispose = function() {
  2105. this._container = null;
  2106. this._soundRect = null;
  2107. if (this._soundOn) {
  2108. d.DisplayObjectUtils.removeFromParent(this._soundOn);
  2109. this._soundOn = null
  2110. }
  2111. if (this._soundOff) {
  2112. d.DisplayObjectUtils.removeFromParent(this._soundOff);
  2113. this._soundOff = null
  2114. }
  2115. };
  2116. return e
  2117. })();
  2118. d.SoundButtonDisplay = c
  2119. })(a.goldenratio || (a.goldenratio = {}));
  2120. var b = a.goldenratio
  2121. })(com || (com = {}));
  2122. var com;
  2123. (function(a) {
  2124. (function(d) {
  2125. var c = (function() {
  2126. function e(f) {
  2127. this._tapContainer = new PIXI.DisplayObjectContainer();
  2128. f.addChild(this._tapContainer);
  2129. this.dispose = this.dispose.bind(this)
  2130. }
  2131. e.prototype.show = function() {
  2132. var h = d.Res.frame.tap_right();
  2133. h.scale.x = 0.6;
  2134. h.scale.y = 0.6;
  2135. h.position.x = 200;
  2136. h.position.y = 400;
  2137. var g = d.Res.frame.tap_left();
  2138. g.scale.x = 0.6;
  2139. g.scale.y = 0.6;
  2140. g.position.x = 40;
  2141. g.position.y = 400;
  2142. this._tapContainer.addChild(g);
  2143. this._tapContainer.addChild(h);
  2144. var f = new PIXI.MovieClip([PIXI.Texture.fromFrame(d.Res.frame.id_tap_hand_01), PIXI.Texture.fromFrame(d.Res.frame.id_tap_hand_02)]);
  2145. f.loop = true;
  2146. f.animationSpeed = 0.05;
  2147. f.gotoAndPlay(0);
  2148. f.scale.x = 0.6;
  2149. f.scale.y = 0.6;
  2150. f.position.x = 125;
  2151. f.position.y = 410;
  2152. this._tapContainer.addChild(f)
  2153. };
  2154. e.prototype.hide = function() {
  2155. var f = this;
  2156. this._tween = new TWEEN.Tween({alpha: 1}).to({alpha: 0}, 200).easing(TWEEN.Easing.Linear.None).onUpdate(function() {
  2157. if (f._tapContainer) {
  2158. f._tapContainer.alpha = this.alpha
  2159. }
  2160. }).onComplete(f.dispose).start()
  2161. };
  2162. e.prototype.dispose = function() {
  2163. if (this._tapContainer) {
  2164. d.DisplayObjectUtils.removeAllChildren(this._tapContainer);
  2165. d.DisplayObjectUtils.removeFromParent(this._tapContainer);
  2166. this._tapContainer = null
  2167. }
  2168. };
  2169. return e
  2170. })();
  2171. d.TapInfo = c
  2172. })(a.goldenratio || (a.goldenratio = {}));
  2173. var b = a.goldenratio
  2174. })(com || (com = {}));
  2175. var com;
  2176. (function(a) {
  2177. (function(d) {
  2178. var c = (function(e) {
  2179. __extends(f, e);
  2180. function f(g) {
  2181. e.call(this);
  2182. this._transitionContainer = new PIXI.DisplayObjectContainer();
  2183. g.addChild(this._transitionContainer);
  2184. this.clear = this.clear.bind(this)
  2185. }
  2186. f.prototype.showScreen = function() {
  2187. this._gfx = d.Res.frame.trans();
  2188. this._gfx.position.x = -320;
  2189. this._transitionContainer.addChild(this._gfx);
  2190. var g = this;
  2191. this._tween = new TWEEN.Tween({x: -320}).to({x: -960}, 500).easing(TWEEN.Easing.Quadratic.In).onUpdate(function() {
  2192. if (g._gfx) {
  2193. g._gfx.position.x = this.x
  2194. }
  2195. }).onComplete(function() {
  2196. g.dispatchEvent(new d.GameEvent(d.GameEvent.SCREEN_TRANSITION_SHOW_SCREEN))
  2197. }).start()
  2198. };
  2199. f.prototype.clear = function() {
  2200. d.DisplayObjectUtils.removeAllChildren(this._transitionContainer);
  2201. this._gfx = null
  2202. };
  2203. f.prototype.hideScreen = function() {
  2204. this._gfx = d.Res.frame.trans();
  2205. this._gfx.position.x = 320;
  2206. this._transitionContainer.addChild(this._gfx);
  2207. var g = this;
  2208. this._tween = new TWEEN.Tween({x: 320}).to({x: -320}, 500).easing(TWEEN.Easing.Quadratic.Out).onUpdate(function() {
  2209. if (g._gfx) {
  2210. g._gfx.position.x = this.x
  2211. }
  2212. }).onComplete(function() {
  2213. g.dispatchEvent(new d.GameEvent(d.GameEvent.SCREEN_TRANSITION_HIDE_SCREEN))
  2214. }).start()
  2215. };
  2216. f.prototype.dispose = function() {
  2217. if (this._tween) {
  2218. this._tween = null
  2219. }
  2220. if (this._transitionContainer) {
  2221. d.DisplayObjectUtils.removeAllChildren(this._transitionContainer);
  2222. this._transitionContainer = null
  2223. }
  2224. this._gfx = null
  2225. };
  2226. return f
  2227. })(PIXI.EventTarget);
  2228. d.ScreenTransition = c
  2229. })(a.goldenratio || (a.goldenratio = {}));
  2230. var b = a.goldenratio
  2231. })(com || (com = {}));
  2232. var com;
  2233. (function(a) {
  2234. (function(d) {
  2235. var c = (function() {
  2236. function e(f) {
  2237. this._stage = f;
  2238. this.mapBinds();
  2239. this.init()
  2240. }
  2241. e.prototype.resetProperties = function() {
  2242. this._landBasketCount = 0;
  2243. this._lifesLeft = 3;
  2244. this._scoreValue = 0;
  2245. this._canEggJump = false;
  2246. this._showTapInfo = true;
  2247. this._isGamePaused = false;
  2248. this._isGameOver = false
  2249. };
  2250. e.prototype.init = function() {
  2251. this.resetProperties();
  2252. this._backgroundContainer = new PIXI.DisplayObjectContainer();
  2253. this._stage.addChild(this._backgroundContainer);
  2254. this._container = new PIXI.DisplayObjectContainer();
  2255. this._container.position.x = 0;
  2256. this._container.position.y = 460;
  2257. this._stage.addChild(this._container);
  2258. this._overlayContainer = new PIXI.DisplayObjectContainer();
  2259. this._stage.addChild(this._overlayContainer);
  2260. this._pauseContainer = new PIXI.DisplayObjectContainer();
  2261. this._stage.addChild(this._pauseContainer);
  2262. this.createBackground();
  2263. this.createEgg();
  2264. this._bucketManager = new d.BucketManager(this._container);
  2265. this._lifeLeftDisplay = new d.LifeLeftDisplay(this._backgroundContainer, this._lifesLeft);
  2266. this._scoreDisplay = new d.ScoreDisplay(this._backgroundContainer);
  2267. this._scoreDisplay.setScore(this._scoreValue);
  2268. this._soundButton = new d.SoundButtonDisplay(this._backgroundContainer);
  2269. this._inputControl = new d.InputControl();
  2270. this._inputControl.addEventListener(d.GameEvent.CANVAS_MOUSE_DOOWN, this.onCanvasMouseDownHL);
  2271. this._inputControl.addEventListener(d.GameEvent.BUTTON_DOWN, this.onInputButtonDownHL);
  2272. this._inputControl.addEventListener("ontouchstart", this.onInputButtonDownHL);
  2273. this._inputControl.addEventListener(d.GameEvent.BUTTON_UP, this.onInputButtonUpHL);
  2274. this._inputControl.addEventListener("ontouchend", this.onInputButtonUpHL);
  2275. this._inputControl.setSoundButtonRect(this._soundButton.soundRect);
  2276. this._inputControl.setEnable(false);
  2277. this._pauseTextGfx = d.Res.frame.text_paused();
  2278. this._pauseTextGfx.scale.x = 0.5;
  2279. this._pauseTextGfx.scale.y = 0.5;
  2280. this._pauseTextGfx.position.x = ((320 - this._pauseTextGfx.width) >> 1) + 5;
  2281. this._pauseTextGfx.position.y = 110;
  2282. this._pauseButtonGfx = d.Res.frame.pause_play_button();
  2283. this._pauseButtonGfx.scale.x = 0.5;
  2284. this._pauseButtonGfx.scale.y = 0.5;
  2285. this._pauseButtonGfx.position.x = ((320 - this._pauseButtonGfx.width) >> 1) + 5;
  2286. this._pauseButtonGfx.position.y = 200;
  2287. this._inputControl.setPauseButtonRect(new PIXI.Rectangle(this._pauseButtonGfx.position.x, 200, this._pauseButtonGfx.width, this._pauseButtonGfx.height));
  2288. this._gameOverScreen = new d.GameOverScreen(this._overlayContainer);
  2289. this._gameOverScreen.addEventListener(d.GameEvent.GAME_OVER_BUTTON_READY, this.onGameOverButtonReady);
  2290. this._tapInfo = new d.TapInfo(this._overlayContainer);
  2291. this._screenTransition = new d.ScreenTransition(this._overlayContainer);
  2292. this._screenTransition.addEventListener(d.GameEvent.SCREEN_TRANSITION_SHOW_SCREEN, this.onScreenTransitionShowScreen);
  2293. this._screenTransition.addEventListener(d.GameEvent.SCREEN_TRANSITION_HIDE_SCREEN, this.onScreenTransitionHideScreen);
  2294. window.addEventListener("blur", this.onWindowBlurHL, false);
  2295. document.addEventListener(visibilityChange, this.handleVisiblityChange, false);
  2296. this.setCanEggJump(true);
  2297. this._egg.setBasketID(0);
  2298. this._bucketManager.updateCurrentBasket(this._egg.basketID);
  2299. this._tapInfo.show();
  2300. this._screenTransition.showScreen()
  2301. };
  2302. e.prototype.handleVisiblityChange = function(f) {
  2303. this.pauseGame();
  2304. f.stopPropagation()
  2305. };
  2306. e.prototype.onWindowBlurHL = function(f) {
  2307. this.pauseGame();
  2308. f.stopPropagation()
  2309. };
  2310. e.prototype.pauseGame = function() {
  2311. if (this._isGamePaused || this._isGameOver) {
  2312. return
  2313. }
  2314. this._isGamePaused = true;
  2315. this._pauseTextGfx.alpha = 1;
  2316. this._pauseContainer.addChild(this._pauseTextGfx);
  2317. this._pauseButtonGfx.alpha = 1;
  2318. this._pauseContainer.addChild(this._pauseButtonGfx);
  2319. this._inputControl.setGamePaused(true)
  2320. };
  2321. e.prototype.resumeGame = function() {
  2322. if (!this._isGamePaused || this._isGameOver) {
  2323. return
  2324. }
  2325. var f = this;
  2326. new TWEEN.Tween({alpha: 1}).to({alpha: 0}, 170).easing(TWEEN.Easing.Linear.None).onUpdate(function() {
  2327. if (f._pauseButtonGfx) {
  2328. f._pauseButtonGfx.alpha = this.alpha
  2329. }
  2330. if (f._pauseTextGfx) {
  2331. f._pauseTextGfx.alpha = this.alpha
  2332. }
  2333. }).onComplete(function() {
  2334. f._isGamePaused = false;
  2335. d.DisplayObjectUtils.removeAllChildren(f._pauseContainer);
  2336. f._inputControl.setGamePaused(false)
  2337. }).start()
  2338. };
  2339. e.prototype.createEgg = function() {
  2340. this._egg = new d.Egg();
  2341. this.addEggListeners();
  2342. this._egg.setPosition(0, 0);
  2343. this._container.addChild(this._egg.gfx)
  2344. };
  2345. e.prototype.addEggListeners = function() {
  2346. this._egg.addEventListener(d.GameEvent.EGG_OUTOFF_BASKET, this.onEggOutOffBasket);
  2347. this._egg.addEventListener(d.GameEvent.EGG_INSIDE_BASKET, this.onEggInsideBasket);
  2348. this._egg.addEventListener(d.GameEvent.EGG_DIED, this.onEggDieHL);
  2349. this._egg.addEventListener(d.GameEvent.GAME_OVER, this.onGameOverHL)
  2350. };
  2351. e.prototype.removeEggListeners = function() {
  2352. this._egg.removeEventListener(d.GameEvent.EGG_OUTOFF_BASKET, this.onEggOutOffBasket);
  2353. this._egg.removeEventListener(d.GameEvent.EGG_INSIDE_BASKET, this.onEggInsideBasket);
  2354. this._egg.removeEventListener(d.GameEvent.EGG_DIED, this.onEggDieHL);
  2355. this._egg.removeEventListener(d.GameEvent.GAME_OVER, this.onGameOverHL)
  2356. };
  2357. e.prototype.createBackground = function() {
  2358. var f = d.Res.frame.bg();
  2359. f.scale.x = 0.4;
  2360. f.scale.y = 0.4;
  2361. this._backgroundContainer.addChild(f)
  2362. };
  2363. e.prototype.mapBinds = function() {
  2364. this.onCanvasMouseDownHL = this.onCanvasMouseDownHL.bind(this);
  2365. this.onEggOutOffBasket = this.onEggOutOffBasket.bind(this);
  2366. this.onEggInsideBasket = this.onEggInsideBasket.bind(this);
  2367. this.onEggDieHL = this.onEggDieHL.bind(this);
  2368. this.onGameOverHL = this.onGameOverHL.bind(this);
  2369. this.onInputButtonUpHL = this.onInputButtonUpHL.bind(this);
  2370. this.onInputButtonDownHL = this.onInputButtonDownHL.bind(this);
  2371. this.onContainerScrollComplete = this.onContainerScrollComplete.bind(this);
  2372. this.onGameOverButtonReady = this.onGameOverButtonReady.bind(this);
  2373. this.onScreenTransitionShowScreen = this.onScreenTransitionShowScreen.bind(this);
  2374. this.onScreenTransitionHideScreen = this.onScreenTransitionHideScreen.bind(this);
  2375. this.onWindowBlurHL = this.onWindowBlurHL.bind(this);
  2376. this.handleVisiblityChange = this.handleVisiblityChange.bind(this)
  2377. };
  2378. e.prototype.onCanvasMouseDownHL = function(f) {
  2379. if (!this._canEggJump || !this._egg) {
  2380. return
  2381. }
  2382. if (this._showTapInfo) {
  2383. this._showTapInfo = false;
  2384. if (this._tapInfo) {
  2385. this._tapInfo.hide()
  2386. }
  2387. }
  2388. this.setCanEggJump(false);
  2389. this._canEggJump = false;
  2390. this._egg.setJump(true);
  2391. this._bucketManager.currentBasket.onEggJumpedOffBasket();
  2392. d.SoundManager.playSFX(d.SFXType.WOOD_TAP)
  2393. };
  2394. e.prototype.setCanEggJump = function(f) {
  2395. this._canEggJump = f
  2396. };
  2397. e.prototype.onInputButtonUpHL = function(f) {
  2398. if (this._inputControl.isSoundButtonPressed) {
  2399. this._soundButton.buttonUp();
  2400. this._soundButton.toggleSound()
  2401. } else {
  2402. if (this._inputControl.isPlayAgainPressed) {
  2403. this._inputControl.setEnable(false);
  2404. this._gameOverScreen.setPlayAgainButtonState(2);
  2405. this._screenTransition.hideScreen()
  2406. } else {
  2407. if (this._inputControl.isMoreGamesPressed) {
  2408. this._gameOverScreen.setMoreGamesButtonState(2);
  2409. //window.top.location.href = btGame.URL.getMoreGame();
  2410. clickMore();
  2411. } else {
  2412. if (this._inputControl.isPauseButtonPressed) {
  2413. this._pauseButtonGfx.position.y -= 2;
  2414. this.resumeGame()
  2415. }
  2416. }
  2417. }
  2418. }
  2419. };
  2420. e.prototype.onInputButtonDownHL = function(f) {
  2421. if (this._inputControl.isSoundButtonPressed) {
  2422. this._soundButton.buttonDown()
  2423. } else {
  2424. if (this._inputControl.isPlayAgainPressed) {
  2425. this._gameOverScreen.setPlayAgainButtonState(1)
  2426. } else {
  2427. if (this._inputControl.isMoreGamesPressed) {
  2428. this._gameOverScreen.setMoreGamesButtonState(1)
  2429. } else {
  2430. if (this._inputControl.isPauseButtonPressed) {
  2431. this._pauseButtonGfx.position.y += 2;
  2432. d.SoundManager.playSFX(d.SFXType.CLICK)
  2433. }
  2434. }
  2435. }
  2436. }
  2437. };
  2438. e.prototype.onEggOutOffBasket = function(f) {
  2439. if (this._bucketManager.nextBasket) {
  2440. this._container.swapChildren(this._bucketManager.nextBasket.gfx, this._egg.gfx)
  2441. }
  2442. };
  2443. e.prototype.onEggDieHL = function(f) {
  2444. this.setCanEggJump(false);
  2445. this._container.swapChildren(this._bucketManager.currentBasket.gfx, this._egg.gfx)
  2446. };
  2447. e.prototype.onGameOverHL = function(f) {
  2448. d.SoundManager.playSFX(d.SFXType.EGG_FALL);
  2449. this._lifesLeft -= 1;
  2450. this._lifeLeftDisplay.reduceLife();
  2451. if (this._lifesLeft > 0) {
  2452. this._egg.reset();
  2453. this._egg.setBasketID(this._bucketManager.currentBasket.id);
  2454. this._bucketManager.currentBasket.reset();
  2455. this._bucketManager.onEggLanded();
  2456. this._bucketManager.currentBasket.onEggLanded();
  2457. this.clearAndUpdateDisplayList();
  2458. this.setCanEggJump(true)
  2459. } else {
  2460. this.showGameOverForReal(true)
  2461. }
  2462. };
  2463. e.prototype.showGameOverForReal = function(f) {
  2464. if (this._egg && f) {
  2465. this._egg.dispose();
  2466. this.removeEggListeners();
  2467. this._egg = null
  2468. }
  2469. this._isGameOver = true;
  2470. this._scoreDisplay.hide();
  2471. this._gameOverScreen.show(this._scoreValue);
  2472. d.SoundManager.playSFX(d.SFXType.LEVEL_COMPLETE)
  2473. };
  2474. e.prototype.onScreenTransitionShowScreen = function(f) {
  2475. this._screenTransition.clear();
  2476. this._inputControl.setEnable(true)
  2477. };
  2478. e.prototype.onScreenTransitionHideScreen = function(f) {
  2479. this.clearGameArea();
  2480. this.init()
  2481. };
  2482. e.prototype.onGameOverButtonReady = function(f) {
  2483. this._inputControl.setPlayAgainRect(this._gameOverScreen.playAgainRect);
  2484. this._inputControl.setMoreGamesRect(this._gameOverScreen.moreGamesRect)
  2485. };
  2486. e.prototype.clearAndUpdateDisplayList = function() {
  2487. d.DisplayObjectUtils.removeAllChildren(this._container);
  2488. this._container.addChild(this._egg.gfx);
  2489. this._bucketManager.updateCurrentBasket(this._egg.basketID)
  2490. };
  2491. e.prototype.onEggInsideBasket = function(f) {
  2492. if (this._bucketManager.nextBasket) {
  2493. this._container.swapChildren(this._bucketManager.nextBasket.gfx, this._egg.gfx)
  2494. }
  2495. };
  2496. e.prototype.update = function(f) {
  2497. if (this._isGamePaused) {
  2498. return
  2499. }
  2500. if (this._egg && !this._egg.hasFallenOffScreen) {
  2501. this._egg.update(f, this._bucketManager.currentBasket, this._bucketManager.nextBasket, this._bucketManager.firstBasket);
  2502. if (this._egg && !this._egg.hasFallenOffScreen) {
  2503. if (this._egg.isFalling && this._egg.canLandInNextBasket && this._bucketManager.nextBasket) {
  2504. this.landOnNextBasket()
  2505. }
  2506. }
  2507. }
  2508. if (this._bucketManager && this._egg) {
  2509. this._bucketManager.update(f)
  2510. }
  2511. };
  2512. e.prototype.landOnNextBasket = function() {
  2513. this._landBasketCount++;
  2514. d.SoundManager.playSFX(d.SFXType.EGG_SUCCESS);
  2515. if (this._bucketManager.currentBasket) {
  2516. this._egg.setBasketID(this._bucketManager.nextBasket.id);
  2517. this._bucketManager.onEggLanded();
  2518. this._bucketManager.updateCurrentBasket(this._egg.basketID);
  2519. this._bucketManager.currentBasket.onEggLanded();
  2520. this.incrementScore(1);
  2521. if (this._bucketManager.nextBasket) {
  2522. if (this._landBasketCount >= 2) {
  2523. this._landBasketCount = 0;
  2524. var f = this;
  2525. this._tween = new TWEEN.Tween({y: this._container.position.y}).to({y: 460 - this._bucketManager.currentBasket.rect.y - this._bucketManager.currentBasket.rect.height - 20}, 500).easing(TWEEN.Easing.Quadratic.Out).delay(200).onUpdate(function() {
  2526. if (f._container) {
  2527. f._container.position.y = this.y
  2528. }
  2529. }).onComplete(this.onContainerScrollComplete).start()
  2530. } else {
  2531. this.setCanEggJump(true)
  2532. }
  2533. } else {
  2534. this.showGameOverForReal(false)
  2535. }
  2536. }
  2537. };
  2538. e.prototype.incrementScore = function(f) {
  2539. this._scoreValue += f;
  2540. this._scoreDisplay.setScore(this._scoreValue)
  2541. };
  2542. e.prototype.onContainerScrollComplete = function() {
  2543. this._bucketManager.onContainerScrollComplete();
  2544. this.setCanEggJump(true)
  2545. };
  2546. e.prototype.clearGameArea = function() {
  2547. window.removeEventListener("blur", this.onWindowBlurHL, false);
  2548. document.removeEventListener(visibilityChange, this.handleVisiblityChange, false);
  2549. if (this._tween) {
  2550. this._tween = null
  2551. }
  2552. if (this._bucketManager) {
  2553. this._bucketManager.dispose();
  2554. this._bucketManager = null
  2555. }
  2556. if (this._lifeLeftDisplay) {
  2557. this._lifeLeftDisplay.dispose();
  2558. this._lifeLeftDisplay = null
  2559. }
  2560. if (this._scoreDisplay) {
  2561. this._scoreDisplay.dispose();
  2562. this._scoreDisplay = null
  2563. }
  2564. if (this._soundButton) {
  2565. this._soundButton.dispose();
  2566. this._soundButton = null
  2567. }
  2568. if (this._inputControl) {
  2569. this._inputControl.removeEventListener(d.GameEvent.CANVAS_MOUSE_DOOWN, this.onCanvasMouseDownHL);
  2570. this._inputControl.removeEventListener(d.GameEvent.BUTTON_DOWN, this.onInputButtonDownHL);
  2571. this._inputControl.removeEventListener(d.GameEvent.BUTTON_UP, this.onInputButtonUpHL);
  2572. this._inputControl.dispose();
  2573. this._inputControl = null
  2574. }
  2575. if (this._egg) {
  2576. this._egg.dispose();
  2577. this._egg = null
  2578. }
  2579. if (this._gameOverScreen) {
  2580. this._gameOverScreen.removeEventListener(d.GameEvent.GAME_OVER_BUTTON_READY, this.onGameOverButtonReady);
  2581. this._gameOverScreen.dispose();
  2582. this._gameOverScreen = null
  2583. }
  2584. if (this._tapInfo) {
  2585. this._tapInfo.dispose();
  2586. this._tapInfo = null
  2587. }
  2588. if (this._screenTransition) {
  2589. this._screenTransition.removeEventListener(d.GameEvent.SCREEN_TRANSITION_SHOW_SCREEN, this.onScreenTransitionShowScreen);
  2590. this._screenTransition.removeEventListener(d.GameEvent.SCREEN_TRANSITION_HIDE_SCREEN, this.onScreenTransitionHideScreen);
  2591. this._screenTransition.dispose();
  2592. this._screenTransition = null
  2593. }
  2594. d.DisplayObjectUtils.removeAllChildren(this._container);
  2595. d.DisplayObjectUtils.removeFromParent(this._container);
  2596. this._container = null;
  2597. d.DisplayObjectUtils.removeAllChildren(this._backgroundContainer);
  2598. d.DisplayObjectUtils.removeFromParent(this._backgroundContainer);
  2599. this._backgroundContainer = null;
  2600. d.DisplayObjectUtils.removeAllChildren(this._overlayContainer);
  2601. d.DisplayObjectUtils.removeFromParent(this._overlayContainer);
  2602. this._overlayContainer = null;
  2603. d.DisplayObjectUtils.removeAllChildren(this._pauseContainer);
  2604. d.DisplayObjectUtils.removeFromParent(this._pauseContainer);
  2605. this._pauseContainer = null;
  2606. this._pauseButtonGfx = null;
  2607. this._pauseTextGfx = null
  2608. };
  2609. e.prototype.dispose = function() {
  2610. this.clearGameArea();
  2611. this._stage = null
  2612. };
  2613. return e
  2614. })();
  2615. d.GameArea = c
  2616. })(a.goldenratio || (a.goldenratio = {}));
  2617. var b = a.goldenratio
  2618. })(com || (com = {}));
  2619. var com;
  2620. (function(a) {
  2621. (function(d) {
  2622. var c = (function(f) {
  2623. __extends(e, f);
  2624. function e(g) {
  2625. f.call(this);
  2626. this.mapBinds();
  2627. this._backgroundContainer = new PIXI.DisplayObjectContainer();
  2628. g.addChild(this._backgroundContainer);
  2629. this._gfxContainer = new PIXI.DisplayObjectContainer();
  2630. g.addChild(this._gfxContainer);
  2631. this._overlayContainer = new PIXI.DisplayObjectContainer();
  2632. g.addChild(this._overlayContainer);
  2633. this.createBackground();
  2634. this.createTitleGfx(false);
  2635. var h = d.Res.frame.labrat_copyright();
  2636. h.position.x = 5;
  2637. h.position.y = 445;
  2638. this._backgroundContainer.addChild(h);
  2639. this._soundButton = new d.SoundButtonDisplay(this._backgroundContainer);
  2640. this._inputControl = new d.InputControl();
  2641. this._inputControl.addEventListener(d.GameEvent.BUTTON_DOWN, this.onInputButtonDownHL);
  2642. this._inputControl.addEventListener(d.GameEvent.BUTTON_UP, this.onInputButtonUpHL);
  2643. this._inputControl.setEnable(false);
  2644. this._inputControl.setSoundButtonRect(this._soundButton.soundRect);
  2645. this.createAndShowButtons(false);
  2646. this._screenTransition = new d.ScreenTransition(this._overlayContainer);
  2647. this._screenTransition.addEventListener(d.GameEvent.SCREEN_TRANSITION_SHOW_SCREEN, this.onScreenTransitionShowScreen);
  2648. this._screenTransition.addEventListener(d.GameEvent.SCREEN_TRANSITION_HIDE_SCREEN, this.onScreenTransitionHideScreen);
  2649. this._screenTransition.showScreen()
  2650. }
  2651. e.prototype.mapBinds = function() {
  2652. this.onScreenTransitionShowScreen = this.onScreenTransitionShowScreen.bind(this);
  2653. this.onScreenTransitionHideScreen = this.onScreenTransitionHideScreen.bind(this);
  2654. this.onInputButtonUpHL = this.onInputButtonUpHL.bind(this);
  2655. this.onInputButtonDownHL = this.onInputButtonDownHL.bind(this);
  2656. this.showCreditsPanel = this.showCreditsPanel.bind(this);
  2657. this.showCreditsMainMenuButton = this.showCreditsMainMenuButton.bind(this);
  2658. this.showCreditsDone = this.showCreditsDone.bind(this);
  2659. this.clearCreditsScreen = this.clearCreditsScreen.bind(this)
  2660. };
  2661. e.prototype.createBackground = function() {
  2662. var g = d.Res.frame.bg();
  2663. g.scale.x = 0.4;
  2664. g.scale.y = 0.4;
  2665. this._backgroundContainer.addChild(g)
  2666. };
  2667. e.prototype.createTitleGfx = function(h) {
  2668. this._titleGfx = d.Res.frame.egg_title();
  2669. this._titleGfx.scale.x = 0.5;
  2670. this._titleGfx.scale.y = 0.5;
  2671. this._titleGfx.position.x = 17;
  2672. this._titleGfx.position.y = 50;
  2673. if (h) {
  2674. this._titleGfx.alpha = 0
  2675. }
  2676. this._gfxContainer.addChild(this._titleGfx);
  2677. if (h) {
  2678. var g = this;
  2679. new TWEEN.Tween({alpha: 0}).to({alpha: 1}, 170).easing(TWEEN.Easing.Linear.None).onUpdate(function() {
  2680. if (g._titleGfx) {
  2681. g._titleGfx.alpha = this.alpha
  2682. }
  2683. }).start()
  2684. }
  2685. };
  2686. e.prototype.createAndShowButtons = function(h) {
  2687. this._playButton = d.Res.frame.button_startgame();
  2688. this._playButton.position.x = 79;
  2689. this._playButton.position.y = 305;
  2690. if (h) {
  2691. this._playButton.alpha = 0
  2692. }
  2693. this._gfxContainer.addChild(this._playButton);
  2694. this._creditsButton = d.Res.frame.button_credits();
  2695. this._creditsButton.position.x = 79;
  2696. this._creditsButton.position.y = 370;
  2697. if (h) {
  2698. this._creditsButton.position.y = 315;
  2699. this._creditsButton.alpha = 0
  2700. }
  2701. this._gfxContainer.addChild(this._creditsButton);
  2702. this._playButtonRect = new PIXI.Rectangle(79, 305, this._playButton.width, this._playButton.height);
  2703. this._creditButtonRect = new PIXI.Rectangle(79, 370, this._creditsButton.width, this._creditsButton.height);
  2704. this._inputControl.setStartGameRect(this._playButtonRect);
  2705. this._inputControl.setCreditsRect(this._creditButtonRect);
  2706. if (h) {
  2707. var g = this;
  2708. new TWEEN.Tween({alpha: 0}).to({alpha: 1}, 200).delay(150).easing(TWEEN.Easing.Linear.None).onUpdate(function() {
  2709. if (g._playButton) {
  2710. g._playButton.alpha = this.alpha
  2711. }
  2712. }).start();
  2713. new TWEEN.Tween({y: 315,alpha: 0}).to({y: 370,alpha: 1}, 200).delay(180).easing(TWEEN.Easing.Back.InOut).onUpdate(function() {
  2714. if (g._creditsButton) {
  2715. g._creditsButton.position.y = this.y;
  2716. g._creditsButton.alpha = this.alpha
  2717. }
  2718. }).onComplete(function() {
  2719. g._inputControl.setEnable(true)
  2720. }).start()
  2721. }
  2722. };
  2723. e.prototype.onInputButtonDownHL = function(g) {
  2724. if (this._inputControl.isSoundButtonPressed) {
  2725. this._soundButton.buttonDown()
  2726. } else {
  2727. if (this._inputControl.isStartGamePressed) {
  2728. this._playButton.position.y += 2;
  2729. d.SoundManager.playSFX(d.SFXType.CLICK)
  2730. } else {
  2731. if (this._inputControl.isCreditPressed) {
  2732. this._creditsButton.position.y += 2;
  2733. d.SoundManager.playSFX(d.SFXType.CLICK)
  2734. } else {
  2735. if (this._inputControl.isMainMenuPressed) {
  2736. this._mainMenuButton.position.y += 2;
  2737. d.SoundManager.playSFX(d.SFXType.CLICK)
  2738. }
  2739. }
  2740. }
  2741. }
  2742. };
  2743. e.prototype.onInputButtonUpHL = function(g) {
  2744. if (this._inputControl.isSoundButtonPressed) {
  2745. this._soundButton.buttonUp();
  2746. this._soundButton.toggleSound()
  2747. } else {
  2748. if (this._inputControl.isStartGamePressed) {
  2749. this._playButton.position.y -= 2;
  2750. this.startGame()
  2751. } else {
  2752. if (this._inputControl.isCreditPressed) {
  2753. this._creditsButton.position.y -= 2;
  2754. // this.hideTitle()
  2755. window.top.location.href = btGame.URL.getMoreGame();
  2756. } else {
  2757. if (this._inputControl.isMainMenuPressed) {
  2758. this._mainMenuButton.position.y -= 2;
  2759. this.hideCreditsScreen()
  2760. }
  2761. }
  2762. }
  2763. }
  2764. };
  2765. e.prototype.startGame = function() {
  2766. this._inputControl.setEnable(false);
  2767. this._screenTransition.hideScreen()
  2768. };
  2769. e.prototype.hideTitle = function() {
  2770. this._inputControl.setEnable(false);
  2771. var g = this;
  2772. new TWEEN.Tween({alpha: 1}).to({alpha: 0}, 170).easing(TWEEN.Easing.Linear.None).onUpdate(function() {
  2773. if (g._titleGfx) {
  2774. g._titleGfx.alpha = this.alpha
  2775. }
  2776. }).start();
  2777. new TWEEN.Tween({x: 79,x2: 79}).to({x: -160,x2: 430}, 200).easing(TWEEN.Easing.Quadratic.Out).onUpdate(function() {
  2778. if (g._playButton) {
  2779. g._playButton.position.x = this.x
  2780. }
  2781. if (g._creditsButton) {
  2782. g._creditsButton.position.x = this.x2
  2783. }
  2784. }).onComplete(g.showCreditsPanel).start()
  2785. };
  2786. e.prototype.clearTitleScreen = function() {
  2787. d.DisplayObjectUtils.removeAllChildren(this._gfxContainer);
  2788. this._titleGfx = null;
  2789. this._playButton = null;
  2790. this._creditsButton = null;
  2791. this._creditButtonRect = null;
  2792. this._playButtonRect = null;
  2793. this._inputControl.setStartGameRect(null);
  2794. this._inputControl.setCreditsRect(null)
  2795. };
  2796. e.prototype.showCreditsPanel = function() {
  2797. this.clearTitleScreen();
  2798. this._creditsPanelGfx = d.Res.frame.credits_panel();
  2799. this._creditsPanelGfx.position.x = 24;
  2800. this._creditsPanelGfx.position.y = 90;
  2801. this._creditsPanelGfx.alpha = 0;
  2802. this._gfxContainer.addChild(this._creditsPanelGfx);
  2803. var g = this;
  2804. new TWEEN.Tween({y: 400,alpha: 0}).to({y: 90,alpha: 1}, 800).easing(TWEEN.Easing.Back.InOut).onUpdate(function() {
  2805. if (g._creditsPanelGfx) {
  2806. g._creditsPanelGfx.position.y = this.y;
  2807. g._creditsPanelGfx.alpha = this.alpha
  2808. }
  2809. }).onComplete(g.showCreditsMainMenuButton).start()
  2810. };
  2811. e.prototype.showCreditsMainMenuButton = function() {
  2812. this._mainMenuButton = d.Res.frame.button_mainmenu();
  2813. this._mainMenuButton.position.x = 79;
  2814. this._mainMenuButton.position.y = 335;
  2815. this._mainMenuButton.alpha = 0;
  2816. this._gfxContainer.addChild(this._mainMenuButton);
  2817. this._mainMenuButtonRect = new PIXI.Rectangle(79, 335, this._mainMenuButton.width, this._mainMenuButton.height);
  2818. var g = this;
  2819. new TWEEN.Tween({y: 290,alpha: 0}).to({y: 335,alpha: 1}, 200).easing(TWEEN.Easing.Quadratic.Out).onUpdate(function() {
  2820. if (g._mainMenuButton) {
  2821. g._mainMenuButton.position.y = this.y;
  2822. g._mainMenuButton.alpha = this.alpha
  2823. }
  2824. }).onComplete(g.showCreditsDone).start()
  2825. };
  2826. e.prototype.hideCreditsScreen = function() {
  2827. this._inputControl.setEnable(false);
  2828. var g = this;
  2829. new TWEEN.Tween({alpha: 1}).to({alpha: 0}, 170).easing(TWEEN.Easing.Linear.None).onUpdate(function() {
  2830. if (g._creditsPanelGfx) {
  2831. g._creditsPanelGfx.alpha = this.alpha
  2832. }
  2833. if (g._mainMenuButton) {
  2834. g._mainMenuButton.alpha = this.alpha
  2835. }
  2836. }).onComplete(g.clearCreditsScreen).start()
  2837. };
  2838. e.prototype.clearCreditsScreen = function() {
  2839. d.DisplayObjectUtils.removeAllChildren(this._gfxContainer);
  2840. this._mainMenuButton = null;
  2841. this._mainMenuButtonRect = null;
  2842. this._creditsPanelGfx = null;
  2843. this._inputControl.setMainMenuRect(null);
  2844. this.createTitleGfx(true);
  2845. this.createAndShowButtons(true)
  2846. };
  2847. e.prototype.showCreditsDone = function() {
  2848. this._inputControl.setMainMenuRect(this._mainMenuButtonRect);
  2849. this._inputControl.setEnable(true)
  2850. };
  2851. e.prototype.onScreenTransitionShowScreen = function(g) {
  2852. this._screenTransition.clear();
  2853. this._inputControl.setEnable(true)
  2854. };
  2855. e.prototype.onScreenTransitionHideScreen = function(g) {
  2856. this.dispatchEvent(new d.GameEvent(d.GameEvent.START_GAME))
  2857. };
  2858. e.prototype.update = function(g) {
  2859. };
  2860. e.prototype.dispose = function() {
  2861. if (this._screenTransition) {
  2862. this._screenTransition.dispose();
  2863. this._screenTransition = null
  2864. }
  2865. if (this._inputControl) {
  2866. this._inputControl.dispose();
  2867. this._inputControl = null
  2868. }
  2869. if (this._soundButton) {
  2870. this._soundButton.dispose();
  2871. this._soundButton = null
  2872. }
  2873. if (this._backgroundContainer) {
  2874. d.DisplayObjectUtils.removeAllChildren(this._backgroundContainer);
  2875. d.DisplayObjectUtils.removeFromParent(this._backgroundContainer);
  2876. this._backgroundContainer = null
  2877. }
  2878. if (this._overlayContainer) {
  2879. d.DisplayObjectUtils.removeAllChildren(this._overlayContainer);
  2880. d.DisplayObjectUtils.removeFromParent(this._overlayContainer);
  2881. this._overlayContainer = null
  2882. }
  2883. if (this._gfxContainer) {
  2884. d.DisplayObjectUtils.removeAllChildren(this._gfxContainer);
  2885. d.DisplayObjectUtils.removeFromParent(this._gfxContainer);
  2886. this._gfxContainer = null
  2887. }
  2888. this._titleGfx = null;
  2889. this._creditsPanelGfx = null;
  2890. this._playButton = null;
  2891. this._playButtonRect = null;
  2892. this._creditButtonRect = null;
  2893. this._creditsButton = null;
  2894. this._mainMenuButton = null;
  2895. this._mainMenuButtonRect = null
  2896. };
  2897. return e
  2898. })(PIXI.EventTarget);
  2899. d.TitleScreen = c
  2900. })(a.goldenratio || (a.goldenratio = {}));
  2901. var b = a.goldenratio
  2902. })(com || (com = {}));
  2903. var com;
  2904. (function(a) {
  2905. (function(d) {
  2906. var c = (function() {
  2907. function e(f) {
  2908. this.type = f
  2909. }
  2910. e.SCRIPT = new e("script");
  2911. e.GRAPHICS = new e("graphics");
  2912. e.SFX = new e("sfx");
  2913. return e
  2914. })();
  2915. d.LoadingState = c
  2916. })(a.goldenratio || (a.goldenratio = {}));
  2917. var b = a.goldenratio
  2918. })(com || (com = {}));
  2919. var com;
  2920. (function(a) {
  2921. (function(e) {
  2922. var d = (function() {
  2923. function f() {
  2924. this._rafDelta = new c();
  2925. this._gameRect = new PIXI.Rectangle(0, 0, f.GAME_DIMENSION.width, f.GAME_DIMENSION.height);
  2926. this._gameRectDesktop = new PIXI.Rectangle(0, 0, 400, 575);
  2927. isMobileDevice = e.DeviceUtils.isMobileDevice();
  2928. if (isMobileDevice) {
  2929. this.resizeGameForMobile()
  2930. } else {
  2931. this.resizeGameForDesktop()
  2932. }
  2933. this.mapBinds();
  2934. window.addEventListener("resize", this.onResizeWindowHandler, false);
  2935. window.addEventListener("orientationchange", this.onOrientationChangeHandler, false);
  2936. document.addEventListener("fullscreenchange", this.onFullscreenChangeHL, false);
  2937. document.addEventListener("mozfullscreenchange", this.onFullscreenChangeHL, false);
  2938. document.addEventListener("webkitfullscreenchange", this.onFullscreenChangeHL, false);
  2939. document.addEventListener("msfullscreenchange", this.onFullscreenChangeHL, false);
  2940. e.SoundManager.event.addEventListener(e.GameEvent.SOUND_LOADED, this.onSoundLoadComplete);
  2941. e.SoundManager.event.addEventListener(e.GameEvent.SOUND_ERROR, this.onSoundLoadComplete);
  2942. this._loader = new e.LoaderScreen();
  2943. this._loader.addEventListener(e.GameEvent.LAUNCH_GAME, this.onLaunchGameHL);
  2944. this._loader.updateViewPort(this._gameRect.width, this._gameRect.height);
  2945. this.updateLoadingTextState(e.LoadingState.GRAPHICS);
  2946. this._assetLoader = new PIXI.AssetLoader(["js/70/data.json"]);
  2947. this._assetLoader.addEventListener("onComplete", this.onAssetsLoadComplete);
  2948. this._assetLoader.load()
  2949. }
  2950. f.prototype.mapBinds = function() {
  2951. this.onAssetsLoadComplete = this.onAssetsLoadComplete.bind(this);
  2952. this.onOrientationChangeHandler = this.onOrientationChangeHandler.bind(this);
  2953. this.onResizeWindowHandler = this.onResizeWindowHandler.bind(this);
  2954. this.update = this.update.bind(this);
  2955. this.onFullscreenChangeHL = this.onFullscreenChangeHL.bind(this);
  2956. this.onLaunchGameHL = this.onLaunchGameHL.bind(this);
  2957. this.launchStartGameFromTitle = this.launchStartGameFromTitle.bind(this);
  2958. this.onSoundLoadComplete = this.onSoundLoadComplete.bind(this)
  2959. };
  2960. f.prototype.onFullscreenChangeHL = function(g) {
  2961. if (isFullscreen()) {
  2962. e.DeviceUtils.lockScreenToPortrait()
  2963. }
  2964. };
  2965. f.prototype.onResizeWindowHandler = function(g) {
  2966. if (isMobileDevice) {
  2967. this.resizeGameForMobile()
  2968. } else {
  2969. this.resizeGameForDesktop()
  2970. }
  2971. };
  2972. f.prototype.onOrientationChangeHandler = function(g) {
  2973. if (isMobileDevice) {
  2974. this.resizeGameForMobile()
  2975. }
  2976. };
  2977. f.prototype.onAssetsLoadComplete = function(g) {
  2978. this._assetLoader.removeEventListener("onComplete", this.onAssetsLoadComplete);
  2979. this.updateLoadingTextState(e.LoadingState.SFX);
  2980. e.SoundManager.init()
  2981. };
  2982. f.prototype.updateLoadingTextState = function(g) {
  2983. document.getElementById("loader-message").style.display = "none";
  2984. document.getElementById("loader-message-sfx").style.display = "none";
  2985. document.getElementById("loader-message-graphics").style.display = "none";
  2986. if (g == e.LoadingState.GRAPHICS) {
  2987. document.getElementById("loader-message-graphics").style.display = "block"
  2988. } else {
  2989. if (g == e.LoadingState.SFX) {
  2990. document.getElementById("loader-message-sfx").style.display = "block"
  2991. } else {
  2992. if (g == e.LoadingState.SCRIPT) {
  2993. document.getElementById("loader-message").style.display = "block"
  2994. }
  2995. }
  2996. }
  2997. };
  2998. f.prototype.onSoundLoadComplete = function(g) {
  2999. e.SoundManager.event.removeEventListener(e.GameEvent.SOUND_LOADED, this.onSoundLoadComplete);
  3000. e.SoundManager.event.removeEventListener(e.GameEvent.SOUND_ERROR, this.onSoundLoadComplete);
  3001. this._loader.onLoadComplete()
  3002. };
  3003. f.prototype.onLaunchGameHL = function(g) {
  3004. this.init()
  3005. };
  3006. f.prototype.init = function() {
  3007. disableTouchFreeze();
  3008. gameArea.style.display = "block";
  3009. var h = document.getElementById("game_area");
  3010. this._stage = new PIXI.Stage(0, false);
  3011. var i = e.DeviceUtils.renderInWebGL();
  3012. var g = getQueryVariable("webgl");
  3013. if (g != null) {
  3014. i = g == "1"
  3015. }
  3016. if (i) {
  3017. this._renderer = PIXI.autoDetectRenderer(f.GAME_DIMENSION.width, f.GAME_DIMENSION.height, h, false, false)
  3018. } else {
  3019. this._renderer = new PIXI.CanvasRenderer(f.GAME_DIMENSION.width, f.GAME_DIMENSION.height, h, false)
  3020. }
  3021. this._renderer.view.style.width = this._gameRect.width + "px";
  3022. this._renderer.view.style.height = this._gameRect.height-40 + "px";
  3023. this.initTitleArea();
  3024. this.onResizeWindowHandler(null);
  3025. this._rafDelta.init();
  3026. this.update()
  3027. };
  3028. f.prototype.initGamePlay = function() {
  3029. if (this._gameArea) {
  3030. this.disposeGameArea()
  3031. }
  3032. this._gameArea = new e.GameArea(this._stage)
  3033. };
  3034. f.prototype.disposeGameArea = function() {
  3035. if (this._gameArea) {
  3036. this._gameArea.dispose();
  3037. this._gameArea = null
  3038. }
  3039. };
  3040. f.prototype.initTitleArea = function() {
  3041. if (this._titleArea) {
  3042. this.disposeTitleArea()
  3043. }
  3044. this._titleArea = new e.TitleScreen(this._stage);
  3045. this._titleArea.addEventListener(e.GameEvent.START_GAME, this.launchStartGameFromTitle)
  3046. };
  3047. f.prototype.disposeTitleArea = function() {
  3048. if (this._titleArea) {
  3049. this._titleArea.addEventListener(e.GameEvent.START_GAME, this.launchStartGameFromTitle);
  3050. this._titleArea.dispose();
  3051. this._titleArea = null
  3052. }
  3053. };
  3054. f.prototype.launchStartGameFromTitle = function(g) {
  3055. this.disposeTitleArea();
  3056. this.initGamePlay()
  3057. };
  3058. f.prototype.update = function() {
  3059. requestAnimFrame(this.update);
  3060. this._rafDelta.update();
  3061. if (this._gameArea) {
  3062. this._gameArea.update(this._rafDelta.delta)
  3063. }
  3064. if (this._titleArea) {
  3065. this._titleArea.update(this._rafDelta.delta)
  3066. }
  3067. if (this._renderer) {
  3068. this._renderer.render(this._stage)
  3069. }
  3070. TWEEN.update()
  3071. };
  3072. f.prototype.resizeGameForDesktop = function() {
  3073. this.resizeGameForMobile(this._gameRectDesktop.width, this._gameRectDesktop.height)
  3074. };
  3075. f.prototype.resizeGameForMobile = function(k, j) {
  3076. var g = window.innerWidth;
  3077. var l = window.innerHeight;
  3078. if (k) {
  3079. g = k
  3080. }
  3081. if (j) {
  3082. l = j
  3083. }
  3084. var m = f.GAME_DIMENSION.width / f.GAME_DIMENSION.height;
  3085. var i = g / l;
  3086. if (i > m) {
  3087. g = Math.round(l * m)
  3088. } else {
  3089. l = Math.round(g / m)
  3090. }
  3091. this._gameRect.width = g;
  3092. this._gameRect.height = l;
  3093. if (this._renderer) {
  3094. this._renderer.view.style.height = l-40 + "px";
  3095. this._renderer.view.style.width = g + "px"
  3096. }
  3097. gameContainer.style.width = g + "px";
  3098. gameContainer.style.height = l-40 + "px";
  3099. if (this._loader) {
  3100. this._loader.updateViewPort(g, l)
  3101. }
  3102. var h = (window.innerHeight - l) >> 1;
  3103. gameContainer.style.marginTop = h.toString() + "px";
  3104. this.displayRotateDeviceInfo()
  3105. };
  3106. f.prototype.displayRotateDeviceInfo = function() {
  3107. if (isMobileDevice) {
  3108. if (e.DeviceUtils.isLandscapeMode() == true) {
  3109. rotateDeviceInfo.style.display = "block"
  3110. } else {
  3111. rotateDeviceInfo.style.display = "none"
  3112. }
  3113. }
  3114. };
  3115. f.GAME_DIMENSION = new PIXI.Rectangle(0, 0, 320, 460);
  3116. return f
  3117. })();
  3118. e.Main = d;
  3119. var c = (function() {
  3120. function f() {
  3121. }
  3122. f.prototype.init = function() {
  3123. this._then = Date.now()
  3124. };
  3125. f.prototype.update = function() {
  3126. this._now = Date.now();
  3127. this.delta = (this._now - this._then) * 0.06;
  3128. this._then = this._now;
  3129. this.delta = (((this.delta * 100) + 0.5) >> 0) / 100;
  3130. if (this.delta > 1) {
  3131. this.delta = 1
  3132. }
  3133. };
  3134. return f
  3135. })();
  3136. e.RAFDelta = c
  3137. })(a.goldenratio || (a.goldenratio = {}));
  3138. var b = a.goldenratio
  3139. })(com || (com = {}));
  3140. var gameContainer;
  3141. var gameArea;
  3142. var rotateDeviceInfo;
  3143. //程序入口
  3144. window.addEventListener("load", onLoad, false);
  3145. function onLoad() {
  3146. //btGame.onlyVScreen();
  3147. gameContainer = document.getElementById("container");
  3148. gameArea = document.getElementById("game_area");
  3149. rotateDeviceInfo = document.getElementById("rotate-device-instruction");
  3150. gameContainer.style.display = "block";
  3151. new com.goldenratio.Main()
  3152. }
  3153. function disableTouchFreeze() {
  3154. document.addEventListener("touchstart", touchHandlerDummy, false);
  3155. document.addEventListener("touchmove", touchHandlerDummy, false);
  3156. document.addEventListener("touchend", touchHandlerDummy, false)
  3157. }
  3158. function touchHandlerDummy(a) {
  3159. a.preventDefault();
  3160. return false
  3161. }
  3162. ;