///////////////////////////// // Start class Start { preload() { game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png'); } create() { this.dbConnectManager = new DBConnectManager(); this.game.stage.backgroundColor = '#4d4d4d'; this.chartGraphics = game.add.graphics(100, game.world.height - 120); // top let backButton = new BackButton( () => { location.href = '../../web/client/menu_app.html'; }); let fullscreenButton = new FullscreenButton(this.game); // contents this.printHowToPlay(appInfoManager.getHowToPlayText(sessionStorageManager.playingAppName)); this.makeStartButton(); let today = new Date(); let date = DateUtil.getYYYYMMDD(today); this.dbConnectManager.requestPlayerHistory( date, historyRecordManager => { this.printChartBaseLine(); if(historyRecordManager.count == 0) { console.log("start - history record : no data"); return; } let underValue = historyRecordManager.underValueForGraph(); let upperValue = historyRecordManager.upperValueForGraph(); let minValue = underValue - (upperValue - underValue) / 10; let maxValue = upperValue;// + (upperValue - underValue) / 10; for(let i = 0; i < historyRecordManager.count; i++) { if(i > 6) break; let data = historyRecordManager.getAt(i); this.drawRecordGraph(i, data.date, data.score, minValue, maxValue); } } ); // bottom let screenBottom = new ScreenBottom(); screenBottom.makeBottomLine(); screenBottom.printBottomLeftText("게임 진행 정보"); let playingAppName = appInfoManager.getAppNameKorean(sessionStorageManager.playingAppName); screenBottom.printBottomCenterText(playingAppName); screenBottom.printBottomRightText(sessionStorageManager.playerName); } printHowToPlay(text) { const style = { font: "32px Arial", fill: "#fff", align: "left", boundsAlignH: "center", boundsAlignV: "middle" }; let howToPlayText = game.add.text(0, 0, appInfoManager.getHowToPlayText(sessionStorageManager.playingAppName), style); howToPlayText.setTextBounds(100, 100, game.world.width - 100, 200); howToPlayText.stroke = "#333"; howToPlayText.strokeThickness = 5; } makeStartButton() { let setting = new RoundRectButtonSetting(200, 100); setting.fontStyle.fontWeight = "bold"; let startButton = new RoundRectButton(setting, "시작", this.startStage); startButton.move(game.world.centerX, game.world.centerY); } printChartBaseLine() { this.chartGraphics.lineStyle(3, 0xffd900, 1); this.chartGraphics.moveTo(0, 0); this.chartGraphics.lineTo(game.world.width - 200, 0); } drawRecordGraph(index, date, score, min, max) { const CHART_GAP_PX = 120; const CHART_HEIGHT = 120; const style = { font: "24px Arial", fill: "#fff", align: "left", boundsAlignH: "center", boundsAlignV: "middle" }; let dateText = game.add.text( 100 + index * CHART_GAP_PX, game.world.height - 140, StringUtil.printMonthDay(date), style ); dateText.setTextBounds(0, 0, 100, 100); dateText.stroke = "#333"; dateText.strokeThickness = 1; let scoreText = game.add.text( 100 + index * CHART_GAP_PX, game.world.height - 300, StringUtil.getScoreTextWithUnit(score), style ); scoreText.setTextBounds(0, 0, 100, 100); scoreText.stroke = "#333"; scoreText.strokeThickness = 1; this.chartGraphics.lineStyle(50, 0xdddddd, 1); this.chartGraphics.moveTo(50 + index * CHART_GAP_PX, 0); this.chartGraphics.lineTo(50 + index * CHART_GAP_PX, -1 * CHART_HEIGHT * ( (score - min) / (max - min) )); } startStage() { location.href = "../../web/client/" + sessionStorageManager.playingAppName + ".html"; } }