diff --git a/assets/common/passCheckFont.plist b/assets/common/passCheckFont.plist index 6a957f9..dd3fb41 100644 --- a/assets/common/passCheckFont.plist +++ b/assets/common/passCheckFont.plist @@ -7,7 +7,7 @@ all_black_0.png frame - {{184,168},{45,48}} + {{206,156},{45,48}} offset {0,1} rotated @@ -20,11 +20,11 @@ all_black_1.png frame - {{137,220},{27,48}} + {{253,156},{27,48}} offset {-1,0} rotated - + sourceColorRect {{8,1},{27,48}} sourceSize @@ -33,7 +33,7 @@ all_black_2.png frame - {{196,2},{39,48}} + {{159,206},{39,48}} offset {0,1} rotated @@ -46,7 +46,7 @@ all_black_3.png frame - {{196,43},{37,48}} + {{104,215},{37,48}} offset {-1,1} rotated @@ -59,7 +59,7 @@ all_black_4.png frame - {{149,118},{45,48}} + {{159,156},{45,48}} offset {0,0} rotated @@ -72,11 +72,11 @@ all_black_5.png frame - {{155,2},{39,48}} + {{54,209},{39,48}} offset {0,1} rotated - + sourceColorRect {{3,0},{39,48}} sourceSize @@ -85,11 +85,11 @@ all_black_6.png frame - {{153,60},{41,48}} + {{53,166},{41,48}} offset {-1,0} rotated - + sourceColorRect {{1,1},{41,48}} sourceSize @@ -98,11 +98,11 @@ all_black_7.png frame - {{137,170},{45,48}} + {{213,109},{45,48}} offset {0,1} rotated - + sourceColorRect {{0,0},{45,48}} sourceSize @@ -111,7 +111,7 @@ all_black_8.png frame - {{106,118},{41,50}} + {{53,54},{41,50}} offset {0,0} rotated @@ -124,20 +124,46 @@ all_black_9.png frame - {{94,176},{41,50}} + {{2,212},{41,50}} offset {0,0} rotated - + sourceColorRect {{2,0},{41,50}} sourceSize {45,50} + cheng.png + + frame + {{247,206},{31,32}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{31,32}} + sourceSize + {31,32} + + fenzhong.png + + frame + {{2,2},{95,50}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{95,50}} + sourceSize + {95,50} + half_black_0.png frame - {{53,2},{53,56}} + {{104,157},{53,56}} offset {0,1} rotated @@ -150,11 +176,11 @@ half_black_1.png frame - {{57,176},{35,56}} + {{96,62},{35,56}} offset {-1,0} rotated - + sourceColorRect {{8,1},{35,56}} sourceSize @@ -163,11 +189,11 @@ half_black_2.png frame - {{104,60},{47,56}} + {{219,60},{47,56}} offset {0,1} rotated - + sourceColorRect {{3,0},{47,56}} sourceSize @@ -176,11 +202,11 @@ half_black_3.png frame - {{108,2},{45,56}} + {{155,109},{45,56}} offset {-1,1} rotated - + sourceColorRect {{3,0},{45,56}} sourceSize @@ -189,7 +215,7 @@ half_black_4.png frame - {{2,180},{53,56}} + {{216,2},{53,56}} offset {0,0} rotated @@ -202,11 +228,11 @@ half_black_5.png frame - {{57,118},{47,56}} + {{161,60},{47,56}} offset {0,1} rotated - + sourceColorRect {{3,0},{47,56}} sourceSize @@ -215,7 +241,7 @@ half_black_6.png frame - {{53,60},{49,56}} + {{104,99},{49,56}} offset {-1,0} rotated @@ -228,7 +254,7 @@ half_black_7.png frame - {{2,122},{53,56}} + {{161,2},{53,56}} offset {0,1} rotated @@ -241,7 +267,7 @@ half_black_8.png frame - {{2,62},{49,58}} + {{53,106},{49,58}} offset {0,0} rotated @@ -254,7 +280,7 @@ half_black_9.png frame - {{2,2},{49,58}} + {{2,152},{49,58}} offset {0,0} rotated @@ -264,6 +290,45 @@ sourceSize {53,58} + jia.png + + frame + {{209,206},{36,34}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{36,34}} + sourceSize + {36,34} + + xiaoshi.png + + frame + {{2,54},{96,49}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{96,49}} + sourceSize + {96,49} + + yuan.png + + frame + {{99,2},{60,58}} + offset + {0,0} + rotated + + sourceColorRect + {{0,0},{60,58}} + sourceSize + {60,58} + metadata @@ -272,9 +337,9 @@ realTextureFileName passCheckFont.png size - {256,256} + {282,255} smartupdate - $TexturePacker:SmartUpdate:ad9874adc9c8a05a25ff74888c02441b$ + $TexturePacker:SmartUpdate:790c3e0d6ee5f49626d30984702c4557$ textureFileName passCheckFont.png diff --git a/assets/common/passCheckFont.plist.meta b/assets/common/passCheckFont.plist.meta index 0657998..b275d12 100644 --- a/assets/common/passCheckFont.plist.meta +++ b/assets/common/passCheckFont.plist.meta @@ -4,8 +4,8 @@ "importer": "asset", "rawTextureUuid": "7fe99da1-dbc0-4fd3-92fd-dba6725ae34c", "size": { - "width": 256, - "height": 256 + "width": 282, + "height": 255 }, "type": "Texture Packer", "subMetas": { @@ -19,8 +19,8 @@ "rotated": false, "offsetX": 0, "offsetY": 1, - "trimX": 184, - "trimY": 168, + "trimX": 206, + "trimY": 156, "width": 45, "height": 48, "rawWidth": 45, @@ -39,11 +39,11 @@ "rawTextureUuid": "7fe99da1-dbc0-4fd3-92fd-dba6725ae34c", "trimType": "auto", "trimThreshold": 1, - "rotated": true, + "rotated": false, "offsetX": -1, "offsetY": 0, - "trimX": 137, - "trimY": 220, + "trimX": 253, + "trimY": 156, "width": 27, "height": 48, "rawWidth": 45, @@ -65,8 +65,8 @@ "rotated": true, "offsetX": 0, "offsetY": 1, - "trimX": 196, - "trimY": 2, + "trimX": 159, + "trimY": 206, "width": 39, "height": 48, "rawWidth": 45, @@ -88,8 +88,8 @@ "rotated": true, "offsetX": -1, "offsetY": 1, - "trimX": 196, - "trimY": 43, + "trimX": 104, + "trimY": 215, "width": 37, "height": 48, "rawWidth": 45, @@ -111,8 +111,8 @@ "rotated": false, "offsetX": 0, "offsetY": 0, - "trimX": 149, - "trimY": 118, + "trimX": 159, + "trimY": 156, "width": 45, "height": 48, "rawWidth": 45, @@ -131,11 +131,11 @@ "rawTextureUuid": "7fe99da1-dbc0-4fd3-92fd-dba6725ae34c", "trimType": "auto", "trimThreshold": 1, - "rotated": false, + "rotated": true, "offsetX": 0, "offsetY": 1, - "trimX": 155, - "trimY": 2, + "trimX": 54, + "trimY": 209, "width": 39, "height": 48, "rawWidth": 45, @@ -154,11 +154,11 @@ "rawTextureUuid": "7fe99da1-dbc0-4fd3-92fd-dba6725ae34c", "trimType": "auto", "trimThreshold": 1, - "rotated": false, + "rotated": true, "offsetX": -1, "offsetY": 0, - "trimX": 153, - "trimY": 60, + "trimX": 53, + "trimY": 166, "width": 41, "height": 48, "rawWidth": 45, @@ -177,11 +177,11 @@ "rawTextureUuid": "7fe99da1-dbc0-4fd3-92fd-dba6725ae34c", "trimType": "auto", "trimThreshold": 1, - "rotated": false, + "rotated": true, "offsetX": 0, "offsetY": 1, - "trimX": 137, - "trimY": 170, + "trimX": 213, + "trimY": 109, "width": 45, "height": 48, "rawWidth": 45, @@ -203,8 +203,8 @@ "rotated": false, "offsetX": 0, "offsetY": 0, - "trimX": 106, - "trimY": 118, + "trimX": 53, + "trimY": 54, "width": 41, "height": 50, "rawWidth": 45, @@ -223,11 +223,11 @@ "rawTextureUuid": "7fe99da1-dbc0-4fd3-92fd-dba6725ae34c", "trimType": "auto", "trimThreshold": 1, - "rotated": false, + "rotated": true, "offsetX": 0, "offsetY": 0, - "trimX": 94, - "trimY": 176, + "trimX": 2, + "trimY": 212, "width": 41, "height": 50, "rawWidth": 45, @@ -239,6 +239,52 @@ "spriteType": "normal", "subMetas": {} }, + "cheng.png": { + "ver": "1.0.6", + "uuid": "27b0449a-aa3d-4e4d-852e-35d1ab00cab3", + "importer": "sprite-frame", + "rawTextureUuid": "7fe99da1-dbc0-4fd3-92fd-dba6725ae34c", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 247, + "trimY": 206, + "width": 31, + "height": 32, + "rawWidth": 31, + "rawHeight": 32, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "fenzhong.png": { + "ver": "1.0.6", + "uuid": "ad0e6516-f4c0-4e14-bf45-ceb50e00ad87", + "importer": "sprite-frame", + "rawTextureUuid": "7fe99da1-dbc0-4fd3-92fd-dba6725ae34c", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 2, + "trimY": 2, + "width": 95, + "height": 50, + "rawWidth": 95, + "rawHeight": 50, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, "half_black_0.png": { "ver": "1.0.6", "uuid": "808b4bbc-92e1-4e77-bfc4-f32f4740272c", @@ -249,8 +295,8 @@ "rotated": false, "offsetX": 0, "offsetY": 1, - "trimX": 53, - "trimY": 2, + "trimX": 104, + "trimY": 157, "width": 53, "height": 56, "rawWidth": 53, @@ -269,11 +315,11 @@ "rawTextureUuid": "7fe99da1-dbc0-4fd3-92fd-dba6725ae34c", "trimType": "auto", "trimThreshold": 1, - "rotated": false, + "rotated": true, "offsetX": -1, "offsetY": 0, - "trimX": 57, - "trimY": 176, + "trimX": 96, + "trimY": 62, "width": 35, "height": 56, "rawWidth": 53, @@ -292,10 +338,10 @@ "rawTextureUuid": "7fe99da1-dbc0-4fd3-92fd-dba6725ae34c", "trimType": "auto", "trimThreshold": 1, - "rotated": false, + "rotated": true, "offsetX": 0, "offsetY": 1, - "trimX": 104, + "trimX": 219, "trimY": 60, "width": 47, "height": 56, @@ -315,11 +361,11 @@ "rawTextureUuid": "7fe99da1-dbc0-4fd3-92fd-dba6725ae34c", "trimType": "auto", "trimThreshold": 1, - "rotated": false, + "rotated": true, "offsetX": -1, "offsetY": 1, - "trimX": 108, - "trimY": 2, + "trimX": 155, + "trimY": 109, "width": 45, "height": 56, "rawWidth": 53, @@ -341,8 +387,8 @@ "rotated": false, "offsetX": 0, "offsetY": 0, - "trimX": 2, - "trimY": 180, + "trimX": 216, + "trimY": 2, "width": 53, "height": 56, "rawWidth": 53, @@ -361,11 +407,11 @@ "rawTextureUuid": "7fe99da1-dbc0-4fd3-92fd-dba6725ae34c", "trimType": "auto", "trimThreshold": 1, - "rotated": false, + "rotated": true, "offsetX": 0, "offsetY": 1, - "trimX": 57, - "trimY": 118, + "trimX": 161, + "trimY": 60, "width": 47, "height": 56, "rawWidth": 53, @@ -387,8 +433,8 @@ "rotated": false, "offsetX": -1, "offsetY": 0, - "trimX": 53, - "trimY": 60, + "trimX": 104, + "trimY": 99, "width": 49, "height": 56, "rawWidth": 53, @@ -410,8 +456,8 @@ "rotated": false, "offsetX": 0, "offsetY": 1, - "trimX": 2, - "trimY": 122, + "trimX": 161, + "trimY": 2, "width": 53, "height": 56, "rawWidth": 53, @@ -433,8 +479,8 @@ "rotated": false, "offsetX": 0, "offsetY": 0, - "trimX": 2, - "trimY": 62, + "trimX": 53, + "trimY": 106, "width": 49, "height": 58, "rawWidth": 53, @@ -457,7 +503,7 @@ "offsetX": 0, "offsetY": 0, "trimX": 2, - "trimY": 2, + "trimY": 152, "width": 49, "height": 58, "rawWidth": 53, @@ -468,6 +514,75 @@ "borderRight": 0, "spriteType": "normal", "subMetas": {} + }, + "jia.png": { + "ver": "1.0.6", + "uuid": "42aacbe2-db33-40d6-932b-445aa9e8479c", + "importer": "sprite-frame", + "rawTextureUuid": "7fe99da1-dbc0-4fd3-92fd-dba6725ae34c", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 209, + "trimY": 206, + "width": 36, + "height": 34, + "rawWidth": 36, + "rawHeight": 34, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "xiaoshi.png": { + "ver": "1.0.6", + "uuid": "18cbc723-0171-4fd1-bef6-4868bbb51e78", + "importer": "sprite-frame", + "rawTextureUuid": "7fe99da1-dbc0-4fd3-92fd-dba6725ae34c", + "trimType": "auto", + "trimThreshold": 1, + "rotated": true, + "offsetX": 0, + "offsetY": 0, + "trimX": 2, + "trimY": 54, + "width": 96, + "height": 49, + "rawWidth": 96, + "rawHeight": 49, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} + }, + "yuan.png": { + "ver": "1.0.6", + "uuid": "1375b028-68b3-484a-972b-32553c1269f6", + "importer": "sprite-frame", + "rawTextureUuid": "7fe99da1-dbc0-4fd3-92fd-dba6725ae34c", + "trimType": "auto", + "trimThreshold": 1, + "rotated": false, + "offsetX": 0, + "offsetY": 0, + "trimX": 99, + "trimY": 2, + "width": 60, + "height": 58, + "rawWidth": 60, + "rawHeight": 58, + "borderTop": 0, + "borderBottom": 0, + "borderLeft": 0, + "borderRight": 0, + "spriteType": "normal", + "subMetas": {} } } } \ No newline at end of file diff --git a/assets/common/passCheckFont.png b/assets/common/passCheckFont.png index f343f4d..f25544f 100644 Binary files a/assets/common/passCheckFont.png and b/assets/common/passCheckFont.png differ diff --git a/assets/common/passCheckFont.png.meta b/assets/common/passCheckFont.png.meta index 7426fa1..aefdee2 100644 --- a/assets/common/passCheckFont.png.meta +++ b/assets/common/passCheckFont.png.meta @@ -8,8 +8,8 @@ "premultiplyAlpha": false, "genMipmaps": false, "packable": true, - "width": 256, - "height": 256, + "width": 282, + "height": 255, "platformSettings": {}, "subMetas": {} } \ No newline at end of file diff --git a/assets/shop/prefab/passCheck.prefab b/assets/shop/prefab/passCheck.prefab index a55c605..2f816ff 100644 --- a/assets/shop/prefab/passCheck.prefab +++ b/assets/shop/prefab/passCheck.prefab @@ -3368,12 +3368,17 @@ "texture_atlas": { "__uuid__": "88f4116d-72c2-46cc-9f06-d164a85a9275" }, + "passCheckFont": null, "newUserAtlas": { "__uuid__": "f5f8c4fd-b672-46fe-85a4-79bd8b1b0eb9" }, "uiAtlas": { "__uuid__": "56aacf5e-256b-4c72-b5d1-3982932775c9" }, + "skylineHealth": null, + "iceb": null, + "chuizi": null, + "starb": null, "_id": "" }, { diff --git a/assets/shop/prefab/passCheckItem.prefab b/assets/shop/prefab/passCheckItem.prefab index 6be3de5..a0fc5a6 100644 --- a/assets/shop/prefab/passCheckItem.prefab +++ b/assets/shop/prefab/passCheckItem.prefab @@ -2305,6 +2305,9 @@ "rightNum": { "__id__": 36 }, + "passCheckFont": { + "__uuid__": "4ed6cebc-e4de-4fe9-9f9b-502ecfa21a7b" + }, "texture_atlas": { "__uuid__": "88f4116d-72c2-46cc-9f06-d164a85a9275" }, @@ -2339,4 +2342,4 @@ "fileId": "", "sync": false } -] \ No newline at end of file +] diff --git a/assets/shop/script/passCheckItem.ts b/assets/shop/script/passCheckItem.ts index 9ff87db..972f650 100644 --- a/assets/shop/script/passCheckItem.ts +++ b/assets/shop/script/passCheckItem.ts @@ -19,6 +19,9 @@ export default class PassCheckItem extends cc.Component { @property(cc.SpriteAtlas) texture_atlas: cc.SpriteAtlas = null; + @property(cc.SpriteAtlas) + passCheckFont: cc.SpriteAtlas = null; + // 添加更多图集属性 @property(cc.SpriteAtlas) newUserAtlas: cc.SpriteAtlas = null; @@ -48,7 +51,6 @@ export default class PassCheckItem extends cc.Component { private itemIndex: number = 0; private isUIInitialized: boolean = false; private levelNode: cc.Node = null; - private numberPositions: { [name: string]: number[] } = {}; // 1001 金币 2001 锤子 2003 魔棒 3001 15分钟无限体力 3002 30分钟 3003 1小时 3004 2小时 3005 3小时 // 添加物品ID到图片名称的映射 private itemImageMap: { [key: number]: { imageName: string, atlas?: string } } = { @@ -61,11 +63,6 @@ export default class PassCheckItem extends cc.Component { 3003: { imageName: "skylineHealth" }, // 可以继续添加更多物品ID和对应图片的映射 }; - private numImgmap: { [key: number]: { imageName: string, atlas: string } } = { - 3001: { imageName: "15", atlas: "uiAtlas" }, - 3002: { imageName: "30min", atlas: "texture_atlas" }, - 3003: { imageName: "1h", atlas: "texture_atlas" }, - } init(data: any, index: number) { this.data = data; @@ -276,71 +273,48 @@ export default class PassCheckItem extends cc.Component { // 使用默认图片 } - let addTiem = node.getChildByName("addTiem"); - addTiem.active = false; - let num1 = node.getChildByName("num_1"); - let num_x = node.getChildByName("num_x"); - const origin = this.numberPositions[node.name] || (this.numberPositions[node.name] = [num1.x, num_x.x]); - num1.x = origin[0]; num_x.x = origin[1]; - num1.active = false; - num_x.active = false; - if ([3001, 3002, 3003].includes(itemID) && addTiem) { - addTiem.active = true; - const numImageInfo = this.numImgmap[itemID]; - if (numImageInfo) { - let targetAtlas: cc.SpriteAtlas = null; - switch (numImageInfo.atlas) { - case "texture_atlas": - targetAtlas = this.texture_atlas; - break; - case "uiAtlas": - targetAtlas = this.uiAtlas; - break; - default: - console.warn(`Unknown atlas for num image: ${numImageInfo.atlas}`); - break; - } + const addTime = node.getChildByName("addTiem"); + const numberNode = node.getChildByName("num_1"); + addTime.active = false; + node.getChildByName("num_x").active = false; + numberNode.active = true; + numberNode.setPosition(addTime.x, addTime.y - 20); + this.updateRewardText(itemID, itemNum, numberNode); + this.setNodeGray(numberNode, itemData === 0 ? cc.color(190, 190, 190, 255) : cc.Color.WHITE); + } - if (targetAtlas) { - const spriteFrame = targetAtlas.getSpriteFrame(numImageInfo.imageName); - if (spriteFrame) { - let numSprite = addTiem.getComponent(cc.Sprite); - if (numSprite) { - numSprite.spriteFrame = spriteFrame; - } - } else { - console.warn(`Sprite frame ${numImageInfo.imageName} not found in atlas ${numImageInfo.atlas}`); - } - } - } - } else { - num1.active = true; - num_x.active = true; - // NumberToImage.numberToImageNodes(itemNum, 50, 25, "pc_num_", num1, true); - // NumberToImage.numberToImageNodes(itemNum, 45, 48, "Black", num1, true); - NumberToImage.numberToImageNodesPassCheck(itemNum, 48, 50, "half_black_", num1, true); - if (itemData === 0) { - this.setNodeGray(num1) - this.setNodeGray(num_x) - } - // num1.scale = 0.8; - if (num_x && num1) { - // 计算数值的位数 - const digitCount = itemNum.toString().length; - const offset = Math.max(0, digitCount); - const num_xWidth = num_x.width; - if (digitCount == 4) { - num1.x = num1.x - 75; - num_x.x = num1.x - (offset - 1) * num_xWidth - 25; - } else if (digitCount == 3) { - num1.x = num1.x - 45; - num_x.x = num1.x - offset * num_xWidth - 15; - } else if (digitCount == 1) { - num_x.x = num1.x - 55; - } + private updateRewardText(itemID: number, itemNum: number, target: cc.Node) { + // 时长由物品 ID 决定,与实际发奖规则保持一致。 + const minutes = { 3001: 15, 3002: 30, 3003: 60 }[itemID]; + const value = minutes ? (minutes >= 60 ? minutes / 60 : minutes) : itemNum; + const frameNames: string[] = itemID === 1001 ? [] : [minutes ? "jia" : "cheng"]; + for (const digit of String(value)) frameNames.push("half_black_" + digit); + if (minutes) frameNames.push(minutes >= 60 ? "xiaoshi" : "fenzhong"); - } + target.destroyAllChildren(); + const glyphs: cc.Node[] = []; + const spacing = 2; + let width = 0; + let height = 0; + for (const name of frameNames) { + const glyph = new cc.Node(name); + const sprite = glyph.addComponent(cc.Sprite); + sprite.sizeMode = cc.Sprite.SizeMode.TRIMMED; + sprite.spriteFrame = this.passCheckFont.getSpriteFrame(name); + target.addChild(glyph); + glyphs.push(glyph); + width += glyph.width; + height = Math.max(height, glyph.height); } + width += spacing * (glyphs.length - 1); + let x = -width / 2; + for (const glyph of glyphs) { + glyph.x = x + glyph.width / 2; + x += glyph.width + spacing; + } + target.setContentSize(width, height); + // 保持原奖励文字约 50 高,长数量或时长限制在卡片内。 + target.scale = Math.min(50 / height, 218 / width, 1); } diff --git a/settings/project.json b/settings/project.json index 3c518e7..fd57f3e 100644 --- a/settings/project.json +++ b/settings/project.json @@ -1,5 +1,5 @@ { - "last-module-event-record-time": 1789116749030, + "last-module-event-record-time": 1789895712220, "group-list": [ "default", "Map"