Commit 98732f78 authored by unknown's avatar unknown

点阵封锁好了

parent 65450189
{
"ver": "1.0.21",
"importer": "image",
"imported": true,
"uuid": "883de798-5814-4177-8223-4703908d0a54",
"files": [
".png",
".json"
],
"subMetas": {
"6c48a": {
"importer": "texture",
"uuid": "883de798-5814-4177-8223-4703908d0a54@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": "883de798-5814-4177-8223-4703908d0a54"
},
"ver": "1.0.21",
"imported": true,
"files": [
".json"
],
"subMetas": {}
},
"f9941": {
"importer": "sprite-frame",
"uuid": "883de798-5814-4177-8223-4703908d0a54@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": "883de798-5814-4177-8223-4703908d0a54@6c48a",
"atlasUuid": ""
},
"ver": "1.0.9",
"imported": true,
"files": [
".json"
],
"subMetas": {}
}
},
"userData": {
"hasAlpha": true,
"type": "sprite-frame",
"redirect": "883de798-5814-4177-8223-4703908d0a54@f9941"
}
}
...@@ -3,7 +3,7 @@ import { _decorator, Component, Node } from 'cc'; ...@@ -3,7 +3,7 @@ import { _decorator, Component, Node } from 'cc';
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
export interface LatticeBlockadeIfo { export interface LatticeBlockadeIfo {
s_xy: [number, number], s_xy: [number, number], //开始点坐标 (0,0)作为左上角第一个点(列,行)
row: number, row: number,
column: number, column: number,
numArr: number[][] numArr: number[][]
...@@ -17,3 +17,12 @@ export const LB_LV_1: LatticeBlockadeIfo = { ...@@ -17,3 +17,12 @@ export const LB_LV_1: LatticeBlockadeIfo = {
, [-1, -1, 1] , [-1, -1, 1]
, [0, -1, -1]] , [0, -1, -1]]
} }
export const LB_LV_2: LatticeBlockadeIfo = {
s_xy: [0, 2],
row: 4,
column: 4,
numArr: [[-1, 3, -1]
, [1, -1, 2]
, [-1, -1, -1]]
}
\ No newline at end of file
import { _decorator, Component, Node, Vec3, v3, UITransform, Prefab, instantiate, Label, Color, Layers, find, Sprite, SpriteFrame, v2, director, Vec2, EventTouch, Canvas } from 'cc'; import { _decorator, Component, Node, Vec3, v3, UITransform, Prefab, instantiate, Label, Color, Layers, find, Sprite, SpriteFrame, v2, director, Vec2, EventTouch, Canvas, CCFloat } from 'cc';
import { LatticeBlockadeIfo, LB_LV_1 } from './LatticeBlockadeCfg'; import { countdownMus, failMus, succMus } from '../../../../startFolder/script/common/AudioDef';
import { AudioMgr } from '../../../../startFolder/script/common/AudioMgr';
import { Utils } from '../../../../startFolder/script/common/Utils';
import { VIEW_DEF } from '../../../../startFolder/script/common/ViewDef';
import { viewMgr, VIEW_INDEX } from '../../../../startFolder/script/common/ViewMgr';
import { BeginCountdownView } from '../../commonView/script/BeginCountdownView';
import { ChallengeFailView } from '../../commonView/script/ChallengeFailView';
import { ChallengeSuccView } from '../../commonView/script/ChallengeSuccView';
import { LatticeBlockadeIfo, LB_LV_1, LB_LV_2 } from './LatticeBlockadeCfg';
import { LatticeBlockadeItem } from './LatticeBlockadeItem'; import { LatticeBlockadeItem } from './LatticeBlockadeItem';
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
...@@ -62,6 +70,12 @@ export class LatticeBlockadeCtr extends Component { ...@@ -62,6 +70,12 @@ export class LatticeBlockadeCtr extends Component {
@property(Prefab) @property(Prefab)
linePre: Prefab = null!; linePre: Prefab = null!;
@property(Label)
countdownLab: Label = null!;
@property(CCFloat)
totalTime: number = 0;
private itemWidth = 100; private itemWidth = 100;
private itemHeight = 100; private itemHeight = 100;
private itemSpaceX = 0; private itemSpaceX = 0;
...@@ -78,16 +92,63 @@ export class LatticeBlockadeCtr extends Component { ...@@ -78,16 +92,63 @@ export class LatticeBlockadeCtr extends Component {
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.NumMatDescView);
}
onCloseGameDescView() {
this.gameState = GAME_STATE.IDLE;
}
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]
this.posArrNode.on(Node.EventType.TOUCH_START, this.onTouchStart, this); this.posArrNode.on(Node.EventType.TOUCH_START, this.onTouchStart, this);
this.posArrNode.on(Node.EventType.TOUCH_MOVE, this.onTouchMove, this); this.posArrNode.on(Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
this.posArrNode.on(Node.EventType.TOUCH_END, this.onTouchEnd, this); this.posArrNode.on(Node.EventType.TOUCH_END, this.onTouchEnd, this);
director.on("begin_countdown_end", () => {
//引导
if (!this.isShowGameDescViewOnce) {
this.gameState = GAME_STATE.PAUSE;
this.showGameDescView();
}
else {
this.gameState = GAME_STATE.IDLE;
}
}, this);
director.on("game_desc_close", this.onCloseGameDescView, this);
this.gameStart(); this.gameStart();
} }
onDestroy() { onDestroy() {
director.off("begin_countdown_end");
director.off("game_desc_close", this.onCloseGameDescView, this);
} }
onTouchStart(event: EventTouch) { onTouchStart(event: EventTouch) {
...@@ -116,6 +177,9 @@ export class LatticeBlockadeCtr extends Component { ...@@ -116,6 +177,9 @@ export class LatticeBlockadeCtr extends Component {
if (this.pathItemPosArr[i].id == this.pathItemPosArr[0].id) continue; if (this.pathItemPosArr[i].id == this.pathItemPosArr[0].id) continue;
this.pathItemPosArr[i].target.getComponent(LatticeBlockadeItem)?.setItemColor(new Color(255, 255, 255, 255)); this.pathItemPosArr[i].target.getComponent(LatticeBlockadeItem)?.setItemColor(new Color(255, 255, 255, 255));
} }
for (let i = 0; i < this.lineArr.length; ++i) {
if (this.lineArr[i].type == LINE_TYPE.FULL) this.lineArr[i].targSpr.color = new Color(255, 255, 255, 255);
}
let idx = -1; let idx = -1;
for (let i = 0; i < this.pathItemPosArr.length; ++i) { for (let i = 0; i < this.pathItemPosArr.length; ++i) {
if (this.pathItemPosArr[i].id == touchItem.getPosIfo().id) { if (this.pathItemPosArr[i].id == touchItem.getPosIfo().id) {
...@@ -151,6 +215,14 @@ export class LatticeBlockadeCtr extends Component { ...@@ -151,6 +215,14 @@ export class LatticeBlockadeCtr extends Component {
console.log(`加一个实线段`); console.log(`加一个实线段`);
if (idx == 0) { if (idx == 0) {
//判断是否成功 //判断是否成功
if (this.checkWin()) {
console.log(`游戏成功`);
this.gameEnd(true);
}
else {
console.log(`游戏没有成功`);
// this.markMoreLine();
}
} }
} }
else if (idx != 0 || (this.pathItemPosArr.length > 1 && this.pathItemPosArr.length <= 3)) { else if (idx != 0 || (this.pathItemPosArr.length > 1 && this.pathItemPosArr.length <= 3)) {
...@@ -190,6 +262,7 @@ export class LatticeBlockadeCtr extends Component { ...@@ -190,6 +262,7 @@ export class LatticeBlockadeCtr extends Component {
this.lineArr.push(line); this.lineArr.push(line);
this.endMarkItemPos = touchPosIfo; this.endMarkItemPos = touchPosIfo;
} }
this.markMoreLine();
} }
onTouchEnd(event: TouchEvent) { onTouchEnd(event: TouchEvent) {
...@@ -208,7 +281,26 @@ export class LatticeBlockadeCtr extends Component { ...@@ -208,7 +281,26 @@ export class LatticeBlockadeCtr extends Component {
return null; return null;
} }
//倒计时
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.levelData = this.getLevelCfg(this.level); this.levelData = this.getLevelCfg(this.level);
this.row = this.levelData.row; this.row = this.levelData.row;
this.column = this.levelData.column; this.column = this.levelData.column;
...@@ -228,9 +320,25 @@ export class LatticeBlockadeCtr extends Component { ...@@ -228,9 +320,25 @@ export class LatticeBlockadeCtr extends Component {
} }
} }
this.endMarkItemPos = null!; this.endMarkItemPos = null!;
this.gameState = GAME_STATE.IDLE; viewMgr.openView(VIEW_DEF.BeginCountdownView, (node) => {
//测试 node.getComponent(BeginCountdownView)?.init();
// this.creLine(this.getItem(0, 0)!, this.getItem(0, 1)!); }, VIEW_INDEX.UPPER);
// this.gameState = GAME_STATE.IDLE;
}
gameEnd(isWin: boolean) {
this.gameState = GAME_STATE.END;
if (isWin) {
viewMgr.openView(VIEW_DEF.ChallengeSuccView, (node) => {
AudioMgr.playOneShot(succMus);
node?.getComponent(ChallengeSuccView)?.init();
}, VIEW_INDEX.TOP);
}
else {
viewMgr.openView(VIEW_DEF.ChallengeFailView, (node) => {
AudioMgr.playOneShot(failMus);
}, VIEW_INDEX.TOP);
}
} }
creAllItem() { creAllItem() {
...@@ -335,6 +443,8 @@ export class LatticeBlockadeCtr extends Component { ...@@ -335,6 +443,8 @@ export class LatticeBlockadeCtr extends Component {
switch (level) { switch (level) {
case 1: case 1:
return LB_LV_1; return LB_LV_1;
case 2:
return LB_LV_2;
default: default:
return LB_LV_1; return LB_LV_1;
} }
...@@ -354,6 +464,22 @@ export class LatticeBlockadeCtr extends Component { ...@@ -354,6 +464,22 @@ export class LatticeBlockadeCtr extends Component {
return null; return null;
} }
checkWin() {
for (let i = 0; i < this.gridIfoArr.length; ++i) {
if (!this.checkGridLine(this.gridIfoArr[i])) return false;
}
return true;
}
markMoreLine() {
for (let i = 0; i < this.gridIfoArr.length; ++i) {
let lineArr = this.getGridMoreLine(this.gridIfoArr[i]);
for (let j = 0; j < lineArr.length; ++j) {
lineArr[j].targSpr.color = new Color(255, 0, 0, 255);
}
}
}
//判断一个格子周围线段是否存在正确数量 //判断一个格子周围线段是否存在正确数量
checkGridLine(grid: GridIfo) { checkGridLine(grid: GridIfo) {
if (grid.count == -1) return true; if (grid.count == -1) return true;
...@@ -367,19 +493,19 @@ export class LatticeBlockadeCtr extends Component { ...@@ -367,19 +493,19 @@ export class LatticeBlockadeCtr extends Component {
//如果一个格子周围的线段多余应有的数量 //如果一个格子周围的线段多余应有的数量
getGridMoreLine(grid: GridIfo) { getGridMoreLine(grid: GridIfo) {
let lineArr: LineIfo[] = []; if (grid.count == -1) return [];
if (grid.count == -1) return lineArr;
let existLineArr: LineIfo[] = []; let existLineArr: LineIfo[] = [];
let count = 0; let count = 0;
if (this.findLine(grid.itemArr[0], grid.itemArr[1], LINE_TYPE.FULL)) { count += 1; existLineArr.push(this.findLine(grid.itemArr[0], grid.itemArr[1], LINE_TYPE.FULL)!) } if (this.findLine(grid.itemArr[0], grid.itemArr[1], LINE_TYPE.FULL)) { count += 1; existLineArr.push(this.findLine(grid.itemArr[0], grid.itemArr[1], LINE_TYPE.FULL)!) }
if (this.findLine(grid.itemArr[0], grid.itemArr[2], LINE_TYPE.FULL)) { count += 1; existLineArr.push(this.findLine(grid.itemArr[0], grid.itemArr[2], LINE_TYPE.FULL)!) } if (this.findLine(grid.itemArr[0], grid.itemArr[2], LINE_TYPE.FULL)) { count += 1; existLineArr.push(this.findLine(grid.itemArr[0], grid.itemArr[2], LINE_TYPE.FULL)!) }
if (this.findLine(grid.itemArr[1], grid.itemArr[3], LINE_TYPE.FULL)) { count += 1; existLineArr.push(this.findLine(grid.itemArr[1], grid.itemArr[3], LINE_TYPE.FULL)!) } if (this.findLine(grid.itemArr[1], grid.itemArr[3], LINE_TYPE.FULL)) { count += 1; existLineArr.push(this.findLine(grid.itemArr[1], grid.itemArr[3], LINE_TYPE.FULL)!) }
if (this.findLine(grid.itemArr[2], grid.itemArr[3], LINE_TYPE.FULL)) { count += 1; existLineArr.push(this.findLine(grid.itemArr[2], grid.itemArr[3], LINE_TYPE.FULL)!) } if (this.findLine(grid.itemArr[2], grid.itemArr[3], LINE_TYPE.FULL)) { count += 1; existLineArr.push(this.findLine(grid.itemArr[2], grid.itemArr[3], LINE_TYPE.FULL)!) }
// for (let i = 0; i < count - grid.count; ++i) { let lineArr: LineIfo[] = [];
// lineArr.push(existLineArr[i]); if (count > grid.count) {
// } for (let i = 0; i < count - grid.count; ++i) {
// return lineArr; lineArr.push(existLineArr[i]);
if (count > grid.count) return existLineArr; }
}
return lineArr; return lineArr;
} }
...@@ -409,7 +535,8 @@ export class LatticeBlockadeCtr extends Component { ...@@ -409,7 +535,8 @@ export class LatticeBlockadeCtr extends Component {
targSpr: spr, targSpr: spr,
} }
} }
// update (deltaTime: number) {
// // [4] update(deltaTime: number) {
// } this.countdownTime(deltaTime);
}
} }
...@@ -22,6 +22,9 @@ ...@@ -22,6 +22,9 @@
}, },
{ {
"__id__": 7 "__id__": 7
},
{
"__id__": 161
} }
], ],
"_active": true, "_active": true,
...@@ -29,7 +32,7 @@ ...@@ -29,7 +32,7 @@
"_prefab": null, "_prefab": null,
"autoReleaseAssets": false, "autoReleaseAssets": false,
"_globals": { "_globals": {
"__id__": 161 "__id__": 164
}, },
"_id": "94d615be-2f2a-47b1-a1a0-aa1f51c47468" "_id": "94d615be-2f2a-47b1-a1a0-aa1f51c47468"
}, },
...@@ -4190,19 +4193,94 @@ ...@@ -4190,19 +4193,94 @@
"totalTime": 30, "totalTime": 30,
"_id": "1326Z2zCRNbah6X48gBQko" "_id": "1326Z2zCRNbah6X48gBQko"
}, },
{
"__type__": "cc.Node",
"_name": "Audio",
"_objFlags": 0,
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 162
},
{
"__id__": 163
}
],
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_layer": 1073741824,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": "7e/m1JMVZAdJ3PYWTfgC+v"
},
{
"__type__": "cc.AudioSource",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 161
},
"_enabled": true,
"__prefab": null,
"_clip": null,
"_loop": false,
"_playOnAwake": true,
"_volume": 1,
"_id": "8cQES2q05LF7hleHp0X39u"
},
{
"__type__": "a46f84T2a1GlbP4xSghryjX",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 161
},
"_enabled": true,
"__prefab": null,
"audioSource": {
"__id__": 162
},
"_id": "25ERdIbWlEbarNxci6Xf2i"
},
{ {
"__type__": "cc.SceneGlobals", "__type__": "cc.SceneGlobals",
"ambient": { "ambient": {
"__id__": 162 "__id__": 165
}, },
"shadows": { "shadows": {
"__id__": 163 "__id__": 166
}, },
"_skybox": { "_skybox": {
"__id__": 164 "__id__": 167
}, },
"fog": { "fog": {
"__id__": 165 "__id__": 168
} }
}, },
{ {
......
...@@ -998,7 +998,7 @@ export const levelCfg: OneVarLevelItf[] = [ ...@@ -998,7 +998,7 @@ export const levelCfg: OneVarLevelItf[] = [
comName: "NumMatReasonCtr", comName: "NumMatReasonCtr",
level: 1, level: 1,
resData: { resData: {
totalTime: 60, totalTime: 30,
level: 1, level: 1,
isShowGuide: true isShowGuide: true
} }
...@@ -1009,7 +1009,35 @@ export const levelCfg: OneVarLevelItf[] = [ ...@@ -1009,7 +1009,35 @@ export const levelCfg: OneVarLevelItf[] = [
comName: "NumMatReasonCtr", comName: "NumMatReasonCtr",
level: 2, level: 2,
resData: { resData: {
totalTime: 120, totalTime: 60,
level: 2
}
}
]
}
, {
gameIdHead: 150,
title: "点阵封锁",
desc: "点阵封锁,第一个版本",
levelArr: [{
gameId: 15001,
sceneUnitIfo: SCENE_DEF.LatticeBlockade_1,
comName: "LatticeBlockadeCtr",
level: 1,
resData: {
totalTime: 20,
level: 1,
isShowGuide: true
}
}
, {
gameId: 15002,
sceneUnitIfo: SCENE_DEF.LatticeBlockade_1,
comName: "LatticeBlockadeCtr",
level: 2,
resData: {
totalTime: 30,
level: 2 level: 2
} }
} }
......
...@@ -26,8 +26,8 @@ export class LevelHomeCtr extends Component { ...@@ -26,8 +26,8 @@ export class LevelHomeCtr extends Component {
// [3] // [3]
if (!levelMgr.loadedOutData) { if (!levelMgr.loadedOutData) {
levelMgr.loadedOutData = true; levelMgr.loadedOutData = true;
levelMgr.gameIdHead = 140; levelMgr.gameIdHead = 150;
levelMgr.unLockCount = 1; levelMgr.unLockCount = 2;
if (Utils.getValueFromHref("gameIdHead")) { if (Utils.getValueFromHref("gameIdHead")) {
levelMgr.gameIdHead = Number(Utils.getValueFromHref("gameIdHead")); levelMgr.gameIdHead = Number(Utils.getValueFromHref("gameIdHead"));
} }
......
...@@ -97,6 +97,8 @@ interface ScenePathItf { ...@@ -97,6 +97,8 @@ interface ScenePathItf {
Sudoku_1: ScenePathUnitItf, Sudoku_1: ScenePathUnitItf,
//数字矩阵 //数字矩阵
NumMatReason_1: ScenePathUnitItf, NumMatReason_1: ScenePathUnitItf,
//点阵封锁
LatticeBlockade_1: ScenePathUnitItf,
} }
export const SCENE_DEF: ScenePathItf = { export const SCENE_DEF: ScenePathItf = {
TestScene: { TestScene: {
...@@ -424,6 +426,11 @@ export const SCENE_DEF: ScenePathItf = { ...@@ -424,6 +426,11 @@ export const SCENE_DEF: ScenePathItf = {
sceneName: "NumMatReason_1", sceneName: "NumMatReason_1",
desc: "数阵推理,第一个版本" desc: "数阵推理,第一个版本"
}, },
LatticeBlockade_1: {
bundleName: "sceneBundle",
sceneName: "LatticeBlockade_1",
desc: "点阵封锁,第一个版本"
},
} }
/** /**
* [1] Class member could be defined like this. * [1] Class member could be defined like this.
......
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