diff --git a/src/game/lib/heart_gauge.js b/src/game/lib/heart_gauge.js index 5a26bd0..4084fcd 100644 --- a/src/game/lib/heart_gauge.js +++ b/src/game/lib/heart_gauge.js @@ -45,5 +45,10 @@ HeartGauge.prototype.updateHearts = function() { } } +HeartGauge.loadResources = function() { + game.load.image('heart_full', '../../../resources/image/ui/heart_full.png'); + game.load.image('heart_empty', '../../../resources/image/ui/heart_empty.png'); +} + HeartGauge.GAP = 35; HeartGauge.HEART_SCALE = 0.6; \ No newline at end of file diff --git a/src/game/typing/word_flyingsaucer/game.js b/src/game/typing/word_flyingsaucer/game.js new file mode 100644 index 0000000..f5dc5f8 --- /dev/null +++ b/src/game/typing/word_flyingsaucer/game.js @@ -0,0 +1,96 @@ +var WordFlyingSaucer = { + + create: function() { + this.dbConnectManager = new DBConnectManager(); + sessionStorageManager.setRecord(0); + + sessionStorageManager.setIsNewAppHighestRecord(false); + + var experienceAppTimer = new ExperienceAppTimer(); + experienceAppTimer.setTimeOverListener( + (function() { this.timeOver(); }).bind(this) + ); + + game.stage.backgroundColor = '#4d4d4d'; + + // top ui + var screenTopUI = new ScreenTopUI(); + screenTopUI.makeBackButton( (function() { this.back(); }).bind(this) ); + screenTopUI.makeFullScreenButton(); + + + this.scoreManager = new ScoreManager(); + this.scoreBoard = new ScoreBoard(); + this.scoreManager.addOnChangeScoreListener( + (function(score) { + sessionStorageManager.setRecord(score); + this.scoreBoard.printScore(NumberUtil.numberWithCommas(score)); + }).bind(this) + ); + this.scoreManager.addOnChangeHighScoreListener( + (function(highScore) { + console.log(highScore); + // sessionStorageManager.setAppHighestRecord(highScore); + sessionStorageManager.setIsNewBestRecrd(true); + // this.screenBottomUI.printLeftTextWithAppHighestRecord(sessionStorageManager.getAppHighestRecord()); + }).bind(this) + ); + + var heartManager = new HeartManager(); + var heartGauge = new HeartGauge(heartManager); + heartManager.addOnChangeGameOverListener( + (function() { this.gameOver(); }).bind(this) + ); + heartGauge.start(); + + + + + + // bottom ui + this.screenBottomUI = new ScreenBottomUI(); + // screenBottomUI.printBottomUILeftText(""); + this.screenBottomUI.printCenterText(sessionStorageManager.getPlayingAppKoreanName()); + this.screenBottomUI.printRightText(sessionStorageManager.getPlayerName()); + + + // this.startGame(); + }, + + + back: function() { + sessionStorageManager.resetPlayingAppData(); + location.href = '../../web/client/menu_app.html'; + }, + + startGame: function() { + }, + + timeOver: function() { + var timeOverText = new TimeOverText(); + + sessionStorageManager.setRecord(this.scoreManager.getScore()); + if(!isExperienceMaestroAccount()) + this.updateResultRecord(); + + game.time.events.add(Phaser.Timer.SECOND * 2, this.goResult, this); + }, + + updateResultRecord: function() { + if(sessionStorageManager.getMaestroAccountType() < 100) { // experience account + this.dbConnectManager.updateResultRecord( + sessionStorageManager.getMaestroID(), + sessionStorageManager.getPlayerID(), + sessionStorageManager.getPlayingAppID(), + sessionStorageManager.getRecord() + ); + } + }, + + goResult: function() { + location.href = '../../web/client/result.html'; + }, + +} + + diff --git a/src/game/typing/word_flyingsaucer/loading.js b/src/game/typing/word_flyingsaucer/loading.js new file mode 100644 index 0000000..51c74cc --- /dev/null +++ b/src/game/typing/word_flyingsaucer/loading.js @@ -0,0 +1,94 @@ +var Loading = { + + preload: function() { + // game.load.image('loadingbar', './image/phaser.png'); + }, + + create: function() { + // var userID = sessionStorage.getItem("UserID"); + // console.log("userID : " + userID); + + // game.stage.backgroundColor = '#4d4d4d'; + + // // Progress report + // this.textProgress = game.add.text(game.world.centerX, 100, '로딩중 . . .', textStyleBasic); + // this.textProgress.anchor.setTo(0.5, 0.4); + // this.textProgress.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); + + // // Preload bar + // this.preloadBar = this.add.sprite(game.world.centerX, game.world.centerY, 'loadingbar'); + // this.preloadBar.anchor.setTo(0.5); + // this.preloadBar.alpha = 0; + + game.load.onFileComplete.add(this.fileComplete, this); + game.load.onLoadComplete.add(this.loadComplete, this); + + this.startLoading(); + }, + + startLoading: function() { + game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png'); + + game.load.image('star', '../../../resources/image/ui/star_particle.png'); + + HeartGauge.loadResources(); + + // game.load.image('hand_left', '../../../resources/image/ui/hand_left.png'); + // game.load.image('hand_right', '../../../resources/image/ui/hand_right.png'); + // game.load.image('a', '../../../resources/image/icon/fullscreen_white.png'); + // game.load.image('b', '../../../resources/image/icon/fullscreen_white.png'); + // game.load.image('c', '../../../resources/image/icon/fullscreen_white.png'); + // game.load.image('d', '../../../resources/image/icon/fullscreen_white.png'); + // game.load.image('a', './image/phaser.png'); + // game.load.image('b', './image/phaser.png'); + // game.load.image('c', './image/phaser.png'); + // game.load.image('d', './image/phaser.png'); + // game.load.image('e', './image/phaser.png'); + // game.load.image('g', './image/phaser.png'); + // game.load.image('e', './image/phaser.png'); + // game.load.image('f', './image/phaser.png'); + // game.load.image('g', './image/phaser.png'); + // game.load.image('h', './image/phaser.png'); + + // game.load.image('phaser', './image/phaser.png'); + // game.load.spritesheet('button', './image/button_basic.png', 200, 100); + // game.load.image('star', './image/star_particle.png'); + // game.load.image('medal_gold', './image/medal_gold.png'); + // game.load.image('medal_silver', './image/medal_silver.png'); + // game.load.image('medal_bronze', './image/medal_bronze.png'); + + game.load.start(); + }, + + fileComplete: function(progress, cacheKey, success, totalLoaded, totalFiles) { + // this.preloadBar.alpha = progress / 100; + + // console.log('progress : ' + progress); + + // text.setText("File Complete: " + progress + "% - " + totalLoaded + " out of " + totalFiles); + + // var newImage = game.add.image(x, y, cacheKey); + // newImage.scale.set(0.3); + + // x += newImage.width + 20; + // if (x > 700) + // { + // x = 32; + // y += 332; + // } + }, + + loadComplete: function(progress, cacheKey, success, totalLoaded, totalFiles) { + // this.preloadBar.alpha = 1; + + if(isDebugMode()) { + this.state.start('WordFlyingSaucer'); + return; + } + + this.state.start('WordFlyingSaucer'); + // this.startMenu(); + // this.startTypingTestStage(); + // this.startTypingTestResult(); + } +} diff --git a/src/game/typing/word_flyingsaucer/main.js b/src/game/typing/word_flyingsaucer/main.js new file mode 100644 index 0000000..ed9f754e --- /dev/null +++ b/src/game/typing/word_flyingsaucer/main.js @@ -0,0 +1,16 @@ +///////////////////////////// +// Main game + +var CONTENT_ID = "WordFlyingSaucer"; + +var game = new Phaser.Game( + GAME_SCREEN_SIZE.x, GAME_SCREEN_SIZE.y, + Phaser.CANVAS, CONTENT_ID, + this, false, false +); + +game.state.add('Loading', Loading); +game.state.start('Loading'); + +game.state.add('WordFlyingSaucer', WordFlyingSaucer); +// game.state.add('Menu', Menu); diff --git a/src/game/typing/word_flyingsaucer/typing_score.js b/src/game/typing/word_flyingsaucer/typing_score.js new file mode 100644 index 0000000..70c8172 --- /dev/null +++ b/src/game/typing/word_flyingsaucer/typing_score.js @@ -0,0 +1,54 @@ +function TypingScore() { + this.typingCount = 0; + + var fontStyle = TypingScore.DEFAULT_TEXT_FONT; + + fontStyle.align = "right"; + fontStyle.boundsAlignH = "right"; + this.scoreTitleText = game.add.text(game.world.width / 2 - 40, TypingScore.SCORE_POS_Y, "연속 성공 타수 : ", fontStyle) + this.scoreTitleText.anchor.set(0.5); + + fontStyle.align = "left"; + fontStyle.boundsAlignH = "left"; + this.scoreText = game.add.text(game.world.width / 2 + 100, TypingScore.SCORE_POS_Y, "0", fontStyle) + this.scoreText.anchor.set(0.5); + + // var grd = this.scoreText.context.createLinearGradient(0, 0, 0, TypingScore.SCORE_POS_Y); + // grd.addColorStop(0, '#8ED6FF'); + // grd.addColorStop(1, '#004CB3'); + // this.scoreText.fill = grd; + // this.scoreText.fill = grd; + + // this.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); + // this.scoreText.stroke = '#000'; + // this.scoreText.strokeThickness = 3; +}; + +TypingScore.prototype.score = function() { + return this.typingCount; +} + +TypingScore.prototype.increase = function() { + this.typingCount++; + this.print(this.typingCount); +} + +TypingScore.prototype.reset = function() { + this.typingCount = 0; + this.print(this.typingCount); +} + +TypingScore.prototype.print = function(typingCount) { + this.scoreText.text = typingCount; +} + + +TypingScore.SCORE_POS_Y = 35; + +TypingScore.DEFAULT_TEXT_FONT = { +font: "38px Arial", +align: "center", +boundsAlignH: "center", // left, center. right +boundsAlignV: "middle", // top, middle, bottom +fill: "#fff" +}; \ No newline at end of file diff --git a/src/web/client/word_flyingsaucer.html b/src/web/client/word_flyingsaucer.html new file mode 100644 index 0000000..1eccbe0 --- /dev/null +++ b/src/web/client/word_flyingsaucer.html @@ -0,0 +1,115 @@ + + +
+ + + + + + + + + + + +