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
+1 -1
View File
@@ -3,7 +3,7 @@ const LANGUAGE_ENGLISH = "english";
const MODE_RELEASE = "release"; const MODE_RELEASE = "release";
const MODE_DEBUG = "debug"; const MODE_DEBUG = "debug";
const runMode = MODE_RELEASE; const runMode = MODE_DEBUG;
function isDebugMode() { function isDebugMode() {
// console.log("debug mode ? " + runMode); // console.log("debug mode ? " + runMode);
+7 -3
View File
@@ -1,6 +1,7 @@
class BackButton extends RoundRectButton { BackButton.prototype = Object.create(RoundRectButton);
BackButton.constructor = BackButton;
constructor(clickEvent) { function BackButton(clickEvent) {
let setting = new RoundRectButtonSetting(30, 30, 50, 50); let setting = new RoundRectButtonSetting(30, 30, 50, 50);
setting.fontStyle.boundsAlignH = "center"; // left, center. right setting.fontStyle.boundsAlignH = "center"; // left, center. right
setting.fontStyle.boundsAlignV = "middle"; // top, middle, bottom setting.fontStyle.boundsAlignV = "middle"; // top, middle, bottom
@@ -24,7 +25,10 @@ class BackButton extends RoundRectButton {
"#333" "#333"
); );
super(setting, RoundRectButton.NONE_ICON, "<", clickEvent); new RoundRectButton(setting, RoundRectButton.NONE_ICON, "<", clickEvent);
} }
BackButton.prototype.startState = function(stateName) {
var game = this.backButton.parent.game;
game.state.start(stateName);
} }
+7 -8
View File
@@ -1,9 +1,10 @@
class FullscreenButton extends RoundRectButton { FullscreenButton.prototype = Object.create(RoundRectButton);
FullscreenButton.constructor = BackButton;
constructor() { function FullscreenButton() {
game.scale.fullScreenScaleMode = Phaser.ScaleManager.EXACT_FIT; game.scale.fullScreenScaleMode = Phaser.ScaleManager.EXACT_FIT;
let setting = new RoundRectButtonSetting(game.world.width - 30, 30, 50, 50); var setting = new RoundRectButtonSetting(game.world.width - 30, 30, 50, 50);
setting.fontStyle.boundsAlignH = "center"; // left, center. right setting.fontStyle.boundsAlignH = "center"; // left, center. right
setting.fontStyle.boundsAlignV = "middle"; // top, middle, bottom setting.fontStyle.boundsAlignV = "middle"; // top, middle, bottom
setting.strokeWidthPx = 3; setting.strokeWidthPx = 3;
@@ -26,7 +27,7 @@ class FullscreenButton extends RoundRectButton {
"#333" "#333"
); );
super( var button = new RoundRectButton(
setting, setting,
RoundRectButton.NONE_ICON, RoundRectButton.NONE_BUTTON_TEXT, RoundRectButton.NONE_ICON, RoundRectButton.NONE_BUTTON_TEXT,
(function() { (function() {
@@ -38,10 +39,8 @@ class FullscreenButton extends RoundRectButton {
}) })
); );
let icon_fullscreen = game.add.sprite(0, 0, 'icon_fullscreen'); var icon_fullscreen = game.add.sprite(0, 0, 'icon_fullscreen');
icon_fullscreen.width = 20; icon_fullscreen.width = 20;
icon_fullscreen.height = 20; icon_fullscreen.height = 20;
this.setIcon(icon_fullscreen); button.setIcon(icon_fullscreen);
}
} }
+19 -5
View File
@@ -1,7 +1,8 @@
class GameAppButton extends RoundRectButton { GameAppButton.prototype = Object.create(RoundRectButton.prototype);
GameAppButton.constructor = GameAppButton;
constructor(x, y, type, iconName, buttonText, clickEvent) { function GameAppButton(x, y, type, iconName, buttonText, appInfo) {
let setting = new RoundRectButtonSetting( var setting = new RoundRectButtonSetting(
x, y, x, y,
GameAppButton.BUTTON_WIDTH, GameAppButton.BUTTON_HEIGHT GameAppButton.BUTTON_WIDTH, GameAppButton.BUTTON_HEIGHT
); );
@@ -60,7 +61,7 @@ class GameAppButton extends RoundRectButton {
fill: "#fff" fill: "#fff"
}; };
let textCount = buttonText.length; var textCount = buttonText.length;
if(textCount > 7) if(textCount > 7)
setting.fontStyle.font = "18px Arial"; setting.fontStyle.font = "18px Arial";
else if(textCount > 5) else if(textCount > 5)
@@ -68,11 +69,24 @@ class GameAppButton extends RoundRectButton {
else else
setting.fontStyle.font = "24px Arial"; setting.fontStyle.font = "24px Arial";
super(setting, iconName, buttonText, clickEvent); this.appInfo = appInfo;
RoundRectButton.call(
this, setting,
iconName, buttonText,
this.clickEvent
);
} }
GameAppButton.prototype.clickEvent = function() {
sessionStorageManager.playingAppID = this.appInfo.AppID;
sessionStorageManager.playingAppName = this.appInfo.AppName;
sessionStorageManager.playingAppKoreanName = this.appInfo.KoreanName;
location.href = '../../web/client/start.html';
} }
GameAppButton.TYPE_MOUSE_APP = 0; GameAppButton.TYPE_MOUSE_APP = 0;
GameAppButton.TYPE_TYPING_PRACTICE = 1; GameAppButton.TYPE_TYPING_PRACTICE = 1;
GameAppButton.TYPE_TYPING_APP = 2; GameAppButton.TYPE_TYPING_APP = 2;
+30 -34
View File
@@ -1,13 +1,11 @@
class RoundRectButtonSetting { function RoundRectButtonSetting(x, y, width, height, roundAmount) {
constructor(x, y, width, height, roundAmount) {
this.x = x; this.x = x;
this.y = y; this.y = y;
this.width = width; this.width = width;
this.height = height; this.height = height;
this.roundAmount = 0; this.roundAmount = 0;
if(typeof roundAmount === "undefined") { if(typeof roundAmount === "undefined") {
let shorterSide = width > height ? height : width; var shorterSide = width > height ? height : width;
this.roundAmount = shorterSide * 0.1; this.roundAmount = shorterSide * 0.1;
} else { } else {
this.roundAmount = roundAmount; this.roundAmount = roundAmount;
@@ -21,7 +19,7 @@ class RoundRectButtonSetting {
this.fontStyle = RoundRectButtonSetting.DEFAULT_TEXT_FONT; this.fontStyle = RoundRectButtonSetting.DEFAULT_TEXT_FONT;
}; };
setStrokeColor(out, over, down, disabled) { RoundRectButtonSetting.prototype.setStrokeColor = function(out, over, down, disabled) {
this.strokeColors = { }; this.strokeColors = { };
this.strokeColors.out = out; this.strokeColors.out = out;
this.strokeColors.over = over; this.strokeColors.over = over;
@@ -29,7 +27,7 @@ class RoundRectButtonSetting {
this.strokeColors.disabled = disabled; this.strokeColors.disabled = disabled;
} }
setButtonColor(out, over, down, disabled) { RoundRectButtonSetting.prototype.setButtonColor = function(out, over, down, disabled) {
this.buttonColors = { }; this.buttonColors = { };
this.buttonColors.out = out; this.buttonColors.out = out;
this.buttonColors.over = over; this.buttonColors.over = over;
@@ -37,7 +35,7 @@ class RoundRectButtonSetting {
this.buttonColors.disabled = disabled; this.buttonColors.disabled = disabled;
} }
setTextColor(out, over, down, disabled) { RoundRectButtonSetting.prototype.setTextColor = function(out, over, down, disabled) {
this.textColors = { }; this.textColors = { };
this.textColors.out = out; this.textColors.out = out;
this.textColors.over = over; this.textColors.over = over;
@@ -45,7 +43,6 @@ class RoundRectButtonSetting {
this.textColors.disabled = disabled; this.textColors.disabled = disabled;
} }
}
RoundRectButtonSetting.DEFAULT_STROKE_COLORS = { RoundRectButtonSetting.DEFAULT_STROKE_COLORS = {
out: 0x666666, out: 0x666666,
@@ -80,8 +77,8 @@ RoundRectButtonSetting.DEFAULT_STROKE_WIDTH_PX = 5; // in pixel
class RoundRectButton {
constructor(roundRectSetting, iconName, buttonText, clickEvent) { function RoundRectButton(roundRectSetting, iconName, buttonText, clickEvent) {
this.setting = roundRectSetting; this.setting = roundRectSetting;
this.clickEvent = clickEvent; this.clickEvent = clickEvent;
@@ -109,7 +106,7 @@ class RoundRectButton {
this.mouseOut(); this.mouseOut();
} }
setEventMethod(target) { RoundRectButton.prototype.setEventMethod = function(target) {
target.events.onInputOver.add(function() { this.mouseOver(); }, this); target.events.onInputOver.add(function() { this.mouseOver(); }, this);
target.events.onInputOut.add(function() { this.mouseOut(); }, this); target.events.onInputOut.add(function() { this.mouseOut(); }, this);
target.events.onInputDown.add(function() { target.events.onInputDown.add(function() {
@@ -122,8 +119,8 @@ class RoundRectButton {
target.events.onInputUp.add(function() { this.mouseOver(); }, this); target.events.onInputUp.add(function() { this.mouseOver(); }, this);
} }
makeButtonStroke() { // outter(bigger) round rect sprite RoundRectButton.prototype.makeButtonStroke = function() { // outter(bigger) round rect sprite
let btnTexture = new Phaser.Graphics() var btnTexture = new Phaser.Graphics()
.beginFill(0xffffff) .beginFill(0xffffff)
.drawRoundedRect(0, 0, this.setting.width, this.setting.height, this.setting.roundAmount) .drawRoundedRect(0, 0, this.setting.width, this.setting.height, this.setting.roundAmount)
.endFill() .endFill()
@@ -136,12 +133,12 @@ class RoundRectButton {
); );
} }
makeButtonSprite() { // inner(smaller) round rect sprite RoundRectButton.prototype.makeButtonSprite = function() { // inner(smaller) round rect sprite
let width = this.setting.width - this.setting.strokeWidthPx * 2; var width = this.setting.width - this.setting.strokeWidthPx * 2;
let height = this.setting.height - this.setting.strokeWidthPx * 2; var height = this.setting.height - this.setting.strokeWidthPx * 2;
let innerRoundAmount = this.setting.roundAmount * (width / this.setting.width / 1.5); var innerRoundAmount = this.setting.roundAmount * (width / this.setting.width / 1.5);
let btnTexture = new Phaser.Graphics() var btnTexture = new Phaser.Graphics()
.beginFill(0xffffff) .beginFill(0xffffff)
.drawRoundedRect(this.setting.strokeWidthPx, this.setting.strokeWidthPx, width, height, innerRoundAmount) .drawRoundedRect(this.setting.strokeWidthPx, this.setting.strokeWidthPx, width, height, innerRoundAmount)
.endFill() .endFill()
@@ -155,19 +152,19 @@ class RoundRectButton {
); );
} }
makeIcon(iconName) { RoundRectButton.prototype.makeIcon = function(iconName) {
let icon = game.add.sprite(0, 0, iconName); var icon = game.add.sprite(0, 0, iconName);
icon.width = 80; icon.width = 80;
icon.height = 80; icon.height = 80;
return icon; return icon;
} }
makeText(textContent) { RoundRectButton.prototype.makeText = function(textContent) {
let width = this.setting.width - this.setting.strokeWidthPx * 2; var width = this.setting.width - this.setting.strokeWidthPx * 2;
let height = this.setting.height - this.setting.strokeWidthPx * 2; var height = this.setting.height - this.setting.strokeWidthPx * 2;
let btnText = game.add.text(0, 0, textContent, this.setting.fontStyle) var btnText = game.add.text(0, 0, textContent, this.setting.fontStyle)
.setTextBounds(0, 0, width, this.setting.height); .setTextBounds(0, 0, width, this.setting.height);
btnText.lineSpacing = RoundRectButtonSetting.DEFAULT_TEXT_LINE_SPACING_PX; btnText.lineSpacing = RoundRectButtonSetting.DEFAULT_TEXT_LINE_SPACING_PX;
@@ -176,7 +173,7 @@ class RoundRectButton {
return btnText; return btnText;
} }
setIcon(icon) { RoundRectButton.prototype.setIcon = function(icon) {
this.buttonIcon = this.button.addChild(icon); this.buttonIcon = this.button.addChild(icon);
this.buttonIcon.x = this.button.width / 2; this.buttonIcon.x = this.button.width / 2;
this.buttonIcon.y = this.button.height / 2; this.buttonIcon.y = this.button.height / 2;
@@ -186,7 +183,7 @@ class RoundRectButton {
} }
mouseOut() { RoundRectButton.prototype.mouseOut = function() {
this.text.fill = this.setting.textColors.out; this.text.fill = this.setting.textColors.out;
this.buttonStroke.tint = this.setting.strokeColors.out; this.buttonStroke.tint = this.setting.strokeColors.out;
this.button.tint = this.setting.buttonColors.out; this.button.tint = this.setting.buttonColors.out;
@@ -195,7 +192,7 @@ class RoundRectButton {
} }
} }
mouseOver() { RoundRectButton.prototype.mouseOver = function() {
this.text.fill = this.setting.textColors.over; this.text.fill = this.setting.textColors.over;
this.buttonStroke.tint = this.setting.strokeColors.over; this.buttonStroke.tint = this.setting.strokeColors.over;
this.button.tint = this.setting.buttonColors.over; this.button.tint = this.setting.buttonColors.over;
@@ -204,7 +201,7 @@ class RoundRectButton {
} }
} }
mouseDown() { RoundRectButton.prototype.mouseDown = function() {
this.text.fill = this.setting.textColors.down; this.text.fill = this.setting.textColors.down;
this.buttonStroke.tint = this.setting.strokeColors.down; this.buttonStroke.tint = this.setting.strokeColors.down;
this.button.tint = this.setting.buttonColors.down; this.button.tint = this.setting.buttonColors.down;
@@ -213,7 +210,7 @@ class RoundRectButton {
} }
} }
buttonDisabled() { RoundRectButton.prototype.buttonDisabled = function() {
this.text.fill = this.setting.textColors.disabled; this.text.fill = this.setting.textColors.disabled;
this.buttonStroke.tint = this.setting.strokeColors.disabled; this.buttonStroke.tint = this.setting.strokeColors.disabled;
this.button.tint = this.setting.buttonColors.disabled; this.button.tint = this.setting.buttonColors.disabled;
@@ -224,7 +221,7 @@ class RoundRectButton {
move(x, y) { RoundRectButton.prototype.move = function(x, y) {
this.buttonStroke.x = x - this.setting.width / 2; this.buttonStroke.x = x - this.setting.width / 2;
this.buttonStroke.y = y - this.setting.height / 2; this.buttonStroke.y = y - this.setting.height / 2;
@@ -232,11 +229,11 @@ class RoundRectButton {
this.button.y = y - this.setting.height / 2+ this.setting.strokeWidthPx; this.button.y = y - this.setting.height / 2+ this.setting.strokeWidthPx;
} }
get inputEnabled() { RoundRectButton.prototype.getInputEnabled = function() {
return this.button.inputEnabled; return this.button.inputEnabled;
} }
set inputEnabled(isEnabled) { RoundRectButton.prototype.setInputEnabled = function(isEnabled) {
this.buttonStroke.inputEnabled = isEnabled; this.buttonStroke.inputEnabled = isEnabled;
this.button.inputEnabled = isEnabled; this.button.inputEnabled = isEnabled;
@@ -247,10 +244,9 @@ class RoundRectButton {
} }
} }
set lineSpacing(spacingInPixels) { RoundRectButton.prototype.setLineSpacing = function(spacingInPixels) {
this.text.lineSpacing = spacingInPixels; this.text.lineSpacing = spacingInPixels;
} }
}
RoundRectButton.NONE_ICON = ""; RoundRectButton.NONE_ICON = "";
RoundRectButton.NONE_BUTTON_TEXT = ""; RoundRectButton.NONE_BUTTON_TEXT = "";
+17 -4
View File
@@ -1,7 +1,8 @@
class TypingAppButton extends RoundRectButton { TypingAppButton.prototype = Object.create(RoundRectButton.prototype);
TypingAppButton.constructor = TypingAppButton;
constructor(type, x, y, iconName, buttonText, clickEvent) { function TypingAppButton(type, x, y, iconName, buttonText, appInfo) {
let setting = new RoundRectButtonSetting(x, y, TypingAppButton.BUTTON_WIDTH, TypingAppButton.BUTTON_HEIGHT); var setting = new RoundRectButtonSetting(x, y, TypingAppButton.BUTTON_WIDTH, TypingAppButton.BUTTON_HEIGHT);
setting.fontStyle.boundsAlignH = "center"; // left, center. right setting.fontStyle.boundsAlignH = "center"; // left, center. right
setting.fontStyle.boundsAlignV = "middle"; // top, middle, bottom setting.fontStyle.boundsAlignV = "middle"; // top, middle, bottom
setting.strokeWidthPx = 5; setting.strokeWidthPx = 5;
@@ -79,7 +80,12 @@ class TypingAppButton extends RoundRectButton {
fill: "#fff" fill: "#fff"
}; };
super(setting, iconName, buttonText, clickEvent); this.appInfo = appInfo;
RoundRectButton.call(
this, setting,
iconName, buttonText,
this.clickEvent
);
this.text.x = 30; this.text.x = 30;
@@ -91,8 +97,15 @@ class TypingAppButton extends RoundRectButton {
} }
TypingAppButton.prototype.clickEvent = function() {
sessionStorageManager.playingAppID = this.appInfo.AppID;
sessionStorageManager.playingAppName = this.appInfo.AppName;
sessionStorageManager.playingAppKoreanName = this.appInfo.KoreanName;
location.href = '../../web/client/start.html';
} }
TypingAppButton.TYPE_PRACTICE_KOREAN = 0; TypingAppButton.TYPE_PRACTICE_KOREAN = 0;
TypingAppButton.TYPE_PRACTICE_ENGLISH = 1; TypingAppButton.TYPE_PRACTICE_ENGLISH = 1;
TypingAppButton.TYPE_TEST_KOREAN = 2; TypingAppButton.TYPE_TEST_KOREAN = 2;
+5 -13
View File
@@ -1,7 +1,8 @@
class TypingTabButton extends RoundRectButton { TypingTabButton.prototype = Object.create(RoundRectButton.prototype);
TypingTabButton.constructor = TypingTabButton;
constructor(x, y, iconName, buttonText, clickEvent) { function TypingTabButton(x, y, iconName, buttonText, clickEvent) {
let setting = new RoundRectButtonSetting( var setting = new RoundRectButtonSetting(
x, y, x, y,
TypingTabButton.BUTTON_WIDTH, TypingTabButton.BUTTON_HEIGHT TypingTabButton.BUTTON_WIDTH, TypingTabButton.BUTTON_HEIGHT
); );
@@ -28,18 +29,9 @@ class TypingTabButton extends RoundRectButton {
"#333" "#333"
); );
super(setting, iconName, buttonText, clickEvent); RoundRectButton.call(this, setting, iconName, buttonText, clickEvent);
if(iconName.length > 0) {
let icon_fullscreen = game.add.sprite(0, 0, iconName);
icon_fullscreen.width = 80;
icon_fullscreen.height = 80;
this.button.setIcon(icon_fullscreen);
}
} }
}
TypingTabButton.BUTTON_WIDTH = 490; TypingTabButton.BUTTON_WIDTH = 490;
TypingTabButton.BUTTON_HEIGHT = 80; TypingTabButton.BUTTON_HEIGHT = 80;
+21 -15
View File
@@ -8,15 +8,13 @@ class Login {
} }
create() { create() {
self = this;
sessionStorageManager.clear(); sessionStorageManager.clear();
this.game.stage.backgroundColor = '#4d4d4d'; this.game.stage.backgroundColor = '#4d4d4d';
this.textStyle = { font: "bold 32px Arial", fill: "#fff", align: "right", boundsAlignH: "right", boundsAlignV: "middle" }; this.textStyle = { font: "bold 32px Arial", fill: "#fff", align: "right", boundsAlignH: "right", boundsAlignV: "middle" };
// top ui // top ui
let screenTopUI = new ScreenTopUI(); var screenTopUI = new ScreenTopUI();
screenTopUI.makeBackButton( function() { screenTopUI.makeBackButton( function() {
sessionStorageManager.clear(); sessionStorageManager.clear();
location.href = '../../web/main/index.html'; location.href = '../../web/main/index.html';
@@ -25,7 +23,7 @@ class Login {
let textX = this.game.world.centerX - 320; var textX = this.game.world.centerX - 320;
if(sessionStorageManager.maestroID === null) if(sessionStorageManager.maestroID === null)
this.makeMaestroNameText(textX, 200); this.makeMaestroNameText(textX, 200);
this.makeNameText(textX, 300); this.makeNameText(textX, 300);
@@ -64,7 +62,7 @@ class Login {
} }
makeInputTypeText(x, y, text) { makeInputTypeText(x, y, text) {
let inputText = new InputTypeText(x + 420, y); var inputText = new InputTypeText(x + 420, y);
inputText.anchor.set(0.5); inputText.anchor.set(0.5);
inputText.canvasInput.value(''); inputText.canvasInput.value('');
if(isDebugMode()) { if(isDebugMode()) {
@@ -72,7 +70,7 @@ class Login {
} }
inputText.canvasInput._onkeyup = function() { inputText.canvasInput._onkeyup = function() {
if(event.keyCode == Phaser.Keyboard.ENTER) { if(event.keyCode == Phaser.Keyboard.ENTER) {
self.startMenu(); (function() { this.startMenu(); }).bind(this)
} }
} }
@@ -80,10 +78,14 @@ class Login {
} }
makeStartButton(x, y) { makeStartButton(x, y) {
let setting = new RoundRectButtonSetting(x, y, 200, 100); var setting = new RoundRectButtonSetting(x, y, 200, 100);
setting.fontStyle.fontWeight = "bold"; setting.fontStyle.fontWeight = "bold";
let startButton = new RoundRectButton(setting, RoundRectButton.NONE_ICON, "시작", this.startMenu); var startButton = new RoundRectButton(
setting,
RoundRectButton.NONE_ICON, "시작",
(function() { this.startMenu(); }).bind(this)
);
} }
makeInfoText(x, y) { makeInfoText(x, y) {
@@ -96,17 +98,21 @@ class Login {
startMenu() { startMenu() {
let maestroName = self.inputTextMaestroName.canvasInput._value; var maestroName = this.inputTextMaestroName.canvasInput._value;
sessionStorageManager.playerName = self.inputTextName.canvasInput._value; sessionStorageManager.playerName = this.inputTextName.canvasInput._value;
let enterCode = self.inputTextEnterCode.canvasInput._value; var enterCode = this.inputTextEnterCode.canvasInput._value;
let dbConnectManager = new DBConnectManager(); var dbConnectManager = new DBConnectManager();
dbConnectManager.requestCheckPlayerLogin( dbConnectManager.requestCheckPlayerLogin(
maestroName, maestroName,
sessionStorageManager.playerName, sessionStorageManager.playerName,
enterCode, enterCode,
self.loginSucceeded, (function(jsonData) {
self.loginFailed this.loginSucceeded(jsonData);
}).bind(this),
(function(jsonData) {
this.loginFailed(jsonData);
}).bind(this)
); );
} }
@@ -131,7 +137,7 @@ class Login {
console.log('login failed, jsonData : ' + JSON.stringify(jsonData)); console.log('login failed, jsonData : ' + JSON.stringify(jsonData));
if(jsonData["error"] !== null) { if(jsonData["error"] !== null) {
self.infoText.text = jsonData["error"]; this.infoText.text = jsonData["error"];
} }
} }
+2 -6
View File
@@ -1,12 +1,10 @@
class AppAreaBG { function AppAreaBG(color, alpha, x, y, width, height) {
constructor(color, alpha, x, y, width, height) {
game.add.graphics() game.add.graphics()
.beginFill(color, alpha) .beginFill(color, alpha)
.drawRect(x, y, width, height); .drawRect(x, y, width, height);
} }
printText(text, x, y, size, color, 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 fontStyle = { font: "36px Arial", fill: "#fff", align: "left", boundsAlignH: "left", boundsAlignV: "bottom" };
let titleText = game.add.text(x, y, text, fontStyle); let titleText = game.add.text(x, y, text, fontStyle);
titleText.anchor.set(0.5); titleText.anchor.set(0.5);
@@ -15,8 +13,6 @@ class AppAreaBG {
titleText.alpha = alpha; titleText.alpha = alpha;
} }
};
AppAreaBG.COLOR_MOUSE_APP = 0xffce54; AppAreaBG.COLOR_MOUSE_APP = 0xffce54;
AppAreaBG.COLOR_TYPING_APP = 0x99ccff; AppAreaBG.COLOR_TYPING_APP = 0x99ccff;
+88 -88
View File
@@ -1,18 +1,15 @@
///////////////////////////// var MenuApp = {
// MenuApp
class MenuApp { preload: function() {
preload() {
game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png'); game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png');
} },
create() { create: function() {
self = this; game.stage.backgroundColor = '#4d4d4d';
this.game.stage.backgroundColor = '#4d4d4d';
// mouse app area // mouse app area
let mouseBG = new AppAreaBG(AppAreaBG.COLOR_MOUSE_APP, 1, var mouseBG = new AppAreaBG(
AppAreaBG.COLOR_MOUSE_APP, 1,
0, 60, 0, 60,
GAME_SCREEN_SIZE.x, 280 GAME_SCREEN_SIZE.x, 280
); );
@@ -23,7 +20,8 @@ class MenuApp {
); );
// typing app area // typing app area
let typingBG = new AppAreaBG(AppAreaBG.COLOR_TYPING_APP, 1, var typingBG = new AppAreaBG(
AppAreaBG.COLOR_TYPING_APP, 1,
0, 340, 0, 340,
GAME_SCREEN_SIZE.x, 378 GAME_SCREEN_SIZE.x, 378
); );
@@ -35,7 +33,7 @@ class MenuApp {
// top ui // top ui
let screenTopUI = new ScreenTopUI(); var screenTopUI = new ScreenTopUI();
screenTopUI.makeBackButton( function() { screenTopUI.makeBackButton( function() {
sessionStorageManager.clear(); sessionStorageManager.clear();
location.href = '../../web/client/login.html'; location.href = '../../web/client/login.html';
@@ -44,9 +42,9 @@ class MenuApp {
// bottom ui // bottom ui
let screenBottomUI = new ScreenBottomUI(); var screenBottomUI = new ScreenBottomUI();
// ScreenBottomUI.printLeftText("게임 진행 정보"); // ScreenBottomUI.printLeftText("게임 진행 정보");
// let playingAppName = appInfoManager.getAppNameKorean(sessionStorageManager.playingAppName); // var playingAppName = appInfoManager.getAppNameKorean(sessionStorageManager.playingAppName);
// ScreenBottomUI.printCenterText(playingAppName); // ScreenBottomUI.printCenterText(playingAppName);
screenBottomUI.printCenterText("메뉴"); screenBottomUI.printCenterText("메뉴");
screenBottomUI.printRightText(sessionStorageManager.playerName); screenBottomUI.printRightText(sessionStorageManager.playerName);
@@ -55,83 +53,87 @@ class MenuApp {
this.loadAppData(); this.loadAppData();
} },
loadAppData() {
let dbConnectManager = new DBConnectManager(); loadAppData: function() {
var dbConnectManager = new DBConnectManager();
dbConnectManager.requestMenuAppList( dbConnectManager.requestMenuAppList(
sessionStorageManager.maestroID, sessionStorageManager.maestroID,
self.loadSucceeded, (function(replyJSON) {
self.loadFailed this.loadSucceeded(replyJSON);
}).bind(this),
(function(replyJSON) {
this.loadFailed(replyJSON);
}).bind(this)
); );
} },
loadSucceeded(replyJSON) { loadSucceeded: function(replyJSON) {
// console.log(replyJSON); // console.log(replyJSON);
self.makeMouseAppButtons( this.makeMouseAppButtons(
replyJSON.MouseAppList, replyJSON.MouseAppList,
replyJSON.MouseActiveAppList replyJSON.MouseActiveAppList
); );
self.makeTypingButtons( this.makeTypingButtons(
replyJSON.TypingPracticeAppCount, replyJSON.TypingPracticeAppCount,
replyJSON.TypingTestAppCount, replyJSON.TypingTestAppCount,
replyJSON.TypingAppList, replyJSON.TypingAppList,
replyJSON.TypingActiveAppList replyJSON.TypingActiveAppList
); );
} },
hasApp(appID, appList) { hasApp: function(appID, appList) {
for(let i = 0; i < appList.length; i++) { for(var i = 0; i < appList.length; i++) {
if(appList[i].AppID === appID) if(appList[i].AppID === appID)
return true; return true;
} }
return false; return false;
} },
makeMouseAppButtons(appList, activeAppList) { makeMouseAppButtons: function(appList, activeAppList) {
// console.log(appList); // console.log(appList);
let mouseAppCount = Object.keys(appList).length; var mouseAppCount = Object.keys(appList).length;
for(let i = 0; i < mouseAppCount; i++) { for(var i = 0; i < mouseAppCount; i++) {
let posX = self.getButtonPosX(i, mouseAppCount); var posX = this.getButtonPosX(i, mouseAppCount);
let posY = self.getButtonPosY(i, mouseAppCount, GameAppButton.BUTTON_UPPER_POS_Y); var posY = this.getButtonPosY(i, mouseAppCount, GameAppButton.BUTTON_UPPER_POS_Y);
let app = appList[i]; var app = appList[i];
let gameAppButton = new GameAppButton( var gameAppButton = new GameAppButton(
posX, posY, GameAppButton.TYPE_MOUSE_APP, posX, posY,
RoundRectButton.NONE_ICON, // "icon_fullscreen", GameAppButton.TYPE_MOUSE_APP,
app.KoreanName, RoundRectButton.NONE_ICON, app.KoreanName,
(function() { {
sessionStorageManager.playingAppID = app.AppID; AppID: app.AppID,
sessionStorageManager.playingAppName = app.AppName; AppName: app.AppName,
sessionStorageManager.playingAppKoreanName = app.KoreanName; KoreanName: app.KoreanName
location.href = '../../web/client/start.html'; }
})
); );
if(!self.hasApp(app.AppID, activeAppList)) if(!this.hasApp(app.AppID, activeAppList))
gameAppButton.inputEnabled = false; gameAppButton.setInputEnabled(false);
}
} }
},
makeTypingButtons(typingPracticeAppCount, typingTestAppCount, appList, activeAppList) { makeTypingButtons: function(typingPracticeAppCount, typingTestAppCount, appList, activeAppList) {
// console.log(typingPracticeAppCount); // console.log(typingPracticeAppCount);
// console.log(typingTestAppCount); // console.log(typingTestAppCount);
// console.log(appList); // console.log(appList);
let isTypingPracticeAppExist = typingPracticeAppCount > 0 ? true : false; var isTypingPracticeAppExist = typingPracticeAppCount > 0 ? true : false;
let isTypingTestAppExist = typingTestAppCount > 0 ? true : false; var isTypingTestAppExist = typingTestAppCount > 0 ? true : false;
let typingAppTotalCount = Object.keys(appList).length; var typingAppTotalCount = Object.keys(appList).length;
let typingAppIndex = 0; var typingAppIndex = 0;
// typing tab buttons // typing tab buttons
let typingPracticeTabButton = new TypingTabButton( var typingPracticeTabButton = new TypingTabButton(
TypingTabButton.PRACTICE_BUTTON_POS_X, TypingTabButton.BUTTON_POS_Y, TypingTabButton.PRACTICE_BUTTON_POS_X, TypingTabButton.BUTTON_POS_Y,
"", "타자 연습", "", "타자 연습",
(function() { (function() {
@@ -139,9 +141,9 @@ class MenuApp {
}) })
); );
if(typingPracticeAppCount === 0) 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, TypingTabButton.TEST_BUTTON_POS_X, TypingTabButton.BUTTON_POS_Y,
"", "타자 시험", "", "타자 시험",
(function() { (function() {
@@ -149,81 +151,79 @@ class MenuApp {
}) })
); );
if(typingTestAppCount === 0) if(typingTestAppCount === 0)
typingTestTabButton.inputEnabled = false; typingTestTabButton.setInputEnabled(false);
// typing app buttons // 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 typingButtonIndex, typingAppTotalCount
); );
let posY = self.getButtonPosY( var posY = this.getButtonPosY(
typingButtonIndex, typingAppTotalCount, GameAppButton.BUTTON_LOWER_POS_Y typingButtonIndex, typingAppTotalCount, GameAppButton.BUTTON_LOWER_POS_Y
); );
let app = appList[typingAppIndex]; var app = appList[typingAppIndex];
let isKoreanTypingApp = app.AppID < 32 ? true : false; var isKoreanTypingApp = app.AppID < 32 ? true : false;
let gameAppButton = new GameAppButton( var gameAppButton = new GameAppButton(
posX, posY, GameAppButton.TYPE_TYPING_APP, posX, posY, GameAppButton.TYPE_TYPING_APP,
RoundRectButton.NONE_ICON, // "icon_fullscreen", RoundRectButton.NONE_ICON, // "icon_fullscreen",
// (isKoreanTypingApp ? "(한글)" : "(영문)") + "\n" + app.KoreanName, // (isKoreanTypingApp ? "(한글)" : "(영문)") + "\n" + app.KoreanName,
app.KoreanName, app.KoreanName,
(function() { {
sessionStorageManager.playingAppID = app.AppID; AppID: app.AppID,
sessionStorageManager.playingAppName = app.AppName; AppName: app.AppName,
sessionStorageManager.playingAppKoreanName = app.KoreanName; KoreanName: app.KoreanName
location.href = '../../web/client/start.html'; }
})
); );
if(!self.hasApp(app.AppID, activeAppList)) if(!this.hasApp(app.AppID, activeAppList))
gameAppButton.inputEnabled = false; gameAppButton.setInputEnabled(false);
typingAppIndex++; typingAppIndex++;
} }
} },
getButtonPosX(index, buttonCount) { getButtonPosX: function(index, buttonCount) {
let gap = GameAppButton.BUTTON_WIDTH + GameAppButton.BUTTON_GAP; var gap = GameAppButton.BUTTON_WIDTH + GameAppButton.BUTTON_GAP;
let maxColumnNum = Math.floor( (game.world.width - GameAppButton.MARGIN_VERTICAL) / gap ); var maxColumnNum = Math.floor( (game.world.width - GameAppButton.MARGIN_VERTICAL) / gap );
// console.log("maxColumnNum : " + maxColumnNum); // console.log("maxColumnNum : " + maxColumnNum);
let rowCount = Math.ceil(buttonCount / maxColumnNum); var rowCount = Math.ceil(buttonCount / maxColumnNum);
// console.log("rowCount : " + rowCount); // console.log("rowCount : " + rowCount);
let columnIndex = index % maxColumnNum; var columnIndex = index % maxColumnNum;
// console.log("columnIndex : " + columnIndex); // console.log("columnIndex : " + columnIndex);
let rowIndex = Math.floor(index / maxColumnNum); var rowIndex = Math.floor(index / maxColumnNum);
// console.log("rowIndex : " + rowIndex); // console.log("rowIndex : " + rowIndex);
let columnCountForThisRow = 0; var columnCountForThisRow = 0;
if(rowIndex < rowCount - 1) if(rowIndex < rowCount - 1)
columnCountForThisRow = maxColumnNum; columnCountForThisRow = maxColumnNum;
else else
columnCountForThisRow = buttonCount - (maxColumnNum * rowIndex); columnCountForThisRow = buttonCount - (maxColumnNum * rowIndex);
// console.log("columnCountForThisRow : " + columnCountForThisRow); // 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; return startX + gap * columnIndex;
} },
getButtonPosY(index, buttonCount, startPosY) { getButtonPosY: function(index, buttonCount, startPosY) {
let gap = GameAppButton.BUTTON_HEIGHT + GameAppButton.BUTTON_GAP; var gap = GameAppButton.BUTTON_HEIGHT + GameAppButton.BUTTON_GAP;
let maxColumnNum = Math.floor( (game.world.width - GameAppButton.MARGIN_VERTICAL) / gap ); var maxColumnNum = Math.floor( (game.world.width - GameAppButton.MARGIN_VERTICAL) / gap );
// console.log("maxColumnNum : " + maxColumnNum); // console.log("maxColumnNum : " + maxColumnNum);
let rowCount = Math.ceil(buttonCount / maxColumnNum); var rowCount = Math.ceil(buttonCount / maxColumnNum);
// console.log("rowCount : " + rowCount); // console.log("rowCount : " + rowCount);
let rowIndex = Math.floor(index / maxColumnNum); var rowIndex = Math.floor(index / maxColumnNum);
// console.log("rowIndex : " + rowIndex); // console.log("rowIndex : " + rowIndex);
let startY = startPosY - ( (gap / 2) * (rowCount - 1) ); var startY = startPosY - ( (gap / 2) * (rowCount - 1) );
return startY + gap * rowIndex; return startY + gap * rowIndex;
} },
loadFailed(replyJSON) { loadFailed: function(replyJSON) {
// console.log('login failed, jsonData : ' + JSON.stringify(replyJSON)); // console.log('login failed, jsonData : ' + JSON.stringify(replyJSON));
} }
} }
+82 -86
View File
@@ -1,27 +1,22 @@
///////////////////////////// var MenuTypingPractice = {
// MenuTypingPractice
class MenuTypingPractice {
preload() { preload() {
game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png'); game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png');
game.load.image('space_invaders', '../../../resources/image/icon/space_invaders.png'); game.load.image('space_invaders', '../../../resources/image/icon/space_invaders.png');
Animal.loadResources(); Animal.loadResources();
} },
create() { create() {
self = this; game.stage.backgroundColor = '#4d4d4d';
this.game.stage.backgroundColor = '#4d4d4d';
// typing app area // typing app area
let typingBG = new AppAreaBG(AppAreaBG.COLOR_TYPING_APP, 1, var typingBG = new AppAreaBG(AppAreaBG.COLOR_TYPING_APP, 1,
0, 60, 0, 60,
GAME_SCREEN_SIZE.x, GAME_SCREEN_SIZE.y - 110 GAME_SCREEN_SIZE.x, GAME_SCREEN_SIZE.y - 110
); );
// korean app area // 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, // AppAreaBG.MARGIN_X, 60 + AppAreaBG.GAP_Y,
// GAME_SCREEN_SIZE.x - AppAreaBG.MARGIN_X * 2, 270 // GAME_SCREEN_SIZE.x - AppAreaBG.MARGIN_X * 2, 270
// ); // );
@@ -32,7 +27,7 @@ class MenuTypingPractice {
// ); // );
// english app area // 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, // AppAreaBG.MARGIN_X, 340,
// GAME_SCREEN_SIZE.x - AppAreaBG.MARGIN_X * 2, 270 // GAME_SCREEN_SIZE.x - AppAreaBG.MARGIN_X * 2, 270
// ); // );
@@ -44,7 +39,7 @@ class MenuTypingPractice {
// top ui // top ui
let screenTopUI = new ScreenTopUI(); var screenTopUI = new ScreenTopUI();
screenTopUI.makeBackButton( function() { screenTopUI.makeBackButton( function() {
location.href = '../../web/client/menu_app.html'; location.href = '../../web/client/menu_app.html';
}); });
@@ -52,178 +47,179 @@ class MenuTypingPractice {
// typing tab buttons // typing tab buttons
let typingPracticeTabButton = new TypingTabButton( var typingPracticeTabButton = new TypingTabButton(
TypingTabButton.PRACTICE_BUTTON_POS_X, TypingTabButton.BUTTON_POS_Y, TypingTabButton.PRACTICE_BUTTON_POS_X, TypingTabButton.BUTTON_POS_Y,
"", "타자 연습", "", "타자 연습",
(function() { (function() {
location.href = '../../web/client/menu_typing_practice.html'; 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, TypingTabButton.TEST_BUTTON_POS_X, TypingTabButton.BUTTON_POS_Y,
"", "타자 시험", "", "타자 시험",
(function() { (function() {
location.href = '../../web/client/menu_typing_test.html'; location.href = '../../web/client/menu_typing_test.html';
}) })
); );
// typingTestTabButton.inputEnabled = false; // typingTestTabButton.setInputEnabled(false);
// bottom ui // bottom ui
let screenBottomUI = new ScreenBottomUI(); var screenBottomUI = new ScreenBottomUI();
// screenBottomUI.printLeftText("게임 진행 정보"); // screenBottomUI.printLeftText("게임 진행 정보");
screenBottomUI.printCenterText("메뉴 > 타자 연습"); screenBottomUI.printCenterText("메뉴 > 타자 연습");
screenBottomUI.printRightText(sessionStorageManager.playerName); screenBottomUI.printRightText(sessionStorageManager.playerName);
this.makeActiveTypingPracticeAppButtons(); this.makeActiveTypingPracticeAppButtons();
} },
makeActiveTypingPracticeAppButtons() { makeActiveTypingPracticeAppButtons: function() {
let dbConnectManager = new DBConnectManager(); var dbConnectManager = new DBConnectManager();
dbConnectManager.requestTypingPracticeAppList( dbConnectManager.requestTypingPracticeAppList(
sessionStorageManager.maestroID, sessionStorageManager.maestroID,
sessionStorageManager.playerID, sessionStorageManager.playerID,
self.downloadListSucceeded, (function(replyJSON) {
self.downloadListFailed this.downloadListSucceeded(replyJSON);
}).bind(this),
(function(replyJSON) {
this.downloadListFailed(replyJSON);
}).bind(this)
); );
} },
hasApp(appID, appList) { hasApp: function(appID, appList) {
for(let i = 0; i < appList.length; i++) { for(var i = 0; i < appList.length; i++) {
if(appList[i].AppID === appID) if(appList[i].AppID === appID)
return true; return true;
} }
return false; return false;
} },
getBestRecord(jsonList, appID) { getBestRecord: function(jsonList, appID) {
let count = Object.keys(jsonList).length; 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) if(jsonList[i].AppID === appID)
return jsonList[i].BestRecord; return jsonList[i].BestRecord;
} }
return 0; return 0;
} },
getIconImage(jsonList, appID) { getIconImage: function(jsonList, appID) {
let bestRecord = this.getBestRecord(jsonList, appID); var bestRecord = this.getBestRecord(jsonList, appID);
if(bestRecord === 0) if(bestRecord === 0)
return "snail_shadow"; 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; return Animal.SPECIES_DATA[animalLevel].species + Animal.SPRITE_NAMES.icon;
} },
downloadListSucceeded(replyJSON) { downloadListSucceeded: function(replyJSON) {
// console.log(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; var koreanTypingPracticeAppCount = Object.keys(replyJSON.KoreanAppList).length;
let englishTypingPracticeAppCount = Object.keys(replyJSON.EnglishAppList).length; var englishTypingPracticeAppCount = Object.keys(replyJSON.EnglishAppList).length;
for(let i = 0; i < koreanTypingPracticeAppCount; i++) { for(var i = 0; i < koreanTypingPracticeAppCount; i++) {
let activeApp = replyJSON.KoreanAppList[i]; var activeApp = replyJSON.KoreanAppList[i];
let posX = self.getButtonPosX(i, koreanTypingPracticeAppCount); var posX = this.getButtonPosX(i, koreanTypingPracticeAppCount);
let posY = self.getButtonPosY(i, koreanTypingPracticeAppCount, var posY = this.getButtonPosY(i, koreanTypingPracticeAppCount,
TypingAppButton.BUTTON_UPPER_POS_Y TypingAppButton.BUTTON_UPPER_POS_Y
); );
let typingPracticeButton = new TypingAppButton( var typingPracticeButton = new TypingAppButton(
TypingAppButton.TYPE_PRACTICE_KOREAN, TypingAppButton.TYPE_PRACTICE_KOREAN,
posX, posY, posX, posY,
self.getIconImage(replyJSON.KoreanHighScoreList, activeApp.AppID), this.getIconImage(replyJSON.KoreanHighScoreList, activeApp.AppID),
activeApp.KoreanName, activeApp.KoreanName,
(function() { {
sessionStorageManager.playingAppID = activeApp.AppID; AppID: activeApp.AppID,
sessionStorageManager.playingAppName = activeApp.AppName; AppName: activeApp.AppName,
sessionStorageManager.playingAppKoreanName = activeApp.KoreanName; KoreanName: activeApp.KoreanName
location.href = '../../web/client/start.html'; }
})
); );
if(!self.hasApp(activeApp.AppID, replyJSON.KoreanActiveAppList)) if(!this.hasApp(activeApp.AppID, replyJSON.KoreanActiveAppList))
typingPracticeButton.inputEnabled = false; typingPracticeButton.setInputEnabled(false);
} }
for(let i = 0; i < englishTypingPracticeAppCount; i++) { for(var i = 0; i < englishTypingPracticeAppCount; i++) {
let activeApp = replyJSON.EnglishAppList[i]; var activeApp = replyJSON.EnglishAppList[i];
let posX = self.getButtonPosX(i, englishTypingPracticeAppCount); var posX = this.getButtonPosX(i, englishTypingPracticeAppCount);
let posY = self.getButtonPosY(i, englishTypingPracticeAppCount, var posY = this.getButtonPosY(i, englishTypingPracticeAppCount,
TypingAppButton.BUTTON_LOWER_POS_Y TypingAppButton.BUTTON_LOWER_POS_Y
); );
let typingPracticeButton = new TypingAppButton( var typingPracticeButton = new TypingAppButton(
TypingAppButton.TYPE_PRACTICE_ENGLISH, TypingAppButton.TYPE_PRACTICE_ENGLISH,
posX, posY, posX, posY,
self.getIconImage(activeApp.AppID), this.getIconImage(activeApp.AppID),
activeApp.KoreanName, activeApp.KoreanName,
(function() { {
sessionStorageManager.playingAppID = activeApp.AppID; AppID: activeApp.AppID,
sessionStorageManager.playingAppName = activeApp.AppName; AppName: activeApp.AppName,
sessionStorageManager.playingAppKoreanName = activeApp.KoreanName; KoreanName: activeApp.KoreanName
location.href = '../../web/client/start.html'; }
})
); );
if(!self.hasApp(activeApp.AppID, replyJSON.EnglishActiveAppList)) if(!this.hasApp(activeApp.AppID, replyJSON.EnglishActiveAppList))
typingPracticeButton.inputEnabled = false; typingPracticeButton.setInputEnabled(false);
}
} }
},
getButtonPosX(index, buttonCount) { getButtonPosX: function(index, buttonCount) {
let gap = TypingAppButton.BUTTON_WIDTH + TypingAppButton.BUTTON_GAP; var gap = TypingAppButton.BUTTON_WIDTH + TypingAppButton.BUTTON_GAP;
let maxColumnNum = Math.floor( (game.world.width - TypingAppButton.MARGIN_VERTICAL) / gap ); var maxColumnNum = Math.floor( (game.world.width - TypingAppButton.MARGIN_VERTICAL) / gap );
// console.log("maxColumnNum : " + maxColumnNum); // console.log("maxColumnNum : " + maxColumnNum);
let rowCount = Math.ceil(buttonCount / maxColumnNum); var rowCount = Math.ceil(buttonCount / maxColumnNum);
// console.log("rowCount : " + rowCount); // console.log("rowCount : " + rowCount);
let columnIndex = index % maxColumnNum; var columnIndex = index % maxColumnNum;
// console.log("columnIndex : " + columnIndex); // console.log("columnIndex : " + columnIndex);
let rowIndex = Math.floor(index / maxColumnNum); var rowIndex = Math.floor(index / maxColumnNum);
// console.log("rowIndex : " + rowIndex); // console.log("rowIndex : " + rowIndex);
let columnCountForThisRow = 0; var columnCountForThisRow = 0;
if(rowIndex < rowCount - 1) if(rowIndex < rowCount - 1)
columnCountForThisRow = maxColumnNum; columnCountForThisRow = maxColumnNum;
else else
columnCountForThisRow = buttonCount - (maxColumnNum * rowIndex); columnCountForThisRow = buttonCount - (maxColumnNum * rowIndex);
// console.log("columnCountForThisRow : " + columnCountForThisRow); // 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; return startX + gap * columnIndex;
} },
getButtonPosY(index, buttonCount, startPosY) { getButtonPosY: function(index, buttonCount, startPosY) {
let rowGap = TypingAppButton.BUTTON_HEIGHT + TypingAppButton.BUTTON_GAP; var rowGap = TypingAppButton.BUTTON_HEIGHT + TypingAppButton.BUTTON_GAP;
let columnGap = TypingAppButton.BUTTON_WIDTH + TypingAppButton.BUTTON_GAP; var columnGap = TypingAppButton.BUTTON_WIDTH + TypingAppButton.BUTTON_GAP;
let maxColumnNum = Math.floor( (game.world.width - TypingAppButton.MARGIN_VERTICAL) / columnGap ); var maxColumnNum = Math.floor( (game.world.width - TypingAppButton.MARGIN_VERTICAL) / columnGap );
// console.log("maxColumnNum : " + maxColumnNum); // console.log("maxColumnNum : " + maxColumnNum);
// console.log("buttonCount : " + buttonCount); // console.log("buttonCount : " + buttonCount);
let rowCount = Math.ceil(buttonCount / maxColumnNum); var rowCount = Math.ceil(buttonCount / maxColumnNum);
// console.log("rowCount : " + rowCount); // console.log("rowCount : " + rowCount);
let rowIndex = Math.floor(index / maxColumnNum); var rowIndex = Math.floor(index / maxColumnNum);
// console.log("rowIndex : " + rowIndex); // console.log("rowIndex : " + rowIndex);
let startY = startPosY - ( (rowGap / 2) * (rowCount - 1) ); var startY = startPosY - ( (rowGap / 2) * (rowCount - 1) );
return startY + rowGap * rowIndex; return startY + rowGap * rowIndex;
} },
downloadListFailed(replyJSON) { downloadListFailed: function(replyJSON) {
console.log('download app list failed, jsonData : ' + JSON.stringify(replyJSON)); console.log('download app list failed, jsonData : ' + JSON.stringify(replyJSON));
} }
} }
+84 -85
View File
@@ -1,27 +1,22 @@
///////////////////////////// var MenuTypingTest = {
// MenuTypingTest
class MenuTypingTest {
preload() { preload() {
game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png'); game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png');
game.load.image('space_invaders', '../../../resources/image/icon/space_invaders.png'); game.load.image('space_invaders', '../../../resources/image/icon/space_invaders.png');
Animal.loadResources(); Animal.loadResources();
} },
create() { create() {
self = this; game.stage.backgroundColor = '#4d4d4d';
this.game.stage.backgroundColor = '#4d4d4d';
// typing app area // typing app area
let typingBG = new AppAreaBG(AppAreaBG.COLOR_TYPING_APP, 1, var typingBG = new AppAreaBG(AppAreaBG.COLOR_TYPING_APP, 1,
0, 60, 0, 60,
GAME_SCREEN_SIZE.x, GAME_SCREEN_SIZE.y - 110 GAME_SCREEN_SIZE.x, GAME_SCREEN_SIZE.y - 110
); );
// korean app area // 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, // 0, 60 + AppAreaBG.GAP_Y,
// GAME_SCREEN_SIZE.x, 270 // GAME_SCREEN_SIZE.x, 270
// ); // );
@@ -32,7 +27,7 @@ class MenuTypingTest {
// ); // );
// english app area // english app area
// let englishBG = new AppAreaBG(AppAreaBG.COLOR_TYPING_ENGLISH, 1, // var englishBG = new AppAreaBG(AppAreaBG.COLOR_TYPING_ENGLISH, 1,
// 0, 340, // 0, 340,
// GAME_SCREEN_SIZE.x, 270 // GAME_SCREEN_SIZE.x, 270
// ); // );
@@ -44,7 +39,7 @@ class MenuTypingTest {
// top ui // top ui
let screenTopUI = new ScreenTopUI(); var screenTopUI = new ScreenTopUI();
screenTopUI.makeBackButton( function() { screenTopUI.makeBackButton( function() {
location.href = '../../web/client/menu_app.html'; location.href = '../../web/client/menu_app.html';
}); });
@@ -52,177 +47,181 @@ class MenuTypingTest {
// typing tab buttons // typing tab buttons
let typingPracticeTabButton = new TypingTabButton( var typingPracticeTabButton = new TypingTabButton(
TypingTabButton.PRACTICE_BUTTON_POS_X, TypingTabButton.BUTTON_POS_Y, TypingTabButton.PRACTICE_BUTTON_POS_X, TypingTabButton.BUTTON_POS_Y,
"", "타자 연습", "", "타자 연습",
(function() { (function() {
location.href = '../../web/client/menu_typing_practice.html'; 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, TypingTabButton.TEST_BUTTON_POS_X, TypingTabButton.BUTTON_POS_Y,
"", "타자 시험", "", "타자 시험",
(function() { (function() {
location.href = '../../web/client/menu_typing_test.html'; location.href = '../../web/client/menu_typing_test.html';
}) })
); );
typingTestTabButton.inputEnabled = false; typingTestTabButton.setInputEnabled(false);
this.makeActiveTypingTestAppButtons(); this.makeActiveTypingTestAppButtons();
// bottom ui // bottom ui
let screenBottomUI = new ScreenBottomUI(); var screenBottomUI = new ScreenBottomUI();
// screenBottomUI.printLeftText("게임 진행 정보"); // screenBottomUI.printLeftText("게임 진행 정보");
screenBottomUI.printCenterText("메뉴 > 타자 시험"); screenBottomUI.printCenterText("메뉴 > 타자 시험");
screenBottomUI.printRightText(sessionStorageManager.playerName); screenBottomUI.printRightText(sessionStorageManager.playerName);
} },
makeActiveTypingTestAppButtons() { makeActiveTypingTestAppButtons: function() {
let dbConnectManager = new DBConnectManager(); var dbConnectManager = new DBConnectManager();
dbConnectManager.requestTypingTestAppList( dbConnectManager.requestTypingTestAppList(
sessionStorageManager.maestroID, sessionStorageManager.maestroID,
sessionStorageManager.playerID, sessionStorageManager.playerID,
self.downloadListSucceeded, // self.downloadListSucceeded,
self.downloadListFailed // self.downloadListFailed
(function(replyJSON) {
this.downloadListSucceeded(replyJSON);
}).bind(this),
(function(replyJSON) {
this.downloadListFailed(replyJSON);
}).bind(this)
); );
} },
hasApp(appID, appList) { hasApp: function(appID, appList) {
for(let i = 0; i < appList.length; i++) { for(var i = 0; i < appList.length; i++) {
if(appList[i].AppID === appID) if(appList[i].AppID === appID)
return true; return true;
} }
return false; return false;
} },
getBestRecord(jsonList, appID) { getBestRecord: function(jsonList, appID) {
let count = Object.keys(jsonList).length; 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) if(jsonList[i].AppID === appID)
return jsonList[i].BestRecord; return jsonList[i].BestRecord;
} }
return 0; return 0;
} },
getIconImage(jsonList, appID) { getIconImage: function(jsonList, appID) {
let bestRecord = this.getBestRecord(jsonList, appID); var bestRecord = this.getBestRecord(jsonList, appID);
if(bestRecord === 0) if(bestRecord === 0)
return "snail_shadow"; 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; return Animal.SPECIES_DATA[animalLevel].species + Animal.SPRITE_NAMES.icon;
} },
downloadListSucceeded(replyJSON) { downloadListSucceeded: function(replyJSON) {
// console.log(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; var koreanTypingPracticeAppCount = Object.keys(replyJSON.KoreanAppList).length;
let englishTypingPracticeAppCount = Object.keys(replyJSON.EnglishAppList).length; var englishTypingPracticeAppCount = Object.keys(replyJSON.EnglishAppList).length;
for(let i = 0; i < koreanTypingPracticeAppCount; i++) { for(var i = 0; i < koreanTypingPracticeAppCount; i++) {
let activeApp = replyJSON.KoreanAppList[i]; var activeApp = replyJSON.KoreanAppList[i];
let posX = self.getButtonPosX(i, koreanTypingPracticeAppCount); var posX = this.getButtonPosX(i, koreanTypingPracticeAppCount);
let posY = self.getButtonPosY(i, koreanTypingPracticeAppCount, var posY = this.getButtonPosY(i, koreanTypingPracticeAppCount,
TypingAppButton.BUTTON_UPPER_POS_Y TypingAppButton.BUTTON_UPPER_POS_Y
); );
let typingTestButton = new TypingAppButton( var typingTestButton = new TypingAppButton(
TypingAppButton.TYPE_TEST_KOREAN, TypingAppButton.TYPE_TEST_KOREAN,
posX, posY, posX, posY,
self.getIconImage(replyJSON.KoreanHighScoreList, activeApp.AppID), this.getIconImage(replyJSON.KoreanHighScoreList, activeApp.AppID),
activeApp.KoreanName, activeApp.KoreanName,
(function() { {
sessionStorageManager.playingAppID = activeApp.AppID; AppID: activeApp.AppID,
sessionStorageManager.playingAppName = activeApp.AppName; AppName: activeApp.AppName,
sessionStorageManager.playingAppKoreanName = activeApp.KoreanName; KoreanName: activeApp.KoreanName
location.href = '../../web/client/start.html'; }
})
); );
if(!self.hasApp(activeApp.AppID, replyJSON.KoreanActiveAppList)) if(!this.hasApp(activeApp.AppID, replyJSON.KoreanActiveAppList))
typingTestButton.inputEnabled = false; typingTestButton.setInputEnabled(false);
} }
for(let i = 0; i < englishTypingPracticeAppCount; i++) { for(var i = 0; i < englishTypingPracticeAppCount; i++) {
let activeApp = replyJSON.EnglishAppList[i]; var activeApp = replyJSON.EnglishAppList[i];
let posX = self.getButtonPosX(i, englishTypingPracticeAppCount); var posX = this.getButtonPosX(i, englishTypingPracticeAppCount);
let posY = self.getButtonPosY(i, englishTypingPracticeAppCount, var posY = this.getButtonPosY(i, englishTypingPracticeAppCount,
TypingAppButton.BUTTON_LOWER_POS_Y TypingAppButton.BUTTON_LOWER_POS_Y
); );
let typingTestButton = new TypingAppButton( var typingTestButton = new TypingAppButton(
TypingAppButton.TYPE_TEST_ENGLISH, TypingAppButton.TYPE_TEST_ENGLISH,
posX, posY, posX, posY,
self.getIconImage(replyJSON.KoreanHighScoreList, activeApp.AppID), this.getIconImage(replyJSON.KoreanHighScoreList, activeApp.AppID),
activeApp.KoreanName, activeApp.KoreanName,
(function() { {
sessionStorageManager.playingAppID = activeApp.AppID; AppID: activeApp.AppID,
sessionStorageManager.playingAppName = activeApp.AppName; AppName: activeApp.AppName,
sessionStorageManager.playingAppKoreanName = activeApp.KoreanName; KoreanName: activeApp.KoreanName
location.href = '../../web/client/start.html'; }
})
); );
if(!self.hasApp(activeApp.AppID, replyJSON.EnglishActiveAppList)) if(!this.hasApp(activeApp.AppID, replyJSON.EnglishActiveAppList))
typingTestButton.inputEnabled = false; typingTestButton.setInputEnabled(false);
}
} }
},
getButtonPosX(index, buttonCount) { getButtonPosX: function(index, buttonCount) {
let gap = TypingAppButton.BUTTON_WIDTH + TypingAppButton.BUTTON_GAP; var gap = TypingAppButton.BUTTON_WIDTH + TypingAppButton.BUTTON_GAP;
let maxColumnNum = Math.floor( (game.world.width - TypingAppButton.MARGIN_VERTICAL) / gap ); var maxColumnNum = Math.floor( (game.world.width - TypingAppButton.MARGIN_VERTICAL) / gap );
// console.log("maxColumnNum : " + maxColumnNum); // console.log("maxColumnNum : " + maxColumnNum);
let rowCount = Math.ceil(buttonCount / maxColumnNum); var rowCount = Math.ceil(buttonCount / maxColumnNum);
// console.log("rowCount : " + rowCount); // console.log("rowCount : " + rowCount);
let columnIndex = index % maxColumnNum; var columnIndex = index % maxColumnNum;
// console.log("columnIndex : " + columnIndex); // console.log("columnIndex : " + columnIndex);
let rowIndex = Math.floor(index / maxColumnNum); var rowIndex = Math.floor(index / maxColumnNum);
// console.log("rowIndex : " + rowIndex); // console.log("rowIndex : " + rowIndex);
let columnCountForThisRow = 0; var columnCountForThisRow = 0;
if(rowIndex < rowCount - 1) if(rowIndex < rowCount - 1)
columnCountForThisRow = maxColumnNum; columnCountForThisRow = maxColumnNum;
else else
columnCountForThisRow = buttonCount - (maxColumnNum * rowIndex); columnCountForThisRow = buttonCount - (maxColumnNum * rowIndex);
// console.log("columnCountForThisRow : " + columnCountForThisRow); // 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; return startX + gap * columnIndex;
} },
getButtonPosY(index, buttonCount, startPosY) { getButtonPosY: function(index, buttonCount, startPosY) {
let rowGap = TypingAppButton.BUTTON_HEIGHT + TypingAppButton.BUTTON_GAP; var rowGap = TypingAppButton.BUTTON_HEIGHT + TypingAppButton.BUTTON_GAP;
let columnGap = TypingAppButton.BUTTON_WIDTH + TypingAppButton.BUTTON_GAP; var columnGap = TypingAppButton.BUTTON_WIDTH + TypingAppButton.BUTTON_GAP;
let maxColumnNum = Math.floor( (game.world.width - TypingAppButton.MARGIN_VERTICAL) / columnGap ); var maxColumnNum = Math.floor( (game.world.width - TypingAppButton.MARGIN_VERTICAL) / columnGap );
// console.log("maxColumnNum : " + maxColumnNum); // console.log("maxColumnNum : " + maxColumnNum);
// console.log("buttonCount : " + buttonCount); // console.log("buttonCount : " + buttonCount);
let rowCount = Math.ceil(buttonCount / maxColumnNum); var rowCount = Math.ceil(buttonCount / maxColumnNum);
// console.log("rowCount : " + rowCount); // console.log("rowCount : " + rowCount);
let rowIndex = Math.floor(index / maxColumnNum); var rowIndex = Math.floor(index / maxColumnNum);
// console.log("rowIndex : " + rowIndex); // console.log("rowIndex : " + rowIndex);
let startY = startPosY - ( (rowGap / 2) * (rowCount - 1) ); var startY = startPosY - ( (rowGap / 2) * (rowCount - 1) );
return startY + rowGap * rowIndex; return startY + rowGap * rowIndex;
} },
downloadListFailed(replyJSON) { downloadListFailed: function(replyJSON) {
console.log('download app list failed, jsonData : ' + JSON.stringify(replyJSON)); console.log('download app list failed, jsonData : ' + JSON.stringify(replyJSON));
} }
+12 -8
View File
@@ -1,7 +1,13 @@
class WelcomePlayerText extends Phaser.Text { WelcomePlayerText.prototype = Object.create(Phaser.Text.prototype);
WelcomePlayerText.constructor = WelcomePlayerText;
constructor(playerName) { function WelcomePlayerText(playerName) {
super(game, game.world.width / 2, game.world.height / 2 - 40, "어서오세요, " + playerName + "님", WelcomePlayerText.DEFAULT_TEXT_FONT); 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.anchor.set(0.5);
this.inputEnabled = false; this.inputEnabled = false;
@@ -19,12 +25,10 @@ class WelcomePlayerText extends Phaser.Text {
tweenAlpha.to( { alpha: 0 }, 2000, Phaser.Easing.Back.In, true); tweenAlpha.to( { alpha: 0 }, 2000, Phaser.Easing.Back.In, true);
game.add.existing(this); game.add.existing(this);
};
destroySelf() {
this.destroy();
} }
WelcomePlayerText.prototype.destroySelf = function() {
this.destroy();
} }
WelcomePlayerText.DEFAULT_TEXT_FONT = { WelcomePlayerText.DEFAULT_TEXT_FONT = {
@@ -32,4 +36,4 @@ WelcomePlayerText.DEFAULT_TEXT_FONT = {
boundsAlignH: "center", // left, center. right boundsAlignH: "center", // left, center. right
boundsAlignV: "middle", // top, middle, bottom boundsAlignV: "middle", // top, middle, bottom
fill: "#fff" fill: "#fff"
}; }
+16 -18
View File
@@ -4,21 +4,19 @@
class Game { class Game {
create() { create() {
let self = this;
this.game.stage.backgroundColor = "#000000"; // '#4d4d4d'; this.game.stage.backgroundColor = "#000000"; // '#4d4d4d';
sessionStorageManager.isNewBestRecrd = false; sessionStorageManager.isNewBestRecrd = false;
// top ui // top ui
let screenTopUI = new ScreenTopUI(); var screenTopUI = new ScreenTopUI();
screenTopUI.makeBackButton( function() { screenTopUI.makeBackButton( function() {
sessionStorageManager.resetPlayingAppData(); sessionStorageManager.resetPlayingAppData();
location.href = '../../web/client/menu_app.html'; location.href = '../../web/client/menu_app.html';
}); });
screenTopUI.makeFullScreenButton(); screenTopUI.makeFullScreenButton();
let scoreBoard = new ScoreBoard(); var scoreBoard = new ScoreBoard();
scoreManager.addOnChangeScoreListener( function(score) { scoreManager.addOnChangeScoreListener( function(score) {
sessionStorageManager.record = score; sessionStorageManager.record = score;
scoreBoard.printScore(NumberUtil.numberWithCommas(score)); scoreBoard.printScore(NumberUtil.numberWithCommas(score));
@@ -30,19 +28,19 @@ class Game {
screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.bestRecord); screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.bestRecord);
}); });
let heartGauge = new HeartGauge(heartManager); var heartGauge = new HeartGauge(heartManager);
heartManager.addOnChangeGameOverListener( heartManager.addOnChangeGameOverListener(
function() { self.gameOver(); } (function() { this.gameOver(); }).bind(this)
); );
heartGauge.start(); heartGauge.start();
// game stage // game stage
let stars = game.add.group(); var stars = game.add.group();
for (let i = 0; i < 128; i++) for (var i = 0; i < 128; i++)
{ {
let randomY = game.rnd.integerInRange(60, GAME_SCREEN_SIZE.y - 80); var randomY = game.rnd.integerInRange(60, GAME_SCREEN_SIZE.y - 80);
stars.create(game.world.randomX, randomY, 'star'); stars.create(game.world.randomX, randomY, 'star');
} }
@@ -55,13 +53,13 @@ class Game {
// contents // contents
this.aliens = []; this.aliens = [];
for(let i = 0; i < 10; i++) { for(var i = 0; i < 10; i++) {
let alien = new Alien(150 + 80 * i, 150, var alien = new Alien(150 + 80 * i, 150,
(function() { self.activateNextAlien(); }), // onGoOnstage (function() { this.activateNextAlien(); }).bind(this), // onGoOnstage
(function(sprite) { (function(sprite) {
scoreManager.plusScore(self.getScore()); scoreManager.plusScore(this.getScore());
let scoreText = new ScoreText(sprite.x, sprite.y, self.getScore()); var scoreText = new ScoreText(sprite.x, sprite.y, this.getScore());
}), // this.onAlienFired, }).bind(this), // this.onAlienFired,
this.onAlienEscaped this.onAlienEscaped
); );
alien.goWaitingRoom(); alien.goWaitingRoom();
@@ -73,7 +71,7 @@ class Game {
// bottom ui // bottom ui
let screenBottomUI = new ScreenBottomUI(); var screenBottomUI = new ScreenBottomUI();
screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.bestRecord); screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.bestRecord);
screenBottomUI.printCenterText(sessionStorageManager.playingAppKoreanName); screenBottomUI.printCenterText(sessionStorageManager.playingAppKoreanName);
screenBottomUI.printRightText(sessionStorageManager.playerName); screenBottomUI.printRightText(sessionStorageManager.playerName);
@@ -109,7 +107,7 @@ class Game {
this.countDownText.text = this.countDownNumber.toString(); this.countDownText.text = this.countDownNumber.toString();
this.countDownText.alpha = 1; this.countDownText.alpha = 1;
let countDownTween = game.add.tween(this.countDownText); var countDownTween = game.add.tween(this.countDownText);
countDownTween.to( { alpha: 0 }, 1000, Phaser.Easing.Linear.None, true); countDownTween.to( { alpha: 0 }, 1000, Phaser.Easing.Linear.None, true);
countDownTween.onComplete.add(this.tweenCountDown, this); countDownTween.onComplete.add(this.tweenCountDown, this);
@@ -125,7 +123,7 @@ class Game {
gameOver() { gameOver() {
this.alienTimer.stop(); this.alienTimer.stop();
let gameOverText = new GameOverText(); var gameOverText = new GameOverText();
game.time.events.add(Phaser.Timer.SECOND * 2, this.goResult, this); game.time.events.add(Phaser.Timer.SECOND * 2, this.goResult, this);
} }
+31 -35
View File
@@ -16,7 +16,7 @@ class Start {
// top ui // top ui
let screenTopUI = new ScreenTopUI(); var screenTopUI = new ScreenTopUI();
screenTopUI.makeBackButton( function() { screenTopUI.makeBackButton( function() {
if(isTypingPracticeStage()) if(isTypingPracticeStage())
location.href = '../../web/client/menu_typing_practice.html'; location.href = '../../web/client/menu_typing_practice.html';
@@ -45,7 +45,7 @@ class Start {
// bottom ui // bottom ui
let screenBottomUI = new ScreenBottomUI(); var screenBottomUI = new ScreenBottomUI();
screenBottomUI.printLeftText("오늘의 최고 기록 : "); screenBottomUI.printLeftText("오늘의 최고 기록 : ");
screenBottomUI.printCenterText(sessionStorageManager.playingAppKoreanName); screenBottomUI.printCenterText(sessionStorageManager.playingAppKoreanName);
screenBottomUI.printRightText(sessionStorageManager.playerName); screenBottomUI.printRightText(sessionStorageManager.playerName);
@@ -54,38 +54,34 @@ class Start {
sessionStorageManager.maestroID, sessionStorageManager.maestroID,
sessionStorageManager.playerID, sessionStorageManager.playerID,
sessionStorageManager.playingAppID, sessionStorageManager.playingAppID,
function(replyJSON) { (function(replyJSON) {
sessionStorageManager.bestRecord = Number(replyJSON["BestRecord"]); sessionStorageManager.bestRecord = Number(replyJSON["BestRecord"]);
screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.bestRecord); screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.bestRecord);
}, }).bind(this),
function(replyJSON) { // no data (function(replyJSON) { // no data
sessionStorageManager.bestRecord = 0; sessionStorageManager.bestRecord = 0;
screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.bestRecord); screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.bestRecord);
} }).bind(this)
); );
} }
loadHowToPlay(appID) { loadHowToPlay(appID) {
let self = this;
this.dbConnectManager.requestHowToPlay( this.dbConnectManager.requestHowToPlay(
sessionStorageManager.playingAppID, // space_invaders app ID sessionStorageManager.playingAppID, // space_invaders app ID
function(jsonData) { (function(jsonData) {
let howToPlayText = jsonData["HowToPlay"].replace(/\\n/g, "\n"); var howToPlayText = jsonData["HowToPlay"].replace(/\\n/g, "\n");
self.howToPlay.printHowToPlay(howToPlayText); this.howToPlay.printHowToPlay(howToPlayText);
}, }).bind(this),
function(jsonData) { (function(jsonData) {
self.howToPlay.printHowToPlay("No data"); this.howToPlay.printHowToPlay("No data");
} }).bind(this)
); );
} }
loadChart() { loadChart() {
let self = this; var today = new Date();
var date = DateUtil.getYYYYMMDD(today);
let today = new Date();
let date = DateUtil.getYYYYMMDD(today);
this.dbConnectManager.requestPlayerHistory( this.dbConnectManager.requestPlayerHistory(
sessionStorageManager.maestroID, sessionStorageManager.maestroID,
date, date,
@@ -95,19 +91,19 @@ class Start {
return; return;
} }
let underValue = historyRecordManager.underValueForGraph(); var underValue = historyRecordManager.underValueForGraph();
let upperValue = historyRecordManager.upperValueForGraph(); var upperValue = historyRecordManager.upperValueForGraph();
let minValue = underValue - (upperValue - underValue) / 10; var minValue = underValue - (upperValue - underValue) / 10;
let maxValue = upperValue;// + (upperValue - underValue) / 10; var maxValue = upperValue;// + (upperValue - underValue) / 10;
let countRecord = historyRecordManager.count; var countRecord = historyRecordManager.count;
for(let i = 0; i < Chart.CHART_COUNT; i++) { for(var i = 0; i < Chart.CHART_COUNT; i++) {
// if(i > 6) // if(i > 6)
// break; // break;
let historyRecord = historyRecordManager.getAt(i); var historyRecord = historyRecordManager.getAt(i);
self.chart.drawRecordGraph( this.chart.drawRecordGraph(
i, i,
historyRecord === undefined ? "-" : historyRecord.date, historyRecord === undefined ? "-" : historyRecord.date,
historyRecord === undefined ? "" : historyRecord.bestRecord, historyRecord === undefined ? "" : historyRecord.bestRecord,
@@ -115,20 +111,20 @@ class Start {
); );
} }
self.chart.printChartBaseLine(); this.chart.printChartBaseLine();
}) })
); );
} }
calcDate(daysBefore) { calcDate(daysBefore) {
let date = new Date(); var date = new Date();
date.setDate(date.getDate() - daysBefore); date.setDate(date.getDate() - daysBefore);
return date; return date;
} }
printSampleChart() { printSampleChart() {
let minValue = 0; var minValue = 0;
let maxValue = 1000; var maxValue = 1000;
this.chart.drawRecordGraph(0, this.calcDate(1), 980, minValue, maxValue); this.chart.drawRecordGraph(0, this.calcDate(1), 980, minValue, maxValue);
this.chart.drawRecordGraph(1, this.calcDate(2), 760, minValue, maxValue); this.chart.drawRecordGraph(1, this.calcDate(2), 760, minValue, maxValue);
this.chart.drawRecordGraph(2, this.calcDate(5), 740, minValue, maxValue); this.chart.drawRecordGraph(2, this.calcDate(5), 740, minValue, maxValue);
@@ -141,14 +137,14 @@ class Start {
} }
makeStartButton() { makeStartButton() {
let setting = new RoundRectButtonSetting(game.world.centerX, game.world.centerY, 200, 100); var setting = new RoundRectButtonSetting(game.world.centerX, game.world.centerY, 200, 100);
setting.fontStyle.fontWeight = "bold"; setting.fontStyle.fontWeight = "bold";
let startButton = new RoundRectButton(setting, RoundRectButton.NONE_ICON, "시작", this.startStage); var startButton = new RoundRectButton(setting, RoundRectButton.NONE_ICON, "시작", this.startStage);
} }
makeRankingButton() { makeRankingButton() {
let setting = new RoundRectButtonSetting(game.world.centerX + 160, game.world.centerY, 60, 60); var setting = new RoundRectButtonSetting(game.world.centerX + 160, game.world.centerY, 60, 60);
setting.fontStyle = { setting.fontStyle = {
font: "18px Arial", font: "18px Arial",
boundsAlignH: "center", // left, center. right boundsAlignH: "center", // left, center. right
@@ -156,7 +152,7 @@ class Start {
fill: "#fff" fill: "#fff"
}; };
let rankingButton = new RoundRectButton( var rankingButton = new RoundRectButton(
setting, RoundRectButton.NONE_ICON, "순위\n보기", setting, RoundRectButton.NONE_ICON, "순위\n보기",
(function() { (function() {
location.href = '../../web/client/ranking.html'; location.href = '../../web/client/ranking.html';