计算积分
This commit is contained in:
@@ -21,7 +21,6 @@ export class Block extends Laya.Script {
|
||||
private tips_labels: Array<Laya.Label> = new Array();
|
||||
|
||||
private selected: boolean = false
|
||||
private newSelect: boolean = false
|
||||
|
||||
private data: DOBlock
|
||||
|
||||
@@ -56,8 +55,6 @@ export class Block extends Laya.Script {
|
||||
|
||||
public setSelected(selected: boolean): void {
|
||||
this.selected = selected
|
||||
if (selected)
|
||||
this.newSelect = true
|
||||
this.updateBlock()
|
||||
}
|
||||
|
||||
@@ -118,15 +115,16 @@ export class Block extends Laya.Script {
|
||||
return this.data
|
||||
}
|
||||
|
||||
public setShowNumber(showNumber: number): boolean {
|
||||
public setShowNumber(showNumber: number, score: number): boolean {
|
||||
this.data.set_show(showNumber)
|
||||
if (this.newSelect) {
|
||||
this.newSelect = false
|
||||
if (this.data.get_checked() && this.data.get_score() <= 0) {
|
||||
var score = 150
|
||||
this.data.set_score(score)
|
||||
if (this.data.get_checked()) {
|
||||
this.data.set_score(score)
|
||||
if (score > 0)
|
||||
G_ShowScoreTips(score.toString(), this.label_show)
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (this.data.get_score() != 0)
|
||||
this.data.set_score(0)
|
||||
}
|
||||
this.data.clean_notes()
|
||||
this.updateBlock()
|
||||
|
||||
@@ -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