game.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. import "./js/weapp-adapter";
  2. import GD from './js/human.min'
  3. import gc from './js/GC'
  4. import * as PIXI from './js/pixi';
  5. import DwSdk from "./duowansdk/DwSdk";
  6. const debug = false;
  7. const objSdk = GD.objSdk = new DwSdk("欢乐记忆翻牌", debug);
  8. /*이미지 서버*/
  9. var GAME_IMG_PATH = 'https://pub.dwstatic.com/wxgame/bugsmatch/BugsMatch/';
  10. var IMG_SERVER = '';
  11. var COMMON_IMG_PATH = '../human/';
  12. /*JS 서버*/
  13. var JS_SERVER = '';
  14. var GAME_JS_PATH = '';
  15. var COMMON_JS_PATH = '../human/';
  16. var JS_PATH = '';
  17. var CACHE_VER = 0.2;
  18. var RES_DIR_IMG = GAME_IMG_PATH + 'image/';
  19. var RES_DIR_JSON = RES_DIR_IMG + 'json/';
  20. var RES_DIR_PNG = RES_DIR_IMG + 'png/';
  21. var RES_DIR_SPINE = RES_DIR_IMG + 'spine/';
  22. var RES_DIR_SOUND = GAME_IMG_PATH + 'sound/';
  23. // 소스버전
  24. var IMG_VERSION = CACHE_VER;
  25. var SOUND_VERSION = CACHE_VER;
  26. /**
  27. * Created by juho on 2016-03-28.
  28. */
  29. (function () {
  30. // 언어설정
  31. GD.leng = 'cn';
  32. GD.isDebug = false;
  33. // Canvas 화면설정
  34. GD.init(720, 1230, 0, 0, 0xFFFFFF);
  35. //PNG==========================================================================================
  36. GD.loader.add('game_bg1', RES_DIR_PNG + "bg1.png");
  37. GD.loader.add('game_bg2', RES_DIR_PNG + "bg2.png");
  38. GD.loader.add('game_bg3', RES_DIR_PNG + "bg3.png");
  39. GD.loader.add('game_bg4', RES_DIR_PNG + "bg4.png");
  40. //메달 업적이미지
  41. GD.loader.add('game_medal_1', RES_DIR_IMG + "mission_0001.png");
  42. GD.loader.add('game_medal_2', RES_DIR_IMG + "mission_0002.png");
  43. GD.loader.add('game_medal_3', RES_DIR_IMG + "mission_0003.png");
  44. GD.loader.add('game_medal_4', RES_DIR_IMG + "mission_0004.png");
  45. //JSON====================================================================================
  46. //인트로
  47. GD.loader.add(RES_DIR_JSON + 'intro/' + 'intro.json');
  48. //튜토리얼
  49. if (GD.leng == 'ko') { GD.loader.add(RES_DIR_JSON + "tutorial/" + "tutorial1.json"); }
  50. else { GD.loader.add(RES_DIR_JSON + "tutorial/" + "tutorial1_" + GD.leng + ".json"); }
  51. GD.loader.add(RES_DIR_JSON + 'tutorial/' + 'tutorialUI.json');
  52. //숫자
  53. GD.loader.add(RES_DIR_JSON + 'number/' + 'basic_number.json');
  54. GD.loader.add(RES_DIR_JSON + 'number/' + 'comnumber.json');
  55. GD.loader.add(RES_DIR_JSON + 'number/' + 'countdown.json');
  56. //게임
  57. GD.loader.add(RES_DIR_JSON + 'game/' + 'fever_bg.json');
  58. GD.loader.add(RES_DIR_JSON + 'game/' + 'warning_bg.json');
  59. GD.loader.add(RES_DIR_JSON + 'game/' + 'block_item.json');
  60. GD.loader.add(RES_DIR_JSON + 'game/' + 'blockopen.json');
  61. GD.loader.add(RES_DIR_JSON + 'game/' + 'gametext.json');
  62. GD.loader.add(RES_DIR_JSON + 'game/' + 'match_effect.json');
  63. GD.loader.add(RES_DIR_JSON + 'game/' + 'game_timebar.json');
  64. GD.loader.add(RES_DIR_JSON + 'game/' + 'bugs.json');
  65. GD.loader.add(RES_DIR_JSON + 'game/' + 'button.json');
  66. GD.loader.add(RES_DIR_JSON + 'game/' + 'fever_danger_text.json');
  67. GD.loader.add(RES_DIR_JSON + 'game/' + 'warningbar.json');
  68. GD.loader.load(loadSound);
  69. // GD.loader.load(onAssetsLoaded);
  70. GD.showProgress();
  71. function loadSound(loader, resource) {
  72. // 사운드 목록 설정
  73. var soundList = ['sound_bgm'];//bgm
  74. var effectList = [//effect
  75. 'sound_bomb',
  76. 'sound_correct',
  77. 'sound_count',
  78. 'sound_error',
  79. 'sound_fever',
  80. 'sound_fever_BG',
  81. 'sound_gameover',
  82. 'sound_hint',
  83. 'sound_levelup',
  84. 'sound_select',
  85. 'sound_start',
  86. 'sound_timewarning',
  87. 'sound_skip_bt',
  88. 'sound_block_line'
  89. ];
  90. if (GD.soundType == 1) soundList = soundList.concat(effectList);
  91. GD.loadSound(soundList, onAssetsLoaded);
  92. }
  93. function onAssetsLoaded() {
  94. // 로딩화면 삭제
  95. GD.hideProgress();
  96. onIntro();
  97. GD.app.ticker.add(objSdk.update, null, PIXI.UPDATE_PRIORITY.UTILITY);
  98. mobileChcck();
  99. }
  100. // 인트로
  101. function onIntro() {
  102. console.log('onIntro')
  103. GD.stage.removeChildren();
  104. objSdk.showAdIcon(10, 1100);
  105. // 공통 튜토리얼
  106. GD.tutorial = GD.Tutorial.getInstance();
  107. GD.tutorial.init(1, 'tutorial_');
  108. GD.tutorial.closeBtn.y = 1085;
  109. // 인트로
  110. var space = 270, posY = 1070;
  111. gc.intro = GD.CommonIntro.getInstance('w', 'intro_bg');
  112. gc.intro.initHelp('intro_help_btn', GD.width / 2 - space, posY);
  113. gc.intro.initSound('intro_option_btn', GD.width / 2 + space, posY);
  114. gc.intro.initStart('intro_start_btn', GD.width / 2, posY, function () {
  115. GD.fullScreen();
  116. onGame();
  117. }, this);
  118. gc.intro.init();
  119. GD.stage.addChild(gc.intro);
  120. }
  121. // 게임
  122. function onGame() {
  123. GD.stage.removeChildren();
  124. gc.game = gc.GameScene.getInstance();
  125. gc.game.init();
  126. GD.stage.addChild(gc.game);
  127. GD.objSdk.hideAdIcon();
  128. // 공통 옵션버튼
  129. GD.commonOption = GD.CommonOption.getInstance('w');
  130. GD.commonOption.on('OPTION_OPEN_EVENT', onOptionOpen);
  131. GD.commonOption.on('OPTION_CLOSE_EVENT', onOptionClose);
  132. GD.commonOption.on('GAME_RESTART', gameRestart);
  133. GD.commonOption.init();
  134. GD.stage.addChild(GD.commonOption);
  135. // GD.bgmPlay(0.8);
  136. }
  137. function onOptionOpen() {
  138. gc.game.pause();
  139. }
  140. function onOptionClose() {
  141. gc.game.resume();
  142. }
  143. //모바일 여부 체크
  144. function mobileChcck() {
  145. var mobileKeyWords = ['iphone', 'ipod', 'blackberry', 'android', 'windows ce', 'lg', 'mot', 'samsung', 'sonyericsson', 'meego', 'nokia', 'webos', 'opera mini', 'opera mobi', 'iemobile'];
  146. gc.IS_MOBILE = false;
  147. var browerAgent = navigator.userAgent.toLowerCase();
  148. for (var i = 0; i < mobileKeyWords.length; ++i) {
  149. if (browerAgent.indexOf(mobileKeyWords[i]) != -1) {
  150. gc.IS_MOBILE = true;
  151. break;
  152. }
  153. }
  154. }
  155. // 게임 재시작
  156. function gameRestart() {
  157. onIntro();
  158. }
  159. })();
  160. wx.onShareAppMessage(function () {
  161. return {
  162. title: "聪明人都在玩的游戏,快来挑战一下!",
  163. imageUrl: "https://pub.dwstatic.com/wxgame/bugsmatch/share.jpg",
  164. query: ""
  165. }
  166. })
  167. wx.showShareMenu({
  168. withShareTicket: false
  169. })