123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- import "./js/weapp-adapter"
- import { GD, gc } from "./js/human"
- import * as PIXI from "./js/pixi.min"
- import DwSdk from "./duowansdk/DwSdk";
- const debug = false;
- const objSdk = GD.objSdk = new DwSdk("厨房消消消", debug);
- /*Image server*/
- var IMG_SERVER = '';
- var GAME_IMG_PATH = 'https://pub.dwstatic.com/wxgame/momobakery/';
- var COMMON_IMG_PATH = '';
- /*JS Server*/
- var JS_SERVER = '';
- var GAME_JS_PATH = '';
- var COMMON_JS_PATH = 'js/common/';
- var JS_PATH = '';
- var CACHE_VER = 0.2;
- var RES_DIR_IMG = GAME_IMG_PATH + 'image/';
- var RES_DIR_JSON = RES_DIR_IMG + 'json/';
- var RES_DIR_PNG = RES_DIR_IMG + 'png/';
- var RES_DIR_SPINE = RES_DIR_IMG + 'spine/';
- var RES_DIR_SOUND = GAME_IMG_PATH + 'sound/';
- // source code version
- var IMG_VERSION = CACHE_VER;
- var SOUND_VERSION = CACHE_VER;
- const { pixelRatio, windowWidth, windowHeight } = wx.getSystemInfoSync()
- // language settings
- GD.leng = 'cn';
- GD.isDebug = false;
- // Canvas screen settings
- GD.init(windowWidth, windowHeight, 0, 0, 0xFFFFFF);
- // var app = new PIXI.Application({
- // width: windowWidth * pixelRatio,
- // height: windowHeight * pixelRatio,
- // view: canvas
- // })
- //PNG==========================================================================================
- //game
- GD.loader.add('game_bg', RES_DIR_PNG + "game/" + "game_bg_0001.png");
- GD.loader.add('game_bg_fever', RES_DIR_PNG + "game/" + "game_bg_fever_0001.png");
- GD.loader.add('game_table', RES_DIR_PNG + "game/" + "game_table_0001.png");
- GD.loader.add('ready_bg', RES_DIR_PNG + "game/" + "ready_bg_0001.png");
- GD.loader.add('shadow_bg', RES_DIR_PNG + "game/" + "shadow_bg.png");
- //Medal achievement image
- GD.loader.add('game_medal_1', RES_DIR_IMG + "game_medal_0001.png");
- GD.loader.add('game_medal_2', RES_DIR_IMG + "game_medal_0002.png");
- GD.loader.add('game_medal_3', RES_DIR_IMG + "game_medal_0003.png");
- GD.loader.add('game_medal_4', RES_DIR_IMG + "game_medal_0004.png");
- //JSON====================================================================================
- //number
- GD.loader.add(RES_DIR_JSON + "number/" + "number.json");
- //game
- GD.loader.add(RES_DIR_JSON + "game/" + "game_icon.json");
- GD.loader.add(RES_DIR_JSON + "game/" + "game_text.json");
- //animation
- GD.loader.add(RES_DIR_JSON + "ani/" + "bomb_item_effect.json");
- GD.loader.add(RES_DIR_JSON + "ani/" + "clear_effect.json");
- GD.loader.add(RES_DIR_JSON + "ani/" + "cookie.json");
- GD.loader.add(RES_DIR_JSON + "ani/" + "eraser_item_effect.json");
- GD.loader.add(RES_DIR_JSON + "ani/" + "fever_effect1.json");
- GD.loader.add(RES_DIR_JSON + "ani/" + "fever_effect2_1.json");
- GD.loader.add(RES_DIR_JSON + "ani/" + "fever_effect2_2.json");
- GD.loader.add(RES_DIR_JSON + "ani/" + "fever_effect2_3.json");
- GD.loader.add(RES_DIR_JSON + "ani/" + "fever_effect2_4.json");
- GD.loader.add(RES_DIR_JSON + "ani/" + "item_effect.json");
- GD.loader.add(RES_DIR_JSON + "ani/" + "momo_fever.json");
- GD.loader.add(RES_DIR_JSON + "ani/" + "momo_normal.json");
- GD.loader.add(RES_DIR_JSON + "ani/" + "shushu_fever.json");
- GD.loader.add(RES_DIR_JSON + "ani/" + "shushu_normal.json");
- //intro
- GD.loader.add(RES_DIR_JSON + "intro/" + "intro.json");
- //tutorial
- GD.loader.add(RES_DIR_JSON + "tutorial/" + "tutorialUI.json");
- if (GD.leng == 'ko') {
- GD.loader.add(RES_DIR_JSON + "tutorial/" + "tutorial1.json");
- GD.loader.add(RES_DIR_JSON + "tutorial/" + "tutorial2.json");
- GD.loader.add(RES_DIR_JSON + "tutorial/" + "tutorial3.json");
- GD.loader.add(RES_DIR_JSON + "tutorial/" + "tutorial4.json");
- } else {
- GD.loader.add(RES_DIR_JSON + "tutorial/" + "tutorial1_" + GD.leng + ".json");
- GD.loader.add(RES_DIR_JSON + "tutorial/" + "tutorial2_" + GD.leng + ".json");
- GD.loader.add(RES_DIR_JSON + "tutorial/" + "tutorial3_" + GD.leng + ".json");
- GD.loader.add(RES_DIR_JSON + "tutorial/" + "tutorial4_" + GD.leng + ".json");
- }
- GD.loader.load(loadSound);
- GD.showProgress();
- function loadSound(loader, resource) {
- //Sound list settings
- var soundList = ['sound_bgm'];
- var effectList = [
- 'sound_fever',
- 'sound_match_1',
- 'sound_match_2',
- 'sound_match_3',
- 'sound_match_fever',
- 'sound_ready',
- 'sound_start',
- 'sound_gameover',
- 'sound_momotime',
- 'sound_use'
- ];
- if (GD.soundType == 1) soundList = soundList.concat(effectList);
- GD.loadSound(soundList, onAssetsLoaded);
- }
- function onAssetsLoaded() {
- console.log(1);
- // Remove loading screen
- GD.hideProgress();
- onIntro();
- gc.IS_MOBILE = true;
- GD.app.ticker.add(objSdk.update, null, PIXI.UPDATE_PRIORITY.UTILITY);
- // mobileChcck();
- }
- // Intro
- function onIntro() {
- GD.stage.removeChildren();
- objSdk.showAdIcon(10, 880);
- // Common Tutorials
- GD.tutorial = GD.Tutorial.getInstance();
- GD.tutorial.init(7, 'tutorial_', 'help_prev', 'help_next');
- GD.tutorial.setPrevButtonPos(60, GD.height / 2);
- GD.tutorial.setNextButtonPos(GD.width - 60, GD.height / 2);
- //GD.tutorial.setCloseButtonPos(x, y);
- // Intro
- var space = 270, posY = 1070;
- gc.intro = GD.CommonIntro.getInstance('w', 'intro_bg');
- gc.intro.initHelp('intro_help_btn', GD.width / 2 - space, posY);
- gc.intro.initSound('intro_option_btn', GD.width / 2 + space, posY);
- gc.intro.initStart('intro_start_btn', GD.width / 2, posY, function () {
- GD.fullScreen();
- onGame();
- }, this);
- gc.intro.init();
- GD.stage.addChild(gc.intro);
- }
- // game
- function onGame() {
- GD.stage.removeChildren();
- GD.objSdk.hideAdIcon();
- // game
- gc.game = gc.GameScene.getInstance();
- gc.game.init();
- GD.stage.addChild(gc.game);
- // Common option button
- GD.commonOption = GD.CommonOption.getInstance('w');
- GD.commonOption.on('OPTION_OPEN_EVENT', onOptionOpen);
- GD.commonOption.on('OPTION_CLOSE_EVENT', onOptionClose);
- GD.commonOption.on('GAME_RESTART', gameRestart);
- GD.commonOption.init();
- GD.stage.addChild(GD.commonOption);
- GD.bgmPlay(0.8);
- }
- function onOptionOpen() {
- gc.game.pause();
- }
- function onOptionClose() {
- gc.game.resume();
- }
- //Check whether you are mobile
- function mobileChcck() {
- var mobileKeyWords = ['iphone', 'ipod', 'blackberry', 'android', 'windows ce', 'lg', 'mot', 'samsung', 'sonyericsson', 'meego', 'nokia', 'webos', 'opera mini', 'opera mobi', 'iemobile'];
- gc.IS_MOBILE = false;
- var browerAgent = navigator.userAgent.toLowerCase();
- for (var i = 0; i < mobileKeyWords.length; ++i) {
- if (browerAgent.indexOf(mobileKeyWords[i]) != -1) {
- gc.IS_MOBILE = true;
- break;
- }
- }
- }
- // Restart game
- function gameRestart() {
- onIntro();
- }
- wx.onShareAppMessage(function () {
- return {
- title: "不许动,把平底锅交出来!",
- imageUrl: "https://pub.dwstatic.com/wxgame/momobakery/image/share.jpg",
- query: ""
- }
- })
- wx.showShareMenu({
- withShareTicket: false
- })
|