Fix: restructing session manager, ES6 -> ES5
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
const LANGUAGE_KOREAN = "korean";
|
||||
const LANGUAGE_ENGLISH = "english";
|
||||
var LANGUAGE_KOREAN = "korean";
|
||||
var LANGUAGE_ENGLISH = "english";
|
||||
|
||||
const MODE_RELEASE = "release";
|
||||
const MODE_DEBUG = "debug";
|
||||
const runMode = MODE_RELEASE;
|
||||
var MODE_RELEASE = "release";
|
||||
var MODE_DEBUG = "debug";
|
||||
var runMode = MODE_RELEASE;
|
||||
|
||||
function isDebugMode() {
|
||||
// console.log("debug mode ? " + runMode);
|
||||
@@ -16,7 +16,7 @@ function isReleaseMode() {
|
||||
}
|
||||
|
||||
|
||||
const GAME_SCREEN_SIZE = { x: 1024, y: 768 }
|
||||
var GAME_SCREEN_SIZE = { x: 1024, y: 768 }
|
||||
|
||||
|
||||
|
||||
|
||||
+11
-14
@@ -1,6 +1,4 @@
|
||||
class Animal {
|
||||
|
||||
constructor(type, x, y) {
|
||||
function Animal(type, x, y) {
|
||||
this.animalType = type;
|
||||
|
||||
this.sprite = null;
|
||||
@@ -8,7 +6,7 @@ class Animal {
|
||||
this.posY = y;
|
||||
}
|
||||
|
||||
loadSpriteNames() {
|
||||
Animal.prototype.loadSpriteNames = function() {
|
||||
let spriteNames = {};
|
||||
|
||||
spriteNames.icon = this.species.species + Animal.SPRITE_NAMES.icon;
|
||||
@@ -19,7 +17,7 @@ class Animal {
|
||||
return spriteNames;
|
||||
}
|
||||
|
||||
setSpecies(species) {
|
||||
Animal.prototype.setSpecies = function(species) {
|
||||
this.species = species;
|
||||
|
||||
if(this.animalType === Animal.TYPE_ICON)
|
||||
@@ -28,7 +26,7 @@ class Animal {
|
||||
this.setupAnimation();
|
||||
}
|
||||
|
||||
tweenAnimation(animationType) {
|
||||
Animal.prototype.tweenAnimation = function(animationType) {
|
||||
switch(animationType) {
|
||||
case Animal.ANIMATION_TYPE_CHANGE:
|
||||
this.sprite.width = 200;
|
||||
@@ -46,7 +44,7 @@ class Animal {
|
||||
|
||||
}
|
||||
|
||||
setupAnimation() {
|
||||
Animal.prototype.setupAnimation = function() {
|
||||
this.spriteFrameNames = this.loadSpriteNames();
|
||||
this.playingSpriteFrameName = this.spriteFrameNames.run1;
|
||||
this.animationFrameID = 1;
|
||||
@@ -63,12 +61,12 @@ class Animal {
|
||||
this.animateionUpdate();
|
||||
}
|
||||
|
||||
startAnimation() {
|
||||
Animal.prototype.startAnimation = function() {
|
||||
if(this.timerEvent === null)
|
||||
this.timerEvent = game.time.events.loop(this.animationSpeedSec, this.animateionUpdate, this);
|
||||
}
|
||||
|
||||
animateionUpdate() {
|
||||
Animal.prototype.animateionUpdate = function() {
|
||||
this.animationFrameID = 1 - this.animationFrameID;
|
||||
|
||||
if(this.animationFrameID === 0) {
|
||||
@@ -78,7 +76,7 @@ class Animal {
|
||||
}
|
||||
}
|
||||
|
||||
stopAnimation() {
|
||||
Animal.prototype.stopAnimation = function() {
|
||||
if(this.timerEvent !== null) {
|
||||
game.time.events.remove(this.timerEvent);
|
||||
this.timerEvent = null;
|
||||
@@ -86,7 +84,7 @@ class Animal {
|
||||
}
|
||||
|
||||
|
||||
static animalLevelIDByRecord(record, gameType) {
|
||||
Animal.animalLevelIDByRecord = function(record, gameType) {
|
||||
for(let i = Animal.SPECIES_DATA.length - 1; i > 0; i--) {
|
||||
if(record >= this.typingCount(Animal.SPECIES_DATA[i], gameType))
|
||||
return i;
|
||||
@@ -95,14 +93,14 @@ class Animal {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static typingCount(speciesData, gameType) {
|
||||
Animal.typingCount = function(speciesData, gameType) {
|
||||
if(gameType === Animal.TYPE_PRACTICE)
|
||||
return speciesData.practiceTypingCount;
|
||||
else
|
||||
return speciesData.testTypingCount;
|
||||
}
|
||||
|
||||
static loadResources() {
|
||||
Animal.loadResources = function() {
|
||||
game.load.image('snail_shadow', '../../../resources/image/character/animal/snail/shadow.png');
|
||||
|
||||
game.load.image('snail_icon', '../../../resources/image/character/animal/snail/run2.png');
|
||||
@@ -145,7 +143,6 @@ class Animal {
|
||||
game.load.image('eagle_run1', '../../../resources/image/character/animal/eagle/run1.png');
|
||||
game.load.image('eagle_run2', '../../../resources/image/character/animal/eagle/run2.png');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Animal.TYPE_ANIMATION = 0;
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
/////////////////////////////
|
||||
// Chart
|
||||
|
||||
class AnnounceBox {
|
||||
|
||||
constructor(x, y) {
|
||||
function AnnounceBox(x, y) {
|
||||
this.posX = x;
|
||||
this.posY = y;
|
||||
}
|
||||
|
||||
drawText(posX, posY, text) {
|
||||
AnnounceBox.prototype.drawText = function(posX, posY, text) {
|
||||
const style = { font: "24px Arial", fill: "#fff", align: "left", boundsAlignH: "center", boundsAlignV: "middle" };
|
||||
|
||||
let textObject = game.add.text(
|
||||
@@ -22,11 +17,11 @@ class AnnounceBox {
|
||||
return textObject;
|
||||
}
|
||||
|
||||
getFontStyle() {
|
||||
AnnounceBox.prototype.getFontStyle = function() {
|
||||
return { font: "32px Arial", fill: "#fff" };
|
||||
}
|
||||
|
||||
drawBox(text) {
|
||||
AnnounceBox.prototype.drawBox = function(text) {
|
||||
this.graphics = game.add.graphics(this.posX, this.posY);
|
||||
this.graphics.alpha = 0.8;
|
||||
|
||||
@@ -48,5 +43,3 @@ class AnnounceBox {
|
||||
announceText.stroke = "#330000";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
class AppInfo {
|
||||
|
||||
constructor(appID, appName, koreanName, howToPlay) {
|
||||
function AppInfo(appID, appName, koreanName, howToPlay) {
|
||||
this.appID = appID;
|
||||
this.appName = appName;
|
||||
|
||||
@@ -9,18 +7,14 @@ class AppInfo {
|
||||
this.howToPlay = howToPlay;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class AppInfoManager {
|
||||
|
||||
constructor() {
|
||||
function AppInfoManager() {
|
||||
this.appInfoMap = new Map();
|
||||
|
||||
this.registerAppInfoList();
|
||||
}
|
||||
|
||||
registerAppInfoList() {
|
||||
AppInfoManager.prototype.registerAppInfoList = function() {
|
||||
// menu
|
||||
this.registerAppInfo(new AppInfo("test", "테스트", ""));
|
||||
this.registerAppInfo(new AppInfo("login", "로그인", ""));
|
||||
@@ -52,26 +46,24 @@ class AppInfoManager {
|
||||
));
|
||||
}
|
||||
|
||||
setHowToPlay(appName, text) {
|
||||
AppInfoManager.prototype.setHowToPlay = function(appName, text) {
|
||||
this.appInfoMap[appName].howToPlay = text;
|
||||
}
|
||||
|
||||
registerAppInfo(appInfo) {
|
||||
AppInfoManager.prototype.registerAppInfo = function(appInfo) {
|
||||
return this.appInfoMap[appInfo.appName] = appInfo;
|
||||
}
|
||||
|
||||
getAppkoreanName(appName) {
|
||||
AppInfoManager.prototype.getAppkoreanName = function(appName) {
|
||||
if(appName === null)
|
||||
return "";
|
||||
|
||||
return this.appInfoMap[appName].koreanName;
|
||||
}
|
||||
|
||||
getHowToPlayText(appName) {
|
||||
AppInfoManager.prototype.getHowToPlayText = function(appName) {
|
||||
if(appName === null)
|
||||
return "";
|
||||
|
||||
return this.appInfoMap[appName].howToPlay;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -79,9 +79,9 @@ function GameAppButton(x, y, type, iconName, buttonText, appInfo) {
|
||||
|
||||
|
||||
GameAppButton.prototype.clickEvent = function() {
|
||||
sessionStorageManager.getPlayingAppID() = this.appInfo.AppID;
|
||||
sessionStorageManager.getPlayingAppName() = this.appInfo.AppName;
|
||||
sessionStorageManager.getPlayingAppKoreanName() = this.appInfo.KoreanName;
|
||||
sessionStorageManager.setPlayingAppID(this.appInfo.AppID);
|
||||
sessionStorageManager.setPlayingAppName(this.appInfo.AppName);
|
||||
sessionStorageManager.setPlayingAppKoreanName(this.appInfo.KoreanName);
|
||||
|
||||
location.href = '../../web/client/start.html';
|
||||
}
|
||||
|
||||
+9
-15
@@ -1,22 +1,17 @@
|
||||
/////////////////////////////
|
||||
// Chart
|
||||
|
||||
class Chart {
|
||||
|
||||
constructor() {
|
||||
function Chart() {
|
||||
this.chartGraphics = game.add.graphics(0, 0);
|
||||
}
|
||||
|
||||
printChartBaseLine() {
|
||||
Chart.prototype.printChartBaseLine = function() {
|
||||
this.chartGraphics.lineStyle(3, 0xffd900, 1);
|
||||
this.chartGraphics.moveTo(100, Chart.CHART_LINE_Y);
|
||||
this.chartGraphics.lineTo(game.world.width - 100, Chart.CHART_LINE_Y);
|
||||
}
|
||||
|
||||
drawRecordGraph(index, date, bestRecord, min, max) {
|
||||
let reverseIndex = (Chart.CHART_COUNT - 1) - index;
|
||||
let posX = Chart.CHART_LINE_START_X + Chart.CHART_GRAPH_OFFSET_X + reverseIndex * Chart.CHART_GAP_PX;
|
||||
let posY = Chart.CHART_LINE_Y;
|
||||
Chart.prototype.drawRecordGraph = function(index, date, bestRecord, min, max) {
|
||||
var reverseIndex = (Chart.CHART_COUNT - 1) - index;
|
||||
var posX = Chart.CHART_LINE_START_X + Chart.CHART_GRAPH_OFFSET_X + reverseIndex * Chart.CHART_GAP_PX;
|
||||
var posY = Chart.CHART_LINE_Y;
|
||||
|
||||
this.drawText(
|
||||
posX, posY + Chart.CHART_DATE_OFFSET_Y,
|
||||
@@ -37,10 +32,10 @@ class Chart {
|
||||
this.chartGraphics.lineTo(posX, posY - Chart.CHART_HEIGHT * ( (bestRecord - min) / (max - min) ));
|
||||
}
|
||||
|
||||
drawText(posX, posY, text) {
|
||||
Chart.prototype.drawText = function(posX, posY, text) {
|
||||
const style = { font: "24px Arial", fill: "#fff", align: "left", boundsAlignH: "center", boundsAlignV: "middle" };
|
||||
|
||||
let textObject = game.add.text(
|
||||
var textObject = game.add.text(
|
||||
posX, posY,
|
||||
text, style
|
||||
);
|
||||
@@ -51,11 +46,10 @@ class Chart {
|
||||
return textObject;
|
||||
}
|
||||
|
||||
getFontStyle() {
|
||||
Chart.prototype.getFontStyle = function() {
|
||||
return { font: "32px Arial", fill: "#fff" };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Chart.CHART_COUNT = 7;
|
||||
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
class DateUtil {
|
||||
function DateUtil() {
|
||||
}
|
||||
|
||||
static getYYYYMMDD(date) {
|
||||
DateUtil.getYYYYMMDD = function(date) {
|
||||
// return date.toISOString().slice(0,10);
|
||||
return date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
|
||||
}
|
||||
|
||||
static getHHMMSS(date) {
|
||||
DateUtil.getHHMMSS = function(date) {
|
||||
return StringUtil.getNumberStartWithZero(date.getHours(), 2) + ":"
|
||||
+ StringUtil.getNumberStartWithZero(date.getMinutes(), 2) + ":"
|
||||
+ StringUtil.getNumberStartWithZero(date.getSeconds(), 2);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
class DBConnectManager {
|
||||
|
||||
constructor() {
|
||||
function DBConnectManager() {
|
||||
this.path = this.getPath();
|
||||
this.directoryName = this.getDirectoryName(this.path);
|
||||
this.phpPath = this.getPHPPath(this.directoryName);
|
||||
@@ -11,49 +9,49 @@ class DBConnectManager {
|
||||
this.dateAndTime = null;
|
||||
}
|
||||
|
||||
setMaestroID(maestroID) {
|
||||
DBConnectManager.prototype.setMaestroID = function(maestroID) {
|
||||
this.maestroID = maestroID;
|
||||
}
|
||||
|
||||
setPlayerID(playerID) {
|
||||
DBConnectManager.prototype.setPlayerID = function(playerID) {
|
||||
this.playerID = playerID;
|
||||
}
|
||||
|
||||
setAppName(appName) {
|
||||
DBConnectManager.prototype.setAppName = function(appName) {
|
||||
this.appName = appName;
|
||||
}
|
||||
|
||||
setDateTime(date, time) {
|
||||
DBConnectManager.prototype.setDateTime = function(date, time) {
|
||||
this.dateAndTime = date + time;
|
||||
}
|
||||
|
||||
resetDateTime() {
|
||||
DBConnectManager.prototype.resetDateTime = function() {
|
||||
this.dateAndTime = null;
|
||||
}
|
||||
|
||||
getPath() {
|
||||
DBConnectManager.prototype.getPath = function() {
|
||||
return window.location.pathname;
|
||||
}
|
||||
|
||||
getDirectoryName(path) {
|
||||
let pathAndFileNames = path.split("/");
|
||||
DBConnectManager.prototype.getDirectoryName = function(path) {
|
||||
var pathAndFileNames = path.split("/");
|
||||
return pathAndFileNames[pathAndFileNames.length - 2];
|
||||
}
|
||||
|
||||
getPHPPath(directoryName) {
|
||||
DBConnectManager.prototype.getPHPPath = function(directoryName) {
|
||||
if(directoryName === "test") // mouse_typing/test/
|
||||
return "../src/web/";
|
||||
else // mousetyping/src/web/client/
|
||||
return "../";
|
||||
}
|
||||
|
||||
requestCheckPlayerLogin(maestroName, playerName, enterCode, onSucceededListener, onFailedListener) {
|
||||
let xhr = new XMLHttpRequest();
|
||||
DBConnectManager.prototype.requestCheckPlayerLogin = function(maestroName, playerName, enterCode, onSucceededListener, onFailedListener) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", this.phpPath + "server/player/login.php", true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.onreadystatechange = function() {
|
||||
if(xhr.readyState == 4 && xhr.status == 200) {
|
||||
let replyJSON = JSON.parse(xhr.responseText);
|
||||
var replyJSON = JSON.parse(xhr.responseText);
|
||||
|
||||
if(replyJSON != null && replyJSON["PlayerID"] != null)
|
||||
onSucceededListener(replyJSON);
|
||||
@@ -65,13 +63,13 @@ class DBConnectManager {
|
||||
}
|
||||
|
||||
/*
|
||||
requestAppList(maestroID, onSucceededListener, onFailedListener) {
|
||||
let xhr = new XMLHttpRequest();
|
||||
DBConnectManager.prototype.requestAppList = function(maestroID, onSucceededListener, onFailedListener) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", this.phpPath + "server/app/app_data.php", true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.onreadystatechange = function() {
|
||||
if(xhr.readyState == 4 && xhr.status == 200) {
|
||||
let replyJSON = JSON.parse(xhr.responseText);
|
||||
var replyJSON = JSON.parse(xhr.responseText);
|
||||
|
||||
if(replyJSON != null)
|
||||
onSucceededListener(replyJSON);
|
||||
@@ -82,13 +80,13 @@ class DBConnectManager {
|
||||
xhr.send("maestro_id=" + maestroID);
|
||||
}
|
||||
|
||||
requestActiveAppList(maestroID, onSucceededListener, onFailedListener) {
|
||||
let xhr = new XMLHttpRequest();
|
||||
DBConnectManager.prototype.requestActiveAppList = function(maestroID, onSucceededListener, onFailedListener) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", this.phpPath + "server/app/active_app.php", true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.onreadystatechange = function() {
|
||||
if(xhr.readyState == 4 && xhr.status == 200) {
|
||||
let replyJSON = JSON.parse(xhr.responseText);
|
||||
var replyJSON = JSON.parse(xhr.responseText);
|
||||
|
||||
if(replyJSON != null)
|
||||
onSucceededListener(replyJSON);
|
||||
@@ -100,13 +98,13 @@ class DBConnectManager {
|
||||
}
|
||||
*/
|
||||
|
||||
requestMenuAppList(maestroID, onSucceededListener, onFailedListener) {
|
||||
let xhr = new XMLHttpRequest();
|
||||
DBConnectManager.prototype.requestMenuAppList = function(maestroID, onSucceededListener, onFailedListener) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", this.phpPath + "server/app/menu_active_app_list.php", true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.onreadystatechange = function() {
|
||||
if(xhr.readyState == 4 && xhr.status == 200) {
|
||||
let replyJSON = JSON.parse(xhr.responseText);
|
||||
var replyJSON = JSON.parse(xhr.responseText);
|
||||
|
||||
if(replyJSON != null)
|
||||
onSucceededListener(replyJSON);
|
||||
@@ -117,13 +115,13 @@ class DBConnectManager {
|
||||
xhr.send("maestro_id=" + maestroID);
|
||||
}
|
||||
|
||||
requestTypingPracticeAppList(maestroID, playerID, onSucceededListener, onFailedListener) {
|
||||
let xhr = new XMLHttpRequest();
|
||||
DBConnectManager.prototype.requestTypingPracticeAppList = function(maestroID, playerID, onSucceededListener, onFailedListener) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", this.phpPath + "server/app/menu_active_typing_practice_app_list.php", true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.onreadystatechange = function() {
|
||||
if(xhr.readyState == 4 && xhr.status == 200) {
|
||||
let replyJSON = JSON.parse(xhr.responseText);
|
||||
var replyJSON = JSON.parse(xhr.responseText);
|
||||
|
||||
if(replyJSON != null)
|
||||
onSucceededListener(replyJSON);
|
||||
@@ -134,13 +132,13 @@ class DBConnectManager {
|
||||
xhr.send("maestro_id=" + maestroID + "&player_id=" + playerID);
|
||||
}
|
||||
|
||||
requestTypingTestAppList(maestroID, playerID, onSucceededListener, onFailedListener) {
|
||||
let xhr = new XMLHttpRequest();
|
||||
DBConnectManager.prototype.requestTypingTestAppList = function(maestroID, playerID, onSucceededListener, onFailedListener) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", this.phpPath + "server/app/menu_active_typing_test_app_list.php", true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.onreadystatechange = function() {
|
||||
if(xhr.readyState == 4 && xhr.status == 200) {
|
||||
let replyJSON = JSON.parse(xhr.responseText);
|
||||
var replyJSON = JSON.parse(xhr.responseText);
|
||||
|
||||
if(replyJSON != null)
|
||||
onSucceededListener(replyJSON);
|
||||
@@ -151,8 +149,8 @@ class DBConnectManager {
|
||||
xhr.send("maestro_id=" + maestroID + "&player_id=" + playerID);
|
||||
}
|
||||
|
||||
requestPlayerHistory(maestroID, date, listener) {
|
||||
let historyRecordManager = new HistoryRecordManager();
|
||||
DBConnectManager.prototype.requestPlayerHistory = function(maestroID, date, listener) {
|
||||
var historyRecordManager = new HistoryRecordManager();
|
||||
|
||||
/*
|
||||
if(isDebugMode()) {
|
||||
@@ -165,14 +163,14 @@ class DBConnectManager {
|
||||
}
|
||||
*/
|
||||
|
||||
let self = this;
|
||||
var self = this;
|
||||
|
||||
let xhr = new XMLHttpRequest();
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", this.phpPath + "server/record/history_record.php", true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.onreadystatechange = function() {
|
||||
if(xhr.readyState == 4 && xhr.status == 200) {
|
||||
let replyJSON = JSON.parse(xhr.responseText);
|
||||
var replyJSON = JSON.parse(xhr.responseText);
|
||||
|
||||
if(replyJSON != null)
|
||||
listener(self.parseJSONtoHistoryRecord(replyJSON));
|
||||
@@ -180,15 +178,15 @@ class DBConnectManager {
|
||||
onFailedListener(replyJSON);
|
||||
}
|
||||
};
|
||||
let params = "MaestroID=" + sessionStorageManager.maestroID
|
||||
+ "&AppID=" + sessionStorageManager.playingAppID
|
||||
+ "&PlayerID=" + sessionStorageManager.playerID
|
||||
var params = "MaestroID=" + sessionStorageManager.getMaestroID()
|
||||
+ "&AppID=" + sessionStorageManager.getPlayingAppID()
|
||||
+ "&PlayerID=" + sessionStorageManager.getPlayerID()
|
||||
+ "&Date=" + date;
|
||||
xhr.send(params);
|
||||
}
|
||||
|
||||
parseJSONtoHistoryRecord(json) {
|
||||
let historyRecordManager = new HistoryRecordManager();
|
||||
DBConnectManager.prototype.parseJSONtoHistoryRecord = function(json) {
|
||||
var historyRecordManager = new HistoryRecordManager();
|
||||
|
||||
if(typeof json === "undefined")
|
||||
return historyRecordManager;
|
||||
@@ -196,9 +194,9 @@ class DBConnectManager {
|
||||
if(typeof json.history === "undefined")
|
||||
return historyRecordManager;
|
||||
|
||||
let count = json.history.length;
|
||||
for(let i = 0; i < count; i++) {
|
||||
let record = new HistoryRecord(
|
||||
var count = json.history.length;
|
||||
for(var i = 0; i < count; i++) {
|
||||
var record = new HistoryRecord(
|
||||
json.history[i]["Date"],
|
||||
json.history[i]["AppName"],
|
||||
json.history[i]["HighScore"]
|
||||
@@ -230,8 +228,8 @@ class DBConnectManager {
|
||||
*/
|
||||
}
|
||||
|
||||
requestRanking(type, maestroID, date, time, listener) {
|
||||
let rankingRecordManager = new RankingRecordManager();
|
||||
DBConnectManager.prototype.requestRanking = function(type, maestroID, date, time, listener) {
|
||||
var rankingRecordManager = new RankingRecordManager();
|
||||
|
||||
/*
|
||||
if(isDebugMode()) {
|
||||
@@ -244,14 +242,14 @@ class DBConnectManager {
|
||||
}
|
||||
*/
|
||||
|
||||
let self = this;
|
||||
var self = this;
|
||||
|
||||
let xhr = new XMLHttpRequest();
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", this.getRankingRecordUrl(type), true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.onreadystatechange = function() {
|
||||
if(xhr.readyState == 4 && xhr.status == 200) {
|
||||
let replyJSON = JSON.parse(xhr.responseText);
|
||||
var replyJSON = JSON.parse(xhr.responseText);
|
||||
|
||||
if(replyJSON != null) {
|
||||
listener(type, self.parseJSONtoRankingRecord(type, replyJSON));
|
||||
@@ -260,15 +258,15 @@ class DBConnectManager {
|
||||
onFailedListener(replyJSON);
|
||||
}
|
||||
};
|
||||
let params = "MaestroID=" + sessionStorageManager.maestroID
|
||||
+ "&AppID=" + sessionStorageManager.playingAppID
|
||||
var params = "MaestroID=" + sessionStorageManager.getMaestroID()
|
||||
+ "&AppID=" + sessionStorageManager.getPlayingAppID()
|
||||
+ "&Date=" + date
|
||||
+ "&Time=" + time;
|
||||
xhr.send(params);
|
||||
}
|
||||
|
||||
getRankingRecordUrl(type) {
|
||||
let rankingRecordURL = this.phpPath;
|
||||
DBConnectManager.prototype.getRankingRecordUrl = function(type) {
|
||||
var rankingRecordURL = this.phpPath;
|
||||
|
||||
switch(type) {
|
||||
case DBConnectManager.TYPE_MY_RANKING_HOUR:
|
||||
@@ -290,13 +288,13 @@ class DBConnectManager {
|
||||
return rankingRecordURL;
|
||||
}
|
||||
|
||||
parseJSONtoRankingRecord(type, json) {
|
||||
let rankingRecordManager = new RankingRecordManager();
|
||||
DBConnectManager.prototype.parseJSONtoRankingRecord = function(type, json) {
|
||||
var rankingRecordManager = new RankingRecordManager();
|
||||
|
||||
if(typeof json === "undefined")
|
||||
return rankingRecordManager;
|
||||
|
||||
let replyJSON = null;
|
||||
var replyJSON = null;
|
||||
switch(type) {
|
||||
case DBConnectManager.TYPE_MY_RANKING_HOUR:
|
||||
case DBConnectManager.TYPE_ALL_RANKING_HOUR:
|
||||
@@ -317,9 +315,9 @@ class DBConnectManager {
|
||||
if(replyJSON === null)
|
||||
return rankingRecordManager;
|
||||
|
||||
let count = replyJSON.length;
|
||||
for(let i = 0; i < count; i++) {
|
||||
let record = new RankingRecord(
|
||||
var count = replyJSON.length;
|
||||
for(var i = 0; i < count; i++) {
|
||||
var record = new RankingRecord(
|
||||
i + 1,
|
||||
replyJSON[i]["PlayerID"],
|
||||
replyJSON[i]["Name"],
|
||||
@@ -332,15 +330,15 @@ class DBConnectManager {
|
||||
}
|
||||
|
||||
|
||||
onFailed(errorMessage) {
|
||||
DBConnectManager.prototype.onFailed = function(errorMessage) {
|
||||
console.log("failed : " + errorMessage);
|
||||
}
|
||||
|
||||
|
||||
makeXHRWithParam(url, param, onSucceededListener, onFailedListener) {
|
||||
DBConnectManager.prototype.makeXHRWithParam = function(url, param, onSucceededListener, onFailedListener) {
|
||||
xhr.onreadystatechange = function() {
|
||||
if(xhr.readyState == 4 && xhr.status == 200) {
|
||||
let replyJSON = JSON.parse(xhr.responseText);
|
||||
var replyJSON = JSON.parse(xhr.responseText);
|
||||
|
||||
if(replyJSON != null && replyJSON["PlayerID"] != null)
|
||||
onSucceededListener(replyJSON);
|
||||
@@ -352,13 +350,13 @@ class DBConnectManager {
|
||||
return xhr;
|
||||
}
|
||||
|
||||
requestHowToPlay(appID, onSucceededListener, onFailedListener) {
|
||||
let xhr = new XMLHttpRequest();
|
||||
DBConnectManager.prototype.requestHowToPlay = function(appID, onSucceededListener, onFailedListener) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", this.phpPath + "server/app/how_to_play.php", true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.onreadystatechange = function() {
|
||||
if(xhr.readyState == 4 && xhr.status == 200) {
|
||||
let replyJSON = JSON.parse(xhr.responseText);
|
||||
var replyJSON = JSON.parse(xhr.responseText);
|
||||
|
||||
if(replyJSON != null && replyJSON["HowToPlay"] != null)
|
||||
onSucceededListener(replyJSON);
|
||||
@@ -369,8 +367,8 @@ class DBConnectManager {
|
||||
xhr.send("AppID=" + appID);
|
||||
}
|
||||
|
||||
updateTodayBestRecord(maestroID, playerID, appID, record) {
|
||||
let xhr = new XMLHttpRequest();
|
||||
DBConnectManager.prototype.updateTodayBestRecord = function(maestroID, playerID, appID, record) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", this.phpPath + "server/record/update_best_record.php", true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.send(
|
||||
@@ -381,13 +379,13 @@ class DBConnectManager {
|
||||
);
|
||||
}
|
||||
|
||||
requestTodayBestRecord(maestroID, playerID, appID, onSucceededListener, onFailedListener) {
|
||||
let xhr = new XMLHttpRequest();
|
||||
DBConnectManager.prototype.requestTodayBestRecord = function(maestroID, playerID, appID, onSucceededListener, onFailedListener) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", this.phpPath + "server/record/request_best_record.php", true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.onreadystatechange = function() {
|
||||
if(xhr.readyState == 4 && xhr.status == 200) {
|
||||
let replyJSON = JSON.parse(xhr.responseText);
|
||||
var replyJSON = JSON.parse(xhr.responseText);
|
||||
|
||||
if(replyJSON != null && replyJSON["BestRecord"] != null)
|
||||
onSucceededListener(replyJSON);
|
||||
@@ -402,13 +400,13 @@ class DBConnectManager {
|
||||
);
|
||||
}
|
||||
|
||||
requestAppRanking(maestroID, appID, onSucceededListener, onFailedListener) {
|
||||
let xhr = new XMLHttpRequest();
|
||||
DBConnectManager.prototype.requestAppRanking = function(maestroID, appID, onSucceededListener, onFailedListener) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", this.phpPath + "server/record/app_ranking.php", true);
|
||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||
xhr.onreadystatechange = function() {
|
||||
if(xhr.readyState == 4 && xhr.status == 200) {
|
||||
let replyJSON = JSON.parse(xhr.responseText);
|
||||
var replyJSON = JSON.parse(xhr.responseText);
|
||||
|
||||
if(replyJSON != null)
|
||||
onSucceededListener(replyJSON);
|
||||
@@ -423,8 +421,7 @@ class DBConnectManager {
|
||||
}
|
||||
|
||||
|
||||
|
||||
loadTempPlayerHistory(historyRecordManager) {
|
||||
DBConnectManager.prototype.loadTempPlayerHistory = function(historyRecordManager) {
|
||||
historyRecordManager.push(new HistoryRecord("05/14", "space_invaders", 14460));
|
||||
historyRecordManager.push(new HistoryRecord("05/13", "space_invaders", 12860));
|
||||
historyRecordManager.push(new HistoryRecord("05/12", "typing_english_basic", 15460));
|
||||
@@ -434,7 +431,7 @@ class DBConnectManager {
|
||||
historyRecordManager.push(new HistoryRecord("05/08", "typing_korean_basic", 13058));
|
||||
}
|
||||
|
||||
loadTempRanking(rankingRecordManager) {
|
||||
DBConnectManager.prototype.loadTempRanking = function(rankingRecordManager) {
|
||||
rankingRecordManager.push(new RankingRecord(1, 7, "강경모", 4400));
|
||||
rankingRecordManager.push(new RankingRecord(2, 2, "강성태", 3400));
|
||||
rankingRecordManager.push(new RankingRecord(3, 3, "김기덕", 2400));
|
||||
@@ -453,8 +450,6 @@ class DBConnectManager {
|
||||
rankingRecordManager.push(new RankingRecord(16, 16, "하하하", 4));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DBConnectManager.TYPE_MY_RANKING_HOUR = 0;
|
||||
DBConnectManager.TYPE_MY_RANKING_DAY = 1;
|
||||
DBConnectManager.TYPE_MY_RANKING_MONTH = 2;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
class GameOverText extends Phaser.Text {
|
||||
GameOverText.prototype = Object.create(Phaser.Text.prototype);
|
||||
GameOverText.constructor = GameOverText;
|
||||
|
||||
constructor() {
|
||||
super(
|
||||
game,
|
||||
function GameOverText() {
|
||||
Phaser.Text.call(
|
||||
this, game,
|
||||
game.world.width / 2,
|
||||
game.world.height / 2 - GameOverText.MOVE_AMOUNT_PX,
|
||||
"게임 오버",
|
||||
@@ -23,16 +24,15 @@ class GameOverText extends Phaser.Text {
|
||||
|
||||
|
||||
this.alpha = 0;
|
||||
let tweenAlpha = game.add.tween(this);
|
||||
var tweenAlpha = game.add.tween(this);
|
||||
tweenAlpha.to( { alpha: 1 }, GameOverText.TWEEN_ALPHA_TIME, Phaser.Easing.Linear.None, true);
|
||||
|
||||
let tweenMove = game.add.tween(this);
|
||||
var tweenMove = game.add.tween(this);
|
||||
tweenMove.to( { y: game.world.height / 2 }, GameOverText.TWEEN_MOVE_TIME, Phaser.Easing.Bounce.Out, true);
|
||||
|
||||
game.add.existing(this);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
GameOverText.DEFAULT_TEXT_FONT = {
|
||||
font: "bold 100px Arial",
|
||||
|
||||
+11
-14
@@ -1,10 +1,8 @@
|
||||
class HeartGauge {
|
||||
|
||||
constructor(heartManager) {
|
||||
function HeartGauge(heartManager) {
|
||||
this.heartManager = heartManager;
|
||||
this.hearts = [];
|
||||
|
||||
let self = this;
|
||||
var self = this;
|
||||
this.heartManager.addOnChangeCountListener(
|
||||
function() { self.onChangeCountListener(); }
|
||||
);
|
||||
@@ -13,10 +11,10 @@ class HeartGauge {
|
||||
function() { self.onChangeMaxCountListener(); }
|
||||
);
|
||||
|
||||
let startPosX = GAME_SCREEN_SIZE.x - HeartGauge.GAP * 4;
|
||||
let posY = 30;
|
||||
for(let i = 0; i < HeartManager.HEART_MAX_COUNT; i++) {
|
||||
let heart = game.add.sprite(startPosX - i * HeartGauge.GAP, posY, "heart_full");
|
||||
var startPosX = GAME_SCREEN_SIZE.x - HeartGauge.GAP * 4;
|
||||
var posY = 30;
|
||||
for(var i = 0; i < HeartManager.HEART_MAX_COUNT; i++) {
|
||||
var heart = game.add.sprite(startPosX - i * HeartGauge.GAP, posY, "heart_full");
|
||||
heart.anchor.set(0.5);
|
||||
heart.scale.set(HeartGauge.HEART_SCALE);
|
||||
heart.alpha = 0;
|
||||
@@ -24,20 +22,20 @@ class HeartGauge {
|
||||
}
|
||||
};
|
||||
|
||||
onChangeCountListener() {
|
||||
HeartGauge.prototype.onChangeCountListener = function() {
|
||||
this.updateHearts();
|
||||
}
|
||||
|
||||
onChangeMaxCountListener() {
|
||||
HeartGauge.prototype.onChangeMaxCountListener = function() {
|
||||
this.updateHearts();
|
||||
}
|
||||
|
||||
start() {
|
||||
HeartGauge.prototype.start = function() {
|
||||
this.updateHearts();
|
||||
}
|
||||
|
||||
updateHearts() {
|
||||
for(let i = 0; i < this.heartManager.getMaxCount(); i++) {
|
||||
HeartGauge.prototype.updateHearts = function() {
|
||||
for(var i = 0; i < this.heartManager.getMaxCount(); i++) {
|
||||
if(i < this.heartManager.getCount())
|
||||
this.hearts[i].loadTexture("heart_full");
|
||||
else
|
||||
@@ -46,7 +44,6 @@ class HeartGauge {
|
||||
this.hearts[i].alpha = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HeartGauge.GAP = 35;
|
||||
HeartGauge.HEART_SCALE = 0.6;
|
||||
@@ -1,6 +1,4 @@
|
||||
class HeartManager {
|
||||
|
||||
constructor() {
|
||||
function HeartManager() {
|
||||
this.countHearts = HeartManager.DEFAULT_COUNT;
|
||||
this.countMaxHearts = HeartManager.DEFAULT_COUNT;
|
||||
|
||||
@@ -9,53 +7,53 @@ class HeartManager {
|
||||
this.onChangeGameOverListeners = [];
|
||||
}
|
||||
|
||||
callListener(functionArray) {
|
||||
HeartManager.prototype.callListener = function(functionArray) {
|
||||
if(functionArray.length > 0) {
|
||||
for(let i = 0; i < functionArray.length; i++) {
|
||||
for(var i = 0; i < functionArray.length; i++) {
|
||||
functionArray[i](this.score);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addOnChangeCountListener(onChangeFunction) {
|
||||
HeartManager.prototype.addOnChangeCountListener = function(onChangeFunction) {
|
||||
this.onChangeCountListeners.push(onChangeFunction);
|
||||
}
|
||||
|
||||
removeOnChangeCountListener(onChangeFunction) {
|
||||
let itemIndex = this.onChangeCountListeners.indexOf(onChangeFunction);
|
||||
HeartManager.prototype.removeOnChangeCountListener = function(onChangeFunction) {
|
||||
var itemIndex = this.onChangeCountListeners.indexOf(onChangeFunction);
|
||||
if(itemIndex > -1)
|
||||
this.onChangeCountListeners.splice(itemIndex, 1);
|
||||
}
|
||||
|
||||
addOnChangeMaxCountListener(onChangeMaxFunction) {
|
||||
HeartManager.prototype.addOnChangeMaxCountListener = function(onChangeMaxFunction) {
|
||||
this.onChangeMaxCountListeners.push(onChangeMaxFunction);
|
||||
}
|
||||
|
||||
removeOnChangeMaxCountListener(onChangeMaxFunction) {
|
||||
let itemIndex = this.onChangeMaxCountListeners.indexOf(onChangeMaxFunction);
|
||||
HeartManager.prototype.removeOnChangeMaxCountListener = function(onChangeMaxFunction) {
|
||||
var itemIndex = this.onChangeMaxCountListeners.indexOf(onChangeMaxFunction);
|
||||
if(itemIndex > -1)
|
||||
this.onChangeMaxCountListeners.splice(itemIndex, 1);
|
||||
}
|
||||
|
||||
addOnChangeGameOverListener(onChangeGameOverFunction) {
|
||||
HeartManager.prototype.addOnChangeGameOverListener = function(onChangeGameOverFunction) {
|
||||
this.onChangeGameOverListeners.push(onChangeGameOverFunction);
|
||||
}
|
||||
|
||||
removeOnChangeHighScoreListener(onChangeGameOverFunction) {
|
||||
let itemIndex = this.onChangeGameOverListeners.indexOf(onChangeGameOverFunction);
|
||||
HeartManager.prototype.removeOnChangeHighScoreListener = function(onChangeGameOverFunction) {
|
||||
var itemIndex = this.onChangeGameOverListeners.indexOf(onChangeGameOverFunction);
|
||||
if(itemIndex > -1)
|
||||
this.onChangeGameOverListeners.splice(itemIndex, 1);
|
||||
}
|
||||
|
||||
removeAllListeners() {
|
||||
HeartManager.prototype.removeAllListeners = function() {
|
||||
this.onChangeCountListeners = [];
|
||||
this.onChangeMaxCountListeners = [];
|
||||
this.onChangeGameOverListeners = [];
|
||||
}
|
||||
|
||||
|
||||
setCount(amount) {
|
||||
let beforeCountHearts = this.countHearts;
|
||||
HeartManager.prototype.setCount = function(amount) {
|
||||
var beforeCountHearts = this.countHearts;
|
||||
this.countHearts = amount;
|
||||
if(this.countHearts < 0)
|
||||
this.countHearts = 0;
|
||||
@@ -69,12 +67,12 @@ class HeartManager {
|
||||
this.callListener(this.onChangeGameOverListeners);
|
||||
}
|
||||
|
||||
getCount() {
|
||||
HeartManager.prototype.getCount = function() {
|
||||
return this.countHearts;
|
||||
}
|
||||
|
||||
setMaxCount(amount) {
|
||||
let beforeCountHearts = this.countMaxHearts;
|
||||
HeartManager.prototype.setMaxCount = function(amount) {
|
||||
var beforeCountHearts = this.countMaxHearts;
|
||||
this.countMaxHearts = amount;
|
||||
if(this.countMaxHearts > HeartManager.HEART_MAX_COUNT)
|
||||
this.countMaxHearts = HeartManager.HEART_MAX_COUNT;
|
||||
@@ -86,20 +84,19 @@ class HeartManager {
|
||||
this.setCount(this.countMaxHearts);
|
||||
}
|
||||
|
||||
getMaxCount() {
|
||||
HeartManager.prototype.getMaxCount = function() {
|
||||
return this.countMaxHearts;
|
||||
}
|
||||
|
||||
addHearts(amount) {
|
||||
HeartManager.prototype.addHearts = function(amount) {
|
||||
this.setCount(this.countHearts + amount);
|
||||
|
||||
}
|
||||
|
||||
breakHearts(amount) {
|
||||
HeartManager.prototype.breakHearts = function(amount) {
|
||||
this.addHearts(-1 * amount);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
HeartManager.DEFAULT_COUNT = 3;
|
||||
HeartManager.HEART_MAX_COUNT = 5;
|
||||
@@ -1,87 +1,79 @@
|
||||
class HistoryRecord {
|
||||
|
||||
constructor(date, appName, bestRecord) {
|
||||
function HistoryRecord(date, appName, bestRecord) {
|
||||
this.date = date;
|
||||
this.appName = appName;
|
||||
this.bestRecord = bestRecord;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
class HistoryRecordManager {
|
||||
|
||||
constructor() {
|
||||
function HistoryRecordManager() {
|
||||
this.clear();
|
||||
}
|
||||
|
||||
push(HistoryRecord) {
|
||||
HistoryRecordManager.prototype.push = function(HistoryRecord) {
|
||||
this.historyRecords.push(HistoryRecord);
|
||||
|
||||
this.minValueOfRecord = this.minValueOfArray();
|
||||
this.maxValueOfRecord = this.maxValueOfArray();
|
||||
}
|
||||
|
||||
clear() {
|
||||
HistoryRecordManager.prototype.clear = function() {
|
||||
this.historyRecords = [];
|
||||
|
||||
this.minValueOfRecord = 0;
|
||||
this.maxValueOfRecord = 0;
|
||||
}
|
||||
|
||||
get count() {
|
||||
HistoryRecordManager.prototype.getCount = function() {
|
||||
return this.historyRecords.length;
|
||||
}
|
||||
|
||||
getAt(index) {
|
||||
HistoryRecordManager.prototype.getAt = function(index) {
|
||||
return this.historyRecords[index];
|
||||
}
|
||||
|
||||
getDateAt(index) {
|
||||
HistoryRecordManager.prototype.getDateAt = function(index) {
|
||||
return this.historyRecords[index].date;
|
||||
}
|
||||
|
||||
getAppNameAt(index) {
|
||||
HistoryRecordManager.prototype.getAppNameAt = function(index) {
|
||||
return this.historyRecords[index].appName;
|
||||
}
|
||||
|
||||
getBestRecordAt(index) {
|
||||
HistoryRecordManager.prototype.getBestRecordAt = function(index) {
|
||||
return this.historyRecords[index].bestRecord;
|
||||
}
|
||||
|
||||
minValueOfArray() {
|
||||
let numberArray = this.getBestRecordArray(this.historyRecords);
|
||||
HistoryRecordManager.prototype.minValueOfArray = function() {
|
||||
var numberArray = this.getBestRecordArray(this.historyRecords);
|
||||
return Math.min.apply(Math, numberArray);
|
||||
}
|
||||
|
||||
maxValueOfArray() {
|
||||
let numberArray = this.getBestRecordArray(this.historyRecords);
|
||||
HistoryRecordManager.prototype.maxValueOfArray = function() {
|
||||
var numberArray = this.getBestRecordArray(this.historyRecords);
|
||||
return Math.max.apply(Math, numberArray);
|
||||
}
|
||||
|
||||
underValueForGraph() {
|
||||
let minNumberOfDigits = NumberUtil.numberOfDigits(this.minValueOfRecord);
|
||||
let underMinValue =
|
||||
HistoryRecordManager.prototype.underValueForGraph = function() {
|
||||
var minNumberOfDigits = NumberUtil.numberOfDigits(this.minValueOfRecord);
|
||||
var underMinValue =
|
||||
Math.floor( (this.minValueOfRecord / Math.pow(10, minNumberOfDigits - 2) ) )
|
||||
* Math.pow(10, minNumberOfDigits - 2 );
|
||||
return underMinValue;
|
||||
}
|
||||
|
||||
upperValueForGraph() {
|
||||
let maxNumberOfDigits = NumberUtil.numberOfDigits(this.maxValueOfRecord);
|
||||
let underMaxValue =
|
||||
HistoryRecordManager.prototype.upperValueForGraph = function() {
|
||||
var maxNumberOfDigits = NumberUtil.numberOfDigits(this.maxValueOfRecord);
|
||||
var underMaxValue =
|
||||
Math.ceil( (this.maxValueOfRecord / Math.pow(10, maxNumberOfDigits - 2) ) )
|
||||
* Math.pow(10, maxNumberOfDigits - 2);
|
||||
return underMaxValue;
|
||||
}
|
||||
|
||||
getBestRecordArray() {
|
||||
let numberArray = [];
|
||||
for(let data of this.historyRecords) {
|
||||
HistoryRecordManager.prototype.getBestRecordArray = function() {
|
||||
var numberArray = [];
|
||||
for(var data of this.historyRecords) {
|
||||
numberArray.push(data.bestRecord);
|
||||
}
|
||||
return numberArray;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,9 +1,4 @@
|
||||
/////////////////////////////
|
||||
// How to play text
|
||||
|
||||
class HowToPlay {
|
||||
|
||||
constructor() {
|
||||
function HowToPlay(x, y) {
|
||||
this.howToPlayText = game.add.text(
|
||||
game.world.centerX, game.world.centerY - HowToPlay.TEXT_OFFSET_X,
|
||||
"", this.getFontStyle()
|
||||
@@ -14,14 +9,13 @@ class HowToPlay {
|
||||
this.howToPlayText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
}
|
||||
|
||||
printHowToPlay(text) {
|
||||
HowToPlay.prototype.printHowToPlay = function(text) {
|
||||
this.howToPlayText.text = text;
|
||||
}
|
||||
|
||||
getFontStyle() {
|
||||
HowToPlay.prototype.getFontStyle = function() {
|
||||
return { font: "32px Arial", fill: "#fff" };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
HowToPlay.TEXT_OFFSET_X = 200;
|
||||
@@ -1,6 +1,4 @@
|
||||
class InputTypeText {
|
||||
|
||||
constructor(x, y) {
|
||||
function InputTypeText(x, y) {
|
||||
var bmd = game.add.bitmapData(400, 50);
|
||||
var myInput = game.add.sprite(x, y, bmd);
|
||||
|
||||
@@ -21,15 +19,16 @@ class InputTypeText {
|
||||
});
|
||||
myInput.inputEnabled = true;
|
||||
myInput.input.useHandCursor = true;
|
||||
myInput.events.onInputUp.add(this.inputFocus, this);
|
||||
myInput.events.onInputUp.add(
|
||||
(function(sprite) {
|
||||
sprite.canvasInput.focus();
|
||||
}).bind(this),
|
||||
this
|
||||
);
|
||||
|
||||
return myInput;
|
||||
}
|
||||
|
||||
inputFocus(sprite){
|
||||
sprite.canvasInput.focus();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
class NumberUtil {
|
||||
function NumberUtil() {
|
||||
}
|
||||
|
||||
static numberWithCommas(x) {
|
||||
|
||||
NumberUtil.numberWithCommas = function(x) {
|
||||
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
||||
}
|
||||
|
||||
static numberOfDigits(number) {
|
||||
NumberUtil.numberOfDigits = function(number) {
|
||||
if(number === 1000)
|
||||
return 4;
|
||||
|
||||
return Math.floor(Math.log(number) / Math.LN10 + 1); // bug : 1000 -> expected 4 but 3
|
||||
}
|
||||
|
||||
static getRecordText(value) {
|
||||
let number = Math.floor(value);
|
||||
let numberWithCommas = NumberUtil.numberWithCommas(number);
|
||||
NumberUtil.getRecordText = function(value) {
|
||||
var number = Math.floor(value);
|
||||
var numberWithCommas = NumberUtil.numberWithCommas(number);
|
||||
|
||||
if(isTypingGame())
|
||||
return numberWithCommas + " 타";
|
||||
else
|
||||
return numberWithCommas + " 점";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,51 +1,43 @@
|
||||
class RankingRecord {
|
||||
|
||||
constructor(rank, playerID, playerName, bestRecord) {
|
||||
function RankingRecord(rank, playerID, playerName, bestRecord) {
|
||||
this.rank = rank;
|
||||
this.playerID = playerID;
|
||||
this.playerName = playerName;
|
||||
this.bestRecord = bestRecord;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
class RankingRecordManager {
|
||||
|
||||
constructor() {
|
||||
function RankingRecordManager() {
|
||||
this.clear();
|
||||
}
|
||||
|
||||
push(RankingRecord) {
|
||||
RankingRecordManager.prototype.push = function(RankingRecord) {
|
||||
this.rankingRecords.push(RankingRecord);
|
||||
}
|
||||
|
||||
clear() {
|
||||
RankingRecordManager.prototype.clear = function() {
|
||||
this.rankingRecords = [];
|
||||
}
|
||||
|
||||
get count() {
|
||||
RankingRecordManager.prototype.getCount = function() {
|
||||
return this.rankingRecords.length;
|
||||
}
|
||||
|
||||
getAt(index) {
|
||||
RankingRecordManager.prototype.getAt = function(index) {
|
||||
return this.rankingRecords[index];
|
||||
}
|
||||
|
||||
getRankAt(index) {
|
||||
RankingRecordManager.prototype.getRankAt = function(index) {
|
||||
return this.rankingRecords[index].rank;
|
||||
}
|
||||
|
||||
getPlayerIDAt(index) {
|
||||
RankingRecordManager.prototype.getPlayerIDAt = function(index) {
|
||||
return this.rankingRecords[index].playerID;
|
||||
}
|
||||
|
||||
getPlayerNameAt(index) {
|
||||
RankingRecordManager.prototype.getPlayerNameAt = function(index) {
|
||||
return this.rankingRecords[index].playerName;
|
||||
}
|
||||
|
||||
getBestRecordAt(index) {
|
||||
RankingRecordManager.prototype.getBestRecordAt = function(index) {
|
||||
return this.rankingRecords[index].bestRecord;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
class ScoreBoard {
|
||||
|
||||
constructor() {
|
||||
let fontStyle = ScoreBoard.DEFAULT_TEXT_FONT;
|
||||
function ScoreBoard() {
|
||||
var fontStyle = ScoreBoard.DEFAULT_TEXT_FONT;
|
||||
|
||||
fontStyle.align = "right";
|
||||
fontStyle.boundsAlignH = "right";
|
||||
@@ -24,11 +22,10 @@ class ScoreBoard {
|
||||
// this.label.strokeThickness = 3;
|
||||
};
|
||||
|
||||
printScore(score) {
|
||||
ScoreBoard.prototype.printScore = function(score) {
|
||||
this.scoreText.text = score;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ScoreBoard.FONT_HEIGHT_PX = 70;
|
||||
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
class ScoreManager {
|
||||
|
||||
constructor() {
|
||||
function ScoreManager() {
|
||||
this.onChangeScoreListeners = [];
|
||||
this.onChangeHighScoreListeners = [];
|
||||
|
||||
this.resetScore();
|
||||
}
|
||||
|
||||
resetScore() {
|
||||
ScoreManager.prototype.resetScore = function() {
|
||||
// this.score = Number(sessionStorageManager.record);
|
||||
this.score = 0;
|
||||
sessionStorageManager.record = this.score;
|
||||
@@ -18,59 +16,59 @@ class ScoreManager {
|
||||
this.highScore = Number(sessionStorageManager.bestRecord);
|
||||
}
|
||||
|
||||
callListener(functionArray) {
|
||||
ScoreManager.prototype.callListener = function(functionArray) {
|
||||
if(functionArray.length > 0) {
|
||||
for(let i = 0; i < functionArray.length; i++) {
|
||||
for(var i = 0; i < functionArray.length; i++) {
|
||||
functionArray[i](this.score);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addOnChangeScoreListener(onChangeFunction) {
|
||||
ScoreManager.prototype.addOnChangeScoreListener = function(onChangeFunction) {
|
||||
this.onChangeScoreListeners.push(onChangeFunction);
|
||||
}
|
||||
|
||||
removeOnChangeScoreListener(onChangeFunction) {
|
||||
let itemIndex = this.onChangeScoreListeners.indexOf(onChangeFunction);
|
||||
ScoreManager.prototype.removeOnChangeScoreListener = function(onChangeFunction) {
|
||||
var itemIndex = this.onChangeScoreListeners.indexOf(onChangeFunction);
|
||||
if(itemIndex > -1)
|
||||
this.onChangeScoreListeners.splice(itemIndex, 1);
|
||||
}
|
||||
|
||||
addOnChangeHighScoreListener(onChangeHighScoreFunction) {
|
||||
ScoreManager.prototype.addOnChangeHighScoreListener = function(onChangeHighScoreFunction) {
|
||||
this.onChangeHighScoreListeners.push(onChangeHighScoreFunction);
|
||||
}
|
||||
|
||||
removeOnChangeHighScoreListener(onChangeHighScoreFunction) {
|
||||
let itemIndex = this.onChangeHighScoreListeners.indexOf(onChangeHighScoreFunction);
|
||||
ScoreManager.prototype.removeOnChangeHighScoreListener = function(onChangeHighScoreFunction) {
|
||||
var itemIndex = this.onChangeHighScoreListeners.indexOf(onChangeHighScoreFunction);
|
||||
if(itemIndex > -1)
|
||||
this.onChangeHighScoreListeners.splice(itemIndex, 1);
|
||||
}
|
||||
|
||||
removeAllListeners() {
|
||||
ScoreManager.prototype.removeAllListeners = function() {
|
||||
this.onChangeScoreListeners = [];
|
||||
this.onChangeHighScoreListeners = [];
|
||||
}
|
||||
|
||||
|
||||
getScore() {
|
||||
ScoreManager.prototype.getScore = function() {
|
||||
return this.score;
|
||||
}
|
||||
|
||||
getHighScore() {
|
||||
ScoreManager.prototype.getHighScore = function() {
|
||||
return this.highScore;
|
||||
}
|
||||
|
||||
|
||||
plusScore(amount) {
|
||||
ScoreManager.prototype.plusScore = function(amount) {
|
||||
this.setScore(this.score + amount);
|
||||
}
|
||||
|
||||
minusScore(amount) {
|
||||
ScoreManager.prototype.minusScore = function(amount) {
|
||||
this.plusScore(-1 * amount);
|
||||
}
|
||||
|
||||
setScore(value) {
|
||||
let beforeScore = this.score;
|
||||
ScoreManager.prototype.setScore = function(value) {
|
||||
var beforeScore = this.score;
|
||||
this.score = value;
|
||||
|
||||
// update score
|
||||
@@ -81,5 +79,3 @@ class ScoreManager {
|
||||
if(this.score > this.highScore)
|
||||
this.callListener(this.onChangeHighScoreListeners);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
class ScoreText extends Phaser.Text {
|
||||
ScoreText.prototype = Object.create(Phaser.Text.prototype);
|
||||
ScoreText.constructor = ScoreText;
|
||||
|
||||
constructor(x, y, score) {
|
||||
super(game, x, y, "+" + NumberUtil.numberWithCommas(score), ScoreText.DEFAULT_TEXT_FONT);
|
||||
function ScoreText(x, y, score) {
|
||||
// super(game, x, y, "+" + NumberUtil.numberWithCommas(score), ScoreText.DEFAULT_TEXT_FONT);
|
||||
Phaser.Text.call(this, game, x, y, "+" + NumberUtil.numberWithCommas(score), ScoreText.DEFAULT_TEXT_FONT);
|
||||
|
||||
this.anchor.set(0.5);
|
||||
this.inputEnabled = false;
|
||||
@@ -15,21 +17,20 @@ class ScoreText extends Phaser.Text {
|
||||
this.strokeThickness = 5;
|
||||
|
||||
|
||||
let tweenAlpha = game.add.tween(this);
|
||||
var tweenAlpha = game.add.tween(this);
|
||||
tweenAlpha.to( { alpha: 0 }, 1000, Phaser.Easing.Linear.None, true);
|
||||
|
||||
let tweenMoveUp = game.add.tween(this);
|
||||
var tweenMoveUp = game.add.tween(this);
|
||||
tweenMoveUp.to( { y: this.y - ScoreText.MOVE_UP_AMOUNT_PX }, 1000, Phaser.Easing.Linear.None, true);
|
||||
tweenMoveUp.onComplete.addOnce(this.destroySelf, this);
|
||||
|
||||
game.add.existing(this);
|
||||
};
|
||||
|
||||
destroySelf() {
|
||||
ScoreText.prototype.destroySelf = function() {
|
||||
this.destroy();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ScoreText.DEFAULT_TEXT_FONT = {
|
||||
font: "30px Arial",
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
/////////////////////////////
|
||||
// Screen bottom
|
||||
|
||||
class ScreenBottomUI {
|
||||
|
||||
constructor() {
|
||||
function ScreenBottomUI() {
|
||||
this.dbConnectManager = new DBConnectManager();
|
||||
|
||||
this.bottomBarCenterY = game.world.height - ScreenBottomUI.BG_HEIGHT / 2;
|
||||
@@ -14,7 +9,7 @@ class ScreenBottomUI {
|
||||
this.rightText = this.printText(this.rightText, "", "right");
|
||||
}
|
||||
|
||||
drawBG() {
|
||||
ScreenBottomUI.prototype.drawBG = function() {
|
||||
game.add.graphics()
|
||||
.beginFill(0x303030, 1)
|
||||
.drawRect(
|
||||
@@ -23,26 +18,26 @@ class ScreenBottomUI {
|
||||
);
|
||||
}
|
||||
|
||||
printLeftText(text) {
|
||||
ScreenBottomUI.prototype.printLeftText = function(text) {
|
||||
this.leftText.text = text;
|
||||
}
|
||||
|
||||
printCenterText(text) {
|
||||
ScreenBottomUI.prototype.printCenterText = function(text) {
|
||||
this.centerText.text = text;
|
||||
}
|
||||
|
||||
printRightText(text) {
|
||||
ScreenBottomUI.prototype.printRightText = function(text) {
|
||||
this.rightText.text = text;
|
||||
}
|
||||
|
||||
printText(textObject, text, align) {
|
||||
ScreenBottomUI.prototype.printText = function(textObject, text, align) {
|
||||
if(textObject !== null && textObject !== undefined) {
|
||||
textObject.text = "";
|
||||
textObject = null;
|
||||
}
|
||||
|
||||
let posX = 0;
|
||||
let anchorValue = 0;
|
||||
var posX = 0;
|
||||
var anchorValue = 0;
|
||||
switch(align) {
|
||||
case "left":
|
||||
posX = ScreenBottomUI.TEXT_OFFSET;
|
||||
@@ -67,17 +62,16 @@ class ScreenBottomUI {
|
||||
return textObject;
|
||||
}
|
||||
|
||||
printLeftTextWithBestRecord(bestRecord) {
|
||||
let roundUpBestRecord = Math.round(bestRecord);
|
||||
let highScoreWithCommas = NumberUtil.numberWithCommas(roundUpBestRecord);
|
||||
ScreenBottomUI.prototype.printLeftTextWithBestRecord = function(bestRecord) {
|
||||
var roundUpBestRecord = Math.round(bestRecord);
|
||||
var highScoreWithCommas = NumberUtil.numberWithCommas(roundUpBestRecord);
|
||||
this.printLeftText("오늘의 최고 기록 : " + highScoreWithCommas);
|
||||
}
|
||||
|
||||
getFontStyle() {
|
||||
ScreenBottomUI.prototype.getFontStyle = function() {
|
||||
return { font: "32px Arial", fill: "#fff", align: "left", boundsAlignH: "left", boundsAlignV: "bottom" };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ScreenBottomUI.BG_HEIGHT = 50;
|
||||
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
/////////////////////////////
|
||||
// Screen top ui
|
||||
|
||||
class ScreenTopUI {
|
||||
|
||||
constructor() {
|
||||
function ScreenTopUI() {
|
||||
this.drawBG();
|
||||
}
|
||||
|
||||
drawBG() {
|
||||
ScreenTopUI.prototype.drawBG = function() {
|
||||
game.add.graphics()
|
||||
.beginFill(0x303030, 1)
|
||||
.drawRect(
|
||||
@@ -16,15 +11,13 @@ class ScreenTopUI {
|
||||
);
|
||||
}
|
||||
|
||||
makeBackButton(eventHandler) {
|
||||
ScreenTopUI.prototype.makeBackButton = function(eventHandler) {
|
||||
this.backButton = new BackButton(eventHandler);
|
||||
}
|
||||
|
||||
makeFullScreenButton() {
|
||||
ScreenTopUI.prototype.makeFullScreenButton = function() {
|
||||
// this.fullscreenButton = new FullscreenButton();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
ScreenTopUI.BG_HEIGHT = 60;
|
||||
@@ -100,11 +100,11 @@ SessionStorageManager.prototype.getIsNewBestRecord = function() {
|
||||
}
|
||||
|
||||
SessionStorageManager.prototype.resetPlayingAppData = function() {
|
||||
this.removeItem(playingAppID);
|
||||
this.removeItem(playingAppName);
|
||||
this.removeItem(playingAppKoreanName);
|
||||
this.removeItem(record);
|
||||
this.removeItem(bestRecord);
|
||||
this.removeItem("playingAppID");
|
||||
this.removeItem("playingAppName");
|
||||
this.removeItem("playingAppKoreanName");
|
||||
this.removeItem("record");
|
||||
this.removeItem("bestRecord");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
class StringUtil {
|
||||
function StringUtil() {
|
||||
}
|
||||
|
||||
static printMonthDay(date) {
|
||||
StringUtil.printMonthDay = function(date) {
|
||||
let dateTime = new Date(date);
|
||||
return (dateTime.getMonth() + 1) + "월 " + dateTime.getDate() + "일";
|
||||
}
|
||||
|
||||
static getRecordTextWithoutUnit(value) {
|
||||
StringUtil.getRecordTextWithoutUnit = function(value) {
|
||||
let number = Math.floor(value);
|
||||
return NumberUtil.numberWithCommas(number);
|
||||
}
|
||||
|
||||
static getRecordTextWithUnit(value) {
|
||||
StringUtil.getRecordTextWithUnit = function(value) {
|
||||
let number = Math.floor(value);
|
||||
let numberWithCommas = NumberUtil.numberWithCommas(number);
|
||||
|
||||
@@ -20,13 +21,12 @@ class StringUtil {
|
||||
return numberWithCommas + " 점";
|
||||
}
|
||||
|
||||
static getNumberStartWithZero(number, digitCount) {
|
||||
StringUtil.getNumberStartWithZero = function(number, digitCount) {
|
||||
let n = number + '';
|
||||
return n.length >= digitCount ? n : new Array(digitCount - n.length + 1).join('0') + n;
|
||||
}
|
||||
|
||||
|
||||
static toKoreanAlphabets(text) {
|
||||
StringUtil.toKoreanAlphabets = function(text) {
|
||||
const cCho = [ 'ㄱ', 'ㄲ', 'ㄴ', 'ㄷ', 'ㄸ', 'ㄹ', 'ㅁ', 'ㅂ', 'ㅃ', 'ㅅ', 'ㅆ', 'ㅇ', 'ㅈ', 'ㅉ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ' ];
|
||||
const cJung = [ 'ㅏ', 'ㅐ', 'ㅑ', 'ㅒ', 'ㅓ', 'ㅔ', 'ㅕ', 'ㅖ', 'ㅗ', 'ㅘ', 'ㅙ', 'ㅚ', 'ㅛ', 'ㅜ', 'ㅝ', 'ㅞ', 'ㅟ', 'ㅠ', 'ㅡ', 'ㅢ', 'ㅣ' ];
|
||||
const cJong = [ '', 'ㄱ', 'ㄲ', 'ㄳ', 'ㄴ', 'ㄵ', 'ㄶ', 'ㄷ', 'ㄹ', 'ㄺ', 'ㄻ', 'ㄼ', 'ㄽ', 'ㄾ', 'ㄿ', 'ㅀ', 'ㅁ', 'ㅂ', 'ㅄ', 'ㅅ', 'ㅆ', 'ㅇ', 'ㅈ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ' ];
|
||||
@@ -56,8 +56,7 @@ class StringUtil {
|
||||
return chars;
|
||||
};
|
||||
|
||||
|
||||
static getUnicodeAlphabetCount(text) {
|
||||
StringUtil.getUnicodeAlphabetCount = function(text) {
|
||||
let chars = StringUtil.toKoreanAlphabets(text);
|
||||
// console.log('char : ' + chars);
|
||||
|
||||
@@ -86,11 +85,9 @@ class StringUtil {
|
||||
return alphabetCount;
|
||||
};
|
||||
|
||||
static getScoreUnit(playingAppID) {
|
||||
StringUtil.getScoreUnit = function(playingAppID) {
|
||||
if(playingAppID < 100)
|
||||
return " 타";
|
||||
else
|
||||
return " 점";
|
||||
}
|
||||
|
||||
}
|
||||
+34
-37
@@ -1,13 +1,10 @@
|
||||
/////////////////////////////
|
||||
// Login
|
||||
var Login = {
|
||||
|
||||
class Login {
|
||||
|
||||
preload() {
|
||||
preload: function() {
|
||||
game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png');
|
||||
}
|
||||
},
|
||||
|
||||
create() {
|
||||
create: function() {
|
||||
sessionStorageManager.clear();
|
||||
|
||||
this.game.stage.backgroundColor = '#4d4d4d';
|
||||
@@ -24,12 +21,12 @@ class Login {
|
||||
|
||||
|
||||
var textX = this.game.world.centerX - 320;
|
||||
if(sessionStorageManager.maestroID === null)
|
||||
if(sessionStorageManager.getMaestroID() === null)
|
||||
this.makeMaestroNameText(textX, 200);
|
||||
this.makeNameText(textX, 300);
|
||||
this.makeEnterCodeText(textX, 360);
|
||||
|
||||
if(sessionStorageManager.maestroID === null)
|
||||
if(sessionStorageManager.getMaestroID() === null)
|
||||
this.inputTextMaestroName.canvasInput.focus();
|
||||
else
|
||||
this.inputTextName.canvasInput.focus();
|
||||
@@ -37,31 +34,31 @@ class Login {
|
||||
this.makeStartButton(game.world.centerX, game.world.centerY + 100);
|
||||
|
||||
this.makeInfoText();
|
||||
}
|
||||
},
|
||||
|
||||
makeMaestroNameText(x, y) {
|
||||
makeMaestroNameText: function(x, y) {
|
||||
this.makeTextField(x, y, "마에스트로 계정 :");
|
||||
this.inputTextMaestroName = this.makeInputTypeText(x, y, "jisangs");
|
||||
}
|
||||
},
|
||||
|
||||
makeNameText(x, y) {
|
||||
makeNameText: function(x, y) {
|
||||
this.makeTextField(x, y, "이름 :");
|
||||
this.inputTextName = this.makeInputTypeText(x, y, "박지상");
|
||||
}
|
||||
},
|
||||
|
||||
makeEnterCodeText(x, y) {
|
||||
makeEnterCodeText: function(x, y) {
|
||||
this.makeTextField(x, y, "입장번호 :");
|
||||
this.inputTextEnterCode = this.makeInputTypeText(x, y, "760621");
|
||||
}
|
||||
},
|
||||
|
||||
makeTextField(x, y, text) {
|
||||
makeTextField: function(x, y, text) {
|
||||
return game.add.text(x, y, text, this.textStyle)
|
||||
.setTextBounds(0, 0, 200, 0)
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2)
|
||||
.boundsAlignH = 'right';
|
||||
}
|
||||
},
|
||||
|
||||
makeInputTypeText(x, y, text) {
|
||||
makeInputTypeText: function(x, y, text) {
|
||||
var inputText = new InputTypeText(x + 420, y);
|
||||
inputText.anchor.set(0.5);
|
||||
inputText.canvasInput.value('');
|
||||
@@ -75,9 +72,9 @@ class Login {
|
||||
}
|
||||
|
||||
return inputText;
|
||||
}
|
||||
},
|
||||
|
||||
makeStartButton(x, y) {
|
||||
makeStartButton: function(x, y) {
|
||||
var setting = new RoundRectButtonSetting(x, y, 200, 100);
|
||||
setting.fontStyle.fontWeight = "bold";
|
||||
|
||||
@@ -86,26 +83,26 @@ class Login {
|
||||
RoundRectButton.NONE_ICON, "시작",
|
||||
(function() { this.startMenu(); }).bind(this)
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
makeInfoText(x, y) {
|
||||
makeInfoText: function(x, y) {
|
||||
var textStyle = { font: "30px Arial", fill: "#faa" };
|
||||
this.infoText = game.add.text(game.world.centerX, 640, "", textStyle);
|
||||
this.infoText.anchor.set(0.5);
|
||||
this.infoText.stroke = "#333";
|
||||
this.infoText.strokeThickness = 3;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
startMenu() {
|
||||
startMenu: function() {
|
||||
var maestroName = this.inputTextMaestroName.canvasInput._value;
|
||||
sessionStorageManager.playerName = this.inputTextName.canvasInput._value;
|
||||
sessionStorageManager.setPlayerName(this.inputTextName.canvasInput._value);
|
||||
var enterCode = this.inputTextEnterCode.canvasInput._value;
|
||||
|
||||
var dbConnectManager = new DBConnectManager();
|
||||
dbConnectManager.requestCheckPlayerLogin(
|
||||
maestroName,
|
||||
sessionStorageManager.playerName,
|
||||
sessionStorageManager.getPlayerName(),
|
||||
enterCode,
|
||||
(function(jsonData) {
|
||||
this.loginSucceeded(jsonData);
|
||||
@@ -114,23 +111,23 @@ class Login {
|
||||
this.loginFailed(jsonData);
|
||||
}).bind(this)
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
loginSucceeded(jsonData) {
|
||||
sessionStorageManager.maestroID = jsonData['MaestroID'];
|
||||
sessionStorageManager.maestroAccountType = jsonData['MaestroAccountType'];
|
||||
sessionStorageManager.playerID = jsonData['PlayerID'];
|
||||
sessionStorageManager.playerName = jsonData['PlayerName'];
|
||||
sessionStorageManager.playerAccountType = jsonData['PlayerAccountType'];
|
||||
loginSucceeded: function(jsonData) {
|
||||
sessionStorageManager.setMaestroID(jsonData['MaestroID']);
|
||||
sessionStorageManager.setMaestroAccountType(jsonData['MaestroAccountType']);
|
||||
sessionStorageManager.setPlayerID(jsonData['PlayerID']);
|
||||
sessionStorageManager.setPlayerName(jsonData['PlayerName']);
|
||||
sessionStorageManager.setPlayerAccountType(jsonData['PlayerAccountType']);
|
||||
|
||||
sessionStorageManager.playingAppName = "menu";
|
||||
sessionStorageManager.setPlayingAppName("menu");
|
||||
location.href = '../../web/client/menu_app.html';
|
||||
|
||||
// console.log("===== after login =====");
|
||||
// console.log(sessionStorageManager.playerID);
|
||||
}
|
||||
},
|
||||
|
||||
loginFailed(jsonData) {
|
||||
loginFailed: function(jsonData) {
|
||||
sessionStorageManager.clear();
|
||||
|
||||
// show retry message
|
||||
|
||||
@@ -69,7 +69,7 @@ var MenuTypingPractice = {
|
||||
var screenBottomUI = new ScreenBottomUI();
|
||||
// screenBottomUI.printLeftText("게임 진행 정보");
|
||||
screenBottomUI.printCenterText("메뉴 > 타자 연습");
|
||||
screenBottomUI.printRightText(sessionStorageManager.playerName);
|
||||
screenBottomUI.printRightText(sessionStorageManager.getPlayerName());
|
||||
|
||||
|
||||
this.makeActiveTypingPracticeAppButtons();
|
||||
@@ -79,8 +79,8 @@ var MenuTypingPractice = {
|
||||
makeActiveTypingPracticeAppButtons: function() {
|
||||
var dbConnectManager = new DBConnectManager();
|
||||
dbConnectManager.requestTypingPracticeAppList(
|
||||
sessionStorageManager.maestroID,
|
||||
sessionStorageManager.playerID,
|
||||
sessionStorageManager.getMaestroID(),
|
||||
sessionStorageManager.getPlayerID(),
|
||||
(function(replyJSON) {
|
||||
this.downloadListSucceeded(replyJSON);
|
||||
}).bind(this),
|
||||
|
||||
@@ -72,15 +72,15 @@ var MenuTypingTest = {
|
||||
var screenBottomUI = new ScreenBottomUI();
|
||||
// screenBottomUI.printLeftText("게임 진행 정보");
|
||||
screenBottomUI.printCenterText("메뉴 > 타자 시험");
|
||||
screenBottomUI.printRightText(sessionStorageManager.playerName);
|
||||
screenBottomUI.printRightText(sessionStorageManager.getPlayerName());
|
||||
},
|
||||
|
||||
|
||||
makeActiveTypingTestAppButtons: function() {
|
||||
var dbConnectManager = new DBConnectManager();
|
||||
dbConnectManager.requestTypingTestAppList(
|
||||
sessionStorageManager.maestroID,
|
||||
sessionStorageManager.playerID,
|
||||
sessionStorageManager.getMaestroID(),
|
||||
sessionStorageManager.getPlayerID(),
|
||||
// self.downloadListSucceeded,
|
||||
// self.downloadListFailed
|
||||
(function(replyJSON) {
|
||||
|
||||
@@ -6,7 +6,7 @@ class Game {
|
||||
create() {
|
||||
this.game.stage.backgroundColor = "#000000"; // '#4d4d4d';
|
||||
|
||||
sessionStorageManager.isNewBestRecrd = false;
|
||||
sessionStorageManager.setIsNewBestRecord(false);
|
||||
|
||||
// top ui
|
||||
var screenTopUI = new ScreenTopUI();
|
||||
@@ -18,14 +18,14 @@ class Game {
|
||||
|
||||
var scoreBoard = new ScoreBoard();
|
||||
scoreManager.addOnChangeScoreListener( function(score) {
|
||||
sessionStorageManager.record = score;
|
||||
sessionStorageManager.setRecord(score);
|
||||
scoreBoard.printScore(NumberUtil.numberWithCommas(score));
|
||||
});
|
||||
scoreManager.addOnChangeHighScoreListener( function(highScore) {
|
||||
console.log(highScore);
|
||||
sessionStorageManager.bestRecord = highScore;
|
||||
sessionStorageManager.isNewBestRecrd = true;
|
||||
screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.bestRecord);
|
||||
sessionStorageManager.setBestRecord(highScore);
|
||||
sessionStorageManager.setIsNewBestRecrd(true);
|
||||
screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.getBestRecord());
|
||||
});
|
||||
|
||||
var heartGauge = new HeartGauge(heartManager);
|
||||
@@ -72,9 +72,9 @@ class Game {
|
||||
|
||||
// bottom ui
|
||||
var screenBottomUI = new ScreenBottomUI();
|
||||
screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.bestRecord);
|
||||
screenBottomUI.printCenterText(sessionStorageManager.playingAppKoreanName);
|
||||
screenBottomUI.printRightText(sessionStorageManager.playerName);
|
||||
screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.getBestRecord());
|
||||
screenBottomUI.printCenterText(sessionStorageManager.getPlayingAppKoreanName());
|
||||
screenBottomUI.printRightText(sessionStorageManager.getPlayerName());
|
||||
|
||||
|
||||
this.startGame();
|
||||
|
||||
+53
-56
@@ -1,13 +1,10 @@
|
||||
/////////////////////////////
|
||||
// Ranking
|
||||
var Ranking = {
|
||||
|
||||
class Ranking {
|
||||
|
||||
preload() {
|
||||
preload: function() {
|
||||
game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png');
|
||||
}
|
||||
},
|
||||
|
||||
create() {
|
||||
create: function() {
|
||||
self = this;
|
||||
|
||||
this.dbConnectManager = new DBConnectManager();
|
||||
@@ -17,20 +14,20 @@ class Ranking {
|
||||
|
||||
this.game.stage.backgroundColor = '#4d4d4d';
|
||||
|
||||
// let phaser = game.add.image(game.world.centerX, game.world.centerY, 'phaser');
|
||||
// var phaser = game.add.image(game.world.centerX, game.world.centerY, 'phaser');
|
||||
// phaser.anchor.set(0.5);
|
||||
// phaser.alpha = 0.1;
|
||||
|
||||
|
||||
// top ui
|
||||
let screenTopUI = new ScreenTopUI();
|
||||
var screenTopUI = new ScreenTopUI();
|
||||
screenTopUI.makeBackButton( function() {
|
||||
location.href = '../../web/client/start.html';
|
||||
});
|
||||
screenTopUI.makeFullScreenButton();
|
||||
|
||||
|
||||
let resultTextStyle = textStyleBasic;
|
||||
var resultTextStyle = textStyleBasic;
|
||||
resultTextStyle.font = "bold 42px Arial";
|
||||
|
||||
this.textTitle = game.add.text(GAME_SCREEN_SIZE.x / 2, 32, "수업시간 순위", resultTextStyle)
|
||||
@@ -42,38 +39,38 @@ class Ranking {
|
||||
// contents
|
||||
|
||||
// rank
|
||||
let rankAreaPositionX = 160;
|
||||
let rankAreaPositionY = 90;
|
||||
let style = { font: "34px Arial", fill: "#fff", tabs: [ 60, 160, 160 ] };
|
||||
var rankAreaPositionX = 160;
|
||||
var rankAreaPositionY = 90;
|
||||
var style = { font: "34px Arial", fill: "#fff", tabs: [ 60, 160, 160 ] };
|
||||
this.textRanking1to10 = game.add.text(rankAreaPositionX, rankAreaPositionY , '', style)
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
this.textRanking11to20 = game.add.text(rankAreaPositionX + 420, rankAreaPositionY, '', style)
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
|
||||
|
||||
let buttonPositionY = 640;
|
||||
let buttonHour = this.makeTextButton(game.world.centerX - 220, buttonPositionY, "수업시간 순위", this.showRankingHour);
|
||||
var buttonPositionY = 640;
|
||||
var buttonHour = this.makeTextButton(game.world.centerX - 220, buttonPositionY, "수업시간 순위", this.showRankingHour);
|
||||
// buttonHour.inputEnabled = false;
|
||||
let buttonDay = this.makeTextButton(game.world.centerX, buttonPositionY, "오늘의 순위", this.showRankingDay);
|
||||
var buttonDay = this.makeTextButton(game.world.centerX, buttonPositionY, "오늘의 순위", this.showRankingDay);
|
||||
// buttonDay.inputEnabled = false;
|
||||
let buttonMonth = this.makeTextButton(game.world.centerX + 220, buttonPositionY, "이달의 순위", this.showRankingMonth);
|
||||
var buttonMonth = this.makeTextButton(game.world.centerX + 220, buttonPositionY, "이달의 순위", this.showRankingMonth);
|
||||
// buttonMonth.inputEnabled = false;
|
||||
|
||||
|
||||
// bottom ui
|
||||
let screenBottomUI = new ScreenBottomUI();
|
||||
var screenBottomUI = new ScreenBottomUI();
|
||||
// ScreenBottomUI.printLeftText("게임 진행 정보");
|
||||
// let playingAppName = appInfoManager.getAppNameKorean(sessionStorageManager.playingAppName);
|
||||
// var playingAppName = appInfoManager.getAppNameKorean(sessionStorageManager.getPlayingAppName());
|
||||
// ScreenBottomUI.printCenterText(playingAppName);
|
||||
screenBottomUI.printCenterText("랭킹");
|
||||
screenBottomUI.printRightText(sessionStorageManager.playerName);
|
||||
screenBottomUI.printRightText(sessionStorageManager.getPlayerName());
|
||||
|
||||
this.getRecordToRankingServer();
|
||||
game.time.events.loop(Phaser.Timer.SECOND * 10, this.getRecordToRankingServer, this);
|
||||
}
|
||||
},
|
||||
|
||||
makeTextButton(x, y, buttonText, eventListener) {
|
||||
let setting = new RoundRectButtonSetting(x, y, 200, 100);
|
||||
makeTextButton: function(x, y, buttonText, eventListener) {
|
||||
var setting = new RoundRectButtonSetting(x, y, 200, 100);
|
||||
setting.fontStyle.fontWeight = "bold";
|
||||
switch(buttonText) {
|
||||
case "수업시간 순위":
|
||||
@@ -142,15 +139,15 @@ class Ranking {
|
||||
}
|
||||
|
||||
return new RoundRectButton(setting, RoundRectButton.NONE_ICON, buttonText, eventListener);
|
||||
}
|
||||
},
|
||||
|
||||
getRecordToRankingServer() {
|
||||
getRecordToRankingServer: function() {
|
||||
// console.log("getRecordToRankingServer : " + this.mode);
|
||||
let self = this;
|
||||
var self = this;
|
||||
|
||||
this.dbConnectManager.requestAppRanking(
|
||||
sessionStorageManager.maestroID,
|
||||
sessionStorageManager.playingAppID,
|
||||
sessionStorageManager.getMaestroID(),
|
||||
sessionStorageManager.getPlayingAppID(),
|
||||
(function(jsonData) {
|
||||
self.showRanking(jsonData);
|
||||
}),
|
||||
@@ -158,48 +155,48 @@ class Ranking {
|
||||
self.showRanking(null);
|
||||
})
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
showRankingHour() {
|
||||
showRankingHour: function() {
|
||||
self.mode = Ranking.MODE_HOUR;
|
||||
self.textTitle.text = "수업시간 순위";
|
||||
self.textTitle.addColor("#ff6666", 0);
|
||||
self.getRecordToRankingServer();
|
||||
}
|
||||
},
|
||||
|
||||
showRankingDay() {
|
||||
showRankingDay: function() {
|
||||
self.mode = Ranking.MODE_DAY;
|
||||
self.textTitle.text = "오늘의 순위";
|
||||
self.textTitle.addColor("#9999ff", 0);
|
||||
self.getRecordToRankingServer();
|
||||
}
|
||||
},
|
||||
|
||||
showRankingMonth() {
|
||||
showRankingMonth: function() {
|
||||
self.mode = Ranking.MODE_MONTH;
|
||||
self.textTitle.text = "이달의 순위";
|
||||
self.textTitle.addColor("#99ff99", 0);
|
||||
self.getRecordToRankingServer();
|
||||
}
|
||||
},
|
||||
|
||||
showRanking(jsonRankingData) {
|
||||
showRanking: function(jsonRankingData) {
|
||||
// console.log(jsonRankingData);
|
||||
|
||||
if(sessionStorageManager.maestroAccountType == 101) {
|
||||
let recordArray = this.getDummyRankList();
|
||||
if(sessionStorageManager.getMaestroAccountType() == 101) {
|
||||
var recordArray = this.getDummyRankList();
|
||||
this.printRanking(recordArray);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if(jsonRankingData === null) {
|
||||
let rankEmpty = [ ];
|
||||
var rankEmpty = [ ];
|
||||
this.textRanking1to10.parseList(rankEmpty);
|
||||
this.textRanking11to20.parseList(rankEmpty);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let jsonRankingList = null;
|
||||
var jsonRankingList = null;
|
||||
if(this.mode === Ranking.MODE_HOUR)
|
||||
jsonRankingList = jsonRankingData.rankingHour;
|
||||
else if(this.mode === Ranking.MODE_DAY)
|
||||
@@ -208,22 +205,22 @@ class Ranking {
|
||||
jsonRankingList = jsonRankingData.rankingMonth;
|
||||
|
||||
if(jsonRankingList === null) {
|
||||
let rankEmpty = [ ];
|
||||
var rankEmpty = [ ];
|
||||
this.textRanking1to10.parseList(rankEmpty);
|
||||
this.textRanking11to20.parseList(rankEmpty);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let recordArray = this.getRankingArrayFromJSON(jsonRankingList);
|
||||
var recordArray = this.getRankingArrayFromJSON(jsonRankingList);
|
||||
this.printRanking(recordArray);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
printRanking(recordArray) {
|
||||
let recordTop10 = [];
|
||||
let recordTop20 = [];
|
||||
for(let i = 0; i < 10; i++) {
|
||||
printRanking: function(recordArray) {
|
||||
var recordTop10 = [];
|
||||
var recordTop20 = [];
|
||||
for(var i = 0; i < 10; i++) {
|
||||
if(i < recordArray.length)
|
||||
recordTop10.push(recordArray[i]);
|
||||
if(i + 10 < recordArray.length)
|
||||
@@ -231,17 +228,17 @@ class Ranking {
|
||||
}
|
||||
this.textRanking1to10.parseList(recordTop10);
|
||||
this.textRanking11to20.parseList(recordTop20);
|
||||
}
|
||||
},
|
||||
|
||||
getRankingArrayFromJSON(jsonRankingList) {
|
||||
getRankingArrayFromJSON: function(jsonRankingList) {
|
||||
// if(isDebugMode())
|
||||
// return this.getDummyRankList();
|
||||
|
||||
let rankingListCount = jsonRankingList.length;
|
||||
var rankingListCount = jsonRankingList.length;
|
||||
|
||||
let recordArray = [];
|
||||
for(let i = 0; i < rankingListCount; i++) {
|
||||
let bestRecordRow = [];
|
||||
var recordArray = [];
|
||||
for(var i = 0; i < rankingListCount; i++) {
|
||||
var bestRecordRow = [];
|
||||
// bestRecordRow[0] = jsonRankingList[i]['UserID'];
|
||||
bestRecordRow[0] = i + 1;
|
||||
bestRecordRow[1] = jsonRankingList[i]['Name'];
|
||||
@@ -252,10 +249,10 @@ class Ranking {
|
||||
}
|
||||
|
||||
return recordArray;
|
||||
}
|
||||
},
|
||||
|
||||
getDummyRankList() {
|
||||
let dummyRankList = [
|
||||
getDummyRankList: function() {
|
||||
var dummyRankList = [
|
||||
[ '1', 'test1', '400' ],
|
||||
[ '2', 'test2', '300' ],
|
||||
[ '3', 'test3', '200' ],
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
/////////////////////////////
|
||||
// History board
|
||||
|
||||
class HistoryBoard {
|
||||
|
||||
constructor(type) {
|
||||
function HistoryBoard(type) {
|
||||
if(type === RecordBoard.TYPE_SAMPLE) {
|
||||
this.printSample();
|
||||
return;
|
||||
@@ -13,52 +8,52 @@ class HistoryBoard {
|
||||
|
||||
this.dbConnectManager = new DBConnectManager();
|
||||
|
||||
let arrayTabStyle = { font: "20px Arial", fill: "#fff", align: "left", tabs: [ 40, 80, 120 ] };
|
||||
var arrayTabStyle = { font: "20px Arial", fill: "#fff", align: "left", tabs: [ 40, 80, 120 ] };
|
||||
|
||||
let posX = 40;
|
||||
let posY = game.world.height / 2 - 10;
|
||||
var posX = 40;
|
||||
var posY = game.world.height / 2 - 10;
|
||||
this.textMyRanking = game.add.text(posX, posY + 100, '', arrayTabStyle)
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
|
||||
let today = new Date();
|
||||
let date = DateUtil.getYYYYMMDD(today);
|
||||
var today = new Date();
|
||||
var date = DateUtil.getYYYYMMDD(today);
|
||||
this.dbConnectManager.requestPlayerHistory(
|
||||
sessionStorageManager.maestroID,
|
||||
sessionStorageManager.getMaestroID(),
|
||||
date,
|
||||
(function(historyRecordManager) {
|
||||
if(historyRecordManager.count == 0) {
|
||||
if(historyRecordManager.getCount() == 0) {
|
||||
console.log("history board - no data");
|
||||
return;
|
||||
}
|
||||
|
||||
for(let i = 0; i < historyRecordManager.count; i++) {
|
||||
let data = historyRecordManager.getAt(i);
|
||||
for(var i = 0; i < historyRecordManager.getCount(); i++) {
|
||||
var data = historyRecordManager.getAt(i);
|
||||
this.printRecord(i, data.date, data.bestRecord);
|
||||
|
||||
if(date == data.date)
|
||||
this.todayBestRecord = data.bestRecord;
|
||||
}
|
||||
})
|
||||
}).bind(this)
|
||||
);
|
||||
}
|
||||
|
||||
calcDate(daysBefore) {
|
||||
let date = new Date();
|
||||
HistoryBoard.prototype.calcDate = function(daysBefore) {
|
||||
var date = new Date();
|
||||
date.setDate(date.getDate() - daysBefore);
|
||||
return date;
|
||||
}
|
||||
|
||||
|
||||
printRecord(index, date, bestRecord) {
|
||||
if(sessionStorageManager.playingAppName.indexOf("typing") < 0)
|
||||
HistoryBoard.prototype.printRecord = function(index, date, bestRecord) {
|
||||
if(sessionStorageManager.getPlayingAppName().indexOf("typing") < 0)
|
||||
this.printMouseAppHistory(index, date, bestRecord);
|
||||
else
|
||||
this.printTypingAppHistory(index, date, appName, bestRecord);
|
||||
}
|
||||
|
||||
printMouseAppHistory(index, date, bestRecord) {
|
||||
let posX = 60;
|
||||
let posY = game.world.height / 2 + 90 + 30 * index;
|
||||
HistoryBoard.prototype.printMouseAppHistory = function(index, date, bestRecord) {
|
||||
var posX = 60;
|
||||
var posY = game.world.height / 2 + 90 + 30 * index;
|
||||
|
||||
var style = { font: "20px Arial", fill: "#ffc", align: "right", boundsAlignH: "right", boundsAlignV: "top" };
|
||||
|
||||
@@ -73,9 +68,9 @@ class HistoryBoard {
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
}
|
||||
|
||||
printTypingAppHistory(index, date, appName, bestRecord) {
|
||||
let posX = 60;
|
||||
let posY = game.world.height / 2 + 90 + 30 * index;
|
||||
HistoryBoard.prototype.printTypingAppHistory = function(index, date, appName, bestRecord) {
|
||||
var posX = 60;
|
||||
var posY = game.world.height / 2 + 90 + 30 * index;
|
||||
|
||||
var style = { font: "20px Arial", fill: "#ffc", align: "right", boundsAlignH: "right", boundsAlignV: "top" };
|
||||
|
||||
@@ -94,7 +89,7 @@ class HistoryBoard {
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
}
|
||||
|
||||
printSample() {
|
||||
HistoryBoard.prototype.printSample = function() {
|
||||
this.printRecord(0, DateUtil.getYYYYMMDD(this.calcDate(2)), 1270);
|
||||
this.printRecord(1, DateUtil.getYYYYMMDD(this.calcDate(3)), 1150);
|
||||
this.printRecord(2, DateUtil.getYYYYMMDD(this.calcDate(5)), 1080);
|
||||
@@ -104,8 +99,6 @@ class HistoryBoard {
|
||||
this.printRecord(6, DateUtil.getYYYYMMDD(this.calcDate(20)), 760);
|
||||
}
|
||||
|
||||
todayBestRecord() {
|
||||
HistoryBoard.prototype.todayBestRecord = function() {
|
||||
return this.todayBestRecord;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,4 @@
|
||||
/////////////////////////////
|
||||
// Ranking board
|
||||
|
||||
class RankingBoard {
|
||||
|
||||
constructor(type) {
|
||||
function RankingBoard(type) {
|
||||
if(type === RecordBoard.TYPE_SAMPLE) {
|
||||
this.printSample();
|
||||
return;
|
||||
@@ -18,24 +13,24 @@ class RankingBoard {
|
||||
}
|
||||
|
||||
|
||||
requestRanking(type) {
|
||||
let today = new Date();
|
||||
let date = DateUtil.getYYYYMMDD(today);
|
||||
let time = DateUtil.getHHMMSS(today);
|
||||
RankingBoard.prototype.requestRanking = function(type) {
|
||||
var today = new Date();
|
||||
var date = DateUtil.getYYYYMMDD(today);
|
||||
var time = DateUtil.getHHMMSS(today);
|
||||
this.dbConnectManager.requestRanking(
|
||||
type, sessionStorageManager.maestroID, date, time,
|
||||
(type, rankingRecordManager) => {
|
||||
if(rankingRecordManager.count == 0) {
|
||||
type, sessionStorageManager.getMaestroID(), date, time,
|
||||
(function(type, rankingRecordManager) {
|
||||
if(rankingRecordManager.getCount() == 0) {
|
||||
console.log("ranking board - no data");
|
||||
return;
|
||||
}
|
||||
|
||||
let beginIndex = this.getBeginIndex(rankingRecordManager);
|
||||
let endIndex = this.getEndIndex(rankingRecordManager);
|
||||
var beginIndex = this.getBeginIndex(rankingRecordManager);
|
||||
var endIndex = this.getEndIndex(rankingRecordManager);
|
||||
|
||||
for(let i = 0; i < endIndex - beginIndex; i++) {
|
||||
let index = beginIndex + i;
|
||||
let data = rankingRecordManager.getAt(index);
|
||||
for(var i = 0; i < endIndex - beginIndex; i++) {
|
||||
var index = beginIndex + i;
|
||||
var data = rankingRecordManager.getAt(index);
|
||||
this.printRecord(type, i, data);
|
||||
}
|
||||
|
||||
@@ -53,16 +48,16 @@ class RankingBoard {
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}).bind(this)
|
||||
);
|
||||
}
|
||||
|
||||
getMyRank(rankingRecordManager) {
|
||||
let playerID = Number(sessionStorageManager.playerID);
|
||||
RankingBoard.prototype.getMyRank = function(rankingRecordManager) {
|
||||
var playerID = Number(sessionStorageManager.getPlayerID());
|
||||
|
||||
for(let i = 0; i < rankingRecordManager.count; i++) {
|
||||
let data = rankingRecordManager.getAt(i);
|
||||
let playerIDNo = Number(data["playerID"]);
|
||||
for(var i = 0; i < rankingRecordManager.getCount(); i++) {
|
||||
var data = rankingRecordManager.getAt(i);
|
||||
var playerIDNo = Number(data["playerID"]);
|
||||
if(playerIDNo === playerID)
|
||||
return i + 1;
|
||||
}
|
||||
@@ -70,13 +65,13 @@ class RankingBoard {
|
||||
return -1;
|
||||
}
|
||||
|
||||
getBeginIndex(rankingRecordManager) {
|
||||
let rankingRecordCount = rankingRecordManager.count;
|
||||
let myRank = this.getMyRank(rankingRecordManager);
|
||||
let myRankIndex = myRank - 1;
|
||||
RankingBoard.prototype.getBeginIndex = function(rankingRecordManager) {
|
||||
var rankingRecordCount = rankingRecordManager.getCount();
|
||||
var myRank = this.getMyRank(rankingRecordManager);
|
||||
var myRankIndex = myRank - 1;
|
||||
|
||||
let startIndex = 0;
|
||||
let endIndex = rankingRecordCount;
|
||||
var startIndex = 0;
|
||||
var endIndex = rankingRecordCount;
|
||||
if(rankingRecordCount > 7) {
|
||||
if(myRank < rankingRecordCount - 3) { // my rank is better than the worst 3
|
||||
if(myRank < 5) {
|
||||
@@ -95,13 +90,13 @@ class RankingBoard {
|
||||
return startIndex;
|
||||
}
|
||||
|
||||
getEndIndex(rankingRecordManager) {
|
||||
let rankingRecordCount = rankingRecordManager.count;
|
||||
let myRank = this.getMyRank(rankingRecordManager);
|
||||
let myRankIndex = myRank - 1;
|
||||
RankingBoard.prototype.getEndIndex = function(rankingRecordManager) {
|
||||
var rankingRecordCount = rankingRecordManager.getCount();
|
||||
var myRank = this.getMyRank(rankingRecordManager);
|
||||
var myRankIndex = myRank - 1;
|
||||
|
||||
let startIndex = 0;
|
||||
let endIndex = rankingRecordCount;
|
||||
var startIndex = 0;
|
||||
var endIndex = rankingRecordCount;
|
||||
if(rankingRecordCount > 7) {
|
||||
if(myRank < rankingRecordCount - 3) { // my rank is better than the worst 3
|
||||
if(myRank < 5) {
|
||||
@@ -121,33 +116,33 @@ class RankingBoard {
|
||||
}
|
||||
|
||||
|
||||
printRecord(type, index, data) {
|
||||
RankingBoard.prototype.printRecord = function(type, index, data) {
|
||||
var style = { font: "20px Arial", fill: "#fff", align: "right", boundsAlignH: "right", boundsAlignV: "top" };
|
||||
|
||||
// rank
|
||||
style.boundsAlignH = "right";
|
||||
let rankText = game.add.text(this.getPosX(type), this.getPosY(index), data.rank, style);
|
||||
var rankText = game.add.text(this.getPosX(type), this.getPosY(index), data.rank, style);
|
||||
// .setTextBounds(0, 0, 40, 40)
|
||||
rankText.anchor.set(1, 0);
|
||||
rankText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
|
||||
// player name
|
||||
let playerNameText = game.add.text(this.getPosX(type) + 20, this.getPosY(index), data.playerName, style);
|
||||
var playerNameText = game.add.text(this.getPosX(type) + 20, this.getPosY(index), data.playerName, style);
|
||||
// .setTextBounds(0, 0, 60, 60)
|
||||
playerNameText.anchor.set(0, 0);
|
||||
playerNameText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
|
||||
// bestRecord
|
||||
let bestRecord = StringUtil.getRecordTextWithoutUnit(data.bestRecord);
|
||||
var bestRecord = StringUtil.getRecordTextWithoutUnit(data.bestRecord);
|
||||
style.boundsAlignH = "right";
|
||||
let recordText = game.add.text(this.getPosX(type) + 180, this.getPosY(index), bestRecord, style);
|
||||
var recordText = game.add.text(this.getPosX(type) + 180, this.getPosY(index), bestRecord, style);
|
||||
// .setTextBounds(0, 0, 80, 60)
|
||||
recordText.anchor.set(1, 0);
|
||||
recordText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
}
|
||||
|
||||
getPosX(type) {
|
||||
let posX = 0;
|
||||
RankingBoard.prototype.getPosX = function(type) {
|
||||
var posX = 0;
|
||||
|
||||
switch(type) {
|
||||
case DBConnectManager.TYPE_MY_RANKING_HOUR:
|
||||
@@ -168,11 +163,11 @@ class RankingBoard {
|
||||
return posX;
|
||||
}
|
||||
|
||||
getPosY(index) {
|
||||
RankingBoard.prototype.getPosY = function(index) {
|
||||
return game.world.height / 2 + 90 + 30 * index;
|
||||
}
|
||||
|
||||
printSample() {
|
||||
RankingBoard.prototype.printSample = function() {
|
||||
// TYPE_MY_RANKING_HOUR
|
||||
this.printRecord(
|
||||
DBConnectManager.TYPE_MY_RANKING_HOUR, 0,
|
||||
@@ -226,14 +221,14 @@ class RankingBoard {
|
||||
}
|
||||
|
||||
|
||||
static loadResources() {
|
||||
RankingBoard.loadResources = function() {
|
||||
game.load.image('medal_gold', '../../../resources/image/ui/medal_gold.png');
|
||||
game.load.image('medal_silver', '../../../resources/image/ui/medal_silver.png');
|
||||
game.load.image('medal_bronze', '../../../resources/image/ui/medal_bronze.png');
|
||||
}
|
||||
|
||||
makeMedalSprites() {
|
||||
let rankAreaPositionY = 630;
|
||||
RankingBoard.prototype.makeMedalSprites = function() {
|
||||
var rankAreaPositionY = 630;
|
||||
this.medalHour = game.add.image(425, rankAreaPositionY, 'medal_gold');
|
||||
this.medalHour.anchor.set(0.5);
|
||||
this.medalHour.alpha = 0;
|
||||
@@ -247,7 +242,7 @@ class RankingBoard {
|
||||
this.medalMonth.alpha = 0;
|
||||
}
|
||||
|
||||
showMedal(medal, myRank) {
|
||||
RankingBoard.prototype.showMedal = function(medal, myRank) {
|
||||
if(myRank > 3) {
|
||||
medal.alpha = 0;
|
||||
return;
|
||||
@@ -264,5 +259,3 @@ class RankingBoard {
|
||||
medal.scale.setTo(0.5);
|
||||
game.add.tween(medal.scale).to( {x: 0.7, y: 0.7}, 1000, Phaser.Easing.Bounce.Out, true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,22 +1,17 @@
|
||||
/////////////////////////////
|
||||
// Record board
|
||||
|
||||
class RecordBoard {
|
||||
|
||||
constructor(type) {
|
||||
function RecordBoard(type) {
|
||||
this.chartGraphics = game.add.graphics(0, 0);
|
||||
|
||||
this.printRecordBoardHeader();
|
||||
this.printSeperator();
|
||||
|
||||
let historyBoard = new HistoryBoard(type);
|
||||
let rankingBoard = new RankingBoard(type);
|
||||
var historyBoard = new HistoryBoard(type);
|
||||
var rankingBoard = new RankingBoard(type);
|
||||
}
|
||||
|
||||
|
||||
printRecordBoardHeader() {
|
||||
let posX = 60;
|
||||
let posY = game.world.height / 2 + 20;
|
||||
RecordBoard.prototype.printRecordBoardHeader = function() {
|
||||
var posX = 60;
|
||||
var posY = game.world.height / 2 + 20;
|
||||
|
||||
var bar = game.add.graphics();
|
||||
bar.beginFill(0x444444);
|
||||
@@ -36,13 +31,13 @@ class RecordBoard {
|
||||
this.printHeader(posX, posY, "이달의 순위", style);
|
||||
}
|
||||
|
||||
printHeader(x, y, title, style) {
|
||||
RecordBoard.prototype.printHeader = function(x, y, title, style) {
|
||||
game.add.text(x, y, title, style)
|
||||
.setTextBounds(0, 0, 200, RecordBoard.HEADER_BAR_HEIGHT_PX)
|
||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
}
|
||||
|
||||
printSeperator() {
|
||||
RecordBoard.prototype.printSeperator = function() {
|
||||
const posX = 290;
|
||||
const posY = 480;
|
||||
|
||||
@@ -51,7 +46,6 @@ class RecordBoard {
|
||||
this.chartGraphics.lineTo(posX, posY + 200);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
RecordBoard.HEADER_BAR_HEIGHT_PX = 60;
|
||||
|
||||
|
||||
+61
-64
@@ -1,25 +1,22 @@
|
||||
/////////////////////////////
|
||||
// Result
|
||||
var Result = {
|
||||
|
||||
class Result {
|
||||
|
||||
preload() {
|
||||
preload: function() {
|
||||
game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png');
|
||||
|
||||
Animal.loadResources();
|
||||
|
||||
RankingBoard.loadResources();
|
||||
game.load.image('star', '../../../resources/image/ui/star_particle.png');
|
||||
}
|
||||
},
|
||||
|
||||
create() {
|
||||
create: function() {
|
||||
this.dbConnectManager = new DBConnectManager();
|
||||
|
||||
this.game.stage.backgroundColor = '#4d4d4d';
|
||||
this.chartGraphics = game.add.graphics(100, game.world.height - 120);
|
||||
|
||||
// top ui
|
||||
let screenTopUI = new ScreenTopUI();
|
||||
var screenTopUI = new ScreenTopUI();
|
||||
screenTopUI.makeBackButton( function() {
|
||||
if(isTypingPracticeStage())
|
||||
location.href = '../../web/client/menu_typing_practice.html';
|
||||
@@ -39,126 +36,126 @@ class Result {
|
||||
|
||||
this.makeRestartButton();
|
||||
|
||||
if(sessionStorageManager.maestroAccountType >= 100) { // experience account
|
||||
let recordBoard = new RecordBoard(RecordBoard.TYPE_SAMPLE);
|
||||
if(sessionStorageManager.getMaestroAccountType() >= 100) { // experience account
|
||||
var recordBoard = new RecordBoard(RecordBoard.TYPE_SAMPLE);
|
||||
this.announceBox = new AnnounceBox(50, 648);
|
||||
this.announceBox.drawBox("체험 계정에서는 기록이 저장되지 않습니다.");
|
||||
} else {
|
||||
let recordBoard = new RecordBoard(RecordBoard.TYPE_DB);
|
||||
var recordBoard = new RecordBoard(RecordBoard.TYPE_DB);
|
||||
this.printTodayBestRecord();
|
||||
}
|
||||
|
||||
|
||||
// bottom ui
|
||||
let screenBottomUI = new ScreenBottomUI();
|
||||
screenBottomUI.printLeftTextWithBestRecord(Math.floor(sessionStorageManager.bestRecord));
|
||||
screenBottomUI.printCenterText(sessionStorageManager.playingAppKoreanName);
|
||||
screenBottomUI.printRightText(sessionStorageManager.playerName);
|
||||
}
|
||||
var screenBottomUI = new ScreenBottomUI();
|
||||
screenBottomUI.printLeftTextWithBestRecord(Math.floor(sessionStorageManager.getBestRecord()));
|
||||
screenBottomUI.printCenterText(sessionStorageManager.getPlayingAppKoreanName());
|
||||
screenBottomUI.printRightText(sessionStorageManager.getPlayerName());
|
||||
},
|
||||
|
||||
printRecord() {
|
||||
printRecord: function() {
|
||||
const style = { font: "bold 38px Arial", fill: "#fff", align: "left", boundsAlignH: "center", boundsAlignV: "middle" };
|
||||
let titleText = game.add.text(game.world.width / 2, 35, "결과", style);
|
||||
var titleText = game.add.text(game.world.width / 2, 35, "결과", style);
|
||||
titleText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
titleText.anchor.set(0.5);
|
||||
|
||||
|
||||
let x = game.world.width / 2;
|
||||
let y = 150;
|
||||
if(sessionStorageManager.record === null)
|
||||
sessionStorageManager.record = 0;
|
||||
let record = NumberUtil.numberWithCommas(Math.floor(sessionStorageManager.record));
|
||||
var x = game.world.width / 2;
|
||||
var y = 150;
|
||||
if(sessionStorageManager.getRecord() === null)
|
||||
sessionStorageManager.setRecord(0);
|
||||
var record = NumberUtil.numberWithCommas(Math.floor(sessionStorageManager.getRecord()));
|
||||
style.font = "80px Arial";
|
||||
|
||||
if(sessionStorageManager.playingAppID < 100) {
|
||||
let leftAnimal = new Animal(Animal.TYPE_ANIMATION, game.world.centerX - 200, 150);
|
||||
let animalLevelID = 0;
|
||||
if(sessionStorageManager.playingAppID < 20)
|
||||
animalLevelID = Animal.animalLevelIDByRecord(sessionStorageManager.record, Animal.TYPE_PRACTICE);
|
||||
if(sessionStorageManager.getPlayingAppID() < 100) {
|
||||
var leftAnimal = new Animal(Animal.TYPE_ANIMATION, game.world.centerX - 200, 150);
|
||||
var animalLevelID = 0;
|
||||
if(sessionStorageManager.getPlayingAppID() < 20)
|
||||
animalLevelID = Animal.animalLevelIDByRecord(sessionStorageManager.getRecord(), Animal.TYPE_PRACTICE);
|
||||
else
|
||||
animalLevelID = Animal.animalLevelIDByRecord(sessionStorageManager.record, Animal.TYPE_TEST);
|
||||
animalLevelID = Animal.animalLevelIDByRecord(sessionStorageManager.getRecord(), Animal.TYPE_TEST);
|
||||
leftAnimal.setSpecies(Animal.SPECIES_DATA[animalLevelID]);;
|
||||
// leftAnimal.tweenAnimation(Animal.ANIMATION_TYPE_CHANGE);
|
||||
leftAnimal.startAnimation();
|
||||
|
||||
let rightAnimal = new Animal(Animal.TYPE_ANIMATION, game.world.centerX + 200, 150);
|
||||
var rightAnimal = new Animal(Animal.TYPE_ANIMATION, game.world.centerX + 200, 150);
|
||||
rightAnimal.setSpecies(Animal.SPECIES_DATA[animalLevelID]);;
|
||||
// rightAnimal.tweenAnimation(Animal.ANIMATION_TYPE_CHANGE);
|
||||
rightAnimal.startAnimation();
|
||||
}
|
||||
|
||||
let scoreText = game.add.text(
|
||||
var scoreText = game.add.text(
|
||||
x, y,
|
||||
record + StringUtil.getScoreUnit(sessionStorageManager.playingAppID),
|
||||
record + StringUtil.getScoreUnit(sessionStorageManager.getPlayingAppID()),
|
||||
style
|
||||
);
|
||||
scoreText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
scoreText.anchor.set(0.5);
|
||||
}
|
||||
},
|
||||
|
||||
recordUnit() {
|
||||
let recordUnit = "";
|
||||
if(sessionStorageManager.playingAppID >= 100)
|
||||
recordUnit: function() {
|
||||
var recordUnit = "";
|
||||
if(sessionStorageManager.getPlayingAppID() >= 100)
|
||||
return "점";
|
||||
else
|
||||
return "타";
|
||||
}
|
||||
},
|
||||
|
||||
printTodayBestRecord() {
|
||||
let newRecordEmitter = game.add.emitter(game.world.centerX, 140, 300);
|
||||
printTodayBestRecord: function() {
|
||||
var newRecordEmitter = game.add.emitter(game.world.centerX, 140, 300);
|
||||
newRecordEmitter.makeParticles('star');
|
||||
newRecordEmitter.gravity = 300;
|
||||
|
||||
let style = { font: "32px Arial", fill: "#ff0", align: "left", boundsAlignH: "center", boundsAlignV: "middle" };
|
||||
let bestRecordText = game.add.text(game.world.centerX, 220, "", style);
|
||||
var style = { font: "32px Arial", fill: "#ff0", align: "left", boundsAlignH: "center", boundsAlignV: "middle" };
|
||||
var bestRecordText = game.add.text(game.world.centerX, 220, "", style);
|
||||
bestRecordText.anchor.set(0.5);
|
||||
bestRecordText.stroke = "#333";
|
||||
bestRecordText.strokeThickness = 5;
|
||||
|
||||
if(sessionStorageManager.bestRecord === null)
|
||||
sessionStorageManager.bestRecord = 0;
|
||||
if(sessionStorageManager.getBestRecord() === 'undefined')
|
||||
sessionStorageManager.setBestRecord(0);
|
||||
|
||||
let todayBestRecord = 0;
|
||||
let flooredBestRecord = Math.floor(sessionStorageManager.bestRecord);
|
||||
let bestRecordWithCommas = NumberUtil.numberWithCommas(flooredBestRecord);
|
||||
var todayBestRecord = 0;
|
||||
var flooredBestRecord = Math.floor(sessionStorageManager.getBestRecord());
|
||||
var bestRecordWithCommas = NumberUtil.numberWithCommas(flooredBestRecord);
|
||||
|
||||
if(sessionStorageManager.record >= sessionStorageManager.bestRecord) {
|
||||
sessionStorageManager.bestRecord = sessionStorageManager.record;
|
||||
if(sessionStorageManager.getRecord() >= sessionStorageManager.getBestRecord()) {
|
||||
sessionStorageManager.setBestRecord(sessionStorageManager.getRecord());
|
||||
|
||||
bestRecordText.text = "! : . 오늘 최고 기록 . : !";
|
||||
newRecordEmitter.start(true, 2000, null, 20);
|
||||
} else {
|
||||
bestRecordText.text = "";
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
uploadRecord() {
|
||||
if(sessionStorageManager.maestroAccountType >= 100) { // experience account
|
||||
uploadRecord: function() {
|
||||
if(sessionStorageManager.getMaestroAccountType() >= 100) { // experience account
|
||||
return;
|
||||
}
|
||||
|
||||
this.dbConnectManager.updateTodayBestRecord(
|
||||
sessionStorageManager.maestroID,
|
||||
sessionStorageManager.playerID,
|
||||
sessionStorageManager.playingAppID,
|
||||
sessionStorageManager.record
|
||||
sessionStorageManager.getMaestroID(),
|
||||
sessionStorageManager.getPlayerID(),
|
||||
sessionStorageManager.getPlayingAppID(),
|
||||
sessionStorageManager.getRecord()
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
makeRestartButton() {
|
||||
let setting = new RoundRectButtonSetting(game.world.centerX, game.world.height / 2 - 70, 200, 100);
|
||||
makeRestartButton: function() {
|
||||
var setting = new RoundRectButtonSetting(game.world.centerX, game.world.height / 2 - 70, 200, 100);
|
||||
setting.fontStyle.fontWeight = "bold";
|
||||
|
||||
let startButton = new RoundRectButton(setting, RoundRectButton.NONE_ICON, "다시 시작", this.restartStage);
|
||||
}
|
||||
var startButton = new RoundRectButton(setting, RoundRectButton.NONE_ICON, "다시 시작", this.restartStage);
|
||||
},
|
||||
|
||||
restartStage() {
|
||||
if(sessionStorageManager.playingAppName.indexOf("practice_") == 0) {
|
||||
restartStage: function() {
|
||||
if(sessionStorageManager.getPlayingAppName().indexOf("practice_") == 0) {
|
||||
location.href = "../../web/client/typing_practice.html";
|
||||
} else if(sessionStorageManager.playingAppName.indexOf("test_") == 0) {
|
||||
} else if(sessionStorageManager.getPlayingAppName().indexOf("test_") == 0) {
|
||||
location.href = "../../web/client/typing_test.html";
|
||||
} else {
|
||||
location.href = "../../web/client/" + sessionStorageManager.playingAppName + ".html";
|
||||
location.href = "../../web/client/" + sessionStorageManager.getPlayingAppName() + ".html";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ class Start {
|
||||
this.makeStartButton();
|
||||
this.makeRankingButton();
|
||||
|
||||
console.log(sessionStorageManager.getMaestroAccountType());
|
||||
if(sessionStorageManager.getMaestroAccountType() >= 100) { // experience account
|
||||
this.printSampleChart();
|
||||
this.announceBox = new AnnounceBox(50, 648);
|
||||
@@ -55,11 +56,11 @@ class Start {
|
||||
sessionStorageManager.getPlayerID(),
|
||||
sessionStorageManager.getPlayingAppID(),
|
||||
(function(replyJSON) {
|
||||
sessionStorageManager.getBestRecord() = Number(replyJSON["BestRecord"]);
|
||||
sessionStorageManager.setBestRecord(Number(replyJSON["BestRecord"]));
|
||||
screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.getBestRecord());
|
||||
}).bind(this),
|
||||
(function(replyJSON) { // no data
|
||||
sessionStorageManager.getBestRecord() = 0;
|
||||
sessionStorageManager.setBestRecord(0);
|
||||
screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.getBestRecord());
|
||||
}).bind(this)
|
||||
);
|
||||
@@ -112,7 +113,7 @@ class Start {
|
||||
}
|
||||
|
||||
this.chart.printChartBaseLine();
|
||||
})
|
||||
}).bind(this)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +1,16 @@
|
||||
/////////////////////////////
|
||||
// TypingPractice
|
||||
|
||||
class TypingPractice {
|
||||
|
||||
create() {
|
||||
self = this;
|
||||
var TypingPractice = {
|
||||
create: function() {
|
||||
var self = this;
|
||||
|
||||
this.isOnStage = false;
|
||||
|
||||
this.initTypingData();
|
||||
sessionStorageManager.isNewBestRecrd = false;
|
||||
sessionStorageManager.setIsNewBestRecord(false);
|
||||
|
||||
game.stage.backgroundColor = '#4d4d4d';
|
||||
|
||||
// top ui
|
||||
let screenTopUI = new ScreenTopUI();
|
||||
var screenTopUI = new ScreenTopUI();
|
||||
screenTopUI.makeBackButton( function() {
|
||||
sessionStorageManager.resetPlayingAppData();
|
||||
location.href = '../../web/client/menu_typing_practice.html';
|
||||
@@ -38,10 +34,10 @@ class TypingPractice {
|
||||
|
||||
|
||||
// typing content
|
||||
let typingContentBG = new TypingContentBG();
|
||||
var typingContentBG = new TypingContentBG();
|
||||
typingContentBG.makePracticeContentBG();
|
||||
|
||||
let TYPING_CONTENT_Y = 200;
|
||||
var TYPING_CONTENT_Y = 200;
|
||||
|
||||
textStyleBasic.font = "bold 84px Times New Roman";
|
||||
this.textTypingContent = game.add.text(game.world.centerX, TYPING_CONTENT_Y, "", textStyleBasic)
|
||||
@@ -56,11 +52,11 @@ class TypingPractice {
|
||||
|
||||
|
||||
// textStyleBasic.font = "32px Arial";
|
||||
let OFFSET_WORD_X = 70;
|
||||
var OFFSET_WORD_X = 70;
|
||||
|
||||
let textDoneColor = [ '#99994d', '#77774d', '#66664d' ];
|
||||
var textDoneColor = [ '#99994d', '#77774d', '#66664d' ];
|
||||
this.textTypingContentsDone = [];
|
||||
for(let i = 0; i < TypingPractice.TYPING_CONTENT_DONE_COUNT; i++) {
|
||||
for(var i = 0; i < TypingPractice.TYPING_CONTENT_DONE_COUNT; i++) {
|
||||
this.textTypingContentsDone[i] = game.add.text(
|
||||
game.world.centerX - 200 - i * OFFSET_WORD_X, TYPING_CONTENT_Y,
|
||||
"", textStyleBasic
|
||||
@@ -69,9 +65,9 @@ class TypingPractice {
|
||||
this.textTypingContentsDone[i].anchor.set(0.5);
|
||||
}
|
||||
|
||||
let textPreviewColor = [ '#666666', '#888888', '#777777' ];
|
||||
var textPreviewColor = [ '#666666', '#888888', '#777777' ];
|
||||
this.textTypingContentPreview = [];
|
||||
for(let i = 0; i < TypingPractice.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
||||
for(var i = 0; i < TypingPractice.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
||||
this.textTypingContentPreview[i] = game.add.text(
|
||||
game.world.centerX + 200 + i * OFFSET_WORD_X,
|
||||
TYPING_CONTENT_Y, "", textStyleBasic
|
||||
@@ -83,7 +79,7 @@ class TypingPractice {
|
||||
// keyboard
|
||||
this.keyMapper = new KeyMapper();
|
||||
this.keyboard = null;
|
||||
if(sessionStorageManager.playingAppName.indexOf("korean") > 0)
|
||||
if(sessionStorageManager.getPlayingAppName().indexOf("korean") > 0)
|
||||
this.keyboard = new Keyboard(this.keyMapper, Keyboard.KOREAN);
|
||||
else
|
||||
this.keyboard = new Keyboard(this.keyMapper, Keyboard.ENGLISH);
|
||||
@@ -103,29 +99,29 @@ class TypingPractice {
|
||||
|
||||
|
||||
// bottom ui
|
||||
let screenBottomUI = new ScreenBottomUI();
|
||||
var screenBottomUI = new ScreenBottomUI();
|
||||
// screenBottomUI.printBottomUILeftText("");
|
||||
screenBottomUI.printCenterText(sessionStorageManager.playingAppKoreanName);
|
||||
screenBottomUI.printRightText(sessionStorageManager.playerName);
|
||||
screenBottomUI.printCenterText(sessionStorageManager.getPlayingAppKoreanName());
|
||||
screenBottomUI.printRightText(sessionStorageManager.getPlayerName());
|
||||
|
||||
|
||||
this.startGame();
|
||||
// this.countDown();
|
||||
}
|
||||
},
|
||||
|
||||
startGame() {
|
||||
startGame: function() {
|
||||
this.isOnStage = true;
|
||||
this.stageTimer.start();
|
||||
|
||||
this.showTypingPracticeContents();
|
||||
this.showHighlightKey();
|
||||
this.moveHands();
|
||||
}
|
||||
},
|
||||
|
||||
gameOver() {
|
||||
gameOver: function() {
|
||||
this.isOnStage = false;
|
||||
|
||||
for(let i = 0; i < TypingPractice.TYPING_CONTENT_DONE_COUNT; i++) {
|
||||
for(var i = 0; i < TypingPractice.TYPING_CONTENT_DONE_COUNT; i++) {
|
||||
this.textTypingContentsDone[i].text = "";
|
||||
}
|
||||
|
||||
@@ -135,7 +131,7 @@ class TypingPractice {
|
||||
this.textTypingContent.addColor(TypingPractice.COLOR_CONTENT_RIGHT, 0);
|
||||
this.textTypingContent.text = "= 연습 끝 =";
|
||||
|
||||
for(let i = 0; i < TypingPractice.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
||||
for(var i = 0; i < TypingPractice.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
||||
this.textTypingContentPreview[i].text = "";
|
||||
}
|
||||
|
||||
@@ -144,22 +140,22 @@ class TypingPractice {
|
||||
|
||||
this.animalOnTitle.stopAnimation();
|
||||
|
||||
let gameOverText = new GameOverText();
|
||||
var gameOverText = new GameOverText();
|
||||
game.time.events.add(Phaser.Timer.SECOND * 2, this.goResult, this);
|
||||
}
|
||||
},
|
||||
|
||||
goResult() {
|
||||
sessionStorageManager.record = this.typingScore.score();
|
||||
if(sessionStorageManager.record > sessionStorageManager.bestRecord)
|
||||
sessionStorageManager.bestRecord = sessionStorageManager.record;
|
||||
goResult: function() {
|
||||
sessionStorageManager.setRecord(this.typingScore.score());
|
||||
if(sessionStorageManager.getRecord() > sessionStorageManager.getBestRecord())
|
||||
sessionStorageManager.setBestRecord(sessionStorageManager.getRecord());
|
||||
|
||||
location.href = '../../web/client/result.html';
|
||||
}
|
||||
},
|
||||
|
||||
initTypingData() {
|
||||
let typingTextMan = new TypingTextManager();
|
||||
initTypingData: function() {
|
||||
var typingTextMan = new TypingTextManager();
|
||||
|
||||
let typingPracticeContents = this.loadPracticeContent();
|
||||
var typingPracticeContents = this.loadPracticeContent();
|
||||
// console.log(typingPracticeContents);
|
||||
typingTextMan.makePracticeContents(typingPracticeContents, 30);
|
||||
this.typingRandomContents = typingTextMan.getContents();
|
||||
@@ -168,17 +164,17 @@ class TypingPractice {
|
||||
this.typingIndex = 0;
|
||||
|
||||
this.playingAnimalIndex = 0;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
loadPracticeContent() {
|
||||
let appName = "";
|
||||
loadPracticeContent: function() {
|
||||
var appName = "";
|
||||
if(isTypingTestStage())
|
||||
appName = sessionStorageManager.playingAppName.substring(5);
|
||||
appName = sessionStorageManager.getPlayingAppName().substring(5);
|
||||
else if(isTypingPracticeStage())
|
||||
appName = sessionStorageManager.playingAppName.substring(9);
|
||||
appName = sessionStorageManager.getPlayingAppName().substring(9);
|
||||
|
||||
let testContent = [];
|
||||
var testContent = [];
|
||||
|
||||
switch(appName) {
|
||||
case "korean_basic":
|
||||
@@ -260,11 +256,11 @@ class TypingPractice {
|
||||
}
|
||||
|
||||
return testContent;
|
||||
}
|
||||
},
|
||||
|
||||
showTypingPracticeContents() {
|
||||
for(let i = 0; i < TypingPractice.TYPING_CONTENT_DONE_COUNT; i++) {
|
||||
let doneIndex = this.typingIndex - i - 1;
|
||||
showTypingPracticeContents: function() {
|
||||
for(var i = 0; i < TypingPractice.TYPING_CONTENT_DONE_COUNT; i++) {
|
||||
var doneIndex = this.typingIndex - i - 1;
|
||||
if(doneIndex < 0) {
|
||||
this.textTypingContentsDone[i].text = "";
|
||||
} else {
|
||||
@@ -279,43 +275,43 @@ class TypingPractice {
|
||||
|
||||
this.textTypingContent.text = this.typingRandomContents[this.typingIndex];
|
||||
|
||||
for(let i = 0; i < TypingPractice.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
||||
let previewIndex = this.typingIndex + i + 1;
|
||||
for(var i = 0; i < TypingPractice.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
||||
var previewIndex = this.typingIndex + i + 1;
|
||||
if(previewIndex < this.typingRandomContents.length)
|
||||
this.textTypingContentPreview[i].text = this.typingRandomContents[previewIndex];
|
||||
else
|
||||
this.textTypingContentPreview[i].text = "";
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
hideHighlightKey() {
|
||||
let prevText = this.typingRandomContents[this.typingIndex];
|
||||
hideHighlightKey: function() {
|
||||
var prevText = this.typingRandomContents[this.typingIndex];
|
||||
if(prevText === undefined)
|
||||
return;
|
||||
|
||||
this.keyboard.hideHighlight(prevText);
|
||||
}
|
||||
},
|
||||
|
||||
showHighlightKey() {
|
||||
let typingText = this.typingRandomContents[this.typingIndex];
|
||||
showHighlightKey: function() {
|
||||
var typingText = this.typingRandomContents[this.typingIndex];
|
||||
if(typingText === undefined)
|
||||
return;
|
||||
|
||||
this.keyboard.showHighlight(typingText, this.leftHand, this.rightHand);
|
||||
}
|
||||
},
|
||||
|
||||
moveHands() {
|
||||
let typingText = this.typingRandomContents[this.typingIndex];
|
||||
moveHands: function() {
|
||||
var typingText = this.typingRandomContents[this.typingIndex];
|
||||
if(typingText === undefined)
|
||||
return;
|
||||
|
||||
let key = this.keyboard.getKeyOfText(typingText);
|
||||
let handSide = key.handSide;
|
||||
var key = this.keyboard.getKeyOfText(typingText);
|
||||
var handSide = key.handSide;
|
||||
if(handSide === KeyButton.LEFT_HAND) {
|
||||
this.leftHand.moveTo(key);
|
||||
|
||||
if(this.keyMapper.isShiftText(typingText)) {
|
||||
let shiftRightKey = this.keyboard.getKey("ShiftRight");
|
||||
var shiftRightKey = this.keyboard.getKey("ShiftRight");
|
||||
shiftRightKey.showHighlight();
|
||||
this.rightHand.moveTo(shiftRightKey);
|
||||
} else {
|
||||
@@ -325,42 +321,42 @@ class TypingPractice {
|
||||
this.rightHand.moveTo(key);
|
||||
|
||||
if(this.keyMapper.isShiftText(typingText)) {
|
||||
let shiftLeftKey = this.keyboard.getKey("ShiftLeft");
|
||||
var shiftLeftKey = this.keyboard.getKey("ShiftLeft");
|
||||
shiftLeftKey.showHighlight();
|
||||
this.leftHand.moveTo(shiftLeftKey);
|
||||
} else {
|
||||
this.leftHand.moveToDefaultPosition();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getKeyCode(text) {
|
||||
getKeyCode: function(text) {
|
||||
return this.keyMapper.getKeyIDOfText(text);
|
||||
}
|
||||
},
|
||||
|
||||
isKeyPressed(inputContent, typingContent) {
|
||||
let inputContentKeyCode = this.getKeyCode(inputContent);
|
||||
let typingContentKeyCode = this.getKeyCode(typingContent);
|
||||
isKeyPressed: function(inputContent, typingContent) {
|
||||
var inputContentKeyCode = this.getKeyCode(inputContent);
|
||||
var typingContentKeyCode = this.getKeyCode(typingContent);
|
||||
|
||||
if(inputContentKeyCode !== typingContentKeyCode)
|
||||
return false;
|
||||
|
||||
let isShiftInputContent = this.shiftKey.isDown;
|
||||
let isShiftTypingContent = this.keyMapper.isShiftText(typingContent);
|
||||
var isShiftInputContent = this.shiftKey.isDown;
|
||||
var isShiftTypingContent = this.keyMapper.isShiftText(typingContent);
|
||||
|
||||
if(isShiftInputContent !== isShiftTypingContent)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
checkTypingContents(evnet) {
|
||||
let inputContent = event.key;
|
||||
let typingContent = this.typingRandomContents[this.typingIndex];
|
||||
checkTypingContents: function(evnet) {
|
||||
var inputContent = event.key;
|
||||
var typingContent = this.typingRandomContents[this.typingIndex];
|
||||
|
||||
if(this.isKeyPressed(inputContent, typingContent)) {
|
||||
this.typingScore.increase();
|
||||
let animalLevelID = Animal.animalLevelIDByRecord(this.typingScore.score(), Animal.TYPE_PRACTICE);
|
||||
var animalLevelID = Animal.animalLevelIDByRecord(this.typingScore.score(), Animal.TYPE_PRACTICE);
|
||||
if(animalLevelID > this.playingAnimalIndex) {
|
||||
this.playingAnimalIndex = animalLevelID;
|
||||
this.animalOnTitle.setSpecies(Animal.SPECIES_DATA[this.playingAnimalIndex]);;
|
||||
@@ -380,10 +376,9 @@ class TypingPractice {
|
||||
this.animalOnTitle.startAnimation();
|
||||
this.animalOnTitle.tweenAnimation(Animal.ANIMATION_TYPE_DAMAGE);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
playNextContent() {
|
||||
playNextContent: function() {
|
||||
this.hideHighlightKey();
|
||||
|
||||
this.typingIndex++;
|
||||
@@ -391,7 +386,6 @@ class TypingPractice {
|
||||
this.showHighlightKey();
|
||||
this.moveHands();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
class Hand {
|
||||
|
||||
constructor(keyMapper) {
|
||||
function Hand(keyMapper) {
|
||||
this.keyMapper = keyMapper;
|
||||
this.pressingFinger = KeyButton.NONE_FINGER;
|
||||
this.prevFingerSprite = null;
|
||||
@@ -29,39 +27,39 @@ class Hand {
|
||||
this.little_finger.alpha = 0.5;
|
||||
this.hand.addChild(this.little_finger);
|
||||
|
||||
let mask = game.add.graphics();
|
||||
var mask = game.add.graphics();
|
||||
mask.beginFill(0xffffff);
|
||||
mask.drawRect(100, 300, 1028, 360);
|
||||
this.hand.mask = mask;
|
||||
}
|
||||
|
||||
move(sprite, x, y) {
|
||||
Hand.prototype.move = function(sprite, x, y) {
|
||||
sprite.x = x;
|
||||
sprite.y = y;
|
||||
}
|
||||
|
||||
moveTo(key) {
|
||||
Hand.prototype.moveTo = function(key) {
|
||||
}
|
||||
|
||||
moveToDefaultPosition() {
|
||||
Hand.prototype.moveToDefaultPosition = function() {
|
||||
this.moveRow(3, null);
|
||||
this.unhighlightOffFinger(KeyButton.NONE_FINGER);
|
||||
}
|
||||
|
||||
|
||||
moveRow(rowNo, key) {
|
||||
let rowIndex = rowNo - 1;
|
||||
Hand.prototype.moveRow = function(rowNo, key) {
|
||||
var rowIndex = rowNo - 1;
|
||||
this.hand.y = Hand.DEFAULT_Y_PX + Keyboard.DEFAULT_KEY_SIZE_PX * rowIndex;
|
||||
|
||||
this.moveColumn(rowNo, key);
|
||||
}
|
||||
|
||||
moveColumn(rowNo, key) {
|
||||
Hand.prototype.moveColumn = function(rowNo, key) {
|
||||
}
|
||||
|
||||
|
||||
getFingerSprite(fingerNo) {
|
||||
let fingerSprite = null;
|
||||
Hand.prototype.getFingerSprite = function(fingerNo) {
|
||||
var fingerSprite = null;
|
||||
switch(fingerNo) {
|
||||
case KeyButton.THUMB:
|
||||
fingerSprite = this.thumb;
|
||||
@@ -83,9 +81,9 @@ class Hand {
|
||||
return fingerSprite;
|
||||
}
|
||||
|
||||
highlightOnFinger(fingerNo) {
|
||||
Hand.prototype.highlightOnFinger = function(fingerNo) {
|
||||
// console.log(fingerNo);
|
||||
let pressingFingerSprite = this.getFingerSprite(fingerNo);
|
||||
var pressingFingerSprite = this.getFingerSprite(fingerNo);
|
||||
if(pressingFingerSprite === this.prevFingerSprite)
|
||||
return;
|
||||
|
||||
@@ -101,7 +99,7 @@ class Hand {
|
||||
this.prevFingerSprite = pressingFingerSprite;
|
||||
}
|
||||
|
||||
unhighlightOffFinger() {
|
||||
Hand.prototype.unhighlightOffFinger = function() {
|
||||
if(this.prevFingerSprite === null)
|
||||
return;
|
||||
this.prevFingerSprite.tint = 0xffffff;
|
||||
@@ -110,16 +108,16 @@ class Hand {
|
||||
this.prevFingerSprite = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Hand.DEFAULT_Y_PX = 540; // 680;
|
||||
|
||||
|
||||
|
||||
class LeftHand extends Hand {
|
||||
LeftHand.prototype = Object.create(Hand.prototype);
|
||||
LeftHand.constructor = LeftHand;
|
||||
|
||||
constructor(keyMapper) {
|
||||
super(keyMapper);
|
||||
function LeftHand(keyMapper) {
|
||||
Hand.call(this, keyMapper);
|
||||
|
||||
this.move(this.thumb, 126, -50);
|
||||
this.move(this.index_finger, 96, -102);
|
||||
@@ -129,12 +127,12 @@ class LeftHand extends Hand {
|
||||
this.moveToDefaultPosition();
|
||||
}
|
||||
|
||||
moveTo(key) {
|
||||
LeftHand.prototype.moveTo = function(key) {
|
||||
if(key === undefined)
|
||||
return;
|
||||
|
||||
// console.log(key);
|
||||
let keyCode = this.keyMapper.getKeyIDOfText(key.normalText);
|
||||
var keyCode = this.keyMapper.getKeyIDOfText(key.normalText);
|
||||
|
||||
if(keyCode != "Space")
|
||||
this.moveRow(key.row, key);
|
||||
@@ -153,14 +151,14 @@ class LeftHand extends Hand {
|
||||
this.highlightOnFinger(key.fingerType);
|
||||
}
|
||||
|
||||
moveColumn(rowNo, key) {
|
||||
let rowIndex = rowNo - 1;
|
||||
LeftHand.prototype.moveColumn = function(rowNo, key) {
|
||||
var rowIndex = rowNo - 1;
|
||||
this.hand.x = LeftHand.DEFAULT_X_PX + (Keyboard.DEFAULT_KEY_SIZE_PX / 2) * rowIndex;
|
||||
|
||||
if(key === null)
|
||||
return;
|
||||
|
||||
let keyCode = this.keyMapper.getKeyIDOfText(key.normalText);
|
||||
var keyCode = this.keyMapper.getKeyIDOfText(key.normalText);
|
||||
switch(keyCode) {
|
||||
case "Key5":
|
||||
case "KeyT":
|
||||
@@ -175,16 +173,16 @@ class LeftHand extends Hand {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
LeftHand.DEFAULT_X_PX = 100;
|
||||
|
||||
|
||||
|
||||
class RightHand extends Hand {
|
||||
RightHand.prototype = Object.create(Hand.prototype);
|
||||
RightHand.constructor = RightHand;
|
||||
|
||||
constructor(keyMapper) {
|
||||
super(keyMapper);
|
||||
function RightHand(keyMapper) {
|
||||
Hand.call(this, keyMapper);
|
||||
|
||||
this.hand.scale.x *= -1;
|
||||
|
||||
@@ -196,12 +194,12 @@ class RightHand extends Hand {
|
||||
this.moveToDefaultPosition();
|
||||
}
|
||||
|
||||
moveTo(key) {
|
||||
RightHand.prototype.moveTo = function(key) {
|
||||
if(key === undefined)
|
||||
return;
|
||||
|
||||
// console.log(key);
|
||||
let keyCode = this.keyMapper.getKeyIDOfText(key.normalText);
|
||||
var keyCode = this.keyMapper.getKeyIDOfText(key.normalText);
|
||||
|
||||
if(keyCode != "Space")
|
||||
this.moveRow(key.row, key);
|
||||
@@ -220,14 +218,14 @@ class RightHand extends Hand {
|
||||
this.highlightOnFinger(key.fingerType);
|
||||
}
|
||||
|
||||
moveColumn(rowNo, key) {
|
||||
let rowIndex = rowNo - 1;
|
||||
RightHand.prototype.moveColumn = function(rowNo, key) {
|
||||
var rowIndex = rowNo - 1;
|
||||
this.hand.x = RightHand.DEFAULT_X_PX + (Keyboard.DEFAULT_KEY_SIZE_PX / 2) * rowIndex;
|
||||
|
||||
if(key === null)
|
||||
return;
|
||||
|
||||
let keyCode = this.keyMapper.getKeyIDOfText(key.normalText);
|
||||
var keyCode = this.keyMapper.getKeyIDOfText(key.normalText);
|
||||
switch(keyCode) {
|
||||
case "Key6":
|
||||
case "KeyY":
|
||||
@@ -261,6 +259,5 @@ class RightHand extends Hand {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
RightHand.DEFAULT_X_PX = 810;
|
||||
@@ -1,6 +1,4 @@
|
||||
class KeyButton {
|
||||
|
||||
constructor(x, y, width, height, normalText, shiftText, handSide, row, fingerType, alignType) {
|
||||
function KeyButton(x, y, width, height, normalText, shiftText, handSide, row, fingerType, alignType) {
|
||||
this.normalText = normalText;
|
||||
this.shiftText = shiftText;
|
||||
this.handSide = handSide;
|
||||
@@ -30,8 +28,8 @@ class KeyButton {
|
||||
this.highlightButtonStroke.alpha = 0;
|
||||
}
|
||||
|
||||
makeButtonSolidSprite(setting) {
|
||||
let btnTexture = new Phaser.Graphics()
|
||||
KeyButton.prototype.makeButtonSolidSprite = function(setting) {
|
||||
var btnTexture = new Phaser.Graphics()
|
||||
.beginFill(0xffffff, 0.5)
|
||||
// .lineStyle(setting.strokeWidthPx, 0xFFffff, 1)
|
||||
.drawRoundedRect(0, 0, setting.width, setting.height, setting.roundAmount)
|
||||
@@ -45,8 +43,8 @@ class KeyButton {
|
||||
);
|
||||
}
|
||||
|
||||
makeButtonStrokeSprite(setting) {
|
||||
let btnTexture = new Phaser.Graphics()
|
||||
KeyButton.prototype.makeButtonStrokeSprite = function(setting) {
|
||||
var btnTexture = new Phaser.Graphics()
|
||||
.lineStyle(setting.strokeWidthPx, 0xaaaaaa, 1)
|
||||
.drawRoundedRect(0, 0, setting.width, setting.height, setting.roundAmount)
|
||||
.generateTexture();
|
||||
@@ -58,9 +56,9 @@ class KeyButton {
|
||||
);
|
||||
}
|
||||
|
||||
makeHighlightButtonStrokeSprite(setting) {
|
||||
let strokeWidth = setting.strokeWidthPx * 2;
|
||||
let btnTexture = new Phaser.Graphics()
|
||||
KeyButton.prototype.makeHighlightButtonStrokeSprite = function(setting) {
|
||||
var strokeWidth = setting.strokeWidthPx * 2;
|
||||
var btnTexture = new Phaser.Graphics()
|
||||
.lineStyle(strokeWidth, 0xfffff00, 1)
|
||||
.drawRoundedRect(0, 0, setting.width, setting.height, setting.roundAmount)
|
||||
.generateTexture();
|
||||
@@ -72,10 +70,10 @@ class KeyButton {
|
||||
);
|
||||
}
|
||||
|
||||
makeBaselineStrokeSprite(setting, width, height) {
|
||||
let strokePx = setting.strokeWidthPx;
|
||||
KeyButton.prototype.makeBaselineStrokeSprite = function(setting, width, height) {
|
||||
var strokePx = setting.strokeWidthPx;
|
||||
|
||||
let baselineTexture = new Phaser.Graphics()
|
||||
var baselineTexture = new Phaser.Graphics()
|
||||
.lineStyle(2, 0x888888)
|
||||
.moveTo(1, 1)
|
||||
.lineTo(16, 1)
|
||||
@@ -84,7 +82,7 @@ class KeyButton {
|
||||
.lineTo(15, 0)
|
||||
.generateTexture();
|
||||
|
||||
let baselineSprite = game.add.sprite(
|
||||
var baselineSprite = game.add.sprite(
|
||||
strokePx + setting.width / 2,
|
||||
strokePx + setting.height - 6,
|
||||
baselineTexture
|
||||
@@ -93,15 +91,15 @@ class KeyButton {
|
||||
return baselineSprite;
|
||||
}
|
||||
|
||||
makeText(setting, textContent) {
|
||||
let fontStyle = { };
|
||||
KeyButton.prototype.makeText = function(setting, textContent) {
|
||||
var fontStyle = { };
|
||||
if(this.alignType === KeyButton.NORMAL_KEY)
|
||||
setting.fontStyle.font = "20px Courier New";
|
||||
else
|
||||
setting.fontStyle.font = "11px Courier New";
|
||||
|
||||
let OFFSET_X = 4, OFFSET_Y = 3;
|
||||
let textPosX = 0, textPosY = 0;
|
||||
var OFFSET_X = 4, OFFSET_Y = 3;
|
||||
var textPosX = 0, textPosY = 0;
|
||||
switch(this.alignType) {
|
||||
case KeyButton.NORMAL_KEY:
|
||||
case KeyButton.NORMAL_FUNCTION_KEY:
|
||||
@@ -125,7 +123,7 @@ class KeyButton {
|
||||
break;
|
||||
}
|
||||
|
||||
let buttonText = game.add.text(textPosX, textPosY, textContent, setting.fontStyle);
|
||||
var buttonText = game.add.text(textPosX, textPosY, textContent, setting.fontStyle);
|
||||
switch(this.alignType) {
|
||||
case KeyButton.NORMAL_KEY:
|
||||
case KeyButton.NORMAL_FUNCTION_KEY:
|
||||
@@ -149,7 +147,7 @@ class KeyButton {
|
||||
}
|
||||
|
||||
|
||||
setNormalColor() {
|
||||
KeyButton.prototype.setNormalColor = function() {
|
||||
switch(this.fingerType) {
|
||||
case KeyButton.THUMB:
|
||||
this.buttonSolid.tint = 0x604d4d;
|
||||
@@ -178,7 +176,7 @@ class KeyButton {
|
||||
}
|
||||
}
|
||||
|
||||
setTargetColor() {
|
||||
KeyButton.prototype.setTargetColor = function() {
|
||||
switch(this.fingerType) {
|
||||
case KeyButton.THUMB:
|
||||
this.buttonSolid.tint = 0xff8080;
|
||||
@@ -207,33 +205,32 @@ class KeyButton {
|
||||
}
|
||||
}
|
||||
|
||||
setGoodPressColor() {
|
||||
KeyButton.prototype.setGoodPressColor = function() {
|
||||
this.buttonSolid.tint = 0x0000ff;
|
||||
}
|
||||
|
||||
setBadPressColor() {
|
||||
KeyButton.prototype.setBadPressColor = function() {
|
||||
this.buttonSolid.tint = 0xff0000;
|
||||
}
|
||||
|
||||
|
||||
showHighlight() {
|
||||
KeyButton.prototype.showHighlight = function() {
|
||||
this.highlightButtonStroke.alpha = 1;
|
||||
}
|
||||
|
||||
hideHighlight() {
|
||||
KeyButton.prototype.hideHighlight = function() {
|
||||
this.highlightButtonStroke.alpha = 0;
|
||||
}
|
||||
|
||||
|
||||
onShiftPressed() {
|
||||
KeyButton.prototype.onShiftPressed = function() {
|
||||
this.buttonText.text = this.shiftText;
|
||||
}
|
||||
|
||||
onShiftUnpressed() {
|
||||
KeyButton.prototype.onShiftUnpressed = function() {
|
||||
this.buttonText.text = this.normalText;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
KeyButton.NONE_ICON = "";
|
||||
KeyButton.NONE_BUTTON_TEXT = "";
|
||||
|
||||
@@ -1,26 +1,16 @@
|
||||
class KeyData {
|
||||
|
||||
constructor() {
|
||||
function KeyData() {
|
||||
this.functionKey = null;
|
||||
this.englishKey = null;
|
||||
this.koreanKey = null;
|
||||
}
|
||||
}
|
||||
|
||||
class KeyTextData {
|
||||
|
||||
constructor(normalText, shiftText) {
|
||||
function KeyTextData(normalText, shiftText) {
|
||||
this.normalText = normalText;
|
||||
this.shiftText = shiftText;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
class KeyMapper {
|
||||
|
||||
constructor() {
|
||||
function KeyMapper() {
|
||||
this.keyboardKeyMap = {};
|
||||
this.inputKeyMap = {};
|
||||
|
||||
@@ -30,7 +20,7 @@ class KeyMapper {
|
||||
}
|
||||
|
||||
|
||||
registerFunctionKey() {
|
||||
KeyMapper.prototype.registerFunctionKey = function() {
|
||||
this.registerFunctionKeyTextData("Backquote", "`", "~");
|
||||
this.registerFunctionKeyTextData("Digit1", "1", "!");
|
||||
this.registerFunctionKeyTextData("Digit2", "2", "@");
|
||||
@@ -72,7 +62,7 @@ class KeyMapper {
|
||||
this.registerFunctionKeyTextData("ControlRight", "ctrl", "ctrl");
|
||||
}
|
||||
|
||||
registerEnglishKey() {
|
||||
KeyMapper.prototype.registerEnglishKey = function() {
|
||||
this.registerEnglishKeyTextData("KeyQ", "q", "Q");
|
||||
this.registerEnglishKeyTextData("KeyW", "w", "W");
|
||||
this.registerEnglishKeyTextData("KeyE", "e", "E");
|
||||
@@ -103,7 +93,7 @@ class KeyMapper {
|
||||
this.registerEnglishKeyTextData("KeyM", "m", "M");
|
||||
}
|
||||
|
||||
registerKoreanKey() {
|
||||
KeyMapper.prototype.registerKoreanKey = function() {
|
||||
this.registerKoreanKeyTextData("KeyQ", "ㅂ", "ㅃ");
|
||||
this.registerKoreanKeyTextData("KeyW", "ㅈ", "ㅉ");
|
||||
this.registerKoreanKeyTextData("KeyE", "ㄷ", "ㄸ");
|
||||
@@ -135,7 +125,7 @@ class KeyMapper {
|
||||
}
|
||||
|
||||
|
||||
registerFunctionKeyTextData(keyID, normalText, shiftText) {
|
||||
KeyMapper.prototype.registerFunctionKeyTextData = function(keyID, normalText, shiftText) {
|
||||
if(this.keyboardKeyMap[keyID] === undefined) {
|
||||
this.keyboardKeyMap[keyID] = new KeyData();
|
||||
}
|
||||
@@ -149,7 +139,7 @@ class KeyMapper {
|
||||
this.inputKeyMap[shiftText] = keyID;
|
||||
}
|
||||
|
||||
registerEnglishKeyTextData(keyID, normalText, shiftText) {
|
||||
KeyMapper.prototype.registerEnglishKeyTextData = function(keyID, normalText, shiftText) {
|
||||
if(this.keyboardKeyMap[keyID] === undefined) {
|
||||
this.keyboardKeyMap[keyID] = new KeyData();
|
||||
}
|
||||
@@ -163,7 +153,7 @@ class KeyMapper {
|
||||
this.inputKeyMap[shiftText] = keyID;
|
||||
}
|
||||
|
||||
registerKoreanKeyTextData(keyID, normalText, shiftText) {
|
||||
KeyMapper.prototype.registerKoreanKeyTextData = function(keyID, normalText, shiftText) {
|
||||
if(this.keyboardKeyMap[keyID] === undefined) {
|
||||
this.keyboardKeyMap[keyID] = new KeyData();
|
||||
}
|
||||
@@ -178,7 +168,7 @@ class KeyMapper {
|
||||
}
|
||||
|
||||
|
||||
getNormalText(keyID, language) {
|
||||
KeyMapper.prototype.getNormalText = function(keyID, language) {
|
||||
if(this.keyboardKeyMap[keyID] === undefined) {
|
||||
console.log(keyID);
|
||||
return "?";
|
||||
@@ -187,7 +177,7 @@ class KeyMapper {
|
||||
// console.log(keyID);
|
||||
// console.log(language);
|
||||
// console.log(this.keyboardKeyMap[keyID]);
|
||||
let keyData = this.keyboardKeyMap[keyID];
|
||||
var keyData = this.keyboardKeyMap[keyID];
|
||||
if(language === Keyboard.ENGLISH && keyData.englishKey !== null) {
|
||||
return keyData.englishKey.normalText;
|
||||
}
|
||||
@@ -202,7 +192,7 @@ class KeyMapper {
|
||||
}
|
||||
}
|
||||
|
||||
getShiftText(keyID, language) {
|
||||
KeyMapper.prototype.getShiftText = function(keyID, language) {
|
||||
if(this.keyboardKeyMap[keyID] === undefined) {
|
||||
console.log(keyID);
|
||||
return "?";
|
||||
@@ -211,7 +201,7 @@ class KeyMapper {
|
||||
// console.log(keyID);
|
||||
// console.log(language);
|
||||
// console.log(this.keyboardKeyMap[keyID]);
|
||||
let keyData = this.keyboardKeyMap[keyID];
|
||||
var keyData = this.keyboardKeyMap[keyID];
|
||||
if(language === Keyboard.ENGLISH && keyData.englishKey !== null) {
|
||||
return keyData.englishKey.shiftText;
|
||||
}
|
||||
@@ -228,13 +218,13 @@ class KeyMapper {
|
||||
|
||||
|
||||
|
||||
getKeyIDOfText(text) {
|
||||
KeyMapper.prototype.getKeyIDOfText = function(text) {
|
||||
return this.inputKeyMap[text];
|
||||
}
|
||||
|
||||
isShiftText(text) {
|
||||
let keyID = this.getKeyIDOfText(text);
|
||||
let keyData = this.keyboardKeyMap[keyID];
|
||||
KeyMapper.prototype.isShiftText = function(text) {
|
||||
var keyID = this.getKeyIDOfText(text);
|
||||
var keyData = this.keyboardKeyMap[keyID];
|
||||
|
||||
if(keyData.englishKey !== null && keyData.englishKey.shiftText === text)
|
||||
return true;
|
||||
@@ -245,5 +235,3 @@ class KeyMapper {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
class Keyboard {
|
||||
|
||||
constructor(keyMapper, language) {
|
||||
function Keyboard(keyMapper, language) {
|
||||
this.keyMapper = keyMapper;
|
||||
this.language = language;
|
||||
|
||||
@@ -22,13 +20,13 @@ class Keyboard {
|
||||
// game.input.keyboard.processKeyUp = this.keyUp;
|
||||
|
||||
|
||||
let shiftKey = game.input.keyboard.addKey(Phaser.KeyCode.SHIFT);
|
||||
var shiftKey = game.input.keyboard.addKey(Phaser.KeyCode.SHIFT);
|
||||
shiftKey.onDown.add(this.shifted, this);
|
||||
shiftKey.onUp.add(this.unshifted, this);
|
||||
|
||||
this.initKeyData();
|
||||
|
||||
for(let i = 0; i < this.keyDataList.length; i++) {
|
||||
for(var i = 0; i < this.keyDataList.length; i++) {
|
||||
this.keyList[i] = new KeyButton(
|
||||
this.keyDataList[i].x,
|
||||
this.keyDataList[i].y,
|
||||
@@ -46,43 +44,43 @@ class Keyboard {
|
||||
}
|
||||
}
|
||||
|
||||
hideHighlight(text) {
|
||||
let keyID = this.keyMapper.getKeyIDOfText(text);
|
||||
Keyboard.prototype.hideHighlight = function(text) {
|
||||
var keyID = this.keyMapper.getKeyIDOfText(text);
|
||||
this.allKeyHash[keyID].hideHighlight();
|
||||
|
||||
if(!this.keyMapper.isShiftText(text))
|
||||
return;
|
||||
|
||||
let handSide = this.allKeyHash[keyID].handSide;
|
||||
var handSide = this.allKeyHash[keyID].handSide;
|
||||
if(handSide === KeyButton.LEFT_HAND)
|
||||
this.allKeyHash["ShiftRight"].hideHighlight();
|
||||
else
|
||||
this.allKeyHash["ShiftLeft"].hideHighlight();
|
||||
}
|
||||
|
||||
showHighlight(text) {
|
||||
let keyID = this.keyMapper.getKeyIDOfText(text);
|
||||
let key = this.allKeyHash[keyID];
|
||||
Keyboard.prototype.showHighlight = function(text) {
|
||||
var keyID = this.keyMapper.getKeyIDOfText(text);
|
||||
var key = this.allKeyHash[keyID];
|
||||
key.showHighlight();
|
||||
}
|
||||
|
||||
getKeyOfText(text) {
|
||||
let keyID = this.keyMapper.getKeyIDOfText(text);
|
||||
Keyboard.prototype.getKeyOfText = function(text) {
|
||||
var keyID = this.keyMapper.getKeyIDOfText(text);
|
||||
return this.allKeyHash[keyID];
|
||||
}
|
||||
|
||||
getKey(keyID) {
|
||||
Keyboard.prototype.getKey = function(keyID) {
|
||||
return this.allKeyHash[keyID];
|
||||
}
|
||||
|
||||
keyDown(char) {
|
||||
let keyCode = char.code;
|
||||
Keyboard.prototype.keyDown = function(char) {
|
||||
var keyCode = char.code;
|
||||
this.setPressedSprite(keyCode);
|
||||
}
|
||||
|
||||
setPressedSprite(keyCode) {
|
||||
let keyID = this.keyMapper.getKeyIDOfText(keyCode);
|
||||
let key = this.allKeyHash[keyID];
|
||||
Keyboard.prototype.setPressedSprite = function(keyCode) {
|
||||
var keyID = this.keyMapper.getKeyIDOfText(keyCode);
|
||||
var key = this.allKeyHash[keyID];
|
||||
if(key === undefined) {
|
||||
console.log(keyCode+ " is pressed but not registered to KeyMapper");
|
||||
return;
|
||||
@@ -100,34 +98,34 @@ class Keyboard {
|
||||
key.setTargetColor();
|
||||
}
|
||||
|
||||
keyUp(char) {
|
||||
let keyCode = char.code;
|
||||
Keyboard.prototype.keyUp = function(char) {
|
||||
var keyCode = char.code;
|
||||
this.setNormalSprite(keyCode);
|
||||
}
|
||||
|
||||
setNormalSprite(keyCode) {
|
||||
let keyID = this.keyMapper.getKeyIDOfText(keyCode);
|
||||
let key = this.allKeyHash[keyID];
|
||||
Keyboard.prototype.setNormalSprite = function(keyCode) {
|
||||
var keyID = this.keyMapper.getKeyIDOfText(keyCode);
|
||||
var key = this.allKeyHash[keyID];
|
||||
if(key !== undefined)
|
||||
key.setNormalColor();
|
||||
}
|
||||
|
||||
|
||||
|
||||
shifted() {
|
||||
for(let i = 0; i < this.keyDataList.length; i++) {
|
||||
Keyboard.prototype.shifted = function() {
|
||||
for(var i = 0; i < this.keyDataList.length; i++) {
|
||||
this.keyList[i].onShiftPressed();
|
||||
}
|
||||
}
|
||||
|
||||
unshifted() {
|
||||
for(let i = 0; i < this.keyDataList.length; i++) {
|
||||
Keyboard.prototype.unshifted = function() {
|
||||
for(var i = 0; i < this.keyDataList.length; i++) {
|
||||
this.keyList[i].onShiftUnpressed();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
keyPress(char) {
|
||||
Keyboard.prototype.keyPress = function(char) {
|
||||
// self.checkTypingContents(event);
|
||||
// console.log(char);
|
||||
if(game.input.keyboard.isDown(Phaser.Keyboard.SHIFT))
|
||||
@@ -135,8 +133,8 @@ class Keyboard {
|
||||
}
|
||||
|
||||
|
||||
makeKeyDataObject(keyID, normalText, shiftText, handSide, row, fingerType, x, y, width, height, alignType) {
|
||||
let keyDataObject = {};
|
||||
Keyboard.prototype.makeKeyDataObject = function(keyID, normalText, shiftText, handSide, row, fingerType, x, y, width, height, alignType) {
|
||||
var keyDataObject = {};
|
||||
keyDataObject.keyID = keyID;
|
||||
keyDataObject.normalText = normalText;
|
||||
keyDataObject.shiftText = shiftText;
|
||||
@@ -152,7 +150,7 @@ class Keyboard {
|
||||
return keyDataObject;
|
||||
}
|
||||
|
||||
makeNextNormalKeyDataObject(keyID, prevKeyData, normalText, shiftText, handSide, fingerType) {
|
||||
Keyboard.prototype.makeNextNormalKeyDataObject = function(keyID, prevKeyData, normalText, shiftText, handSide, fingerType) {
|
||||
return this.makeKeyDataObject(
|
||||
keyID,
|
||||
normalText,
|
||||
@@ -169,11 +167,11 @@ class Keyboard {
|
||||
}
|
||||
|
||||
|
||||
addFunctionKeyData(keyID, handSide, row, fingerType, x, y, width, height, type) {
|
||||
let normalText = this.keyMapper.getNormalText(keyID, this.language);
|
||||
let shiftText = this.keyMapper.getShiftText(keyID, this.language);
|
||||
Keyboard.prototype.addFunctionKeyData = function(keyID, handSide, row, fingerType, x, y, width, height, type) {
|
||||
var normalText = this.keyMapper.getNormalText(keyID, this.language);
|
||||
var shiftText = this.keyMapper.getShiftText(keyID, this.language);
|
||||
|
||||
let newKey = this.makeKeyDataObject(
|
||||
var newKey = this.makeKeyDataObject(
|
||||
keyID,
|
||||
normalText, shiftText,
|
||||
handSide, row, fingerType,
|
||||
@@ -185,12 +183,12 @@ class Keyboard {
|
||||
this.keyIndex++;
|
||||
}
|
||||
|
||||
addNextFunctionKeyData(keyID, handSide, fingerType, width, height, type) {
|
||||
let prevKey = this.keyDataList[this.keyIndex - 1];
|
||||
let normalText = this.keyMapper.getNormalText(keyID, this.language);
|
||||
let shiftText = this.keyMapper.getShiftText(keyID, this.language);
|
||||
Keyboard.prototype.addNextFunctionKeyData = function(keyID, handSide, fingerType, width, height, type) {
|
||||
var prevKey = this.keyDataList[this.keyIndex - 1];
|
||||
var normalText = this.keyMapper.getNormalText(keyID, this.language);
|
||||
var shiftText = this.keyMapper.getShiftText(keyID, this.language);
|
||||
|
||||
let newKey = this.makeKeyDataObject(
|
||||
var newKey = this.makeKeyDataObject(
|
||||
keyID,
|
||||
normalText, shiftText,
|
||||
handSide, prevKey.row, fingerType,
|
||||
@@ -204,12 +202,12 @@ class Keyboard {
|
||||
// this.normalKeyHash[keyID] = newKey;
|
||||
}
|
||||
|
||||
addNextNormalKeyData(keyID, handSide, fingerType) {
|
||||
let prevKey = this.keyDataList[this.keyIndex - 1];
|
||||
let normalText = this.keyMapper.getNormalText(keyID, this.language);
|
||||
let shiftText = this.keyMapper.getShiftText(keyID, this.language);
|
||||
Keyboard.prototype.addNextNormalKeyData = function(keyID, handSide, fingerType) {
|
||||
var prevKey = this.keyDataList[this.keyIndex - 1];
|
||||
var normalText = this.keyMapper.getNormalText(keyID, this.language);
|
||||
var shiftText = this.keyMapper.getShiftText(keyID, this.language);
|
||||
|
||||
let newKey = this.makeNextNormalKeyDataObject(
|
||||
var newKey = this.makeNextNormalKeyDataObject(
|
||||
keyID,
|
||||
prevKey,
|
||||
normalText, shiftText,
|
||||
@@ -223,7 +221,7 @@ class Keyboard {
|
||||
|
||||
|
||||
|
||||
initKeyData(keyMapper) {
|
||||
Keyboard.prototype.initKeyData = function(keyMapper) {
|
||||
// row 1
|
||||
this.addFunctionKeyData(
|
||||
"Backquote",
|
||||
@@ -416,8 +414,6 @@ class Keyboard {
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Keyboard.ENGLISH = "english";
|
||||
Keyboard.KOREAN = "korean";
|
||||
|
||||
@@ -1,17 +1,11 @@
|
||||
/////////////////////////////
|
||||
// Loading
|
||||
var Loading = {
|
||||
|
||||
// var x = 32;
|
||||
// var y = 80;
|
||||
|
||||
class Loading {
|
||||
|
||||
preload() {
|
||||
preload: function() {
|
||||
// this.game.load.image('loadingbar', './image/phaser.png');
|
||||
}
|
||||
},
|
||||
|
||||
create() {
|
||||
// let userID = sessionStorage.getItem("UserID");
|
||||
create: function() {
|
||||
// var userID = sessionStorage.getItem("UserID");
|
||||
// console.log("userID : " + userID);
|
||||
|
||||
// this.game.stage.backgroundColor = '#4d4d4d';
|
||||
@@ -30,9 +24,9 @@ class Loading {
|
||||
this.game.load.onLoadComplete.add(this.loadComplete, this);
|
||||
|
||||
this.startLoading();
|
||||
}
|
||||
},
|
||||
|
||||
startLoading() {
|
||||
startLoading: function() {
|
||||
this.game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png');
|
||||
|
||||
this.game.load.image('hand_palm', '../../../resources/image/ui/hand_palm.png');
|
||||
@@ -70,9 +64,9 @@ class Loading {
|
||||
// this.game.load.image('medal_bronze', './image/medal_bronze.png');
|
||||
|
||||
this.game.load.start();
|
||||
}
|
||||
},
|
||||
|
||||
fileComplete(progress, cacheKey, success, totalLoaded, totalFiles) {
|
||||
fileComplete: function(progress, cacheKey, success, totalLoaded, totalFiles) {
|
||||
// this.preloadBar.alpha = progress / 100;
|
||||
|
||||
// console.log('progress : ' + progress);
|
||||
@@ -88,9 +82,9 @@ class Loading {
|
||||
// x = 32;
|
||||
// y += 332;
|
||||
// }
|
||||
}
|
||||
},
|
||||
|
||||
loadComplete(progress, cacheKey, success, totalLoaded, totalFiles) {
|
||||
loadComplete: function(progress, cacheKey, success, totalLoaded, totalFiles) {
|
||||
// this.preloadBar.alpha = 1;
|
||||
|
||||
if(isDebugMode()) {
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
class StageTimer {
|
||||
|
||||
constructor(stageTimerSec, onTimeOver) {
|
||||
|
||||
function StageTimer(stageTimerSec, onTimeOver) {
|
||||
this.stageTimerSec = stageTimerSec;
|
||||
this.onTimeOver = onTimeOver;
|
||||
|
||||
let fontStyle = StageTimer.DEFAULT_TEXT_FONT;
|
||||
var fontStyle = StageTimer.DEFAULT_TEXT_FONT;
|
||||
|
||||
fontStyle.align = "right";
|
||||
fontStyle.boundsAlignH = "right";
|
||||
@@ -25,23 +22,23 @@ class StageTimer {
|
||||
this.timerEvent = null;
|
||||
};
|
||||
|
||||
start() {
|
||||
StageTimer.prototype.start = function() {
|
||||
this.timeLeft = this.stageTimerSec;
|
||||
this.printTime();
|
||||
if(this.timerEvent === null)
|
||||
this.timerEvent = game.time.events.loop(Phaser.Timer.SECOND, this.updateTimer, this);
|
||||
}
|
||||
|
||||
pause() {
|
||||
StageTimer.prototype.pause = function() {
|
||||
}
|
||||
|
||||
stop() {
|
||||
StageTimer.prototype.stop = function() {
|
||||
if(this.timerEvent)
|
||||
this.removeTimer();
|
||||
this.timerText.text = "시간 끝";
|
||||
}
|
||||
|
||||
updateTimer() {
|
||||
StageTimer.prototype.updateTimer = function() {
|
||||
this.timeLeft--;
|
||||
if(this.timeLeft === 0) {
|
||||
this.stop();
|
||||
@@ -51,16 +48,15 @@ class StageTimer {
|
||||
}
|
||||
}
|
||||
|
||||
printTime() {
|
||||
StageTimer.prototype.printTime = function() {
|
||||
this.timerText.text = this.timeLeft.toString() + "초";
|
||||
}
|
||||
|
||||
removeTimer() {
|
||||
StageTimer.prototype.removeTimer = function() {
|
||||
game.time.events.remove(this.timerEvent);
|
||||
this.timerEvent = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
StageTimer.FONT_HEIGHT_PX = 70;
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
class TypingScore {
|
||||
|
||||
constructor() {
|
||||
function TypingScore() {
|
||||
this.typingCount = 0;
|
||||
|
||||
let fontStyle = TypingScore.DEFAULT_TEXT_FONT;
|
||||
var fontStyle = TypingScore.DEFAULT_TEXT_FONT;
|
||||
|
||||
fontStyle.align = "right";
|
||||
fontStyle.boundsAlignH = "right";
|
||||
@@ -26,25 +24,24 @@ class TypingScore {
|
||||
// this.scoreText.strokeThickness = 3;
|
||||
};
|
||||
|
||||
score() {
|
||||
TypingScore.prototype.score = function() {
|
||||
return this.typingCount;
|
||||
}
|
||||
|
||||
increase() {
|
||||
TypingScore.prototype.increase = function() {
|
||||
this.typingCount++;
|
||||
this.print(this.typingCount);
|
||||
}
|
||||
|
||||
reset() {
|
||||
TypingScore.prototype.reset = function() {
|
||||
this.typingCount = 0;
|
||||
this.print(this.typingCount);
|
||||
}
|
||||
|
||||
print(typingCount) {
|
||||
TypingScore.prototype.print = function(typingCount) {
|
||||
this.scoreText.text = typingCount;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TypingScore.SCORE_POS_Y = 35;
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
class AverageTypingSpeed {
|
||||
|
||||
constructor() {
|
||||
let fontStyle = AverageTypingSpeed.DEFAULT_TEXT_FONT;
|
||||
function AverageTypingSpeed() {
|
||||
var fontStyle = AverageTypingSpeed.DEFAULT_TEXT_FONT;
|
||||
|
||||
fontStyle.align = "right";
|
||||
fontStyle.boundsAlignH = "right";
|
||||
@@ -24,11 +22,10 @@ class AverageTypingSpeed {
|
||||
// this.label.strokeThickness = 3;
|
||||
};
|
||||
|
||||
print(typingSpeed) {
|
||||
AverageTypingSpeed.prototype.print = function(typingSpeed) {
|
||||
this.typingSpeedText.text = typingSpeed;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
AverageTypingSpeed.FONT_HEIGHT_PX = 30;
|
||||
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
/////////////////////////////
|
||||
// TypingTest
|
||||
var TypingTest = {
|
||||
|
||||
class TypingTest {
|
||||
|
||||
create() {
|
||||
create: function() {
|
||||
self = this;
|
||||
|
||||
this.initTypingData();
|
||||
sessionStorageManager.isNewBestRecrd = false;
|
||||
sessionStorageManager.setIsNewBestRecord(false);
|
||||
|
||||
game.stage.backgroundColor = '#4d4d4d';
|
||||
|
||||
@@ -105,14 +102,14 @@ class TypingTest {
|
||||
|
||||
// bottom ui
|
||||
let screenBottomUI = new ScreenBottomUI();
|
||||
screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.bestRecord);
|
||||
screenBottomUI.printCenterText(sessionStorageManager.playingAppKoreanName);
|
||||
screenBottomUI.printRightText(sessionStorageManager.playerName);
|
||||
screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.getBestRecord());
|
||||
screenBottomUI.printCenterText(sessionStorageManager.getPlayingAppKoreanName());
|
||||
screenBottomUI.printRightText(sessionStorageManager.getPlayerName());
|
||||
|
||||
|
||||
this.startGame();
|
||||
// this.countDown();
|
||||
}
|
||||
},
|
||||
|
||||
/*
|
||||
countDown() {
|
||||
@@ -145,30 +142,30 @@ class TypingTest {
|
||||
}
|
||||
*/
|
||||
|
||||
startGame() {
|
||||
startGame: function() {
|
||||
this.averageTypingSpeedText.print(0);
|
||||
|
||||
this.showTypingTestContents();
|
||||
this.showPlayingWordNumber();
|
||||
}
|
||||
},
|
||||
|
||||
gameOver() {
|
||||
gameOver: function() {
|
||||
let gameOverText = new GameOverText();
|
||||
|
||||
this.animalOnTitle.stopAnimation();
|
||||
|
||||
game.time.events.add(Phaser.Timer.SECOND * 2, this.goResult, this);
|
||||
}
|
||||
},
|
||||
|
||||
goResult() {
|
||||
sessionStorageManager.record = this.typingRecordTotal;
|
||||
if(sessionStorageManager.record > sessionStorageManager.bestRecord)
|
||||
sessionStorageManager.bestRecord = sessionStorageManager.record;
|
||||
goResult: function() {
|
||||
sessionStorageManager.setRecord(this.typingRecordTotal);
|
||||
if(sessionStorageManager.getRecord() > sessionStorageManager.getBestRecord())
|
||||
sessionStorageManager.setBestRecord(sessionStorageManager.record);
|
||||
|
||||
location.href = '../../web/client/result.html';
|
||||
}
|
||||
},
|
||||
|
||||
initTypingData() {
|
||||
initTypingData: function() {
|
||||
let typingTextMan = new TypingTextManager();
|
||||
|
||||
let typingPracticeContents = this.getTypingTestContents();
|
||||
@@ -190,10 +187,10 @@ class TypingTest {
|
||||
|
||||
this.typingLetterCountTotal = 0;
|
||||
this.typingRecordTotal = 0;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
getTypingTestContents() {
|
||||
getTypingTestContents: function() {
|
||||
let typingTestContents = this.loadTestContent();
|
||||
// console.log('playingStageData.language : ' + playingStageData.language);
|
||||
// console.log('playingStageData.level : ' + playingStageData.level);
|
||||
@@ -207,14 +204,14 @@ class TypingTest {
|
||||
}
|
||||
|
||||
return typingTestContents;
|
||||
}
|
||||
},
|
||||
|
||||
loadTestContent() {
|
||||
loadTestContent: function() {
|
||||
let appName = "";
|
||||
if(isTypingTestStage())
|
||||
appName = sessionStorageManager.playingAppName.substring(5);
|
||||
appName = sessionStorageManager.getPlayingAppName().substring(5);
|
||||
else if(isTypingPracticeStage())
|
||||
appName = sessionStorageManager.playingAppName.substring(9);
|
||||
appName = sessionStorageManager.getPlayingAppName().substring(9);
|
||||
|
||||
let testContent = [];
|
||||
switch(appName) {
|
||||
@@ -276,9 +273,9 @@ class TypingTest {
|
||||
}
|
||||
|
||||
return testContent;
|
||||
}
|
||||
},
|
||||
|
||||
showTypingTestContents() {
|
||||
showTypingTestContents: function() {
|
||||
for(let i = 0; i < TypingTest.TYPING_CONTENT_DONE_COUNT; i++) {
|
||||
let doneIndex = this.typingIndex - i - 1;
|
||||
if(doneIndex < 0) {
|
||||
@@ -304,15 +301,15 @@ class TypingTest {
|
||||
else
|
||||
this.textTypingContentPreview[i].text = "";
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
resetTypingContent() {
|
||||
resetTypingContent: function() {
|
||||
this.textTypingContent.clearColors();
|
||||
this.textTypingContent.addColor(TypingTest.COLOR_CONTENT_INPUT, 0);
|
||||
this.inputTextContent.canvasInput.value('');
|
||||
}
|
||||
},
|
||||
|
||||
checkTypingContents(evnet) {
|
||||
checkTypingContents: function(evnet) {
|
||||
if(event.keyCode == Phaser.Keyboard.ENTER) {
|
||||
// console.log("### enter ###");
|
||||
let inputContent = this.inputTextContent.canvasInput.value();
|
||||
@@ -336,9 +333,9 @@ class TypingTest {
|
||||
|
||||
this.showTypingContentHighlight();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
showTypingContentHighlight() {
|
||||
showTypingContentHighlight: function() {
|
||||
let typingContent = this.typingRandomContents[this.typingIndex];
|
||||
let inputContent = this.inputTextContent.canvasInput.value();
|
||||
|
||||
@@ -358,9 +355,9 @@ class TypingTest {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
calculateTypingRecord(typingContent) {
|
||||
calculateTypingRecord: function(typingContent) {
|
||||
// console.log('입력 단어 : ' + this.typingRandomContents[this.typingIndex]);
|
||||
|
||||
this.isTyping = false;
|
||||
@@ -404,20 +401,20 @@ class TypingTest {
|
||||
this.animalOnTitle.tweenAnimation(Animal.ANIMATION_TYPE_CHANGE);
|
||||
this.animalOnTitle.startAnimation();
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
playNextContent() {
|
||||
playNextContent: function() {
|
||||
this.typingIndex++;
|
||||
this.showTypingTestContents();
|
||||
this.showPlayingWordNumber();
|
||||
this.resetTypingContent();
|
||||
}
|
||||
},
|
||||
|
||||
showPlayingWordNumber() {
|
||||
showPlayingWordNumber: function() {
|
||||
this.contentProgressText.print(this.typingIndex + 1, this.typingContentLength);
|
||||
}
|
||||
},
|
||||
|
||||
setTimeTypingStart() {
|
||||
setTimeTypingStart: function() {
|
||||
this.timeTypingStart = game.time.elapsedSince(0);
|
||||
let timeGap = this.timeTypingStart - this.timeTypingEnd;
|
||||
|
||||
|
||||
@@ -1,17 +1,11 @@
|
||||
/////////////////////////////
|
||||
// Loading
|
||||
var Loading = {
|
||||
|
||||
// var x = 32;
|
||||
// var y = 80;
|
||||
|
||||
class Loading {
|
||||
|
||||
preload() {
|
||||
preload: function() {
|
||||
// this.game.load.image('loadingbar', './image/phaser.png');
|
||||
}
|
||||
},
|
||||
|
||||
create() {
|
||||
// let userID = sessionStorage.getItem("UserID");
|
||||
create: function() {
|
||||
// var userID = sessionStorage.getItem("UserID");
|
||||
// console.log("userID : " + userID);
|
||||
|
||||
// this.game.stage.backgroundColor = '#4d4d4d';
|
||||
@@ -30,9 +24,9 @@ class Loading {
|
||||
this.game.load.onLoadComplete.add(this.loadComplete, this);
|
||||
|
||||
this.startLoading();
|
||||
}
|
||||
},
|
||||
|
||||
startLoading() {
|
||||
startLoading: function() {
|
||||
this.game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png');
|
||||
|
||||
Animal.loadResources();
|
||||
@@ -61,9 +55,9 @@ class Loading {
|
||||
// this.game.load.image('medal_bronze', './image/medal_bronze.png');
|
||||
|
||||
this.game.load.start();
|
||||
}
|
||||
},
|
||||
|
||||
fileComplete(progress, cacheKey, success, totalLoaded, totalFiles) {
|
||||
fileComplete: function(progress, cacheKey, success, totalLoaded, totalFiles) {
|
||||
// this.preloadBar.alpha = progress / 100;
|
||||
|
||||
// console.log('progress : ' + progress);
|
||||
@@ -79,9 +73,9 @@ class Loading {
|
||||
// x = 32;
|
||||
// y += 332;
|
||||
// }
|
||||
}
|
||||
},
|
||||
|
||||
loadComplete(progress, cacheKey, success, totalLoaded, totalFiles) {
|
||||
loadComplete: function(progress, cacheKey, success, totalLoaded, totalFiles) {
|
||||
// this.preloadBar.alpha = 1;
|
||||
|
||||
if(isDebugMode()) {
|
||||
@@ -93,5 +87,5 @@ class Loading {
|
||||
// this.startMenu();
|
||||
// this.startTypingTestStage();
|
||||
// this.startTypingTestResult();
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user