diff --git a/src/game/lib/animal.js b/src/game/lib/animal.js index 3cd1b17..6fde25f 100644 --- a/src/game/lib/animal.js +++ b/src/game/lib/animal.js @@ -9,20 +9,22 @@ class Animal { } animalLevelIDByRecord(record) { - if(sessionStorageManager.playingAppID <= 20) { // practice - for(let i = 0; i < Animal.SPECIES_DATA.length - 1; i++) { - if(record < Animal.SPECIES_DATA[i].practiceTypingCount) - return i; - } - } else { // test - for(let i = 0; i < Animal.SPECIES_DATA.length - 1; i++) { - if(record < Animal.SPECIES_DATA[i].testTypingCount) - return i; - } - + console.log(record); + for(let i = Animal.SPECIES_DATA.length - 1; i > 0; i--) { + console.log(i); + console.log(this.typingCount(Animal.SPECIES_DATA[i])); + if(record >= this.typingCount(Animal.SPECIES_DATA[i])) + return i; } - return Animal.SPECIES_DATA.length - 1; + return 0; + } + + typingCount(speciesData) { + if(sessionStorageManager.playingAppID <= 20) + return speciesData.practiceTypingCount; + else + return speciesData.testTypingCount; } loadSpriteNames() { @@ -112,16 +114,16 @@ Animal.ANIMATION_TYPE_DAMAGE = 1; Animal.SPECIES_DATA = [ - { "species" : "snail", "runningFPS" : 1.1, "practiceTypingCount" : 5, "testTypingCount" : 10 }, - { "species" : "turtle", "runningFPS" : 5.5, "practiceTypingCount" : 10, "testTypingCount" : 20 }, - { "species" : "cat", "runningFPS" : 10.1, "practiceTypingCount" : 20, "testTypingCount" : 30 }, - { "species" : "lion", "runningFPS" : 15.5, "practiceTypingCount" : 30, "testTypingCount" : 50 }, - { "species" : "rabbit", "runningFPS" : 20.2, "practiceTypingCount" : 40, "testTypingCount" : 100 }, - { "species" : "ostrich", "runningFPS" : 25.5, "practiceTypingCount" : 50, "testTypingCount" : 200 }, - { "species" : "horse", "runningFPS" : 30.3, "practiceTypingCount" : 60, "testTypingCount" : 300 }, - { "species" : "dog", "runningFPS" : 35.5, "practiceTypingCount" : 70, "testTypingCount" : 400 }, - { "species" : "cheetah", "runningFPS" : 40.4, "practiceTypingCount" : 80, "testTypingCount" : 500 }, - { "species" : "eagle", "runningFPS" : 45.5, "practiceTypingCount" : 1000, "testTypingCount" : 1000 } + { "species" : "snail", "runningFPS" : 1.1, "practiceTypingCount" : 0, "testTypingCount" : 0 }, + { "species" : "turtle", "runningFPS" : 5.5, "practiceTypingCount" : 5, "testTypingCount" : 20 }, + { "species" : "cat", "runningFPS" : 10.1, "practiceTypingCount" : 10, "testTypingCount" : 50 }, + { "species" : "lion", "runningFPS" : 15.5, "practiceTypingCount" : 15, "testTypingCount" : 100 }, + { "species" : "rabbit", "runningFPS" : 20.2, "practiceTypingCount" : 20, "testTypingCount" : 200 }, + { "species" : "ostrich", "runningFPS" : 25.5, "practiceTypingCount" : 30, "testTypingCount" : 300 }, + { "species" : "horse", "runningFPS" : 30.3, "practiceTypingCount" : 40, "testTypingCount" : 400 }, + { "species" : "dog", "runningFPS" : 35.5, "practiceTypingCount" : 50, "testTypingCount" : 500 }, + { "species" : "cheetah", "runningFPS" : 40.4, "practiceTypingCount" : 60, "testTypingCount" : 600 }, + { "species" : "eagle", "runningFPS" : 45.5, "practiceTypingCount" : 80, "testTypingCount" : 700 } ]; Animal.SPRITE_NAMES = { diff --git a/src/game/login/login.js b/src/game/login/login.js index c58556a..aa7e1b5 100644 --- a/src/game/login/login.js +++ b/src/game/login/login.js @@ -15,6 +15,11 @@ class Login { this.game.stage.backgroundColor = '#4d4d4d'; this.textStyle = { font: "bold 32px Arial", fill: "#fff", align: "right", boundsAlignH: "right", boundsAlignV: "middle" }; + let backButton = new BackButton( () => { + sessionStorageManager.clear(); + location.href = '../../web/main/index.html'; + }); + let fullscreenButton = new FullscreenButton(this.game); let textX = this.game.world.centerX - 320; diff --git a/src/game/menu/menu_app.js b/src/game/menu/menu_app.js index 0adafbd..e7178c7 100644 --- a/src/game/menu/menu_app.js +++ b/src/game/menu/menu_app.js @@ -17,6 +17,9 @@ class MenuApp { sessionStorageManager.clear(); location.href = '../../web/client/login.html'; }); + + new WelcomePlayerText(sessionStorageManager.playerName); + let fullscreenButton = new FullscreenButton(this.game); diff --git a/src/game/menu/welcome_player_text.js b/src/game/menu/welcome_player_text.js new file mode 100644 index 0000000..2479ed9 --- /dev/null +++ b/src/game/menu/welcome_player_text.js @@ -0,0 +1,45 @@ +class WelcomePlayerText extends Phaser.Text { + + constructor(playerName) { + super(game, game.world.width / 2, WelcomePlayerText.FONT_HEIGHT_PX, "어서오세요, " + playerName + "님", WelcomePlayerText.DEFAULT_TEXT_FONT); + + this.anchor.set(0.5); + this.inputEnabled = false; + + var grd = this.context.createLinearGradient(0, 0, 0, this.height); + grd.addColorStop(0, '#8ED6FF'); + grd.addColorStop(1, '#4C6CB3'); + this.fill = grd; + this.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); + this.stroke = '#000'; + this.strokeThickness = 5; + + let tweenAlpha = game.add.tween(this); + tweenAlpha.from( { alpha: 0 } ).to( { alpha: 100 }, 1000, Phaser.Easing.Linear.None, true); + + /* + let 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 - WelcomePlayerText.MOVE_UP_AMOUNT_PX }, 1000, Phaser.Easing.Linear.None, true); + tweenMoveUp.onComplete.addOnce(this.destroySelf, this); + */ + + game.add.existing(this); + }; + + destroySelf() { + this.destroy(); + } + +} + +WelcomePlayerText.DEFAULT_TEXT_FONT = { + font: "40px Arial", + boundsAlignH: "center", // left, center. right + boundsAlignV: "middle", // top, middle, bottom + fill: "#fff" +}; + +WelcomePlayerText.FONT_HEIGHT_PX = 35; \ No newline at end of file diff --git a/src/web/client/login.html b/src/web/client/login.html index f0c2f2b..8c2081d 100644 --- a/src/web/client/login.html +++ b/src/web/client/login.html @@ -16,6 +16,7 @@ + diff --git a/src/web/client/menu_app.html b/src/web/client/menu_app.html index 2bbf190..ca3478b 100644 --- a/src/web/client/menu_app.html +++ b/src/web/client/menu_app.html @@ -26,6 +26,7 @@ +