计算积分
This commit is contained in:
@@ -5,7 +5,7 @@ import { Candy } from "./Candy";
|
||||
import { DOStage } from "../models/DOStage";
|
||||
import { config } from "../constants/config";
|
||||
import { StorageManager } from "../models/StorageManager";
|
||||
import { Utility_ConvertSecondToString } from "../utils/utility";
|
||||
import { Utility_CalculateScore, Utility_ConvertSecondToString } from "../utils/utility";
|
||||
import { EVENT_TYPES, EventManager } from "../models/EventManager";
|
||||
import { G_getMonthInfo } from "../models/DCManager";
|
||||
|
||||
@@ -246,7 +246,7 @@ export class Stage extends Laya.Script {
|
||||
this.selectedBlock.setNotes(undo.notes)
|
||||
}
|
||||
else {
|
||||
this.selectedBlock.setShowNumber(undo.show)
|
||||
this.selectedBlock.setShowNumber(undo.show, 0)
|
||||
}
|
||||
// this.onSetBlock(this.selectedBlock)
|
||||
this.onUpdateScore()
|
||||
@@ -265,7 +265,7 @@ export class Stage extends Laya.Script {
|
||||
var notes = this.selectedBlock.getData().get_notes()
|
||||
if (show > 0 || notes.length > 0) {
|
||||
this.data.add_undo(this.selectedBlock.getData().get_index(), show, notes)
|
||||
this.selectedBlock.setShowNumber(0)
|
||||
this.selectedBlock.setShowNumber(0, 0)
|
||||
this.onUpdateScore()
|
||||
this.onSetBlock(this.selectedBlock)
|
||||
}
|
||||
@@ -289,7 +289,7 @@ export class Stage extends Laya.Script {
|
||||
if (hint > 0) {
|
||||
if (this.selectedBlock.getData().get_checked() == false) {//当前选中的格子没有完成
|
||||
var correct = this.selectedBlock.getData().get_correct()
|
||||
this.onApplyCandy(correct)
|
||||
this.onApplyCandy(correct, true)
|
||||
this.data.set_hint(hint-1)
|
||||
this.onUpdateHintStatus()
|
||||
}
|
||||
@@ -308,7 +308,7 @@ export class Stage extends Laya.Script {
|
||||
var block = list[index]
|
||||
this.onApplyBlock(block)
|
||||
var correct = block.getData().get_correct()
|
||||
this.onApplyCandy(correct)
|
||||
this.onApplyCandy(correct, true)
|
||||
this.data.set_hint(hint-1)
|
||||
this.onUpdateHintStatus()
|
||||
}
|
||||
@@ -328,7 +328,7 @@ export class Stage extends Laya.Script {
|
||||
this.btn_hint_label.text = hint.toString()
|
||||
}
|
||||
|
||||
public onApplyCandy(showNumber: number): void {
|
||||
public onApplyCandy(showNumber: number, hint: boolean): void {
|
||||
var show = this.selectedBlock.getData().get_show()
|
||||
var notes = this.selectedBlock.getData().get_notes()
|
||||
if (this.selectedBlock.getData().get_checked() == false) {
|
||||
@@ -358,14 +358,20 @@ export class Stage extends Laya.Script {
|
||||
else {
|
||||
this.data.add_undo(this.selectedBlock.getData().get_index(), show, notes)
|
||||
if (this.selectedBlock.getData().get_show() == showNumber) {
|
||||
this.selectedBlock.setShowNumber(0);
|
||||
this.selectedBlock.setShowNumber(0, 0);
|
||||
this.onSetBlock(this.selectedBlock)
|
||||
}
|
||||
else {
|
||||
var b = this.selectedBlock.setShowNumber(showNumber)
|
||||
var blockScore = 0
|
||||
if (hint == false) {
|
||||
var duration = this.data.get_duration() - this.data.get_last_hit_time()
|
||||
blockScore = Utility_CalculateScore(this.data.get_difficulty(), duration)
|
||||
}
|
||||
var b = this.selectedBlock.setShowNumber(showNumber, blockScore)
|
||||
var score = this.onUpdateScore()
|
||||
this.onSetBlock(this.selectedBlock, true)
|
||||
if (b) {
|
||||
this.data.set_last_hit_time(this.data.get_duration())
|
||||
var user = StorageManager.getInstance().getUser()
|
||||
var all = 0
|
||||
var finished = 0
|
||||
@@ -423,13 +429,13 @@ export class Stage extends Laya.Script {
|
||||
|
||||
public onClickCandy(evt: Laya.Event): void {
|
||||
var candy = evt.target.getComponent(Candy);
|
||||
this.onApplyCandy(candy.get_show())
|
||||
this.onApplyCandy(candy.get_show(), false)
|
||||
}
|
||||
|
||||
onKeyUp(evt: Laya.Event): void {
|
||||
var n = Number(evt.key)
|
||||
if (n && n > 0) {
|
||||
this.onApplyCandy(n)
|
||||
this.onApplyCandy(n, false)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user