Add: menu typing practice
This commit is contained in:
@@ -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');
|
||||||
@@ -68,7 +68,7 @@ class MenuApp {
|
|||||||
if(typingAppCount > 0) {
|
if(typingAppCount > 0) {
|
||||||
new AppButton(game.world.width / 2, 500, AppButton.TYPE_TYPING, "icon_fullscreen",
|
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';
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -24,8 +24,8 @@
|
|||||||
<script src="../../game/lib/db_connect_manager.js"></script>
|
<script src="../../game/lib/db_connect_manager.js"></script>
|
||||||
|
|
||||||
<!-- source files -->
|
<!-- source files -->
|
||||||
<script src="../../game/menu/menu_app.js"></script>
|
<script src="../../game/menu/menu_typing_practice.js"></script>
|
||||||
<script src="../../game/menu/main_menu_app.js"></script>
|
<script src="../../game/menu/main_menu_typing_practice.js"></script>
|
||||||
|
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
Reference in New Issue
Block a user