Fix: ES6 -> ES5 (imcompleted)
This commit is contained in:
@@ -1,27 +1,22 @@
|
||||
/////////////////////////////
|
||||
// MenuTypingTest
|
||||
|
||||
class MenuTypingTest {
|
||||
|
||||
var MenuTypingTest = {
|
||||
preload() {
|
||||
game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png');
|
||||
game.load.image('space_invaders', '../../../resources/image/icon/space_invaders.png');
|
||||
|
||||
Animal.loadResources();
|
||||
}
|
||||
},
|
||||
|
||||
create() {
|
||||
self = this;
|
||||
this.game.stage.backgroundColor = '#4d4d4d';
|
||||
game.stage.backgroundColor = '#4d4d4d';
|
||||
|
||||
// typing app area
|
||||
let typingBG = new AppAreaBG(AppAreaBG.COLOR_TYPING_APP, 1,
|
||||
var typingBG = new AppAreaBG(AppAreaBG.COLOR_TYPING_APP, 1,
|
||||
0, 60,
|
||||
GAME_SCREEN_SIZE.x, GAME_SCREEN_SIZE.y - 110
|
||||
);
|
||||
|
||||
// korean app area
|
||||
// let koreanBG = new AppAreaBG(AppAreaBG.COLOR_TYPING_KOREAN, 1,
|
||||
// var koreanBG = new AppAreaBG(AppAreaBG.COLOR_TYPING_KOREAN, 1,
|
||||
// 0, 60 + AppAreaBG.GAP_Y,
|
||||
// GAME_SCREEN_SIZE.x, 270
|
||||
// );
|
||||
@@ -32,7 +27,7 @@ class MenuTypingTest {
|
||||
// );
|
||||
|
||||
// english app area
|
||||
// let englishBG = new AppAreaBG(AppAreaBG.COLOR_TYPING_ENGLISH, 1,
|
||||
// var englishBG = new AppAreaBG(AppAreaBG.COLOR_TYPING_ENGLISH, 1,
|
||||
// 0, 340,
|
||||
// GAME_SCREEN_SIZE.x, 270
|
||||
// );
|
||||
@@ -44,7 +39,7 @@ class MenuTypingTest {
|
||||
|
||||
|
||||
// top ui
|
||||
let screenTopUI = new ScreenTopUI();
|
||||
var screenTopUI = new ScreenTopUI();
|
||||
screenTopUI.makeBackButton( function() {
|
||||
location.href = '../../web/client/menu_app.html';
|
||||
});
|
||||
@@ -52,177 +47,181 @@ class MenuTypingTest {
|
||||
|
||||
|
||||
// typing tab buttons
|
||||
let typingPracticeTabButton = new TypingTabButton(
|
||||
var typingPracticeTabButton = new TypingTabButton(
|
||||
TypingTabButton.PRACTICE_BUTTON_POS_X, TypingTabButton.BUTTON_POS_Y,
|
||||
"", "타자 연습",
|
||||
(function() {
|
||||
location.href = '../../web/client/menu_typing_practice.html';
|
||||
})
|
||||
);
|
||||
// typingPracticeTabButton.inputEnabled = false;
|
||||
// typingPracticeTabButton.setInputEnabled(false);
|
||||
|
||||
let typingTestTabButton = new TypingTabButton(
|
||||
var typingTestTabButton = new TypingTabButton(
|
||||
TypingTabButton.TEST_BUTTON_POS_X, TypingTabButton.BUTTON_POS_Y,
|
||||
"", "타자 시험",
|
||||
(function() {
|
||||
location.href = '../../web/client/menu_typing_test.html';
|
||||
})
|
||||
);
|
||||
typingTestTabButton.inputEnabled = false;
|
||||
typingTestTabButton.setInputEnabled(false);
|
||||
|
||||
this.makeActiveTypingTestAppButtons();
|
||||
|
||||
|
||||
// bottom ui
|
||||
let screenBottomUI = new ScreenBottomUI();
|
||||
var screenBottomUI = new ScreenBottomUI();
|
||||
// screenBottomUI.printLeftText("게임 진행 정보");
|
||||
screenBottomUI.printCenterText("메뉴 > 타자 시험");
|
||||
screenBottomUI.printRightText(sessionStorageManager.playerName);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
makeActiveTypingTestAppButtons() {
|
||||
let dbConnectManager = new DBConnectManager();
|
||||
makeActiveTypingTestAppButtons: function() {
|
||||
var dbConnectManager = new DBConnectManager();
|
||||
dbConnectManager.requestTypingTestAppList(
|
||||
sessionStorageManager.maestroID,
|
||||
sessionStorageManager.playerID,
|
||||
self.downloadListSucceeded,
|
||||
self.downloadListFailed
|
||||
// self.downloadListSucceeded,
|
||||
// self.downloadListFailed
|
||||
(function(replyJSON) {
|
||||
this.downloadListSucceeded(replyJSON);
|
||||
}).bind(this),
|
||||
(function(replyJSON) {
|
||||
this.downloadListFailed(replyJSON);
|
||||
}).bind(this)
|
||||
);
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
hasApp(appID, appList) {
|
||||
for(let i = 0; i < appList.length; i++) {
|
||||
hasApp: function(appID, appList) {
|
||||
for(var i = 0; i < appList.length; i++) {
|
||||
if(appList[i].AppID === appID)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
getBestRecord(jsonList, appID) {
|
||||
let count = Object.keys(jsonList).length;
|
||||
getBestRecord: function(jsonList, appID) {
|
||||
var count = Object.keys(jsonList).length;
|
||||
|
||||
for(let i = 0; i < count; i++) {
|
||||
for(var i = 0; i < count; i++) {
|
||||
if(jsonList[i].AppID === appID)
|
||||
return jsonList[i].BestRecord;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
|
||||
getIconImage(jsonList, appID) {
|
||||
let bestRecord = this.getBestRecord(jsonList, appID);
|
||||
getIconImage: function(jsonList, appID) {
|
||||
var bestRecord = this.getBestRecord(jsonList, appID);
|
||||
|
||||
if(bestRecord === 0)
|
||||
return "snail_shadow";
|
||||
|
||||
let animalLevel = Animal.animalLevelIDByRecord(bestRecord, Animal.TYPE_TEST);
|
||||
var animalLevel = Animal.animalLevelIDByRecord(bestRecord, Animal.TYPE_TEST);
|
||||
return Animal.SPECIES_DATA[animalLevel].species + Animal.SPRITE_NAMES.icon;
|
||||
}
|
||||
},
|
||||
|
||||
downloadListSucceeded(replyJSON) {
|
||||
downloadListSucceeded: function(replyJSON) {
|
||||
// console.log(replyJSON);
|
||||
|
||||
let buttonWidthGap = TypingAppButton.BUTTON_WIDTH + MenuTypingTest.BUTTON_GAP;
|
||||
var buttonWidthGap = TypingAppButton.BUTTON_WIDTH + MenuTypingTest.BUTTON_GAP;
|
||||
|
||||
let koreanTypingPracticeAppCount = Object.keys(replyJSON.KoreanAppList).length;
|
||||
let englishTypingPracticeAppCount = Object.keys(replyJSON.EnglishAppList).length;
|
||||
var koreanTypingPracticeAppCount = Object.keys(replyJSON.KoreanAppList).length;
|
||||
var englishTypingPracticeAppCount = Object.keys(replyJSON.EnglishAppList).length;
|
||||
|
||||
for(let i = 0; i < koreanTypingPracticeAppCount; i++) {
|
||||
let activeApp = replyJSON.KoreanAppList[i];
|
||||
for(var i = 0; i < koreanTypingPracticeAppCount; i++) {
|
||||
var activeApp = replyJSON.KoreanAppList[i];
|
||||
|
||||
let posX = self.getButtonPosX(i, koreanTypingPracticeAppCount);
|
||||
let posY = self.getButtonPosY(i, koreanTypingPracticeAppCount,
|
||||
var posX = this.getButtonPosX(i, koreanTypingPracticeAppCount);
|
||||
var posY = this.getButtonPosY(i, koreanTypingPracticeAppCount,
|
||||
TypingAppButton.BUTTON_UPPER_POS_Y
|
||||
);
|
||||
|
||||
let typingTestButton = new TypingAppButton(
|
||||
var typingTestButton = new TypingAppButton(
|
||||
TypingAppButton.TYPE_TEST_KOREAN,
|
||||
posX, posY,
|
||||
self.getIconImage(replyJSON.KoreanHighScoreList, activeApp.AppID),
|
||||
this.getIconImage(replyJSON.KoreanHighScoreList, activeApp.AppID),
|
||||
activeApp.KoreanName,
|
||||
(function() {
|
||||
sessionStorageManager.playingAppID = activeApp.AppID;
|
||||
sessionStorageManager.playingAppName = activeApp.AppName;
|
||||
sessionStorageManager.playingAppKoreanName = activeApp.KoreanName;
|
||||
location.href = '../../web/client/start.html';
|
||||
})
|
||||
{
|
||||
AppID: activeApp.AppID,
|
||||
AppName: activeApp.AppName,
|
||||
KoreanName: activeApp.KoreanName
|
||||
}
|
||||
);
|
||||
|
||||
if(!self.hasApp(activeApp.AppID, replyJSON.KoreanActiveAppList))
|
||||
typingTestButton.inputEnabled = false;
|
||||
if(!this.hasApp(activeApp.AppID, replyJSON.KoreanActiveAppList))
|
||||
typingTestButton.setInputEnabled(false);
|
||||
}
|
||||
|
||||
for(let i = 0; i < englishTypingPracticeAppCount; i++) {
|
||||
let activeApp = replyJSON.EnglishAppList[i];
|
||||
for(var i = 0; i < englishTypingPracticeAppCount; i++) {
|
||||
var activeApp = replyJSON.EnglishAppList[i];
|
||||
|
||||
let posX = self.getButtonPosX(i, englishTypingPracticeAppCount);
|
||||
let posY = self.getButtonPosY(i, englishTypingPracticeAppCount,
|
||||
var posX = this.getButtonPosX(i, englishTypingPracticeAppCount);
|
||||
var posY = this.getButtonPosY(i, englishTypingPracticeAppCount,
|
||||
TypingAppButton.BUTTON_LOWER_POS_Y
|
||||
);
|
||||
|
||||
let typingTestButton = new TypingAppButton(
|
||||
var typingTestButton = new TypingAppButton(
|
||||
TypingAppButton.TYPE_TEST_ENGLISH,
|
||||
posX, posY,
|
||||
self.getIconImage(replyJSON.KoreanHighScoreList, activeApp.AppID),
|
||||
this.getIconImage(replyJSON.KoreanHighScoreList, activeApp.AppID),
|
||||
activeApp.KoreanName,
|
||||
(function() {
|
||||
sessionStorageManager.playingAppID = activeApp.AppID;
|
||||
sessionStorageManager.playingAppName = activeApp.AppName;
|
||||
sessionStorageManager.playingAppKoreanName = activeApp.KoreanName;
|
||||
location.href = '../../web/client/start.html';
|
||||
})
|
||||
{
|
||||
AppID: activeApp.AppID,
|
||||
AppName: activeApp.AppName,
|
||||
KoreanName: activeApp.KoreanName
|
||||
}
|
||||
);
|
||||
|
||||
if(!self.hasApp(activeApp.AppID, replyJSON.EnglishActiveAppList))
|
||||
typingTestButton.inputEnabled = false;
|
||||
if(!this.hasApp(activeApp.AppID, replyJSON.EnglishActiveAppList))
|
||||
typingTestButton.setInputEnabled(false);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getButtonPosX(index, buttonCount) {
|
||||
let gap = TypingAppButton.BUTTON_WIDTH + TypingAppButton.BUTTON_GAP;
|
||||
let maxColumnNum = Math.floor( (game.world.width - TypingAppButton.MARGIN_VERTICAL) / gap );
|
||||
getButtonPosX: function(index, buttonCount) {
|
||||
var gap = TypingAppButton.BUTTON_WIDTH + TypingAppButton.BUTTON_GAP;
|
||||
var maxColumnNum = Math.floor( (game.world.width - TypingAppButton.MARGIN_VERTICAL) / gap );
|
||||
// console.log("maxColumnNum : " + maxColumnNum);
|
||||
let rowCount = Math.ceil(buttonCount / maxColumnNum);
|
||||
var rowCount = Math.ceil(buttonCount / maxColumnNum);
|
||||
// console.log("rowCount : " + rowCount);
|
||||
|
||||
let columnIndex = index % maxColumnNum;
|
||||
var columnIndex = index % maxColumnNum;
|
||||
// console.log("columnIndex : " + columnIndex);
|
||||
let rowIndex = Math.floor(index / maxColumnNum);
|
||||
var rowIndex = Math.floor(index / maxColumnNum);
|
||||
// console.log("rowIndex : " + rowIndex);
|
||||
|
||||
let columnCountForThisRow = 0;
|
||||
var columnCountForThisRow = 0;
|
||||
if(rowIndex < rowCount - 1)
|
||||
columnCountForThisRow = maxColumnNum;
|
||||
else
|
||||
columnCountForThisRow = buttonCount - (maxColumnNum * rowIndex);
|
||||
// console.log("columnCountForThisRow : " + columnCountForThisRow);
|
||||
|
||||
let startX = game.world.width / 2 - ( (gap / 2) * (columnCountForThisRow - 1) );
|
||||
var startX = game.world.width / 2 - ( (gap / 2) * (columnCountForThisRow - 1) );
|
||||
return startX + gap * columnIndex;
|
||||
}
|
||||
},
|
||||
|
||||
getButtonPosY(index, buttonCount, startPosY) {
|
||||
let rowGap = TypingAppButton.BUTTON_HEIGHT + TypingAppButton.BUTTON_GAP;
|
||||
getButtonPosY: function(index, buttonCount, startPosY) {
|
||||
var rowGap = TypingAppButton.BUTTON_HEIGHT + TypingAppButton.BUTTON_GAP;
|
||||
|
||||
let columnGap = TypingAppButton.BUTTON_WIDTH + TypingAppButton.BUTTON_GAP;
|
||||
let maxColumnNum = Math.floor( (game.world.width - TypingAppButton.MARGIN_VERTICAL) / columnGap );
|
||||
var columnGap = TypingAppButton.BUTTON_WIDTH + TypingAppButton.BUTTON_GAP;
|
||||
var maxColumnNum = Math.floor( (game.world.width - TypingAppButton.MARGIN_VERTICAL) / columnGap );
|
||||
// console.log("maxColumnNum : " + maxColumnNum);
|
||||
// console.log("buttonCount : " + buttonCount);
|
||||
let rowCount = Math.ceil(buttonCount / maxColumnNum);
|
||||
var rowCount = Math.ceil(buttonCount / maxColumnNum);
|
||||
// console.log("rowCount : " + rowCount);
|
||||
|
||||
let rowIndex = Math.floor(index / maxColumnNum);
|
||||
var rowIndex = Math.floor(index / maxColumnNum);
|
||||
// console.log("rowIndex : " + rowIndex);
|
||||
|
||||
let startY = startPosY - ( (rowGap / 2) * (rowCount - 1) );
|
||||
var startY = startPosY - ( (rowGap / 2) * (rowCount - 1) );
|
||||
return startY + rowGap * rowIndex;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
downloadListFailed(replyJSON) {
|
||||
downloadListFailed: function(replyJSON) {
|
||||
console.log('download app list failed, jsonData : ' + JSON.stringify(replyJSON));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user