Commit ed99c6cc authored by unknown's avatar unknown

算式接龙好了

parent 85a40717
......@@ -9,6 +9,7 @@ import { viewMgr, VIEW_INDEX } from '../../../../startFolder/script/common/ViewM
import { BeginCountdownView } from '../../commonView/script/BeginCountdownView';
import { ChallengeSuccView } from '../../commonView/script/ChallengeSuccView';
import { GameDescView } from '../../commonView/script/GameDescView';
import { SwitchOkView } from '../../commonView/script/SwitchOkView';
import { FormulaSolitaireCfg, FS_LV_1, FS_LV_2 } from './FormulaSolitaireCfg';
import { FormulaSolitaireItem, FS_ITEM_STATE } from './FormulaSolitaireItem';
const { ccclass, property } = _decorator;
......@@ -259,10 +260,15 @@ export class FormulaSolitaireCtr extends Component {
gameEnd(isWin: boolean) {
this.gameState = GAME_STATE.END;
if (isWin) {
viewMgr.openView(VIEW_DEF.ChallengeSuccView, (node) => {
AudioMgr.playEffect(succMus);
node?.getComponent(ChallengeSuccView)?.init();
}, VIEW_INDEX.TOP);
AudioMgr.playEffect(succMus);
viewMgr.openView(VIEW_DEF.SwitchOkView, (node) => {
node.getComponent(SwitchOkView)!.endCb = () => {
viewMgr.openView(VIEW_DEF.ChallengeSuccView, (node) => {
node?.getComponent(ChallengeSuccView)?.init();
}, VIEW_INDEX.TOP);
};
node.getComponent(SwitchOkView)?.init(1.5);
});
}
else {
viewMgr.openView(VIEW_DEF.ChallengeFailView, (node) => {
......@@ -272,7 +278,7 @@ export class FormulaSolitaireCtr extends Component {
}
checkWin() {
if (this.allLinePointArr.length < this.levelData.resultCount) return false;
// if (this.allLinePointArr.length < this.levelData.resultCount) return false;
let retArr: number[][] = [];
for (let i = 0; i < this.allLinePointArr.length; ++i) {
let numAtrArr: string[] = [];
......@@ -289,6 +295,7 @@ export class FormulaSolitaireCtr extends Component {
}
console.log(`所有结果`);
console.log(retArr);
this.resultLab.string = `算式结果:` + this.levelData.result + "\n" + `剩余算式:` + (this.levelData.resultCount - count);
if (count >= this.levelData.resultCount) return true;
return false;
}
......@@ -329,6 +336,17 @@ export class FormulaSolitaireCtr extends Component {
return null;
}
onResetBtnClick(){
for (let i = 0; i < this.allLinePointArr.length; ++i) {
let line = this.allLinePointArr[i];
for (let j = 0; j < line.length; ++j) {
line[j].target.getComponent(FormulaSolitaireItem)?.setItemState(FS_ITEM_STATE.CENTER);
line[j].target.getComponent(FormulaSolitaireItem)?.setColor(Color.fromHEX(new Color(), this.orgColor));
}
}
this.allLinePointArr = [];
}
gameStart() {
this.gameState = GAME_STATE.READY;
this.countdownLab.string = Utils.formatTime(Math.floor(this.totalTime * 1000));
......@@ -336,7 +354,7 @@ export class FormulaSolitaireCtr extends Component {
this.curLinePointArr = [];
this.allLinePointArr = [];
this.loadLevelData();
this.resultLab.string = `正确答案:` + this.levelData.result;
this.resultLab.string = `算式结果:` + this.levelData.result + "\n" + `剩余算式:` + this.levelData.resultCount;
this.creAllItem();
this.setBgSprSize();
viewMgr.openView(VIEW_DEF.BeginCountdownView, (node) => {
......
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