Fix: ES6 -> ES5 (imcompleted)

This commit is contained in:
2018-09-14 11:15:24 +09:00
parent bccee696d4
commit 1a2d9e6800
15 changed files with 832 additions and 819 deletions
+13 -17
View File
@@ -1,21 +1,17 @@
class AppAreaBG {
function AppAreaBG(color, alpha, x, y, width, height) {
game.add.graphics()
.beginFill(color, alpha)
.drawRect(x, y, width, height);
}
constructor(color, alpha, x, y, width, height) {
game.add.graphics()
.beginFill(color, alpha)
.drawRect(x, y, width, height);
}
printText(text, x, y, size, color, alpha) {
let fontStyle = { font: "36px Arial", fill: "#fff", align: "left", boundsAlignH: "left", boundsAlignV: "bottom" };
let titleText = game.add.text(x, y, text, fontStyle);
titleText.anchor.set(0.5);
titleText.fontSize = size;
titleText.addColor(color, 0);
titleText.alpha = alpha;
}
};
AppAreaBG.prototype.printText = function(text, x, y, size, color, alpha) {
let fontStyle = { font: "36px Arial", fill: "#fff", align: "left", boundsAlignH: "left", boundsAlignV: "bottom" };
let titleText = game.add.text(x, y, text, fontStyle);
titleText.anchor.set(0.5);
titleText.fontSize = size;
titleText.addColor(color, 0);
titleText.alpha = alpha;
}
AppAreaBG.COLOR_MOUSE_APP = 0xffce54;
AppAreaBG.COLOR_TYPING_APP = 0x99ccff;
+88 -88
View File
@@ -1,18 +1,15 @@
/////////////////////////////
// MenuApp
var MenuApp = {
class MenuApp {
preload() {
preload: function() {
game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png');
}
},
create() {
self = this;
this.game.stage.backgroundColor = '#4d4d4d';
create: function() {
game.stage.backgroundColor = '#4d4d4d';
// mouse app area
let mouseBG = new AppAreaBG(AppAreaBG.COLOR_MOUSE_APP, 1,
var mouseBG = new AppAreaBG(
AppAreaBG.COLOR_MOUSE_APP, 1,
0, 60,
GAME_SCREEN_SIZE.x, 280
);
@@ -23,7 +20,8 @@ class MenuApp {
);
// typing app area
let typingBG = new AppAreaBG(AppAreaBG.COLOR_TYPING_APP, 1,
var typingBG = new AppAreaBG(
AppAreaBG.COLOR_TYPING_APP, 1,
0, 340,
GAME_SCREEN_SIZE.x, 378
);
@@ -35,7 +33,7 @@ class MenuApp {
// top ui
let screenTopUI = new ScreenTopUI();
var screenTopUI = new ScreenTopUI();
screenTopUI.makeBackButton( function() {
sessionStorageManager.clear();
location.href = '../../web/client/login.html';
@@ -44,9 +42,9 @@ class MenuApp {
// bottom ui
let screenBottomUI = new ScreenBottomUI();
var screenBottomUI = new ScreenBottomUI();
// ScreenBottomUI.printLeftText("게임 진행 정보");
// let playingAppName = appInfoManager.getAppNameKorean(sessionStorageManager.playingAppName);
// var playingAppName = appInfoManager.getAppNameKorean(sessionStorageManager.playingAppName);
// ScreenBottomUI.printCenterText(playingAppName);
screenBottomUI.printCenterText("메뉴");
screenBottomUI.printRightText(sessionStorageManager.playerName);
@@ -55,83 +53,87 @@ class MenuApp {
this.loadAppData();
}
},
loadAppData() {
let dbConnectManager = new DBConnectManager();
loadAppData: function() {
var dbConnectManager = new DBConnectManager();
dbConnectManager.requestMenuAppList(
sessionStorageManager.maestroID,
self.loadSucceeded,
self.loadFailed
(function(replyJSON) {
this.loadSucceeded(replyJSON);
}).bind(this),
(function(replyJSON) {
this.loadFailed(replyJSON);
}).bind(this)
);
}
},
loadSucceeded(replyJSON) {
loadSucceeded: function(replyJSON) {
// console.log(replyJSON);
self.makeMouseAppButtons(
this.makeMouseAppButtons(
replyJSON.MouseAppList,
replyJSON.MouseActiveAppList
);
self.makeTypingButtons(
this.makeTypingButtons(
replyJSON.TypingPracticeAppCount,
replyJSON.TypingTestAppCount,
replyJSON.TypingAppList,
replyJSON.TypingActiveAppList
);
}
},
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;
}
},
makeMouseAppButtons(appList, activeAppList) {
makeMouseAppButtons: function(appList, activeAppList) {
// console.log(appList);
let mouseAppCount = Object.keys(appList).length;
var mouseAppCount = Object.keys(appList).length;
for(let i = 0; i < mouseAppCount; i++) {
let posX = self.getButtonPosX(i, mouseAppCount);
let posY = self.getButtonPosY(i, mouseAppCount, GameAppButton.BUTTON_UPPER_POS_Y);
for(var i = 0; i < mouseAppCount; i++) {
var posX = this.getButtonPosX(i, mouseAppCount);
var posY = this.getButtonPosY(i, mouseAppCount, GameAppButton.BUTTON_UPPER_POS_Y);
let app = appList[i];
let gameAppButton = new GameAppButton(
posX, posY, GameAppButton.TYPE_MOUSE_APP,
RoundRectButton.NONE_ICON, // "icon_fullscreen",
app.KoreanName,
(function() {
sessionStorageManager.playingAppID = app.AppID;
sessionStorageManager.playingAppName = app.AppName;
sessionStorageManager.playingAppKoreanName = app.KoreanName;
location.href = '../../web/client/start.html';
})
var app = appList[i];
var gameAppButton = new GameAppButton(
posX, posY,
GameAppButton.TYPE_MOUSE_APP,
RoundRectButton.NONE_ICON, app.KoreanName,
{
AppID: app.AppID,
AppName: app.AppName,
KoreanName: app.KoreanName
}
);
if(!self.hasApp(app.AppID, activeAppList))
gameAppButton.inputEnabled = false;
if(!this.hasApp(app.AppID, activeAppList))
gameAppButton.setInputEnabled(false);
}
}
},
makeTypingButtons(typingPracticeAppCount, typingTestAppCount, appList, activeAppList) {
makeTypingButtons: function(typingPracticeAppCount, typingTestAppCount, appList, activeAppList) {
// console.log(typingPracticeAppCount);
// console.log(typingTestAppCount);
// console.log(appList);
let isTypingPracticeAppExist = typingPracticeAppCount > 0 ? true : false;
let isTypingTestAppExist = typingTestAppCount > 0 ? true : false;
var isTypingPracticeAppExist = typingPracticeAppCount > 0 ? true : false;
var isTypingTestAppExist = typingTestAppCount > 0 ? true : false;
let typingAppTotalCount = Object.keys(appList).length;
let typingAppIndex = 0;
var typingAppTotalCount = Object.keys(appList).length;
var typingAppIndex = 0;
// typing tab buttons
let typingPracticeTabButton = new TypingTabButton(
var typingPracticeTabButton = new TypingTabButton(
TypingTabButton.PRACTICE_BUTTON_POS_X, TypingTabButton.BUTTON_POS_Y,
"", "타자 연습",
(function() {
@@ -139,9 +141,9 @@ class MenuApp {
})
);
if(typingPracticeAppCount === 0)
typingPracticeTabButton.inputEnabled = false;
typingPracticeTabButton.setInputEnabled(false);
let typingTestTabButton = new TypingTabButton(
var typingTestTabButton = new TypingTabButton(
TypingTabButton.TEST_BUTTON_POS_X, TypingTabButton.BUTTON_POS_Y,
"", "타자 시험",
(function() {
@@ -149,81 +151,79 @@ class MenuApp {
})
);
if(typingTestAppCount === 0)
typingTestTabButton.inputEnabled = false;
typingTestTabButton.setInputEnabled(false);
// typing app buttons
for(let typingButtonIndex = 0; typingButtonIndex < typingAppTotalCount; typingButtonIndex++) {
for(var typingButtonIndex = 0; typingButtonIndex < typingAppTotalCount; typingButtonIndex++) {
let posX = self.getButtonPosX(
var posX = this.getButtonPosX(
typingButtonIndex, typingAppTotalCount
);
let posY = self.getButtonPosY(
var posY = this.getButtonPosY(
typingButtonIndex, typingAppTotalCount, GameAppButton.BUTTON_LOWER_POS_Y
);
let app = appList[typingAppIndex];
let isKoreanTypingApp = app.AppID < 32 ? true : false;
var app = appList[typingAppIndex];
var isKoreanTypingApp = app.AppID < 32 ? true : false;
let gameAppButton = new GameAppButton(
var gameAppButton = new GameAppButton(
posX, posY, GameAppButton.TYPE_TYPING_APP,
RoundRectButton.NONE_ICON, // "icon_fullscreen",
// (isKoreanTypingApp ? "(한글)" : "(영문)") + "\n" + app.KoreanName,
app.KoreanName,
(function() {
sessionStorageManager.playingAppID = app.AppID;
sessionStorageManager.playingAppName = app.AppName;
sessionStorageManager.playingAppKoreanName = app.KoreanName;
location.href = '../../web/client/start.html';
})
{
AppID: app.AppID,
AppName: app.AppName,
KoreanName: app.KoreanName
}
);
if(!self.hasApp(app.AppID, activeAppList))
gameAppButton.inputEnabled = false;
if(!this.hasApp(app.AppID, activeAppList))
gameAppButton.setInputEnabled(false);
typingAppIndex++;
}
}
},
getButtonPosX(index, buttonCount) {
let gap = GameAppButton.BUTTON_WIDTH + GameAppButton.BUTTON_GAP;
let maxColumnNum = Math.floor( (game.world.width - GameAppButton.MARGIN_VERTICAL) / gap );
getButtonPosX: function(index, buttonCount) {
var gap = GameAppButton.BUTTON_WIDTH + GameAppButton.BUTTON_GAP;
var maxColumnNum = Math.floor( (game.world.width - GameAppButton.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 gap = GameAppButton.BUTTON_HEIGHT + GameAppButton.BUTTON_GAP;
let maxColumnNum = Math.floor( (game.world.width - GameAppButton.MARGIN_VERTICAL) / gap );
getButtonPosY: function(index, buttonCount, startPosY) {
var gap = GameAppButton.BUTTON_HEIGHT + GameAppButton.BUTTON_GAP;
var maxColumnNum = Math.floor( (game.world.width - GameAppButton.MARGIN_VERTICAL) / gap );
// console.log("maxColumnNum : " + maxColumnNum);
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 - ( (gap / 2) * (rowCount - 1) );
var startY = startPosY - ( (gap / 2) * (rowCount - 1) );
return startY + gap * rowIndex;
}
},
loadFailed(replyJSON) {
loadFailed: function(replyJSON) {
// console.log('login failed, jsonData : ' + JSON.stringify(replyJSON));
}
}
+82 -86
View File
@@ -1,27 +1,22 @@
/////////////////////////////
// MenuTypingPractice
class MenuTypingPractice {
var MenuTypingPractice = {
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,
// AppAreaBG.MARGIN_X, 60 + AppAreaBG.GAP_Y,
// GAME_SCREEN_SIZE.x - AppAreaBG.MARGIN_X * 2, 270
// );
@@ -32,7 +27,7 @@ class MenuTypingPractice {
// );
// english app area
// let englishBG = new AppAreaBG(AppAreaBG.COLOR_TYPING_ENGLISH, 1,
// var englishBG = new AppAreaBG(AppAreaBG.COLOR_TYPING_ENGLISH, 1,
// AppAreaBG.MARGIN_X, 340,
// GAME_SCREEN_SIZE.x - AppAreaBG.MARGIN_X * 2, 270
// );
@@ -44,7 +39,7 @@ class MenuTypingPractice {
// top ui
let screenTopUI = new ScreenTopUI();
var screenTopUI = new ScreenTopUI();
screenTopUI.makeBackButton( function() {
location.href = '../../web/client/menu_app.html';
});
@@ -52,178 +47,179 @@ class MenuTypingPractice {
// 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);
// bottom ui
let screenBottomUI = new ScreenBottomUI();
var screenBottomUI = new ScreenBottomUI();
// screenBottomUI.printLeftText("게임 진행 정보");
screenBottomUI.printCenterText("메뉴 > 타자 연습");
screenBottomUI.printRightText(sessionStorageManager.playerName);
this.makeActiveTypingPracticeAppButtons();
}
},
makeActiveTypingPracticeAppButtons() {
let dbConnectManager = new DBConnectManager();
makeActiveTypingPracticeAppButtons: function() {
var dbConnectManager = new DBConnectManager();
dbConnectManager.requestTypingPracticeAppList(
sessionStorageManager.maestroID,
sessionStorageManager.playerID,
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_PRACTICE);
var animalLevel = Animal.animalLevelIDByRecord(bestRecord, Animal.TYPE_PRACTICE);
return Animal.SPECIES_DATA[animalLevel].species + Animal.SPRITE_NAMES.icon;
}
},
downloadListSucceeded(replyJSON) {
downloadListSucceeded: function(replyJSON) {
// console.log(replyJSON);
let buttonWidthGap = TypingAppButton.BUTTON_WIDTH + MenuTypingPractice.BUTTON_GAP;
var buttonWidthGap = TypingAppButton.BUTTON_WIDTH + MenuTypingPractice.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 typingPracticeButton = new TypingAppButton(
var typingPracticeButton = new TypingAppButton(
TypingAppButton.TYPE_PRACTICE_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))
typingPracticeButton.inputEnabled = false;
if(!this.hasApp(activeApp.AppID, replyJSON.KoreanActiveAppList))
typingPracticeButton.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 typingPracticeButton = new TypingAppButton(
var typingPracticeButton = new TypingAppButton(
TypingAppButton.TYPE_PRACTICE_ENGLISH,
posX, posY,
self.getIconImage(activeApp.AppID),
this.getIconImage(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))
typingPracticeButton.inputEnabled = false;
if(!this.hasApp(activeApp.AppID, replyJSON.EnglishActiveAppList))
typingPracticeButton.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));
}
}
+84 -85
View File
@@ -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));
}
+26 -22
View File
@@ -1,30 +1,34 @@
class WelcomePlayerText extends Phaser.Text {
WelcomePlayerText.prototype = Object.create(Phaser.Text.prototype);
WelcomePlayerText.constructor = WelcomePlayerText;
constructor(playerName) {
super(game, game.world.width / 2, game.world.height / 2 - 40, "어서오세요, " + playerName + "님", WelcomePlayerText.DEFAULT_TEXT_FONT);
function WelcomePlayerText(playerName) {
Phaser.Text.call(
this, game,
game.world.width / 2, game.world.height / 2 - 40,
"어서오세요, " + playerName + "님",
WelcomePlayerText.DEFAULT_TEXT_FONT
);
this.anchor.set(0.5);
this.inputEnabled = false;
this.anchor.set(0.5);
this.inputEnabled = false;
var grd = this.context.createLinearGradient(0, 0, 0, this.height);
grd.addColorStop(0, '#8ED6FF');
grd.addColorStop(1, '#4C6CB3');
this.fill = grd;
this.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
this.stroke = '#000';
this.strokeThickness = 5;
var grd = this.context.createLinearGradient(0, 0, 0, this.height);
grd.addColorStop(0, '#8ED6FF');
grd.addColorStop(1, '#4C6CB3');
this.fill = grd;
this.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
this.stroke = '#000';
this.strokeThickness = 5;
this.alpha = 1;
let tweenAlpha = game.add.tween(this);
tweenAlpha.to( { alpha: 0 }, 2000, Phaser.Easing.Back.In, true);
this.alpha = 1;
let tweenAlpha = game.add.tween(this);
tweenAlpha.to( { alpha: 0 }, 2000, Phaser.Easing.Back.In, true);
game.add.existing(this);
};
destroySelf() {
this.destroy();
}
game.add.existing(this);
}
WelcomePlayerText.prototype.destroySelf = function() {
this.destroy();
}
WelcomePlayerText.DEFAULT_TEXT_FONT = {
@@ -32,4 +36,4 @@ WelcomePlayerText.DEFAULT_TEXT_FONT = {
boundsAlignH: "center", // left, center. right
boundsAlignV: "middle", // top, middle, bottom
fill: "#fff"
};
}