Add: medals and new high score particle

This commit is contained in:
2018-09-12 09:08:04 +09:00
parent d458cedf7a
commit f38e779317
8 changed files with 107 additions and 21 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

+10
View File
@@ -9,6 +9,8 @@ class HistoryBoard {
return; return;
} }
this.todayBestRecord = 0;
this.dbConnectManager = new DBConnectManager(); this.dbConnectManager = new DBConnectManager();
let arrayTabStyle = { font: "20px Arial", fill: "#fff", align: "left", tabs: [ 40, 80, 120 ] }; 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++) { for(let i = 0; i < historyRecordManager.count; i++) {
let data = historyRecordManager.getAt(i); let data = historyRecordManager.getAt(i);
this.printRecord(i, data.date, data.bestRecord); 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(5, DateUtil.getYYYYMMDD(this.calcDate(15)), 840);
this.printRecord(6, DateUtil.getYYYYMMDD(this.calcDate(20)), 760); this.printRecord(6, DateUtil.getYYYYMMDD(this.calcDate(20)), 760);
} }
todayBestRecord() {
return this.todayBestRecord;
}
} }
+59 -2
View File
@@ -9,15 +9,16 @@ class RankingBoard {
return; return;
} }
this.dbConnectManager = new DBConnectManager(); this.makeMedalSprites();
this.dbConnectManager = new DBConnectManager();
this.requestRanking(DBConnectManager.TYPE_MY_RANKING_HOUR); this.requestRanking(DBConnectManager.TYPE_MY_RANKING_HOUR);
this.requestRanking(DBConnectManager.TYPE_MY_RANKING_DAY); this.requestRanking(DBConnectManager.TYPE_MY_RANKING_DAY);
this.requestRanking(DBConnectManager.TYPE_MY_RANKING_MONTH); this.requestRanking(DBConnectManager.TYPE_MY_RANKING_MONTH);
} }
requestRanking(type, rankingRecordManager) { requestRanking(type) {
let today = new Date(); let today = new Date();
let date = DateUtil.getYYYYMMDD(today); let date = DateUtil.getYYYYMMDD(today);
let time = DateUtil.getHHMMSS(today); let time = DateUtil.getHHMMSS(today);
@@ -37,6 +38,21 @@ class RankingBoard {
let data = rankingRecordManager.getAt(index); let data = rankingRecordManager.getAt(index);
this.printRecord(type, i, data); 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) 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);
}
} }
+37 -18
View File
@@ -7,6 +7,9 @@ class Result {
game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png'); game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png');
Animal.loadResources(); Animal.loadResources();
RankingBoard.loadResources();
game.load.image('star', '../../../resources/image/ui/star_particle.png');
} }
create() { create() {
@@ -15,7 +18,6 @@ class Result {
this.game.stage.backgroundColor = '#4d4d4d'; this.game.stage.backgroundColor = '#4d4d4d';
this.chartGraphics = game.add.graphics(100, game.world.height - 120); this.chartGraphics = game.add.graphics(100, game.world.height - 120);
// top ui // top ui
let screenTopUI = new ScreenTopUI(); let screenTopUI = new ScreenTopUI();
screenTopUI.makeBackButton( () => { screenTopUI.makeBackButton( () => {
@@ -33,6 +35,7 @@ class Result {
// contents // contents
this.printRecord(); this.printRecord();
this.printTodayBestRecord();
this.uploadRecord(); this.uploadRecord();
this.makeRestartButton(); this.makeRestartButton();
@@ -45,6 +48,7 @@ class Result {
let recordBoard = new RecordBoard(RecordBoard.TYPE_DB); let recordBoard = new RecordBoard(RecordBoard.TYPE_DB);
} }
// bottom ui // bottom ui
let screenBottomUI = new ScreenBottomUI(); let screenBottomUI = new ScreenBottomUI();
screenBottomUI.printLeftTextWithBestRecord(Math.floor(sessionStorageManager.bestRecord)); screenBottomUI.printLeftTextWithBestRecord(Math.floor(sessionStorageManager.bestRecord));
@@ -90,27 +94,42 @@ class Result {
); );
scoreText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); scoreText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
scoreText.anchor.set(0.5); scoreText.anchor.set(0.5);
}
recordUnit() {
let recordUnit = "";
if(sessionStorageManager.playingAppID >= 100)
return "점";
else
return "타";
}
if(sessionStorageManager.isNewBestRecrd === true) { printTodayBestRecord() {
style.font = "32px Arial"; let newRecordEmitter = game.add.emitter(game.world.centerX, 140, 300);
let bestRecordText = game.add.text(game.world.width / 2, 110, "!!! 새로운 최고 기록 !!!", style); newRecordEmitter.makeParticles('star');
// .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2); newRecordEmitter.gravity = 300;
bestRecordText.anchor.set(0.5);
bestRecordText.stroke = "#333"; let style = { font: "32px Arial", fill: "#ff0", align: "left", boundsAlignH: "center", boundsAlignV: "middle" };
bestRecordText.strokeThickness = 5; let bestRecordText = game.add.text(game.world.centerX, 220, "", style);
} bestRecordText.anchor.set(0.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);
bestRecordText.stroke = "#333"; bestRecordText.stroke = "#333";
bestRecordText.strokeThickness = 5; 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() { uploadRecord() {
+1 -1
View File
@@ -3,7 +3,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <!-- <meta http-equiv="X-UA-Compatible" content="IE=edge"> -->
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>마우스 타자 연습</title> <title>마우스 타자 연습</title>