function Chart() { this.dbConnectManager = new DBConnectManager(); this.chartGraphics = game.add.graphics(0, 0); this.printChartTitle(); this.printChartBaseLine(); this.records = []; for(var i = 0; i < 7; i++) this.records.push(new ChartRecord(i)); } Chart.prototype.printChartTitle = function() { var offsetY = -25; var fontStyle = { font: "30px Arial", fill: "#fff", align: "center" }; Chart.drawText(Chart.DATE_POS_X, Chart.CHART_LINE_Y + offsetY, "날짜", fontStyle); Chart.drawText(Chart.SCORE_POS_X, Chart.CHART_LINE_Y + offsetY, "점수", fontStyle); Chart.drawText(Chart.GRADE_POS_X, Chart.CHART_LINE_Y + offsetY, "등급", fontStyle); Chart.drawText(Chart.SUBJECT_POS_X, Chart.CHART_LINE_Y + offsetY, "과목", fontStyle); } Chart.prototype.printChartBaseLine = function() { this.chartGraphics.lineStyle(3, 0xffd900, 1); this.chartGraphics.moveTo(Chart.CHART_LINE_START_X, Chart.CHART_LINE_Y); this.chartGraphics.lineTo(game.world.width - Chart.CHART_LINE_START_X, Chart.CHART_LINE_Y); /* for(var i = 0; i < 6; i++) { this.chartGraphics.lineStyle(1, 0x888888, 1); this.chartGraphics.moveTo( Chart.CHART_LINE_START_X, ChartRecord.getPosY(i) + ChartRecord.RECORD_HEIGHT ); this.chartGraphics.lineTo( game.world.width - Chart.CHART_LINE_START_X, ChartRecord.getPosY(i) + ChartRecord.RECORD_HEIGHT ); } */ } /* Chart.prototype.drawRecordGraph = function(index, date, bestRecord, min, max) { var reverseIndex = (Chart.CHART_COUNT - 1) - index; var posX = Chart.CHART_LINE_START_X + Chart.CHART_GRAPH_OFFSET_X + reverseIndex * Chart.CHART_GAP_PX; var posY = Chart.CHART_LINE_Y; this.drawText( posX, posY + Chart.CHART_DATE_OFFSET_Y, date === "-" ? "-" : StringUtil.printMonthDay(date) ); if(bestRecord === "") return; this.drawText( posX, posY - Chart.CHART_HEIGHT - Chart.CHART_RECORD_OFFSET_Y, // StringUtil.getRecordTextWithoutUnit(bestRecord) + StringUtil.getScoreUnit(sessionStorageManager.playingAppID) RecordUtil.getRecordValueWithUnit(bestRecord, sessionStorageManager.getPlayingAppID()) ); // chart this.chartGraphics.lineStyle(50, 0xdddddd, 1); this.chartGraphics.moveTo(posX, posY); this.chartGraphics.lineTo(posX, posY - Chart.CHART_HEIGHT * ( (bestRecord - min) / (max - min) )); } */ Chart.drawText = function(posX, posY, text, fontStyle) { var textObject = game.add.text( posX, posY, text, fontStyle ); textObject.anchor.set(0.5); textObject.stroke = "#333"; textObject.strokeThickness = 3; return textObject; } Chart.prototype.printContents = function() { if(isDebugMode()) { for(var i = 0; i < this.records.length; i++) { this.records[i].printDate("12월 10일"); this.records[i].printScore(360); this.records[i].printGrade("B"); this.records[i].printSubject("ITQ 파워포인트"); } } } Chart.CHART_COUNT = 7; Chart.CHART_LINE_START_X = 230; Chart.CHART_LINE_Y = 370; Chart.CHART_GAP_PX = 120; Chart.CHART_HEIGHT = 120; Chart.CHART_GRAPH_OFFSET_X = 50; Chart.CHART_DATE_OFFSET_Y = 20; Chart.CHART_SCORE_OFFSET_Y = 30; Chart.DATE_POS_X = Chart.CHART_LINE_START_X + 70; Chart.SCORE_POS_X = Chart.DATE_POS_X + 120; Chart.GRADE_POS_X = Chart.DATE_POS_X + 200; Chart.SUBJECT_POS_X = Chart.DATE_POS_X + 360; function ChartRecord(indexRow) { this.date = new DateData(indexRow); this.score = new ScoreData(indexRow); this.grade = new GradeData(indexRow); this.subject = new SubjectData(indexRow); return this; } ChartRecord.prototype.printDate = function(date) { this.date.text = date; } ChartRecord.prototype.printScore = function(score) { this.score.text = RecordUtil.getRecordValueWithUnit(score, 101); //sessionStorageManager.getPlayingAppID()); } ChartRecord.prototype.printGrade = function(grade) { this.grade.text = grade; } ChartRecord.prototype.printSubject = function(subject) { this.subject.text = subject; } ChartRecord.getPosX = function(columnName) { var posX = Chart.CHART_LINE_START_X; switch(columnName) { case "date": posX = Chart.DATE_POS_X; break; case "score": posX = Chart.SCORE_POS_X; break; case "grade": posX = Chart.GRADE_POS_X; break; case "subject": posX = Chart.SUBJECT_POS_X; break; } return posX; } ChartRecord.getPosY = function(rowIndex) { var offsetY = 30; return Chart.CHART_LINE_Y + offsetY + ChartRecord.GAP_RECORD_Y * rowIndex; } ChartRecord.getDefaultFontStyle = function() { return { font: "26px Arial", fill: "#ffc", align: "center" }; } ChartRecord.GAP_RECORD_Y = 40; ChartRecord.RECORD_HEIGHT = 16; function DateData(index) { this.dateText = Chart.drawText( ChartRecord.getPosX("date"), ChartRecord.getPosY(index), "-", ChartRecord.getDefaultFontStyle() ); return this.dateText; } function ScoreData(index) { this.scoreText = Chart.drawText( ChartRecord.getPosX("score"), ChartRecord.getPosY(index), "-", ChartRecord.getDefaultFontStyle() ); return this.scoreText; } function GradeData(index) { this.gradeText = Chart.drawText( ChartRecord.getPosX("grade"), ChartRecord.getPosY(index), "-", ChartRecord.getDefaultFontStyle() ); return this.gradeText; } function SubjectData(index) { this.subjectText = Chart.drawText( ChartRecord.getPosX("subject"), ChartRecord.getPosY(index), "-", ChartRecord.getDefaultFontStyle() ); return this.subjectText; }