Fix: restructing session manager, ES6 -> ES5
This commit is contained in:
+123
-126
@@ -1,150 +1,147 @@
|
||||
class Animal {
|
||||
function Animal(type, x, y) {
|
||||
this.animalType = type;
|
||||
|
||||
constructor(type, x, y) {
|
||||
this.animalType = type;
|
||||
this.sprite = null;
|
||||
this.posX = x;
|
||||
this.posY = y;
|
||||
}
|
||||
|
||||
this.sprite = null;
|
||||
this.posX = x;
|
||||
this.posY = y;
|
||||
}
|
||||
Animal.prototype.loadSpriteNames = function() {
|
||||
let spriteNames = {};
|
||||
|
||||
loadSpriteNames() {
|
||||
let spriteNames = {};
|
||||
spriteNames.icon = this.species.species + Animal.SPRITE_NAMES.icon;
|
||||
|
||||
spriteNames.icon = this.species.species + Animal.SPRITE_NAMES.icon;
|
||||
spriteNames.run1 = this.species.species + Animal.SPRITE_NAMES.run1;
|
||||
spriteNames.run2 = this.species.species + Animal.SPRITE_NAMES.run2;
|
||||
|
||||
spriteNames.run1 = this.species.species + Animal.SPRITE_NAMES.run1;
|
||||
spriteNames.run2 = this.species.species + Animal.SPRITE_NAMES.run2;
|
||||
return spriteNames;
|
||||
}
|
||||
|
||||
return spriteNames;
|
||||
}
|
||||
Animal.prototype.setSpecies = function(species) {
|
||||
this.species = species;
|
||||
|
||||
setSpecies(species) {
|
||||
this.species = species;
|
||||
if(this.animalType === Animal.TYPE_ICON)
|
||||
return;
|
||||
|
||||
if(this.animalType === Animal.TYPE_ICON)
|
||||
return;
|
||||
this.setupAnimation();
|
||||
}
|
||||
|
||||
this.setupAnimation();
|
||||
}
|
||||
Animal.prototype.tweenAnimation = function(animationType) {
|
||||
switch(animationType) {
|
||||
case Animal.ANIMATION_TYPE_CHANGE:
|
||||
this.sprite.width = 200;
|
||||
this.sprite.height = 200;
|
||||
game.add.tween(this.sprite).to( { width: 150, height: 150 }, 500, Phaser.Easing.Bounce.Out, true);
|
||||
break;
|
||||
|
||||
tweenAnimation(animationType) {
|
||||
switch(animationType) {
|
||||
case Animal.ANIMATION_TYPE_CHANGE:
|
||||
this.sprite.width = 200;
|
||||
this.sprite.height = 200;
|
||||
game.add.tween(this.sprite).to( { width: 150, height: 150 }, 500, Phaser.Easing.Bounce.Out, true);
|
||||
break;
|
||||
|
||||
case Animal.ANIMATION_TYPE_DAMAGE:
|
||||
this.sprite.width = 200;
|
||||
game.add.tween(this.sprite).to( { width: 150 }, 500, Phaser.Easing.Bounce.In, true);
|
||||
// game.add.tween(this.sprite).to( { width: 50 }, 500, Phaser.Easing.Elastic.Out, true);
|
||||
break;
|
||||
|
||||
}
|
||||
case Animal.ANIMATION_TYPE_DAMAGE:
|
||||
this.sprite.width = 200;
|
||||
game.add.tween(this.sprite).to( { width: 150 }, 500, Phaser.Easing.Bounce.In, true);
|
||||
// game.add.tween(this.sprite).to( { width: 50 }, 500, Phaser.Easing.Elastic.Out, true);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
setupAnimation() {
|
||||
this.spriteFrameNames = this.loadSpriteNames();
|
||||
this.playingSpriteFrameName = this.spriteFrameNames.run1;
|
||||
this.animationFrameID = 1;
|
||||
this.animationSpeedSec = 1000 / this.species.runningFPS;
|
||||
}
|
||||
|
||||
if(this.sprite === null) {
|
||||
this.sprite = game.add.sprite(this.posX, this.posY, this.spriteFrameNames.run1);
|
||||
this.sprite.anchor.set(0.5);
|
||||
this.sprite.width = 150;
|
||||
this.sprite.height = 150;
|
||||
}
|
||||
Animal.prototype.setupAnimation = function() {
|
||||
this.spriteFrameNames = this.loadSpriteNames();
|
||||
this.playingSpriteFrameName = this.spriteFrameNames.run1;
|
||||
this.animationFrameID = 1;
|
||||
this.animationSpeedSec = 1000 / this.species.runningFPS;
|
||||
|
||||
this.stopAnimation();
|
||||
this.animateionUpdate();
|
||||
if(this.sprite === null) {
|
||||
this.sprite = game.add.sprite(this.posX, this.posY, this.spriteFrameNames.run1);
|
||||
this.sprite.anchor.set(0.5);
|
||||
this.sprite.width = 150;
|
||||
this.sprite.height = 150;
|
||||
}
|
||||
|
||||
startAnimation() {
|
||||
if(this.timerEvent === null)
|
||||
this.timerEvent = game.time.events.loop(this.animationSpeedSec, this.animateionUpdate, this);
|
||||
this.stopAnimation();
|
||||
this.animateionUpdate();
|
||||
}
|
||||
|
||||
Animal.prototype.startAnimation = function() {
|
||||
if(this.timerEvent === null)
|
||||
this.timerEvent = game.time.events.loop(this.animationSpeedSec, this.animateionUpdate, this);
|
||||
}
|
||||
|
||||
Animal.prototype.animateionUpdate = function() {
|
||||
this.animationFrameID = 1 - this.animationFrameID;
|
||||
|
||||
if(this.animationFrameID === 0) {
|
||||
this.sprite.loadTexture(this.spriteFrameNames.run2);
|
||||
} else {
|
||||
this.sprite.loadTexture(this.spriteFrameNames.run1);
|
||||
}
|
||||
}
|
||||
|
||||
Animal.prototype.stopAnimation = function() {
|
||||
if(this.timerEvent !== null) {
|
||||
game.time.events.remove(this.timerEvent);
|
||||
this.timerEvent = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
animateionUpdate() {
|
||||
this.animationFrameID = 1 - this.animationFrameID;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(this.animationFrameID === 0) {
|
||||
this.sprite.loadTexture(this.spriteFrameNames.run2);
|
||||
} else {
|
||||
this.sprite.loadTexture(this.spriteFrameNames.run1);
|
||||
}
|
||||
}
|
||||
Animal.typingCount = function(speciesData, gameType) {
|
||||
if(gameType === Animal.TYPE_PRACTICE)
|
||||
return speciesData.practiceTypingCount;
|
||||
else
|
||||
return speciesData.testTypingCount;
|
||||
}
|
||||
|
||||
stopAnimation() {
|
||||
if(this.timerEvent !== null) {
|
||||
game.time.events.remove(this.timerEvent);
|
||||
this.timerEvent = null;
|
||||
}
|
||||
}
|
||||
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');
|
||||
game.load.image('snail_run1', '../../../resources/image/character/animal/snail/run1.png');
|
||||
game.load.image('snail_run2', '../../../resources/image/character/animal/snail/run2.png');
|
||||
|
||||
static animalLevelIDByRecord(record, gameType) {
|
||||
for(let i = Animal.SPECIES_DATA.length - 1; i > 0; i--) {
|
||||
if(record >= this.typingCount(Animal.SPECIES_DATA[i], gameType))
|
||||
return i;
|
||||
}
|
||||
game.load.image('turtle_icon', '../../../resources/image/character/animal/turtle/run2.png');
|
||||
game.load.image('turtle_run1', '../../../resources/image/character/animal/turtle/run1.png');
|
||||
game.load.image('turtle_run2', '../../../resources/image/character/animal/turtle/run2.png');
|
||||
|
||||
return 0;
|
||||
}
|
||||
game.load.image('cat_icon', '../../../resources/image/character/animal/cat/run2.png');
|
||||
game.load.image('cat_run1', '../../../resources/image/character/animal/cat/run1.png');
|
||||
game.load.image('cat_run2', '../../../resources/image/character/animal/cat/run2.png');
|
||||
|
||||
static typingCount(speciesData, gameType) {
|
||||
if(gameType === Animal.TYPE_PRACTICE)
|
||||
return speciesData.practiceTypingCount;
|
||||
else
|
||||
return speciesData.testTypingCount;
|
||||
}
|
||||
game.load.image('lion_icon', '../../../resources/image/character/animal/lion/run2.png');
|
||||
game.load.image('lion_run1', '../../../resources/image/character/animal/lion/run1.png');
|
||||
game.load.image('lion_run2', '../../../resources/image/character/animal/lion/run2.png');
|
||||
|
||||
static loadResources() {
|
||||
game.load.image('snail_shadow', '../../../resources/image/character/animal/snail/shadow.png');
|
||||
game.load.image('rabbit_icon', '../../../resources/image/character/animal/rabbit/run2.png');
|
||||
game.load.image('rabbit_run1', '../../../resources/image/character/animal/rabbit/run1.png');
|
||||
game.load.image('rabbit_run2', '../../../resources/image/character/animal/rabbit/run2.png');
|
||||
|
||||
game.load.image('snail_icon', '../../../resources/image/character/animal/snail/run2.png');
|
||||
game.load.image('snail_run1', '../../../resources/image/character/animal/snail/run1.png');
|
||||
game.load.image('snail_run2', '../../../resources/image/character/animal/snail/run2.png');
|
||||
game.load.image('ostrich_icon', '../../../resources/image/character/animal/ostrich/run2.png');
|
||||
game.load.image('ostrich_run1', '../../../resources/image/character/animal/ostrich/run1.png');
|
||||
game.load.image('ostrich_run2', '../../../resources/image/character/animal/ostrich/run2.png');
|
||||
|
||||
game.load.image('turtle_icon', '../../../resources/image/character/animal/turtle/run2.png');
|
||||
game.load.image('turtle_run1', '../../../resources/image/character/animal/turtle/run1.png');
|
||||
game.load.image('turtle_run2', '../../../resources/image/character/animal/turtle/run2.png');
|
||||
game.load.image('horse_icon', '../../../resources/image/character/animal/horse/run2.png');
|
||||
game.load.image('horse_run1', '../../../resources/image/character/animal/horse/run1.png');
|
||||
game.load.image('horse_run2', '../../../resources/image/character/animal/horse/run2.png');
|
||||
|
||||
game.load.image('cat_icon', '../../../resources/image/character/animal/cat/run2.png');
|
||||
game.load.image('cat_run1', '../../../resources/image/character/animal/cat/run1.png');
|
||||
game.load.image('cat_run2', '../../../resources/image/character/animal/cat/run2.png');
|
||||
game.load.image('dog_icon', '../../../resources/image/character/animal/dog/run2.png');
|
||||
game.load.image('dog_run1', '../../../resources/image/character/animal/dog/run1.png');
|
||||
game.load.image('dog_run2', '../../../resources/image/character/animal/dog/run2.png');
|
||||
|
||||
game.load.image('lion_icon', '../../../resources/image/character/animal/lion/run2.png');
|
||||
game.load.image('lion_run1', '../../../resources/image/character/animal/lion/run1.png');
|
||||
game.load.image('lion_run2', '../../../resources/image/character/animal/lion/run2.png');
|
||||
game.load.image('cheetah_icon', '../../../resources/image/character/animal/cheetah/run2.png');
|
||||
game.load.image('cheetah_run1', '../../../resources/image/character/animal/cheetah/run1.png');
|
||||
game.load.image('cheetah_run2', '../../../resources/image/character/animal/cheetah/run2.png');
|
||||
|
||||
game.load.image('rabbit_icon', '../../../resources/image/character/animal/rabbit/run2.png');
|
||||
game.load.image('rabbit_run1', '../../../resources/image/character/animal/rabbit/run1.png');
|
||||
game.load.image('rabbit_run2', '../../../resources/image/character/animal/rabbit/run2.png');
|
||||
|
||||
game.load.image('ostrich_icon', '../../../resources/image/character/animal/ostrich/run2.png');
|
||||
game.load.image('ostrich_run1', '../../../resources/image/character/animal/ostrich/run1.png');
|
||||
game.load.image('ostrich_run2', '../../../resources/image/character/animal/ostrich/run2.png');
|
||||
|
||||
game.load.image('horse_icon', '../../../resources/image/character/animal/horse/run2.png');
|
||||
game.load.image('horse_run1', '../../../resources/image/character/animal/horse/run1.png');
|
||||
game.load.image('horse_run2', '../../../resources/image/character/animal/horse/run2.png');
|
||||
|
||||
game.load.image('dog_icon', '../../../resources/image/character/animal/dog/run2.png');
|
||||
game.load.image('dog_run1', '../../../resources/image/character/animal/dog/run1.png');
|
||||
game.load.image('dog_run2', '../../../resources/image/character/animal/dog/run2.png');
|
||||
|
||||
game.load.image('cheetah_icon', '../../../resources/image/character/animal/cheetah/run2.png');
|
||||
game.load.image('cheetah_run1', '../../../resources/image/character/animal/cheetah/run1.png');
|
||||
game.load.image('cheetah_run2', '../../../resources/image/character/animal/cheetah/run2.png');
|
||||
|
||||
game.load.image('eagle_icon', '../../../resources/image/character/animal/eagle/run2.png');
|
||||
game.load.image('eagle_run1', '../../../resources/image/character/animal/eagle/run1.png');
|
||||
game.load.image('eagle_run2', '../../../resources/image/character/animal/eagle/run2.png');
|
||||
}
|
||||
game.load.image('eagle_icon', '../../../resources/image/character/animal/eagle/run2.png');
|
||||
game.load.image('eagle_run1', '../../../resources/image/character/animal/eagle/run1.png');
|
||||
game.load.image('eagle_run2', '../../../resources/image/character/animal/eagle/run2.png');
|
||||
}
|
||||
|
||||
|
||||
@@ -159,16 +156,16 @@ Animal.ANIMATION_TYPE_DAMAGE = 1;
|
||||
|
||||
|
||||
Animal.SPECIES_DATA = [
|
||||
{ "species" : "snail", "runningFPS" : 1.1, "practiceTypingCount" : 0, "testTypingCount" : 0 },
|
||||
{ "species" : "turtle", "runningFPS" : 2.2, "practiceTypingCount" : 5, "testTypingCount" : 20 },
|
||||
{ "species" : "cat", "runningFPS" : 3.3, "practiceTypingCount" : 10, "testTypingCount" : 50 },
|
||||
{ "species" : "lion", "runningFPS" : 4.4, "practiceTypingCount" : 15, "testTypingCount" : 100 },
|
||||
{ "species" : "rabbit", "runningFPS" : 5.5, "practiceTypingCount" : 20, "testTypingCount" : 200 },
|
||||
{ "species" : "ostrich", "runningFPS" : 7.7, "practiceTypingCount" : 25, "testTypingCount" : 300 },
|
||||
{ "species" : "horse", "runningFPS" : 9.9, "practiceTypingCount" : 30, "testTypingCount" : 400 },
|
||||
{ "species" : "dog", "runningFPS" : 12.2, "practiceTypingCount" : 35, "testTypingCount" : 500 },
|
||||
{ "species" : "cheetah", "runningFPS" : 16, "practiceTypingCount" : 40, "testTypingCount" : 600 },
|
||||
{ "species" : "eagle", "runningFPS" : 20, "practiceTypingCount" : 50, "testTypingCount" : 700 }
|
||||
{ "species" : "snail", "runningFPS" : 1.1, "practiceTypingCount" : 0, "testTypingCount" : 0 },
|
||||
{ "species" : "turtle", "runningFPS" : 2.2, "practiceTypingCount" : 5, "testTypingCount" : 20 },
|
||||
{ "species" : "cat", "runningFPS" : 3.3, "practiceTypingCount" : 10, "testTypingCount" : 50 },
|
||||
{ "species" : "lion", "runningFPS" : 4.4, "practiceTypingCount" : 15, "testTypingCount" : 100 },
|
||||
{ "species" : "rabbit", "runningFPS" : 5.5, "practiceTypingCount" : 20, "testTypingCount" : 200 },
|
||||
{ "species" : "ostrich", "runningFPS" : 7.7, "practiceTypingCount" : 25, "testTypingCount" : 300 },
|
||||
{ "species" : "horse", "runningFPS" : 9.9, "practiceTypingCount" : 30, "testTypingCount" : 400 },
|
||||
{ "species" : "dog", "runningFPS" : 12.2, "practiceTypingCount" : 35, "testTypingCount" : 500 },
|
||||
{ "species" : "cheetah", "runningFPS" : 16, "practiceTypingCount" : 40, "testTypingCount" : 600 },
|
||||
{ "species" : "eagle", "runningFPS" : 20, "practiceTypingCount" : 50, "testTypingCount" : 700 }
|
||||
];
|
||||
|
||||
Animal.SPRITE_NAMES = {
|
||||
|
||||
@@ -1,52 +1,45 @@
|
||||
/////////////////////////////
|
||||
// Chart
|
||||
function AnnounceBox(x, y) {
|
||||
this.posX = x;
|
||||
this.posY = y;
|
||||
}
|
||||
|
||||
class AnnounceBox {
|
||||
AnnounceBox.prototype.drawText = function(posX, posY, text) {
|
||||
const style = { font: "24px Arial", fill: "#fff", align: "left", boundsAlignH: "center", boundsAlignV: "middle" };
|
||||
|
||||
constructor(x, y) {
|
||||
this.posX = x;
|
||||
this.posY = y;
|
||||
}
|
||||
let textObject = game.add.text(
|
||||
posX, posY,
|
||||
text, style
|
||||
);
|
||||
textObject.anchor.set(0.5);
|
||||
textObject.stroke = "#333";
|
||||
textObject.strokeThickness = 3;
|
||||
|
||||
drawText(posX, posY, text) {
|
||||
const style = { font: "24px Arial", fill: "#fff", align: "left", boundsAlignH: "center", boundsAlignV: "middle" };
|
||||
return textObject;
|
||||
}
|
||||
|
||||
let textObject = game.add.text(
|
||||
posX, posY,
|
||||
text, style
|
||||
);
|
||||
textObject.anchor.set(0.5);
|
||||
textObject.stroke = "#333";
|
||||
textObject.strokeThickness = 3;
|
||||
AnnounceBox.prototype.getFontStyle = function() {
|
||||
return { font: "32px Arial", fill: "#fff" };
|
||||
}
|
||||
|
||||
return textObject;
|
||||
}
|
||||
AnnounceBox.prototype.drawBox = function(text) {
|
||||
this.graphics = game.add.graphics(this.posX, this.posY);
|
||||
this.graphics.alpha = 0.8;
|
||||
|
||||
getFontStyle() {
|
||||
return { font: "32px Arial", fill: "#fff" };
|
||||
}
|
||||
this.graphics.beginFill(0x303030);
|
||||
this.graphics.lineStyle(4, 0x880000, 1);
|
||||
this.graphics.moveTo(0, -190);
|
||||
this.graphics.lineTo(game.world.width / 2, -170);
|
||||
this.graphics.lineTo(game.world.width - this.posX * 2, -190);
|
||||
this.graphics.lineTo(game.world.width - this.posX * 2, 50);
|
||||
this.graphics.lineTo(game.world.width / 2, 30);
|
||||
this.graphics.lineTo(0, 50);
|
||||
this.graphics.endFill();
|
||||
|
||||
drawBox(text) {
|
||||
this.graphics = game.add.graphics(this.posX, this.posY);
|
||||
this.graphics.alpha = 0.8;
|
||||
|
||||
this.graphics.beginFill(0x303030);
|
||||
this.graphics.lineStyle(4, 0x880000, 1);
|
||||
this.graphics.moveTo(0, -190);
|
||||
this.graphics.lineTo(game.world.width / 2, -170);
|
||||
this.graphics.lineTo(game.world.width - this.posX * 2, -190);
|
||||
this.graphics.lineTo(game.world.width - this.posX * 2, 50);
|
||||
this.graphics.lineTo(game.world.width / 2, 30);
|
||||
this.graphics.lineTo(0, 50);
|
||||
this.graphics.endFill();
|
||||
|
||||
let announceText = this.drawText(
|
||||
game.world.width / 2, this.posY - 75,
|
||||
text
|
||||
);
|
||||
announceText.addColor("#ff0000", 0);
|
||||
announceText.stroke = "#330000";
|
||||
|
||||
}
|
||||
let announceText = this.drawText(
|
||||
game.world.width / 2, this.posY - 75,
|
||||
text
|
||||
);
|
||||
announceText.addColor("#ff0000", 0);
|
||||
announceText.stroke = "#330000";
|
||||
|
||||
}
|
||||
@@ -1,77 +1,69 @@
|
||||
class AppInfo {
|
||||
|
||||
constructor(appID, appName, koreanName, howToPlay) {
|
||||
this.appID = appID;
|
||||
this.appName = appName;
|
||||
|
||||
this.koreanName = koreanName;
|
||||
this.isActivated = false;
|
||||
this.howToPlay = howToPlay;
|
||||
}
|
||||
function AppInfo(appID, appName, koreanName, howToPlay) {
|
||||
this.appID = appID;
|
||||
this.appName = appName;
|
||||
|
||||
this.koreanName = koreanName;
|
||||
this.isActivated = false;
|
||||
this.howToPlay = howToPlay;
|
||||
}
|
||||
|
||||
|
||||
class AppInfoManager {
|
||||
function AppInfoManager() {
|
||||
this.appInfoMap = new Map();
|
||||
|
||||
constructor() {
|
||||
this.appInfoMap = new Map();
|
||||
this.registerAppInfoList();
|
||||
}
|
||||
|
||||
this.registerAppInfoList();
|
||||
}
|
||||
AppInfoManager.prototype.registerAppInfoList = function() {
|
||||
// menu
|
||||
this.registerAppInfo(new AppInfo("test", "테스트", ""));
|
||||
this.registerAppInfo(new AppInfo("login", "로그인", ""));
|
||||
this.registerAppInfo(new AppInfo("menu", "메뉴", ""));
|
||||
|
||||
registerAppInfoList() {
|
||||
// menu
|
||||
this.registerAppInfo(new AppInfo("test", "테스트", ""));
|
||||
this.registerAppInfo(new AppInfo("login", "로그인", ""));
|
||||
this.registerAppInfo(new AppInfo("menu", "메뉴", ""));
|
||||
// typing
|
||||
this.registerAppInfo(new AppInfo("korean_basic", "기본 자리", ""));
|
||||
this.registerAppInfo(new AppInfo("korean_left_upper", "왼손 윗글쇠", ""));
|
||||
this.registerAppInfo(new AppInfo("korean_second_finger", "검지 글쇠", ""));
|
||||
this.registerAppInfo(new AppInfo("korean_right_upper", "오른손 윗글쇠", ""));
|
||||
this.registerAppInfo(new AppInfo("korean_left_lower", "왼손 밑글쇠", ""));
|
||||
this.registerAppInfo(new AppInfo("korean_right_lower", "오른손 밑글쇠", ""));
|
||||
this.registerAppInfo(new AppInfo("korean_left_upper_double", "쌍자음", ""));
|
||||
this.registerAppInfo(new AppInfo("korean_right_upper_double", "쌍모음", ""));
|
||||
|
||||
// typing
|
||||
this.registerAppInfo(new AppInfo("korean_basic", "기본 자리", ""));
|
||||
this.registerAppInfo(new AppInfo("korean_left_upper", "왼손 윗글쇠", ""));
|
||||
this.registerAppInfo(new AppInfo("korean_second_finger", "검지 글쇠", ""));
|
||||
this.registerAppInfo(new AppInfo("korean_right_upper", "오른손 윗글쇠", ""));
|
||||
this.registerAppInfo(new AppInfo("korean_left_lower", "왼손 밑글쇠", ""));
|
||||
this.registerAppInfo(new AppInfo("korean_right_lower", "오른손 밑글쇠", ""));
|
||||
this.registerAppInfo(new AppInfo("korean_left_upper_double", "쌍자음", ""));
|
||||
this.registerAppInfo(new AppInfo("korean_right_upper_double", "쌍모음", ""));
|
||||
this.registerAppInfo(new AppInfo("english_basic", "기본 자리", ""));
|
||||
this.registerAppInfo(new AppInfo("english_left_upper", "왼손 윗글쇠", ""));
|
||||
this.registerAppInfo(new AppInfo("english_second_finger", "검지 글쇠", ""));
|
||||
this.registerAppInfo(new AppInfo("english_right_upper", "오른손 윗글쇠", ""));
|
||||
this.registerAppInfo(new AppInfo("english_left_lower", "왼손 밑글쇠", ""));
|
||||
this.registerAppInfo(new AppInfo("english_right_lower", "오른손 밑글쇠", ""));
|
||||
|
||||
this.registerAppInfo(new AppInfo("english_basic", "기본 자리", ""));
|
||||
this.registerAppInfo(new AppInfo("english_left_upper", "왼손 윗글쇠", ""));
|
||||
this.registerAppInfo(new AppInfo("english_second_finger", "검지 글쇠", ""));
|
||||
this.registerAppInfo(new AppInfo("english_right_upper", "오른손 윗글쇠", ""));
|
||||
this.registerAppInfo(new AppInfo("english_left_lower", "왼손 밑글쇠", ""));
|
||||
this.registerAppInfo(new AppInfo("english_right_lower", "오른손 밑글쇠", ""));
|
||||
// mouse
|
||||
this.registerAppInfo(new AppInfo("space_invaders", "외계인 침공",
|
||||
"외계인이 나타났다!\n마우스 왼쪽 버튼으로\n외계인을 클릭해서 물리쳐 주세요."
|
||||
));
|
||||
this.registerAppInfo(new AppInfo("card_matching", "카드 짝 맞추기",
|
||||
"외계인이 나타났다 사라집니다.\n\n마우스 왼쪽 버튼으로 외계인을 클릭해서\n\n물리쳐 주세요."
|
||||
));
|
||||
}
|
||||
|
||||
// mouse
|
||||
this.registerAppInfo(new AppInfo("space_invaders", "외계인 침공",
|
||||
"외계인이 나타났다!\n마우스 왼쪽 버튼으로\n외계인을 클릭해서 물리쳐 주세요."
|
||||
));
|
||||
this.registerAppInfo(new AppInfo("card_matching", "카드 짝 맞추기",
|
||||
"외계인이 나타났다 사라집니다.\n\n마우스 왼쪽 버튼으로 외계인을 클릭해서\n\n물리쳐 주세요."
|
||||
));
|
||||
}
|
||||
AppInfoManager.prototype.setHowToPlay = function(appName, text) {
|
||||
this.appInfoMap[appName].howToPlay = text;
|
||||
}
|
||||
|
||||
setHowToPlay(appName, text) {
|
||||
this.appInfoMap[appName].howToPlay = text;
|
||||
}
|
||||
AppInfoManager.prototype.registerAppInfo = function(appInfo) {
|
||||
return this.appInfoMap[appInfo.appName] = appInfo;
|
||||
}
|
||||
|
||||
registerAppInfo(appInfo) {
|
||||
return this.appInfoMap[appInfo.appName] = appInfo;
|
||||
}
|
||||
AppInfoManager.prototype.getAppkoreanName = function(appName) {
|
||||
if(appName === null)
|
||||
return "";
|
||||
|
||||
getAppkoreanName(appName) {
|
||||
if(appName === null)
|
||||
return "";
|
||||
return this.appInfoMap[appName].koreanName;
|
||||
}
|
||||
|
||||
return this.appInfoMap[appName].koreanName;
|
||||
}
|
||||
|
||||
getHowToPlayText(appName) {
|
||||
if(appName === null)
|
||||
return "";
|
||||
|
||||
return this.appInfoMap[appName].howToPlay;
|
||||
}
|
||||
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';
|
||||
}
|
||||
|
||||
+51
-57
@@ -1,62 +1,56 @@
|
||||
/////////////////////////////
|
||||
// Chart
|
||||
|
||||
class Chart {
|
||||
|
||||
constructor() {
|
||||
this.chartGraphics = game.add.graphics(0, 0);
|
||||
}
|
||||
|
||||
printChartBaseLine() {
|
||||
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;
|
||||
|
||||
this.drawText(
|
||||
posX, posY + Chart.CHART_DATE_OFFSET_Y,
|
||||
date === "-" ? "-" : StringUtil.printMonthDay(date)
|
||||
);
|
||||
|
||||
if(bestRecord === "")
|
||||
return;
|
||||
|
||||
this.drawText(
|
||||
posX, posY - Chart.CHART_HEIGHT - Chart.CHART_RECORD_OFFSET_Y,
|
||||
StringUtil.getRecordTextWithoutUnit(bestRecord) + StringUtil.getScoreUnit(sessionStorageManager.playingAppID),
|
||||
);
|
||||
|
||||
// chart
|
||||
this.chartGraphics.lineStyle(50, 0xdddddd, 1);
|
||||
this.chartGraphics.moveTo(posX, posY);
|
||||
this.chartGraphics.lineTo(posX, posY - Chart.CHART_HEIGHT * ( (bestRecord - min) / (max - min) ));
|
||||
}
|
||||
|
||||
drawText(posX, posY, text) {
|
||||
const style = { font: "24px Arial", fill: "#fff", align: "left", boundsAlignH: "center", boundsAlignV: "middle" };
|
||||
|
||||
let textObject = game.add.text(
|
||||
posX, posY,
|
||||
text, style
|
||||
);
|
||||
textObject.anchor.set(0.5);
|
||||
textObject.stroke = "#333";
|
||||
textObject.strokeThickness = 3;
|
||||
|
||||
return textObject;
|
||||
}
|
||||
|
||||
getFontStyle() {
|
||||
return { font: "32px Arial", fill: "#fff" };
|
||||
}
|
||||
|
||||
function Chart() {
|
||||
this.chartGraphics = game.add.graphics(0, 0);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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,
|
||||
date === "-" ? "-" : StringUtil.printMonthDay(date)
|
||||
);
|
||||
|
||||
if(bestRecord === "")
|
||||
return;
|
||||
|
||||
this.drawText(
|
||||
posX, posY - Chart.CHART_HEIGHT - Chart.CHART_RECORD_OFFSET_Y,
|
||||
StringUtil.getRecordTextWithoutUnit(bestRecord) + StringUtil.getScoreUnit(sessionStorageManager.playingAppID),
|
||||
);
|
||||
|
||||
// chart
|
||||
this.chartGraphics.lineStyle(50, 0xdddddd, 1);
|
||||
this.chartGraphics.moveTo(posX, posY);
|
||||
this.chartGraphics.lineTo(posX, posY - Chart.CHART_HEIGHT * ( (bestRecord - min) / (max - min) ));
|
||||
}
|
||||
|
||||
Chart.prototype.drawText = function(posX, posY, text) {
|
||||
const style = { font: "24px Arial", fill: "#fff", align: "left", boundsAlignH: "center", boundsAlignV: "middle" };
|
||||
|
||||
var textObject = game.add.text(
|
||||
posX, posY,
|
||||
text, style
|
||||
);
|
||||
textObject.anchor.set(0.5);
|
||||
textObject.stroke = "#333";
|
||||
textObject.strokeThickness = 3;
|
||||
|
||||
return textObject;
|
||||
}
|
||||
|
||||
Chart.prototype.getFontStyle = function() {
|
||||
return { font: "32px Arial", fill: "#fff" };
|
||||
}
|
||||
|
||||
|
||||
Chart.CHART_COUNT = 7;
|
||||
|
||||
Chart.CHART_LINE_START_X = 100;
|
||||
|
||||
+10
-11
@@ -1,14 +1,13 @@
|
||||
class DateUtil {
|
||||
function DateUtil() {
|
||||
}
|
||||
|
||||
static getYYYYMMDD(date) {
|
||||
// return date.toISOString().slice(0,10);
|
||||
return date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
|
||||
}
|
||||
|
||||
static getHHMMSS(date) {
|
||||
return StringUtil.getNumberStartWithZero(date.getHours(), 2) + ":"
|
||||
+ StringUtil.getNumberStartWithZero(date.getMinutes(), 2) + ":"
|
||||
+ StringUtil.getNumberStartWithZero(date.getSeconds(), 2);
|
||||
}
|
||||
DateUtil.getYYYYMMDD = function(date) {
|
||||
// return date.toISOString().slice(0,10);
|
||||
return date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
|
||||
}
|
||||
|
||||
DateUtil.getHHMMSS = function(date) {
|
||||
return StringUtil.getNumberStartWithZero(date.getHours(), 2) + ":"
|
||||
+ StringUtil.getNumberStartWithZero(date.getMinutes(), 2) + ":"
|
||||
+ StringUtil.getNumberStartWithZero(date.getSeconds(), 2);
|
||||
}
|
||||
+390
-395
@@ -1,458 +1,453 @@
|
||||
class DBConnectManager {
|
||||
function DBConnectManager() {
|
||||
this.path = this.getPath();
|
||||
this.directoryName = this.getDirectoryName(this.path);
|
||||
this.phpPath = this.getPHPPath(this.directoryName);
|
||||
|
||||
constructor() {
|
||||
this.path = this.getPath();
|
||||
this.directoryName = this.getDirectoryName(this.path);
|
||||
this.phpPath = this.getPHPPath(this.directoryName);
|
||||
this.maestroID = 0;
|
||||
this.playerID = 0;
|
||||
this.appName = "";
|
||||
this.dateAndTime = null;
|
||||
}
|
||||
|
||||
this.maestroID = 0;
|
||||
this.playerID = 0;
|
||||
this.appName = "";
|
||||
this.dateAndTime = null;
|
||||
}
|
||||
DBConnectManager.prototype.setMaestroID = function(maestroID) {
|
||||
this.maestroID = maestroID;
|
||||
}
|
||||
|
||||
setMaestroID(maestroID) {
|
||||
this.maestroID = maestroID;
|
||||
}
|
||||
DBConnectManager.prototype.setPlayerID = function(playerID) {
|
||||
this.playerID = playerID;
|
||||
}
|
||||
|
||||
setPlayerID(playerID) {
|
||||
this.playerID = playerID;
|
||||
}
|
||||
DBConnectManager.prototype.setAppName = function(appName) {
|
||||
this.appName = appName;
|
||||
}
|
||||
|
||||
setAppName(appName) {
|
||||
this.appName = appName;
|
||||
}
|
||||
DBConnectManager.prototype.setDateTime = function(date, time) {
|
||||
this.dateAndTime = date + time;
|
||||
}
|
||||
|
||||
setDateTime(date, time) {
|
||||
this.dateAndTime = date + time;
|
||||
}
|
||||
DBConnectManager.prototype.resetDateTime = function() {
|
||||
this.dateAndTime = null;
|
||||
}
|
||||
|
||||
resetDateTime() {
|
||||
this.dateAndTime = null;
|
||||
}
|
||||
DBConnectManager.prototype.getPath = function() {
|
||||
return window.location.pathname;
|
||||
}
|
||||
|
||||
getPath() {
|
||||
return window.location.pathname;
|
||||
}
|
||||
DBConnectManager.prototype.getDirectoryName = function(path) {
|
||||
var pathAndFileNames = path.split("/");
|
||||
return pathAndFileNames[pathAndFileNames.length - 2];
|
||||
}
|
||||
|
||||
getDirectoryName(path) {
|
||||
let pathAndFileNames = path.split("/");
|
||||
return pathAndFileNames[pathAndFileNames.length - 2];
|
||||
}
|
||||
DBConnectManager.prototype.getPHPPath = function(directoryName) {
|
||||
if(directoryName === "test") // mouse_typing/test/
|
||||
return "../src/web/";
|
||||
else // mousetyping/src/web/client/
|
||||
return "../";
|
||||
}
|
||||
|
||||
getPHPPath(directoryName) {
|
||||
if(directoryName === "test") // mouse_typing/test/
|
||||
return "../src/web/";
|
||||
else // mousetyping/src/web/client/
|
||||
return "../";
|
||||
}
|
||||
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) {
|
||||
var replyJSON = JSON.parse(xhr.responseText);
|
||||
|
||||
requestCheckPlayerLogin(maestroName, playerName, enterCode, onSucceededListener, onFailedListener) {
|
||||
let 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);
|
||||
if(replyJSON != null && replyJSON["PlayerID"] != null)
|
||||
onSucceededListener(replyJSON);
|
||||
else
|
||||
onFailedListener(replyJSON);
|
||||
}
|
||||
};
|
||||
xhr.send("maestro_name=" + maestroName + "&name=" + playerName + "&enter_code=" + enterCode);
|
||||
}
|
||||
|
||||
if(replyJSON != null && replyJSON["PlayerID"] != null)
|
||||
onSucceededListener(replyJSON);
|
||||
else
|
||||
onFailedListener(replyJSON);
|
||||
}
|
||||
};
|
||||
xhr.send("maestro_name=" + maestroName + "&name=" + playerName + "&enter_code=" + enterCode);
|
||||
}
|
||||
/*
|
||||
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) {
|
||||
var replyJSON = JSON.parse(xhr.responseText);
|
||||
|
||||
if(replyJSON != null)
|
||||
onSucceededListener(replyJSON);
|
||||
else
|
||||
onFailedListener(replyJSON);
|
||||
}
|
||||
};
|
||||
xhr.send("maestro_id=" + maestroID);
|
||||
}
|
||||
|
||||
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) {
|
||||
var replyJSON = JSON.parse(xhr.responseText);
|
||||
|
||||
if(replyJSON != null)
|
||||
onSucceededListener(replyJSON);
|
||||
else
|
||||
onFailedListener(replyJSON);
|
||||
}
|
||||
};
|
||||
xhr.send("maestro_id=" + maestroID);
|
||||
}
|
||||
*/
|
||||
|
||||
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) {
|
||||
var replyJSON = JSON.parse(xhr.responseText);
|
||||
|
||||
if(replyJSON != null)
|
||||
onSucceededListener(replyJSON);
|
||||
else
|
||||
onFailedListener(replyJSON);
|
||||
}
|
||||
};
|
||||
xhr.send("maestro_id=" + maestroID);
|
||||
}
|
||||
|
||||
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) {
|
||||
var replyJSON = JSON.parse(xhr.responseText);
|
||||
|
||||
if(replyJSON != null)
|
||||
onSucceededListener(replyJSON);
|
||||
else
|
||||
onFailedListener(replyJSON);
|
||||
}
|
||||
};
|
||||
xhr.send("maestro_id=" + maestroID + "&player_id=" + playerID);
|
||||
}
|
||||
|
||||
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) {
|
||||
var replyJSON = JSON.parse(xhr.responseText);
|
||||
|
||||
if(replyJSON != null)
|
||||
onSucceededListener(replyJSON);
|
||||
else
|
||||
onFailedListener(replyJSON);
|
||||
}
|
||||
};
|
||||
xhr.send("maestro_id=" + maestroID + "&player_id=" + playerID);
|
||||
}
|
||||
|
||||
DBConnectManager.prototype.requestPlayerHistory = function(maestroID, date, listener) {
|
||||
var historyRecordManager = new HistoryRecordManager();
|
||||
|
||||
/*
|
||||
requestAppList(maestroID, onSucceededListener, onFailedListener) {
|
||||
let 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);
|
||||
if(isDebugMode()) {
|
||||
this.loadTempPlayerHistory(historyRecordManager);
|
||||
|
||||
if(replyJSON != null)
|
||||
onSucceededListener(replyJSON);
|
||||
else
|
||||
onFailedListener(replyJSON);
|
||||
}
|
||||
};
|
||||
xhr.send("maestro_id=" + maestroID);
|
||||
}
|
||||
if(listener !== null)
|
||||
listener(historyRecordManager);
|
||||
|
||||
requestActiveAppList(maestroID, onSucceededListener, onFailedListener) {
|
||||
let 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);
|
||||
|
||||
if(replyJSON != null)
|
||||
onSucceededListener(replyJSON);
|
||||
else
|
||||
onFailedListener(replyJSON);
|
||||
}
|
||||
};
|
||||
xhr.send("maestro_id=" + maestroID);
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
requestMenuAppList(maestroID, onSucceededListener, onFailedListener) {
|
||||
let 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 self = this;
|
||||
|
||||
if(replyJSON != null)
|
||||
onSucceededListener(replyJSON);
|
||||
else
|
||||
onFailedListener(replyJSON);
|
||||
}
|
||||
};
|
||||
xhr.send("maestro_id=" + maestroID);
|
||||
}
|
||||
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) {
|
||||
var replyJSON = JSON.parse(xhr.responseText);
|
||||
|
||||
requestTypingPracticeAppList(maestroID, playerID, onSucceededListener, onFailedListener) {
|
||||
let 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);
|
||||
|
||||
if(replyJSON != null)
|
||||
onSucceededListener(replyJSON);
|
||||
else
|
||||
onFailedListener(replyJSON);
|
||||
}
|
||||
};
|
||||
xhr.send("maestro_id=" + maestroID + "&player_id=" + playerID);
|
||||
}
|
||||
|
||||
requestTypingTestAppList(maestroID, playerID, onSucceededListener, onFailedListener) {
|
||||
let 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);
|
||||
|
||||
if(replyJSON != null)
|
||||
onSucceededListener(replyJSON);
|
||||
else
|
||||
onFailedListener(replyJSON);
|
||||
}
|
||||
};
|
||||
xhr.send("maestro_id=" + maestroID + "&player_id=" + playerID);
|
||||
}
|
||||
|
||||
requestPlayerHistory(maestroID, date, listener) {
|
||||
let historyRecordManager = new HistoryRecordManager();
|
||||
|
||||
/*
|
||||
if(isDebugMode()) {
|
||||
this.loadTempPlayerHistory(historyRecordManager);
|
||||
|
||||
if(listener !== null)
|
||||
listener(historyRecordManager);
|
||||
|
||||
return;
|
||||
if(replyJSON != null)
|
||||
listener(self.parseJSONtoHistoryRecord(replyJSON));
|
||||
else
|
||||
onFailedListener(replyJSON);
|
||||
}
|
||||
*/
|
||||
};
|
||||
var params = "MaestroID=" + sessionStorageManager.getMaestroID()
|
||||
+ "&AppID=" + sessionStorageManager.getPlayingAppID()
|
||||
+ "&PlayerID=" + sessionStorageManager.getPlayerID()
|
||||
+ "&Date=" + date;
|
||||
xhr.send(params);
|
||||
}
|
||||
|
||||
let self = this;
|
||||
|
||||
let 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);
|
||||
|
||||
if(replyJSON != null)
|
||||
listener(self.parseJSONtoHistoryRecord(replyJSON));
|
||||
else
|
||||
onFailedListener(replyJSON);
|
||||
}
|
||||
};
|
||||
let params = "MaestroID=" + sessionStorageManager.maestroID
|
||||
+ "&AppID=" + sessionStorageManager.playingAppID
|
||||
+ "&PlayerID=" + sessionStorageManager.playerID
|
||||
+ "&Date=" + date;
|
||||
xhr.send(params);
|
||||
}
|
||||
|
||||
parseJSONtoHistoryRecord(json) {
|
||||
let historyRecordManager = new HistoryRecordManager();
|
||||
|
||||
if(typeof json === "undefined")
|
||||
return historyRecordManager;
|
||||
|
||||
if(typeof json.history === "undefined")
|
||||
return historyRecordManager;
|
||||
|
||||
let count = json.history.length;
|
||||
for(let i = 0; i < count; i++) {
|
||||
let record = new HistoryRecord(
|
||||
json.history[i]["Date"],
|
||||
json.history[i]["AppName"],
|
||||
json.history[i]["HighScore"]
|
||||
);
|
||||
historyRecordManager.push(record);
|
||||
}
|
||||
DBConnectManager.prototype.parseJSONtoHistoryRecord = function(json) {
|
||||
var historyRecordManager = new HistoryRecordManager();
|
||||
|
||||
if(typeof json === "undefined")
|
||||
return historyRecordManager;
|
||||
|
||||
if(typeof json.history === "undefined")
|
||||
return historyRecordManager;
|
||||
|
||||
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"]
|
||||
);
|
||||
historyRecordManager.push(record);
|
||||
}
|
||||
|
||||
return historyRecordManager;
|
||||
|
||||
/*
|
||||
var startIndex = 0;
|
||||
var endIndex = jsonRankingList.length;
|
||||
var startIndex = 0;
|
||||
var endIndex = jsonRankingList.length;
|
||||
|
||||
var recordArray = [];
|
||||
for(var i = startIndex; i < endIndex; i++) {
|
||||
var bestRecordRow = [];
|
||||
var strDate = jsonRankingList[i]['Date'];
|
||||
var dateArray = strDate.split("-");
|
||||
var recordDate = new Date(dateArray[0], dateArray[1], dateArray[2]);
|
||||
bestRecordRow[0] = recordDate.getMonth() + "월 " + recordDate.getDate() + "일";
|
||||
bestRecordRow[1] = Math.floor(jsonRankingList[i]['BestRecord']);
|
||||
bestRecordRow[2] = getStageNameForKorean(jsonRankingList[i]['StageName']);
|
||||
// console.log("$BestRecordRow : " + bestRecordRow[0] + ", " + bestRecordRow[1] + ", " + bestRecordRow[2]);
|
||||
var recordArray = [];
|
||||
for(var i = startIndex; i < endIndex; i++) {
|
||||
var bestRecordRow = [];
|
||||
var strDate = jsonRankingList[i]['Date'];
|
||||
var dateArray = strDate.split("-");
|
||||
var recordDate = new Date(dateArray[0], dateArray[1], dateArray[2]);
|
||||
bestRecordRow[0] = recordDate.getMonth() + "월 " + recordDate.getDate() + "일";
|
||||
bestRecordRow[1] = Math.floor(jsonRankingList[i]['BestRecord']);
|
||||
bestRecordRow[2] = getStageNameForKorean(jsonRankingList[i]['StageName']);
|
||||
// console.log("$BestRecordRow : " + bestRecordRow[0] + ", " + bestRecordRow[1] + ", " + bestRecordRow[2]);
|
||||
|
||||
recordArray.push(bestRecordRow);
|
||||
}
|
||||
recordArray.push(bestRecordRow);
|
||||
}
|
||||
|
||||
return recordArray;
|
||||
return recordArray;
|
||||
*/
|
||||
}
|
||||
|
||||
DBConnectManager.prototype.requestRanking = function(type, maestroID, date, time, listener) {
|
||||
var rankingRecordManager = new RankingRecordManager();
|
||||
|
||||
/*
|
||||
if(isDebugMode()) {
|
||||
this.loadTempRanking(rankingRecordManager);
|
||||
|
||||
if(listener !== null)
|
||||
listener(rankingRecordManager);
|
||||
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
requestRanking(type, maestroID, date, time, listener) {
|
||||
let rankingRecordManager = new RankingRecordManager();
|
||||
var self = this;
|
||||
|
||||
/*
|
||||
if(isDebugMode()) {
|
||||
this.loadTempRanking(rankingRecordManager);
|
||||
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) {
|
||||
var replyJSON = JSON.parse(xhr.responseText);
|
||||
|
||||
if(listener !== null)
|
||||
listener(rankingRecordManager);
|
||||
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
let self = this;
|
||||
|
||||
let 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);
|
||||
|
||||
if(replyJSON != null) {
|
||||
listener(type, self.parseJSONtoRankingRecord(type, replyJSON));
|
||||
}
|
||||
else
|
||||
onFailedListener(replyJSON);
|
||||
if(replyJSON != null) {
|
||||
listener(type, self.parseJSONtoRankingRecord(type, replyJSON));
|
||||
}
|
||||
};
|
||||
let params = "MaestroID=" + sessionStorageManager.maestroID
|
||||
+ "&AppID=" + sessionStorageManager.playingAppID
|
||||
+ "&Date=" + date
|
||||
+ "&Time=" + time;
|
||||
xhr.send(params);
|
||||
else
|
||||
onFailedListener(replyJSON);
|
||||
}
|
||||
};
|
||||
var params = "MaestroID=" + sessionStorageManager.getMaestroID()
|
||||
+ "&AppID=" + sessionStorageManager.getPlayingAppID()
|
||||
+ "&Date=" + date
|
||||
+ "&Time=" + time;
|
||||
xhr.send(params);
|
||||
}
|
||||
|
||||
DBConnectManager.prototype.getRankingRecordUrl = function(type) {
|
||||
var rankingRecordURL = this.phpPath;
|
||||
|
||||
switch(type) {
|
||||
case DBConnectManager.TYPE_MY_RANKING_HOUR:
|
||||
case DBConnectManager.TYPE_ALL_RANKING_HOUR:
|
||||
rankingRecordURL += "server/record/ranking_record_hour.php";
|
||||
break;
|
||||
|
||||
case DBConnectManager.TYPE_MY_RANKING_DAY:
|
||||
case DBConnectManager.TYPE_ALL_RANKING_DAY:
|
||||
rankingRecordURL += "server/record/ranking_record_day.php";
|
||||
break;
|
||||
|
||||
case DBConnectManager.TYPE_MY_RANKING_MONTH:
|
||||
case DBConnectManager.TYPE_ALL_RANKING_MONTH:
|
||||
rankingRecordURL += "server/record/ranking_record_month.php";
|
||||
break;
|
||||
}
|
||||
|
||||
getRankingRecordUrl(type) {
|
||||
let rankingRecordURL = this.phpPath;
|
||||
return rankingRecordURL;
|
||||
}
|
||||
|
||||
switch(type) {
|
||||
case DBConnectManager.TYPE_MY_RANKING_HOUR:
|
||||
case DBConnectManager.TYPE_ALL_RANKING_HOUR:
|
||||
rankingRecordURL += "server/record/ranking_record_hour.php";
|
||||
break;
|
||||
|
||||
case DBConnectManager.TYPE_MY_RANKING_DAY:
|
||||
case DBConnectManager.TYPE_ALL_RANKING_DAY:
|
||||
rankingRecordURL += "server/record/ranking_record_day.php";
|
||||
break;
|
||||
|
||||
case DBConnectManager.TYPE_MY_RANKING_MONTH:
|
||||
case DBConnectManager.TYPE_ALL_RANKING_MONTH:
|
||||
rankingRecordURL += "server/record/ranking_record_month.php";
|
||||
break;
|
||||
}
|
||||
|
||||
return rankingRecordURL;
|
||||
}
|
||||
|
||||
parseJSONtoRankingRecord(type, json) {
|
||||
let rankingRecordManager = new RankingRecordManager();
|
||||
|
||||
if(typeof json === "undefined")
|
||||
return rankingRecordManager;
|
||||
|
||||
let replyJSON = null;
|
||||
switch(type) {
|
||||
case DBConnectManager.TYPE_MY_RANKING_HOUR:
|
||||
case DBConnectManager.TYPE_ALL_RANKING_HOUR:
|
||||
replyJSON = json.rankingHour;
|
||||
break;
|
||||
|
||||
case DBConnectManager.TYPE_MY_RANKING_DAY:
|
||||
case DBConnectManager.TYPE_ALL_RANKING_DAY:
|
||||
replyJSON = json.rankingDay;
|
||||
break;
|
||||
|
||||
case DBConnectManager.TYPE_MY_RANKING_MONTH:
|
||||
case DBConnectManager.TYPE_ALL_RANKING_MONTH:
|
||||
replyJSON = json.rankingMonth;
|
||||
break;
|
||||
}
|
||||
|
||||
if(replyJSON === null)
|
||||
return rankingRecordManager;
|
||||
|
||||
let count = replyJSON.length;
|
||||
for(let i = 0; i < count; i++) {
|
||||
let record = new RankingRecord(
|
||||
i + 1,
|
||||
replyJSON[i]["PlayerID"],
|
||||
replyJSON[i]["Name"],
|
||||
replyJSON[i]["HighScore"]
|
||||
);
|
||||
rankingRecordManager.push(record);
|
||||
}
|
||||
DBConnectManager.prototype.parseJSONtoRankingRecord = function(type, json) {
|
||||
var rankingRecordManager = new RankingRecordManager();
|
||||
|
||||
if(typeof json === "undefined")
|
||||
return rankingRecordManager;
|
||||
|
||||
var replyJSON = null;
|
||||
switch(type) {
|
||||
case DBConnectManager.TYPE_MY_RANKING_HOUR:
|
||||
case DBConnectManager.TYPE_ALL_RANKING_HOUR:
|
||||
replyJSON = json.rankingHour;
|
||||
break;
|
||||
|
||||
case DBConnectManager.TYPE_MY_RANKING_DAY:
|
||||
case DBConnectManager.TYPE_ALL_RANKING_DAY:
|
||||
replyJSON = json.rankingDay;
|
||||
break;
|
||||
|
||||
case DBConnectManager.TYPE_MY_RANKING_MONTH:
|
||||
case DBConnectManager.TYPE_ALL_RANKING_MONTH:
|
||||
replyJSON = json.rankingMonth;
|
||||
break;
|
||||
}
|
||||
|
||||
if(replyJSON === null)
|
||||
return rankingRecordManager;
|
||||
|
||||
onFailed(errorMessage) {
|
||||
console.log("failed : " + errorMessage);
|
||||
var count = replyJSON.length;
|
||||
for(var i = 0; i < count; i++) {
|
||||
var record = new RankingRecord(
|
||||
i + 1,
|
||||
replyJSON[i]["PlayerID"],
|
||||
replyJSON[i]["Name"],
|
||||
replyJSON[i]["HighScore"]
|
||||
);
|
||||
rankingRecordManager.push(record);
|
||||
}
|
||||
|
||||
return rankingRecordManager;
|
||||
}
|
||||
|
||||
makeXHRWithParam(url, param, onSucceededListener, onFailedListener) {
|
||||
xhr.onreadystatechange = function() {
|
||||
if(xhr.readyState == 4 && xhr.status == 200) {
|
||||
let replyJSON = JSON.parse(xhr.responseText);
|
||||
|
||||
if(replyJSON != null && replyJSON["PlayerID"] != null)
|
||||
onSucceededListener(replyJSON);
|
||||
else
|
||||
onFailedListener(replyJSON);
|
||||
}
|
||||
DBConnectManager.prototype.onFailed = function(errorMessage) {
|
||||
console.log("failed : " + errorMessage);
|
||||
}
|
||||
|
||||
|
||||
DBConnectManager.prototype.makeXHRWithParam = function(url, param, onSucceededListener, onFailedListener) {
|
||||
xhr.onreadystatechange = function() {
|
||||
if(xhr.readyState == 4 && xhr.status == 200) {
|
||||
var replyJSON = JSON.parse(xhr.responseText);
|
||||
|
||||
if(replyJSON != null && replyJSON["PlayerID"] != null)
|
||||
onSucceededListener(replyJSON);
|
||||
else
|
||||
onFailedListener(replyJSON);
|
||||
}
|
||||
|
||||
return xhr;
|
||||
}
|
||||
|
||||
requestHowToPlay(appID, onSucceededListener, onFailedListener) {
|
||||
let 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);
|
||||
return xhr;
|
||||
}
|
||||
|
||||
if(replyJSON != null && replyJSON["HowToPlay"] != null)
|
||||
onSucceededListener(replyJSON);
|
||||
else
|
||||
onFailedListener(replyJSON);
|
||||
}
|
||||
};
|
||||
xhr.send("AppID=" + appID);
|
||||
}
|
||||
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) {
|
||||
var replyJSON = JSON.parse(xhr.responseText);
|
||||
|
||||
updateTodayBestRecord(maestroID, playerID, appID, record) {
|
||||
let 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(
|
||||
"MaestroID=" + maestroID
|
||||
+ "&PlayerID=" + playerID
|
||||
+ "&AppID=" + appID
|
||||
+ "&BestRecord=" + record
|
||||
);
|
||||
}
|
||||
if(replyJSON != null && replyJSON["HowToPlay"] != null)
|
||||
onSucceededListener(replyJSON);
|
||||
else
|
||||
onFailedListener(replyJSON);
|
||||
}
|
||||
};
|
||||
xhr.send("AppID=" + appID);
|
||||
}
|
||||
|
||||
requestTodayBestRecord(maestroID, playerID, appID, onSucceededListener, onFailedListener) {
|
||||
let 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);
|
||||
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(
|
||||
"MaestroID=" + maestroID
|
||||
+ "&PlayerID=" + playerID
|
||||
+ "&AppID=" + appID
|
||||
+ "&BestRecord=" + record
|
||||
);
|
||||
}
|
||||
|
||||
if(replyJSON != null && replyJSON["BestRecord"] != null)
|
||||
onSucceededListener(replyJSON);
|
||||
else
|
||||
onFailedListener(replyJSON);
|
||||
}
|
||||
};
|
||||
xhr.send(
|
||||
"MaestroID=" + maestroID
|
||||
+ "&PlayerID=" + playerID
|
||||
+ "&AppID=" + appID
|
||||
);
|
||||
}
|
||||
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) {
|
||||
var replyJSON = JSON.parse(xhr.responseText);
|
||||
|
||||
requestAppRanking(maestroID, appID, onSucceededListener, onFailedListener) {
|
||||
let 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);
|
||||
if(replyJSON != null && replyJSON["BestRecord"] != null)
|
||||
onSucceededListener(replyJSON);
|
||||
else
|
||||
onFailedListener(replyJSON);
|
||||
}
|
||||
};
|
||||
xhr.send(
|
||||
"MaestroID=" + maestroID
|
||||
+ "&PlayerID=" + playerID
|
||||
+ "&AppID=" + appID
|
||||
);
|
||||
}
|
||||
|
||||
if(replyJSON != null)
|
||||
onSucceededListener(replyJSON);
|
||||
else
|
||||
onFailedListener(replyJSON);
|
||||
}
|
||||
};
|
||||
xhr.send(
|
||||
"MaestroID=" + maestroID
|
||||
+ "&AppID=" + appID
|
||||
);
|
||||
}
|
||||
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) {
|
||||
var replyJSON = JSON.parse(xhr.responseText);
|
||||
|
||||
if(replyJSON != null)
|
||||
onSucceededListener(replyJSON);
|
||||
else
|
||||
onFailedListener(replyJSON);
|
||||
}
|
||||
};
|
||||
xhr.send(
|
||||
"MaestroID=" + maestroID
|
||||
+ "&AppID=" + appID
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
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));
|
||||
historyRecordManager.push(new HistoryRecord("05/11", "typing_korean_basic", 13040));
|
||||
historyRecordManager.push(new HistoryRecord("05/10", "space_invaders", 15460));
|
||||
historyRecordManager.push(new HistoryRecord("05/09", "typing_english_basic", 14607));
|
||||
historyRecordManager.push(new HistoryRecord("05/08", "typing_korean_basic", 13058));
|
||||
}
|
||||
|
||||
loadTempPlayerHistory(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));
|
||||
historyRecordManager.push(new HistoryRecord("05/11", "typing_korean_basic", 13040));
|
||||
historyRecordManager.push(new HistoryRecord("05/10", "space_invaders", 15460));
|
||||
historyRecordManager.push(new HistoryRecord("05/09", "typing_english_basic", 14607));
|
||||
historyRecordManager.push(new HistoryRecord("05/08", "typing_korean_basic", 13058));
|
||||
}
|
||||
|
||||
loadTempRanking(rankingRecordManager) {
|
||||
rankingRecordManager.push(new RankingRecord(1, 7, "강경모", 4400));
|
||||
rankingRecordManager.push(new RankingRecord(2, 2, "강성태", 3400));
|
||||
rankingRecordManager.push(new RankingRecord(3, 3, "김기덕", 2400));
|
||||
rankingRecordManager.push(new RankingRecord(4, 4, "김남희", 1400));
|
||||
rankingRecordManager.push(new RankingRecord(5, 5, "고봉순", 900));
|
||||
rankingRecordManager.push(new RankingRecord(6, 6, "파르마", 800));
|
||||
rankingRecordManager.push(new RankingRecord(7, 1, "박지상", 700));
|
||||
rankingRecordManager.push(new RankingRecord(8, 8, "신현주", 600));
|
||||
rankingRecordManager.push(new RankingRecord(9, 9, "꼬봉이", 500));
|
||||
rankingRecordManager.push(new RankingRecord(10, 10, "거북이", 400));
|
||||
rankingRecordManager.push(new RankingRecord(11, 11, "다람쥐", 300));
|
||||
rankingRecordManager.push(new RankingRecord(12, 12, "사시미", 200));
|
||||
rankingRecordManager.push(new RankingRecord(13, 13, "태권도", 100));
|
||||
rankingRecordManager.push(new RankingRecord(14, 14, "합기도", 40));
|
||||
rankingRecordManager.push(new RankingRecord(15, 15, "우습지", 10));
|
||||
rankingRecordManager.push(new RankingRecord(16, 16, "하하하", 4));
|
||||
}
|
||||
|
||||
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));
|
||||
rankingRecordManager.push(new RankingRecord(4, 4, "김남희", 1400));
|
||||
rankingRecordManager.push(new RankingRecord(5, 5, "고봉순", 900));
|
||||
rankingRecordManager.push(new RankingRecord(6, 6, "파르마", 800));
|
||||
rankingRecordManager.push(new RankingRecord(7, 1, "박지상", 700));
|
||||
rankingRecordManager.push(new RankingRecord(8, 8, "신현주", 600));
|
||||
rankingRecordManager.push(new RankingRecord(9, 9, "꼬봉이", 500));
|
||||
rankingRecordManager.push(new RankingRecord(10, 10, "거북이", 400));
|
||||
rankingRecordManager.push(new RankingRecord(11, 11, "다람쥐", 300));
|
||||
rankingRecordManager.push(new RankingRecord(12, 12, "사시미", 200));
|
||||
rankingRecordManager.push(new RankingRecord(13, 13, "태권도", 100));
|
||||
rankingRecordManager.push(new RankingRecord(14, 14, "합기도", 40));
|
||||
rankingRecordManager.push(new RankingRecord(15, 15, "우습지", 10));
|
||||
rankingRecordManager.push(new RankingRecord(16, 16, "하하하", 4));
|
||||
}
|
||||
|
||||
DBConnectManager.TYPE_MY_RANKING_HOUR = 0;
|
||||
|
||||
@@ -1,38 +1,38 @@
|
||||
class GameOverText extends Phaser.Text {
|
||||
GameOverText.prototype = Object.create(Phaser.Text.prototype);
|
||||
GameOverText.constructor = GameOverText;
|
||||
|
||||
constructor() {
|
||||
super(
|
||||
game,
|
||||
game.world.width / 2,
|
||||
game.world.height / 2 - GameOverText.MOVE_AMOUNT_PX,
|
||||
"게임 오버",
|
||||
GameOverText.DEFAULT_TEXT_FONT
|
||||
);
|
||||
// super(game, 600, 300, "게임 오버", GameOverText.DEFAULT_TEXT_FONT);
|
||||
function GameOverText() {
|
||||
Phaser.Text.call(
|
||||
this, game,
|
||||
game.world.width / 2,
|
||||
game.world.height / 2 - GameOverText.MOVE_AMOUNT_PX,
|
||||
"게임 오버",
|
||||
GameOverText.DEFAULT_TEXT_FONT
|
||||
);
|
||||
// super(game, 600, 300, "게임 오버", GameOverText.DEFAULT_TEXT_FONT);
|
||||
|
||||
this.anchor.set(0.5);
|
||||
this.inputEnabled = false;
|
||||
this.anchor.set(0.5);
|
||||
this.inputEnabled = false;
|
||||
|
||||
var grd = this.context.createLinearGradient(0, 0, 0, this.height);
|
||||
grd.addColorStop(0, '#FFD68E');
|
||||
grd.addColorStop(1, '#B34C00');
|
||||
this.fill = grd;
|
||||
// this.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
this.stroke = '#000';
|
||||
this.strokeThickness = 10;
|
||||
var grd = this.context.createLinearGradient(0, 0, 0, this.height);
|
||||
grd.addColorStop(0, '#FFD68E');
|
||||
grd.addColorStop(1, '#B34C00');
|
||||
this.fill = grd;
|
||||
// this.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
this.stroke = '#000';
|
||||
this.strokeThickness = 10;
|
||||
|
||||
|
||||
this.alpha = 0;
|
||||
let tweenAlpha = game.add.tween(this);
|
||||
tweenAlpha.to( { alpha: 1 }, GameOverText.TWEEN_ALPHA_TIME, Phaser.Easing.Linear.None, true);
|
||||
this.alpha = 0;
|
||||
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);
|
||||
tweenMove.to( { y: game.world.height / 2 }, GameOverText.TWEEN_MOVE_TIME, Phaser.Easing.Bounce.Out, true);
|
||||
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);
|
||||
};
|
||||
game.add.existing(this);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
GameOverText.DEFAULT_TEXT_FONT = {
|
||||
font: "bold 100px Arial",
|
||||
|
||||
+36
-39
@@ -1,50 +1,47 @@
|
||||
class HeartGauge {
|
||||
function HeartGauge(heartManager) {
|
||||
this.heartManager = heartManager;
|
||||
this.hearts = [];
|
||||
|
||||
constructor(heartManager) {
|
||||
this.heartManager = heartManager;
|
||||
this.hearts = [];
|
||||
var self = this;
|
||||
this.heartManager.addOnChangeCountListener(
|
||||
function() { self.onChangeCountListener(); }
|
||||
);
|
||||
|
||||
let self = this;
|
||||
this.heartManager.addOnChangeCountListener(
|
||||
function() { self.onChangeCountListener(); }
|
||||
);
|
||||
this.heartManager.addOnChangeMaxCountListener(
|
||||
function() { self.onChangeMaxCountListener(); }
|
||||
);
|
||||
|
||||
this.heartManager.addOnChangeMaxCountListener(
|
||||
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");
|
||||
heart.anchor.set(0.5);
|
||||
heart.scale.set(HeartGauge.HEART_SCALE);
|
||||
heart.alpha = 0;
|
||||
this.hearts.push(heart);
|
||||
}
|
||||
};
|
||||
|
||||
onChangeCountListener() {
|
||||
this.updateHearts();
|
||||
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;
|
||||
this.hearts.push(heart);
|
||||
}
|
||||
};
|
||||
|
||||
onChangeMaxCountListener() {
|
||||
this.updateHearts();
|
||||
}
|
||||
HeartGauge.prototype.onChangeCountListener = function() {
|
||||
this.updateHearts();
|
||||
}
|
||||
|
||||
start() {
|
||||
this.updateHearts();
|
||||
}
|
||||
HeartGauge.prototype.onChangeMaxCountListener = function() {
|
||||
this.updateHearts();
|
||||
}
|
||||
|
||||
updateHearts() {
|
||||
for(let i = 0; i < this.heartManager.getMaxCount(); i++) {
|
||||
if(i < this.heartManager.getCount())
|
||||
this.hearts[i].loadTexture("heart_full");
|
||||
else
|
||||
this.hearts[i].loadTexture("heart_empty");
|
||||
HeartGauge.prototype.start = function() {
|
||||
this.updateHearts();
|
||||
}
|
||||
|
||||
this.hearts[i].alpha = 1;
|
||||
}
|
||||
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
|
||||
this.hearts[i].loadTexture("heart_empty");
|
||||
|
||||
this.hearts[i].alpha = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,105 +1,102 @@
|
||||
class HeartManager {
|
||||
function HeartManager() {
|
||||
this.countHearts = HeartManager.DEFAULT_COUNT;
|
||||
this.countMaxHearts = HeartManager.DEFAULT_COUNT;
|
||||
|
||||
constructor() {
|
||||
this.countHearts = HeartManager.DEFAULT_COUNT;
|
||||
this.countMaxHearts = HeartManager.DEFAULT_COUNT;
|
||||
this.onChangeCountListeners = [];
|
||||
this.onChangeMaxCountListeners = [];
|
||||
this.onChangeGameOverListeners = [];
|
||||
}
|
||||
|
||||
this.onChangeCountListeners = [];
|
||||
this.onChangeMaxCountListeners = [];
|
||||
this.onChangeGameOverListeners = [];
|
||||
}
|
||||
|
||||
callListener(functionArray) {
|
||||
if(functionArray.length > 0) {
|
||||
for(let i = 0; i < functionArray.length; i++) {
|
||||
functionArray[i](this.score);
|
||||
}
|
||||
HeartManager.prototype.callListener = function(functionArray) {
|
||||
if(functionArray.length > 0) {
|
||||
for(var i = 0; i < functionArray.length; i++) {
|
||||
functionArray[i](this.score);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addOnChangeCountListener(onChangeFunction) {
|
||||
this.onChangeCountListeners.push(onChangeFunction);
|
||||
}
|
||||
HeartManager.prototype.addOnChangeCountListener = function(onChangeFunction) {
|
||||
this.onChangeCountListeners.push(onChangeFunction);
|
||||
}
|
||||
|
||||
removeOnChangeCountListener(onChangeFunction) {
|
||||
let itemIndex = this.onChangeCountListeners.indexOf(onChangeFunction);
|
||||
if(itemIndex > -1)
|
||||
this.onChangeCountListeners.splice(itemIndex, 1);
|
||||
}
|
||||
HeartManager.prototype.removeOnChangeCountListener = function(onChangeFunction) {
|
||||
var itemIndex = this.onChangeCountListeners.indexOf(onChangeFunction);
|
||||
if(itemIndex > -1)
|
||||
this.onChangeCountListeners.splice(itemIndex, 1);
|
||||
}
|
||||
|
||||
addOnChangeMaxCountListener(onChangeMaxFunction) {
|
||||
this.onChangeMaxCountListeners.push(onChangeMaxFunction);
|
||||
}
|
||||
HeartManager.prototype.addOnChangeMaxCountListener = function(onChangeMaxFunction) {
|
||||
this.onChangeMaxCountListeners.push(onChangeMaxFunction);
|
||||
}
|
||||
|
||||
removeOnChangeMaxCountListener(onChangeMaxFunction) {
|
||||
let itemIndex = this.onChangeMaxCountListeners.indexOf(onChangeMaxFunction);
|
||||
if(itemIndex > -1)
|
||||
this.onChangeMaxCountListeners.splice(itemIndex, 1);
|
||||
}
|
||||
HeartManager.prototype.removeOnChangeMaxCountListener = function(onChangeMaxFunction) {
|
||||
var itemIndex = this.onChangeMaxCountListeners.indexOf(onChangeMaxFunction);
|
||||
if(itemIndex > -1)
|
||||
this.onChangeMaxCountListeners.splice(itemIndex, 1);
|
||||
}
|
||||
|
||||
addOnChangeGameOverListener(onChangeGameOverFunction) {
|
||||
this.onChangeGameOverListeners.push(onChangeGameOverFunction);
|
||||
}
|
||||
HeartManager.prototype.addOnChangeGameOverListener = function(onChangeGameOverFunction) {
|
||||
this.onChangeGameOverListeners.push(onChangeGameOverFunction);
|
||||
}
|
||||
|
||||
removeOnChangeHighScoreListener(onChangeGameOverFunction) {
|
||||
let itemIndex = this.onChangeGameOverListeners.indexOf(onChangeGameOverFunction);
|
||||
if(itemIndex > -1)
|
||||
this.onChangeGameOverListeners.splice(itemIndex, 1);
|
||||
}
|
||||
HeartManager.prototype.removeOnChangeHighScoreListener = function(onChangeGameOverFunction) {
|
||||
var itemIndex = this.onChangeGameOverListeners.indexOf(onChangeGameOverFunction);
|
||||
if(itemIndex > -1)
|
||||
this.onChangeGameOverListeners.splice(itemIndex, 1);
|
||||
}
|
||||
|
||||
removeAllListeners() {
|
||||
this.onChangeCountListeners = [];
|
||||
this.onChangeMaxCountListeners = [];
|
||||
this.onChangeGameOverListeners = [];
|
||||
}
|
||||
HeartManager.prototype.removeAllListeners = function() {
|
||||
this.onChangeCountListeners = [];
|
||||
this.onChangeMaxCountListeners = [];
|
||||
this.onChangeGameOverListeners = [];
|
||||
}
|
||||
|
||||
|
||||
setCount(amount) {
|
||||
let beforeCountHearts = this.countHearts;
|
||||
this.countHearts = amount;
|
||||
if(this.countHearts < 0)
|
||||
this.countHearts = 0;
|
||||
else if(this.countHearts > this.countMaxHearts)
|
||||
this.countHearts = this.countMaxHearts;
|
||||
HeartManager.prototype.setCount = function(amount) {
|
||||
var beforeCountHearts = this.countHearts;
|
||||
this.countHearts = amount;
|
||||
if(this.countHearts < 0)
|
||||
this.countHearts = 0;
|
||||
else if(this.countHearts > this.countMaxHearts)
|
||||
this.countHearts = this.countMaxHearts;
|
||||
|
||||
if(beforeCountHearts !== this.countHearts)
|
||||
this.callListener(this.onChangeCountListeners);
|
||||
if(beforeCountHearts !== this.countHearts)
|
||||
this.callListener(this.onChangeCountListeners);
|
||||
|
||||
if(this.countHearts === 0)
|
||||
this.callListener(this.onChangeGameOverListeners);
|
||||
}
|
||||
if(this.countHearts === 0)
|
||||
this.callListener(this.onChangeGameOverListeners);
|
||||
}
|
||||
|
||||
getCount() {
|
||||
return this.countHearts;
|
||||
}
|
||||
HeartManager.prototype.getCount = function() {
|
||||
return this.countHearts;
|
||||
}
|
||||
|
||||
setMaxCount(amount) {
|
||||
let beforeCountHearts = this.countMaxHearts;
|
||||
this.countMaxHearts = amount;
|
||||
if(this.countMaxHearts > HeartManager.HEART_MAX_COUNT)
|
||||
this.countMaxHearts = HeartManager.HEART_MAX_COUNT;
|
||||
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;
|
||||
|
||||
if(beforeCountHearts !== this.countMaxHearts)
|
||||
this.callListener(this.onChangeMaxCountListeners);
|
||||
if(beforeCountHearts !== this.countMaxHearts)
|
||||
this.callListener(this.onChangeMaxCountListeners);
|
||||
|
||||
if(this.countHearts > this.countMaxHearts)
|
||||
this.setCount(this.countMaxHearts);
|
||||
}
|
||||
if(this.countHearts > this.countMaxHearts)
|
||||
this.setCount(this.countMaxHearts);
|
||||
}
|
||||
|
||||
getMaxCount() {
|
||||
return this.countMaxHearts;
|
||||
}
|
||||
HeartManager.prototype.getMaxCount = function() {
|
||||
return this.countMaxHearts;
|
||||
}
|
||||
|
||||
addHearts(amount) {
|
||||
this.setCount(this.countHearts + amount);
|
||||
|
||||
}
|
||||
|
||||
breakHearts(amount) {
|
||||
this.addHearts(-1 * amount);
|
||||
}
|
||||
HeartManager.prototype.addHearts = function(amount) {
|
||||
this.setCount(this.countHearts + 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) {
|
||||
this.date = date;
|
||||
this.appName = appName;
|
||||
this.bestRecord = bestRecord;
|
||||
}
|
||||
function HistoryRecord(date, appName, bestRecord) {
|
||||
this.date = date;
|
||||
this.appName = appName;
|
||||
this.bestRecord = bestRecord;
|
||||
}
|
||||
|
||||
|
||||
|
||||
class HistoryRecordManager {
|
||||
function HistoryRecordManager() {
|
||||
this.clear();
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.clear();
|
||||
HistoryRecordManager.prototype.push = function(HistoryRecord) {
|
||||
this.historyRecords.push(HistoryRecord);
|
||||
|
||||
this.minValueOfRecord = this.minValueOfArray();
|
||||
this.maxValueOfRecord = this.maxValueOfArray();
|
||||
}
|
||||
|
||||
HistoryRecordManager.prototype.clear = function() {
|
||||
this.historyRecords = [];
|
||||
|
||||
this.minValueOfRecord = 0;
|
||||
this.maxValueOfRecord = 0;
|
||||
}
|
||||
|
||||
HistoryRecordManager.prototype.getCount = function() {
|
||||
return this.historyRecords.length;
|
||||
}
|
||||
|
||||
HistoryRecordManager.prototype.getAt = function(index) {
|
||||
return this.historyRecords[index];
|
||||
}
|
||||
|
||||
HistoryRecordManager.prototype.getDateAt = function(index) {
|
||||
return this.historyRecords[index].date;
|
||||
}
|
||||
|
||||
HistoryRecordManager.prototype.getAppNameAt = function(index) {
|
||||
return this.historyRecords[index].appName;
|
||||
}
|
||||
|
||||
HistoryRecordManager.prototype.getBestRecordAt = function(index) {
|
||||
return this.historyRecords[index].bestRecord;
|
||||
}
|
||||
|
||||
HistoryRecordManager.prototype.minValueOfArray = function() {
|
||||
var numberArray = this.getBestRecordArray(this.historyRecords);
|
||||
return Math.min.apply(Math, numberArray);
|
||||
}
|
||||
|
||||
HistoryRecordManager.prototype.maxValueOfArray = function() {
|
||||
var numberArray = this.getBestRecordArray(this.historyRecords);
|
||||
return Math.max.apply(Math, numberArray);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
HistoryRecordManager.prototype.getBestRecordArray = function() {
|
||||
var numberArray = [];
|
||||
for(var data of this.historyRecords) {
|
||||
numberArray.push(data.bestRecord);
|
||||
}
|
||||
|
||||
push(HistoryRecord) {
|
||||
this.historyRecords.push(HistoryRecord);
|
||||
|
||||
this.minValueOfRecord = this.minValueOfArray();
|
||||
this.maxValueOfRecord = this.maxValueOfArray();
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.historyRecords = [];
|
||||
|
||||
this.minValueOfRecord = 0;
|
||||
this.maxValueOfRecord = 0;
|
||||
}
|
||||
|
||||
get count() {
|
||||
return this.historyRecords.length;
|
||||
}
|
||||
|
||||
getAt(index) {
|
||||
return this.historyRecords[index];
|
||||
}
|
||||
|
||||
getDateAt(index) {
|
||||
return this.historyRecords[index].date;
|
||||
}
|
||||
|
||||
getAppNameAt(index) {
|
||||
return this.historyRecords[index].appName;
|
||||
}
|
||||
|
||||
getBestRecordAt(index) {
|
||||
return this.historyRecords[index].bestRecord;
|
||||
}
|
||||
|
||||
minValueOfArray() {
|
||||
let numberArray = this.getBestRecordArray(this.historyRecords);
|
||||
return Math.min.apply(Math, numberArray);
|
||||
}
|
||||
|
||||
maxValueOfArray() {
|
||||
let numberArray = this.getBestRecordArray(this.historyRecords);
|
||||
return Math.max.apply(Math, numberArray);
|
||||
}
|
||||
|
||||
underValueForGraph() {
|
||||
let minNumberOfDigits = NumberUtil.numberOfDigits(this.minValueOfRecord);
|
||||
let 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 =
|
||||
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) {
|
||||
numberArray.push(data.bestRecord);
|
||||
}
|
||||
return numberArray;
|
||||
}
|
||||
|
||||
|
||||
return numberArray;
|
||||
}
|
||||
+18
-24
@@ -1,27 +1,21 @@
|
||||
/////////////////////////////
|
||||
// How to play text
|
||||
|
||||
class HowToPlay {
|
||||
|
||||
constructor() {
|
||||
this.howToPlayText = game.add.text(
|
||||
game.world.centerX, game.world.centerY - HowToPlay.TEXT_OFFSET_X,
|
||||
"", this.getFontStyle()
|
||||
);
|
||||
this.howToPlayText.anchor.set(0.5);
|
||||
this.howToPlayText.stroke = "#333";
|
||||
this.howToPlayText.strokeThickness = 3;
|
||||
this.howToPlayText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
}
|
||||
|
||||
printHowToPlay(text) {
|
||||
this.howToPlayText.text = text;
|
||||
}
|
||||
|
||||
getFontStyle() {
|
||||
return { font: "32px Arial", fill: "#fff" };
|
||||
}
|
||||
|
||||
function HowToPlay(x, y) {
|
||||
this.howToPlayText = game.add.text(
|
||||
game.world.centerX, game.world.centerY - HowToPlay.TEXT_OFFSET_X,
|
||||
"", this.getFontStyle()
|
||||
);
|
||||
this.howToPlayText.anchor.set(0.5);
|
||||
this.howToPlayText.stroke = "#333";
|
||||
this.howToPlayText.strokeThickness = 3;
|
||||
this.howToPlayText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
}
|
||||
|
||||
HowToPlay.prototype.printHowToPlay = function(text) {
|
||||
this.howToPlayText.text = text;
|
||||
}
|
||||
|
||||
HowToPlay.prototype.getFontStyle = function() {
|
||||
return { font: "32px Arial", fill: "#fff" };
|
||||
}
|
||||
|
||||
|
||||
HowToPlay.TEXT_OFFSET_X = 200;
|
||||
@@ -1,37 +1,36 @@
|
||||
class InputTypeText {
|
||||
function InputTypeText(x, y) {
|
||||
var bmd = game.add.bitmapData(400, 50);
|
||||
var myInput = game.add.sprite(x, y, bmd);
|
||||
|
||||
constructor(x, y) {
|
||||
var bmd = game.add.bitmapData(400, 50);
|
||||
var myInput = game.add.sprite(x, y, bmd);
|
||||
myInput.canvasInput = new CanvasInput({
|
||||
canvas: bmd.canvas,
|
||||
fontSize: 30,
|
||||
fontFamily: 'Arial',
|
||||
fontColor: '#212121',
|
||||
fontWeight: 'bold',
|
||||
width: 400,
|
||||
padding: 8,
|
||||
borderWidth: 1,
|
||||
borderColor: '#000',
|
||||
borderRadius: 3,
|
||||
boxShadow: '1px 1px 0px #fff',
|
||||
innerShadow: '0px 0px 5px rgba(0, 0, 0, 0.5)',
|
||||
placeHolder: 'Enter message here...'
|
||||
});
|
||||
myInput.inputEnabled = true;
|
||||
myInput.input.useHandCursor = true;
|
||||
myInput.events.onInputUp.add(
|
||||
(function(sprite) {
|
||||
sprite.canvasInput.focus();
|
||||
}).bind(this),
|
||||
this
|
||||
);
|
||||
|
||||
myInput.canvasInput = new CanvasInput({
|
||||
canvas: bmd.canvas,
|
||||
fontSize: 30,
|
||||
fontFamily: 'Arial',
|
||||
fontColor: '#212121',
|
||||
fontWeight: 'bold',
|
||||
width: 400,
|
||||
padding: 8,
|
||||
borderWidth: 1,
|
||||
borderColor: '#000',
|
||||
borderRadius: 3,
|
||||
boxShadow: '1px 1px 0px #fff',
|
||||
innerShadow: '0px 0px 5px rgba(0, 0, 0, 0.5)',
|
||||
placeHolder: 'Enter message here...'
|
||||
});
|
||||
myInput.inputEnabled = true;
|
||||
myInput.input.useHandCursor = true;
|
||||
myInput.events.onInputUp.add(this.inputFocus, this);
|
||||
|
||||
return myInput;
|
||||
}
|
||||
|
||||
inputFocus(sprite){
|
||||
sprite.canvasInput.focus();
|
||||
}
|
||||
return myInput;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* CanvasInput v1.2.0
|
||||
* https://goldfirestudios.com/blog/108/CanvasInput-HTML5-Canvas-Text-Input
|
||||
|
||||
+17
-17
@@ -1,24 +1,24 @@
|
||||
class NumberUtil {
|
||||
function NumberUtil() {
|
||||
}
|
||||
|
||||
static numberWithCommas(x) {
|
||||
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
||||
}
|
||||
|
||||
static numberOfDigits(number) {
|
||||
if(number === 1000)
|
||||
return 4;
|
||||
NumberUtil.numberWithCommas = function(x) {
|
||||
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
||||
}
|
||||
|
||||
return Math.floor(Math.log(number) / Math.LN10 + 1); // bug : 1000 -> expected 4 but 3
|
||||
}
|
||||
NumberUtil.numberOfDigits = function(number) {
|
||||
if(number === 1000)
|
||||
return 4;
|
||||
|
||||
static getRecordText(value) {
|
||||
let number = Math.floor(value);
|
||||
let numberWithCommas = NumberUtil.numberWithCommas(number);
|
||||
return Math.floor(Math.log(number) / Math.LN10 + 1); // bug : 1000 -> expected 4 but 3
|
||||
}
|
||||
|
||||
if(isTypingGame())
|
||||
return numberWithCommas + " 타";
|
||||
else
|
||||
return numberWithCommas + " 점";
|
||||
}
|
||||
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) {
|
||||
this.rank = rank;
|
||||
this.playerID = playerID;
|
||||
this.playerName = playerName;
|
||||
this.bestRecord = bestRecord;
|
||||
}
|
||||
function RankingRecord(rank, playerID, playerName, bestRecord) {
|
||||
this.rank = rank;
|
||||
this.playerID = playerID;
|
||||
this.playerName = playerName;
|
||||
this.bestRecord = bestRecord;
|
||||
}
|
||||
|
||||
|
||||
function RankingRecordManager() {
|
||||
this.clear();
|
||||
}
|
||||
|
||||
class RankingRecordManager {
|
||||
RankingRecordManager.prototype.push = function(RankingRecord) {
|
||||
this.rankingRecords.push(RankingRecord);
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.clear();
|
||||
}
|
||||
RankingRecordManager.prototype.clear = function() {
|
||||
this.rankingRecords = [];
|
||||
}
|
||||
|
||||
push(RankingRecord) {
|
||||
this.rankingRecords.push(RankingRecord);
|
||||
}
|
||||
RankingRecordManager.prototype.getCount = function() {
|
||||
return this.rankingRecords.length;
|
||||
}
|
||||
|
||||
clear() {
|
||||
this.rankingRecords = [];
|
||||
}
|
||||
RankingRecordManager.prototype.getAt = function(index) {
|
||||
return this.rankingRecords[index];
|
||||
}
|
||||
|
||||
get count() {
|
||||
return this.rankingRecords.length;
|
||||
}
|
||||
RankingRecordManager.prototype.getRankAt = function(index) {
|
||||
return this.rankingRecords[index].rank;
|
||||
}
|
||||
|
||||
getAt(index) {
|
||||
return this.rankingRecords[index];
|
||||
}
|
||||
RankingRecordManager.prototype.getPlayerIDAt = function(index) {
|
||||
return this.rankingRecords[index].playerID;
|
||||
}
|
||||
|
||||
getRankAt(index) {
|
||||
return this.rankingRecords[index].rank;
|
||||
}
|
||||
|
||||
getPlayerIDAt(index) {
|
||||
return this.rankingRecords[index].playerID;
|
||||
}
|
||||
|
||||
getPlayerNameAt(index) {
|
||||
return this.rankingRecords[index].playerName;
|
||||
}
|
||||
|
||||
getBestRecordAt(index) {
|
||||
return this.rankingRecords[index].bestRecord;
|
||||
}
|
||||
RankingRecordManager.prototype.getPlayerNameAt = function(index) {
|
||||
return this.rankingRecords[index].playerName;
|
||||
}
|
||||
|
||||
RankingRecordManager.prototype.getBestRecordAt = function(index) {
|
||||
return this.rankingRecords[index].bestRecord;
|
||||
}
|
||||
+22
-25
@@ -1,35 +1,32 @@
|
||||
class ScoreBoard {
|
||||
function ScoreBoard() {
|
||||
var fontStyle = ScoreBoard.DEFAULT_TEXT_FONT;
|
||||
|
||||
constructor() {
|
||||
let fontStyle = ScoreBoard.DEFAULT_TEXT_FONT;
|
||||
fontStyle.align = "right";
|
||||
fontStyle.boundsAlignH = "right";
|
||||
this.label = game.add.text(0, 0, "점수 : ", fontStyle)
|
||||
.setTextBounds(0, 0, game.world.width / 2, ScoreBoard.FONT_HEIGHT_PX);
|
||||
|
||||
fontStyle.align = "right";
|
||||
fontStyle.boundsAlignH = "right";
|
||||
this.label = game.add.text(0, 0, "점수 : ", fontStyle)
|
||||
.setTextBounds(0, 0, game.world.width / 2, ScoreBoard.FONT_HEIGHT_PX);
|
||||
fontStyle.align = "left";
|
||||
fontStyle.boundsAlignH = "left";
|
||||
this.scoreText = game.add.text(game.world.width / 2, 0, "0", fontStyle)
|
||||
.setTextBounds(0, 0, game.world.width / 2, ScoreBoard.FONT_HEIGHT_PX);
|
||||
|
||||
fontStyle.align = "left";
|
||||
fontStyle.boundsAlignH = "left";
|
||||
this.scoreText = game.add.text(game.world.width / 2, 0, "0", fontStyle)
|
||||
.setTextBounds(0, 0, game.world.width / 2, ScoreBoard.FONT_HEIGHT_PX);
|
||||
// var grd = this.label.context.createLinearGradient(0, 0, 0, ScoreBoard.FONT_HEIGHT_PX);
|
||||
// grd.addColorStop(0, '#8ED6FF');
|
||||
// grd.addColorStop(1, '#004CB3');
|
||||
// this.label.fill = grd;
|
||||
// this.scoreText.fill = grd;
|
||||
|
||||
// var grd = this.label.context.createLinearGradient(0, 0, 0, ScoreBoard.FONT_HEIGHT_PX);
|
||||
// grd.addColorStop(0, '#8ED6FF');
|
||||
// grd.addColorStop(1, '#004CB3');
|
||||
// this.label.fill = grd;
|
||||
// this.scoreText.fill = grd;
|
||||
|
||||
// this.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
// this.label.stroke = '#000';
|
||||
// this.label.strokeThickness = 3;
|
||||
};
|
||||
|
||||
printScore(score) {
|
||||
this.scoreText.text = score;
|
||||
}
|
||||
// this.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
// this.label.stroke = '#000';
|
||||
// this.label.strokeThickness = 3;
|
||||
};
|
||||
|
||||
ScoreBoard.prototype.printScore = function(score) {
|
||||
this.scoreText.text = score;
|
||||
}
|
||||
|
||||
|
||||
ScoreBoard.FONT_HEIGHT_PX = 70;
|
||||
|
||||
ScoreBoard.DEFAULT_TEXT_FONT = {
|
||||
|
||||
@@ -1,85 +1,81 @@
|
||||
class ScoreManager {
|
||||
function ScoreManager() {
|
||||
this.onChangeScoreListeners = [];
|
||||
this.onChangeHighScoreListeners = [];
|
||||
|
||||
constructor() {
|
||||
this.onChangeScoreListeners = [];
|
||||
this.onChangeHighScoreListeners = [];
|
||||
this.resetScore();
|
||||
}
|
||||
|
||||
this.resetScore();
|
||||
}
|
||||
ScoreManager.prototype.resetScore = function() {
|
||||
// this.score = Number(sessionStorageManager.record);
|
||||
this.score = 0;
|
||||
sessionStorageManager.record = this.score;
|
||||
|
||||
resetScore() {
|
||||
// this.score = Number(sessionStorageManager.record);
|
||||
this.score = 0;
|
||||
sessionStorageManager.record = this.score;
|
||||
if(sessionStorageManager.bestRecord === null)
|
||||
this.highScore = 0;
|
||||
else
|
||||
this.highScore = Number(sessionStorageManager.bestRecord);
|
||||
}
|
||||
|
||||
if(sessionStorageManager.bestRecord === null)
|
||||
this.highScore = 0;
|
||||
else
|
||||
this.highScore = Number(sessionStorageManager.bestRecord);
|
||||
}
|
||||
|
||||
callListener(functionArray) {
|
||||
if(functionArray.length > 0) {
|
||||
for(let i = 0; i < functionArray.length; i++) {
|
||||
functionArray[i](this.score);
|
||||
}
|
||||
ScoreManager.prototype.callListener = function(functionArray) {
|
||||
if(functionArray.length > 0) {
|
||||
for(var i = 0; i < functionArray.length; i++) {
|
||||
functionArray[i](this.score);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addOnChangeScoreListener(onChangeFunction) {
|
||||
this.onChangeScoreListeners.push(onChangeFunction);
|
||||
}
|
||||
ScoreManager.prototype.addOnChangeScoreListener = function(onChangeFunction) {
|
||||
this.onChangeScoreListeners.push(onChangeFunction);
|
||||
}
|
||||
|
||||
removeOnChangeScoreListener(onChangeFunction) {
|
||||
let itemIndex = this.onChangeScoreListeners.indexOf(onChangeFunction);
|
||||
if(itemIndex > -1)
|
||||
this.onChangeScoreListeners.splice(itemIndex, 1);
|
||||
}
|
||||
ScoreManager.prototype.removeOnChangeScoreListener = function(onChangeFunction) {
|
||||
var itemIndex = this.onChangeScoreListeners.indexOf(onChangeFunction);
|
||||
if(itemIndex > -1)
|
||||
this.onChangeScoreListeners.splice(itemIndex, 1);
|
||||
}
|
||||
|
||||
addOnChangeHighScoreListener(onChangeHighScoreFunction) {
|
||||
this.onChangeHighScoreListeners.push(onChangeHighScoreFunction);
|
||||
}
|
||||
ScoreManager.prototype.addOnChangeHighScoreListener = function(onChangeHighScoreFunction) {
|
||||
this.onChangeHighScoreListeners.push(onChangeHighScoreFunction);
|
||||
}
|
||||
|
||||
removeOnChangeHighScoreListener(onChangeHighScoreFunction) {
|
||||
let itemIndex = this.onChangeHighScoreListeners.indexOf(onChangeHighScoreFunction);
|
||||
if(itemIndex > -1)
|
||||
this.onChangeHighScoreListeners.splice(itemIndex, 1);
|
||||
}
|
||||
ScoreManager.prototype.removeOnChangeHighScoreListener = function(onChangeHighScoreFunction) {
|
||||
var itemIndex = this.onChangeHighScoreListeners.indexOf(onChangeHighScoreFunction);
|
||||
if(itemIndex > -1)
|
||||
this.onChangeHighScoreListeners.splice(itemIndex, 1);
|
||||
}
|
||||
|
||||
removeAllListeners() {
|
||||
this.onChangeScoreListeners = [];
|
||||
this.onChangeHighScoreListeners = [];
|
||||
}
|
||||
ScoreManager.prototype.removeAllListeners = function() {
|
||||
this.onChangeScoreListeners = [];
|
||||
this.onChangeHighScoreListeners = [];
|
||||
}
|
||||
|
||||
|
||||
getScore() {
|
||||
return this.score;
|
||||
}
|
||||
ScoreManager.prototype.getScore = function() {
|
||||
return this.score;
|
||||
}
|
||||
|
||||
getHighScore() {
|
||||
return this.highScore;
|
||||
}
|
||||
ScoreManager.prototype.getHighScore = function() {
|
||||
return this.highScore;
|
||||
}
|
||||
|
||||
|
||||
plusScore(amount) {
|
||||
this.setScore(this.score + amount);
|
||||
}
|
||||
ScoreManager.prototype.plusScore = function(amount) {
|
||||
this.setScore(this.score + amount);
|
||||
}
|
||||
|
||||
minusScore(amount) {
|
||||
this.plusScore(-1 * amount);
|
||||
}
|
||||
ScoreManager.prototype.minusScore = function(amount) {
|
||||
this.plusScore(-1 * amount);
|
||||
}
|
||||
|
||||
setScore(value) {
|
||||
let beforeScore = this.score;
|
||||
this.score = value;
|
||||
ScoreManager.prototype.setScore = function(value) {
|
||||
var beforeScore = this.score;
|
||||
this.score = value;
|
||||
|
||||
// update score
|
||||
if(beforeScore !== this.score)
|
||||
this.callListener(this.onChangeScoreListeners);
|
||||
|
||||
// update high score
|
||||
if(this.score > this.highScore)
|
||||
this.callListener(this.onChangeHighScoreListeners);
|
||||
}
|
||||
// update score
|
||||
if(beforeScore !== this.score)
|
||||
this.callListener(this.onChangeScoreListeners);
|
||||
|
||||
// update high score
|
||||
if(this.score > this.highScore)
|
||||
this.callListener(this.onChangeHighScoreListeners);
|
||||
}
|
||||
+24
-23
@@ -1,36 +1,37 @@
|
||||
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;
|
||||
this.anchor.set(0.5);
|
||||
this.inputEnabled = false;
|
||||
|
||||
var grd = this.context.createLinearGradient(0, 0, 0, this.height);
|
||||
grd.addColorStop(0, '#8ED6FF');
|
||||
grd.addColorStop(1, '#004CB3');
|
||||
this.fill = grd;
|
||||
// this.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
this.stroke = '#fff';
|
||||
this.strokeThickness = 5;
|
||||
var grd = this.context.createLinearGradient(0, 0, 0, this.height);
|
||||
grd.addColorStop(0, '#8ED6FF');
|
||||
grd.addColorStop(1, '#004CB3');
|
||||
this.fill = grd;
|
||||
// this.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
this.stroke = '#fff';
|
||||
this.strokeThickness = 5;
|
||||
|
||||
|
||||
let tweenAlpha = game.add.tween(this);
|
||||
tweenAlpha.to( { alpha: 0 }, 1000, Phaser.Easing.Linear.None, true);
|
||||
var tweenAlpha = game.add.tween(this);
|
||||
tweenAlpha.to( { alpha: 0 }, 1000, Phaser.Easing.Linear.None, true);
|
||||
|
||||
let 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);
|
||||
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() {
|
||||
this.destroy();
|
||||
}
|
||||
game.add.existing(this);
|
||||
};
|
||||
|
||||
ScoreText.prototype.destroySelf = function() {
|
||||
this.destroy();
|
||||
}
|
||||
|
||||
|
||||
ScoreText.DEFAULT_TEXT_FONT = {
|
||||
font: "30px Arial",
|
||||
boundsAlignH: "center", // left, center. right
|
||||
|
||||
@@ -1,84 +1,78 @@
|
||||
/////////////////////////////
|
||||
// Screen bottom
|
||||
function ScreenBottomUI() {
|
||||
this.dbConnectManager = new DBConnectManager();
|
||||
|
||||
class ScreenBottomUI {
|
||||
|
||||
constructor() {
|
||||
this.dbConnectManager = new DBConnectManager();
|
||||
|
||||
this.bottomBarCenterY = game.world.height - ScreenBottomUI.BG_HEIGHT / 2;
|
||||
|
||||
this.drawBG();
|
||||
this.leftText = this.printText(this.leftText, "", "left");
|
||||
this.centerText = this.printText(this.centerText, "", "center");
|
||||
this.rightText = this.printText(this.rightText, "", "right");
|
||||
}
|
||||
|
||||
drawBG() {
|
||||
game.add.graphics()
|
||||
.beginFill(0x303030, 1)
|
||||
.drawRect(
|
||||
0, game.world.height - ScreenBottomUI.BG_HEIGHT,
|
||||
game.world.width, ScreenBottomUI.BG_HEIGHT
|
||||
);
|
||||
}
|
||||
|
||||
printLeftText(text) {
|
||||
this.leftText.text = text;
|
||||
}
|
||||
|
||||
printCenterText(text) {
|
||||
this.centerText.text = text;
|
||||
}
|
||||
|
||||
printRightText(text) {
|
||||
this.rightText.text = text;
|
||||
}
|
||||
|
||||
printText(textObject, text, align) {
|
||||
if(textObject !== null && textObject !== undefined) {
|
||||
textObject.text = "";
|
||||
textObject = null;
|
||||
}
|
||||
|
||||
let posX = 0;
|
||||
let anchorValue = 0;
|
||||
switch(align) {
|
||||
case "left":
|
||||
posX = ScreenBottomUI.TEXT_OFFSET;
|
||||
break;
|
||||
|
||||
case "center":
|
||||
posX = game.world.centerX;
|
||||
anchorValue = 0.5;
|
||||
break;
|
||||
|
||||
case "right":
|
||||
posX = game.world.width - ScreenBottomUI.TEXT_OFFSET;
|
||||
anchorValue = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
textObject = game.add.text(posX, this.bottomBarCenterY, text, this.getFontStyle());
|
||||
|
||||
textObject.anchor.x = anchorValue;
|
||||
textObject.anchor.y = 0.5;
|
||||
|
||||
return textObject;
|
||||
}
|
||||
|
||||
printLeftTextWithBestRecord(bestRecord) {
|
||||
let roundUpBestRecord = Math.round(bestRecord);
|
||||
let highScoreWithCommas = NumberUtil.numberWithCommas(roundUpBestRecord);
|
||||
this.printLeftText("오늘의 최고 기록 : " + highScoreWithCommas);
|
||||
}
|
||||
|
||||
getFontStyle() {
|
||||
return { font: "32px Arial", fill: "#fff", align: "left", boundsAlignH: "left", boundsAlignV: "bottom" };
|
||||
}
|
||||
this.bottomBarCenterY = game.world.height - ScreenBottomUI.BG_HEIGHT / 2;
|
||||
|
||||
this.drawBG();
|
||||
this.leftText = this.printText(this.leftText, "", "left");
|
||||
this.centerText = this.printText(this.centerText, "", "center");
|
||||
this.rightText = this.printText(this.rightText, "", "right");
|
||||
}
|
||||
|
||||
ScreenBottomUI.prototype.drawBG = function() {
|
||||
game.add.graphics()
|
||||
.beginFill(0x303030, 1)
|
||||
.drawRect(
|
||||
0, game.world.height - ScreenBottomUI.BG_HEIGHT,
|
||||
game.world.width, ScreenBottomUI.BG_HEIGHT
|
||||
);
|
||||
}
|
||||
|
||||
ScreenBottomUI.prototype.printLeftText = function(text) {
|
||||
this.leftText.text = text;
|
||||
}
|
||||
|
||||
ScreenBottomUI.prototype.printCenterText = function(text) {
|
||||
this.centerText.text = text;
|
||||
}
|
||||
|
||||
ScreenBottomUI.prototype.printRightText = function(text) {
|
||||
this.rightText.text = text;
|
||||
}
|
||||
|
||||
ScreenBottomUI.prototype.printText = function(textObject, text, align) {
|
||||
if(textObject !== null && textObject !== undefined) {
|
||||
textObject.text = "";
|
||||
textObject = null;
|
||||
}
|
||||
|
||||
var posX = 0;
|
||||
var anchorValue = 0;
|
||||
switch(align) {
|
||||
case "left":
|
||||
posX = ScreenBottomUI.TEXT_OFFSET;
|
||||
break;
|
||||
|
||||
case "center":
|
||||
posX = game.world.centerX;
|
||||
anchorValue = 0.5;
|
||||
break;
|
||||
|
||||
case "right":
|
||||
posX = game.world.width - ScreenBottomUI.TEXT_OFFSET;
|
||||
anchorValue = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
textObject = game.add.text(posX, this.bottomBarCenterY, text, this.getFontStyle());
|
||||
|
||||
textObject.anchor.x = anchorValue;
|
||||
textObject.anchor.y = 0.5;
|
||||
|
||||
return textObject;
|
||||
}
|
||||
|
||||
ScreenBottomUI.prototype.printLeftTextWithBestRecord = function(bestRecord) {
|
||||
var roundUpBestRecord = Math.round(bestRecord);
|
||||
var highScoreWithCommas = NumberUtil.numberWithCommas(roundUpBestRecord);
|
||||
this.printLeftText("오늘의 최고 기록 : " + highScoreWithCommas);
|
||||
}
|
||||
|
||||
ScreenBottomUI.prototype.getFontStyle = function() {
|
||||
return { font: "32px Arial", fill: "#fff", align: "left", boundsAlignH: "left", boundsAlignV: "bottom" };
|
||||
}
|
||||
|
||||
|
||||
ScreenBottomUI.BG_HEIGHT = 50;
|
||||
|
||||
ScreenBottomUI.NAME_WIDTH = 200;
|
||||
|
||||
@@ -1,29 +1,22 @@
|
||||
/////////////////////////////
|
||||
// Screen top ui
|
||||
function ScreenTopUI() {
|
||||
this.drawBG();
|
||||
}
|
||||
|
||||
class ScreenTopUI {
|
||||
ScreenTopUI.prototype.drawBG = function() {
|
||||
game.add.graphics()
|
||||
.beginFill(0x303030, 1)
|
||||
.drawRect(
|
||||
0, 0,
|
||||
game.world.width, ScreenTopUI.BG_HEIGHT
|
||||
);
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.drawBG();
|
||||
}
|
||||
|
||||
drawBG() {
|
||||
game.add.graphics()
|
||||
.beginFill(0x303030, 1)
|
||||
.drawRect(
|
||||
0, 0,
|
||||
game.world.width, ScreenTopUI.BG_HEIGHT
|
||||
);
|
||||
}
|
||||
|
||||
makeBackButton(eventHandler) {
|
||||
this.backButton = new BackButton(eventHandler);
|
||||
}
|
||||
|
||||
makeFullScreenButton() {
|
||||
// this.fullscreenButton = new FullscreenButton();
|
||||
}
|
||||
ScreenTopUI.prototype.makeBackButton = function(eventHandler) {
|
||||
this.backButton = new BackButton(eventHandler);
|
||||
}
|
||||
|
||||
ScreenTopUI.prototype.makeFullScreenButton = function() {
|
||||
// this.fullscreenButton = new FullscreenButton();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
||||
+76
-79
@@ -1,96 +1,93 @@
|
||||
class StringUtil {
|
||||
function StringUtil() {
|
||||
}
|
||||
|
||||
static printMonthDay(date) {
|
||||
let dateTime = new Date(date);
|
||||
return (dateTime.getMonth() + 1) + "월 " + dateTime.getDate() + "일";
|
||||
}
|
||||
StringUtil.printMonthDay = function(date) {
|
||||
let dateTime = new Date(date);
|
||||
return (dateTime.getMonth() + 1) + "월 " + dateTime.getDate() + "일";
|
||||
}
|
||||
|
||||
static getRecordTextWithoutUnit(value) {
|
||||
let number = Math.floor(value);
|
||||
return NumberUtil.numberWithCommas(number);
|
||||
}
|
||||
StringUtil.getRecordTextWithoutUnit = function(value) {
|
||||
let number = Math.floor(value);
|
||||
return NumberUtil.numberWithCommas(number);
|
||||
}
|
||||
|
||||
static getRecordTextWithUnit(value) {
|
||||
let number = Math.floor(value);
|
||||
let numberWithCommas = NumberUtil.numberWithCommas(number);
|
||||
StringUtil.getRecordTextWithUnit = function(value) {
|
||||
let number = Math.floor(value);
|
||||
let numberWithCommas = NumberUtil.numberWithCommas(number);
|
||||
|
||||
if(isTypingGame())
|
||||
return numberWithCommas + " 타";
|
||||
else
|
||||
return numberWithCommas + " 점";
|
||||
}
|
||||
if(isTypingGame())
|
||||
return numberWithCommas + " 타";
|
||||
else
|
||||
return numberWithCommas + " 점";
|
||||
}
|
||||
|
||||
static getNumberStartWithZero(number, digitCount) {
|
||||
let n = number + '';
|
||||
return n.length >= digitCount ? n : new Array(digitCount - n.length + 1).join('0') + n;
|
||||
}
|
||||
StringUtil.getNumberStartWithZero = function(number, digitCount) {
|
||||
let n = number + '';
|
||||
return n.length >= digitCount ? n : new Array(digitCount - n.length + 1).join('0') + n;
|
||||
}
|
||||
|
||||
StringUtil.toKoreanAlphabets = function(text) {
|
||||
const cCho = [ 'ㄱ', 'ㄲ', 'ㄴ', 'ㄷ', 'ㄸ', 'ㄹ', 'ㅁ', 'ㅂ', 'ㅃ', 'ㅅ', 'ㅆ', 'ㅇ', 'ㅈ', 'ㅉ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ' ];
|
||||
const cJung = [ 'ㅏ', 'ㅐ', 'ㅑ', 'ㅒ', 'ㅓ', 'ㅔ', 'ㅕ', 'ㅖ', 'ㅗ', 'ㅘ', 'ㅙ', 'ㅚ', 'ㅛ', 'ㅜ', 'ㅝ', 'ㅞ', 'ㅟ', 'ㅠ', 'ㅡ', 'ㅢ', 'ㅣ' ];
|
||||
const cJong = [ '', 'ㄱ', 'ㄲ', 'ㄳ', 'ㄴ', 'ㄵ', 'ㄶ', 'ㄷ', 'ㄹ', 'ㄺ', 'ㄻ', 'ㄼ', 'ㄽ', 'ㄾ', 'ㄿ', 'ㅀ', 'ㅁ', 'ㅂ', 'ㅄ', 'ㅅ', 'ㅆ', 'ㅇ', 'ㅈ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ' ];
|
||||
|
||||
static toKoreanAlphabets(text) {
|
||||
const cCho = [ 'ㄱ', 'ㄲ', 'ㄴ', 'ㄷ', 'ㄸ', 'ㄹ', 'ㅁ', 'ㅂ', 'ㅃ', 'ㅅ', 'ㅆ', 'ㅇ', 'ㅈ', 'ㅉ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ' ];
|
||||
const cJung = [ 'ㅏ', 'ㅐ', 'ㅑ', 'ㅒ', 'ㅓ', 'ㅔ', 'ㅕ', 'ㅖ', 'ㅗ', 'ㅘ', 'ㅙ', 'ㅚ', 'ㅛ', 'ㅜ', 'ㅝ', 'ㅞ', 'ㅟ', 'ㅠ', 'ㅡ', 'ㅢ', 'ㅣ' ];
|
||||
const cJong = [ '', 'ㄱ', 'ㄲ', 'ㄳ', 'ㄴ', 'ㄵ', 'ㄶ', 'ㄷ', 'ㄹ', 'ㄺ', 'ㄻ', 'ㄼ', 'ㄽ', 'ㄾ', 'ㄿ', 'ㅀ', 'ㅁ', 'ㅂ', 'ㅄ', 'ㅅ', 'ㅆ', 'ㅇ', 'ㅈ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ' ];
|
||||
let cho, jung, jong;
|
||||
let str = text;
|
||||
let cnt = str.length;
|
||||
let chars = [], cCode;
|
||||
|
||||
let cho, jung, jong;
|
||||
let str = text;
|
||||
let cnt = str.length;
|
||||
let chars = [], cCode;
|
||||
|
||||
for (let i = 0; i < cnt; i++) {
|
||||
cCode = str.charCodeAt(i);
|
||||
// if (cCode == 32) { continue; } // 한글이 아닌 경우
|
||||
if (cCode < 0xAC00 || cCode > 0xD7A3) {
|
||||
chars.push(str.charAt(i));
|
||||
continue;
|
||||
}
|
||||
cCode = str.charCodeAt(i) - 0xAC00;
|
||||
jong = cCode % 28; // 종성
|
||||
jung = ((cCode - jong) / 28 ) % 21; // 중성
|
||||
cho = (((cCode - jong) / 28 ) - jung ) / 21; // 초성
|
||||
|
||||
chars.push(cCho[cho], cJung[jung]);
|
||||
if (cJong[jong] !== '') {
|
||||
chars.push(cJong[jong]);
|
||||
}
|
||||
for (let i = 0; i < cnt; i++) {
|
||||
cCode = str.charCodeAt(i);
|
||||
// if (cCode == 32) { continue; } // 한글이 아닌 경우
|
||||
if (cCode < 0xAC00 || cCode > 0xD7A3) {
|
||||
chars.push(str.charAt(i));
|
||||
continue;
|
||||
}
|
||||
return chars;
|
||||
};
|
||||
cCode = str.charCodeAt(i) - 0xAC00;
|
||||
jong = cCode % 28; // 종성
|
||||
jung = ((cCode - jong) / 28 ) % 21; // 중성
|
||||
cho = (((cCode - jong) / 28 ) - jung ) / 21; // 초성
|
||||
|
||||
|
||||
static getUnicodeAlphabetCount(text) {
|
||||
let chars = StringUtil.toKoreanAlphabets(text);
|
||||
// console.log('char : ' + chars);
|
||||
|
||||
let doubleJaum = [
|
||||
'ㄲ', 'ㅉ', 'ㄸ', 'ㄲ', 'ㅆ',
|
||||
'ㄳ', 'ㄵ', 'ㄶ', 'ㄺ', 'ㄻ', 'ㄼ', 'ㄽ', 'ㄾ', 'ㄿ', 'ㅀ', 'ㅄ'
|
||||
];
|
||||
let doubleMoum = [
|
||||
'ㅒ', 'ㅖ',
|
||||
'ㅘ', 'ㅙ', 'ㅚ', 'ㅝ', 'ㅞ', 'ㅟ', 'ㅢ'
|
||||
];
|
||||
|
||||
let alphabetCount = 0;
|
||||
let alphabet;
|
||||
for(let i = 0; i < chars.length; i++) {
|
||||
alphabet = chars[i];
|
||||
if(doubleJaum.indexOf(alphabet) > -1 || doubleMoum.indexOf(alphabet) > -1) {
|
||||
// console.log('double alphabet : ' + alphabet);
|
||||
alphabetCount += 2;
|
||||
}
|
||||
else
|
||||
alphabetCount++;
|
||||
chars.push(cCho[cho], cJung[jung]);
|
||||
if (cJong[jong] !== '') {
|
||||
chars.push(cJong[jong]);
|
||||
}
|
||||
}
|
||||
return chars;
|
||||
};
|
||||
|
||||
// return chars;
|
||||
return alphabetCount;
|
||||
};
|
||||
StringUtil.getUnicodeAlphabetCount = function(text) {
|
||||
let chars = StringUtil.toKoreanAlphabets(text);
|
||||
// console.log('char : ' + chars);
|
||||
|
||||
static getScoreUnit(playingAppID) {
|
||||
if(playingAppID < 100)
|
||||
return " 타";
|
||||
let doubleJaum = [
|
||||
'ㄲ', 'ㅉ', 'ㄸ', 'ㄲ', 'ㅆ',
|
||||
'ㄳ', 'ㄵ', 'ㄶ', 'ㄺ', 'ㄻ', 'ㄼ', 'ㄽ', 'ㄾ', 'ㄿ', 'ㅀ', 'ㅄ'
|
||||
];
|
||||
let doubleMoum = [
|
||||
'ㅒ', 'ㅖ',
|
||||
'ㅘ', 'ㅙ', 'ㅚ', 'ㅝ', 'ㅞ', 'ㅟ', 'ㅢ'
|
||||
];
|
||||
|
||||
let alphabetCount = 0;
|
||||
let alphabet;
|
||||
for(let i = 0; i < chars.length; i++) {
|
||||
alphabet = chars[i];
|
||||
if(doubleJaum.indexOf(alphabet) > -1 || doubleMoum.indexOf(alphabet) > -1) {
|
||||
// console.log('double alphabet : ' + alphabet);
|
||||
alphabetCount += 2;
|
||||
}
|
||||
else
|
||||
return " 점";
|
||||
alphabetCount++;
|
||||
}
|
||||
|
||||
// return chars;
|
||||
return alphabetCount;
|
||||
};
|
||||
|
||||
StringUtil.getScoreUnit = function(playingAppID) {
|
||||
if(playingAppID < 100)
|
||||
return " 타";
|
||||
else
|
||||
return " 점";
|
||||
}
|
||||
Reference in New Issue
Block a user