gc.js 86 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359
  1. import * as PIXI from"./pixi.min"
  2. import {TweenMax, TimelineLite} from "./TweenMax.min"
  3. import GD from "./human"
  4. var {pixelRatio, windowWidth, windowHeight} = wx.getSystemInfoSync()
  5. var gWidth = windowWidth * pixelRatio
  6. var gHeight = windowHeight * pixelRatio
  7. var gc = {
  8. loader:null,
  9. stats:null,
  10. width:gWidth,
  11. height:gHeight,
  12. stage:null,
  13. intro:null,
  14. tutorial:null,
  15. game:null
  16. };
  17. gc.MovieClip = function(fileName, start, end, speed, repeat) {
  18. PIXI.extras.AnimatedSprite.call(this, this.getRepeatTexture(fileName, start, end, repeat));
  19. this.animationSpeed = speed;
  20. this.play();
  21. };
  22. gc.MovieClip.constructor = gc.MovieClip;
  23. gc.MovieClip.prototype = Object.create(PIXI.extras.AnimatedSprite.prototype);
  24. gc.MovieClip.prototype.setAnimation = function(fileName, start, end, speed, repeat){
  25. this.textures = this.getRepeatTexture(fileName, start, end, repeat);
  26. this.animationSpeed = speed;
  27. };
  28. gc.MovieClip.prototype.getRepeatTexture = function(fileName, start, end, repeat){
  29. var textures = [];
  30. var i = repeat || 1;
  31. while(i--){
  32. textures = textures.concat(this.getTexture(fileName, start, end));
  33. }
  34. return textures;
  35. };
  36. gc.MovieClip.prototype.getTexture = function(fileName, start, end){
  37. start = start || 1;
  38. var textures = [],
  39. i = end - start + 1,
  40. j = start;
  41. while(i--) {
  42. if(j < 10){textures.push(PIXI.Texture.fromFrame(fileName + '0' + j + '.png'));}
  43. else {textures.push(PIXI.Texture.fromFrame(fileName + j + '.png'));}
  44. j++;
  45. }
  46. return textures;
  47. };
  48. gc.MovieClip.prototype.updateTransform = function() {
  49. PIXI.extras.AnimatedSprite.prototype.updateTransform.call(this);
  50. };
  51. gc.NumberText = function(fileName, align, space, iconName, iconAlign, strLen) {
  52. this.CENTER = 'center';
  53. this.RIGHT = 'right';
  54. this.value = 0;
  55. this.isChange = false;
  56. this.list = [];
  57. this.tmpList = [];
  58. this.fileName = fileName;
  59. this.align = align;
  60. this.space = space;
  61. this.iconName = iconName;
  62. this.iconAlign = iconAlign;
  63. this.strLen = strLen;
  64. this.icon = null;
  65. PIXI.Container.call(this);
  66. this.container = new PIXI.Container();
  67. this.addChild(this.container);
  68. this.setValue(0);
  69. };
  70. gc.NumberText.constructor = gc.NumberText;
  71. gc.NumberText.prototype = Object.create(PIXI.Container.prototype);
  72. gc.NumberText.prototype.setValue = function(value){
  73. this.value = value;
  74. this.isChange = true;
  75. };
  76. gc.NumberText.prototype.getNumberSprite = function(num){
  77. var sprite, name = this.fileName + num + '.png';
  78. if(this.tmpList.length > 0){
  79. sprite = this.tmpList.shift();
  80. sprite.texture = PIXI.Texture.fromFrame(name);
  81. }else{
  82. sprite = PIXI.Sprite.fromFrame(name);
  83. }
  84. return sprite;
  85. };
  86. gc.NumberText.prototype.removeAll = function(){
  87. var txt, i = this.list.length;
  88. while(i--){
  89. txt = this.list.shift();
  90. this.tmpList.push(txt);
  91. }
  92. if(this.container) this.container.removeChildren();
  93. };
  94. gc.NumberText.prototype.updateTransform = function() {
  95. if(this.isChange){
  96. this.removeAll();
  97. var numStr = this.value.toString();
  98. if(this.strLen) numStr = Util.zeroStr(this.value, this.strLen);
  99. var index = 0, txt,
  100. space = 0,
  101. i = numStr.length;
  102. if(this.iconName){
  103. if(!this.icon) this.icon = PIXI.Sprite.fromFrame(this.iconName + '.png');
  104. this.container.addChild(this.icon);
  105. if(this.iconAlign == 'left'){
  106. space += this.icon.width + this.space;
  107. }
  108. }
  109. while(i--){
  110. txt = this.getNumberSprite(parseInt(numStr.substr(index, 1))+1);
  111. txt.x = space;
  112. space += txt.width + this.space;
  113. index++;
  114. this.container.addChild(txt);
  115. this.list[i] = txt;
  116. }
  117. if(this.iconAlign == 'right'){
  118. this.icon.x = space;
  119. space += this.icon.width + this.space;
  120. }
  121. if(this.align == this.CENTER){
  122. this.container.x = -space/2;
  123. }else if(this.align == this.RIGHT){
  124. this.container.x = -space;
  125. }
  126. this.isChange = false;
  127. }
  128. PIXI.Container.prototype.updateTransform.call(this);
  129. };
  130. gc.GameScene = function(){
  131. PIXI.Container.call(this);
  132. this.lastEventTime = undefined; //Time the click occurred
  133. //120
  134. this.cookieMatrixPos = [[75,550], [170,550], [265,550], [360,550], [455,550], [550,550], [645,550],
  135. [75,645], [170,645], [265,645], [360,645], [455,645], [550,645], [645,645],
  136. [75,740], [170,740], [265,740], [360,740], [455,740], [550,740], [645,740],
  137. [75,835], [170,835], [265,835], [360,835], [455,835], [550,835], [645,835],
  138. [75,935], [170,935], [265,935], [360,935], [455,935], [550,935], [645,935],
  139. [75,1030], [170,1030], [265,1030], [360,1030], [455,1030], [550,1030], [645,1030],
  140. [75,1125], [170,1125], [265,1125], [360,1125], [455,1125], [550,1125], [645,1125]];
  141. this.cookieNumMatrix = [];
  142. this.cookieMatrix = [];
  143. this.itemEffectMc = [];
  144. this.bombAnerge = 0;
  145. this.bombfull = 50;
  146. this.fixArr1 = [];
  147. this.fixArr2 = [];
  148. this.readytxt = true;
  149. this.starttxt = false;
  150. this.playGame = false;
  151. this.addPoint = 0;
  152. this.itemIndex = undefined;
  153. this.itemIndex1 = undefined;
  154. this.itemIndex2 = undefined;
  155. this.itemIndexes = [];
  156. this.canClick = false;
  157. this.hint = [];
  158. this.giveHint = false;
  159. this.bundle = [];
  160. this.prestageMode = 'normal';
  161. this.stageMode = 'normal';
  162. this.chance = 60;
  163. this.useItem = false;
  164. this.remembers = [];//Store cookies like items
  165. this.combo = 0;
  166. this.restComboTime = 0;
  167. this.lastTime = undefined;
  168. this.totalCombo = 0; //Combo 3 times or more .. Medal 1, Combo 100 times or more .. Medal 4
  169. this.champagneCombo = 0; //Champagne 10 times .. Medals 2
  170. this.bombCombo = 0; //Bomb item 10 times .. Medals 3
  171. this.getMedal1 = false;
  172. this.getMedal2 = false;
  173. this.getMedal3 = false;
  174. this.getMedal4 = false;
  175. this.callfevercnt = 0;
  176. this.lastEnd = false; //To prevent timeup if last fang
  177. this.bumpscale = 0.01;
  178. this.pauseMode = false;
  179. this.pauseTime = 0;
  180. this.exceptSound = false; //During mode change = To inform the fiver sound only once when using the item
  181. };
  182. gc.GameScene.constructor = gc.GameScene;
  183. gc.GameScene.prototype = Object.create(PIXI.Container.prototype);
  184. gc.GameScene.prototype.init = function() {
  185. this.readytxt = true;
  186. this.starttxt = false;
  187. this.declareObjects();
  188. this.setBG();
  189. this.readyGame();
  190. this.fever = setInterval(this.setFever.bind(this), 33.333);
  191. this.test = true;
  192. this.explode();
  193. this.stageMode = 'fever';
  194. this.actFever(); //Make a one-time call to resolve the bug in the first peer
  195. //Return to default mode
  196. this.stageMode = 'normal';
  197. this.normalMode();
  198. };
  199. //Create Object
  200. gc.GameScene.prototype.declareObjects = function () {
  201. this.bomb = new PIXI.Sprite.fromFrame('bomb_0001.png');
  202. this.bombgauge = new PIXI.Sprite.fromFrame('bomb_gauge_bar_0001.png');
  203. this.chanceImg= new gc.NumberText('score_num_', 'center', -4);
  204. this.readyBG = new PIXI.Sprite(GD.loader.resources['ready_bg'].texture);
  205. this.readyImg = new PIXI.Sprite.fromFrame('ready_0001.png');
  206. this.startImg = new PIXI.Sprite.fromFrame('start_0001.png');
  207. this.gameoverImg = new PIXI.Sprite.fromFrame('gameover.png');
  208. for(var i=0; i<this.cookieMatrixPos.length; i++) {
  209. this.cookieMatrix[i] = new PIXI.Sprite.fromFrame('cookie_0001.png');
  210. this.itemEffectMc[i] = new gc.MovieClip('item_effect_00', 1, 14, 0.2);
  211. }
  212. this.gameBG = new PIXI.Sprite(GD.loader.resources['game_bg'].texture);
  213. this.gameTable = new PIXI.Sprite(GD.loader.resources['game_table'].texture);
  214. this.shadow = new PIXI.Sprite(GD.loader.resources['shadow_bg'].texture);
  215. this.fevereffect1 = new gc.MovieClip('fever_effect_1_00', 1, 23, 0.3, true);
  216. this.fevereffect2 = new gc.MovieClip('fever_effect_2_00', 1, 29, 0.3, true);
  217. this.normalmomo = new gc.MovieClip('momo_normal_00', 1, 50, 0.3);
  218. this.fevermomo = new gc.MovieClip('momo_fever_00', 1, 43, 0.3);
  219. this.normalshushu = new gc.MovieClip('shushu_normal_00', 1, 12, 0.3);
  220. this.fevershushu = new gc.MovieClip('shushu_fever_00', 1, 17, 0.3);
  221. this.timeup = new PIXI.Sprite.fromFrame('momotime_0001.png');
  222. this.scoreTxt= new gc.NumberText('score_num_', 'center', -4);
  223. this.crossEffect1 = new PIXI.Sprite.fromFrame('line_clear_effect.png');
  224. this.crossEffect2 = new PIXI.Sprite.fromFrame('line_clear_effect.png');
  225. this.superfeverText = new PIXI.Sprite.fromFrame('super_fever_0001.png');
  226. this.feverText = new PIXI.Sprite.fromFrame('fever_0001.png');
  227. };
  228. //Game settings
  229. gc.GameScene.prototype.readyGame = function() {
  230. if(this.readytxt) {
  231. GD.soundPlay('sound_ready');
  232. this.readyBG.anchor.set(0.5);
  233. this.readyBG.position.x = GD.width / 2;
  234. this.readyBG.position.y = GD.height / 2;
  235. this.addChild(this.readyBG);
  236. this.readyImg.anchor.set(0.5);
  237. this.readyImg.position = this.readyBG.position;
  238. this.readyImg.scale.x = 0;
  239. this.readyImg.scale.y = 0;
  240. TweenMax.to(this.readyImg.scale, 0.8, {x:1, y:1});
  241. this.addChild(this.readyImg);
  242. this.readytxt = false;
  243. this.starttxt = true;
  244. setTimeout(this.startGame.bind(this), 1000);
  245. }
  246. };
  247. gc.GameScene.prototype.startGame = function() {
  248. if(this.starttxt){
  249. GD.soundPlay('sound_start');
  250. this.readyImg.visible = false;
  251. this.startImg.anchor.set(0.5);
  252. this.startImg.position = this.readyImg.position;
  253. this.startImg.scale.x = 0;
  254. this.startImg.scale.y = 0;
  255. TweenMax.to(this.startImg.scale, 0.5, {x:1.2, y:1.2});
  256. this.addChild(this.startImg);
  257. setTimeout(this.playStart.bind(this),600);
  258. }
  259. };
  260. gc.GameScene.prototype.setItemEffect = function () {
  261. for(var i=0; i<this.cookieMatrix.length; i++) this.cookieMatrix[i].removeChild(this.itemEffectMc[i]);
  262. for(var i=0; i<this.cookieMatrixPos.length; i++){
  263. this.itemEffectMc[i].anchor.set(0.5);
  264. this.itemEffectMc[i].stop();
  265. this.itemEffectMc[i].alpha = 0;
  266. this.cookieMatrix[i].addChild(this.itemEffectMc[i]);
  267. }
  268. };
  269. gc.GameScene.prototype.playStart = function(){
  270. this.removeChild(this.readyImg);
  271. this.removeChild(this.startImg);
  272. this.readyBG.visible = false;
  273. this.setCookies();
  274. };
  275. gc.GameScene.prototype.setBG = function() {
  276. this.gameTable.position.y = 470;
  277. this.addChild(this.gameBG);
  278. this.setFeverEffect2();
  279. this.setMomo();
  280. this.setShushu();
  281. this.gameBG.addChild(this.gameTable);
  282. this.setBomb();
  283. this.setChance();
  284. this.makeShadow();
  285. this.setScore();
  286. this.setFeverEffect1();
  287. };
  288. gc.GameScene.prototype.makeShadow = function () {
  289. this.shadowContainer.addChild(this.shadow);
  290. this.shadow.alpha = 0;
  291. };
  292. gc.GameScene.prototype.setFeverEffect1 = function() {
  293. this.fevereffect1.anchor.set(0.5);
  294. this.fevereffect1.position.x = gc.width/2;
  295. this.fevereffect1.position.y = 600;
  296. this.addChild(this.fevereffect1);
  297. this.fevereffect1.alpha = 0;
  298. };
  299. gc.GameScene.prototype.setFeverEffect2 = function() {
  300. this.fevereffect2.anchor.set(0.5);
  301. this.fevereffect2.position.x = gc.width/2;
  302. this.fevereffect2.position.y = 288.5;
  303. this.gameBG.addChild(this.fevereffect2);
  304. this.fevereffect2.alpha = 0;
  305. };
  306. gc.GameScene.prototype.setMomo = function() {
  307. this.normalmomo.position.x = gc.width / 2;
  308. this.normalmomo.position.y = 220;
  309. this.gameBG.addChild(this.normalmomo);
  310. this.fevermomo.position.x = this.normalmomo.x;
  311. this.fevermomo.position.y = this.normalmomo.y;
  312. this.fevermomo.alpha = 0;
  313. this.fevermomo.stop();
  314. this.gameBG.addChild(this.fevermomo);
  315. };
  316. gc.GameScene.prototype.setShushu = function() {
  317. this.normalshushu.position.x = gc.width / 4;
  318. this.normalshushu.position.y = 300;
  319. this.gameBG.addChild(this.normalshushu);
  320. this.fevershushu.position.x = this.normalshushu.x;
  321. this.fevershushu.position.y = this.normalshushu.y;
  322. this.fevershushu.alpha = 0;
  323. this.fevershushu.stop();
  324. this.gameBG.addChild(this.fevershushu);
  325. };
  326. gc.GameScene.prototype.normalMode = function () {
  327. console.log('normal');
  328. this.fevermomo.alpha = 0;
  329. this.fevermomo.stop();
  330. this.normalmomo.alpha = 1;
  331. this.normalmomo.play();
  332. this.fevershushu.alpha = 0;
  333. this.fevershushu.stop();
  334. this.normalshushu.alpha = 1;
  335. this.normalshushu.play();
  336. };
  337. gc.GameScene.prototype.otherMode = function () {
  338. console.log('other');
  339. this.normalmomo.alpha = 0;
  340. this.normalmomo.stop();
  341. this.fevermomo.alpha = 1;
  342. this.fevermomo.play();
  343. this.normalshushu.alpha = 0;
  344. this.normalshushu.stop();
  345. this.fevershushu.alpha = 1;
  346. this.fevershushu.play();
  347. };
  348. gc.GameScene.prototype.setChance = function () {
  349. if(this.explodeContainer == undefined) {
  350. this.explodeContainer = new PIXI.Container();
  351. this.explodeContainer.position = this.gameBG.position;
  352. this.explodeContainer.width = this.gameBG.width;
  353. this.explodeContainer.height = this.gameBG.height;
  354. this.addChild(this.explodeContainer);
  355. }
  356. this.shadowContainer = new PIXI.Container();
  357. this.addChild(this.shadowContainer);
  358. if(this.explodeContainer2 == undefined) {
  359. this.explodeContainer2 = new PIXI.Container();
  360. this.explodeContainer2.position = this.gameBG.position;
  361. this.explodeContainer2.width = this.gameBG.width;
  362. this.explodeContainer2.height = this.gameBG.height;
  363. this.addChild(this.explodeContainer2);
  364. }
  365. this.chanceImg.x = 55;
  366. this.chanceImg.y = 45;
  367. this.chanceImg.scale.x = 0.8;
  368. this.chanceImg.scale.y = 0.8;
  369. this.rangeChance();
  370. };
  371. //남은 기회 표시
  372. gc.GameScene.prototype.rangeChance = function () {
  373. this.chanceImg.setValue(this.chance);
  374. };
  375. //라스트팡(남은 아이템 클리어)=======================================================================================
  376. gc.GameScene.prototype.lastPang = function () {
  377. this.lastEnd = true;
  378. this.itemOver = false;
  379. this.scanIndex = undefined;
  380. this.useItem = false;
  381. var count = 0;
  382. for(var i=0; i<this.cookieNumMatrix.length; i++){
  383. if(this.cookieNumMatrix[i] > 6){
  384. this.scanIndex = i;
  385. this.useItem = true;
  386. if (this.cookieNumMatrix[i] == 10) {this.actBomb(i);}
  387. else if (this.cookieNumMatrix[i] == 9) {this.actEqual(i);}
  388. else if (this.cookieNumMatrix[i] == 8) {
  389. this.crossIndex = i;
  390. this.actCross(i);
  391. }
  392. break;
  393. } else {count++;}
  394. }
  395. if(count == this.cookieNumMatrix.length) {
  396. this.itemOver = true;
  397. this.checkMatching3();
  398. }
  399. };
  400. //게임오버===========================================================================================================
  401. gc.GameScene.prototype.setGameOver = function(){
  402. this.canClick = false;
  403. this.playGame = false;
  404. this.checkLeftItem();
  405. if(this.lastEnd) {
  406. this.timeup.anchor.set(0.5);
  407. this.timeup.position.x = this.gameBG.width / 2;
  408. this.timeup.position.y = GD.height/2+50;
  409. this.timeup.scale.x = 0;
  410. this.timeup.scale.y = 0;
  411. this.addChild(this.timeup);
  412. GD.soundPlay('sound_momotime');
  413. this.canClick = false;
  414. this.removeChild(this.hintMc1);
  415. this.removeChild(this.hintMc2);
  416. if (this.real1 != undefined) {this.real1.alpha = 1;}
  417. if (this.real2 != undefined) {this.real2.alpha = 1;}
  418. this.reachmax = false;
  419. this.incdgree = 0.15;
  420. this.stageMode = 'momotime';
  421. this.playGame = false;
  422. this.otherMode();
  423. this.actfeverEffect();
  424. this.momotime = setInterval(this.showMomoTime.bind(this), 33.333);
  425. }
  426. else {//아이템이 없으면 모모타임 이미지, 소리 없이 끝내기
  427. this.lastPang();
  428. }
  429. };
  430. gc.GameScene.prototype.checkLeftItem = function () {
  431. this.lastEnd = false;
  432. for(var i=0; i<this.cookieNumMatrix.length; i++){
  433. if(this.cookieNumMatrix[i]>7) {
  434. this.lastEnd = true;
  435. }
  436. }
  437. };
  438. gc.GameScene.prototype.showMomoTime = function () {
  439. if(this.reachmax && this.timeup.scale.x <= 1) {
  440. this.incdgree = 0;
  441. setTimeout(this.delay.bind(this), 1000);
  442. clearInterval(this.momotime);
  443. }
  444. if(this.timeup.scale.x >= 1.3){
  445. this.incdgree *= -1;
  446. this.reachmax = true;
  447. }
  448. this.timeup.scale.x += this.incdgree;
  449. this.timeup.scale.y += this.incdgree;
  450. };
  451. gc.GameScene.prototype.delay = function () {
  452. this.dropmomotime = setInterval(this.dropMomoTime.bind(this),33.333);
  453. };
  454. gc.GameScene.prototype.dropMomoTime = function () {
  455. this.timeup.scale.y = 1.2;
  456. this.timeup.position.y += 70;
  457. if(this.timeup.position.y >= gc.height+this.timeup.height){
  458. this.removeChild(this.timeup);
  459. //모모타임이 되고 나서 제일 첫 lastpang
  460. this.lastPang();
  461. clearInterval(this.dropmomotime);
  462. }
  463. };
  464. gc.GameScene.prototype.setScore = function(){
  465. this.scoreTxt.x = 355;
  466. this.scoreTxt.y = 45;
  467. this.scoreTxt.scale.x = 0.8;
  468. this.scoreTxt.scale.y = 0.8;
  469. this.score = 0;
  470. this.scoreTxt.setValue(this.score);
  471. this.shadowContainer.addChild(this.chanceImg);
  472. this.shadowContainer.addChild(this.scoreTxt);
  473. };
  474. gc.GameScene.prototype.setBomb = function() {
  475. this.bomb.anchor.set(0.5);
  476. this.bomb.x = 69;
  477. this.bomb.y = 211;
  478. //this.bomb.alpha = 0;
  479. this.bombgauge.anchor.x = 0.5;
  480. this.bombgauge.anchor.y = 1;
  481. this.bombgauge.position.x = 69;
  482. this.bombgauge.position.y = 448;
  483. this.addChild(this.bombgauge);
  484. this.addChild(this.bomb);
  485. };
  486. gc.GameScene.prototype.setCookies = function() {
  487. for(var i=0; i<this.cookieMatrixPos.length; i++){
  488. if(this.cookieNumMatrix[i] < 7 || this.cookieNumMatrix[i] == undefined) {
  489. this.cookieNumMatrix[i] = parseInt(Math.random() * 6 + 1);
  490. }
  491. }
  492. if(this.checkMatching1()){
  493. this.setCookies();
  494. }else{ //맞는게 없을 때
  495. for(var i=0; i<this.cookieNumMatrix.length; i++) {
  496. this.drawCookie(this.cookieNumMatrix[i], i);
  497. }
  498. this.giveHint = false;
  499. if(this.playGame) this.findHint();
  500. }
  501. };
  502. gc.GameScene.prototype.drawCookie = function (cookieNum, index) {
  503. switch (cookieNum) {
  504. case 1:
  505. this.cookieMatrix[index].texture = PIXI.Texture.fromFrame('cookie_0001.png');
  506. break;
  507. case 2:
  508. this.cookieMatrix[index].texture = PIXI.Texture.fromFrame('cookie_0002.png');
  509. break;
  510. case 3:
  511. this.cookieMatrix[index].texture = PIXI.Texture.fromFrame('cookie_0003.png');
  512. break;
  513. case 4:
  514. this.cookieMatrix[index].texture = PIXI.Texture.fromFrame('cookie_0004.png');
  515. break;
  516. case 5:
  517. this.cookieMatrix[index].texture = PIXI.Texture.fromFrame('cookie_0005.png');
  518. break;
  519. case 6:
  520. this.cookieMatrix[index].texture = PIXI.Texture.fromFrame('cookie_0006.png');
  521. break;
  522. default :
  523. this.cookieMatrix[index].texture = this.cookieMatrix[index].texture;
  524. }
  525. this.cookieMatrix[index].anchor.set(0.5);
  526. this.cookieMatrix[index].scale.x = 0.85;
  527. this.cookieMatrix[index].scale.y = 0.85;
  528. this.cookieMatrix[index].position.x = this.cookieMatrixPos[index][0];
  529. this.cookieMatrix[index].position.y = this.cookieMatrixPos[index][1];
  530. if(this.cookieNumMatrix[index] < 7) TweenMax.from(this.cookieMatrix[index], 0.1, {y:this.cookieMatrixPos[index][1]-30});
  531. this.cookieMatrix[index].flag = 1;
  532. if(this.cookieNumMatrix[index] != 9) this.cookieMatrix[index].remember = 0; //Equal아이템이 나왔을 때 없앨 번호 기억을 위함
  533. this.cookieMatrix[index].buttonMode = true;
  534. this.cookieMatrix[index].interactive = true;
  535. if(!gc.IS_MOBILE)
  536. {
  537. this.cookieMatrix[index].mousedown = this.cookieMatrix[index].touchstart = (function(e){
  538. e.stopPropagation();
  539. this.getTouchStartPosition(index);
  540. }).bind(this);
  541. this.cookieMatrix[index].mouseupoutside = this.cookieMatrix[index].touchendoutside = (function(e){
  542. e.stopPropagation();
  543. this.getTouchEndPosition(index);
  544. }).bind(this);
  545. }
  546. else
  547. {
  548. this.cookieMatrix[index].touchstart = (function(e){
  549. e.stopPropagation();
  550. if(gc.IS_MOBILE) {
  551. this.previousX = e.data.getLocalPosition(this.parent).x;
  552. this.previousY = e.data.getLocalPosition(this.parent).y;
  553. }
  554. this.getTouchStartPosition(index);
  555. }).bind(this);
  556. this.cookieMatrix[index].touchendoutside = (function(e){
  557. e.stopPropagation();
  558. if(gc.IS_MOBILE) {
  559. this.currentX = e.data.getLocalPosition(this.parent).x;
  560. this.currentY = e.data.getLocalPosition(this.parent).y;
  561. }
  562. this.getTouchEndPosition(index);
  563. }).bind(this);
  564. }
  565. this.gameBG.addChild(this.cookieMatrix[index]);
  566. if(index == 48){
  567. this.playGame = true;
  568. this.canClick = true;
  569. if(this.lastEventTime == undefined) this.lastEventTime = Date.now();
  570. if(this.sethint == undefined) this.sethint = setInterval(this.setHint.bind(this), 33.333);
  571. if(this.bum == undefined) this.bum = setInterval(this.bump.bind(this), 33.333);
  572. this.setItemEffect();
  573. this.setFeverText();
  574. //맞출 블럭이 없어 새로 그려졌을 때 아이템 강조 이펙트 작동을 위함
  575. this.stopItemAccentEffect();
  576. this.playItemAccentEffect();
  577. }
  578. };
  579. //힌트==========================================================================================
  580. gc.GameScene.prototype.setHint = function () {
  581. var now = Date.now();
  582. if(!this.pauseMode) {
  583. if(this.pauseTime != 0){
  584. this.lastEventTime += Math.abs(now - this.pauseTime);
  585. this.pauseTime = 0;
  586. }
  587. if (Math.abs(this.lastEventTime - now) / 1000 >= 5) {
  588. if (!this.giveHint && this.playGame) this.showHint();
  589. }
  590. }else{
  591. if(this.pauseTime == 0) this.pauseTime = now;
  592. }
  593. };
  594. gc.GameScene.prototype.findHint = function () {
  595. var temp = undefined;
  596. var index = undefined;
  597. var check1 = undefined;
  598. var check2 = undefined;
  599. this.hint = [];
  600. //오른쪽 맨 끝 열은 체크안해도 됨
  601. for(var i=0; i<6; i++){
  602. for(var j=0; j<7; j++){
  603. index = i + j*7;
  604. temp = this.cookieNumMatrix[index];
  605. this.cookieNumMatrix[index] = this.cookieNumMatrix[index+1];
  606. this.cookieNumMatrix[index+1] = temp;
  607. check1 = this.checkMatching1();
  608. this.cookieNumMatrix[index+1] = this.cookieNumMatrix[index];
  609. this.cookieNumMatrix[index] = temp;
  610. if(check1) this.hint.push([index, index+1]);
  611. }
  612. }
  613. //맨 아래 행은 체크 안해도 됨
  614. for(var i=0; i<7; i++){
  615. for(var j=0; j<6; j++){
  616. index = i+ j*7;
  617. temp = this.cookieNumMatrix[index];
  618. this.cookieNumMatrix[index] = this.cookieNumMatrix[index+7];
  619. this.cookieNumMatrix[index+7] = temp;
  620. check2 = this.checkMatching1();
  621. this.cookieNumMatrix[index+7] = this.cookieNumMatrix[index];
  622. this.cookieNumMatrix[index] = temp;
  623. if(check2) this.hint.push([index, index+7]);
  624. }
  625. }
  626. //맞춰지는 블럭 없을 때 다시 그리기
  627. if(this.hint.length == 0){
  628. for(var i=0; i<this.cookieMatrix.length; i++){
  629. if(this.cookieNumMatrix[i]<7) this.gameBG.removeChild(this.cookieMatrix[i]);
  630. }
  631. this.setCookies();
  632. }
  633. };
  634. gc.GameScene.prototype.showHint = function(){
  635. this.giveHint = true;
  636. var texturename1, texturename2;
  637. var randHint = parseInt(Math.random() * this.hint.length);
  638. var texturenum1 = this.cookieNumMatrix[this.hint[randHint][0]];
  639. var texturenum2 = this.cookieNumMatrix[this.hint[randHint][1]];
  640. if(this.cookieNumMatrix[this.hint[randHint][0]] < 7) texturename1 = 'cookie_' + texturenum1 + '_00';
  641. if(this.cookieNumMatrix[this.hint[randHint][1]] < 7) texturename2 = 'cookie_' + texturenum2 + '_00';
  642. this.removeChild(this.hintMc1);
  643. this.removeChild(this.hintMc2);
  644. if(this.real1 != undefined) this.real1.alpha = 1;
  645. if(this.real2 != undefined) this.real2.alpha = 1;
  646. if(this.cookieNumMatrix[this.hint[randHint][0]] < 7) {
  647. this.hintMc1 = new gc.MovieClip(texturename1, 1, 8, 0.2);
  648. this.hintMc1.anchor.set(0.5);
  649. this.hintMc1.scale.x = 0.85;
  650. this.hintMc1.scale.y = 0.85;
  651. this.hintMc1.position.x = this.cookieMatrixPos[this.hint[randHint][0]][0];
  652. this.hintMc1.position.y = this.cookieMatrixPos[this.hint[randHint][0]][1]-12;
  653. this.addChild(this.hintMc1);
  654. this.real1 = this.cookieMatrix[this.hint[randHint][0]];
  655. this.real1.alpha = 0;
  656. }
  657. if(this.cookieNumMatrix[this.hint[randHint][1]] < 7) {
  658. this.hintMc2 = new gc.MovieClip(texturename2, 1, 8, 0.2);
  659. this.hintMc2.anchor.set(0.5);
  660. this.hintMc2.scale.x = 0.85;
  661. this.hintMc2.scale.y = 0.85;
  662. this.hintMc2.position.x = this.cookieMatrixPos[this.hint[randHint][1]][0];
  663. this.hintMc2.position.y = this.cookieMatrixPos[this.hint[randHint][1]][1]-12;
  664. this.addChild(this.hintMc2);
  665. this.real2 = this.cookieMatrix[this.hint[randHint][1]];
  666. this.real2.alpha = 0;
  667. }
  668. };
  669. //선택한 마우스 포인트 저장
  670. gc.GameScene.prototype.getTouchStartPosition = function(index) {
  671. if(!gc.IS_MOBILE){
  672. var e = window.event;
  673. this.previousX = e.clientX;
  674. this.previousY = e.clientY;
  675. }
  676. if(this.canClick && this.playGame) this.scanCookieNum(index);
  677. };
  678. //끝난 마우스 포인트 저장, 스와핑 방향 검사
  679. gc.GameScene.prototype.getTouchEndPosition = function(index) {
  680. if(!gc.IS_MOBILE){
  681. var e = window.event;
  682. this.currentX = e.clientX;
  683. this.currentY = e.clientY;
  684. }
  685. if(this.canClick && this.playGame) this.swap(index);
  686. };
  687. //클릭한 쿠키의 인덱스가 아이템인 겨우 아이템 작동
  688. gc.GameScene.prototype.scanCookieNum = function (index) {
  689. if(this.cookieNumMatrix[index]>6) {
  690. this.scanIndex = index;
  691. if(this.chance>0) {
  692. this.chance--;
  693. this.rangeChance();
  694. }
  695. this.useItem = true;
  696. this.lastEventTime = Date.now();
  697. this.giveHint = false;
  698. this.removeChild(this.hintMc1);
  699. this.removeChild(this.hintMc2);
  700. if(this.real1 != undefined) this.real1.alpha = 1;
  701. if(this.real2 != undefined) this.real2.alpha = 1;
  702. if (this.cookieNumMatrix[index] == 10) {
  703. if (this.canClick) this.actBomb(index);
  704. } else if (this.cookieNumMatrix[index] == 9) {
  705. if (this.canClick) this.actEqual(index);
  706. } else if (this.cookieNumMatrix[index] == 8) {
  707. this.crossIndex = index;
  708. if (this.canClick) this.actCross(index);
  709. }
  710. this.combo++;
  711. this.totalCombo++;
  712. if(this.combo>=15) {this.stageMode = 'superfever';}
  713. else if(this.combo>=5){
  714. this.stageMode = 'fever';
  715. this.callfevercnt = 0;
  716. } else{this.stageMode = 'normal';}
  717. this.lastTime = Date.now();
  718. this.restComboTime = 3;
  719. this.canClick = false;
  720. }else this.useItem = false;
  721. };
  722. //스와핑==================================================================================
  723. gc.GameScene.prototype.swap = function(clickIndex){
  724. var gapX = this.currentX - this.previousX;
  725. var gapY = this.currentY - this.previousY;
  726. //힌트 movieclip삭제
  727. this.removeChild(this.hintMc1);
  728. this.removeChild(this.hintMc2);
  729. //힌트애니메이션동안 안보였던 원래 텍스쳐 보이게 하기
  730. if(this.real1 != undefined) this.real1.alpha = 1;
  731. if(this.real2 != undefined) this.real2.alpha = 1;
  732. //왼쪽 쿠키랑 바꾸기
  733. if((gapX<0) && (Math.abs(gapX)>Math.abs(gapY))){
  734. if(clickIndex%7 != 0){
  735. this.lastEventTime = Date.now();
  736. this.canClick = false;
  737. this.swapLeft(clickIndex);
  738. return;
  739. }
  740. }
  741. //오른쪽
  742. if((gapX>0) && (Math.abs(gapX)>Math.abs(gapY))){
  743. if((clickIndex%7) != 6 || (clickIndex==0)){
  744. this.lastEventTime = Date.now();
  745. this.canClick = false;
  746. this.swapRight(clickIndex);
  747. return;
  748. }
  749. }
  750. //위쪽
  751. if((gapY<0) && (Math.abs(gapX)<Math.abs(gapY))){
  752. if(clickIndex > 6){
  753. this.lastEventTime = Date.now();
  754. this.canClick = false;
  755. this.swapUp(clickIndex);
  756. return;
  757. }
  758. }
  759. //아래쪽
  760. if((gapY>0) && (Math.abs(gapX)<Math.abs(gapY))){
  761. if(clickIndex < 42){
  762. this.lastEventTime = Date.now();
  763. this.canClick = false;
  764. this.swapDown(clickIndex);
  765. }
  766. }
  767. };
  768. gc.GameScene.prototype.swapLeft = function (selectIndex) {
  769. var tempTexture1, tempTexture2;
  770. var tempRemember;
  771. //텍스쳐 저장
  772. tempTexture1 = this.cookieMatrix[selectIndex].texture;
  773. tempTexture2 = this.cookieMatrix[selectIndex-1].texture;
  774. //매칭 확인을 위해 쿠키 번호 바꾸기
  775. var tempNum = this.cookieNumMatrix[selectIndex];
  776. this.cookieNumMatrix[selectIndex] = this.cookieNumMatrix[selectIndex-1];
  777. this.cookieNumMatrix[selectIndex-1] = tempNum;
  778. //매칭 확인
  779. this.checkMatching2(selectIndex);
  780. this.fixArr1 = this.memories;
  781. this.itemIndex1 = this.itemIndex;
  782. this.checkMatching2(selectIndex-1);
  783. this.fixArr2 = this.memories;
  784. this.itemIndex2 = this.itemIndex;
  785. //맞는게 없을 때
  786. if((this.fixArr1.length == 0) && (this.fixArr2.length == 0)){
  787. //쿠키 번호 복구
  788. tempNum = this.cookieNumMatrix[selectIndex];
  789. this.cookieNumMatrix[selectIndex] = this.cookieNumMatrix[selectIndex-1];
  790. this.cookieNumMatrix[selectIndex-1] = tempNum;
  791. this.cookieMatrix[selectIndex].texture = tempTexture2;
  792. this.cookieMatrix[selectIndex-1].texture = tempTexture1;
  793. TweenMax.from(this.cookieMatrix[selectIndex], 0.1, {x:this.cookieMatrixPos[selectIndex-1][0], onComplete: (function () {
  794. this.cookieMatrix[selectIndex].texture = tempTexture1;
  795. TweenMax.from(this.cookieMatrix[selectIndex], 0.1, {x:this.cookieMatrixPos[selectIndex-1][0]});
  796. }.bind(this))});
  797. TweenMax.from(this.cookieMatrix[selectIndex-1], 0.1, {x:this.cookieMatrixPos[selectIndex][0], onComplete:(function () {
  798. this.cookieMatrix[selectIndex-1].texture = tempTexture2;
  799. TweenMax.from(this.cookieMatrix[selectIndex-1], 0.1, {x:this.cookieMatrixPos[selectIndex][0], onComplete:(function(){
  800. this.canClick = true;
  801. }.bind(this))});
  802. }.bind(this))});
  803. this.lastEventTime = Date.now();
  804. this.giveHint = false;
  805. } else {//맞춰졌을 때
  806. this.chance--;
  807. if(this.fixArr1.length != 0) {
  808. this.combo++;
  809. this.totalCombo++;
  810. }
  811. if(this.fixArr2.length != 0) {
  812. this.combo++;
  813. this.totalCombo++;
  814. }
  815. if(this.combo>=15) {this.stageMode = 'superfever';}
  816. else if(this.combo>=5){
  817. this.stageMode = 'fever';
  818. this.callfevercnt = 0;
  819. } else{this.stageMode = 'normal';}
  820. this.lastTime = Date.now();
  821. this.restComboTime = 3;
  822. this.rangeChance();
  823. //스와핑 효과 보이기
  824. this.cookieMatrix[selectIndex].texture = tempTexture2;
  825. this.cookieMatrix[selectIndex - 1].texture = tempTexture1;
  826. TweenMax.from(this.cookieMatrix[selectIndex], 0.1, {x: this.cookieMatrixPos[selectIndex - 1][0], onComplete:(function () {
  827. for(var i=0; i<this.fixArr1.length; i++) this.cookieMatrix[this.fixArr1[i]].alpha = 0;
  828. }.bind(this))});
  829. TweenMax.from(this.cookieMatrix[selectIndex - 1], 0.1, {x: this.cookieMatrixPos[selectIndex][0], onComplete:(function () {
  830. for(var i=0; i<this.fixArr2.length; i++) this.cookieMatrix[this.fixArr2[i]].alpha = 0;
  831. }.bind(this))});
  832. //remember값 교환
  833. tempRemember = this.cookieMatrix[selectIndex].remember;
  834. this.cookieMatrix[selectIndex].remember = this.cookieMatrix[selectIndex-1].remember;
  835. this.cookieMatrix[selectIndex-1].remember = tempRemember;
  836. //경우에 상관없이 explode() 실행.. 객체 의미 없음
  837. TweenMax.from(this.cookieMatrix[selectIndex], 0.1, {onComplete:(function () {
  838. this.explode();
  839. }.bind(this))});
  840. }
  841. };
  842. gc.GameScene.prototype.swapRight = function (selectIndex) {
  843. var tempTexture1, tempTexture2;
  844. var tempRemember;
  845. //텍스쳐 저장
  846. tempTexture1 = this.cookieMatrix[selectIndex].texture;
  847. tempTexture2 = this.cookieMatrix[selectIndex+1].texture;
  848. //매칭 확인을 위해 쿠키 번호 바꾸기
  849. var tempNum = this.cookieNumMatrix[selectIndex];
  850. this.cookieNumMatrix[selectIndex] = this.cookieNumMatrix[selectIndex+1];
  851. this.cookieNumMatrix[selectIndex+1] = tempNum;
  852. //매칭 확인
  853. this.checkMatching2(selectIndex);
  854. this.fixArr1 = this.memories;
  855. this.itemIndex1 = this.itemIndex;
  856. this.checkMatching2(selectIndex+1);
  857. this.fixArr2 = this.memories;
  858. this.itemIndex2 = this.itemIndex;
  859. //맞는게 없을 때
  860. if((this.fixArr1.length == 0) && (this.fixArr2.length == 0)) {
  861. //쿠키 번호 복구
  862. tempNum = this.cookieNumMatrix[selectIndex];
  863. this.cookieNumMatrix[selectIndex] = this.cookieNumMatrix[selectIndex + 1];
  864. this.cookieNumMatrix[selectIndex + 1] = tempNum;
  865. this.cookieMatrix[selectIndex].texture = tempTexture2;
  866. this.cookieMatrix[selectIndex+1].texture = tempTexture1;
  867. TweenMax.from(this.cookieMatrix[selectIndex], 0.1, {x:this.cookieMatrixPos[selectIndex+1][0], onComplete: (function () {
  868. this.cookieMatrix[selectIndex].texture = tempTexture1;
  869. TweenMax.from(this.cookieMatrix[selectIndex], 0.1, {x:this.cookieMatrixPos[selectIndex+1][0]});
  870. }.bind(this))});
  871. TweenMax.from(this.cookieMatrix[selectIndex+1], 0.1, {x:this.cookieMatrixPos[selectIndex][0], onComplete:(function () {
  872. this.cookieMatrix[selectIndex+1].texture = tempTexture2;
  873. TweenMax.from(this.cookieMatrix[selectIndex+1], 0.1, {x:this.cookieMatrixPos[selectIndex][0], onComplete:(function(){
  874. this.canClick = true;
  875. }.bind(this))});
  876. }.bind(this))});
  877. this.lastEventTime = Date.now();
  878. this.giveHint = false;
  879. } else{//맞춰졌을 때
  880. this.chance--;
  881. if(this.fixArr1.length != 0) {
  882. this.combo++;
  883. this.totalCombo++;
  884. }
  885. if(this.fixArr2.length != 0) {
  886. this.combo++;
  887. this.totalCombo++;
  888. }
  889. if(this.combo>=15) {this.stageMode = 'superfever';}
  890. else if(this.combo>=5){
  891. this.stageMode = 'fever';
  892. this.callfevercnt = 0;
  893. } else{this.stageMode = 'normal';}
  894. this.lastTime = Date.now();
  895. this.restComboTime = 3;
  896. this.rangeChance();
  897. this.cookieMatrix[selectIndex].texture = tempTexture2;
  898. this.cookieMatrix[selectIndex + 1].texture = tempTexture1;
  899. TweenMax.from(this.cookieMatrix[selectIndex], 0.1, {x: this.cookieMatrixPos[selectIndex + 1][0], onComplete:(function () {
  900. for(var i=0; i<this.fixArr1.length; i++) this.cookieMatrix[this.fixArr1[i]].alpha = 0;
  901. }.bind(this))});
  902. TweenMax.from(this.cookieMatrix[selectIndex + 1], 0.1, {x: this.cookieMatrixPos[selectIndex][0], onComplete:(function () {
  903. for(var i=0; i<this.fixArr2.length; i++) this.cookieMatrix[this.fixArr2[i]].alpha = 0;
  904. }.bind(this))});
  905. //remember값 교환
  906. tempRemember = this.cookieMatrix[selectIndex].remember;
  907. this.cookieMatrix[selectIndex].remember = this.cookieMatrix[selectIndex+1].remember;
  908. this.cookieMatrix[selectIndex+1].remember = tempRemember;
  909. //경우에 상관없이 explode() 실행.. 객체 의미 없음
  910. TweenMax.from(this.cookieMatrix[selectIndex], 0.1, {onComplete:(function () {
  911. this.explode();
  912. }.bind(this))});
  913. }
  914. };
  915. gc.GameScene.prototype.swapUp = function (selectIndex) {
  916. var tempTexture1, tempTexture2;
  917. var tempRemember;
  918. //텍스쳐 저장
  919. tempTexture1 = this.cookieMatrix[selectIndex].texture;
  920. tempTexture2 = this.cookieMatrix[selectIndex-7].texture;
  921. //매칭 확인을 위해 쿠키 번호 바꾸기
  922. var tempNum = this.cookieNumMatrix[selectIndex];
  923. this.cookieNumMatrix[selectIndex] = this.cookieNumMatrix[selectIndex-7];
  924. this.cookieNumMatrix[selectIndex-7] = tempNum;
  925. //매칭 확인
  926. this.checkMatching2(selectIndex);
  927. this.fixArr1 = this.memories;
  928. this.itemIndex1 = this.itemIndex;
  929. this.checkMatching2(selectIndex-7);
  930. this.fixArr2 = this.memories;
  931. this.itemIndex2 = this.itemIndex;
  932. //맞는게 없을 때
  933. if((this.fixArr1.length == 0) && (this.fixArr2.length == 0)) {
  934. //쿠키 번호 복구
  935. tempNum = this.cookieNumMatrix[selectIndex];
  936. this.cookieNumMatrix[selectIndex] = this.cookieNumMatrix[selectIndex - 7];
  937. this.cookieNumMatrix[selectIndex - 7] = tempNum;
  938. this.cookieMatrix[selectIndex].texture = tempTexture2;
  939. this.cookieMatrix[selectIndex-7].texture = tempTexture1;
  940. TweenMax.from(this.cookieMatrix[selectIndex], 0.1, {y:this.cookieMatrixPos[selectIndex-7][1], onComplete: (function () {
  941. this.cookieMatrix[selectIndex].texture = tempTexture1;
  942. TweenMax.from(this.cookieMatrix[selectIndex], 0.1, {y:this.cookieMatrixPos[selectIndex-7][1]});
  943. }.bind(this))});
  944. TweenMax.from(this.cookieMatrix[selectIndex-7], 0.1, {y:this.cookieMatrixPos[selectIndex][1], onComplete:(function () {
  945. this.cookieMatrix[selectIndex-7].texture = tempTexture2;
  946. TweenMax.from(this.cookieMatrix[selectIndex-7], 0.1, {y:this.cookieMatrixPos[selectIndex][1], onComplete:(function(){
  947. this.canClick = true;
  948. }.bind(this))});
  949. }.bind(this))});
  950. this.lastEventTime = Date.now();
  951. this.giveHint = false;
  952. } else{//맞춰졌을 때
  953. this.chance--;
  954. if(this.fixArr1.length != 0) {
  955. this.combo++;
  956. this.totalCombo++;
  957. }
  958. if(this.fixArr2.length != 0) {
  959. this.combo++;
  960. this.totalCombo++;
  961. }
  962. if(this.combo>=15) {this.stageMode = 'superfever';}
  963. else if(this.combo>=5){
  964. this.stageMode = 'fever';
  965. this.callfevercnt = 0;
  966. } else{this.stageMode = 'normal';}
  967. this.lastTime = Date.now();
  968. this.restComboTime = 3;
  969. this.rangeChance();
  970. this.cookieMatrix[selectIndex].texture = tempTexture2;
  971. this.cookieMatrix[selectIndex-7].texture = tempTexture1;
  972. TweenMax.from(this.cookieMatrix[selectIndex], 0.1, {y:this.cookieMatrixPos[selectIndex-7][1], onComplete:(function () {
  973. for(var i=0; i<this.fixArr1.length; i++) this.cookieMatrix[this.fixArr1[i]].alpha = 0;
  974. }.bind(this))});
  975. TweenMax.from(this.cookieMatrix[selectIndex-7], 0.1, {y:this.cookieMatrixPos[selectIndex][1], onComplete:(function () {
  976. for(var i=0; i<this.fixArr2.length; i++) this.cookieMatrix[this.fixArr2[i]].alpha = 0;
  977. }.bind(this))});
  978. //remember값 교환
  979. tempRemember = this.cookieMatrix[selectIndex].remember;
  980. this.cookieMatrix[selectIndex].remember = this.cookieMatrix[selectIndex-7].remember;
  981. this.cookieMatrix[selectIndex-7].remember = tempRemember;
  982. //경우에 상관없이 explode() 실행.. 객체 의미 없음
  983. TweenMax.from(this.cookieMatrix[selectIndex], 0.1, {onComplete:(function () {
  984. this.explode();
  985. }.bind(this))});
  986. }
  987. };
  988. gc.GameScene.prototype.swapDown = function (selectIndex) {
  989. var tempTexture1, tempTexture2;
  990. var tempRemember;
  991. //텍스쳐 저장
  992. tempTexture1 = this.cookieMatrix[selectIndex].texture;
  993. tempTexture2 = this.cookieMatrix[selectIndex+7].texture;
  994. //매칭 확인을 위해 쿠키 번호 바꾸기
  995. var tempNum = this.cookieNumMatrix[selectIndex];
  996. this.cookieNumMatrix[selectIndex] = this.cookieNumMatrix[selectIndex+7];
  997. this.cookieNumMatrix[selectIndex+7] = tempNum;
  998. //매칭 확인
  999. this.checkMatching2(selectIndex);
  1000. this.fixArr1 = this.memories;
  1001. this.itemIndex1 = this.itemIndex;
  1002. this.checkMatching2(selectIndex+7);
  1003. this.fixArr2 = this.memories;
  1004. this.itemIndex2 = this.itemIndex;
  1005. //맞는게 없을 때
  1006. if((this.fixArr1.length == 0) && (this.fixArr2.length == 0)) {
  1007. //쿠키 번호 복구
  1008. tempNum = this.cookieNumMatrix[selectIndex];
  1009. this.cookieNumMatrix[selectIndex] = this.cookieNumMatrix[selectIndex + 7];
  1010. this.cookieNumMatrix[selectIndex + 7] = tempNum;
  1011. this.cookieMatrix[selectIndex].texture = tempTexture2;
  1012. this.cookieMatrix[selectIndex+7].texture = tempTexture1;
  1013. TweenMax.from(this.cookieMatrix[selectIndex], 0.1, {y:this.cookieMatrixPos[selectIndex+7][1], onComplete: (function () {
  1014. this.cookieMatrix[selectIndex].texture = tempTexture1;
  1015. TweenMax.from(this.cookieMatrix[selectIndex], 0.1, {y:this.cookieMatrixPos[selectIndex+7][1]});
  1016. }.bind(this))});
  1017. TweenMax.from(this.cookieMatrix[selectIndex+7], 0.1, {y:this.cookieMatrixPos[selectIndex][1], onComplete:(function () {
  1018. this.cookieMatrix[selectIndex+7].texture = tempTexture2;
  1019. TweenMax.from(this.cookieMatrix[selectIndex+7], 0.1, {y:this.cookieMatrixPos[selectIndex][1], onComplete:(function(){
  1020. this.canClick = true;
  1021. }.bind(this))});
  1022. }.bind(this))});
  1023. this.lastEventTime = Date.now();
  1024. this.giveHint = false;
  1025. } else{//맞춰졌을 때
  1026. this.chance--;
  1027. if(this.fixArr1.length != 0) {
  1028. this.combo++;
  1029. this.totalCombo++;
  1030. }
  1031. if(this.fixArr2.length != 0) {
  1032. this.combo++;
  1033. this.totalCombo++;
  1034. }
  1035. if(this.combo>=15) {this.stageMode = 'superfever';}
  1036. else if(this.combo>=5){
  1037. this.stageMode = 'fever';
  1038. this.callfevercnt = 0;
  1039. } else{this.stageMode = 'normal';}
  1040. this.lastTime = Date.now();
  1041. this.restComboTime = 3;
  1042. this.rangeChance();
  1043. this.cookieMatrix[selectIndex].texture = tempTexture2;
  1044. this.cookieMatrix[selectIndex + 7].texture = tempTexture1;
  1045. TweenMax.from(this.cookieMatrix[selectIndex], 0.1, {y: this.cookieMatrixPos[selectIndex + 7][1], onComplete:(function () {
  1046. for(var i=0; i<this.fixArr1.length; i++) this.cookieMatrix[this.fixArr1[i]].alpha = 0;
  1047. }.bind(this))});
  1048. TweenMax.from(this.cookieMatrix[selectIndex + 7], 0.1, {y: this.cookieMatrixPos[selectIndex][1], onComplete:(function () {
  1049. for(var i=0; i<this.fixArr2.length; i++) this.cookieMatrix[this.fixArr2[i]].alpha = 0;
  1050. }.bind(this))});
  1051. //remember값 교환
  1052. tempRemember = this.cookieMatrix[selectIndex].remember;
  1053. this.cookieMatrix[selectIndex].remember = this.cookieMatrix[selectIndex+7].remember;
  1054. this.cookieMatrix[selectIndex+7].remember = tempRemember;
  1055. //경우에 상관없이 explode() 실행.. 객체 의미 없음
  1056. TweenMax.from(this.cookieMatrix[selectIndex], 0.1, {onComplete:(function () {
  1057. this.explode();
  1058. }.bind(this))});
  1059. }
  1060. };
  1061. //폭발==============================================================================================
  1062. //더이상 터질게 없을 때
  1063. gc.GameScene.prototype.explode = function () {
  1064. var makeBomb = false;
  1065. var explodeEqual = false;
  1066. var explodeBomb = false;
  1067. this.explodetime = 0.3;
  1068. //= 아이템 체크
  1069. if(this.scanIndex != undefined) {
  1070. if (this.cookieNumMatrix[this.scanIndex] == 9) {explodeEqual = true;}
  1071. if (this.cookieNumMatrix[this.scanIndex] == 10) {explodeBomb = true;}
  1072. }
  1073. //크로스 아이템 이펙트
  1074. if(this.crossIndex != undefined){
  1075. this.crossEffect1.anchor.set(0.5);
  1076. this.crossEffect1.position.x = this.cookieMatrixPos[this.crossIndex][0];
  1077. this.crossEffect1.position.y = this.cookieMatrixPos[21][1];
  1078. this.crossEffect1.height = 720;
  1079. this.crossEffect2.anchor.set(0.5);
  1080. this.crossEffect2.position.x = this.cookieMatrixPos[3][0];
  1081. this.crossEffect2.position.y = this.cookieMatrixPos[this.crossIndex][1];
  1082. this.crossEffect2.height = 720;
  1083. this.crossEffect2.transform.rotation = Math.PI/2;
  1084. var crossMc = new gc.MovieClip('eraser_effect_00', 1, 7, 0.3);
  1085. crossMc.anchor.set(0.5);
  1086. crossMc.position.x = this.cookieMatrixPos[this.crossIndex][0];
  1087. crossMc.position.y = this.cookieMatrixPos[this.crossIndex][1];
  1088. crossMc.loop = false;
  1089. this.explodeContainer.addChild(this.crossEffect1);
  1090. this.explodeContainer.addChild(this.crossEffect2);
  1091. this.explodeContainer.addChild(crossMc);
  1092. crossMc.onComplete = function () {
  1093. gc.game.explodeContainer.removeChild(crossMc);
  1094. };
  1095. TweenMax.to(this.crossEffect1.scale, this.explodetime, {x:1, y:0.6, alpha:1});
  1096. TweenMax.to(this.crossEffect2.scale, this.explodetime, {x:1, y:0.6, alpha:1});
  1097. }
  1098. if(explodeBomb){
  1099. var bombMc = new gc.MovieClip('bomb_effect_00', 1, 9, 0.3);
  1100. bombMc.anchor.set(0.5);
  1101. bombMc.position.x = this.cookieMatrixPos[this.scanIndex][0];
  1102. bombMc.position.y = this.cookieMatrixPos[this.scanIndex][1];
  1103. bombMc.loop = false;
  1104. this.explodeContainer.addChild(bombMc);
  1105. }
  1106. //기본 폭발 이미지.. 모든 폭발에 적용
  1107. for(var i=0; i<this.cookieMatrix.length; i++){
  1108. if(this.cookieMatrix[i].flag == 0){
  1109. //폭탄아이템 생성 조건
  1110. this.bombAnerge++;
  1111. if(this.bombAnerge >= this.bombfull) {
  1112. makeBomb = true;
  1113. this.setBombItem();
  1114. this.bombAnerge -= this.bombfull;
  1115. }
  1116. var explodeMc = new gc.MovieClip('clear_effect_00', 1, 9, 0.4);
  1117. explodeMc.anchor.set(0.5);
  1118. explodeMc.position.x = this.cookieMatrixPos[i][0];
  1119. explodeMc.position.y = this.cookieMatrixPos[i][1];
  1120. explodeMc.alpha = 1;
  1121. explodeMc.loop = false;
  1122. if(!explodeEqual) {this.explodeContainer.addChild(explodeMc);
  1123. }else{this.explodeContainer2.addChild(explodeMc);}
  1124. }
  1125. }
  1126. this.scanIndex = undefined;
  1127. //mask 폭탄 게이지 보이는 화면
  1128. var gap = this.bombgauge.height/this.bombfull;
  1129. if(this.thing == undefined) {
  1130. this.thing = new PIXI.Graphics();
  1131. this.thing.position.x = 0;
  1132. this.thing.position.y = 0;
  1133. this.bombgauge.addChild(this.thing);
  1134. this.bombgauge.mask = this.thing;
  1135. this.thing.lineStyle(0);
  1136. this.thing.clear();
  1137. this.thing.beginFill(0xffffff, 1);
  1138. this.maskRect = this.thing.drawRect(-14, -this.bombgauge.height+gap*(this.bombfull-this.bombAnerge), this.bombgauge.width, this.bombgauge.height, 10);
  1139. this.thing.endFill();
  1140. }
  1141. //점수 부여
  1142. for(var i=0; i<this.cookieMatrix.length; i++){
  1143. if(this.cookieMatrix[i].flag == 0) {this.addScore(i)}
  1144. }
  1145. //폭발 사운드 처리
  1146. if(!explodeEqual && !this.test)this.manageSound();
  1147. this.settingItem();
  1148. //점수 합산
  1149. if(!this.test) DataManager.point('point', this.addPoint, Date.now().toString()); // 획득 점수 저장
  1150. this.score += this.addPoint;
  1151. this.addPoint = 0;
  1152. this.scoreTxt.setValue(this.score);
  1153. //터지는 이미지 시간 작용
  1154. this.explodetime = 0.3;
  1155. if(this.crossIndex != undefined) {this.crossIndex = undefined;}
  1156. if(explodeEqual) {this.explodetime = 0.15*(this.remembers.length+2);}
  1157. if(makeBomb) {
  1158. //폭탄 생성 이펙트
  1159. this.cookieMatrix[this.randBombIndex].alpha = 0;
  1160. var fakebomb = new PIXI.Sprite.fromFrame('bomb_0002.png');
  1161. fakebomb.anchor.set(0.5);
  1162. fakebomb.x = this.bomb.x;
  1163. fakebomb.y = this.bomb.y;
  1164. this.addChild(fakebomb);
  1165. this.restComboTime = 3;
  1166. TweenMax.to(fakebomb.scale, 0.3, {x:1.3, y:1.3, onComplete:(function () {
  1167. TweenMax.to(fakebomb.scale, 0.2, {x:1, y:1, onComplete:(function () {
  1168. TweenMax.to(fakebomb, 1, {rotation:90, x:this.cookieMatrixPos[this.randBombIndex][0], y:this.cookieMatrixPos[this.randBombIndex][1], onComplete:(function () {
  1169. this.removeChild(fakebomb);
  1170. this.cookieMatrix[this.randBombIndex].alpha = 1;
  1171. this.explodeOver();
  1172. }).bind(this)},0);
  1173. }).bind(this)});
  1174. }).bind(this)});
  1175. //TweenMax.to(fakebomb, 1.2, {rotation:90, x:this.cookieMatrixPos[this.randBombIndex][0], y:this.cookieMatrixPos[this.randBombIndex][1], onComplete:(function () {
  1176. // this.removeChild(fakebomb);
  1177. // this.cookieMatrix[this.randBombIndex].alpha = 1;
  1178. // this.explodeOver();
  1179. //}).bind(this)},0);
  1180. this.bomb.texture = PIXI.Texture.fromFrame('bomb_0002.png');
  1181. TweenMax.to(this.maskRect, 0.1, {y:-this.bombgauge.height, onComplete:(function () {
  1182. TweenMax.to(this.maskRect, 0.1, {y:-this.bombgauge.height+gap*this.bombfull, onComplete:(function () {
  1183. TweenMax.to(this.maskRect, 0.1, {y:-this.bombgauge.height+gap*(this.bombfull-this.bombAnerge), onComplete:(function () {
  1184. this.bomb.texture = PIXI.Texture.fromFrame('bomb_0001.png');
  1185. }).bind(this)});
  1186. }).bind(this)});
  1187. }).bind(this)});
  1188. } else {
  1189. TweenMax.to(this.maskRect, 0.1, {y:-this.bombgauge.height+gap*(this.bombfull-this.bombAnerge)});
  1190. this.explodeOver();
  1191. }
  1192. //폭발 이미지 제거
  1193. TweenMax.to(this.cookieMatrix[0], this.explodetime, {onComplete: (function() {
  1194. this.explodeContainer.removeChildren();
  1195. if(this.explodeContainer2 != undefined)this.explodeContainer2.removeChildren();
  1196. }.bind(this))});
  1197. //메달 획득 확인
  1198. this.manageMedal();
  1199. };
  1200. //폭발 후 쿠키 떨어뜨리는 역할
  1201. gc.GameScene.prototype.explodeOver = function () {
  1202. //터질때 발생하는 작업 전체 종료 후 쿠키 떨구기
  1203. TweenMax.to(this.cookieMatrix[0], this.explodetime, {onComplete: (function() {
  1204. this.dropCookie();
  1205. }.bind(this))});
  1206. };
  1207. //소리===================================================================================================
  1208. gc.GameScene.prototype.manageSound = function () {
  1209. if(this.prestageMode == this.stageMode){
  1210. this.exceptSound = false;
  1211. this.basicSound();
  1212. }else{
  1213. //모드 변화 시
  1214. if(this.stageMode == 'superfever' || this.stageMode == 'fever') {
  1215. if(!this.exceptSound) {this.exceptSound = true;}
  1216. else{GD.soundPlay('sound_match_fever');}
  1217. } else{
  1218. //모모타임일 때
  1219. if(this.stageMode == 'momotime') {this.momoSound();}
  1220. else{this.basicSound();}//피버모드가 풀렸을 때
  1221. }
  1222. }
  1223. };
  1224. gc.GameScene.prototype.basicSound = function () {
  1225. //기본 블럭 사운드
  1226. if(!this.useItem){
  1227. if (this.stageMode == 'normal') {
  1228. if (this.combo == 1) GD.soundPlay('sound_match_1');
  1229. else if (this.combo == 3)GD.soundPlay('sound_match_2');
  1230. else GD.soundPlay('sound_match_3');
  1231. } else {GD.soundPlay('sound_match_fever');}
  1232. return;
  1233. }else{
  1234. //아이템 사운드
  1235. GD.soundPlay('sound_use');
  1236. this.useItem = false;
  1237. return;
  1238. }
  1239. };
  1240. gc.GameScene.prototype.momoSound = function () {
  1241. //기본 블럭 사운드
  1242. if(!this.useItem){
  1243. if (this.prestageMode == 'normal') {
  1244. if (this.combo == 1) GD.soundPlay('sound_match_1');
  1245. else if (this.combo == 3) GD.soundPlay('sound_match_2');
  1246. else GD.soundPlay('sound_match_3');
  1247. } else {GD.soundPlay('sound_match_fever')};
  1248. return;
  1249. }else{
  1250. //아이템 사운드
  1251. GD.soundPlay('sound_use');
  1252. this.useItem = false;
  1253. return;
  1254. }
  1255. };
  1256. //점수===================================================================================================
  1257. gc.GameScene.prototype.addScore = function (i) {
  1258. if(this.stageMode == 'normal') {this.normalPoint(i);}
  1259. else if(this.stageMode == 'fever'){this.feverPoint(i);}
  1260. else if(this.stageMode == 'superfever'){this.superfeverPoint(i);}
  1261. else { //모모타임 점수
  1262. if(this.prestageMode == 'normal'){this.normalPoint(i);}
  1263. else if(this.prestageMode == 'fever'){this.feverPoint(i);}
  1264. else if(this.prestageMode == 'superfever'){this.superfeverPoint(i);}
  1265. }
  1266. };
  1267. gc.GameScene.prototype.normalPoint = function (i) {
  1268. if(this.cookieNumMatrix[i]<7) {this.addPoint += 100;}
  1269. else {
  1270. if(this.cookieNumMatrix[i] == 10) {this.addPoint += 450;}
  1271. if(this.cookieNumMatrix[i] == 9) {this.addPoint += 350;}
  1272. if(this.cookieNumMatrix[i] == 8) {this.addPoint += 250;}
  1273. }
  1274. };
  1275. gc.GameScene.prototype.feverPoint = function (i) {
  1276. if(this.cookieNumMatrix[i]<7) {this.addPoint += 200;}
  1277. else {
  1278. if(this.cookieNumMatrix[i] == 10) {this.addPoint += 600;}
  1279. if(this.cookieNumMatrix[i] == 9) {this.addPoint += 550;}
  1280. if(this.cookieNumMatrix[i] == 8) {this.addPoint += 350;}
  1281. }
  1282. }
  1283. gc.GameScene.prototype.superfeverPoint = function (i) {
  1284. if(this.cookieNumMatrix[i]<7) {
  1285. this.addPoint += 300;}
  1286. else {
  1287. if(this.cookieNumMatrix[i] == 10) {this.addPoint += 900;}
  1288. if(this.cookieNumMatrix[i] == 9) {this.addPoint += 700;}
  1289. if(this.cookieNumMatrix[i] == 8) {this.addPoint += 500;}
  1290. }
  1291. };
  1292. //아이템====================================================================================
  1293. gc.GameScene.prototype.settingItem = function(){
  1294. if(this.itemIndex1 != undefined){
  1295. if(this.fixArr1.length >=5){
  1296. this.setEqualItem('origin');
  1297. } else if(this.fixArr1.length >=4){
  1298. this.setCrossItem('origin');
  1299. }
  1300. this.cookieMatrix[this.itemIndex1].alpha = 1;
  1301. this.cookieMatrix[this.itemIndex1].flag = 1;
  1302. this.itemIndex1 = undefined;
  1303. }
  1304. if(this.itemIndex2 != undefined){
  1305. if(this.fixArr2.length >=5){
  1306. this.setEqualItem('other');
  1307. } else if(this.fixArr2.length >=4){
  1308. this.setCrossItem('other');
  1309. }
  1310. this.cookieMatrix[this.itemIndex2].alpha = 1;
  1311. this.cookieMatrix[this.itemIndex2].flag = 1;
  1312. this.itemIndex2 = undefined;
  1313. }
  1314. };
  1315. gc.GameScene.prototype.setBombItem = function(){
  1316. this.randBombIndex = parseInt(Math.random()*14);
  1317. if(this.cookieMatrix[this.randBombIndex].flag != 0 && this.cookieNumMatrix[this.randBombIndex] <7) {
  1318. this.cookieMatrix[this.randBombIndex].texture = PIXI.Texture.fromFrame('bomb_item_0001.png');
  1319. this.cookieNumMatrix[this.randBombIndex] = 10;
  1320. this.matchItemSize(this.randBombIndex);
  1321. }else this.setBombItem();
  1322. };
  1323. gc.GameScene.prototype.setEqualItem = function(thing){
  1324. var itemName = 'cookie2_000';
  1325. var fullItemName;
  1326. switch (thing) {
  1327. case 'origin':
  1328. this.cookieMatrix[this.itemIndex1].remember = this.cookieNumMatrix[this.itemIndex1];
  1329. fullItemName = itemName+this.cookieMatrix[this.itemIndex1].remember+'.png';
  1330. this.cookieMatrix[this.itemIndex1].texture = PIXI.Texture.fromFrame(fullItemName);
  1331. this.cookieNumMatrix[this.itemIndex1] = 9;
  1332. this.matchItemSize(this.itemIndex1);
  1333. break;
  1334. case 'other':
  1335. this.cookieMatrix[this.itemIndex2].remember = this.cookieNumMatrix[this.itemIndex2];
  1336. fullItemName = itemName+this.cookieMatrix[this.itemIndex2].remember+'.png';
  1337. this.cookieMatrix[this.itemIndex2].texture = PIXI.Texture.fromFrame(fullItemName);
  1338. this.cookieNumMatrix[this.itemIndex2] = 9;
  1339. this.matchItemSize(this.itemIndex2);
  1340. break;
  1341. }
  1342. };
  1343. gc.GameScene.prototype.setCrossItem = function(thing){
  1344. switch (thing) {
  1345. case 'origin':
  1346. this.cookieMatrix[this.itemIndex1].texture = PIXI.Texture.fromFrame('eraser_0001.png');
  1347. this.cookieNumMatrix[this.itemIndex1] = 8;
  1348. this.matchItemSize(this.itemIndex1);
  1349. break;
  1350. case 'other':
  1351. this.cookieMatrix[this.itemIndex2].texture = PIXI.Texture.fromFrame('eraser_0001.png');
  1352. this.cookieNumMatrix[this.itemIndex2] = 8;
  1353. this.matchItemSize(this.itemIndex2);
  1354. break;
  1355. }
  1356. };
  1357. gc.GameScene.prototype.matchItemSize = function (index) {
  1358. var min = 2;
  1359. var max = 0;
  1360. for(var i=0; i<this.cookieMatrix.length; i++){
  1361. if(this.cookieMatrix[i].scale.x < min){min = this.cookieMatrix[i].scale.x}
  1362. }
  1363. if(min == 0.85){
  1364. for(var i=0; i<this.cookieMatrix.length; i++){
  1365. if(this.cookieMatrix[i].scale.x > max){max = this.cookieMatrix[i].scale.x}
  1366. }
  1367. }
  1368. if(min != 0.85) {
  1369. this.cookieMatrix[index].scale.x = min;
  1370. this.cookieMatrix[index].scale.y = min;
  1371. }else {
  1372. this.cookieMatrix[index].scale.x = max;
  1373. this.cookieMatrix[index].scale.y = max;
  1374. }
  1375. this.getItemIndex();
  1376. };
  1377. gc.GameScene.prototype.bump = function () {
  1378. if(this.itemIndexes.length > 0) {
  1379. if(this.cookieMatrix[this.itemIndexes[0]].scale.x >= 1 || this.cookieMatrix[this.itemIndexes[0]].scale.x <= 0.85){
  1380. if(this.cookieMatrix[this.itemIndexes[0]].scale.x > 1) this.cookieMatrix[this.itemIndexes[0]].scale.x = 1;
  1381. if(this.cookieMatrix[this.itemIndexes[0]].scale.x < 0.85) this.cookieMatrix[this.itemIndexes[0]].scale.x = 0.85;
  1382. this.bumpscale *= -1;
  1383. }
  1384. this.cookieMatrix[this.itemIndexes[0]].scale.x += this.bumpscale;
  1385. this.cookieMatrix[this.itemIndexes[0]].scale.y += this.bumpscale;
  1386. }
  1387. for(var i=0; i<this.itemIndexes.length; i++){
  1388. this.cookieMatrix[this.itemIndexes[i]].scale.x = this.cookieMatrix[this.itemIndexes[0]].scale.x
  1389. this.cookieMatrix[this.itemIndexes[i]].scale.y = this.cookieMatrix[this.itemIndexes[0]].scale.x;
  1390. }
  1391. };
  1392. gc.GameScene.prototype.getItemIndex = function () {
  1393. this.itemIndexes = [];
  1394. for(var i=0; i<this.cookieNumMatrix.length; i++){
  1395. if(this.cookieNumMatrix[i]>6){
  1396. this.itemIndexes.push(i);
  1397. }
  1398. }
  1399. };
  1400. gc.GameScene.prototype.actBomb = function(actIndex){
  1401. this.bombCombo++;
  1402. //본인
  1403. this.cookieMatrix[actIndex].flag = 0;
  1404. this.cookieMatrix[actIndex].remember = 0;
  1405. this.cookieMatrix[actIndex].alpha = 0;
  1406. //첫번째 열이 아님
  1407. if(actIndex%7 != 0) {
  1408. //왼쪽 위
  1409. if(actIndex-7-1 >= 0) {
  1410. //대상이 아이템 블럭이 아님
  1411. if(this.cookieNumMatrix[actIndex - 7 - 1] < 7) {
  1412. this.cookieMatrix[actIndex - 7 - 1].flag = 0;
  1413. this.cookieMatrix[actIndex - 7 - 1].alpha = 0;
  1414. this.cookieMatrix[actIndex - 7 - 1].remember = 0;
  1415. }
  1416. }
  1417. //왼쪽 아래
  1418. if(actIndex+7-1 <= 48) {
  1419. //대상이 아이템 블럭이 아님
  1420. if(this.cookieNumMatrix[actIndex + 7 - 1] < 7) {
  1421. this.cookieMatrix[actIndex + 7 - 1].flag = 0;
  1422. this.cookieMatrix[actIndex + 7 - 1].alpha = 0;
  1423. this.cookieMatrix[actIndex + 7 - 1].remember = 0;
  1424. }
  1425. }
  1426. //왼쪽
  1427. if(actIndex-1 >= 0) {
  1428. //대상이 아이템 블럭이 아님
  1429. if(this.cookieNumMatrix[actIndex - 1] < 7) {
  1430. this.cookieMatrix[actIndex - 1].flag = 0;
  1431. this.cookieMatrix[actIndex - 1].alpha = 0;
  1432. this.cookieMatrix[actIndex - 1].remember = 0;
  1433. }
  1434. }
  1435. }
  1436. //위
  1437. if(actIndex-7 >= 0){
  1438. if(this.cookieNumMatrix[actIndex - 7] < 7) {
  1439. this.cookieMatrix[actIndex - 7].flag = 0;
  1440. this.cookieMatrix[actIndex - 7].alpha = 0;
  1441. this.cookieMatrix[actIndex - 7].remember = 0;
  1442. }
  1443. }
  1444. //아래
  1445. if(actIndex+7 <= 48){
  1446. if(this.cookieNumMatrix[actIndex + 7] < 7) {
  1447. this.cookieMatrix[actIndex + 7].flag = 0;
  1448. this.cookieMatrix[actIndex + 7].alpha = 0;
  1449. this.cookieMatrix[actIndex + 7].remember = 0;
  1450. }
  1451. }
  1452. //오른쪽 끝 열이 아님
  1453. if(actIndex%7 != 6) {
  1454. //오른쪽 위
  1455. if (actIndex - 7 + 1 >= 0) {
  1456. //대상이 아이템 블럭이 아님
  1457. if (this.cookieNumMatrix[actIndex - 7 + 1] < 7) {
  1458. this.cookieMatrix[actIndex - 7 + 1].flag = 0;
  1459. this.cookieMatrix[actIndex - 7 + 1].alpha = 0;
  1460. this.cookieMatrix[actIndex - 7 + 1].remember = 0;
  1461. }
  1462. }
  1463. //오른쪽 아래
  1464. if (actIndex + 7 + 1 <= 48) {
  1465. //대상이 아이템 블럭이 아님
  1466. if (this.cookieNumMatrix[actIndex + 7 + 1] < 7) {
  1467. this.cookieMatrix[actIndex + 7 + 1].flag = 0;
  1468. this.cookieMatrix[actIndex + 7 + 1].alpha = 0;
  1469. this.cookieMatrix[actIndex + 7 + 1].remember = 0;
  1470. }
  1471. }
  1472. //오른쪽
  1473. if (actIndex + 1 <= 48) {
  1474. //대상이 아이템 블럭이 아님
  1475. if (this.cookieNumMatrix[actIndex + 1] < 7) {
  1476. this.cookieMatrix[actIndex + 1].flag = 0;
  1477. this.cookieMatrix[actIndex + 1].alpha = 0;
  1478. this.cookieMatrix[actIndex + 1].remember = 0;
  1479. }
  1480. }
  1481. }
  1482. //아이템 사용시 강조 이펙트 제거를 위함
  1483. this.stopItemAccentEffect();
  1484. this.playItemAccentEffect();
  1485. this.explode();
  1486. };
  1487. gc.GameScene.prototype.explodeEqual = function () {
  1488. var explodeMc = new gc.MovieClip('clear_effect_00', 1, 9, 0.4);
  1489. explodeMc.onComplete = function() {gc.game.explodeContainer2.removeChild(explodeMc);};
  1490. explodeMc.anchor.set(0.5);
  1491. explodeMc.position.x = this.cookieMatrixPos[this.remembers[0]][0];
  1492. explodeMc.position.y = this.cookieMatrixPos[this.remembers[0]][1];
  1493. explodeMc.alpha = 1;
  1494. explodeMc.scale.x = 1.3;
  1495. explodeMc.scale.y = 1.3;
  1496. explodeMc.loop = false;
  1497. this.explodeContainer2.addChild(explodeMc);
  1498. };
  1499. gc.GameScene.prototype.rise = function () {
  1500. var fakeCookie = new PIXI.Sprite.fromFrame('cookie_1_0001.png');
  1501. fakeCookie.texture = this.cookieMatrix[this.remembers[0]].texture;
  1502. fakeCookie.anchor.set(0.5);
  1503. fakeCookie.position.x = this.cookieMatrixPos[this.remembers[0]][0];
  1504. fakeCookie.position.y = this.cookieMatrixPos[this.remembers[0]][1];
  1505. this.explodeContainer2.addChild(fakeCookie);
  1506. this.manageSound();
  1507. this.cookieMatrix[this.remembers[0]].alpha = 0;
  1508. this.cookieMatrix[this.remembers[0]].flag = 0;
  1509. this.cookieMatrix[this.remembers[0]].remember = 0;
  1510. TweenMax.to(fakeCookie.scale, 0.1,{x:1.15, y:1.15, onComplete:(function () {
  1511. this.explodeEqual();
  1512. this.remembers.splice(0, 1);
  1513. if(this.remembers.length>0) setTimeout(this.rise.bind(this),100);
  1514. else{
  1515. this.explodeContainer2.removeChildren();
  1516. this.explode();
  1517. this.shadow.alpha = 0;
  1518. }
  1519. }).bind(this)});
  1520. };
  1521. gc.GameScene.prototype.actEqual = function(actIndex){
  1522. this.remembers = [];
  1523. this.tempRemembers = []; // 쿠키가 커진 후 크기 돌려놓기 위함
  1524. //본인
  1525. this.cookieMatrix[actIndex].flag = 0;
  1526. this.remembers.push(actIndex);
  1527. for (var i = 0; i < this.cookieNumMatrix.length; i++) {
  1528. if (this.cookieNumMatrix[i] == this.cookieMatrix[actIndex].remember) {
  1529. this.cookieMatrix[i].flag = 0;
  1530. this.remembers.push(i);
  1531. this.tempRemembers.push(i);
  1532. }
  1533. }
  1534. this.shadow.alpha = 1;
  1535. //아이템 사용시 강조 이펙트 제거를 위함
  1536. this.stopItemAccentEffect();
  1537. this.playItemAccentEffect();
  1538. //순서대로 커지게 만들기
  1539. this.rise();
  1540. };
  1541. gc.GameScene.prototype.actCross = function(actIndex){
  1542. this.champagneCombo++;
  1543. //본인
  1544. this.cookieMatrix[actIndex].flag = 0;
  1545. this.cookieMatrix[actIndex].remember = 0;
  1546. this.cookieMatrix[actIndex].alpha = 0;
  1547. var colIndex = actIndex%7; //몇번째 열인지 체크
  1548. for(var i=0; i<7; i++){
  1549. if(this.cookieMatrix[i * 7 + colIndex].flag != 0) {
  1550. if (this.cookieNumMatrix[i * 7 + colIndex] < 7) {
  1551. this.cookieMatrix[i * 7 + colIndex].flag = 0;
  1552. this.cookieMatrix[i * 7 + colIndex].alpha = 0;
  1553. this.cookieMatrix[i * 7 + colIndex].remember = 0;
  1554. }
  1555. }
  1556. }
  1557. var rowIndex = Math.floor(actIndex/7); //몇번째 열인지 체크
  1558. for(var i=0; i<7; i++){
  1559. if(this.cookieMatrix[rowIndex * 7 + i].flag != 0) {
  1560. if (this.cookieNumMatrix[rowIndex * 7 + i] < 7) {
  1561. this.cookieMatrix[rowIndex * 7 + i].flag = 0;
  1562. this.cookieMatrix[rowIndex * 7 + i].alpha = 0;
  1563. this.cookieMatrix[rowIndex * 7 + i].remember = 0;
  1564. }
  1565. }
  1566. }
  1567. //아이템 사용시 강조 이펙트 제거를 위함
  1568. this.stopItemAccentEffect();
  1569. this.playItemAccentEffect();
  1570. this.explode();
  1571. };
  1572. //쿠키 메우기==================================================================
  1573. gc.GameScene.prototype.dropCookie = function(){
  1574. var index;
  1575. var lineCount = 0; //한 열의 빈 블럭 수 카운트
  1576. var dropCount = 0; //한 열의 내려온 블럭 수 카운트(완전히 내려온 후 카운트)
  1577. var fullCount = 0; //떨어질 블럭 전체 수 카운트(빈 공간 + 새로 떨어질 블럭 수)
  1578. var dropIndexes = []; //떨어질 블럭 인덱스
  1579. for(var i=0; i<7; i++){
  1580. lineCount = 0;
  1581. //기존 블럭 내리기
  1582. for(var j=6; j>=0; j--){
  1583. index = j*7+i;
  1584. if(this.cookieMatrix[index].flag == 0){
  1585. lineCount++;
  1586. this.cookieMatrix[index].alpha = 1;
  1587. this.cookieMatrix[index].flag = 1;
  1588. }else{
  1589. if(lineCount > 0) {
  1590. fullCount++;
  1591. dropIndexes.push(index + lineCount * 7);
  1592. //내려올 블럭: (index + lineCount * 7), 복사해올 블럭: (index)
  1593. this.cookieMatrix[index + lineCount * 7].texture = this.cookieMatrix[index].texture;
  1594. this.cookieMatrix[index + lineCount * 7].remember = this.cookieMatrix[index].remember;
  1595. this.cookieMatrix[index].remember = 0;
  1596. this.cookieNumMatrix[index + lineCount * 7] = this.cookieNumMatrix[index];
  1597. this.cookieNumMatrix[index] = 0;
  1598. //아이템이 내려올 때 크기 복사
  1599. if(this.cookieNumMatrix[index + lineCount * 7] > 7) this.matchItemSize(index + lineCount * 7);
  1600. else{
  1601. this.cookieMatrix[index + lineCount * 7].scale.x = 0.85;
  1602. this.cookieMatrix[index + lineCount * 7].scale.y = 0.85;
  1603. }
  1604. TweenMax.from(this.cookieMatrix[index + lineCount * 7], 0.3, {
  1605. y: this.cookieMatrixPos[index][1], onComplete: (function () {
  1606. dropCount++;
  1607. if(dropCount == fullCount && !this.canClick) {
  1608. //이전 스테이지모드 저장
  1609. if(this.stageMode != 'momotime') this.prestageMode = this.stageMode;
  1610. this.checkAgain();
  1611. }
  1612. else {
  1613. this.lastEventTime = Date.now();
  1614. }
  1615. }.bind(this))
  1616. });
  1617. }
  1618. }
  1619. }
  1620. //새로운 쿠키 내리기
  1621. for(var j= lineCount-1; j>=0; j--){
  1622. index = j*7+i;
  1623. fullCount++;
  1624. this.cookieNumMatrix[index] = parseInt(Math.random()*6+1);
  1625. this.cookieMatrix[index].texture = PIXI.Texture.fromFrame('cookie_000'+ this.cookieNumMatrix[index] + '.png');
  1626. this.cookieMatrix[index].scale.x = 0.85;
  1627. this.cookieMatrix[index].scale.y = 0.85;
  1628. this.cookieMatrix[index].remember = 0;
  1629. this.cookieMatrix[index].alpha = 1;
  1630. this.cookieMatrix[index].flag = 1;
  1631. TweenMax.from(this.cookieMatrix[index], 0.3, {y:this.gameTable.position.y+this.cookieMatrix[index].height/2, onComplete: (function (){
  1632. dropCount++;
  1633. if(dropCount == fullCount && !this.canClick) {
  1634. //이전 스테이지모드 저장
  1635. if(this.stageMode != 'momotime') this.prestageMode = this.stageMode;
  1636. this.checkAgain();
  1637. }
  1638. else {
  1639. this.lastEventTime = Date.now();
  1640. }
  1641. }.bind(this))});
  1642. }
  1643. }
  1644. //내려올 블럭이 아이템일 경우 아이템 강조 이펙트도 같이 움직이기 위함
  1645. this.stopItemAccentEffect();
  1646. this.playItemAccentEffect();
  1647. this.getItemIndex();
  1648. //객체 의미 없음
  1649. TweenMax.from(this.cookieMatrix[0], 0.3, {onComplete: (function (){
  1650. this.restComboTime = 3; //=아이템 블럭이 많으면 다음 콤보까지 시간 부족.. 블럭 다 떨어지고 초기화
  1651. //힌트 저장을 위함
  1652. this.giveHint = false;
  1653. if(!this.checkMatching1() && this.playGame) {
  1654. this.checkAgain();
  1655. this.findHint();
  1656. }
  1657. ////게임 종료
  1658. //if(this.chance<=0 && !this.haveEmpty) this.setGameOver();
  1659. }.bind(this))});
  1660. };
  1661. gc.GameScene.prototype.checkAgain = function(){
  1662. for(var i=0; i<this.cookieMatrixPos.length; i++) {
  1663. this.cookieMatrix[i].position.x = this.cookieMatrixPos[i][0];
  1664. this.cookieMatrix[i].position.y = this.cookieMatrixPos[i][1];
  1665. }
  1666. this.checkMatching3();
  1667. };
  1668. //아이템 강조 이펙트 설정======================================================================
  1669. gc.GameScene.prototype.playItemAccentEffect = function () {
  1670. for(var i=0; i<this.cookieNumMatrix.length; i++){
  1671. if(this.cookieNumMatrix[i] > 7 && this.cookieMatrix[i].flag == 1){
  1672. this.itemEffectMc[i].alpha = 1;
  1673. this.itemEffectMc[i].play();
  1674. }
  1675. }
  1676. };
  1677. gc.GameScene.prototype.stopItemAccentEffect = function () {
  1678. for(var i=0; i<this.itemEffectMc.length; i++) {
  1679. this.itemEffectMc[i].stop();
  1680. this.itemEffectMc[i].alpha = 0;
  1681. }
  1682. };
  1683. //매칭확인=============================================================================
  1684. //처음 그릴때 매칭 되는 거 없게 하기 위함
  1685. gc.GameScene.prototype.checkMatching1= function(){
  1686. //가로 체크
  1687. var num1 = undefined;
  1688. var num2 = undefined;
  1689. var countRow = 0;
  1690. var countCol = 0;
  1691. var index1 = undefined;
  1692. var index2 = undefined;
  1693. //가로(행) 매칭 체크
  1694. for(var i=0; i<7; i++){
  1695. num1 = this.cookieNumMatrix[i*7];
  1696. countRow = 0;
  1697. for(var j=0; j<7; j++){
  1698. index1 = j+i*7;
  1699. if (num1 <7 && this.cookieNumMatrix[index1] == num1) {
  1700. countRow++;
  1701. } else {
  1702. num1 = this.cookieNumMatrix[index1];
  1703. countRow = 1;
  1704. }
  1705. if (countRow >= 3) {
  1706. return true;
  1707. }
  1708. }
  1709. }
  1710. //세로(열) 매칭 체크
  1711. for(var i=0; i<7; i++){
  1712. countCol = 0;
  1713. num2 = this.cookieNumMatrix[i];
  1714. for(var j=0; j<7; j++){
  1715. index2 = j*7+i;
  1716. if (num2<7 && this.cookieNumMatrix[index2] == num2) {
  1717. countCol++;
  1718. } else {
  1719. num2 = this.cookieNumMatrix[index2];
  1720. countCol = 1;
  1721. }
  1722. if (countCol >= 3) {
  1723. return true;
  1724. }
  1725. }
  1726. }
  1727. return false;
  1728. };
  1729. //스와핑 후 매칭 확인
  1730. gc.GameScene.prototype.checkMatching2 = function (checkingIndex){
  1731. this.l_c = 0;
  1732. this.r_c = 0;
  1733. this.u_c = 0;
  1734. this.d_c = 0;
  1735. this.itemIndex = undefined;
  1736. this.memories = [];
  1737. if(this.cookieNumMatrix[checkingIndex] < 7) {
  1738. //왼쪽 파트
  1739. for (var i = checkingIndex; i >= Math.floor(checkingIndex / 7) * 7; i--) {
  1740. if (this.cookieNumMatrix[i] == this.cookieNumMatrix[checkingIndex]) {
  1741. this.l_c++;
  1742. } else {
  1743. break;
  1744. }
  1745. }
  1746. //오른쪽 파트
  1747. for (var i = checkingIndex; i <= Math.floor(checkingIndex / 7 + 1) * 7 - 1; i++) {
  1748. if (this.cookieNumMatrix[i] == this.cookieNumMatrix[checkingIndex]) {
  1749. this.r_c++;
  1750. } else {
  1751. break;
  1752. }
  1753. }
  1754. //위쪽 파트
  1755. for (var i = checkingIndex; i >= 0; i -= 7) {
  1756. if (this.cookieNumMatrix[i] == this.cookieNumMatrix[checkingIndex]) {
  1757. this.u_c++;
  1758. } else {
  1759. break;
  1760. }
  1761. }
  1762. //아래쪽 파트
  1763. for (var i = checkingIndex; i < this.cookieMatrix.length; i += 7) {
  1764. if (this.cookieNumMatrix[i] == this.cookieNumMatrix[checkingIndex]) {
  1765. this.d_c++;
  1766. } else {
  1767. break;
  1768. }
  1769. }
  1770. }
  1771. //매칭 쿠키 확인
  1772. if(this.l_c+this.r_c -1 >= 3){ //맞춰진 가로 수가 3개 이상이면
  1773. //가로 4개 이상
  1774. if(this.l_c+this.r_c -1 >= 4) this.itemIndex = checkingIndex;
  1775. for(var i=checkingIndex-this.l_c+1; i <= checkingIndex + this.r_c-1; i++){
  1776. this.cookieMatrix[i].flag = 0;
  1777. this.memories.push(i);
  1778. }
  1779. if(this.u_c+this.d_c-1 >= 3){ //맞춰진 세로 수가 3개 이상이면
  1780. for(var i=checkingIndex-(this.u_c-1)*7; i <= checkingIndex+(this.d_c-1)*7; i+=7){
  1781. if(i != checkingIndex) {
  1782. this.cookieMatrix[i].flag = 0;
  1783. this.memories.push(i);
  1784. }
  1785. }
  1786. //십자 모양
  1787. this.itemIndex = checkingIndex;
  1788. }
  1789. return true;
  1790. }else if(this.l_c+this.r_c -1 < 3 && this.u_c+this.d_c-1 >= 3) { //가로 개수가 3개 미만이고, 세로 개수가 3개 이상
  1791. for(var i=checkingIndex-(this.u_c-1)*7; i <= checkingIndex+(this.d_c-1)*7; i+=7){
  1792. this.cookieMatrix[i].flag = 0;
  1793. this.memories.push(i);
  1794. }
  1795. //세로 4개 이상
  1796. if(this.memories.length>=4) this.itemIndex = checkingIndex;
  1797. return true;
  1798. }else{ //맞는게 없을 때
  1799. return false;
  1800. }
  1801. };
  1802. //모든 쿠키 내리고 나서 다시 매칭 확인
  1803. gc.GameScene.prototype.checkMatching3 = function(){
  1804. this.bundle = []; //매칭되는 모든 배열을 저장하기 위한 배열
  1805. for (var j = 0; j < this.cookieMatrix.length; j++) {
  1806. this.l_c = 0;
  1807. this.r_c = 0;
  1808. this.u_c = 0;
  1809. this.d_c = 0;
  1810. this.itemIndex = undefined;
  1811. this.memories = [];
  1812. if (this.cookieMatrix[j].flag != 0 && this.cookieNumMatrix[j]<7) {
  1813. //왼쪽 파트
  1814. for (var i = j; i >= Math.floor(j / 7) * 7; i--) {
  1815. if (this.cookieNumMatrix[i] == this.cookieNumMatrix[j]) {
  1816. this.l_c++;
  1817. } else {
  1818. break;
  1819. }
  1820. }
  1821. //오른쪽 파트
  1822. for (var i = j; i <= Math.floor(j / 7 + 1) * 7 - 1; i++) {
  1823. if (this.cookieNumMatrix[i] == this.cookieNumMatrix[j]) {
  1824. this.r_c++;
  1825. } else {
  1826. break;
  1827. }
  1828. }
  1829. //위쪽 파트
  1830. for (var i = j; i >= 0; i -= 7) {
  1831. if (this.cookieNumMatrix[i] == this.cookieNumMatrix[j]) {
  1832. this.u_c++;
  1833. } else {
  1834. break;
  1835. }
  1836. }
  1837. //아래쪽 파트
  1838. for (var i = j; i < this.cookieMatrix.length; i += 7) {
  1839. if (this.cookieNumMatrix[i] == this.cookieNumMatrix[j]) {
  1840. this.d_c++;
  1841. } else {
  1842. break;
  1843. }
  1844. }
  1845. //매칭 쿠키 확인
  1846. if (this.l_c + this.r_c - 1 >= 3) { //맞춰진 가로 수가 3개 이상이면
  1847. for (var i = j - this.l_c + 1; i <= j + this.r_c - 1; i++) {
  1848. this.memories.push(i);
  1849. }
  1850. if (this.u_c + this.d_c - 1 >= 3) { //맞춰진 세로 수가 3개 이상이면
  1851. for (var i = j - (this.u_c - 1) * 7; i <= j + (this.d_c - 1) * 7; i += 7) {
  1852. if (i != j) {
  1853. this.memories.push(i);
  1854. }
  1855. }
  1856. }
  1857. } else if (this.l_c + this.r_c - 1 < 3 && this.u_c + this.d_c - 1 >= 3) { //가로 개수가 3개 미만이고, 세로 개수가 3개 이상
  1858. for (var i = j - (this.u_c - 1) * 7; i <= j + (this.d_c - 1) * 7; i += 7) {
  1859. this.memories.push(i);
  1860. }
  1861. }
  1862. }
  1863. this.bundle[j] = this.memories;
  1864. }
  1865. var bundleCount = 0;
  1866. for (var i = 0; i < this.bundle.length; i++) {
  1867. if (this.bundle[i].length == 0) {
  1868. bundleCount++;
  1869. }
  1870. }
  1871. //맞춰진 블럭이 있을때
  1872. if (bundleCount != this.bundle.length) this.searchingMaxLength();
  1873. else {
  1874. this.haveEmpty = false;
  1875. for (var i = 0; i < this.cookieMatrix.length; i++) {
  1876. if (this.cookieMatrix[i].flag == 0) this.haveEmpty = true;
  1877. }
  1878. if (this.haveEmpty) this.explode();
  1879. else {
  1880. if (this.playGame) {
  1881. this.canClick = true;
  1882. }
  1883. else {
  1884. if (this.itemOver) {
  1885. this.PlayOver();//게임이 완전히 끝났을 때
  1886. } else {
  1887. this.lastPang();//횟수는 끝났으나 아이템이 남아있으면 터뜨리기}
  1888. }
  1889. }
  1890. //게임 종료
  1891. if (this.playGame && this.chance <= 0 && !this.haveEmpty) this.setGameOver();
  1892. }
  1893. }
  1894. };
  1895. gc.GameScene.prototype.PlayOver = function () {
  1896. this.gameoverImg.anchor.set(0.5);
  1897. this.gameoverImg.x = GD.width/2;
  1898. this.gameoverImg.y = GD.height/2;
  1899. this.addChild(this.gameoverImg);
  1900. TweenMax.to(this.gameoverImg.scale, 0.5, {x:1, y:1, onComplete:(function () {
  1901. TweenMax.to(this.gameoverImg.scale, 0.3, {x:1.2, y:1.2});
  1902. }).bind(this)});
  1903. TweenMax.from(this.gameoverImg, 0.5, {y:GD.height+this.gameoverImg.height});
  1904. this.giveHint = true;
  1905. this.canClick = false;
  1906. this.normalmomo.stop();
  1907. this.fevermomo.stop();
  1908. this.normalshushu.stop();
  1909. this.fevershushu.stop();
  1910. this.fevereffect1.stop();
  1911. this.fevereffect2.stop();
  1912. GD.soundPlay('sound_gameover');
  1913. setTimeout(this.onResult.bind(this),1000);
  1914. };
  1915. //타임업 사운드가 끝나고 결과창으로 이동
  1916. gc.GameScene.prototype.onResult = function () {
  1917. GD.bgmStop();
  1918. gc.game = null;
  1919. GD.commonOption.finish(this.score);
  1920. };
  1921. //맞춰진 배열에서 가장 긴 배열에 아이템을 넣기 위한 함수
  1922. gc.GameScene.prototype.searchingMaxLength = function(){
  1923. var maxLength = 0;
  1924. var maxLengthIndex = undefined;
  1925. for(var i=0; i<this.bundle.length; i++){
  1926. if(this.bundle[i].length > maxLength) {
  1927. maxLength = this.bundle[i].length;
  1928. maxLengthIndex = i;
  1929. }
  1930. }
  1931. for (var i = 0; i < this.bundle[maxLengthIndex].length; i++) {
  1932. this.cookieMatrix[this.bundle[maxLengthIndex][i]].flag = 0;
  1933. this.cookieMatrix[this.bundle[maxLengthIndex][i]].alpha = 0;
  1934. this.cookieMatrix[this.bundle[maxLengthIndex][i]].remember = 0;
  1935. }
  1936. if(this.bundle[maxLengthIndex].length >= 4) {
  1937. if (this.bundle[maxLengthIndex].length >= 5) {
  1938. this.cookieMatrix[maxLengthIndex].remember = this.cookieNumMatrix[maxLengthIndex];
  1939. var itemName = 'cookie2_000';
  1940. var fullItemName = itemName+this.cookieMatrix[maxLengthIndex].remember+'.png';
  1941. this.cookieMatrix[maxLengthIndex].texture = PIXI.Texture.fromFrame(fullItemName);
  1942. this.cookieNumMatrix[maxLengthIndex] = 9;
  1943. }else if (this.bundle[maxLengthIndex].length >= 4) {
  1944. this.cookieMatrix[maxLengthIndex].texture = PIXI.Texture.fromFrame('eraser_0001.png');
  1945. this.cookieNumMatrix[maxLengthIndex] = 8;
  1946. }
  1947. this.cookieMatrix[maxLengthIndex].flag = 1;
  1948. this.cookieMatrix[maxLengthIndex].alpha = 1;
  1949. }
  1950. this.combo++;
  1951. this.totalCombo++;
  1952. if(this.stageMode != 'momotime') {
  1953. if(this.combo>=15) {this.stageMode = 'superfever';}
  1954. else if(this.combo>=5){
  1955. this.stageMode = 'fever';
  1956. this.callfevercnt = 0;
  1957. } else{this.stageMode = 'normal';}
  1958. }
  1959. this.lastTime = Date.now();
  1960. this.restComboTime = 3;
  1961. this.checkMatching3();
  1962. };
  1963. //피버모드=======================================================================================================
  1964. gc.GameScene.prototype.setFeverText = function () {
  1965. this.superfeverText.anchor.set(0.5);
  1966. this.superfeverText.position.x = gc.width / 2;
  1967. this.superfeverText.position.y = this.gameTable.position.y;
  1968. this.superfeverText.scale.x = 0;
  1969. this.superfeverText.scale.y = 0;
  1970. this.addChild(this.superfeverText);
  1971. this.feverText.anchor.set(0.5);
  1972. this.feverText.position.x = gc.width / 2;
  1973. this.feverText.position.y = this.gameTable.position.y;
  1974. this.feverText.scale.x = 0;
  1975. this.feverText.scale.y = 0;
  1976. this.addChild(this.feverText);
  1977. };
  1978. gc.GameScene.prototype.setFever = function () {
  1979. if(!this.pauseMode) {
  1980. var now = Date.now();
  1981. if (this.lastTime == undefined) this.lastTime = now;
  1982. if (this.playGame) {
  1983. if (this.restComboTime > 0) {this.restComboTime -= (now - this.lastTime) / 1000;}
  1984. else {
  1985. this.combo = 0;
  1986. this.restComboTime = 0;
  1987. this.lastTime = undefined;
  1988. if(this.stageMode != 'normal') this.prestageMode = this.stageMode;
  1989. this.stageMode = 'normal';
  1990. this.callfevercnt = 0;
  1991. }
  1992. if (this.prestageMode != this.stageMode && this.callfevercnt == 0) {this.actFever();}
  1993. this.lastTime = now;
  1994. }
  1995. }else this.lastTime = Date.now();
  1996. };
  1997. gc.GameScene.prototype.actFever = function () {
  1998. this.callfevercnt++;
  1999. if(this.stageMode == 'normal'){
  2000. this.normalMode();
  2001. this.gameBG.texture = GD.loader.resources['game_bg'].texture;
  2002. this.fevereffect1.alpha = 0;
  2003. this.fevereffect2.alpha = 0;
  2004. } else{
  2005. this.otherMode();
  2006. this.actfeverEffect();
  2007. }
  2008. };
  2009. gc.GameScene.prototype.actfeverEffect = function(){
  2010. if(this.test){
  2011. this.fevereffect1.y = -200;
  2012. this.fevereffect2.y = -200;
  2013. }else {
  2014. this.gameBG.texture = GD.loader.resources['game_bg_fever'].texture;
  2015. this.fevereffect1.y = 465;
  2016. this.fevereffect2.y = 345;
  2017. }
  2018. this.fevereffect1.alpha = 1;
  2019. this.fevereffect2.alpha = 1;
  2020. this.fevereffect2.scale.y = 1.5;
  2021. if(!this.test)if (this.stageMode != 'momotime') GD.soundPlay('sound_fever');
  2022. if (this.stageMode == 'superfever') {
  2023. this.superfeverText.alpha = 1;
  2024. TweenMax.to(this.superfeverText.scale, 0.5, {
  2025. x: 1, y: 1, alpha: 1, onComplete: (function () {
  2026. TweenMax.to(this.superfeverText, 0.7, {
  2027. onComplete: (function () {
  2028. this.superfeverText.scale.x = 0;
  2029. this.superfeverText.scale.y = 0;
  2030. this.superfeverText.alpha = 0;
  2031. }).bind(this)
  2032. });
  2033. }).bind(this)
  2034. });
  2035. } else if (this.stageMode == 'fever') {
  2036. this.feverText.alpha = 1;
  2037. TweenMax.to(this.feverText.scale, 0.5, {
  2038. x: 1, y: 1, alpha: 1, onComplete: (function () {
  2039. TweenMax.to(this.feverText, 0.7, {
  2040. onComplete: (function () {
  2041. this.feverText.scale.x = 0;
  2042. this.feverText.scale.y = 0;
  2043. this.feverText.alpha = 0;
  2044. if(this.test) {
  2045. this.test = false;
  2046. this.stageMode = 'normal';
  2047. }
  2048. }).bind(this)
  2049. });
  2050. }).bind(this)
  2051. });
  2052. }
  2053. };
  2054. // 일시정지
  2055. gc.GameScene.prototype.pause = function(){
  2056. this.pauseMode = true;
  2057. this.setInteractive(false);
  2058. };
  2059. // 게임진행
  2060. gc.GameScene.prototype.resume = function(){
  2061. this.pauseMode = false;
  2062. this.setInteractive(true);
  2063. };
  2064. // 버튼 이벤트 설정
  2065. gc.GameScene.prototype.setInteractive = function(bool){
  2066. for(var i=0; i<this.cookieMatrix.length; i++){ this.cookieMatrix[i].interactive = bool;}
  2067. if(this.pauseMode){
  2068. this.fevereffect1.stop();
  2069. this.fevereffect2.stop();
  2070. this.normalmomo.stop();
  2071. this.fevermomo.stop();
  2072. this.normalshushu.stop();
  2073. this.fevershushu.stop();
  2074. if(this.giveHint){
  2075. this.hintMc1.stop();
  2076. this.hintMc2.stop();
  2077. }
  2078. }else{
  2079. this.fevereffect1.play();
  2080. this.fevereffect2.play();
  2081. if(this.stageMode == 'normal') {this.normalMode();}
  2082. else{this.otherMode();}
  2083. if(this.giveHint){
  2084. this.hintMc1.play();
  2085. this.hintMc2.play();
  2086. }
  2087. }
  2088. };
  2089. //메달(업적) 관리==================================================================================================
  2090. gc.GameScene.prototype.manageMedal = function () {
  2091. if(this.totalCombo >= 100 && !this.getMedal4) {
  2092. DataManager.addMedal(4);
  2093. this.getMedal4 = true;
  2094. } else if(this.totalCombo >= 3 && !this.getMedal1) {
  2095. DataManager.addMedal(1);
  2096. this.getMedal1 = true;
  2097. }else if(this.champagneCombo >= 10 && !this.getMedal2) {
  2098. DataManager.addMedal(2);
  2099. this.getMedal2 = true;
  2100. }else if(this.bombCombo >= 10 && !this.getMedal3) {
  2101. DataManager.addMedal(3);
  2102. this.getMedal3 = true;
  2103. }
  2104. };
  2105. gc.GameScene.getInstance = function(){
  2106. if(!gc.game) gc.game = new gc.GameScene();
  2107. return gc.game;
  2108. };
  2109. module.exports = gc;