diff --git a/resources/image/character/alien/cockpit.png b/resources/image/character/alien/cockpit.png index 96ce3e9..9bc4fa8 100644 Binary files a/resources/image/character/alien/cockpit.png and b/resources/image/character/alien/cockpit.png differ diff --git a/resources/image/character/alien/jet.png b/resources/image/character/alien/jet.png index fc8bd2b..f4296b8 100644 Binary files a/resources/image/character/alien/jet.png and b/resources/image/character/alien/jet.png differ diff --git a/resources/image/character/alien/ship.png b/resources/image/character/alien/ship.png index 960bd65..073fbcd 100644 Binary files a/resources/image/character/alien/ship.png and b/resources/image/character/alien/ship.png differ diff --git a/resources/image/character/alien/spaceship.afdesign b/resources/image/character/alien/spaceship.afdesign new file mode 100644 index 0000000..78a178d Binary files /dev/null and b/resources/image/character/alien/spaceship.afdesign differ diff --git a/src/game/lib/text/center_message_text.js b/src/game/lib/text/center_message_text.js index 48098bc..8eb0671 100644 --- a/src/game/lib/text/center_message_text.js +++ b/src/game/lib/text/center_message_text.js @@ -1,15 +1,14 @@ CenterMessageText.prototype = Object.create(Phaser.Text.prototype); CenterMessageText.constructor = CenterMessageText; -function CenterMessageText(contentText) { +function CenterMessageText() { Phaser.Text.call( this, game, game.world.width / 2, game.world.height / 2 - CenterMessageText.MOVE_AMOUNT_PX, - contentText, + "", CenterMessageText.DEFAULT_TEXT_FONT ); - // super(game, 600, 300, "게임 오버", CenterMessageText.DEFAULT_TEXT_FONT); this.anchor.set(0.5); this.inputEnabled = false; @@ -18,37 +17,55 @@ function CenterMessageText(contentText) { // grd.addColorStop(0, CenterMessageText.COLOR_GRADATION_START); //'#FFD68E'); // grd.addColorStop(1, CenterMessageText.COLOR_GRADATION_END); //'#B34C00'); // this.fill = grd; - this.fill = CenterMessageText.COLOR_TEXT; + // this.fill = CenterMessageText.COLOR_TEXT; // this.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); this.stroke = CenterMessageText.COLOR_STROKE; this.strokeThickness = 9; + this.tweenAlpha = game.add.tween(this); + this.tweenAlpha.to( { alpha: 0 }, CenterMessageText.TWEEN_ALPHA_TIME, Phaser.Easing.Elastic.In, false); + // this.tweenAlpha.onComplete.addOnce(this.hide, this); - this.alpha = 1; - var tweenAlpha = game.add.tween(this); - tweenAlpha.to( { alpha: 0 }, CenterMessageText.TWEEN_ALPHA_TIME, Phaser.Easing.Elastic.In, true); - tweenAlpha.onComplete.addOnce(this.destroy, this); - - // var tweenScale = game.add.tween(this.scale); - // tweenScale.to( { x: 0.8, y: 0.8 }, CenterMessageText.TWEEN_SCALE_TIME, Phaser.Easing.Bounce.Out, true); - // tweenScale.onComplete.addOnce(this.destroy, this); + this.timerEventTween = null; + this.alpha = 0; game.add.existing(this); }; +CenterMessageText.prototype.showText = function(wordLevel, wordLevelText) { + if(this.timerEventTween) + game.time.events.remove(this.timerEventTween); + + if(this.tweenAlpha != null) + this.tweenAlpha.stop(); + + this.text = "[ " + wordLevelText + " ] 단계 활성화"; + this.fill = GameLevelManager.CENTER_MESSAGE_TEXT_COLOR_LIST[wordLevel]; + this.stroke = GameLevelManager.CENTER_MESSAGE_STROKE_COLOR_LIST[wordLevel]; + // console.log(this.fill); + // console.log(this.stroke); + + this.alpha = 1; + this.tweenAlpha.start(); + + this.timerEventTween = game.time.events.add(CenterMessageText.TWEEN_ALPHA_TIME, this.hide, this); +} + +CenterMessageText.prototype.hide = function() { + this.alpha = 0; +} CenterMessageText.DEFAULT_TEXT_FONT = { - font: "bold 40px Arial", // "bold 100px Arial", + font: "bold 40px Arial", boundsAlignH: "center", // left, center. right boundsAlignV: "middle", // top, middle, bottom - fill: CenterMessageText.COLOR_TEXT // "#fff" + fill: "#ffffff" }; CenterMessageText.MOVE_AMOUNT_PX = 100; CenterMessageText.TWEEN_ALPHA_TIME = 1500; -CenterMessageText.TWEEN_SCALE_TIME = 1500; -CenterMessageText.COLOR_TEXT = "#ffcc00"; // "#cc9900"; -CenterMessageText.COLOR_GRADATION_START = "#B34C00"; // "#333333"; //"#666666"; -CenterMessageText.COLOR_GRADATION_END = "#333333"; // "#B34C00"; -CenterMessageText.COLOR_STROKE = "#663300"; //"#FFDD88"; //"#FFD68E"; \ No newline at end of file +CenterMessageText.COLOR_TEXT = "#ffcc00"; +CenterMessageText.COLOR_GRADATION_START = "#B34C00"; +CenterMessageText.COLOR_GRADATION_END = "#333333"; +CenterMessageText.COLOR_STROKE = "#663300"; \ No newline at end of file diff --git a/src/game/typing/lib/extract_word_manager.js b/src/game/typing/lib/extract_word_manager.js index 6cdce49..0cd8639 100644 --- a/src/game/typing/lib/extract_word_manager.js +++ b/src/game/typing/lib/extract_word_manager.js @@ -57,6 +57,17 @@ ExtractWordManager.prototype.initVariables = function() { } } +ExtractWordManager.prototype.getWordLevelCount = function() { + // console.log("this.easyWordList.length : " + this.easyWordList.length); + // console.log("this.hardWordList.length : " + this.hardWordList.length); + + var wordLevelCount = this.easyWordList.length; + if(wordLevelCount < this.hardWordList.length) + wordLevelCount = this.hardWordList.length; + + return wordLevelCount; +} + ExtractWordManager.prototype.pickOutDifficulty = function(wordList, difficultyForLevel) { var pickOutWordList = []; @@ -120,6 +131,12 @@ ExtractWordManager.prototype.getWord = function(wordLevel, difficultyForLevel) { // console.log("wordLevel : " + wordLevel); // console.log("difficultyForLevel : " + difficultyForLevel); + if(this.easyWordList[wordLevel] == undefined || this.hardWordList[wordLevel] == undefined) { + console.log("====== Error ======"); + console.log("wordLevel : " + wordLevel); + console.log("difficultyForLevel : " + difficultyForLevel); + } + var word = ""; if(difficultyForLevel == ExtractWordManager.DIFFICULTY_EASY) word = this.spliceRandomWord(this.easyWordList[wordLevel]); diff --git a/src/game/typing/word_flyingsaucer/flyingsaucer.js b/src/game/typing/word_flyingsaucer/flyingsaucer.js index fa5f3aa..a141322 100644 --- a/src/game/typing/word_flyingsaucer/flyingsaucer.js +++ b/src/game/typing/word_flyingsaucer/flyingsaucer.js @@ -7,7 +7,7 @@ function FlyingSaucer(lineIndex) { this.initVariables(); - Phaser.Sprite.call(this, game, game.world.centerX, game.world.centerY, 'alien_normal'); + Phaser.Sprite.call(this, game, game.world.centerX, game.world.centerY, 'ship_cockpit'); game.add.existing(this); game.physics.arcade.enable(this); @@ -15,11 +15,11 @@ function FlyingSaucer(lineIndex) { this.anchor.set(0.5); this.halfWidth = this.width / 2; - var COCKPIT_OFFSET_Y = -5; - var BODY_OFFSET_Y = 28; - var JET_OFFSET_Y = 52; + var ALIEN_OFFSET_Y = -12; + var BODY_OFFSET_Y = 14; + var JET_OFFSET_Y = 40; - this.cockpit = this.makeCockpit(0, COCKPIT_OFFSET_Y); + this.cockpit = this.makeAlien(0, ALIEN_OFFSET_Y); this.addChild(this.cockpit); this.jetLeft = this.makeJet(-50, JET_OFFSET_Y); @@ -69,19 +69,17 @@ FlyingSaucer.prototype.initVariables = function() { this.tweenScale = null; } -FlyingSaucer.prototype.makeCockpit = function(posX, posY) { - var cockpit = game.make.sprite(posX, posY, 'ship_cockpit'); - cockpit.anchor.set(0.5); - cockpit.alpha = 0.6; - cockpit.tint = 0xff00ff; +FlyingSaucer.prototype.makeAlien = function(posX, posY) { + var alien = game.make.sprite(posX, posY, 'alien_normal'); + alien.anchor.set(0.5); - return cockpit; + return alien; } FlyingSaucer.prototype.makeJet = function(posX, posY) { var jet = game.make.sprite(posX, posY, 'ship_jet'); jet.anchor.set(0.5); - jet.tint = FlyingSaucer.JET_COLOR_HIGH; + // jet.tint = FlyingSaucer.JET_COLOR_HIGH; return jet; } @@ -142,7 +140,7 @@ FlyingSaucer.prototype.changeJetColor = function(color) { } FlyingSaucer.prototype.changeCockpitColor = function(color) { - this.cockpit.tint = FlyingSaucer.COKCPIT_COLOR[this.wordLevel]; + this.tint = GameLevelManager.COCKPIT_COLOR_LIST[this.wordLevel]; } @@ -218,7 +216,7 @@ FlyingSaucer.prototype.startAttack = function() { this.word = this.extractWordManager.getWord(this.wordLevel, this.difficultyForLevel); // console.log("this.word : " + this.word); this.setWord(this.word); - this.standardScore = this.gameLevelManager.getStandardScore(this.wordLevel, this.speed); + this.standardScore = this.gameLevelManager.getStandardScore(this.wordLevel, this.difficultyForLevel, this.speed); // console.log(this.standardScore); this.moveInitialPos(); @@ -365,10 +363,10 @@ FlyingSaucer.SPEED_DOWN_AMOUNT = FlyingSaucer.SPEED_UP_AMOUNT / 2; // dot per s FlyingSaucer.START_POS_Y = 100; // px FlyingSaucer.CRASH_POS_Y = GAME_SCREEN_SIZE.y - 200; // px -FlyingSaucer.WORD_TEXT_OFFSET_Y = 30; // px +FlyingSaucer.WORD_TEXT_OFFSET_Y = 18; // px -FlyingSaucer.TEXT_COLOR_NORMAL = "#000000"; -FlyingSaucer.TEXT_COLOR_CORRECT = "#ffff4d"; +FlyingSaucer.TEXT_COLOR_NORMAL = "#ffffff"; +FlyingSaucer.TEXT_COLOR_CORRECT = "#ffcc00"; // "#ffff4d"; FlyingSaucer.TEXT_STROKE_COLOR = "#ffffff"; FlyingSaucer.JET_STATUS_HIGH = 0; @@ -377,10 +375,4 @@ FlyingSaucer.JET_STATUS_LOW = 2; FlyingSaucer.JET_COLOR_HIGH = 0x00ff00; //0x00ffff; FlyingSaucer.JET_COLOR_MIDDLE = 0xffff00; //0xffff00; -FlyingSaucer.JET_COLOR_LOW = 0xff0000; - -FlyingSaucer.COKCPIT_COLOR = [ - // 0xff0000, 0xff6600, 0xffff00, 0x00ffff, 0x00ffff, 0x6666ff, 0xff00ff - // 0x00ffff, 0x55aacc, 0x0000ff, 0x8800cc, 0xff00ff, 0x6666ff, 0xff00ff - 0xffff33, 0x00ff00, 0x00ccff, 0x3366ff, 0x9933ff, 0xff00ff, 0xff6600 -] \ No newline at end of file +FlyingSaucer.JET_COLOR_LOW = 0xff0000; \ No newline at end of file diff --git a/src/game/typing/word_flyingsaucer/game.js b/src/game/typing/word_flyingsaucer/game.js index 1dcc8e1..ca8795d 100644 --- a/src/game/typing/word_flyingsaucer/game.js +++ b/src/game/typing/word_flyingsaucer/game.js @@ -55,10 +55,10 @@ var WordFlyingSaucer = { this.flyingsaucers[i].setHeartManager(this.heartManager); this.flyingsaucers[i].setExtractWordManager(this.extractWordManager); this.flyingsaucers[i].setGameLevelManager(this.gameLevelManager); - this.flyingsaucers[i].startAttack(); + // this.flyingsaucers[i].startAttack(); } - + this.centerMessageText = new CenterMessageText(); // top ui var screenTopUI = new ScreenTopUI(); @@ -93,8 +93,7 @@ var WordFlyingSaucer = { this.screenBottomUI.printRightText(sessionStorageManager.getPlayerName()); - // this.startGame(); - this.showLevelUpText(); + this.startGame(); }, @@ -107,6 +106,7 @@ var WordFlyingSaucer = { initVariables: function() { this.extractWordManager = new ExtractWordManager(); this.gameLevelManager = new GameLevelManager(this); + this.gameLevelManager.setExtractWordManager(this.extractWordManager); this.speedLevel = 0; @@ -144,7 +144,6 @@ var WordFlyingSaucer = { bmd.rect(0, y, GAME_SCREEN_SIZE.x, y + GRADIATION_HEIGHT, Phaser.Color.getWebRGB(c)); y += GRADIATION_HEIGHT; } - console.log("final y : " + y); var stars = game.add.group(); for (var i = 0; i < 128; i++) { @@ -153,17 +152,33 @@ var WordFlyingSaucer = { } var GROUND_OFFSET_Y = 600; - // this.tileSprite = game.add.tileSprite(50, GROUND_OFFSET_Y, GAME_SCREEN_SIZE.x + 50, GROUND_OFFSET_Y + 150, "tile_choco"); - // this.tileSprite = game.add.tileSprite(300, 300, 100, 100, "tile_choco"); this.tileSprite = game.add.tileSprite( - GAME_SCREEN_SIZE.x, GAME_SCREEN_SIZE.y, - GAME_SCREEN_SIZE.x, 200, + GAME_SCREEN_SIZE.x, GAME_SCREEN_SIZE.y - 50, + GAME_SCREEN_SIZE.x, 100, "tile_choco"); this.tileSprite.anchor.set(0.5); this.tileSprite.tileScale.set(2); }, startGame: function() { + this.showLevelUpText(this.gameLevelManager.getWordLevel()); // initial wordLevel = 0; + + var startIndexList = []; + for(var i = 0; i < WordFlyingSaucer.MAX_FLYINGSAUCER_COUNT; i++) + startIndexList.push(i); + this.randomStartIndex = 0; + this.randomStartIndexList = Phaser.ArrayUtils.shuffle(startIndexList); + + for(var i = 0; i < this.randomStartIndexList.length; i++) { + var randomDelayTime = Phaser.Timer.SECOND * 2 * i + Math.random() * Phaser.Timer.SECOND; + game.time.events.add(randomDelayTime, this.waitAndStartAttack, this); + } + }, + + waitAndStartAttack: function() { + var index = this.randomStartIndexList[this.randomStartIndex]; + this.flyingsaucers[index].startAttack(); + this.randomStartIndex++; }, timeOver: function() { @@ -224,11 +239,8 @@ var WordFlyingSaucer = { } }, - showLevelUpText: function() { - if(this.centerMessageText) - // this.centerMessageText.text = ""; - this.centerMessageText.destroy(); - this.centerMessageText = new CenterMessageText("[ " + this.gameLevelManager.getWordLevelText() + " ] 단계 활성화"); + showLevelUpText: function(wordLevel) { + this.centerMessageText.showText(wordLevel, this.gameLevelManager.getWordLevelText(wordLevel)); }, } diff --git a/src/game/typing/word_flyingsaucer/game_level_manager.js b/src/game/typing/word_flyingsaucer/game_level_manager.js index 086cc12..665bf3a 100644 --- a/src/game/typing/word_flyingsaucer/game_level_manager.js +++ b/src/game/typing/word_flyingsaucer/game_level_manager.js @@ -1,23 +1,31 @@ function GameLevelManager(mainGame) { this.mainGame = mainGame; + this.extractWordManager = null; this.wordLevel = 0; this.clearedWordCountForLevel = [0, 0, 0, 0, 0, 0]; +} + +GameLevelManager.prototype.setExtractWordManager = function(extractWordManager) { + this.extractWordManager = extractWordManager; this.difficultyForLevelList = []; - for(var i = 0; i < GameLevelManager.MAX_WORD_LEVEL; i++) + var count = this.extractWordManager.getWordLevelCount(); + for(var i = 0; i < count; i++) this.difficultyForLevelList[i] = ExtractWordManager.DIFFICULTY_EASY; } GameLevelManager.prototype.getWordLevel = function() { + // return this.wordLevel; + var randomLevel = Math.floor(Math.random() * (this.wordLevel + 1)); return randomLevel; } -GameLevelManager.prototype.getWordLevelText = function() { +GameLevelManager.prototype.getWordLevelText = function(wordLevel) { var wordLevelText = ""; - switch(this.wordLevel) { + switch(wordLevel) { case 0: if(isKoreanTypingApp()) wordLevelText = "기본자리"; else wordLevelText = "Basic"; @@ -65,14 +73,15 @@ GameLevelManager.prototype.getDifficultyForLevel = function(wordLevel) { return this.difficultyForLevelList[wordLevel]; } -GameLevelManager.prototype.getStandardScore = function(wordLevel, speed) { - return (wordLevel + 1) * (speed + 1); +GameLevelManager.prototype.getStandardScore = function(wordLevel, difficulty, speed) { + return (wordLevel + 1) * (1 + difficulty) * (speed + 1); } GameLevelManager.prototype.clearWord = function(wordLevel, landingRatio) { // console.log("===="); - // for(var i = 0; i < GameLevelManager.MAX_WORD_LEVEL; i++) { + // var count = this.extractWordManager.getWordLevelCount(); + // for(var i = 0; i < count; i++) { // console.log("difficultyForLevelList[" + i + "] : " + this.difficultyForLevelList[i]); // } @@ -81,29 +90,20 @@ GameLevelManager.prototype.clearWord = function(wordLevel, landingRatio) { this.increaseClearedWordCountForLevel(wordLevel); - if(this.wordLevel == GameLevelManager.MAX_WORD_LEVEL) { - // console.log("*** no more higher word level"); - return; - } - - if(wordLevel < this.wordLevel) { - // console.log("*** already goNextLevel"); - return; - } - if(landingRatio < GameLevelManager.LEVEL_UP_LANDING_RATIO) { // console.log("*** not enough ratio"); return; } - this.goNextWordLevel(); + this.goNextWordLevel(wordLevel); } GameLevelManager.prototype.increaseClearedWordCountForLevel = function(wordLevel) { this.clearedWordCountForLevel[wordLevel] += 1; // console.log("===="); - // for(var i = 0; i < GameLevelManager.MAX_WORD_LEVEL; i++) { + // var count = this.extractWordManager.getWordLevelCount(); + // for(var i = 0; i < count; i++) { // console.log("clearedWordCountForLevel[" + i + "] : " + this.clearedWordCountForLevel[i]); // } @@ -124,20 +124,53 @@ GameLevelManager.prototype.increaseClearedWordCountForLevel = function(wordLevel } } -GameLevelManager.prototype.goNextWordLevel = function() { - this.wordLevel++; +GameLevelManager.prototype.goNextWordLevel = function(wordLevel) { + if(wordLevel < this.wordLevel) { + // console.log("*** already goNextLevel"); + return; + } - this.mainGame.showLevelUpText(); - // console.log("goNextWordLevel to " + this.wordLevel); + if(this.wordLevel < this.extractWordManager.getWordLevelCount() - 1) { + this.wordLevel++; + this.mainGame.showLevelUpText(this.wordLevel); + } } GameLevelManager.LEVEL_UP_LANDING_RATIO = 0.7; GameLevelManager.WARNING_LANDING_RATIO = 0.3; -GameLevelManager.MAX_WORD_LEVEL = 6; - GameLevelManager.CLEARED_WORD_COUNT_FOR_NEXT_LEVEL = [15, 12, 10, 9, 8, 7]; -// GameLevelManager.KOREAN_WORD_LENGTH = [2, 3]; -// GameLevelManager.ENGLISH_WORD_LENGTH = [3, 6];; \ No newline at end of file +GameLevelManager.COCKPIT_COLOR_LIST = [ + 0xff66ff, + 0x9966ff, + 0x3399ff, + 0x00ffff, + 0x66ff66, + 0xffff66, + 0xff6633, + 0xff6666 +] + +GameLevelManager.CENTER_MESSAGE_TEXT_COLOR_LIST = [ + "#ff66ff", + "#9966ff", + "#3399ff", + "#00ffff", + "#66ff66", + "#ffff66", + "#ff6633", + "#ff6666" +] + +GameLevelManager.CENTER_MESSAGE_STROKE_COLOR_LIST = [ + "#662266", + "#332266", + "#113366", + "#006666", + "#226622", + "#666622", + "#662211", + "#662222" +] \ No newline at end of file diff --git a/src/web/client/word_flyingsaucer.html b/src/web/client/word_flyingsaucer.html index c4c2fbb..4c11867 100644 --- a/src/web/client/word_flyingsaucer.html +++ b/src/web/client/word_flyingsaucer.html @@ -23,7 +23,7 @@ 격추! 비행접시 | 초코마에 - +