Commit ed99c6cc authored by unknown's avatar unknown

算式接龙好了

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