From 3fce5e25fa7ab5aa281cbf2ea7c6d1fa0e9c4948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=A2=E1=84=91=E1=85=B3=E1=86=AF=20=E1=84=82?= =?UTF-8?q?=E1=85=A9=E1=84=90=E1=85=B3=E1=84=87=E1=85=AE=E1=86=A8?= Date: Sun, 6 Jan 2019 07:51:54 +0900 Subject: [PATCH] Fix: change cockpit color --- .../typing/word_flyingsaucer/flyingsaucer.js | 68 ++++++++++++++++--- .../word_flyingsaucer/game_level_manager.js | 2 +- 2 files changed, 58 insertions(+), 12 deletions(-) diff --git a/src/game/typing/word_flyingsaucer/flyingsaucer.js b/src/game/typing/word_flyingsaucer/flyingsaucer.js index 0019786..a64b16a 100644 --- a/src/game/typing/word_flyingsaucer/flyingsaucer.js +++ b/src/game/typing/word_flyingsaucer/flyingsaucer.js @@ -19,8 +19,8 @@ function FlyingSaucer(lineIndex) { var BODY_OFFSET_Y = 28; var JET_OFFSET_Y = 52; - var cockpit = this.makeCockpit(0, COCKPIT_OFFSET_Y); - this.addChild(cockpit); + this.cockpit = this.makeCockpit(0, COCKPIT_OFFSET_Y); + this.addChild(this.cockpit); this.jetLeft = this.makeJet(-50, JET_OFFSET_Y); this.addChild(this.jetLeft); @@ -50,6 +50,7 @@ FlyingSaucer.prototype.initVariables = function() { this.wordLevel = 0; this.wordScore = 0; this.speed = FlyingSaucer.DEFAULT_SPEED; + this.jetStatus = FlyingSaucer.JET_STATUS_HIGH; this.scoreManager = null; this.heartManager = null; @@ -71,7 +72,7 @@ FlyingSaucer.prototype.makeCockpit = function(posX, posY) { FlyingSaucer.prototype.makeJet = function(posX, posY) { var jet = game.make.sprite(posX, posY, 'ship_jet'); jet.anchor.set(0.5); - jet.tint = 0xffff00; + jet.tint = FlyingSaucer.JET_COLOR_HIGH; return jet; } @@ -102,6 +103,8 @@ FlyingSaucer.prototype.update = function() { this.wordText.y = this.y + FlyingSaucer.WORD_TEXT_OFFSET_Y; + this.updateJetColor(); + if(this.y > FlyingSaucer.CRASH_POS_Y) this.crash(); } else { @@ -109,6 +112,29 @@ FlyingSaucer.prototype.update = function() { } } +FlyingSaucer.prototype.updateJetColor = function() { + var landingRatio = this.getLandingRatio(); + + if(this.jetStatus == FlyingSaucer.JET_STATUS_HIGH && landingRatio < 0.9) { + this.jetStatus = FlyingSaucer.JET_STATUS_MIDDLE; + this.changeJetColor(FlyingSaucer.JET_COLOR_MIDDLE); + } else if(this.jetStatus == FlyingSaucer.JET_STATUS_MIDDLE && landingRatio < 0.1) { + this.jetStatus = FlyingSaucer.JET_STATUS_LOW; + this.changeJetColor(FlyingSaucer.JET_COLOR_LOW); + } +} + +FlyingSaucer.prototype.changeJetColor = function(color) { + this.jetLeft.tint = color; + this.jetCenter.tint = color; + this.jetRight.tint = color; +} + +FlyingSaucer.prototype.changeCockpitColor = function(color) { + this.cockpit.tint = FlyingSaucer.COKCPIT_COLOR[this.wordLevel - 1]; +} + + FlyingSaucer.prototype.setScoreManager = function(scoreManager) { this.scoreManager = scoreManager; } @@ -150,6 +176,11 @@ FlyingSaucer.prototype.setActive = function(isActivated) { FlyingSaucer.prototype.moveInitialPos = function() { this.x = 100 + this.lineIndex * 200; this.y = FlyingSaucer.START_POS_Y; + this.speed += FlyingSaucer.SPEED_UP_AMOUNT; + + this.changeCockpitColor(); + this.jetStatus = FlyingSaucer.JET_STATUS_HIGH; + this.changeJetColor(FlyingSaucer.JET_COLOR_HIGH); this.wordText.x = this.x; this.wordText.y = this.y + FlyingSaucer.WORD_TEXT_OFFSET_Y; @@ -159,12 +190,13 @@ FlyingSaucer.prototype.moveInitialPos = function() { FlyingSaucer.prototype.startAttack = function() { - this.moveInitialPos(); this.wordLevel = this.gameLevelManager.getWordLevel(); this.word = this.wordManager.getWord(this.wordLevel); this.setWord(this.word); this.wordScore = this.gameLevelManager.getWordScore(); // console.log(this.wordScore); + + this.moveInitialPos(); this.setActive(true); } @@ -197,7 +229,7 @@ FlyingSaucer.prototype.checkInputText = function(inputText) { this.wordText.addColor(FlyingSaucer.TEXT_COLOR_NORMAL, index); } -FlyingSaucer.prototype.getClearTiming = function(inputText) { +FlyingSaucer.prototype.getLandingRatio = function(inputText) { var heightDown = FlyingSaucer.CRASH_POS_Y - FlyingSaucer.START_POS_Y; var distanceDown = this.y - FlyingSaucer.START_POS_Y; return (heightDown - distanceDown) / heightDown; @@ -210,7 +242,7 @@ FlyingSaucer.prototype.checkWord = function(inputText) { // var word = this.wordText.text; if(this.word == inputText) { - this.gameLevelManager.clearWord(this.wordLevel, this.getClearTiming()); + this.gameLevelManager.clearWord(this.wordLevel, this.getLandingRatio()); this.wordManager.removeWord(this.wordLevel, this.word); this.setWord(""); this.setActive(false); @@ -230,9 +262,9 @@ FlyingSaucer.prototype.explode = function(inputText) { } FlyingSaucer.prototype.plusScore = function(inputText) { - console.log(this.wordScore); - console.log(this.getClearTiming()); - var totalScore = Math.floor(this.wordScore * (this.getClearTiming() * 100)); + // console.log(this.wordScore); + // console.log(this.getLandingRatio()); + var totalScore = Math.floor(this.wordScore * (this.getLandingRatio() * 100)); this.scoreManager.plusScore(totalScore); var scoreText = new ScoreText(this.x, this.y, totalScore); } @@ -265,11 +297,25 @@ FlyingSaucer.loadResource = function() { FlyingSaucer.DEFAULT_SPEED = 10; // dot per sec +FlyingSaucer.SPEED_UP_AMOUNT = 4; // dot per sec +FlyingSaucer.SPEED_DOWN_AMOUNT = FlyingSaucer.SPEED_UP_AMOUNT / 2; // dot per sec FlyingSaucer.START_POS_Y = 100; // px FlyingSaucer.CRASH_POS_Y = GAME_SCREEN_SIZE.y - 200; // px FlyingSaucer.WORD_TEXT_OFFSET_Y = 30; // px -FlyingSaucer.TEXT_COLOR_NORMAL = "#000000"; -FlyingSaucer.TEXT_COLOR_CORRECT = "#ffff4d"; \ No newline at end of file +FlyingSaucer.TEXT_COLOR_NORMAL = "#000000"; +FlyingSaucer.TEXT_COLOR_CORRECT = "#ffff4d"; + +FlyingSaucer.JET_STATUS_HIGH = 0; +FlyingSaucer.JET_STATUS_MIDDLE = 1; +FlyingSaucer.JET_STATUS_LOW = 2; + +FlyingSaucer.JET_COLOR_HIGH = 0x00ffff; +FlyingSaucer.JET_COLOR_MIDDLE = 0xffff00; +FlyingSaucer.JET_COLOR_LOW = 0xff0000; + +FlyingSaucer.COKCPIT_COLOR = [ + 0xff0000, 0xff6600, 0xff0000, 0x00ffff, 0x00ffff, 0x6666ff, 0xff00ff +] diff --git a/src/game/typing/word_flyingsaucer/game_level_manager.js b/src/game/typing/word_flyingsaucer/game_level_manager.js index 2f7d475..a896e4f 100644 --- a/src/game/typing/word_flyingsaucer/game_level_manager.js +++ b/src/game/typing/word_flyingsaucer/game_level_manager.js @@ -26,6 +26,6 @@ GameLevelManager.prototype.clearWord = function(wordLevel, clearTiming) { } -GameLevelManager.LEVELUP_TIMING = 0.9; +GameLevelManager.LEVELUP_TIMING = 0.5; GameLevelManager.MAX_KOR_WORD_LEVEL = 7; \ No newline at end of file