Fix: restructing session manager, ES6 -> ES5
This commit is contained in:
+51
-57
@@ -1,62 +1,56 @@
|
||||
/////////////////////////////
|
||||
// Chart
|
||||
|
||||
class Chart {
|
||||
|
||||
constructor() {
|
||||
this.chartGraphics = game.add.graphics(0, 0);
|
||||
}
|
||||
|
||||
printChartBaseLine() {
|
||||
this.chartGraphics.lineStyle(3, 0xffd900, 1);
|
||||
this.chartGraphics.moveTo(100, Chart.CHART_LINE_Y);
|
||||
this.chartGraphics.lineTo(game.world.width - 100, Chart.CHART_LINE_Y);
|
||||
}
|
||||
|
||||
drawRecordGraph(index, date, bestRecord, min, max) {
|
||||
let reverseIndex = (Chart.CHART_COUNT - 1) - index;
|
||||
let posX = Chart.CHART_LINE_START_X + Chart.CHART_GRAPH_OFFSET_X + reverseIndex * Chart.CHART_GAP_PX;
|
||||
let 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),
|
||||
);
|
||||
|
||||
// chart
|
||||
this.chartGraphics.lineStyle(50, 0xdddddd, 1);
|
||||
this.chartGraphics.moveTo(posX, posY);
|
||||
this.chartGraphics.lineTo(posX, posY - Chart.CHART_HEIGHT * ( (bestRecord - min) / (max - min) ));
|
||||
}
|
||||
|
||||
drawText(posX, posY, text) {
|
||||
const style = { font: "24px Arial", fill: "#fff", align: "left", boundsAlignH: "center", boundsAlignV: "middle" };
|
||||
|
||||
let textObject = game.add.text(
|
||||
posX, posY,
|
||||
text, style
|
||||
);
|
||||
textObject.anchor.set(0.5);
|
||||
textObject.stroke = "#333";
|
||||
textObject.strokeThickness = 3;
|
||||
|
||||
return textObject;
|
||||
}
|
||||
|
||||
getFontStyle() {
|
||||
return { font: "32px Arial", fill: "#fff" };
|
||||
}
|
||||
|
||||
function Chart() {
|
||||
this.chartGraphics = game.add.graphics(0, 0);
|
||||
}
|
||||
|
||||
Chart.prototype.printChartBaseLine = function() {
|
||||
this.chartGraphics.lineStyle(3, 0xffd900, 1);
|
||||
this.chartGraphics.moveTo(100, Chart.CHART_LINE_Y);
|
||||
this.chartGraphics.lineTo(game.world.width - 100, Chart.CHART_LINE_Y);
|
||||
}
|
||||
|
||||
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),
|
||||
);
|
||||
|
||||
// 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.prototype.drawText = function(posX, posY, text) {
|
||||
const style = { font: "24px Arial", fill: "#fff", align: "left", boundsAlignH: "center", boundsAlignV: "middle" };
|
||||
|
||||
var textObject = game.add.text(
|
||||
posX, posY,
|
||||
text, style
|
||||
);
|
||||
textObject.anchor.set(0.5);
|
||||
textObject.stroke = "#333";
|
||||
textObject.strokeThickness = 3;
|
||||
|
||||
return textObject;
|
||||
}
|
||||
|
||||
Chart.prototype.getFontStyle = function() {
|
||||
return { font: "32px Arial", fill: "#fff" };
|
||||
}
|
||||
|
||||
|
||||
Chart.CHART_COUNT = 7;
|
||||
|
||||
Chart.CHART_LINE_START_X = 100;
|
||||
|
||||
Reference in New Issue
Block a user