diff --git a/assets/Script/JiaZai.ts b/assets/Script/JiaZai.ts index e62fbb6..04de0a4 100644 --- a/assets/Script/JiaZai.ts +++ b/assets/Script/JiaZai.ts @@ -644,24 +644,31 @@ export default class JiaZai extends cc.Component { "kuang" ] rightElements.forEach(elementName => { - let element; - if (elementName === "Pause") { - element = this.node.getChildByName(elementName); - } else if (elementName === "popRank") { - element = this.node.getChildByName("rank"); - } else if (elementName === "tiaodik" || elementName === "shezhiBtn") { - element = loadNode.getChildByName(elementName); - } else { - element = loadNode.getChildByName("Top").getChildByName(elementName); + if (this.node) { + let element; + if (elementName === "Pause") { + if (this.node.getChildByName(elementName)) + element = this.node.getChildByName(elementName); + } else if (elementName === "popRank") { + if (this.node.getChildByName("rank")) + element = this.node.getChildByName("rank"); + } else if (elementName === "tiaodik" || elementName === "shezhiBtn") { + if (loadNode) + element = loadNode.getChildByName(elementName); + } else { + if (loadNode) + element = loadNode.getChildByName("Top").getChildByName(elementName); + } + + if (element) { + if (!element.originalRightOffset) { + element.originalRightOffset = designSize.width / 2 - element.x; + } + element.x = designSize.width / 2 - element.originalRightOffset + barWidth / scale; + element.scale = hmScale; + } } - if (element) { - if (!element.originalRightOffset) { - element.originalRightOffset = designSize.width / 2 - element.x; - } - element.x = designSize.width / 2 - element.originalRightOffset + barWidth / scale; - element.scale = hmScale; - } }); rightElements2.forEach(elementName => { let element; diff --git a/assets/Script/Map.ts b/assets/Script/Map.ts index 4880380..980fb66 100644 --- a/assets/Script/Map.ts +++ b/assets/Script/Map.ts @@ -676,7 +676,16 @@ export default class MapConroler extends cc.Component { blockInit() { let blockArray = cc.fx.GameConfig.BLOCK_INFO[0]; + for (let i = 0; i < blockArray.length; i++) { + let blockInfo = blockArray[i]; + if (blockInfo.floorMove != null && blockInfo.floorMove != undefined) { + if (blockInfo.floorMove) { + this.floorMove = true; + } + } + } blockArray = this.sortBlock(blockArray); + // this.floorSort(blockArray); //console.log("创建方块", blockArray); let index = 0; // 当前要创建的方块索引 let BLOCKS_PER_FRAME = 1; // 初始每帧创建的方块数量 @@ -687,11 +696,7 @@ export default class MapConroler extends cc.Component { const startTime = performance.now(); for (let i = 0; i < BLOCKS_PER_FRAME && index < blockArray.length; i++) { let blockInfo = blockArray[index]; - if (blockInfo.floorMove != null && blockInfo.floorMove != undefined) { - if (blockInfo.floorMove) { - this.floorMove = true; - } - } + // 缓存 Block_Array 访问 const blockPrefab = this.Block_Array[blockInfo.block]; let block = cc.instantiate(blockPrefab); @@ -793,8 +798,35 @@ export default class MapConroler extends cc.Component { createBlocks(); } //给创建方块排序,用来降低drawcall 合批 - sortBlock(allBlocks: { color: number; block: number; type: number }[]) { + sortBlock(allBlocks: { color: number; block: number; type: number; floor: number }[]) { return allBlocks.sort((a, b) => { + // 最高优先级:如果a或者b有一个有floor,则不打乱有floor的排序 + if (this.floorMove == true) { + // console.log("可移动地板关"); + if (a.floor !== undefined || b.floor !== undefined) { + // 如果a和b都有floor且相同,保持相对顺序 + if (a.floor !== undefined && b.floor !== undefined && a.floor === b.floor) { + return 0; + } + // 如果a有floor而b没有,a排在b前面 + if (a.floor !== undefined && b.floor === undefined) { + return -1; + } + // 如果b有floor而a没有,b排在a前面 + if (a.floor === undefined && b.floor !== undefined) { + return 1; + } + // 如果a和b都有floor但不同,保持相对顺序 + if (a.floor !== undefined && b.floor !== undefined && a.floor !== b.floor) { + return 0; + } + } + } + else { + // console.log("________无可移动地板关"); + } + + // 先处理 type 为 1 的情况,将其放到最后 if (a.type === 1 && b.type !== 1) { return 1; @@ -827,6 +859,9 @@ export default class MapConroler extends cc.Component { }); } + + + //创建墙壁 wallInit() { @@ -837,36 +872,39 @@ export default class MapConroler extends cc.Component { const createWalls = () => { const startTime = performance.now(); - for (let i = 0; i < WALLS_PER_FRAME && index < this.wallInfo.length; i++) { - let block = this.wallInfo[index]; - let dir = this.getWllDiraction("wall", cc.v2(block.getComponent("MapBlock").posX, block.getComponent("MapBlock").posY)); - if (dir != null) { - this.createWall(dir, block); + if (this.wallInfo) { + for (let i = 0; i < WALLS_PER_FRAME && index < this.wallInfo.length; i++) { + let block = this.wallInfo[index]; + let dir = this.getWllDiraction("wall", cc.v2(block.getComponent("MapBlock").posX, block.getComponent("MapBlock").posY)); + if (dir != null) { + this.createWall(dir, block); + } + index++; + } + const endTime = performance.now(); + const frameTime = endTime - startTime; + // 如果当前帧执行时间过长,减少每帧创建数量 + if (frameTime > 16) { + WALLS_PER_FRAME = Math.max(WALLS_PER_FRAME - 1, MIN_PER_FRAME); + } else { + WALLS_PER_FRAME = Math.min(WALLS_PER_FRAME + 1, MAX_PER_FRAME); + } + + // 如果还有墙壁未创建,下一帧继续创建 + if (index < this.wallInfo.length) { + this.scheduleOnce(() => { + createWalls(); + }, 0); + } else { + // 所有墙壁创建完成后,创建拐角节点 + this.createCornerNodes(); + this.sortWall(); + if (this.revolving_state != 0) { + this.createRevolvingWall(); + } } - index++; - } - const endTime = performance.now(); - const frameTime = endTime - startTime; - // 如果当前帧执行时间过长,减少每帧创建数量 - if (frameTime > 16) { - WALLS_PER_FRAME = Math.max(WALLS_PER_FRAME - 1, MIN_PER_FRAME); - } else { - WALLS_PER_FRAME = Math.min(WALLS_PER_FRAME + 1, MAX_PER_FRAME); } - // 如果还有墙壁未创建,下一帧继续创建 - if (index < this.wallInfo.length) { - this.scheduleOnce(() => { - createWalls(); - }, 0); - } else { - // 所有墙壁创建完成后,创建拐角节点 - this.createCornerNodes(); - this.sortWall(); - if (this.revolving_state != 0) { - this.createRevolvingWall(); - } - } }; // 开始分帧创建墙壁 @@ -2689,6 +2727,7 @@ export default class MapConroler extends cc.Component { for (let i = 0; i < this.blocks.length; i++) { if (this.blocks[i].getComponent("Block").block_Info) { let blockInfo = this.blocks[i].getComponent("Block").block_Info; + console.log("floorMove", blockInfo.floor); if (blockInfo.floorMove != undefined) { if (blockInfo.floorMove == true) { if (this.teamBlocks.length == 0) { @@ -2745,7 +2784,7 @@ export default class MapConroler extends cc.Component { } removeFloor() { - // console.log("结束"); + console.log("结束__________"); if (this.teamBlocks.length > 0) { for (let j = 0; j < this.teamBlocks.length; j++) { this.teamBlocks[j].getComponent("Block").setMoveFloor(); diff --git a/assets/career/script/CareerList.ts b/assets/career/script/CareerList.ts index a78b27d..5ee9545 100644 --- a/assets/career/script/CareerList.ts +++ b/assets/career/script/CareerList.ts @@ -135,7 +135,8 @@ export default class CareerList extends cc.Component { this.randerChildren = []; this.itemHeight = this.itemRender.height; this.itemWidth = this.itemRender.width; - this.scrollView = this.node.getComponent(cc.ScrollView); + if (this.node) + this.scrollView = this.node.getComponent(cc.ScrollView); this.content = this.scrollView.content; this.content.anchorX = 0; this.content.anchorY = 1; @@ -232,11 +233,13 @@ export default class CareerList extends cc.Component { continue; } + if (item) { + let itemRender: CareerItem = item.getComponent(CareerItem); + itemRender.itemIndex = i + startIndex; + itemRender.data = this.itemDataList[i + startIndex]; + itemRender.dataChanged(); + } - let itemRender: CareerItem = item.getComponent(CareerItem); - itemRender.itemIndex = i + startIndex; - itemRender.data = this.itemDataList[i + startIndex]; - itemRender.dataChanged(); // 计算firstRender的高度偏移 let firstRenderHeight = this.firstRender ? this.firstRender.height : 0; @@ -523,8 +526,11 @@ export default class CareerList extends cc.Component { cc.assetManager.loadRemote(url, { ext: '.png' }, (err, texture: cc.Texture2D) => { if (texture && node) { // node.getChildByName("pic").active = true; - var sprite = node.getComponent(cc.Sprite); - sprite.spriteFrame = new cc.SpriteFrame(texture); + if (node.getComponent(cc.Sprite)) { + var sprite = node.getComponent(cc.Sprite); + sprite.spriteFrame = new cc.SpriteFrame(texture); + } + } else { diff --git a/assets/career/script/CareerManager.ts b/assets/career/script/CareerManager.ts index 5cc1378..ca2979a 100644 --- a/assets/career/script/CareerManager.ts +++ b/assets/career/script/CareerManager.ts @@ -22,20 +22,27 @@ export default class CareerManager extends cc.Component { } //初始化数据 init(data, topData) { - this.rankList = cc.find("ScrollView", this.node).getComponent(CareerList); this.listData = data; this.selfData = null; this.rankNumber = 100; this.rankTotal = 100; - this.rankList.setData(data, topData); + + if (this.node) { + this.rankList = cc.find("ScrollView", this.node).getComponent(CareerList); + this.rankList.setData(data, topData); + } + // 获取当前日期 let currentDate = new Date(); let month = currentDate.getMonth() + 1; let day = currentDate.getDate(); - if (this.bg.getChildByName("month")) - this.bg.getChildByName("month").getComponent(cc.Label).string = month.toString(); - if (this.bg.getChildByName("day")) - this.bg.getChildByName("day").getComponent(cc.Label).string = day.toString(); + if (this.bg) { + if (this.bg.getChildByName("month")) + this.bg.getChildByName("month").getComponent(cc.Label).string = month.toString(); + if (this.bg.getChildByName("day")) + this.bg.getChildByName("day").getComponent(cc.Label).string = day.toString(); + } + } start() { diff --git a/assets/shop/script/passCheckItem.ts b/assets/shop/script/passCheckItem.ts index 7102cd3..121d650 100644 --- a/assets/shop/script/passCheckItem.ts +++ b/assets/shop/script/passCheckItem.ts @@ -396,9 +396,12 @@ export default class PassCheckItem extends cc.Component { private setNodeGray(node: cc.Node, color?: cc.Color) { let setColor = color || cc.color(190, 190, 190, 255); - for (let i = 0; i < node.children.length; i++) { - // console.log("设置子节点颜色", node.children[i]); - node.children[i].color = setColor; + if (node) { + for (let i = 0; i < node.children.length; i++) { + // console.log("设置子节点颜色", node.children[i]); + node.children[i].color = setColor; + } } + } } \ No newline at end of file diff --git a/assets/shop/script/shop.ts b/assets/shop/script/shop.ts index ad62881..446e295 100644 --- a/assets/shop/script/shop.ts +++ b/assets/shop/script/shop.ts @@ -143,46 +143,49 @@ export default class NewClass extends cc.Component { { product_id: "gold_5", price: 32800, coin: 100000, title: "" }, { product_id: "gold_6", price: 64800, coin: 240000, title: "" }, ]; - for (let i = 2; i <= 7 && i < this.itemList.children.length; i++) { - const spriteComp = this.itemList.children[i].children[0].getComponent(cc.Sprite); - const price = this.itemList.children[i].children[1]; - const title = this.itemList.children[i].children[2]; - const discount = this.itemList.children[i].children[4]; - const add = this.itemList.children[i].children[5]; - this.itemList.children[i].children[4].active = false; - this.itemList.children[i].children[5].active = false; - this.itemList.children[i].children[6].active = false; - const product = products[i - 1]; - let name = "gold_" + (i - 1) - if (this.doubleInfo) { - console.log(name); - console.log(this.doubleInfo[name]); - if (this.doubleInfo[name] == false) { - this.itemList.children[i].children[4].active = true; - this.itemList.children[i].children[5].active = true; - this.itemList.children[i].children[6].active = true; + if (this.itemList) { + for (let i = 2; i <= 7 && i < this.itemList.children.length; i++) { + const spriteComp = this.itemList.children[i].children[0].getComponent(cc.Sprite); + const price = this.itemList.children[i].children[1]; + const title = this.itemList.children[i].children[2]; + const discount = this.itemList.children[i].children[4]; + const add = this.itemList.children[i].children[5]; + this.itemList.children[i].children[4].active = false; + this.itemList.children[i].children[5].active = false; + this.itemList.children[i].children[6].active = false; + const product = products[i - 1]; + let name = "gold_" + (i - 1) + if (this.doubleInfo) { + console.log(name); + console.log(this.doubleInfo[name]); + if (this.doubleInfo[name] == false) { + this.itemList.children[i].children[4].active = true; + this.itemList.children[i].children[5].active = true; + this.itemList.children[i].children[6].active = true; + } + } + + if (spriteComp && product) { + // TODO: 根据 product_id 或 name 设置 spriteComp.spriteFrame + } + + + if (price && product) { + NumberToImage.numberToImageNodesShop(product.price / 100, 37, 20, "resultBlack_", price, false) + } + if (title && product) { + NumberToImage.numberToImageNodes(product.coin, 40, 25, "scoin_", title, true) + } + if (discount && product) { + NumberToImage.numberToImageNodesShop(product.coin, 40, 25, "new_coin_", discount, true) + let pos = cc.v2(discount.children[0].position.x, discount.children[0].position.y); + let number = i % 2 == 0 ? 34 : 42 + add.x = pos.x + discount.x - number; add.y = pos.y + discount.y; + } } - - if (spriteComp && product) { - // TODO: 根据 product_id 或 name 设置 spriteComp.spriteFrame - } - - - if (price && product) { - NumberToImage.numberToImageNodesShop(product.price / 100, 37, 20, "resultBlack_", price, false) - } - if (title && product) { - NumberToImage.numberToImageNodes(product.coin, 40, 25, "scoin_", title, true) - } - if (discount && product) { - NumberToImage.numberToImageNodesShop(product.coin, 40, 25, "new_coin_", discount, true) - let pos = cc.v2(discount.children[0].position.x, discount.children[0].position.y); - let number = i % 2 == 0 ? 34 : 42 - add.x = pos.x + discount.x - number; add.y = pos.y + discount.y; - - } } + } @@ -838,7 +841,8 @@ export default class NewClass extends cc.Component { this.monthCardTime.active = false; } - NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.monthTime, 35, 15, "button_", this.monthCardTime.children[1], true); + if (this.monthCardTime) + NumberToImage.numberToImageNodes(cc.fx.GameConfig.GM_INFO.monthTime, 35, 15, "button_", this.monthCardTime.children[1], true); } openConfirmBox() { diff --git a/settings/project.json b/settings/project.json index 9434f6d..87c88e1 100644 --- a/settings/project.json +++ b/settings/project.json @@ -1,5 +1,5 @@ { - "last-module-event-record-time": 1768881764145, + "last-module-event-record-time": 1769499063709, "group-list": [ "default", "Map"