Add: menu typing practice

This commit is contained in:
2018-06-02 16:55:05 +09:00
parent 7341be330f
commit b91986393b
4 changed files with 116 additions and 3 deletions
+101
View File
@@ -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));
}
}