Fix: show best record with DB
This commit is contained in:
@@ -8,6 +8,8 @@ class ScreenBottom {
|
|||||||
this.BOTTOM_BAR_NAME_WIDTH = 200;
|
this.BOTTOM_BAR_NAME_WIDTH = 200;
|
||||||
this.BOTTOM_BAR_TEXT_OFFSET = 10;
|
this.BOTTOM_BAR_TEXT_OFFSET = 10;
|
||||||
|
|
||||||
|
this.dbConnectManager = new DBConnectManager();
|
||||||
|
|
||||||
this.bottomAreaPositionY = game.world.height - this.BOTTOM_BAR_HEIGHT;
|
this.bottomAreaPositionY = game.world.height - this.BOTTOM_BAR_HEIGHT;
|
||||||
|
|
||||||
let style = { font: "32px Arial", fill: "#fff", align: "left", boundsAlignH: "left", boundsAlignV: "bottom" };
|
let style = { font: "32px Arial", fill: "#fff", align: "left", boundsAlignH: "left", boundsAlignV: "bottom" };
|
||||||
@@ -61,4 +63,8 @@ class ScreenBottom {
|
|||||||
this.rightText.text = text;
|
this.rightText.text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printBottomLeftTextWithBestRecord(bestRecord) {
|
||||||
|
this.printBottomLeftText("오늘의 최고 기록 : " + bestRecord);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -75,4 +75,12 @@ class SessionStorageManager {
|
|||||||
return sessionStorage.getItem("bestRecord");
|
return sessionStorage.getItem("bestRecord");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// best record
|
||||||
|
set isNewBestRecord(value) {
|
||||||
|
sessionStorage.setItem("isNewBestRecord", value);
|
||||||
|
}
|
||||||
|
get isNewBestRecord() {
|
||||||
|
return sessionStorage.getItem("isNewBestRecord");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -6,21 +6,13 @@ class Game {
|
|||||||
create() {
|
create() {
|
||||||
this.game.stage.backgroundColor = '#4d4d4d';
|
this.game.stage.backgroundColor = '#4d4d4d';
|
||||||
|
|
||||||
|
sessionStorageManager.isNewBestRecrd = false;
|
||||||
|
|
||||||
// top
|
// top
|
||||||
let backButton = new BackButton( () => {
|
let backButton = new BackButton( () => {
|
||||||
location.href = '../../web/client/menu_app.html';
|
location.href = '../../web/client/menu_app.html';
|
||||||
});
|
});
|
||||||
|
|
||||||
let scoreBoard = new ScoreBoard();
|
|
||||||
scoreManager.addOnChangeScoreListener( score => {
|
|
||||||
sessionStorageManager.record = score;
|
|
||||||
scoreBoard.printScore(NumberUtil.numberWithCommas(score));
|
|
||||||
});
|
|
||||||
scoreManager.addOnChangeHighScoreListener( highScore => {
|
|
||||||
sessionStorageManager.bestRecord = highScore;
|
|
||||||
screenBottom.printBottomLeftText("최고 기록 : " + NumberUtil.numberWithCommas(highScore));
|
|
||||||
});
|
|
||||||
|
|
||||||
let heartGauge = new HeartGauge(heartManager);
|
let heartGauge = new HeartGauge(heartManager);
|
||||||
heartManager.addOnChangeGameOverListener(
|
heartManager.addOnChangeGameOverListener(
|
||||||
() => { this.gameOver(); }
|
() => { this.gameOver(); }
|
||||||
@@ -30,6 +22,18 @@ class Game {
|
|||||||
let fullscreenButton = new FullscreenButton(this.game);
|
let fullscreenButton = new FullscreenButton(this.game);
|
||||||
|
|
||||||
|
|
||||||
|
let scoreBoard = new ScoreBoard();
|
||||||
|
scoreManager.addOnChangeScoreListener( score => {
|
||||||
|
sessionStorageManager.record = score;
|
||||||
|
scoreBoard.printScore(NumberUtil.numberWithCommas(score));
|
||||||
|
});
|
||||||
|
scoreManager.addOnChangeHighScoreListener( highScore => {
|
||||||
|
sessionStorageManager.bestRecord = highScore;
|
||||||
|
sessionStorageManager.isNewBestRecrd = true;
|
||||||
|
screenBottom.printBottomLeftTextWithBestRecord();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// waiting room
|
// waiting room
|
||||||
this.game.add.graphics()
|
this.game.add.graphics()
|
||||||
.beginFill(0xffffff, 0.1)
|
.beginFill(0xffffff, 0.1)
|
||||||
@@ -58,8 +62,7 @@ class Game {
|
|||||||
// bottom
|
// bottom
|
||||||
let screenBottom = new ScreenBottom();
|
let screenBottom = new ScreenBottom();
|
||||||
screenBottom.makeBottomLine();
|
screenBottom.makeBottomLine();
|
||||||
let highScore = NumberUtil.numberWithCommas(scoreManager.getHighScore());
|
screenBottom.printBottomLeftTextWithBestRecord(sessionStorageManager.bestRecord);
|
||||||
screenBottom.printBottomLeftText("최고 기록 : " + highScore);
|
|
||||||
screenBottom.printBottomCenterText(sessionStorageManager.playingAppKoreanName);
|
screenBottom.printBottomCenterText(sessionStorageManager.playingAppKoreanName);
|
||||||
screenBottom.printBottomRightText(sessionStorageManager.playerName);
|
screenBottom.printBottomRightText(sessionStorageManager.playerName);
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class Result {
|
|||||||
// bottom
|
// bottom
|
||||||
let screenBottom = new ScreenBottom();
|
let screenBottom = new ScreenBottom();
|
||||||
screenBottom.makeBottomLine();
|
screenBottom.makeBottomLine();
|
||||||
screenBottom.printBottomLeftText("게임 진행 정보");
|
screenBottom.printBottomLeftTextWithBestRecord(sessionStorageManager.bestRecord);
|
||||||
screenBottom.printBottomCenterText(sessionStorageManager.playingAppKoreanName);
|
screenBottom.printBottomCenterText(sessionStorageManager.playingAppKoreanName);
|
||||||
screenBottom.printBottomRightText(sessionStorageManager.playerName);
|
screenBottom.printBottomRightText(sessionStorageManager.playerName);
|
||||||
}
|
}
|
||||||
@@ -54,6 +54,16 @@ class Result {
|
|||||||
.setTextBounds(0, posY, game.world.width, 60)
|
.setTextBounds(0, posY, game.world.width, 60)
|
||||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||||
|
|
||||||
|
|
||||||
|
if(sessionStorageManager.isNewBestRecrd === true) {
|
||||||
|
style.font = "32px Arial";
|
||||||
|
let bestRecordText = game.add.text(0, 0, "!!! 새로운 최고 기록 !!!", style)
|
||||||
|
.setTextBounds(0, posY + 80, game.world.width, 40);
|
||||||
|
// .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||||
|
bestRecordText.stroke = "#333";
|
||||||
|
bestRecordText.strokeThickness = 5;
|
||||||
|
}
|
||||||
|
/*
|
||||||
if(sessionStorageManager.bestRecord === null)
|
if(sessionStorageManager.bestRecord === null)
|
||||||
sessionStorageManager.bestRecord = 0;
|
sessionStorageManager.bestRecord = 0;
|
||||||
let bestRecord = NumberUtil.numberWithCommas(sessionStorageManager.bestRecord);
|
let bestRecord = NumberUtil.numberWithCommas(sessionStorageManager.bestRecord);
|
||||||
@@ -63,6 +73,7 @@ class Result {
|
|||||||
// .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
// .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||||
bestRecordText.stroke = "#333";
|
bestRecordText.stroke = "#333";
|
||||||
bestRecordText.strokeThickness = 5;
|
bestRecordText.strokeThickness = 5;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadRecord() {
|
uploadRecord() {
|
||||||
|
|||||||
+14
-3
@@ -58,10 +58,21 @@ class Start {
|
|||||||
// bottom
|
// bottom
|
||||||
let screenBottom = new ScreenBottom();
|
let screenBottom = new ScreenBottom();
|
||||||
screenBottom.makeBottomLine();
|
screenBottom.makeBottomLine();
|
||||||
screenBottom.printBottomLeftText("게임 진행 정보");
|
screenBottom.printBottomLeftText("오늘의 최고 기록 : ");
|
||||||
let playingAppKoreanName = sessionStorageManager.playingAppKoreanName;
|
screenBottom.printBottomCenterText(sessionStorageManager.playingAppKoreanName);
|
||||||
screenBottom.printBottomCenterText(playingAppKoreanName);
|
|
||||||
screenBottom.printBottomRightText(sessionStorageManager.playerName);
|
screenBottom.printBottomRightText(sessionStorageManager.playerName);
|
||||||
|
|
||||||
|
|
||||||
|
this.dbConnectManager.requestTodayBestRecord(
|
||||||
|
sessionStorageManager.maestroID,
|
||||||
|
sessionStorageManager.playerUserID,
|
||||||
|
sessionStorageManager.playingAppID,
|
||||||
|
replyJSON => {
|
||||||
|
sessionStorageManager.BestRecord = Number(replyJSON["BestRecord"]);
|
||||||
|
let highScoreWithCommas = NumberUtil.numberWithCommas(sessionStorageManager.BestRecord);
|
||||||
|
screenBottom.printBottomLeftText("오늘의 최고 기록 : " + highScoreWithCommas);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
loadHowToPlay(appID) {
|
loadHowToPlay(appID) {
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
<script src="../../game/lib/round_rect_button.js"></script>
|
<script src="../../game/lib/round_rect_button.js"></script>
|
||||||
<script src="../../game/lib/back_button.js"></script>
|
<script src="../../game/lib/back_button.js"></script>
|
||||||
<script src="../../game/lib/fullscreen_button.js"></script>
|
<script src="../../game/lib/fullscreen_button.js"></script>
|
||||||
|
<script src="../../game/lib/db_connect_manager.js"></script>
|
||||||
<script src="../../game/lib/screen_bottom.js"></script>
|
<script src="../../game/lib/screen_bottom.js"></script>
|
||||||
<script src="../../game/lib/game_over_text.js"></script>
|
<script src="../../game/lib/game_over_text.js"></script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user