Commit 7076bf96 authored by yu's avatar yu

分数调整

parent f5a3c159
...@@ -72,7 +72,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -72,7 +72,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this.logs = []; this.logs = [];
this._cantouch = true; this._cantouch = true;
Game.getIns().init(this.data); Game.getIns().init(this.data);
this._colors = ["#f87b8e", "#fdb652", "#4acfe0", "#30ff6d", "#848cff"]; // this._colors = ["#f87b8e", "#fdb652", "#4acfe0", "#30ff6d", "#848cff"];
} }
...@@ -176,7 +176,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -176,7 +176,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
do { do {
this.downArr.sort(() => Math.random() - 0.5); this.downArr.sort(() => Math.random() - 0.5);
} while (this.downArr[0].id == this.upArr[0].id); } while (this.downArr[0].id == this.upArr[0].id);
this._colors = [].concat(["#f87b8e", "#fdb652", "#4acfe0", "#30ff6d", "#848cff"]);
this._colors.sort(() => Math.random() - 0.5); this._colors.sort(() => Math.random() - 0.5);
} }
...@@ -372,24 +372,6 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -372,24 +372,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
right.getComponent(cc.Button).interactable = false; right.getComponent(cc.Button).interactable = false;
this.drawLine(lift, right); this.drawLine(lift, right);
let page = Game.getIns().getDataByPage(this.roundIdx).page;
let log = this.logs.find(rli =>
rli.option.page == page
);
console.log("pag:" + Game.getIns().getDataByPage(this.roundIdx).page)
if (log) {
log.option = Game.getIns().getDataByPage(this.roundIdx);
// log.submit = datas;
log.isRight = true;
log.score = isRight ? log.score += Game.getIns().score : log.score += 0;
} else {
this.logs.push({
option: Game.getIns().getDataByPage(this.roundIdx),
// submit: datas,
isRight: true,
score: isRight ? Game.getIns().score : 0
})
}
// } else { // } else {
// // pg.audio.playAudio(this.wrongClip, () => { // // pg.audio.playAudio(this.wrongClip, () => {
...@@ -480,6 +462,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -480,6 +462,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
gs.destroy(); gs.destroy();
this.resetLeftCardStateById(gs.data.left); this.resetLeftCardStateById(gs.data.left);
this.resetRightCardStateById(gs.data.right); this.resetRightCardStateById(gs.data.right);
this._colors.push(gs.data.color);
} }
if (type == 0 && gs.data.right == id) { if (type == 0 && gs.data.right == id) {
gs.getComponent(cc.Graphics).clear(); gs.getComponent(cc.Graphics).clear();
...@@ -488,6 +471,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -488,6 +471,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
gs.destroy(); gs.destroy();
this.resetRightCardStateById(gs.data.right); this.resetRightCardStateById(gs.data.right);
this.resetLeftCardStateById(gs.data.left); this.resetLeftCardStateById(gs.data.left);
this._colors.push(gs.data.color);
} }
}) })
} }
...@@ -510,10 +494,11 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -510,10 +494,11 @@ export default class SceneComponent extends MyCocosSceneComponent {
right.touch = touchState.FINISH; right.touch = touchState.FINISH;
let graphicsNode = cc.instantiate(cc.find("graphics", this.node)); let graphicsNode = cc.instantiate(cc.find("graphics", this.node));
let graphics = graphicsNode.getComponent(cc.Graphics); let graphics = graphicsNode.getComponent(cc.Graphics);
graphicsNode.data = { left: lift.data.id, right: right.data.id }; let color = this._colors.splice(0, 1)[0];
let color = this._colors[this.graphicsArr.length];
graphics.strokeColor = new cc.Color().fromHEX(color); graphics.strokeColor = new cc.Color().fromHEX(color);
graphicsNode.data = { left: lift.data.id, right: right.data.id, color: color };
// let line = [point1, point2, color]; // let line = [point1, point2, color];
// this.lined.push(line); // this.lined.push(line);
this.graphicsArr.push(graphicsNode); this.graphicsArr.push(graphicsNode);
...@@ -547,6 +532,7 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -547,6 +532,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this._drawIndex++; this._drawIndex++;
if (this.graphicsArr.length >= this.data.questions[this.roundIdx].options.length) { if (this.graphicsArr.length >= this.data.questions[this.roundIdx].options.length) {
this.scheduleOnce(() => { this.scheduleOnce(() => {
this.addSendData();
this._drawIndex = 0; this._drawIndex = 0;
this.roundIdx++; this.roundIdx++;
if (this.roundIdx < this.data.questions.length) { if (this.roundIdx < this.data.questions.length) {
...@@ -564,7 +550,18 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -564,7 +550,18 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
} }
private addSendData() {
let score = 0;
this.graphicsArr.forEach((item) => {
if (item.data.right == item.data.left) score += Game.getIns().score;
})
this.logs.push({
option: Game.getIns().getDataByPage(this.roundIdx),
// submit: datas,
isRight: true,
score: score
})
}
......
...@@ -20,7 +20,7 @@ export default class Game { ...@@ -20,7 +20,7 @@ export default class Game {
} }
private data: any; private data: any;
private lists: Array<any> private lists: Array<any>
public score: Number; public score: number;
constructor() { constructor() {
// //
this.start = false; this.start = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment