diff --git a/src/game/lib/animal.js b/src/game/lib/animal.js index dc92ada..5695365 100644 --- a/src/game/lib/animal.js +++ b/src/game/lib/animal.js @@ -11,6 +11,8 @@ function Animal(type, index, x, y) { this.sprite.animations.add("stand", [index * 2]); this.sprite.animations.play("stand"); this.sprite.animations.add("run", [index * 2, index * 2 + 1]); + + this.species = Animal.SPECIES_DATA[index]; } @@ -18,30 +20,15 @@ Animal.prototype.setScale = function(value) { this.sprite.scale.set(value); } -Animal.prototype.setIconSprite = function(species) { - this.setSpecies(species); - - // this.spriteFrameNames = this.loadSpriteNames(); - // this.sprite.loadTexture(this.spriteFrameNames.run1); -} +// Animal.prototype.setIconSprite = function(species) { +// this.setSpecies(species); +// } Animal.prototype.setSpecies = function(species) { + console.log(species); this.species = species; } -/* -Animal.prototype.loadSpriteNames = function() { - let spriteNames = {}; - - 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; - - return spriteNames; -} -*/ - Animal.prototype.setAlpha = function(value) { this.sprite.alpha = value; } @@ -61,55 +48,19 @@ Animal.prototype.tweenAnimation = function(animationType) { game.add.tween(this.sprite).to( { width: 50 }, 500, Phaser.Easing.Bounce.In, true); // game.add.tween(this.sprite).to( { width: 50 }, 500, Phaser.Easing.Elastic.Out, true); break; - } } -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(); -} +// Animal.prototype.setupAnimation = function() { +// this.stopAnimation(); +// } Animal.prototype.startAnimation = function(species) { - this.sprite.animations.play("run", 5, true); - - /* - this.setSpecies(species); - this.setupAnimation(); - - if(this.timerEvent === null) - this.timerEvent = game.time.events.loop(this.animationSpeedSec, this.animateionUpdate, this); - */ + this.sprite.animations.play("run", this.species.fps, true); } -/* -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); - } - this.sprite.width = 150; - this.sprite.height = 150; -} -*/ - Animal.prototype.stopAnimation = function() { this.sprite.animations.stop("run"); - - /* - if(this.timerEvent !== null) { - game.time.events.remove(this.timerEvent); - this.timerEvent = null; - } - */ } @@ -122,6 +73,10 @@ Animal.animalLevelIDByRecord = function(record, gameType) { return 0; } +Animal.getAnimalPracticeTypingCount = function(animalIndex) { + return Animal.SPECIES_DATA[animalIndex].practiceTypingCount; +} + Animal.typingCount = function(speciesData, gameType) { if(gameType === Animal.TYPE_PRACTICE) return speciesData.practiceTypingCount; @@ -132,50 +87,7 @@ Animal.typingCount = function(speciesData, gameType) { Animal.loadResources = function() { game.load.spritesheet('animals', '../../../resources/image/character/animal/animals.png', 50, 50); - - 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'); - - 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('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('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('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('snail_shadow', '../../../resources/image/character/animal/snail/shadow.png'); } @@ -190,25 +102,19 @@ Animal.ANIMATION_TYPE_DAMAGE = 1; Animal.SPECIES_DATA = [ - { "species" : "snail", "fps" : 1.1, "practiceTypingCount" : 0, "testTypingCount" : 0 }, - { "species" : "turtle", "fps" : 2.2, "practiceTypingCount" : 5, "testTypingCount" : 20 }, - { "species" : "chick", "fps" : 3.3, "practiceTypingCount" : 10, "testTypingCount" : 40 }, - { "species" : "mouse", "fps" : 4.4, "practiceTypingCount" : 15, "testTypingCount" : 70 }, - { "species" : "chicken", "fps" : 5.5, "practiceTypingCount" : 20, "testTypingCount" : 100 }, - { "species" : "pig", "fps" : 7.7, "practiceTypingCount" : 25, "testTypingCount" : 150 }, - { "species" : "cat", "fps" : 9.9, "practiceTypingCount" : 30, "testTypingCount" : 200 }, - { "species" : "deer", "fps" : 12.2, "practiceTypingCount" : 40, "testTypingCount" : 250 }, - { "species" : "kangaroo", "fps" : 16, "practiceTypingCount" : 50, "testTypingCount" : 300 }, - { "species" : "rabbit", "fps" : 20, "practiceTypingCount" : 60, "testTypingCount" : 350 }, - { "species" : "dog", "fps" : 20, "practiceTypingCount" : 80, "testTypingCount" : 400 }, - { "species" : "zebra", "fps" : 20, "practiceTypingCount" : 100, "testTypingCount" : 450 }, - { "species" : "ostrich", "fps" : 20, "practiceTypingCount" : 120, "testTypingCount" : 500 }, - { "species" : "lion", "fps" : 20, "practiceTypingCount" : 140, "testTypingCount" : 600 }, - { "species" : "cheetah", "fps" : 20, "practiceTypingCount" : 160, "testTypingCount" : 700 } -]; - -Animal.SPRITE_NAMES = { - "icon" : "_icon", - "run1" : "_run1", - "run2" : "_run2" -}; \ No newline at end of file + { "species" : "snail", "fps" : 1, "practiceTypingCount" : 0, "testTypingCount" : 0 }, + { "species" : "turtle", "fps" : 2, "practiceTypingCount" : 5, "testTypingCount" : 20 }, + { "species" : "chick", "fps" : 5, "practiceTypingCount" : 10, "testTypingCount" : 40 }, + { "species" : "mouse", "fps" : 12, "practiceTypingCount" : 15, "testTypingCount" : 70 }, + { "species" : "chicken", "fps" : 11, "practiceTypingCount" : 20, "testTypingCount" : 100 }, + { "species" : "pig", "fps" : 5, "practiceTypingCount" : 25, "testTypingCount" : 150 }, + { "species" : "cat", "fps" : 10, "practiceTypingCount" : 30, "testTypingCount" : 200 }, + { "species" : "deer", "fps" : 9, "practiceTypingCount" : 40, "testTypingCount" : 250 }, + { "species" : "kangaroo", "fps" : 4, "practiceTypingCount" : 50, "testTypingCount" : 300 }, + { "species" : "rabbit", "fps" : 12, "practiceTypingCount" : 60, "testTypingCount" : 350 }, + { "species" : "dog", "fps" : 9, "practiceTypingCount" : 70, "testTypingCount" : 400 }, + { "species" : "zebra", "fps" : 12, "practiceTypingCount" : 80, "testTypingCount" : 450 }, + { "species" : "ostrich", "fps" : 15, "practiceTypingCount" : 90, "testTypingCount" : 500 }, + { "species" : "lion", "fps" : 10, "practiceTypingCount" : 100, "testTypingCount" : 600 }, + { "species" : "cheetah", "fps" : 15, "practiceTypingCount" : 110, "testTypingCount" : 700 } +]; \ No newline at end of file diff --git a/src/game/lib/animal_list.js b/src/game/lib/animal_list.js index 77c5a6d..4855e87 100644 --- a/src/game/lib/animal_list.js +++ b/src/game/lib/animal_list.js @@ -9,6 +9,8 @@ function AnimalList(y) { // console.log("animalCount : " + animalCount); // console.log("offsetAnimal : " + offsetAnimal); + this.activeAnimalIndex = 0; + for(var i = 0; i < animalCount; i++) { this.animals[i] = new Animal( Animal.TYPE_ICON, @@ -19,8 +21,6 @@ function AnimalList(y) { this.inactivate(i); } - this.activeAnimalIndex = 0; - // this.activate(this.activeAnimalIndex); this.activate(this.activeAnimalIndex); this.tweenAnimation(Animal.ANIMATION_TYPE_DAMAGE); } @@ -39,9 +39,6 @@ AnimalList.prototype.inactivate = function(index) { this.animals[index].stopAnimation(); this.animals[index].setScale(1); this.animals[index].setAlpha(AnimalList.ALPHA_INACTIVE); - - var animalData = Animal.SPECIES_DATA[index]; - this.animals[index].setIconSprite(animalData); } AnimalList.prototype.animate = function(index) { diff --git a/src/game/lib/button/round_rect_button.js b/src/game/lib/button/round_rect_button.js index 570af23..a50f887 100644 --- a/src/game/lib/button/round_rect_button.js +++ b/src/game/lib/button/round_rect_button.js @@ -94,7 +94,7 @@ function RoundRectButton(roundRectSetting, iconName, buttonText, clickEvent) { this.button.addChild(this.text); } - if(iconName.length > 0) { + if(iconName != null && iconName.length > 0) { this.icon = this.makeIcon(iconName); this.setIcon(this.icon); } diff --git a/src/game/lib/button/typing_app_button.js b/src/game/lib/button/typing_app_button.js index 793fbc3..3523b9e 100644 --- a/src/game/lib/button/typing_app_button.js +++ b/src/game/lib/button/typing_app_button.js @@ -1,7 +1,7 @@ TypingAppButton.prototype = Object.create(RoundRectButton.prototype); TypingAppButton.constructor = TypingAppButton; -function TypingAppButton(type, x, y, iconName, buttonText, appInfo) { +function TypingAppButton(type, x, y, iconSprite, buttonText, appInfo) { var setting = new RoundRectButtonSetting(x, y, TypingAppButton.BUTTON_WIDTH, TypingAppButton.BUTTON_HEIGHT); setting.fontStyle.boundsAlignH = "center"; // left, center. right setting.fontStyle.boundsAlignV = "middle"; // top, middle, bottom @@ -83,16 +83,19 @@ function TypingAppButton(type, x, y, iconName, buttonText, appInfo) { this.appInfo = appInfo; RoundRectButton.call( this, setting, - iconName, buttonText, + null, + buttonText, this.clickEvent ); this.text.x = 30; - if(iconName.length > 0) { - this.icon.x = 40; - this.icon.width = 100; - this.icon.height = 100; + if(iconSprite != null) { + this.icon = iconSprite.sprite; + this.buttonIcon = this.button.addChild(this.icon); + + this.buttonIcon.x = 40; + this.buttonIcon.y = this.button.height / 2 - 5; } } diff --git a/src/game/menu/menu_typing_practice.js b/src/game/menu/menu_typing_practice.js index d61bab9..4484636 100644 --- a/src/game/menu/menu_typing_practice.js +++ b/src/game/menu/menu_typing_practice.js @@ -123,14 +123,19 @@ var MenuTypingPractice = { return 0; }, - getIconImage: function(jsonList, appID) { + getAnimalSprite: function(jsonList, appID) { var appHighestRecord = this.getAppHighestRecord(jsonList, appID); + var animalSprite = null; - if(appHighestRecord === 0) - return "snail_shadow"; + if(appHighestRecord === 0) { + animalSprite = new Animal(Animal.TYPE_ICON, 0, 0, 0); + // animalSprite.sprite.tint = RoundRectButtonSetting.DEFAULT_BUTTON_COLORS.disabled; + } else { + var animalLevel = Animal.animalLevelIDByRecord(appHighestRecord, Animal.TYPE_PRACTICE); + animalSprite = new Animal(Animal.TYPE_ICON, animalLevel, 0, 0); + } - var animalLevel = Animal.animalLevelIDByRecord(appHighestRecord, Animal.TYPE_PRACTICE); - return Animal.SPECIES_DATA[animalLevel].species + Animal.SPRITE_NAMES.icon; + return animalSprite; }, downloadListSucceeded: function(replyJSON) { @@ -152,7 +157,7 @@ var MenuTypingPractice = { var typingPracticeButton = new TypingAppButton( TypingAppButton.TYPE_PRACTICE_KOREAN, posX, posY, - this.getIconImage(replyJSON.KoreanHighScoreList, activeApp.AppID), + this.getAnimalSprite(replyJSON.KoreanHighScoreList, activeApp.AppID), activeApp.KoreanName, { AppID: activeApp.AppID, @@ -176,7 +181,7 @@ var MenuTypingPractice = { var typingPracticeButton = new TypingAppButton( TypingAppButton.TYPE_PRACTICE_ENGLISH, posX, posY, - this.getIconImage(replyJSON.EnglishHighScoreList, activeApp.AppID), + this.getAnimalSprite(replyJSON.EnglishHighScoreList, activeApp.AppID), activeApp.KoreanName, { AppID: activeApp.AppID, diff --git a/src/game/menu/menu_typing_test.js b/src/game/menu/menu_typing_test.js index ed5b7b6..c257b71 100644 --- a/src/game/menu/menu_typing_test.js +++ b/src/game/menu/menu_typing_test.js @@ -125,14 +125,19 @@ var MenuTypingTest = { return 0; }, - getIconImage: function(jsonList, appID) { + getAnimalSprite: function(jsonList, appID) { var appHighestRecord = this.getAppHighestRecord(jsonList, appID); + var animalSprite = null; - if(appHighestRecord === 0) - return "snail_shadow"; + if(appHighestRecord === 0) { + animalSprite = new Animal(Animal.TYPE_ICON, 0, 0, 0); + // animalSprite.sprite.tint = RoundRectButtonSetting.DEFAULT_BUTTON_COLORS.disabled; + } else { + var animalLevel = Animal.animalLevelIDByRecord(appHighestRecord, Animal.TYPE_PRACTICE); + animalSprite = new Animal(Animal.TYPE_ICON, animalLevel, 0, 0); + } - var animalLevel = Animal.animalLevelIDByRecord(appHighestRecord, Animal.TYPE_TEST); - return Animal.SPECIES_DATA[animalLevel].species + Animal.SPRITE_NAMES.icon; + return animalSprite; }, downloadListSucceeded: function(replyJSON) { @@ -154,7 +159,7 @@ var MenuTypingTest = { var typingTestButton = new TypingAppButton( TypingAppButton.TYPE_TEST_KOREAN, posX, posY, - this.getIconImage(replyJSON.KoreanHighScoreList, activeApp.AppID), + this.getAnimalSprite(replyJSON.KoreanHighScoreList, activeApp.AppID), activeApp.KoreanName, { AppID: activeApp.AppID, @@ -178,7 +183,7 @@ var MenuTypingTest = { var typingTestButton = new TypingAppButton( TypingAppButton.TYPE_TEST_ENGLISH, posX, posY, - this.getIconImage(replyJSON.EnglishHighScoreList, activeApp.AppID), + this.getAnimalSprite(replyJSON.EnglishHighScoreList, activeApp.AppID), activeApp.KoreanName, { AppID: activeApp.AppID, diff --git a/src/game/result/result.js b/src/game/result/result.js index cecb1e3..4d1b10a 100644 --- a/src/game/result/result.js +++ b/src/game/result/result.js @@ -89,20 +89,17 @@ var Result = { var record = NumberUtil.numberWithCommas(Math.floor(sessionStorageManager.getRecord())); style.font = "80px Arial"; - // if(sessionStorageManager.getPlayingAppID() < 100) { if(isTypingPracticeApp() || isTypingTestApp()) { - var leftAnimal = new Animal(Animal.TYPE_ANIMATION, game.world.centerX - 200, 150); var animalLevelID = 0; - // if(sessionStorageManager.getPlayingAppID() < 20) if(isTypingPracticeApp()) animalLevelID = Animal.animalLevelIDByRecord(sessionStorageManager.getRecord(), Animal.TYPE_PRACTICE); else animalLevelID = Animal.animalLevelIDByRecord(sessionStorageManager.getRecord(), Animal.TYPE_TEST); - // leftAnimal.tweenAnimation(Animal.ANIMATION_TYPE_CHANGE); + + var leftAnimal = new Animal(Animal.TYPE_ANIMATION, animalLevelID, game.world.centerX - 200, 150); leftAnimal.startAnimation(Animal.SPECIES_DATA[animalLevelID]); - var rightAnimal = new Animal(Animal.TYPE_ANIMATION, game.world.centerX + 200, 150); - // rightAnimal.tweenAnimation(Animal.ANIMATION_TYPE_CHANGE); + var rightAnimal = new Animal(Animal.TYPE_ANIMATION, animalLevelID, game.world.centerX + 200, 150); rightAnimal.startAnimation(Animal.SPECIES_DATA[animalLevelID]); } diff --git a/src/game/typing/lib/typing_text_manager.js b/src/game/typing/lib/typing_text_manager.js index 21c48cb..7af963f 100644 --- a/src/game/typing/lib/typing_text_manager.js +++ b/src/game/typing/lib/typing_text_manager.js @@ -30,7 +30,7 @@ TypingTextManager.prototype.fillLeftRightBasicKey = function() { var char = this.contents[i]; // console.log(char); if(this.isKoreanConsonant(char)) { - this.contents.splice(i + 1, 0, "ㅏ"); + this.contents.splice(i + 1, 0, "ㅓ"); } else if(this.isKoreanVowel(char)) { this.contents.splice(i, 0, "ㄹ"); } @@ -66,7 +66,7 @@ TypingTextManager.prototype.makePracticeContents = function(arr, repeatCount) { TypingTextManager.prototype.makeTestContents = function(arr) { this.init(); - this.add(this.getShuffledArray()); + this.add(this.getShuffledArray(arr)); } diff --git a/src/game/typing/practice/game.js b/src/game/typing/practice/game.js index 51b13bc..d642a2d 100644 --- a/src/game/typing/practice/game.js +++ b/src/game/typing/practice/game.js @@ -380,9 +380,10 @@ var TypingPractice = { // this.goResult(); } } else { - this.typingScore.reset(); + if(this.playingAnimalIndex > 0) + this.playingAnimalIndex--; + this.typingScore.set(Animal.getAnimalPracticeTypingCount(this.playingAnimalIndex)); - this.playingAnimalIndex = 0; this.animalList.activate(this.playingAnimalIndex); this.animalList.tweenAnimation(Animal.ANIMATION_TYPE_DAMAGE); } @@ -405,7 +406,7 @@ TypingPractice.TYPING_COUNT_PLUS_ENTER = 1; TypingPractice.OFFSET_RIGHT_ALIGN = 10; -TypingPractice.STAGE_TIMER_SEC = 60; +TypingPractice.STAGE_TIMER_SEC = 30; TypingPractice.COLOR_CONTENT_INPUT = "#dddddd"; TypingPractice.COLOR_BRACKET = "#dddd70"; diff --git a/src/game/typing/practice/typing_score.js b/src/game/typing/practice/typing_score.js index 70c8172..ac2b23e 100644 --- a/src/game/typing/practice/typing_score.js +++ b/src/game/typing/practice/typing_score.js @@ -38,6 +38,11 @@ TypingScore.prototype.reset = function() { this.print(this.typingCount); } +TypingScore.prototype.set = function(score) { + this.typingCount = score; + this.print(this.typingCount); +} + TypingScore.prototype.print = function(typingCount) { this.scoreText.text = typingCount; }