Commit 400e77fe authored by unknown's avatar unknown

纵横填数完全好了

parent 086d8625
{
"ver": "1.0.21",
"importer": "image",
"imported": true,
"uuid": "f808b95f-27d0-4292-b534-72a0b37d6584",
"files": [
".png",
".json"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "f808b95f-27d0-4292-b534-72a0b37d6584@6c48a",
"displayName": "时间框",
"id": "6c48a",
"name": "texture",
"userData": {
"wrapModeS": "clamp-to-edge",
"wrapModeT": "clamp-to-edge",
"minfilter": "linear",
"magfilter": "linear",
"mipfilter": "none",
"anisotropy": 0,
"isUuid": true,
"imageUuidOrDatabaseUri": "f808b95f-27d0-4292-b534-72a0b37d6584"
},
"ver": "1.0.21",
"imported": true,
"files": [
".json"
],
"subMetas": {}
},
"f9941": {
"importer": "sprite-frame",
"uuid": "f808b95f-27d0-4292-b534-72a0b37d6584@f9941",
"displayName": "时间框",
"id": "f9941",
"name": "spriteFrame",
"userData": {
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
"offsetX": 0,
"offsetY": 0,
"trimX": 0,
"trimY": 0,
"width": 376,
"height": 69,
"rawWidth": 376,
"rawHeight": 69,
"borderTop": 0,
"borderBottom": 0,
"borderLeft": 0,
"borderRight": 0,
"packable": true,
"isUuid": true,
"imageUuidOrDatabaseUri": "f808b95f-27d0-4292-b534-72a0b37d6584@6c48a",
"atlasUuid": ""
},
"ver": "1.0.9",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"hasAlpha": true,
"type": "sprite-frame",
"redirect": "f808b95f-27d0-4292-b534-72a0b37d6584@f9941"
}
}
...@@ -39,3 +39,31 @@ export const vhfn_lv_1: VHFillNumCfg = { ...@@ -39,3 +39,31 @@ export const vhfn_lv_1: VHFillNumCfg = {
], ],
options: [5, 2, 8] options: [5, 2, 8]
} }
export const vhfn_lv_2: VHFillNumCfg = {
row: 4,
column: 4,
numArr: [
[2, 4, 2, 10],
[6, 5, 2, 60],
[3, 3, 3, 9],
[4, 60, 7, -1]
],
emptyCtrArr: [
[1, 0, 1, 1],
[0, 0, 1, 1],
[1, 1, 0, 1],
[1, 1, 1, 1]
],
rowSymb: [
["+", "×", "="],
["×", "×", "="],
["+", "+", "="]
],
columnSymb: [
["×", "×", "×"],
["÷", "×", "+"],
["=", "=", "="],
],
options: [5, 6, 4, 3]
}
import { _decorator, Component, Node, Prefab, Label, CCFloat, Vec3, UITransform, instantiate, v3, Color, Toggle, director } from 'cc'; import { _decorator, Component, Node, Prefab, Label, CCFloat, Vec3, UITransform, instantiate, v3, Color, Toggle, director } from 'cc';
import { failMus, succMus } from '../../../../startFolder/script/common/AudioDef'; import { countdownMus, failMus, succMus } from '../../../../startFolder/script/common/AudioDef';
import { AudioMgr } from '../../../../startFolder/script/common/AudioMgr'; import { AudioMgr } from '../../../../startFolder/script/common/AudioMgr';
import { Utils } from '../../../../startFolder/script/common/Utils';
import { VIEW_DEF } from '../../../../startFolder/script/common/ViewDef'; import { VIEW_DEF } from '../../../../startFolder/script/common/ViewDef';
import { viewMgr, VIEW_INDEX } from '../../../../startFolder/script/common/ViewMgr'; import { viewMgr, VIEW_INDEX } from '../../../../startFolder/script/common/ViewMgr';
import { BeginCountdownView } from '../../commonView/script/BeginCountdownView';
import { ChallengeSuccView } from '../../commonView/script/ChallengeSuccView'; import { ChallengeSuccView } from '../../commonView/script/ChallengeSuccView';
import { VHFillNumCfg, vhfn_lv_1 } from './VHFillNumCfg'; import { GameDescView } from '../../commonView/script/GameDescView';
import { VHFillNumCfg, vhfn_lv_1, vhfn_lv_2 } from './VHFillNumCfg';
import { VHFillNumItem, VHFN_ITEM_TYPE } from './VHFillNumItem'; import { VHFillNumItem, VHFN_ITEM_TYPE } from './VHFillNumItem';
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
...@@ -51,16 +54,64 @@ export class VHFillNumCtr extends Component { ...@@ -51,16 +54,64 @@ export class VHFillNumCtr extends Component {
private itemPosIfoArr: ItemPosIfo[] = []; private itemPosIfoArr: ItemPosIfo[] = [];
private row = 4; private row = 4;
private column = 4; private column = 4;
private level = 1; private level = 2;
private levelData: VHFillNumCfg = null!; private levelData: VHFillNumCfg = null!;
private selNum = 0; private selNum = 0;
private gameState = GAME_STATE.READY; private gameState = GAME_STATE.READY;
private costTime = 0;
private isPlayCountdownMus = false;
private isShowGameDescViewOnce = false;
showGameDescView() {
this.isShowGameDescViewOnce = true;
viewMgr.openView(VIEW_DEF.GameDescView, (node) => {
node.getComponent(GameDescView)?.setDesc("选择数字填入空格使横着的和竖着的算式都要成立。\n注意:不论从左到右还是从上到下都要符合四则运算优先级。");
});
}
onCloseGameDescView() {
this.gameState = GAME_STATE.RUN;
}
setGameData(resData: object) {
//@ts-ignore
if (resData.totalTime) {
//@ts-ignore
this.totalTime = resData.totalTime;
}
//@ts-ignore
if (resData.level) {
//@ts-ignore
this.level = resData.level;
}
//@ts-ignore
if (resData.isShowGuide) {
//@ts-ignore
this.isShowGameDescViewOnce = false;
}
else {
this.isShowGameDescViewOnce = true;
}
}
start() { start() {
// [3] // [3]
director.on("VHFM_click", this.onItemClick, this); director.on("VHFM_click", this.onItemClick, this);
director.on("begin_countdown_end", () => {
//引导
if (!this.isShowGameDescViewOnce) {
this.gameState = GAME_STATE.PAUSE;
this.showGameDescView();
}
else {
this.gameState = GAME_STATE.RUN;
}
}, this);
director.on("game_desc_close", this.onCloseGameDescView, this);
this.gameStart(); this.gameStart();
} }
...@@ -68,25 +119,42 @@ export class VHFillNumCtr extends Component { ...@@ -68,25 +119,42 @@ export class VHFillNumCtr extends Component {
director.off("VHFM_click", this.onItemClick, this); director.off("VHFM_click", this.onItemClick, this);
} }
//倒计时
countdownTime(dt: number) {
if (this.gameState == GAME_STATE.READY || this.gameState == GAME_STATE.END || this.gameState == GAME_STATE.PAUSE) {
return;
}
this.costTime += dt;
if (!this.isPlayCountdownMus && this.totalTime - this.costTime < 3.5) {
this.isPlayCountdownMus = true;
AudioMgr.playOneShot(countdownMus);
}
if (this.totalTime - this.costTime <= 0) {
console.log(`游戏时间到`);
this.gameEnd(false);
return;
}
this.countdownLab.string = Utils.formatTime(Math.floor((this.totalTime - this.costTime) * 1000));
}
gameStart() { gameStart() {
this.countdownLab.string = Utils.formatTime(Math.floor(this.totalTime * 1000));
this.gameState = GAME_STATE.READY; this.gameState = GAME_STATE.READY;
this.loadLevelData(); this.loadLevelData();
this.creAllItem(); this.creAllItem();
this.creOptions(); this.creOptions();
this.setBgSprSize(); this.setBgSprSize();
this.checkWin(); this.checkWin();
this.gameState = GAME_STATE.RUN; viewMgr.openView(VIEW_DEF.BeginCountdownView, (node) => {
node.getComponent(BeginCountdownView)?.init();
}, VIEW_INDEX.UPPER);
} }
onItemClick(item: VHFillNumItem) { onItemClick(item: VHFillNumItem) {
console.log(`一个item被点击2`);
if (item.itemType == VHFN_ITEM_TYPE.RESULT || item.itemType == VHFN_ITEM_TYPE.FIX_ELE) return; if (item.itemType == VHFN_ITEM_TYPE.RESULT || item.itemType == VHFN_ITEM_TYPE.FIX_ELE) return;
item.showNum = this.selNum; item.showNum = this.selNum;
if (this.checkWin()) { if (this.checkWin()) {
console.log(`游戏成功`); this.gameEnd(true);
}
else {
console.log(`游戏还没成功`);
} }
} }
...@@ -102,14 +170,14 @@ export class VHFillNumCtr extends Component { ...@@ -102,14 +170,14 @@ export class VHFillNumCtr extends Component {
let optArr: string[] = []; let optArr: string[] = [];
for (let i = 0; i < optArr_1.length; ++i) { for (let i = 0; i < optArr_1.length; ++i) {
optArr.push(optArr_1[i]); optArr.push(optArr_1[i]);
if(optArr_2[i]) optArr.push(optArr_2[i]); if (optArr_2[i]) optArr.push(optArr_2[i]);
} }
// console.log(`传入的算式行: ${r}`); // console.log(`传入的算式行: ${r}`);
// console.log(optArr); // console.log(optArr);
if(this.calculator(optArr) == itemPosIfoArr[itemPosIfoArr.length - 1].target.getComponent(VHFillNumItem)!.showNum){ if (this.calculator(optArr) == itemPosIfoArr[itemPosIfoArr.length - 1].target.getComponent(VHFillNumItem)!.showNum) {
itemPosIfoArr[itemPosIfoArr.length - 1].target.getComponent(VHFillNumItem)!.bgSpr.node.active = true; itemPosIfoArr[itemPosIfoArr.length - 1].target.getComponent(VHFillNumItem)!.bgSpr.node.active = true;
} }
else{ else {
isWin = false; isWin = false;
itemPosIfoArr[itemPosIfoArr.length - 1].target.getComponent(VHFillNumItem)!.bgSpr.node.active = false; itemPosIfoArr[itemPosIfoArr.length - 1].target.getComponent(VHFillNumItem)!.bgSpr.node.active = false;
} }
...@@ -125,14 +193,14 @@ export class VHFillNumCtr extends Component { ...@@ -125,14 +193,14 @@ export class VHFillNumCtr extends Component {
let optArr: string[] = []; let optArr: string[] = [];
for (let i = 0; i < optArr_1.length; ++i) { for (let i = 0; i < optArr_1.length; ++i) {
optArr.push(optArr_1[i]); optArr.push(optArr_1[i]);
if(optArr_2[i]) optArr.push(optArr_2[i]); if (optArr_2[i]) optArr.push(optArr_2[i]);
} }
// console.log(`传入的算式列: ${c}`); // console.log(`传入的算式列: ${c}`);
// console.log(optArr); // console.log(optArr);
if(this.calculator(optArr) == itemPosIfoArr[itemPosIfoArr.length - 1].target.getComponent(VHFillNumItem)!.showNum){ if (this.calculator(optArr) == itemPosIfoArr[itemPosIfoArr.length - 1].target.getComponent(VHFillNumItem)!.showNum) {
itemPosIfoArr[itemPosIfoArr.length - 1].target.getComponent(VHFillNumItem)!.bgSpr.node.active = true; itemPosIfoArr[itemPosIfoArr.length - 1].target.getComponent(VHFillNumItem)!.bgSpr.node.active = true;
} }
else{ else {
isWin = false; isWin = false;
itemPosIfoArr[itemPosIfoArr.length - 1].target.getComponent(VHFillNumItem)!.bgSpr.node.active = false; itemPosIfoArr[itemPosIfoArr.length - 1].target.getComponent(VHFillNumItem)!.bgSpr.node.active = false;
} }
...@@ -322,6 +390,9 @@ export class VHFillNumCtr extends Component { ...@@ -322,6 +390,9 @@ export class VHFillNumCtr extends Component {
case 1: case 1:
this.levelData = vhfn_lv_1; this.levelData = vhfn_lv_1;
break; break;
case 2:
this.levelData = vhfn_lv_2;
break;
default: default:
this.levelData = vhfn_lv_1; this.levelData = vhfn_lv_1;
break; break;
...@@ -391,20 +462,21 @@ export class VHFillNumCtr extends Component { ...@@ -391,20 +462,21 @@ export class VHFillNumCtr extends Component {
getOperatorArr(idx: number, isRow: boolean) { getOperatorArr(idx: number, isRow: boolean) {
let optArr: string[] = []; let optArr: string[] = [];
if(isRow){ if (isRow) {
for(let i = 0; i < this.levelData.rowSymb[idx].length - 1; ++ i){ for (let i = 0; i < this.levelData.rowSymb[idx].length - 1; ++i) {
optArr.push(this.levelData.rowSymb[idx][i]); optArr.push(this.levelData.rowSymb[idx][i]);
} }
} }
else{ else {
for(let i = 0; i < this.levelData.columnSymb.length - 1; ++ i){ for (let i = 0; i < this.levelData.columnSymb.length - 1; ++i) {
optArr.push(this.levelData.columnSymb[i][idx]); optArr.push(this.levelData.columnSymb[i][idx]);
} }
} }
return optArr; return optArr;
} }
// update (deltaTime: number) { update(deltaTime: number) {
// // [4] // [4]
// } this.countdownTime(deltaTime);
}
} }
...@@ -72,7 +72,6 @@ export class VHFillNumItem extends Component { ...@@ -72,7 +72,6 @@ export class VHFillNumItem extends Component {
// console.log(`一个item被点击0`); // console.log(`一个item被点击0`);
// console.log(this.clickNode); // console.log(this.clickNode);
this.clickNode.on(Node.EventType.TOUCH_END, () => { this.clickNode.on(Node.EventType.TOUCH_END, () => {
console.log(`一个item被点击1`);
director.emit("VHFM_click", this); director.emit("VHFM_click", this);
}); });
} }
......
...@@ -1109,4 +1109,32 @@ export const levelCfg: OneVarLevelItf[] = [ ...@@ -1109,4 +1109,32 @@ export const levelCfg: OneVarLevelItf[] = [
} }
] ]
} }
, {
gameIdHead: 180,
title: "纵横填数",
desc: "纵横填数,第一个版本",
levelArr: [{
gameId: 18001,
sceneUnitIfo: SCENE_DEF.VHFillNum_1,
comName: "VHFillNumCtr",
level: 1,
resData: {
totalTime: 60,
level: 1,
isShowGuide: true
}
}
, {
gameId: 18002,
sceneUnitIfo: SCENE_DEF.VHFillNum_1,
comName: "VHFillNumCtr",
level: 2,
resData: {
totalTime: 120,
level: 2
}
}
]
}
]; ];
\ No newline at end of file
...@@ -26,7 +26,7 @@ export class LevelHomeCtr extends Component { ...@@ -26,7 +26,7 @@ export class LevelHomeCtr extends Component {
// [3] // [3]
if (!levelMgr.loadedOutData) { if (!levelMgr.loadedOutData) {
levelMgr.loadedOutData = true; levelMgr.loadedOutData = true;
levelMgr.gameIdHead = 170; levelMgr.gameIdHead = 180;
levelMgr.unLockCount = 10; levelMgr.unLockCount = 10;
if (Utils.getValueFromHref("gameIdHead")) { if (Utils.getValueFromHref("gameIdHead")) {
levelMgr.gameIdHead = Number(Utils.getValueFromHref("gameIdHead")); levelMgr.gameIdHead = Number(Utils.getValueFromHref("gameIdHead"));
......
...@@ -103,6 +103,8 @@ interface ScenePathItf { ...@@ -103,6 +103,8 @@ interface ScenePathItf {
DigitalMysteryFigure_1: ScenePathUnitItf, DigitalMysteryFigure_1: ScenePathUnitItf,
//邻接数组 //邻接数组
AdjacentArray_1: ScenePathUnitItf, AdjacentArray_1: ScenePathUnitItf,
//纵横填数
VHFillNum_1: ScenePathUnitItf,
} }
export const SCENE_DEF: ScenePathItf = { export const SCENE_DEF: ScenePathItf = {
TestScene: { TestScene: {
...@@ -445,4 +447,9 @@ export const SCENE_DEF: ScenePathItf = { ...@@ -445,4 +447,9 @@ export const SCENE_DEF: ScenePathItf = {
sceneName: "AdjacentArray_1", sceneName: "AdjacentArray_1",
desc: "邻接数组,第一个版本" desc: "邻接数组,第一个版本"
}, },
VHFillNum_1: {
bundleName: "sceneBundle",
sceneName: "VHFillNum_1",
desc: "纵横填数,第一个版本"
},
} }
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