diff --git a/src/game/menu/main_menu_typing_practice.js b/src/game/menu/main_menu_typing_practice.js new file mode 100644 index 0000000..e657f30 --- /dev/null +++ b/src/game/menu/main_menu_typing_practice.js @@ -0,0 +1,12 @@ +///////////////////////////// +// Main game + +const CONTENT_ID = "Menu"; + +let game = new Phaser.Game( + GAME_SCREEN_SIZE.x, GAME_SCREEN_SIZE.y, + Phaser.CANVAS, CONTENT_ID +); + +game.state.add('MenuTypingPractice', MenuTypingPractice); +game.state.start('MenuTypingPractice'); diff --git a/src/game/menu/menu_app.js b/src/game/menu/menu_app.js index f189eab..63d37fe 100644 --- a/src/game/menu/menu_app.js +++ b/src/game/menu/menu_app.js @@ -68,7 +68,7 @@ class MenuApp { if(typingAppCount > 0) { new AppButton(game.world.width / 2, 500, AppButton.TYPE_TYPING, "icon_fullscreen", () => { - location.href = '../../web/client/menu_typing_app.html'; + location.href = '../../web/client/menu_typing_practice.html'; } ); } diff --git a/src/game/menu/menu_typing_practice.js b/src/game/menu/menu_typing_practice.js new file mode 100644 index 0000000..44352e0 --- /dev/null +++ b/src/game/menu/menu_typing_practice.js @@ -0,0 +1,101 @@ +///////////////////////////// +// MenuApp + +class MenuTypingPractice { + + preload() { + game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png'); + game.load.image('space_invaders', '../../../resources/image/icon/space_invaders.png'); + } + + create() { + self = this; + this.game.stage.backgroundColor = '#4d4d4d'; + + // top + let backButton = new BackButton( () => { + sessionStorageManager.clear(); + location.href = '../../web/client/login.html'; + }); + let fullscreenButton = new FullscreenButton(this.game); + + + // bottom + let screenBottom = new ScreenBottom(); + screenBottom.makeBottomLine(); + // screenBottom.printBottomLeftText("게임 진행 정보"); + let playingAppName = appInfoManager.getAppNameKorean(sessionStorageManager.playingAppName); + screenBottom.printBottomCenterText(playingAppName); + screenBottom.printBottomRightText(sessionStorageManager.playerName); + + + this.makeActiveAppButtons(); + } + + + makeActiveAppButtons() { + let dbConnectManager = new DBConnectManager(); + dbConnectManager.requestActiveAppList( + sessionStorageManager.maestroID, + self.loginSucceeded, + self.loginFailed + ); + + } + + loginSucceeded(replyJSON) { + // console.log(replyJSON); + + let mouseAppCount = self.getAppCount(replyJSON, AppButton.TYPE_MOUSE); + let typingAppCount = self.getAppCount(replyJSON, AppButton.TYPE_TYPING); + + let startX = game.world.width / 2 - (150 * mouseAppCount / 2) - (150 / 2); + let mouseAppIndex = 0; + for(let i = 0; i < replyJSON.length; i++) { + let activeApp = replyJSON[i]; + if(self.isMouseApp(activeApp)) { + mouseAppIndex++; + new AppButton(startX + 150 * mouseAppIndex, 300, AppButton.TYPE_MOUSE, activeApp.AppName, + () => { + sessionStorageManager.playingAppID = activeApp.AppID; + sessionStorageManager.playingAppName = activeApp.AppName; + location.href = '../../web/client/start.html'; + } + ); + } + } + + if(typingAppCount > 0) { + new AppButton(game.world.width / 2, 500, AppButton.TYPE_TYPING, "icon_fullscreen", + () => { + location.href = '../../web/client/menu_typing_app.html'; + } + ); + } + } + + isMouseApp(app) { + if(app.AppType > 100) + return true; + + return false; + } + + getAppCount(replyJSON, type) { + let appCount = 0; + for(let i = 0; i < replyJSON.length; i++) { + let activeApp = replyJSON[i]; + if(type == AppButton.TYPE_TYPING && activeApp.AppType <= 100) + appCount++; + else if(type == AppButton.TYPE_MOUSE && activeApp.AppType > 100) + appCount++; + } + + return appCount; + } + + loginFailed(replyJSON) { + console.log('login failed, jsonData : ' + JSON.stringify(replyJSON)); + } + +} \ No newline at end of file diff --git a/src/web/client/menu_typing_app.html b/src/web/client/menu_typing_practice.html similarity index 89% rename from src/web/client/menu_typing_app.html rename to src/web/client/menu_typing_practice.html index 857c079..459cfd5 100644 --- a/src/web/client/menu_typing_app.html +++ b/src/web/client/menu_typing_practice.html @@ -24,8 +24,8 @@ - - + +