diff --git a/resources/image/ui/medal_bronze.png b/resources/image/ui/medal_bronze.png new file mode 100644 index 0000000..c34c290 Binary files /dev/null and b/resources/image/ui/medal_bronze.png differ diff --git a/resources/image/ui/medal_gold.png b/resources/image/ui/medal_gold.png new file mode 100644 index 0000000..5d2a8f5 Binary files /dev/null and b/resources/image/ui/medal_gold.png differ diff --git a/resources/image/ui/medal_silver.png b/resources/image/ui/medal_silver.png new file mode 100644 index 0000000..bcd5f49 Binary files /dev/null and b/resources/image/ui/medal_silver.png differ diff --git a/resources/image/ui/star_particle.png b/resources/image/ui/star_particle.png new file mode 100755 index 0000000..314b622 Binary files /dev/null and b/resources/image/ui/star_particle.png differ diff --git a/src/game/result/history_board.js b/src/game/result/history_board.js index 710f045..6762abe 100644 --- a/src/game/result/history_board.js +++ b/src/game/result/history_board.js @@ -9,6 +9,8 @@ class HistoryBoard { return; } + this.todayBestRecord = 0; + this.dbConnectManager = new DBConnectManager(); let arrayTabStyle = { font: "20px Arial", fill: "#fff", align: "left", tabs: [ 40, 80, 120 ] }; @@ -32,6 +34,9 @@ class HistoryBoard { for(let i = 0; i < historyRecordManager.count; i++) { let data = historyRecordManager.getAt(i); this.printRecord(i, data.date, data.bestRecord); + + if(date == data.date) + this.todayBestRecord = data.bestRecord; } } ); @@ -98,4 +103,9 @@ class HistoryBoard { this.printRecord(5, DateUtil.getYYYYMMDD(this.calcDate(15)), 840); this.printRecord(6, DateUtil.getYYYYMMDD(this.calcDate(20)), 760); } + + todayBestRecord() { + return this.todayBestRecord; + } + } \ No newline at end of file diff --git a/src/game/result/ranking_board.js b/src/game/result/ranking_board.js index 8859380..d327d82 100644 --- a/src/game/result/ranking_board.js +++ b/src/game/result/ranking_board.js @@ -9,15 +9,16 @@ class RankingBoard { return; } - this.dbConnectManager = new DBConnectManager(); + this.makeMedalSprites(); + this.dbConnectManager = new DBConnectManager(); this.requestRanking(DBConnectManager.TYPE_MY_RANKING_HOUR); this.requestRanking(DBConnectManager.TYPE_MY_RANKING_DAY); this.requestRanking(DBConnectManager.TYPE_MY_RANKING_MONTH); } - requestRanking(type, rankingRecordManager) { + requestRanking(type) { let today = new Date(); let date = DateUtil.getYYYYMMDD(today); let time = DateUtil.getHHMMSS(today); @@ -37,6 +38,21 @@ class RankingBoard { let data = rankingRecordManager.getAt(index); this.printRecord(type, i, data); } + + switch(type) { + case DBConnectManager.TYPE_MY_RANKING_HOUR: + this.showMedal(this.medalHour, this.getMyRank(rankingRecordManager)); + break; + + case DBConnectManager.TYPE_MY_RANKING_DAY: + this.showMedal(this.medalDay, this.getMyRank(rankingRecordManager)); + break; + + case DBConnectManager.TYPE_MY_RANKING_MONTH: + this.showMedal(this.medalMonth, this.getMyRank(rankingRecordManager)); + break; + + } } ); } @@ -208,4 +224,45 @@ class RankingBoard { new RankingRecord(4, 0, "6-3이철수", 480) ); } + + + static loadResources() { + game.load.image('medal_gold', '../../../resources/image/ui/medal_gold.png'); + game.load.image('medal_silver', '../../../resources/image/ui/medal_silver.png'); + game.load.image('medal_bronze', '../../../resources/image/ui/medal_bronze.png'); + } + + makeMedalSprites() { + let rankAreaPositionY = 630; + this.medalHour = game.add.image(425, rankAreaPositionY, 'medal_gold'); + this.medalHour.anchor.set(0.5); + this.medalHour.alpha = 0; + + this.medalDay = game.add.image(655, rankAreaPositionY, 'medal_gold'); + this.medalDay.anchor.set(0.5); + this.medalDay.alpha = 0; + + this.medalMonth = game.add.image(885, rankAreaPositionY, 'medal_gold'); + this.medalMonth.anchor.set(0.5); + this.medalMonth.alpha = 0; + } + + showMedal(medal, myRank) { + if(myRank > 3) { + medal.alpha = 0; + return; + } + + if(myRank == 1) + medal.loadTexture("medal_gold"); + else if(myRank == 2) + medal.loadTexture("medal_silver"); + else if(myRank == 3) + medal.loadTexture("medal_bronze"); + + medal.alpha = 1; + medal.scale.setTo(0.5); + game.add.tween(medal.scale).to( {x: 0.7, y: 0.7}, 1000, Phaser.Easing.Bounce.Out, true); + } + } \ No newline at end of file diff --git a/src/game/result/result.js b/src/game/result/result.js index d0adb16..14a42ff 100644 --- a/src/game/result/result.js +++ b/src/game/result/result.js @@ -7,6 +7,9 @@ class Result { game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png'); Animal.loadResources(); + + RankingBoard.loadResources(); + game.load.image('star', '../../../resources/image/ui/star_particle.png'); } create() { @@ -15,7 +18,6 @@ class Result { this.game.stage.backgroundColor = '#4d4d4d'; this.chartGraphics = game.add.graphics(100, game.world.height - 120); - // top ui let screenTopUI = new ScreenTopUI(); screenTopUI.makeBackButton( () => { @@ -33,6 +35,7 @@ class Result { // contents this.printRecord(); + this.printTodayBestRecord(); this.uploadRecord(); this.makeRestartButton(); @@ -45,6 +48,7 @@ class Result { let recordBoard = new RecordBoard(RecordBoard.TYPE_DB); } + // bottom ui let screenBottomUI = new ScreenBottomUI(); screenBottomUI.printLeftTextWithBestRecord(Math.floor(sessionStorageManager.bestRecord)); @@ -90,27 +94,42 @@ class Result { ); scoreText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); scoreText.anchor.set(0.5); + } + recordUnit() { + let recordUnit = ""; + if(sessionStorageManager.playingAppID >= 100) + return "점"; + else + return "타"; + } - if(sessionStorageManager.isNewBestRecrd === true) { - style.font = "32px Arial"; - let bestRecordText = game.add.text(game.world.width / 2, 110, "!!! 새로운 최고 기록 !!!", style); - // .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); - bestRecordText.anchor.set(0.5); - bestRecordText.stroke = "#333"; - bestRecordText.strokeThickness = 5; - } - /* - if(sessionStorageManager.bestRecord === null) - sessionStorageManager.bestRecord = 0; - let bestRecord = NumberUtil.numberWithCommas(sessionStorageManager.bestRecord); - style.font = "32px Arial"; - let bestRecordText = game.add.text(0, 0, "오늘 최고 기록 : " + bestRecord, style) - .setTextBounds(0, posY + 80, game.world.width, 40); - // .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); + printTodayBestRecord() { + let newRecordEmitter = game.add.emitter(game.world.centerX, 140, 300); + newRecordEmitter.makeParticles('star'); + newRecordEmitter.gravity = 300; + + let style = { font: "32px Arial", fill: "#ff0", align: "left", boundsAlignH: "center", boundsAlignV: "middle" }; + let bestRecordText = game.add.text(game.world.centerX, 220, "", style); + bestRecordText.anchor.set(0.5); bestRecordText.stroke = "#333"; bestRecordText.strokeThickness = 5; - */ + + if(sessionStorageManager.bestRecord === null) + sessionStorageManager.bestRecord = 0; + + let todayBestRecord = 0; + let flooredBestRecord = Math.floor(sessionStorageManager.bestRecord); + let bestRecordWithCommas = NumberUtil.numberWithCommas(flooredBestRecord); + + if(sessionStorageManager.record >= sessionStorageManager.bestRecord) { + sessionStorageManager.bestRecord = sessionStorageManager.record; + + bestRecordText.text = "! : . 오늘 최고 기록 . : !"; + newRecordEmitter.start(true, 2000, null, 20); + } else { + bestRecordText.text = ""; + } } uploadRecord() { diff --git a/src/web/main/index.html b/src/web/main/index.html index 0d29f22..1732c43 100644 --- a/src/web/main/index.html +++ b/src/web/main/index.html @@ -3,7 +3,7 @@ - + 마우스 타자 연습