GC.js 63 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790
  1. import * as PIXI from './pixi';
  2. import GD from './human.min'
  3. import { TweenMax } from './TweenMax.min'
  4. import { pixelRatioX, pixelRatioY, windowWidth, windowHeight } from './fitConfig';
  5. var gWidth = windowWidth * pixelRatioX
  6. var gHeight = windowHeight * pixelRatioY
  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. TextStyle1: {
  17. fontFamily: 'Arial',
  18. fontSize: '36px',
  19. fontStyle: 'italic',
  20. fontWeight: 'bold',
  21. fill: '#F7EDCA',
  22. stroke: '#4a1850',
  23. strokeThickness: 5,
  24. dropShadow: true,
  25. dropShadowColor: '#000000',
  26. dropShadowAngle: Math.PI / 6,
  27. dropShadowDistance: 6,
  28. wordWrap: true,
  29. wordWrapWidth: 440
  30. },
  31. TextStyle2: {
  32. fontFamily: 'Arial',
  33. fontSize: '36px',
  34. fill: '#FFFFFF',
  35. stroke: '#4a1850',
  36. strokeThickness: 2,
  37. dropShadow: true,
  38. dropShadowColor: '#000000',
  39. dropShadowAngle: Math.PI / 6,
  40. dropShadowDistance: 6,
  41. wordWrap: true,
  42. wordWrapWidth: 440
  43. },
  44. TextStyle3: {
  45. fontFamily: 'Arial',
  46. fontSize: '25px',
  47. fill: '#FFFFFF',
  48. stroke: '#4a1850',
  49. strokeThickness: 2,
  50. //dropShadow : true,
  51. //dropShadowColor : '#000000',
  52. //dropShadowAngle : Math.PI / 6,
  53. //dropShadowDistance : 6,
  54. wordWrap: true,
  55. wordWrapWidth: 440,
  56. align: 'center'
  57. }
  58. };
  59. /**
  60. * MovieClip
  61. * Created by juho on 2016-03-29.
  62. */
  63. gc.MovieClip = function (fileName, start, end, speed, repeat) {
  64. PIXI.extras.AnimatedSprite.call(this, this.getRepeatTexture(fileName, start, end, repeat));
  65. this.animationSpeed = speed;
  66. this.play();
  67. };
  68. gc.MovieClip.constructor = gc.MovieClip;
  69. gc.MovieClip.prototype = Object.create(PIXI.extras.AnimatedSprite.prototype);
  70. gc.MovieClip.prototype.setAnimation = function (fileName, start, end, speed, repeat) {
  71. this.textures = this.getRepeatTexture(fileName, start, end, repeat);
  72. this.animationSpeed = speed;
  73. };
  74. gc.MovieClip.prototype.getRepeatTexture = function (fileName, start, end, repeat) {
  75. var textures = [];
  76. var i = repeat || 1;
  77. while (i--) {
  78. textures = textures.concat(this.getTexture(fileName, start, end));
  79. }
  80. return textures;
  81. };
  82. gc.MovieClip.prototype.getTexture = function (fileName, start, end) {
  83. start = start || 1;
  84. var textures = [],
  85. i = end - start + 1,
  86. j = start;
  87. while (i--) {
  88. if (j < 10) { textures.push(PIXI.Texture.fromFrame(fileName + '0' + j + '.png')); }
  89. else { textures.push(PIXI.Texture.fromFrame(fileName + j + '.png')); }
  90. j++;
  91. }
  92. return textures;
  93. };
  94. gc.MovieClip.prototype.updateTransform = function () {
  95. PIXI.extras.AnimatedSprite.prototype.updateTransform.call(this);
  96. };
  97. /**
  98. * Created by juho on 2016-03-30.
  99. */
  100. gc.NumberText = function (fileName, align, space, iconName, iconAlign, commaName) {
  101. this.CENTER = 'center';
  102. this.RIGHT = 'right';
  103. this.LEFT = 'left';
  104. this.value = 0;
  105. this.isChange = false;
  106. this.list = [];
  107. this.tmpList = [];
  108. this.fileName = fileName;
  109. this.align = align;
  110. this.space = space;
  111. this.iconName = iconName;
  112. this.iconAlign = iconAlign;
  113. this.commaName = commaName;
  114. this.icon = null;
  115. PIXI.Container.call(this);
  116. this.container = new PIXI.Container();
  117. this.addChild(this.container);
  118. this.setValue(0);
  119. };
  120. gc.NumberText.constructor = gc.NumberText;
  121. gc.NumberText.prototype = Object.create(PIXI.Container.prototype);
  122. gc.NumberText.prototype.setValue = function (value) {
  123. this.value = value;
  124. this.isChange = true;
  125. };
  126. gc.NumberText.prototype.getNumberSprite = function (num) {
  127. var sprite, name;
  128. if (num != 10) name = this.fileName + '0' + num + '.png';
  129. else name = this.fileName + num + '.png';
  130. if (this.tmpList.length > 0) {
  131. sprite = this.tmpList.shift();
  132. sprite.texture = PIXI.Texture.fromFrame(name);
  133. } else {
  134. sprite = PIXI.Sprite.fromFrame(name);
  135. }
  136. return sprite;
  137. };
  138. gc.NumberText.prototype.getCommaSprite = function () {
  139. var sprite, name = this.commaName + '.png';
  140. if (this.tmpList.length > 0) {
  141. sprite = this.tmpList.shift();
  142. sprite.texture = PIXI.Texture.fromFrame(name);
  143. } else {
  144. sprite = PIXI.Sprite.fromFrame(name);
  145. }
  146. return sprite;
  147. };
  148. gc.NumberText.prototype.removeAll = function () {
  149. var txt, i = this.list.length;
  150. while (i--) {
  151. txt = this.list.shift();
  152. this.tmpList.push(txt);
  153. }
  154. if (this.container) this.container.removeChildren();
  155. };
  156. gc.NumberText.prototype.updateTransform = function () {
  157. if (this.isChange) {
  158. this.removeAll();
  159. var numStr = (this.commaName) ? Util.comma(this.value) : this.value.toString();
  160. var index = 0, txt, str,
  161. space = 0,
  162. i = numStr.length;
  163. if (this.iconName) {
  164. if (!this.icon) this.icon = PIXI.Sprite.fromFrame(this.iconName);
  165. this.container.addChild(this.icon);
  166. if (this.iconAlign == 'left') {
  167. space += this.icon.width + this.space;
  168. }
  169. }
  170. while (i--) {
  171. str = numStr.substr(index, 1);
  172. if (str == '.') {
  173. txt = this.getCommaSprite();
  174. } else {
  175. txt = this.getNumberSprite(parseInt(str) + 1);
  176. }
  177. txt.x = space;
  178. space += txt.width;
  179. if (i > 0) space += this.space;
  180. index++;
  181. this.container.addChild(txt);
  182. this.list[i] = txt;
  183. }
  184. if (this.iconAlign == 'right') {
  185. this.icon.x = space;
  186. space += this.icon.width + this.space;
  187. }
  188. if (this.align == this.CENTER) {
  189. this.container.x = -space / 2;
  190. } else if (this.align == this.RIGHT) {
  191. this.container.x = -space;
  192. }
  193. this.isChange = false;
  194. }
  195. PIXI.Container.prototype.updateTransform.call(this);
  196. };
  197. /**
  198. * Created by admin on 2016-10-24.
  199. */
  200. gc.GameScene = function () {
  201. PIXI.Container.call(this);
  202. var gap = 5;
  203. this.mapmatrixXpos = [];
  204. this.mapmatrixYpos = [];
  205. for (var i = 0; i < 6; i++) this.mapmatrixXpos[i] = 30 + 53 + (106 + gap) * i;
  206. for (var i = 0; i < 8; i++) this.mapmatrixYpos[i] = 1140 - 110 - (106 + gap) * i;
  207. this.card = [];
  208. this.flipmc = [];
  209. this.fliplightmc = [];
  210. this.explodemc = [];
  211. this.declareObjects();
  212. this.manageEvent();
  213. };
  214. gc.GameScene.constructor = gc.GameScene;
  215. gc.GameScene.prototype = Object.create(PIXI.Container.prototype);
  216. gc.GameScene.prototype.declareObjects = function () {
  217. //텍스트 이미지
  218. this.textimg = new PIXI.Sprite.fromFrame('start.png');
  219. this.three = new PIXI.Sprite.fromFrame('count_3.png');
  220. this.two = new PIXI.Sprite.fromFrame('count_2.png');
  221. this.one = new PIXI.Sprite.fromFrame('count_1.png');
  222. //배경에 필히 붙어있는 기본 UI
  223. this.gamebg = new PIXI.Sprite(GD.loader.resources['game_bg1'].texture);
  224. this.skipbtn = new PIXI.Sprite.fromFrame('timebar_button.png');
  225. this.fevereffectbg = new PIXI.Sprite.fromFrame('feverlight1.png');
  226. this.fevereffect_text = new PIXI.Sprite.fromFrame('feverfont.png');
  227. this.dangerffectbar = new PIXI.Sprite.fromFrame('warning_bar.png');
  228. this.dangerffect_text = new PIXI.Sprite.fromFrame('warning.png');
  229. this.dangereffect_skeleton = new PIXI.Sprite.fromFrame('warning_s1.png');
  230. this.danger_shadow = new PIXI.Sprite.fromFrame('warning_bg.png');
  231. this.gametimebarbg = new PIXI.Sprite.fromFrame('game_timebarBg.png');
  232. this.gametimebar = new PIXI.Sprite.fromFrame('game_timebar.png');
  233. this.timermask = new PIXI.Graphics();
  234. this.timermask.clear();
  235. this.timermask.beginFill(0xffffff, 1);
  236. //this.timerrect = this.timermask.drawRoundedRect(this.gametimebar.x-this.gametimebar.width/2, this.gametimebar.y-this.gametimebar.height/2, this.gametimebar.width,this.gametimebar.height, 20);
  237. this.timerrect = this.timermask.drawRoundedRect(this.gametimebar.x - this.gametimebar.width * 1.5, this.gametimebar.y - this.gametimebar.height / 2, this.gametimebar.width, this.gametimebar.height, 20);
  238. this.timermask.endFill();
  239. this.gametimebar.mask = this.timermask;
  240. this.levelnumimg = new gc.NumberText('basicNum_00', 'center', 0);
  241. this.scorenumimg = new gc.NumberText('basicNum_00', 'left', -5);
  242. this.missionnumimg = new gc.NumberText('basicNum_00', 'center', 0);
  243. //컨테이너(레이어)
  244. this.cardContainer = new PIXI.Container();
  245. this.movieclipContainer = new PIXI.Container();
  246. this.explodeContainer = new PIXI.Container();
  247. this.bgeffectContainer = new PIXI.Container();
  248. this.textContainer = new PIXI.Container();
  249. //카드 생성
  250. var s1 = [];//카드
  251. var s2 = [];//카드 뒷면 mc
  252. var s3 = [];//라이트 mc
  253. var s4 = [];//폭발 mc
  254. var s5 = [];
  255. for (var i = 0; i < this.mapmatrixXpos.length; i++) {
  256. s1 = [];
  257. s2 = [];
  258. s3 = [];
  259. s4 = [];
  260. for (var j = 0; j < this.mapmatrixYpos.length; j++) {
  261. s1.push(new PIXI.Sprite.fromFrame('blockOpen_0_0001.png'));
  262. s2.push(new gc.MovieClip('blockOpen_0_00', 1, 3, 2));
  263. s3.push(new gc.MovieClip('blockOpenLight_00', 1, 4, 2));
  264. s4.push(new gc.MovieClip('match_effect_00', 1, 11, 1));
  265. }
  266. this.card.push(s1);
  267. this.flipmc.push(s2);
  268. this.fliplightmc.push(s3);
  269. this.explodemc.push(s4);
  270. }
  271. this.attachObjects();
  272. };
  273. gc.GameScene.prototype.attachObjects = function () {
  274. //배경에 기본으로 붙어있는
  275. this.addChild(this.gamebg);
  276. this.gamebg.addChild(this.gametimebarbg);
  277. this.gamebg.addChild(this.gametimebar);
  278. this.gametimebar.addChild(this.timermask);
  279. this.gamebg.addChild(this.skipbtn);
  280. this.gamebg.addChild(this.levelnumimg);
  281. this.gamebg.addChild(this.scorenumimg);
  282. this.gamebg.addChild(this.missionnumimg);
  283. //컨테이너 부착
  284. this.addChild(this.cardContainer);
  285. this.addChild(this.movieclipContainer);
  286. this.addChild(this.explodeContainer);
  287. this.addChild(this.bgeffectContainer);
  288. this.addChild(this.textContainer);
  289. this.bgeffectContainer.addChild(this.fevereffect_text);
  290. this.bgeffectContainer.addChild(this.fevereffectbg);
  291. this.bgeffectContainer.addChild(this.dangerffectbar);
  292. this.bgeffectContainer.addChild(this.dangerffect_text);
  293. this.bgeffectContainer.addChild(this.dangereffect_skeleton);
  294. this.bgeffectContainer.addChild(this.danger_shadow);
  295. this.textContainer.addChild(this.textimg);
  296. this.textContainer.addChild(this.three);
  297. this.textContainer.addChild(this.two);
  298. this.textContainer.addChild(this.one);
  299. for (var i = 0; i < this.mapmatrixXpos.length; i++) {
  300. for (var j = 0; j < this.mapmatrixYpos.length; j++) {
  301. this.card[i][j].interactive = false;
  302. this.setCardAction(i, j);//카드를 눌렸을 때의 작동
  303. this.cardContainer.addChild(this.card[i][j]);
  304. this.movieclipContainer.addChild(this.flipmc[i][j]);
  305. this.movieclipContainer.addChild(this.fliplightmc[i][j]);
  306. this.explodeContainer.addChild(this.explodemc[i][j]);
  307. }
  308. }
  309. };
  310. gc.GameScene.prototype.setScore = function (incase) {
  311. this.addpoint = 50 + (20 * this.level - 1);
  312. this.addpoint += this.matchcnt * 100;
  313. if (incase == 'hint') this.addpoint = 0;
  314. if (incase == 'bomb') this.addpoint = 300;
  315. if (this.fever) this.addpoint *= 2;
  316. GD.DataManager.point('point', gc.game.addpoint, Date.now().toString()); // 획득 점수 저장
  317. this.score += this.addpoint;
  318. this.scorenumimg.setValue(this.score);
  319. }
  320. gc.GameScene.prototype.manageEvent = function () {
  321. };
  322. gc.GameScene.prototype.init = function () {
  323. //console.log('init gamescene');
  324. this.getmedal1 = false;
  325. this.getmedal2 = false;
  326. this.getmedal3 = false;//4는 누적이므로 플래그 필요 없음
  327. this.isbgm = true;
  328. this.start = false;
  329. this.choice = [false, false];
  330. this.choicecardindex = [];
  331. this.checkmatch = false;
  332. this.matchresult = false;//매칭 결과..맞춤, 못맞춤
  333. this.flipwaitrate = 0.1;//카드가 뒤집히고 나서 사라지거나 다시 뒤집힐 시간
  334. this.waittimer = true;//작업중일 때 시간 멈춰두기 위한 타이머
  335. this.gameover = false;
  336. this.stageclear = false;
  337. this.matchrate = 2;
  338. this.matchcnt = 0;
  339. this.match = false; //콤보 유지 여부 확인 flag
  340. this.flip = false;//카드가 뒤집히는 중인지
  341. this.drop = false;//카드가 떨어지는 중인지
  342. this.increase = false;//카드가 올라와야 하는지
  343. this.insituation = false;//피버모드 혹은 위험 상태
  344. this.indanger = false;//층이 7층 이상
  345. this.fever = false;//4콤보 부터
  346. this.pausegame = false;
  347. this.makeItem = false; //아이템을 만들 수 있는지
  348. this.inccnt = 0; //올라온 층 수
  349. this.usehint = false;
  350. this.hintrate = 2;//힌트로 카드를 보여줄 시간
  351. this.hintindex = [];//선택한 힌트 인덱스
  352. this.bombindex = [];//선택한 힌트 인덱스
  353. this.setBasicUiPos();
  354. this.setStartValue();//초기 시작 값 설정
  355. this.setCard();
  356. this.setRandCardType();
  357. this.countdown = false;
  358. this.isdangersound = false;
  359. this.blockCardActive();
  360. this.resetChoice();
  361. this.timer = setInterval(this.GameTimer.bind(this), 33.333);
  362. };
  363. gc.GameScene.prototype.setBasicUiPos = function () {
  364. //console.log('init ui pos');
  365. //텍스트 이미지 위치
  366. this.textimg.anchor.set(0.5);
  367. this.textimg.x = gc.width / 2;
  368. this.textimg.y = gc.height / 2;
  369. this.textimg.scale.x = 0;
  370. this.textimg.scale.y = 0;
  371. this.three.anchor.set(0.5);
  372. this.three.x = gc.width / 2;
  373. this.three.y = gc.height / 2;
  374. this.two.anchor.set(0.5);
  375. this.two.x = this.three.x;
  376. this.two.y = this.three.y;
  377. this.one.anchor.set(0.5);
  378. this.one.x = this.three.x;
  379. this.one.y = this.three.y;
  380. //타이머 위치
  381. this.gametimebarbg.anchor.set(0.5);
  382. this.gametimebarbg.x = gc.width / 2;
  383. this.gametimebarbg.y = 1170;
  384. this.gametimebar.anchor.set(0.5);
  385. this.gametimebar.position = this.gametimebarbg;
  386. //스킵버튼
  387. this.skipbtn.anchor.set(0.5);
  388. this.skipbtn.x = this.gametimebarbg.x + this.gametimebarbg.width / 2 - 20;
  389. this.skipbtn.y = this.gametimebarbg.y;
  390. this.skipbtn.interactive = false;
  391. //숫자 이미지 위치
  392. this.levelnumimg.x = 170;
  393. this.levelnumimg.y = 20;
  394. this.scorenumimg.x = this.levelnumimg.x - 10;
  395. this.scorenumimg.y = this.levelnumimg.y + 55;
  396. this.missionnumimg.x = 500;
  397. this.missionnumimg.y = this.levelnumimg.y;
  398. //배경 이펙트
  399. this.fevereffect_text.anchor.set(0.5);
  400. this.fevereffect_text.alpha = 0;
  401. this.fevereffect_text.x = gc.width / 2;
  402. this.fevereffect_text.y = 300;
  403. this.fevereffectbg.alpha = 0;
  404. this.dangerffectbar.anchor.set(0.5);
  405. this.dangerffectbar.x = gc.width / 2;
  406. this.dangerffectbar.y = 165;
  407. this.dangerffectbar.scale.y = 0.95;
  408. this.dangerffectbar.alpha = 0;
  409. this.dangerffect_text.anchor.set(0.5);
  410. this.dangerffect_text.alpha = 0;
  411. this.dangerffect_text.x = this.dangerffectbar.x;
  412. this.dangerffect_text.y = this.dangerffectbar.y;
  413. this.dangereffect_skeleton.anchor.set(0.5);
  414. this.dangereffect_skeleton.x = this.dangerffect_text.x;
  415. this.dangereffect_skeleton.y = this.dangerffect_text.y;
  416. this.dangereffect_skeleton.alpha = 0;
  417. this.danger_shadow.alpha = 0;
  418. //카드 위치
  419. for (var i = 0; i < this.mapmatrixXpos.length; i++) {
  420. for (var j = 0; j < this.mapmatrixYpos.length; j++) {
  421. this.card[i][j].anchor.set(0.5);
  422. this.card[i][j].x = this.mapmatrixXpos[i];
  423. this.card[i][j].y = this.mapmatrixYpos[j];
  424. this.flipmc[i][j].anchor.set(0.5);
  425. this.flipmc[i][j].loop = false;
  426. this.flipmc[i][j].stop();
  427. this.flipmc[i][j].x = this.mapmatrixXpos[i];
  428. this.flipmc[i][j].y = this.mapmatrixYpos[j];
  429. this.flipmc[i][j].alpha = 0;
  430. this.fliplightmc[i][j].anchor.set(0.5);
  431. this.fliplightmc[i][j].loop = false;
  432. this.fliplightmc[i][j].stop();
  433. this.fliplightmc[i][j].x = this.mapmatrixXpos[i];
  434. this.fliplightmc[i][j].y = this.mapmatrixYpos[j];
  435. this.fliplightmc[i][j].alpha = 0;
  436. this.explodemc[i][j].anchor.set(0.5);
  437. this.explodemc[i][j].loop = false;
  438. this.explodemc[i][j].stop();
  439. this.explodemc[i][j].x = this.mapmatrixXpos[i];
  440. this.explodemc[i][j].y = this.mapmatrixYpos[j];
  441. this.explodemc[i][j].alpha = 0;
  442. }
  443. }
  444. this.skipButtonAction();
  445. };
  446. gc.GameScene.prototype.skipButtonAction = function () {
  447. if (gc.IS_MOBILE) {
  448. this.skipbtn.touchend = (function (e) {
  449. e.stopPropagation();
  450. this.skipButtonActive();
  451. }).bind(this);
  452. } else {
  453. this.skipbtn.mouseup = this.skipbtn.touchend = (function (e) {
  454. e.stopPropagation();
  455. this.skipButtonActive();
  456. }).bind(this);
  457. }
  458. };
  459. gc.GameScene.prototype.skipButtonActive = function () {
  460. //console.log('안눌려지게 했지!!!!!!!');
  461. //if(this.start && !this.flip && !this.drop && !this.waittimer && !this.pausegame && !this.stageclear && !this.gameover) {
  462. // GD.soundPlay('sound_skip_bt');
  463. //
  464. // this.setLeftTime();
  465. // this.increaseFloor();//층 올리기 함수
  466. // this.increase = false;
  467. //}
  468. };
  469. gc.GameScene.prototype.setStartValue = function () {
  470. this.level = 1;
  471. this.score = 0;
  472. this.addpoint = 0;
  473. this.levelnumimg.setValue(this.level);
  474. this.scorenumimg.setValue(this.score);
  475. this.basetime;
  476. this.setMission();
  477. this.setLeftTime();//층이 올라오기까지 남은 시간
  478. };
  479. gc.GameScene.prototype.setMission = function () {
  480. if (this.level == 1) this.mission = 8;
  481. else if (this.level == 2) this.mission = 11;
  482. else if (this.level == 3) this.mission = 13;
  483. else if (this.level >= 4 && this.level <= 8) this.mission = 10 + 2 * (this.level - 1);
  484. else if (this.level <= 9) this.mission = 24;
  485. else this.mission = 26 + 2 * (this.level - 10);
  486. this.missionnumimg.setValue(this.mission);
  487. };
  488. gc.GameScene.prototype.setLeftTime = function () {
  489. if (this.level <= 2) this.basetime = 8;
  490. else if (this.level <= 4) this.basetime = 7;
  491. else if (this.level <= 6) this.basetime = 6;
  492. else if (this.level <= 8) this.basetime = 5;
  493. //else if(this.level<=12) this.basetime = 6;
  494. //else if(this.level<=13) this.basetime = 5;
  495. else this.basetime = 4;
  496. this.lefttime = this.basetime;
  497. };
  498. gc.GameScene.prototype.setCard = function () {
  499. var floor;
  500. switch (this.level) {
  501. case 1:
  502. case 6:
  503. case 10:
  504. floor = 3;
  505. break;
  506. case 2:
  507. case 7:
  508. case 11:
  509. floor = 4;
  510. break;
  511. default:
  512. floor = 5;
  513. break;
  514. }
  515. //초기 카드 보이는 라인 설정
  516. for (var i = 0; i < this.card.length; i++) {
  517. for (var j = 0; j < this.card[i].length; j++) {
  518. if (j < floor) {
  519. this.card[i][j].alpha = 1;
  520. this.card[i][j].work = true;
  521. } else {
  522. this.card[i][j].alpha = 0;
  523. this.card[i][j].work = false;
  524. }
  525. this.card[i][j].flip = false;//뒤집혔는지 확인.. 다시 클릭 하지 못하게 하기 위함
  526. }
  527. }
  528. };
  529. gc.GameScene.prototype.setRandCardType = function () {
  530. var rand;
  531. var randtype;//카드 이미지 타입
  532. var name1 = 'blockOpen_';
  533. var name2 = '_01.png';
  534. var fullname;
  535. for (var i = 0; i < this.card.length; i++) {
  536. for (var j = 0; j < this.card[i].length; j++) {
  537. if (this.card[i][j].work) {
  538. rand = Math.floor(Math.random() * 100);
  539. randtype = this.setCardType(rand);
  540. this.card[i][j].type = randtype;
  541. fullname = name1 + randtype + name2;
  542. this.card[i][j].texturename = fullname;
  543. }
  544. }
  545. }
  546. for (var i = 0; i < this.card.length; i++) {
  547. for (var j = 0; j < this.card[i].length; j++) {
  548. if (this.card[i][j].work) {
  549. this.card[i][j].texture = PIXI.Texture.fromFrame(this.card[i][j].texturename);
  550. }
  551. }
  552. }
  553. };
  554. //레벨에 따른 이미지 타입 선정
  555. gc.GameScene.prototype.setCardType = function (rand) {
  556. var range = Math.floor(100 / (this.level + 1));
  557. var typerange = this.level + 1;
  558. if (this.level > 8) typerange = 9;//벌레 종류
  559. var type = 1;
  560. for (var i = 0; i < typerange; i++) {
  561. if (rand >= range * i && rand <= range * (i + 1)) {
  562. type = i + 1;
  563. break;
  564. }
  565. }
  566. //if(this.level <= 10) type = 1;
  567. return type;
  568. };
  569. gc.GameScene.prototype.setCardActive = function () {
  570. //console.log('카드 작동')
  571. for (var i = 0; i < this.card.length; i++) {
  572. for (var j = 0; j < this.card[i].length; j++) {
  573. if (this.card[i][j].work) this.card[i][j].interactive = true;
  574. }
  575. }
  576. this.skipbtn.interactive = true;
  577. this.waittimer = false;
  578. };
  579. gc.GameScene.prototype.blockCardActive = function () {
  580. //console.log('카드 정지')
  581. for (var i = 0; i < this.card.length; i++) {
  582. for (var j = 0; j < this.card[i].length; j++) {
  583. this.card[i][j].interactive = false;
  584. }
  585. }
  586. this.skipbtn.interactive = false;
  587. this.waittimer = true;
  588. };
  589. gc.GameScene.prototype.setCardAction = function (i, j) {
  590. if (gc.IS_MOBILE) {
  591. this.card[i][j].touchend = (function (e) {
  592. e.stopPropagation();
  593. this.chooseBlock(i, j);
  594. }).bind(this);
  595. } else {
  596. this.card[i][j].mouseup = this.card[i][j].touchend = (function (e) {
  597. e.stopPropagation();
  598. this.chooseBlock(i, j);
  599. }).bind(this);
  600. }
  601. };
  602. gc.GameScene.prototype.resetChoice = function () {
  603. for (var i = 0; i < 2; i++) {
  604. gc.game.choice[i] = false;
  605. gc.game.choicecardindex[i] = [];
  606. }
  607. };
  608. gc.GameScene.prototype.refreshChoiceInfo = function () {
  609. for (var i = 0; i < this.choice.length; i++) {
  610. if (this.choice[i]) {
  611. this.choicecardindex[i][1]++;
  612. }
  613. }
  614. };
  615. gc.GameScene.prototype.chooseBlock = function (i, j) {
  616. //console.log(GD.isBgmSound);
  617. //interactive -> false, 카드뒤집기 Mc부착.. 실제 카드 보이기, 선택(choice, choicecardindex) 배열 설정
  618. if (!this.pausegame) {
  619. if (this.start) {
  620. //console.log('선택', i, j);
  621. if (!this.choice[0]) {
  622. GD.soundPlay('sound_select');
  623. this.blockCardActive();
  624. this.choice[0] = true;
  625. this.choicecardindex[0] = [i, j];
  626. } else {
  627. if (this.choicecardindex[0][0] != i || this.choicecardindex[0][1] != j) {
  628. if (this.card[i][j].type != 22) GD.soundPlay('sound_select');
  629. //다른 카드 눌렸을 때
  630. this.blockCardActive();
  631. this.choice[1] = true;
  632. this.choicecardindex[1] = [i, j];
  633. } else {
  634. //매치 아이템을 다시 눌렸을 때.. 선택 취소
  635. if (this.card[i][j].type == 22) {
  636. this.card[i][j].flip = false;
  637. this.card[i][j].texture = PIXI.Texture.fromFrame('blockOpen_22_0001.png');
  638. this.choice[0] = false;
  639. this.choicecardindex[0] = [];
  640. }
  641. }
  642. }
  643. //카드 열기
  644. if (this.choice[0] && this.choice[1] && this.card[this.choicecardindex[0][0]][this.choicecardindex[0][1]].type == 22 && this.card[this.choicecardindex[1][0]][this.choicecardindex[1][1]].type > 20) {
  645. //매치 아이템 다음으로 아이템 선택 안되게 하기
  646. this.choice[1] = false;
  647. this.choicecardindex[1] = [];
  648. this.setCardActive();
  649. } else {
  650. if (this.choice[0]) {
  651. if (!this.card[i][j].flip) {
  652. //console.log('뒤집기 시작')
  653. this.flip = true;
  654. this.card[i][j].flip = true;
  655. if (this.card[i][j].type > 20) {
  656. var name1 = 'blockOpen_';
  657. var name2 = '_0002.png';
  658. var fullname;
  659. fullname = name1 + this.card[i][j].type + name2;
  660. this.card[i][j].texture = PIXI.Texture.fromFrame(fullname);
  661. if (this.card[i][j].type == 22) {
  662. this.useMatch();
  663. }
  664. else if (this.card[i][j].type == 23) {
  665. this.hintindex = [i, j];
  666. this.useHint();
  667. }
  668. else if (this.card[i][j].type == 21) {
  669. this.useBomb(i, j);
  670. }
  671. } else {
  672. this.card[i][j].alpha = 0;
  673. this.card[i][j].texture = PIXI.Texture.fromFrame(gc.game.card[i][j].texturename);
  674. this.flipmc[i][j].gotoAndPlay(0);
  675. this.flipmc[i][j].alpha = 1;
  676. this.flipmc[i][j].onComplete = function () {
  677. //console.log('뒤집기 라이트');
  678. this.alpha = 0;
  679. gc.game.openFlipLightMc(i, j);
  680. };
  681. }
  682. }
  683. }
  684. }
  685. }
  686. }
  687. };
  688. gc.GameScene.prototype.useMatch = function () {
  689. GD.soundPlay('sound_select')
  690. //console.log('use MATCH');
  691. if (!this.choice[1]) {
  692. this.setCardActive();
  693. this.flip = false;
  694. }
  695. if (this.choice[0] && this.choice[1]) this.checkMatchCard();
  696. };
  697. gc.GameScene.prototype.useHint = function () {
  698. GD.soundPlay('sound_hint');
  699. this.resetChoice();
  700. var cnt = 0;
  701. //console.log('use HINT');
  702. this.usehint = true;
  703. for (var i = 0; i < this.card.length; i++) {
  704. for (var j = 0; j < this.card[i].length; j++) {
  705. if (this.card[i][j].work && this.card[i][j].type < 21 && !this.card[i][j].flip) {
  706. cnt++;
  707. this.openFlipMc_Hint(i, j);
  708. }
  709. }
  710. }
  711. if (cnt == 0) {
  712. //console.log('뒤집을거 없음');
  713. this.usehint = false;
  714. this.resetCard(this.hintindex[0], this.hintindex[1]);
  715. this.dropCard('hint');
  716. }
  717. };
  718. gc.GameScene.prototype.useBomb = function (i, j) {
  719. GD.soundPlay('sound_bomb');
  720. //console.log('use BOMB');
  721. this.resetChoice();
  722. //오픈되어있는 카드 뒤집기
  723. for (var x = 0; x < this.card.length; x++) {
  724. for (var y = 0; y < this.card[x].length; y++) {
  725. if (this.card[x][y].work) {
  726. if (this.card[x][y].type < 21 && this.card[x][y].flip) {
  727. this.card[x][y].texture = PIXI.Texture.fromFrame('blockOpen_0_0001.png');
  728. this.card[x][y].flip = false;
  729. }
  730. }
  731. }
  732. }
  733. var fullcnt = 0;
  734. var cnt = 0;
  735. var s = [];
  736. this.matchresult = true;
  737. this.bombindex = [i, j];
  738. if (i != 0 && i != this.card.length - 1) {//양쪽 끝 라인이 아닐때
  739. if (j != this.card[i].length - 1) {//위층에 터질 카드 수 체크
  740. if (this.card[i - 1][j + 1].work && this.card[i - 1][j + 1].type < 21) {
  741. fullcnt++;
  742. s.push([i - 1, j + 1]);
  743. }
  744. if (this.card[i][j + 1].work && this.card[i][j + 1].type < 21) {
  745. fullcnt++;
  746. s.push([i, j + 1]);
  747. }
  748. if (this.card[i + 1][j + 1].work && this.card[i + 1][j + 1].type < 21) {
  749. fullcnt++;
  750. s.push([i + 1, j + 1]);
  751. }
  752. }
  753. if (j != 0) {//아래층 터질 카드 수 체크
  754. if (this.card[i - 1][j - 1].work && this.card[i - 1][j - 1].type < 21) {
  755. fullcnt++;
  756. s.push([i - 1, j - 1]);
  757. }
  758. if (this.card[i][j - 1].work && this.card[i][j - 1].type < 21) {
  759. fullcnt++;
  760. s.push([i, j - 1]);
  761. }
  762. if (this.card[i + 1][j - 1].work && this.card[i + 1][j - 1].type < 21) {
  763. fullcnt++;
  764. s.push([i + 1, j - 1]);
  765. }
  766. }
  767. //양 옆 카드 체크
  768. if (this.card[i - 1][j].work && this.card[i - 1][j].type < 21) {
  769. fullcnt++;
  770. s.push([i - 1, j]);
  771. }
  772. if (this.card[i + 1][j].work && this.card[i + 1][j].type < 21) {
  773. fullcnt++;
  774. s.push([i + 1, j]);
  775. }
  776. } else {
  777. if (i == 0) {//첫 라인일 경우
  778. if (j != this.card[i].length - 1) {//위층에 터질 카드 수 체크
  779. if (this.card[i][j + 1].work && this.card[i][j + 1].type < 21) {
  780. fullcnt++;
  781. s.push([i, j + 1]);
  782. }
  783. if (this.card[i + 1][j + 1].work && this.card[i + 1][j + 1].type < 21) {
  784. fullcnt++;
  785. s.push([i + 1, j + 1]);
  786. }
  787. }
  788. if (j != 0) {//아래층 터질 카드 수 체크
  789. if (this.card[i][j - 1].work && this.card[i][j - 1].type < 21) {
  790. fullcnt++;
  791. s.push([i, j - 1]);
  792. }
  793. if (this.card[i + 1][j - 1].work) {
  794. fullcnt++;
  795. s.push([i + 1, j - 1]);
  796. }
  797. }
  798. if (this.card[i + 1][j].work && this.card[i + 1][j].type < 21) {
  799. fullcnt++;
  800. s.push([i + 1, j]);
  801. }//오른쪽 카드 체크
  802. } else {//맨 끝 라인
  803. if (j != this.card[i].length - 1) {//위층에 터질 카드 수 체크
  804. if (this.card[i - 1][j + 1].work && this.card[i - 1][j + 1].type < 21) {
  805. fullcnt++;
  806. s.push([i - 1, j + 1]);
  807. }
  808. if (this.card[i][j + 1].work && this.card[i][j + 1].type < 21) {
  809. fullcnt++;
  810. s.push([i, j + 1]);
  811. }
  812. }
  813. if (j != 0) {//아래층 터질 카드 수 체크
  814. if (this.card[i - 1][j - 1].work && this.card[i - 1][j - 1].type < 21) {
  815. fullcnt++;
  816. s.push([i - 1, j - 1]);
  817. }
  818. if (this.card[i][j - 1].work && this.card[i][j - 1].type < 21) fullcnt++;
  819. s.push([i, j - 1]);
  820. }
  821. if (this.card[i - 1][j].work && this.card[i - 1][j].type < 21) {//왼쪽 카드 체크
  822. fullcnt++;
  823. s.push([i - 1, j]);
  824. }
  825. }
  826. }
  827. for (var i = 0; i < s.length; i++) {
  828. cnt++;
  829. this.explodeCard_Bomb(s[i], fullcnt, cnt);
  830. }
  831. if (s.length == 0) {
  832. //터뜨릴게 없을 때
  833. this.resetCard(i, j);
  834. this.bombindex = [];
  835. this.dropCard('bomb');
  836. }
  837. };
  838. gc.GameScene.prototype.openFlipMc_Hint = function (i, j) {
  839. this.card[i][j].alpha = 0;
  840. this.card[i][j].texture = PIXI.Texture.fromFrame(this.card[i][j].texturename);
  841. this.flipmc[i][j].gotoAndPlay(0);
  842. this.flipmc[i][j].alpha = 1;
  843. this.flipmc[i][j].onComplete = function () {
  844. this.alpha = 0;
  845. gc.game.openFlipLightMc_Hint(i, j);
  846. };
  847. };
  848. gc.GameScene.prototype.openFlipLightMc_Hint = function (i, j) {
  849. this.fliplightmc[i][j].alpha = 1;
  850. this.fliplightmc[i][j].gotoAndPlay(0);
  851. this.fliplightmc[i][j].onComplete = function () {
  852. this.alpha = 0;
  853. gc.game.card[i][j].alpha = 1;
  854. };
  855. };
  856. gc.GameScene.prototype.openFlipLightMc = function (i, j) {
  857. this.fliplightmc[i][j].alpha = 1;
  858. this.fliplightmc[i][j].gotoAndPlay(0);
  859. this.fliplightmc[i][j].onComplete = function () {
  860. //console.log('카드 오픈 라이트 완료');
  861. this.alpha = 0;
  862. gc.game.card[i][j].alpha = 1;
  863. if (!gc.game.choice[1]) {
  864. //console.log('뒤집기 완료!! 카드 작동 시키기!!!')
  865. gc.game.setCardActive();
  866. gc.game.flip = false;
  867. }
  868. if (gc.game.choice[0] && gc.game.choice[1]) gc.game.checkMatchCard();
  869. };
  870. };
  871. //카드 다시 뒤집어 두기
  872. gc.GameScene.prototype.closeCard_Hint = function () {
  873. var fullcnt = 0;
  874. var cnt = 0;
  875. for (var i = 0; i < this.card.length; i++) {
  876. for (var j = 0; j < this.card[i].length; j++) {
  877. if (this.card[i][j].work && this.card[i][j].type < 21) { fullcnt++; }
  878. }
  879. }
  880. for (var i = 0; i < this.card.length; i++) {
  881. for (var j = 0; j < this.card[i].length; j++) {
  882. if (this.card[i][j].work && this.card[i][j].type < 21) {
  883. cnt++;
  884. this.card[i][j].alpha = 0;
  885. this.card[i][j].texture = PIXI.Texture.fromFrame('blockOpen_0_0001.png');
  886. this.fliplightmc[i][j].textures.reverse();
  887. this.fliplightmc[i][j].gotoAndPlay();
  888. this.closeFlip_Hint(i, j, fullcnt, cnt);
  889. }
  890. }
  891. }
  892. };
  893. gc.GameScene.prototype.closeFlip_Hint = function (i, j, fullcnt, cnt) {
  894. this.flipmc[i][j].alpha = 1;
  895. this.flipmc[i][j].textures.reverse();
  896. this.flipmc[i][j].gotoAndPlay(0);
  897. this.flipmc[i][j].onComplete = function () {
  898. gc.game.card[i][j].alpha = 1;//카드 이미지 보이기
  899. gc.game.card[i][j].flip = false;//카드 이미지 보이기
  900. this.alpha = 0;
  901. if (fullcnt == cnt) {
  902. if (gc.game.hintindex[0] != undefined && gc.game.hintindex[1] != undefined) gc.game.resetCard(gc.game.hintindex[0], gc.game.hintindex[1]);
  903. gc.game.flip = false;
  904. gc.game.dropCard('hint');
  905. }
  906. };
  907. };
  908. gc.GameScene.prototype.closeCard = function () {
  909. //GD.soundPlay('sound_error');
  910. var cnt = 0;
  911. var i1, i2, j1, j2;
  912. i1 = gc.game.choicecardindex[0][0];
  913. j1 = gc.game.choicecardindex[0][1];
  914. i2 = gc.game.choicecardindex[1][0];
  915. j2 = gc.game.choicecardindex[1][1];
  916. //카드 이미지 교체
  917. this.card[i1][j1].alpha = 0;
  918. this.card[i2][j2].alpha = 0;
  919. this.card[i1][j1].texture = PIXI.Texture.fromFrame('blockOpen_0_0001.png');
  920. this.card[i2][j2].texture = PIXI.Texture.fromFrame('blockOpen_0_0001.png');
  921. //뒤집기 효과
  922. this.fliplightmc[i1][j1].alpha = 1;
  923. this.fliplightmc[i1][j1].textures.reverse();
  924. this.fliplightmc[i1][j1].gotoAndPlay(0);
  925. this.fliplightmc[i1][j1].onComplete = function () {
  926. this.alpha = 0;
  927. cnt++;
  928. gc.game.closeFlipMc(i1, j1, cnt);
  929. };
  930. this.fliplightmc[i2][j2].textures.reverse();
  931. this.fliplightmc[i2][j2].gotoAndPlay(0);
  932. this.fliplightmc[i2][j2].onComplete = function () {
  933. this.alpha = 0;
  934. cnt++;
  935. gc.game.closeFlipMc(i2, j2, cnt);
  936. };
  937. };
  938. gc.GameScene.prototype.closeFlipMc = function (i, j, callcnt) {
  939. this.flipmc[i][j].alpha = 1;
  940. this.flipmc[i][j].textures.reverse();
  941. this.flipmc[i][j].gotoAndPlay(0);
  942. this.flipmc[i][j].onComplete = function () {
  943. gc.game.card[i][j].alpha = 1;//카드 이미지 보이기
  944. gc.game.card[i][j].flip = false;//카드 이미지 보이기
  945. this.alpha = 0;
  946. if (callcnt == 2) {
  947. //console.log('카드 복귀')
  948. gc.game.resetChoice();//선택 정보 초기화
  949. gc.game.setCardActive();
  950. gc.game.flip = false;
  951. }
  952. };
  953. };
  954. gc.GameScene.prototype.closeCard_Increase = function () {
  955. //console.log('close by increase');
  956. var cnt = 0;
  957. var fullcnt = 0;
  958. //뒤집을 카드 수 체크
  959. for (var i = 0; i < this.card.length; i++) { if (this.card[i][0].type < 21) { fullcnt++; } }
  960. //뒤집기
  961. for (var i = 0; i < this.card.length; i++) {
  962. if (this.card[i][0].type < 21) {
  963. this.card[i][0].alpha = 0;
  964. this.card[i][0].texture = PIXI.Texture.fromFrame('blockOpen_0_0001.png');
  965. this.fliplightmc[i][0].alpha = 1;
  966. this.fliplightmc[i][0].textures.reverse();
  967. this.fliplightmc[i][0].gotoAndPlay(0);
  968. this.fliplightmc[i][0].onComplete = function () {
  969. cnt++;
  970. this.alpha = 0;
  971. if (cnt == fullcnt) gc.game.closeCard_Increase2();
  972. };
  973. }
  974. }
  975. };
  976. gc.GameScene.prototype.closeCard_Increase2 = function () {
  977. //console.log('close by increase');
  978. var cnt = 0;
  979. var fullcnt = 0;
  980. for (var i = 0; i < this.card.length; i++) { if (this.card[i][0].type < 21) { fullcnt++; } }
  981. for (var i = 0; i < this.card.length; i++) {
  982. if (this.card[i][0].type < 21) {
  983. this.flipmc[i][0].alpha = 1;
  984. this.flipmc[i][0].gotoAndPlay(0);
  985. this.flipmc[i][0].textures.reverse();
  986. this.flipmc[i][0].onComplete = function () {
  987. cnt++;
  988. this.alpha = 0;
  989. if (cnt == fullcnt) gc.game.closeCard_Increase3();
  990. };
  991. }
  992. }
  993. };
  994. gc.GameScene.prototype.closeCard_Increase3 = function () {
  995. for (var i = 0; i < this.card.length; i++) {
  996. this.card[i][0].alpha = 1;
  997. this.card[i][0].flip = false;
  998. this.card[i][0].alpha = 1;
  999. }
  1000. this.setCardActive();
  1001. };
  1002. gc.GameScene.prototype.checkMatchCard = function () {
  1003. var i1, i2, j1, j2;
  1004. i1 = this.choicecardindex[0][0];
  1005. j1 = this.choicecardindex[0][1];
  1006. i2 = this.choicecardindex[1][0];
  1007. j2 = this.choicecardindex[1][1];
  1008. if (this.card[i1][j1].type == this.card[i2][j2].type || this.card[i1][j1].type == 22 || this.card[i2][j2].type == 22) {//this.card[i][j].type==22은 매칭 아이템
  1009. this.matchresult = true;
  1010. this.explodeCard();
  1011. GD.soundPlay('sound_correct');
  1012. } else {
  1013. this.matchresult = false;
  1014. GD.soundPlay('sound_error');
  1015. }
  1016. this.checkmatch = true;
  1017. };
  1018. //짝을 맞췄을 때 폭발 이펙트
  1019. gc.GameScene.prototype.explodeCard_Bomb = function (arr, fullcnt, cnt) {
  1020. this.explodemc[arr[0]][arr[1]].alpha = 1;
  1021. this.explodemc[arr[0]][arr[1]].gotoAndPlay(0);
  1022. this.explodemc[arr[0]][arr[1]].onComplete = function () {
  1023. this.alpha = 0;
  1024. gc.game.resetCard(arr[0], arr[1]);
  1025. if (fullcnt == cnt) {
  1026. gc.game.resetCard(gc.game.bombindex[0], gc.game.bombindex[1]);
  1027. gc.game.bombindex = [];
  1028. gc.game.dropCard('bomb');
  1029. }
  1030. };
  1031. };
  1032. gc.GameScene.prototype.explodeCard = function () {
  1033. this.drop = true;
  1034. var i1, i2, j1, j2;
  1035. i1 = gc.game.choicecardindex[0][0];
  1036. j1 = gc.game.choicecardindex[0][1];
  1037. i2 = gc.game.choicecardindex[1][0];
  1038. j2 = gc.game.choicecardindex[1][1];
  1039. var cnt = 0;
  1040. //터지는 이펙트
  1041. this.explodemc[i1][j1].alpha = 1;
  1042. this.explodemc[i1][j1].gotoAndPlay(0);
  1043. this.explodemc[i1][j1].onComplete = function () {
  1044. this.alpha = 0;
  1045. cnt++;
  1046. gc.game.resetCard(i1, j1);
  1047. if (cnt == 2) gc.game.dropCard();//떨어질 카드가 있으면 떨어뜨리고, 없으면 choice초기화,interval 세팅
  1048. };
  1049. this.explodemc[i2][j2].alpha = 1;
  1050. this.explodemc[i2][j2].gotoAndPlay(0);
  1051. this.explodemc[i2][j2].onComplete = function () {
  1052. this.alpha = 0;
  1053. cnt++;
  1054. gc.game.resetCard(i2, j2);
  1055. if (cnt == 2) gc.game.dropCard();
  1056. };
  1057. };
  1058. gc.GameScene.prototype.dropCard = function (incase) {
  1059. //모든 카드의 위쪽을 체크하여 정보 이동
  1060. var dropfullcnt = 0;//떨어질 블럭 전체 수
  1061. var dropcnt = 0;//내려온 블럭
  1062. var s = [];//블럭 인덱스 저장
  1063. for (var i = 0; i < this.card.length; i++) {
  1064. for (var j = 0; j < this.card[i].length; j++) {
  1065. if (!this.card[i][j].work) {
  1066. for (var k = j + 1; k < this.card[i].length; k++) {
  1067. if (this.card[i][k].work) {
  1068. //this.dropEach(i,j,k);
  1069. s.push([i, j, k]);//i:라인, j:내려와야 할 지점, k:내려오기 시작하는 지점
  1070. this.card[i][j].type = this.card[i][k].type;
  1071. this.card[i][j].texturename = this.card[i][k].texturename;
  1072. this.card[i][j].texture = this.card[i][k].texture;
  1073. this.card[i][j].flip = false;
  1074. this.card[i][j].work = true;
  1075. this.card[i][k].work = false;
  1076. this.card[i][j].alpha = 1;
  1077. this.card[i][k].alpha = 0;
  1078. dropfullcnt++;
  1079. break;
  1080. }
  1081. }
  1082. }
  1083. }
  1084. }
  1085. if (dropfullcnt != 0) {
  1086. for (var i = 0; i < s.length; i++) {
  1087. dropcnt++;
  1088. //console.log(dropfullcnt, dropcnt)
  1089. this.dropEach(s[i], dropfullcnt, dropcnt, incase);
  1090. }
  1091. } else {//내려올 카드가 없을 때
  1092. if (incase != 'hint' && incase != 'bomb') {
  1093. if (this.match) {
  1094. this.matchcnt++;
  1095. this.matchrate = 2;
  1096. if (this.matchcnt > 3) {
  1097. this.fever = true;
  1098. this.insituation = true;
  1099. if (this.matchcnt == 4) this.feverTextEffect();
  1100. }
  1101. this.comboEffect();
  1102. }
  1103. this.match = true;
  1104. this.manageMedal();
  1105. }
  1106. //console.log(this.matchcnt, '콤보');
  1107. //this.checkOffBgEffect();
  1108. this.checkInDanger();
  1109. if (incase != 'hint' && incase != 'bomb') this.mission--;
  1110. this.missionnumimg.setValue(this.mission);
  1111. if (this.mission == 0) {
  1112. this.stageClear();
  1113. }
  1114. else {
  1115. this.resetChoice();
  1116. //console.log('카드 떨구기2')
  1117. this.setCardActive();
  1118. this.drop = false;
  1119. this.flip = false;
  1120. }
  1121. }
  1122. //this.checkInDanger();
  1123. //점수 처리
  1124. if (incase == undefined) this.setScore('basic');
  1125. else this.setScore(incase);
  1126. };
  1127. gc.GameScene.prototype.dropEach = function (s, dropfullcnt, dropcnt, incase) {//s:라인, 내려오게 될 위치, 내려오기 시작하는 위치
  1128. TweenMax.from(this.card[s[0]][s[1]], 0.05, {
  1129. x: this.mapmatrixXpos[s[0]], y: this.mapmatrixYpos[s[2]], onComplete: (function () {
  1130. if (dropcnt == dropfullcnt) {
  1131. //콤보
  1132. if (incase != 'hint' && incase != 'bomb') {
  1133. if (this.match) {
  1134. this.matchcnt++;
  1135. this.matchrate = 2;
  1136. if (this.matchcnt > 3) {
  1137. this.fever = true;
  1138. this.insituation = true;
  1139. if (this.matchcnt == 4) this.feverTextEffect();
  1140. }
  1141. this.comboEffect();
  1142. }
  1143. this.match = true;
  1144. this.manageMedal();
  1145. }
  1146. //미션 처리
  1147. if (incase != 'hint' && incase != 'bomb') this.mission--;
  1148. this.missionnumimg.setValue(this.mission);
  1149. if (this.mission == 0) { this.stageClear(); }
  1150. else {
  1151. //선택 초기화, interval 처리
  1152. this.resetChoice();
  1153. //console.log('카드 떨구기1')
  1154. this.setCardActive();
  1155. this.drop = false;
  1156. this.flip = false;
  1157. }
  1158. //this.checkOffBgEffect();
  1159. this.checkInDanger();
  1160. }
  1161. }).bind(this)
  1162. });
  1163. };
  1164. //카드 정보 초기화
  1165. gc.GameScene.prototype.resetCard = function (i, j) {
  1166. this.card[i][j].flip = false;
  1167. this.card[i][j].work = false;
  1168. this.card[i][j].texture = PIXI.Texture.fromFrame('blockOpen_0_0001.png');
  1169. this.card[i][j].alpha = 0;
  1170. };
  1171. gc.GameScene.prototype.comboEffect = function () {
  1172. var comboimg1 = new PIXI.Sprite.fromFrame('combo.png');
  1173. var comboimg2 = new gc.NumberText('comNum_00', 'center', -4);
  1174. comboimg1.anchor.set(0.5);
  1175. comboimg1.x = gc.width / 2;
  1176. comboimg1.y = 400;
  1177. comboimg2.setValue(this.matchcnt);
  1178. comboimg2.x = 0;
  1179. comboimg2.y = 20;
  1180. comboimg1.addChild(comboimg2);
  1181. this.textContainer.addChild(comboimg1);
  1182. TweenMax.to(comboimg1, 0.5, {
  1183. y: comboimg1.y - 70, alpha: 0, onComplete: (function () {
  1184. this.textContainer.removeChild(comboimg1);
  1185. }).bind(this)
  1186. });
  1187. };
  1188. gc.GameScene.prototype.resetCombo = function () {
  1189. this.matchrate = 2;
  1190. this.matchcnt = 0;
  1191. this.match = false;
  1192. this.fever = false;
  1193. GD.soundStop('sound_fever_BG');
  1194. if (!this.isbgm) {
  1195. //console.log('bgm on')
  1196. this.isbgm = true;
  1197. GD.bgmPlay();
  1198. this.checkInDanger();
  1199. }
  1200. };
  1201. //경고 상황 체크
  1202. gc.GameScene.prototype.checkInDanger = function () {
  1203. //console.log('check in danger')
  1204. var danger = false;
  1205. for (var i = 0; i < this.card.length; i++) {
  1206. if (this.card[i][6].work) {
  1207. danger = true;
  1208. }
  1209. }
  1210. if (danger) {
  1211. this.indanger = true;
  1212. this.insituation = true;
  1213. } else {
  1214. this.indanger = false;
  1215. GD.soundStop('sound_timewarning');
  1216. this.isdangersound = false;
  1217. }
  1218. //console.log('danger', this.indanger);
  1219. if (this.indanger && !this.fever) {
  1220. if (!this.isdangersound) GD.soundPlay('sound_timewarning', 1, true);
  1221. this.isdangersound = true;
  1222. }
  1223. };
  1224. gc.GameScene.prototype.increaseFloor = function () {
  1225. GD.soundPlay('sound_block_line');
  1226. this.blockCardActive();
  1227. this.inccnt++;
  1228. var incfullcnt = 0;
  1229. var inccnt = 0;
  1230. var inctime = 0.25;
  1231. var name1 = 'blockOpen_';
  1232. var name2 = '_01.png';
  1233. var rand, randtype, fullname;
  1234. var itemratio, itempos, itemkind, range;
  1235. //게임오버 체크
  1236. for (var i = 0; i < this.card.length; i++) {
  1237. var topfloor = this.card[i].length - 1;
  1238. if (this.card[i][topfloor].work) {
  1239. this.gameover = true;
  1240. this.gameOver();
  1241. break;
  1242. }
  1243. }
  1244. if (!this.gameover) {
  1245. for (var i = 0; i < this.flipmc.length; i++) {
  1246. for (var j = 0; j < this.flipmc[i].length; j++) {
  1247. this.flipmc[i][j].gotoAndStop(0);
  1248. this.flipmc[i][j].alpha = 0;
  1249. }
  1250. }
  1251. for (var i = 0; i < this.fliplightmc.length; i++) {
  1252. for (var j = 0; j < this.fliplightmc[i].length; j++) {
  1253. this.fliplightmc[i][j].gotoAndStop(0);
  1254. this.fliplightmc[i][j].alpha = 0;
  1255. }
  1256. }
  1257. for (var j = this.card[0].length - 1; j >= 0; j--) {//윗줄부터
  1258. if (j == 0) {
  1259. //아이템 생성
  1260. itemratio = Math.floor(Math.random() * 100);
  1261. if (this.level <= 9) range = 50;
  1262. else if (this.level <= 10) range = 40;
  1263. else if (this.level <= 11) range = 30;
  1264. else range = 20;
  1265. if (itemratio <= range) {
  1266. this.makeItem = true;
  1267. itempos = Math.floor(Math.random() * 6);
  1268. itemkind = Math.floor(Math.random() * 3) + 21;
  1269. }
  1270. }
  1271. for (var i = 0; i < this.card.length; i++) {//옆 라인으로
  1272. if (j != 0) {
  1273. if (this.card[i][j - 1].work) {
  1274. incfullcnt++;
  1275. this.card[i][j].type = this.card[i][j - 1].type;
  1276. this.card[i][j].texturename = this.card[i][j - 1].texturename;
  1277. this.card[i][j].flip = this.card[i][j - 1].flip;
  1278. this.card[i][j].work = true;
  1279. this.card[i][j].texture = this.card[i][j - 1].texture;
  1280. this.card[i][j].alpha = 1;
  1281. TweenMax.from(this.card[i][j], inctime, {
  1282. x: this.card[i][j - 1].x, y: this.card[i][j - 1].y, onComplete: (function () {
  1283. inccnt++;
  1284. if (inccnt == incfullcnt) {
  1285. this.refreshChoiceInfo();
  1286. //console.log('층 올리기1')
  1287. this.setCardActive();
  1288. }
  1289. }).bind(this)
  1290. });
  1291. }
  1292. } else {
  1293. incfullcnt++;
  1294. rand = Math.floor(Math.random() * 100);
  1295. randtype = this.setCardType(rand);
  1296. //아이템 적용
  1297. if (this.makeItem) {
  1298. if (i == itempos) {
  1299. randtype = itemkind;
  1300. name2 = '_0001.png';
  1301. } else {
  1302. name2 = '_01.png';
  1303. }
  1304. } else {
  1305. name2 = '_01.png';
  1306. }
  1307. this.card[i][j].type = randtype;
  1308. fullname = name1 + randtype + name2;
  1309. this.card[i][j].texturename = fullname;
  1310. this.card[i][j].flip = false;
  1311. this.card[i][j].work = true;
  1312. this.card[i][j].texture = PIXI.Texture.fromFrame(this.card[i][j].texturename);
  1313. this.card[i][j].alpha = 1;
  1314. TweenMax.from(this.card[i][j], inctime, {
  1315. x: this.card[i][j].x, y: this.card[i][j].y + 106, onComplete: (function () {
  1316. inccnt++;
  1317. if (inccnt == incfullcnt) {
  1318. this.refreshChoiceInfo();
  1319. //console.log('층 올리기2')
  1320. TweenMax.from(this.card[0][0], 0.4, {
  1321. onComplete: (function () {//0.4초 후에 카드 덮고 작동 시작
  1322. gc.game.closeCard_Increase();
  1323. }).bind(this)
  1324. });
  1325. }
  1326. }).bind(this)
  1327. })
  1328. }
  1329. }
  1330. }
  1331. this.checkInDanger();
  1332. }
  1333. };
  1334. gc.GameScene.prototype.stageClear = function () {
  1335. GD.soundPlay('sound_levelup');
  1336. this.stageclear = true;
  1337. this.level++;
  1338. this.levelnumimg.setValue(this.level);
  1339. this.blockCardActive();
  1340. this.resetChoice();
  1341. //배경 변경
  1342. var bgname;
  1343. if (this.level % 4 == 0) bgname = 'game_bg4';
  1344. else bgname = 'game_bg' + (this.level % 4);
  1345. this.gamebg.texture = GD.loader.resources[bgname].texture;
  1346. this.inccnt = 0;
  1347. this.textimg.scale.x = 1;
  1348. this.textimg.scale.y = 1;
  1349. this.textimg.texture = PIXI.Texture.fromFrame('levelup.png');
  1350. this.textimg.alpha = 1;
  1351. //타임바 위치 초기화
  1352. TweenMax.to(this.timerrect, 0.5, { x: this.gametimebar.x - this.gametimebar.width * 1.5 });
  1353. TweenMax.from(this.textimg.scale, 0.3, {
  1354. x: 1.5, y: 1.5, onComplete: (function () {
  1355. TweenMax.to(this.textimg.scale, 0.3, {
  1356. x: 1.2, y: 1.2, onComplete: (function () {
  1357. TweenMax.to(this.textimg.scale, 0.3, {
  1358. x: 1, y: 1, onComplete: (function () {
  1359. TweenMax.to(this.textimg, 0.5, {
  1360. alpha: 0, onComplete: (function () {
  1361. this.setCard();
  1362. this.setRandCardType();
  1363. this.setMission();
  1364. this.setLeftTime();
  1365. //this.checkOffBgEffect();
  1366. this.checkInDanger();
  1367. this.textimg.alpha = 0;
  1368. this.textimg.scale.x = 0;
  1369. this.textimg.scale.y = 0;
  1370. this.textimg.texture = PIXI.Texture.fromFrame('start.png');
  1371. this.start = false;
  1372. this.stageclear = false;
  1373. }).bind(this)
  1374. });
  1375. }).bind(this)
  1376. });
  1377. }).bind(this)
  1378. });
  1379. }).bind(this)
  1380. });
  1381. this.hintindex = [];
  1382. this.flipwaitrate = 0.1;
  1383. this.insituation = false;
  1384. this.indanger = false;
  1385. this.fever = false;
  1386. this.matchcnt = 0;
  1387. this.match = false;
  1388. this.flip = false;
  1389. this.drop = false;
  1390. this.increase = false;
  1391. this.fevereffectbg.alpha = 0;
  1392. this.danger_shadow.alpha = 0;
  1393. this.dangerffectbar.alpha = 0;
  1394. this.isdangersound = false;
  1395. GD.soundStop('sound_fever_BG');
  1396. GD.soundStop('sound_timewarning');
  1397. this.manageMedal();
  1398. };
  1399. gc.GameScene.prototype.gameOver = function () {
  1400. this.textimg.scale.x = 1;
  1401. this.textimg.scale.y = 1;
  1402. this.textimg.texture = PIXI.Texture.fromFrame('gameover.png');
  1403. this.textimg.alpha = 0;
  1404. GD.soundPlay('sound_gameover');
  1405. TweenMax.to(this.textimg, 1, { alpha: 1 });
  1406. TweenMax.fromTo(this.textimg.scale, 0.3, { x: 4, y: 4 }, {
  1407. x: 0.8, y: 0.8, onComplete: (function () {
  1408. TweenMax.to(this.textimg.scale, 0.2, {
  1409. x: 1, y: 1, onComplete: (function () {
  1410. TweenMax.to(this.textimg, 0.5, {
  1411. onComplete: (function () {
  1412. this.onResult();
  1413. }).bind(this)
  1414. });
  1415. }).bind(this)
  1416. });
  1417. }).bind(this)
  1418. });
  1419. this.blockCardActive();
  1420. clearInterval(this.timer);
  1421. };
  1422. //타임업 사운드가 끝나고 결과창으로 이동
  1423. gc.GameScene.prototype.onResult = function () {
  1424. //console.log('on result');
  1425. GD.bgmStop();
  1426. GD.soundStop('sound_timewarning');
  1427. GD.soundStop('sound_fever_BG');
  1428. gc.game = null;
  1429. GD.commonOption.finish(this.score);
  1430. };
  1431. gc.GameScene.prototype.startCountdown = function () {
  1432. GD.bgmStop();
  1433. this.isbgm = true;
  1434. GD.bgmPlay(.8);
  1435. var time = 1;
  1436. this.three.alpha = 0;
  1437. this.two.alpha = 0;
  1438. this.one.alpha = 0;
  1439. this.textimg.alpha = 0;
  1440. GD.soundPlay('sound_count');
  1441. TweenMax.to(this.three, time, { alpha: 1 });
  1442. TweenMax.from(this.three.scale, time, {
  1443. x: 3, y: 3, onComplete: (function () {
  1444. this.three.alpha = 0;
  1445. GD.soundPlay('sound_count');
  1446. TweenMax.to(this.two, time, { alpha: 1 });
  1447. TweenMax.from(this.two.scale, time, {
  1448. x: 3, y: 3, onComplete: (function () {
  1449. this.two.alpha = 0;
  1450. GD.soundPlay('sound_count');
  1451. TweenMax.to(this.one, time, { alpha: 1 });
  1452. TweenMax.from(this.one.scale, time, {
  1453. x: 3, y: 3, onComplete: (function () {
  1454. this.one.alpha = 0;
  1455. this.closeCard_Hint();
  1456. GD.soundPlay('sound_start');
  1457. TweenMax.to(this.textimg, 0.5, { alpha: 1 });
  1458. TweenMax.to(this.textimg.scale, 0.5, {
  1459. x: 1, y: 1, onComplete: (function () {
  1460. TweenMax.to(this.textimg, 0.1, { alpha: 0 });
  1461. TweenMax.to(this.textimg.scale, 0.1, {
  1462. x: 3, y: 3, onComplete: (function () {
  1463. this.countdown = false;
  1464. this.start = true;
  1465. //console.log('게임 시작')
  1466. this.setCardActive();
  1467. }).bind(this)
  1468. });
  1469. }).bind(this)
  1470. });
  1471. }).bind(this)
  1472. });
  1473. }).bind(this)
  1474. });
  1475. }).bind(this)
  1476. });
  1477. };
  1478. //피버 텍스트 이펙트
  1479. gc.GameScene.prototype.feverTextEffect = function () {
  1480. GD.bgmStop();
  1481. this.isbgm = false;
  1482. if (GD.isBgmSound) GD.soundPlay('sound_fever_BG', 1, true);
  1483. GD.soundPlay('sound_fever');
  1484. this.isdangersound = false;
  1485. GD.soundStop('sound_timewarning');
  1486. this.fevereffect_text.y = 350;
  1487. this.fevereffect_text.alpha = 1;
  1488. this.fevereffect_text.scale.x = 1;
  1489. this.fevereffect_text.scale.y = 1;
  1490. TweenMax.from(this.fevereffect_text, 0.7, {
  1491. y: 100, onComplete: (function () {
  1492. TweenMax.to(this.fevereffect_text.scale, 0.2, {
  1493. x: 1.1, y: 1.1, onComplete: (function () {
  1494. TweenMax.to(this.fevereffect_text.scale, 0.5, { x: 1, y: 1 });
  1495. TweenMax.to(this.fevereffect_text, 0.5, { y: 350 });
  1496. }).bind(this)
  1497. });
  1498. }).bind(this)
  1499. });
  1500. TweenMax.from(this.fevereffect_text, 0.9, {
  1501. alpha: 0, onComplete: (function () {
  1502. TweenMax.to(this.fevereffect_text, 0.5, { alpha: 0 });
  1503. }).bind(this)
  1504. });
  1505. };
  1506. gc.GameScene.prototype.GameTimer = function () {
  1507. var now = Date.now();
  1508. if (this.lasttime == undefined) this.lasttime = now;
  1509. if (!this.start) {
  1510. if (!this.pausegame) {
  1511. if (!this.countdown) {
  1512. this.countdown = true;
  1513. this.startCountdown();
  1514. }
  1515. }
  1516. } else {
  1517. //층을 올리기 위한 타이머
  1518. if (this.lefttime > 0) {
  1519. //if(!this.waittimer && !this.stageclear && !this.pausegame) {this.lefttime -= (now-this.lasttime)/1000;}
  1520. if (!this.usehint && !this.stageclear && !this.pausegame) { this.lefttime -= (now - this.lasttime) / 1000; }
  1521. } else {
  1522. this.setLeftTime();//층 올리기 시간 초기화
  1523. this.increase = true;
  1524. }
  1525. //this.timerrect.x = this.gametimebar.width * (this.lefttime / this.basetime) - this.gametimebar.width;//타이머가 줄어들기
  1526. if (!this.stageclear) this.timerrect.x = this.gametimebar.width * ((this.basetime - this.lefttime) / this.basetime);//타이머가 늘어나기
  1527. //카드를 뒤집거나 내리기 까지 기다림 시간
  1528. if (this.checkmatch && !this.stageclear) {
  1529. if (this.flipwaitrate > 0) {
  1530. if (!this.matchresult) { this.flipwaitrate -= (now - this.lasttime) / 1000; }
  1531. } else {
  1532. this.checkmatch = false;
  1533. this.flipwaitrate = 0.1;
  1534. this.closeCard();
  1535. this.resetCombo();
  1536. }
  1537. }
  1538. //힌트를 보여줄 시간
  1539. if (this.usehint) {
  1540. if (this.hintrate > 0) this.hintrate -= (now - this.lasttime) / 1000;
  1541. else {
  1542. this.usehint = false;
  1543. this.hintrate = 2;
  1544. this.closeCard_Hint();
  1545. }
  1546. }
  1547. }
  1548. //배경 이펙트 깜빡이기
  1549. if (!this.gameover) {
  1550. if (!this.insituation) {
  1551. this.blinkrate = 0;
  1552. this.fevereffectbg.alpha = 0;
  1553. this.fevereffect_text.alpha = 0;
  1554. this.dangereffect_skeleton.alpha = 0;
  1555. this.dangerffectbar.alpha = 0;
  1556. this.dangerffect_text.alpha = 0;
  1557. this.danger_shadow.alpha = 0;
  1558. } else {
  1559. if (!this.indanger && !this.fever) this.insituation = false;//상황 초기화
  1560. if (this.indanger || this.fever) {
  1561. if (this.blinkrate > 0) {
  1562. if (!this.pausegame) { this.blinkrate -= (now - this.lasttime) / 1000; }
  1563. } else {
  1564. this.blinkrate = 0.15;
  1565. if (this.fever) {
  1566. this.fevereffectbg.alpha = 1;
  1567. if (this.fevereffectbg.texture == PIXI.Texture.fromFrame('feverlight1.png')) this.fevereffectbg.texture = PIXI.Texture.fromFrame('feverlight2.png');
  1568. else this.fevereffectbg.texture = PIXI.Texture.fromFrame('feverlight1.png');
  1569. this.danger_shadow.alpha = 0;
  1570. this.dangereffect_skeleton.alpha = 0;
  1571. this.dangerffect_text.alpha = 0;
  1572. this.dangerffectbar.alpha = 0;
  1573. } else {
  1574. this.danger_shadow.alpha = 1;
  1575. this.dangerffectbar.alpha = 1;
  1576. //if(this.dangerffectbar.alpha<=0) this.dangerffectbar.alpha = 1;
  1577. //else this.dangerffectbar.alpha -= 0.25;
  1578. if (this.dangerffect_text.alpha <= 0.5) this.dangerffect_text.alpha = 1;
  1579. else this.dangerffect_text.alpha -= 0.25;
  1580. this.dangereffect_skeleton.alpha = 1;
  1581. if (this.dangereffect_skeleton.texture == PIXI.Texture.fromFrame('warning_s1.png')) this.dangereffect_skeleton.texture = PIXI.Texture.fromFrame('warning_s2.png');
  1582. else this.dangereffect_skeleton.texture = PIXI.Texture.fromFrame('warning_s1.png');
  1583. this.fevereffectbg.alpha = 0;//피버 배경 이펫트 끄기
  1584. }
  1585. }
  1586. }
  1587. }
  1588. //콤보 체크를 위한 타이머
  1589. if (this.matchrate > 0) {
  1590. if (!this.waittimer && !this.stageclear && !this.pausegame) {
  1591. if (this.match) this.matchrate -= (now - this.lasttime) / 1000;
  1592. }
  1593. } else {
  1594. this.resetCombo();
  1595. }
  1596. if (this.increase) {
  1597. //console.log('증가')
  1598. if (!this.flip && !this.drop) {
  1599. this.increaseFloor();//층 올리기 함수
  1600. this.increase = false;
  1601. }
  1602. }
  1603. }
  1604. this.lasttime = now;
  1605. };
  1606. //옵션 버튼을 눌렸을 때 일시정지, 계속 설정
  1607. gc.GameScene.prototype.pause = function () {
  1608. this.pausegame = true;
  1609. TweenMax.pauseAll(true, true, true);
  1610. };
  1611. gc.GameScene.prototype.resume = function () {
  1612. this.pausegame = false;
  1613. TweenMax.resumeAll();
  1614. GD.soundStop('sound_fever_BG');
  1615. if (this.fever) {
  1616. if (GD.isBgmSound) { GD.soundPlay('sound_fever_BG', 1, true); }
  1617. }
  1618. };
  1619. //메달(업적) 관리==================================================================================================
  1620. gc.GameScene.prototype.manageMedal = function () {
  1621. if (this.level == 2 && !this.getmedal1) {
  1622. GD.DataManager.addMedal(1);
  1623. this.getmedal1 = true;
  1624. //console.log('get medal 1.. 레벨 2!!!!!!!!!!!!!');
  1625. }
  1626. else if (this.level == 9 && !this.getmedal3) {
  1627. GD.DataManager.addMedal(3);
  1628. this.getmedal3 = true;
  1629. //console.log('get medal 3.. 레벨 9!!!!!!!!!');
  1630. }
  1631. else if (this.matchcnt == 7 && !this.getmedal2) {
  1632. GD.DataManager.addMedal(2);
  1633. this.getmedal2 = true;
  1634. //console.log('get medal 2.. 콤보 7회!!!!!!!!!');
  1635. }
  1636. else if (this.matchresult) {
  1637. GD.DataManager.addMedal(4);
  1638. //console.log('get medal 4');
  1639. }
  1640. };
  1641. gc.GameScene.getInstance = function () {
  1642. if (!gc.game) gc.game = new gc.GameScene();
  1643. return gc.game;
  1644. };
  1645. module.exports = gc