From 77075b26501edabb7acf6aaedd0052683c14415a Mon Sep 17 00:00:00 2001 From: panfudan Date: Wed, 20 Aug 2025 20:51:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=BA=97=20=E5=9F=BA=E6=9C=AC?= =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/resources/gui/element/goods.prefab | 1314 +++++++++++------ .../script/game/common/SingletonModuleComp.ts | 7 + assets/script/game/map/GoodsComp.ts | 101 +- assets/script/game/map/ShopPageComp.ts | 2 +- 4 files changed, 940 insertions(+), 484 deletions(-) diff --git a/assets/resources/gui/element/goods.prefab b/assets/resources/gui/element/goods.prefab index 4c90ad64..3ad3cb67 100644 --- a/assets/resources/gui/element/goods.prefab +++ b/assets/resources/gui/element/goods.prefab @@ -34,29 +34,35 @@ "__id__": 67 }, { - "__id__": 77 + "__id__": 79 }, { - "__id__": 109 + "__id__": 90 }, { - "__id__": 123 + "__id__": 110 + }, + { + "__id__": 124 + }, + { + "__id__": 156 } ], "_active": true, "_components": [ { - "__id__": 155 + "__id__": 170 }, { - "__id__": 157 + "__id__": 172 }, { - "__id__": 159 + "__id__": 174 } ], "_prefab": { - "__id__": 161 + "__id__": 176 }, "_lpos": { "__type__": "cc.Vec3", @@ -527,7 +533,7 @@ "_lpos": { "__type__": "cc.Vec3", "x": 0, - "y": 15, + "y": 25, "z": 0 }, "_lrot": { @@ -648,7 +654,7 @@ "_top": 0, "_bottom": 0, "_horizontalCenter": 0, - "_verticalCenter": 15, + "_verticalCenter": 25, "_isAbsLeft": true, "_isAbsRight": true, "_isAbsTop": true, @@ -705,7 +711,7 @@ "_lpos": { "__type__": "cc.Vec3", "x": -0.05, - "y": 62.8, + "y": 72.8, "z": 0 }, "_lrot": { @@ -843,7 +849,7 @@ "_target": null, "_left": 0, "_right": 0, - "_top": 10, + "_top": 0, "_bottom": 0, "_horizontalCenter": 0, "_verticalCenter": 0, @@ -907,7 +913,7 @@ "_lpos": { "__type__": "cc.Vec3", "x": -19.24609375, - "y": -20, + "y": 0, "z": 0 }, "_lrot": { @@ -1246,7 +1252,7 @@ "_top": 0, "_bottom": 0, "_horizontalCenter": 5, - "_verticalCenter": -20, + "_verticalCenter": 0, "_isAbsLeft": true, "_isAbsRight": true, "_isAbsTop": true, @@ -1276,6 +1282,326 @@ "targetOverrides": null, "nestedPrefabInstanceRoots": null }, + { + "__type__": "cc.Node", + "_name": "max", + "_objFlags": 0, + "__editorExtras__": {}, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 68 + } + ], + "_active": true, + "_components": [ + { + "__id__": 74 + }, + { + "__id__": 76 + } + ], + "_prefab": { + "__id__": 78 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 24.232, + "y": -23.164, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_mobility": 0, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "Label", + "_objFlags": 0, + "__editorExtras__": {}, + "_parent": { + "__id__": 67 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 69 + }, + { + "__id__": 71 + } + ], + "_prefab": { + "__id__": 73 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": -36.502, + "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 + }, + "_mobility": 0, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 68 + }, + "_enabled": true, + "__prefab": { + "__id__": 70 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 73.16259765625, + "height": 54.4 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "15vRoNKoFI8ZgHSR/cXscW" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 68 + }, + "_enabled": true, + "__prefab": { + "__id__": 72 + }, + "_customMaterial": null, + "_srcBlendFactor": 2, + "_dstBlendFactor": 4, + "_color": { + "__type__": "cc.Color", + "r": 160, + "g": 140, + "b": 223, + "a": 255 + }, + "_string": "每日限购 :", + "_horizontalAlign": 1, + "_verticalAlign": 1, + "_actualFontSize": 15, + "_fontSize": 15, + "_fontFamily": "Arial", + "_lineHeight": 40, + "_overflow": 0, + "_enableWrapText": true, + "_font": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_isItalic": false, + "_isBold": true, + "_isUnderline": false, + "_underlineHeight": 2, + "_cacheMode": 0, + "_enableOutline": true, + "_outlineColor": { + "__type__": "cc.Color", + "r": 76, + "g": 63, + "b": 112, + "a": 255 + }, + "_outlineWidth": 2, + "_enableShadow": false, + "_shadowColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_shadowOffset": { + "__type__": "cc.Vec2", + "x": 2, + "y": 2 + }, + "_shadowBlur": 2, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "05blh1TeFOZKAt8JdYIvxk" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "00iZJjs0tK+56OO8F/16UT", + "nestedPrefabInstanceRoots": null + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 67 + }, + "_enabled": true, + "__prefab": { + "__id__": 75 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 29.02685546875, + "height": 54.4 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0.5 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "ccWWnsQN9LgKaWmKwq8Y3K" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 67 + }, + "_enabled": true, + "__prefab": { + "__id__": 77 + }, + "_customMaterial": null, + "_srcBlendFactor": 2, + "_dstBlendFactor": 4, + "_color": { + "__type__": "cc.Color", + "r": 160, + "g": 140, + "b": 223, + "a": 255 + }, + "_string": "333", + "_horizontalAlign": 0, + "_verticalAlign": 1, + "_actualFontSize": 15, + "_fontSize": 15, + "_fontFamily": "Arial", + "_lineHeight": 40, + "_overflow": 0, + "_enableWrapText": true, + "_font": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_isItalic": false, + "_isBold": true, + "_isUnderline": false, + "_underlineHeight": 2, + "_cacheMode": 0, + "_enableOutline": true, + "_outlineColor": { + "__type__": "cc.Color", + "r": 76, + "g": 63, + "b": 112, + "a": 255 + }, + "_outlineWidth": 2, + "_enableShadow": false, + "_shadowColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_shadowOffset": { + "__type__": "cc.Vec2", + "x": 2, + "y": 2 + }, + "_shadowBlur": 2, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "4fQE3v435M/J95MHOaJTXR" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "beypliiLtL77Bu5AtYAJys", + "instance": null, + "targetOverrides": null, + "nestedPrefabInstanceRoots": null + }, { "__type__": "cc.Node", "_name": "btn", @@ -1288,20 +1614,20 @@ "_active": true, "_components": [ { - "__id__": 68 + "__id__": 80 }, { - "__id__": 70 + "__id__": 82 }, { - "__id__": 72 + "__id__": 84 }, { - "__id__": 74 + "__id__": 86 } ], "_prefab": { - "__id__": 76 + "__id__": 89 }, "_lpos": { "__type__": "cc.Vec3", @@ -1338,11 +1664,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 67 + "__id__": 79 }, "_enabled": true, "__prefab": { - "__id__": 69 + "__id__": 81 }, "_contentSize": { "__type__": "cc.Size", @@ -1366,11 +1692,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 67 + "__id__": 79 }, "_enabled": true, "__prefab": { - "__id__": 71 + "__id__": 83 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -1411,11 +1737,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 67 + "__id__": 79 }, "_enabled": true, "__prefab": { - "__id__": 73 + "__id__": 85 }, "_alignFlags": 44, "_target": null, @@ -1442,40 +1768,74 @@ "fileId": "26vNKfqLlBjZ6gG1fIQx9S" }, { - "__type__": "cc.Widget", + "__type__": "cc.Button", "_name": "", "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 67 + "__id__": 79 }, "_enabled": true, "__prefab": { - "__id__": 75 + "__id__": 87 }, - "_alignFlags": 0, + "clickEvents": [ + { + "__id__": 88 + } + ], + "_interactable": true, + "_transition": 3, + "_normalColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_hoverColor": { + "__type__": "cc.Color", + "r": 211, + "g": 211, + "b": 211, + "a": 255 + }, + "_pressedColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_disabledColor": { + "__type__": "cc.Color", + "r": 124, + "g": 124, + "b": 124, + "a": 255 + }, + "_normalSprite": null, + "_hoverSprite": null, + "_pressedSprite": null, + "_disabledSprite": null, + "_duration": 0.1, + "_zoomScale": 0.7, "_target": null, - "_left": 0, - "_right": 0, - "_top": 0, - "_bottom": 0, - "_horizontalCenter": 0, - "_verticalCenter": 0, - "_isAbsLeft": true, - "_isAbsRight": true, - "_isAbsTop": true, - "_isAbsBottom": true, - "_isAbsHorizontalCenter": true, - "_isAbsVerticalCenter": true, - "_originalWidth": 0, - "_originalHeight": 0, - "_alignMode": 2, - "_lockFlags": 0, "_id": "" }, { "__type__": "cc.CompPrefabInfo", - "fileId": "33Fvuhi3tJGZaMetm+LTCZ" + "fileId": "bb9bZB3JpJ06TZXFWaT8yl" + }, + { + "__type__": "cc.ClickEvent", + "target": { + "__id__": 1 + }, + "component": "", + "_componentId": "e2416fOedBPmaPY8US76Vmj", + "handler": "to_buy", + "customEventData": "" }, { "__type__": "cc.PrefabInfo", @@ -1500,29 +1860,26 @@ }, "_children": [ { - "__id__": 78 + "__id__": 91 }, { - "__id__": 84 - }, - { - "__id__": 90 + "__id__": 97 } ], - "_active": false, + "_active": true, "_components": [ { - "__id__": 102 + "__id__": 103 }, { - "__id__": 104 + "__id__": 105 }, { - "__id__": 106 + "__id__": 107 } ], "_prefab": { - "__id__": 108 + "__id__": 109 }, "_lpos": { "__type__": "cc.Vec3", @@ -1559,25 +1916,25 @@ "_objFlags": 0, "__editorExtras__": {}, "_parent": { - "__id__": 77 + "__id__": 90 }, "_children": [], "_active": true, "_components": [ { - "__id__": 79 + "__id__": 92 }, { - "__id__": 81 + "__id__": 94 } ], "_prefab": { - "__id__": 83 + "__id__": 96 }, "_lpos": { "__type__": "cc.Vec3", - "x": -24.462, - "y": 0, + "x": 41.754, + "y": 14.927, "z": 0 }, "_lrot": { @@ -1609,11 +1966,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 78 + "__id__": 91 }, "_enabled": true, "__prefab": { - "__id__": 80 + "__id__": 93 }, "_contentSize": { "__type__": "cc.Size", @@ -1637,11 +1994,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 78 + "__id__": 91 }, "_enabled": true, "__prefab": { - "__id__": 82 + "__id__": 95 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -1695,24 +2052,24 @@ "_objFlags": 0, "__editorExtras__": {}, "_parent": { - "__id__": 77 + "__id__": 90 }, "_children": [], "_active": true, "_components": [ { - "__id__": 85 + "__id__": 98 }, { - "__id__": 87 + "__id__": 100 } ], "_prefab": { - "__id__": 89 + "__id__": 102 }, "_lpos": { "__type__": "cc.Vec3", - "x": -1.933, + "x": 0, "y": 0, "z": 0 }, @@ -1745,15 +2102,15 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 84 + "__id__": 97 }, "_enabled": true, "__prefab": { - "__id__": 86 + "__id__": 99 }, "_contentSize": { "__type__": "cc.Size", - "width": 17.90380859375, + "width": 54, "height": 54.4 }, "_anchorPoint": { @@ -1773,11 +2130,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 84 + "__id__": 97 }, "_enabled": true, "__prefab": { - "__id__": 88 + "__id__": 101 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -1789,7 +2146,7 @@ "b": 255, "a": 255 }, - "_string": "3", + "_string": "获取", "_horizontalAlign": 0, "_verticalAlign": 1, "_actualFontSize": 25, @@ -1848,219 +2205,6 @@ "targetOverrides": null, "nestedPrefabInstanceRoots": null }, - { - "__type__": "cc.Node", - "_name": "max", - "_objFlags": 0, - "__editorExtras__": {}, - "_parent": { - "__id__": 77 - }, - "_children": [ - { - "__id__": 91 - } - ], - "_active": true, - "_components": [ - { - "__id__": 97 - }, - { - "__id__": 99 - } - ], - "_prefab": { - "__id__": 101 - }, - "_lpos": { - "__type__": "cc.Vec3", - "x": 28.896, - "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 - }, - "_mobility": 0, - "_layer": 1073741824, - "_euler": { - "__type__": "cc.Vec3", - "x": 0, - "y": 0, - "z": 0 - }, - "_id": "" - }, - { - "__type__": "cc.Node", - "_name": "Label", - "_objFlags": 0, - "__editorExtras__": {}, - "_parent": { - "__id__": 90 - }, - "_children": [], - "_active": true, - "_components": [ - { - "__id__": 92 - }, - { - "__id__": 94 - } - ], - "_prefab": { - "__id__": 96 - }, - "_lpos": { - "__type__": "cc.Vec3", - "x": -15, - "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 - }, - "_mobility": 0, - "_layer": 1073741824, - "_euler": { - "__type__": "cc.Vec3", - "x": 0, - "y": 0, - "z": 0 - }, - "_id": "" - }, - { - "__type__": "cc.UITransform", - "_name": "", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 91 - }, - "_enabled": true, - "__prefab": { - "__id__": 93 - }, - "_contentSize": { - "__type__": "cc.Size", - "width": 9.556640625, - "height": 54.4 - }, - "_anchorPoint": { - "__type__": "cc.Vec2", - "x": 0.5, - "y": 0.5 - }, - "_id": "" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "d0cIKGUz5NT7ZkBc/nv9vN" - }, - { - "__type__": "cc.Label", - "_name": "", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 91 - }, - "_enabled": true, - "__prefab": { - "__id__": 95 - }, - "_customMaterial": null, - "_srcBlendFactor": 2, - "_dstBlendFactor": 4, - "_color": { - "__type__": "cc.Color", - "r": 255, - "g": 255, - "b": 255, - "a": 255 - }, - "_string": "/", - "_horizontalAlign": 1, - "_verticalAlign": 1, - "_actualFontSize": 20, - "_fontSize": 20, - "_fontFamily": "Arial", - "_lineHeight": 40, - "_overflow": 0, - "_enableWrapText": true, - "_font": null, - "_isSystemFontUsed": true, - "_spacingX": 0, - "_isItalic": false, - "_isBold": true, - "_isUnderline": false, - "_underlineHeight": 2, - "_cacheMode": 0, - "_enableOutline": true, - "_outlineColor": { - "__type__": "cc.Color", - "r": 0, - "g": 0, - "b": 0, - "a": 255 - }, - "_outlineWidth": 2, - "_enableShadow": false, - "_shadowColor": { - "__type__": "cc.Color", - "r": 0, - "g": 0, - "b": 0, - "a": 255 - }, - "_shadowOffset": { - "__type__": "cc.Vec2", - "x": 2, - "y": 2 - }, - "_shadowBlur": 2, - "_id": "" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "4c3FDgOfpJuLlqXLh0OnVx" - }, - { - "__type__": "cc.PrefabInfo", - "root": { - "__id__": 1 - }, - "asset": { - "__id__": 0 - }, - "fileId": "5e4Nngp/ZBB5KrlyWcU6nQ", - "instance": null, - "targetOverrides": null, - "nestedPrefabInstanceRoots": null - }, { "__type__": "cc.UITransform", "_name": "", @@ -2071,120 +2215,11 @@ }, "_enabled": true, "__prefab": { - "__id__": 98 + "__id__": 104 }, "_contentSize": { "__type__": "cc.Size", - "width": 17.90380859375, - "height": 54.4 - }, - "_anchorPoint": { - "__type__": "cc.Vec2", - "x": 0.5, - "y": 0.5 - }, - "_id": "" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "ccWWnsQN9LgKaWmKwq8Y3K" - }, - { - "__type__": "cc.Label", - "_name": "", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 90 - }, - "_enabled": true, - "__prefab": { - "__id__": 100 - }, - "_customMaterial": null, - "_srcBlendFactor": 2, - "_dstBlendFactor": 4, - "_color": { - "__type__": "cc.Color", - "r": 255, - "g": 255, - "b": 255, - "a": 255 - }, - "_string": "3", - "_horizontalAlign": 0, - "_verticalAlign": 1, - "_actualFontSize": 25, - "_fontSize": 25, - "_fontFamily": "Arial", - "_lineHeight": 40, - "_overflow": 0, - "_enableWrapText": true, - "_font": null, - "_isSystemFontUsed": true, - "_spacingX": 0, - "_isItalic": false, - "_isBold": false, - "_isUnderline": false, - "_underlineHeight": 2, - "_cacheMode": 0, - "_enableOutline": true, - "_outlineColor": { - "__type__": "cc.Color", - "r": 0, - "g": 0, - "b": 0, - "a": 255 - }, - "_outlineWidth": 2, - "_enableShadow": false, - "_shadowColor": { - "__type__": "cc.Color", - "r": 0, - "g": 0, - "b": 0, - "a": 255 - }, - "_shadowOffset": { - "__type__": "cc.Vec2", - "x": 2, - "y": 2 - }, - "_shadowBlur": 2, - "_id": "" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "4fQE3v435M/J95MHOaJTXR" - }, - { - "__type__": "cc.PrefabInfo", - "root": { - "__id__": 1 - }, - "asset": { - "__id__": 0 - }, - "fileId": "beypliiLtL77Bu5AtYAJys", - "instance": null, - "targetOverrides": null, - "nestedPrefabInstanceRoots": null - }, - { - "__type__": "cc.UITransform", - "_name": "", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 77 - }, - "_enabled": true, - "__prefab": { - "__id__": 103 - }, - "_contentSize": { - "__type__": "cc.Size", - "width": 94.2076171875, + "width": 84.6, "height": 50 }, "_anchorPoint": { @@ -2204,11 +2239,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 77 + "__id__": 90 }, "_enabled": false, "__prefab": { - "__id__": 105 + "__id__": 106 }, "_resizeMode": 1, "_layoutType": 1, @@ -2242,11 +2277,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 77 + "__id__": 90 }, "_enabled": true, "__prefab": { - "__id__": 107 + "__id__": 108 }, "_alignFlags": 4, "_target": null, @@ -2281,8 +2316,6 @@ "__id__": 0 }, "fileId": "c5191IztlAOYvsl7+Bfvx9", - "instance": null, - "targetOverrides": null, "nestedPrefabInstanceRoots": null }, { @@ -2295,23 +2328,23 @@ }, "_children": [ { - "__id__": 110 + "__id__": 111 } ], - "_active": true, + "_active": false, "_components": [ { - "__id__": 116 + "__id__": 117 }, { - "__id__": 118 + "__id__": 119 }, { - "__id__": 120 + "__id__": 121 } ], "_prefab": { - "__id__": 122 + "__id__": 123 }, "_lpos": { "__type__": "cc.Vec3", @@ -2348,20 +2381,20 @@ "_objFlags": 0, "__editorExtras__": {}, "_parent": { - "__id__": 109 + "__id__": 110 }, "_children": [], "_active": true, "_components": [ { - "__id__": 111 + "__id__": 112 }, { - "__id__": 113 + "__id__": 114 } ], "_prefab": { - "__id__": 115 + "__id__": 116 }, "_lpos": { "__type__": "cc.Vec3", @@ -2398,11 +2431,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 110 + "__id__": 111 }, "_enabled": true, "__prefab": { - "__id__": 112 + "__id__": 113 }, "_contentSize": { "__type__": "cc.Size", @@ -2426,11 +2459,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 110 + "__id__": 111 }, "_enabled": true, "__prefab": { - "__id__": 114 + "__id__": 115 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -2507,11 +2540,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 109 + "__id__": 110 }, "_enabled": true, "__prefab": { - "__id__": 117 + "__id__": 118 }, "_contentSize": { "__type__": "cc.Size", @@ -2535,11 +2568,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 109 + "__id__": 110 }, "_enabled": true, "__prefab": { - "__id__": 119 + "__id__": 120 }, "_resizeMode": 1, "_layoutType": 1, @@ -2573,11 +2606,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 109 + "__id__": 110 }, "_enabled": true, "__prefab": { - "__id__": 121 + "__id__": 122 }, "_alignFlags": 4, "_target": null, @@ -2626,29 +2659,29 @@ }, "_children": [ { - "__id__": 124 + "__id__": 125 }, { - "__id__": 130 + "__id__": 131 }, { - "__id__": 136 + "__id__": 137 } ], "_active": false, "_components": [ { - "__id__": 148 + "__id__": 149 }, { - "__id__": 150 + "__id__": 151 }, { - "__id__": 152 + "__id__": 153 } ], "_prefab": { - "__id__": 154 + "__id__": 155 }, "_lpos": { "__type__": "cc.Vec3", @@ -2685,20 +2718,20 @@ "_objFlags": 0, "__editorExtras__": {}, "_parent": { - "__id__": 123 + "__id__": 124 }, "_children": [], "_active": false, "_components": [ { - "__id__": 125 + "__id__": 126 }, { - "__id__": 127 + "__id__": 128 } ], "_prefab": { - "__id__": 129 + "__id__": 130 }, "_lpos": { "__type__": "cc.Vec3", @@ -2735,11 +2768,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 124 + "__id__": 125 }, "_enabled": true, "__prefab": { - "__id__": 126 + "__id__": 127 }, "_contentSize": { "__type__": "cc.Size", @@ -2763,11 +2796,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 124 + "__id__": 125 }, "_enabled": true, "__prefab": { - "__id__": 128 + "__id__": 129 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -2821,20 +2854,20 @@ "_objFlags": 0, "__editorExtras__": {}, "_parent": { - "__id__": 123 + "__id__": 124 }, "_children": [], "_active": false, "_components": [ { - "__id__": 131 + "__id__": 132 }, { - "__id__": 133 + "__id__": 134 } ], "_prefab": { - "__id__": 135 + "__id__": 136 }, "_lpos": { "__type__": "cc.Vec3", @@ -2871,11 +2904,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 130 + "__id__": 131 }, "_enabled": true, "__prefab": { - "__id__": 132 + "__id__": 133 }, "_contentSize": { "__type__": "cc.Size", @@ -2899,11 +2932,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 130 + "__id__": 131 }, "_enabled": true, "__prefab": { - "__id__": 134 + "__id__": 135 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -2957,24 +2990,24 @@ "_objFlags": 0, "__editorExtras__": {}, "_parent": { - "__id__": 123 + "__id__": 124 }, "_children": [ { - "__id__": 137 + "__id__": 138 } ], "_active": true, "_components": [ { - "__id__": 143 + "__id__": 144 }, { - "__id__": 145 + "__id__": 146 } ], "_prefab": { - "__id__": 147 + "__id__": 148 }, "_lpos": { "__type__": "cc.Vec3", @@ -3011,20 +3044,20 @@ "_objFlags": 0, "__editorExtras__": {}, "_parent": { - "__id__": 136 + "__id__": 137 }, "_children": [], "_active": true, "_components": [ { - "__id__": 138 + "__id__": 139 }, { - "__id__": 140 + "__id__": 141 } ], "_prefab": { - "__id__": 142 + "__id__": 143 }, "_lpos": { "__type__": "cc.Vec3", @@ -3061,11 +3094,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 137 + "__id__": 138 }, "_enabled": true, "__prefab": { - "__id__": 139 + "__id__": 140 }, "_contentSize": { "__type__": "cc.Size", @@ -3089,11 +3122,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 137 + "__id__": 138 }, "_enabled": true, "__prefab": { - "__id__": 141 + "__id__": 142 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -3170,11 +3203,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 136 + "__id__": 137 }, "_enabled": true, "__prefab": { - "__id__": 144 + "__id__": 145 }, "_contentSize": { "__type__": "cc.Size", @@ -3198,11 +3231,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 136 + "__id__": 137 }, "_enabled": true, "__prefab": { - "__id__": 146 + "__id__": 147 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -3279,11 +3312,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 123 + "__id__": 124 }, "_enabled": true, "__prefab": { - "__id__": 149 + "__id__": 150 }, "_contentSize": { "__type__": "cc.Size", @@ -3307,11 +3340,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 123 + "__id__": 124 }, "_enabled": true, "__prefab": { - "__id__": 151 + "__id__": 152 }, "_resizeMode": 1, "_layoutType": 1, @@ -3345,11 +3378,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 123 + "__id__": 124 }, "_enabled": true, "__prefab": { - "__id__": 153 + "__id__": 154 }, "_alignFlags": 4, "_target": null, @@ -3388,6 +3421,337 @@ "targetOverrides": null, "nestedPrefabInstanceRoots": null }, + { + "__type__": "cc.Node", + "_name": "nothing", + "_objFlags": 0, + "__editorExtras__": {}, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 157 + } + ], + "_active": false, + "_components": [ + { + "__id__": 163 + }, + { + "__id__": 165 + }, + { + "__id__": 167 + } + ], + "_prefab": { + "__id__": 169 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": -57.099999999999994, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_mobility": 0, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "num", + "_objFlags": 0, + "__editorExtras__": {}, + "_parent": { + "__id__": 156 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 158 + }, + { + "__id__": 160 + } + ], + "_prefab": { + "__id__": 162 + }, + "_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 + }, + "_mobility": 0, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 157 + }, + "_enabled": true, + "__prefab": { + "__id__": 159 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 79, + "height": 54.4 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "166+icVs5OLLE/rSds3IQX" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 157 + }, + "_enabled": true, + "__prefab": { + "__id__": 161 + }, + "_customMaterial": null, + "_srcBlendFactor": 2, + "_dstBlendFactor": 4, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_string": "已售罄", + "_horizontalAlign": 0, + "_verticalAlign": 1, + "_actualFontSize": 25, + "_fontSize": 25, + "_fontFamily": "Arial", + "_lineHeight": 40, + "_overflow": 0, + "_enableWrapText": true, + "_font": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_isItalic": false, + "_isBold": false, + "_isUnderline": false, + "_underlineHeight": 2, + "_cacheMode": 0, + "_enableOutline": true, + "_outlineColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_outlineWidth": 2, + "_enableShadow": false, + "_shadowColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_shadowOffset": { + "__type__": "cc.Vec2", + "x": 2, + "y": 2 + }, + "_shadowBlur": 2, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "7bWqrfzcJIXLK91IS8Da7E" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "a1cW4p9kJBTLfwzmpxf8Wm", + "instance": null, + "targetOverrides": null, + "nestedPrefabInstanceRoots": null + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 156 + }, + "_enabled": true, + "__prefab": { + "__id__": 164 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 79, + "height": 50 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "ac9Jyl6zFAz4hrFsnTVgRM" + }, + { + "__type__": "cc.Layout", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 156 + }, + "_enabled": true, + "__prefab": { + "__id__": 166 + }, + "_resizeMode": 1, + "_layoutType": 1, + "_cellSize": { + "__type__": "cc.Size", + "width": 40, + "height": 40 + }, + "_startAxis": 0, + "_paddingLeft": 0, + "_paddingRight": 0, + "_paddingTop": 0, + "_paddingBottom": 0, + "_spacingX": -1, + "_spacingY": 0, + "_verticalDirection": 1, + "_horizontalDirection": 0, + "_constraint": 0, + "_constraintNum": 2, + "_affectedByScale": true, + "_isAlign": true, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "41MApRGrxG6Z0ZAIfqve7r" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 156 + }, + "_enabled": true, + "__prefab": { + "__id__": 168 + }, + "_alignFlags": 4, + "_target": null, + "_left": 0, + "_right": 0, + "_top": 0, + "_bottom": 17.9, + "_horizontalCenter": 0, + "_verticalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 0, + "_originalHeight": 0, + "_alignMode": 2, + "_lockFlags": 0, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "6bMzWb0uBD9pIaefvIn0K9" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "82OGYIyJ5MObBdDqryOhCq", + "instance": null, + "targetOverrides": null, + "nestedPrefabInstanceRoots": null + }, { "__type__": "cc.UITransform", "_name": "", @@ -3398,7 +3762,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 156 + "__id__": 171 }, "_contentSize": { "__type__": "cc.Size", @@ -3426,7 +3790,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 158 + "__id__": 173 }, "_alignFlags": 2, "_target": null, @@ -3462,7 +3826,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 160 + "__id__": 175 }, "_id": "" }, diff --git a/assets/script/game/common/SingletonModuleComp.ts b/assets/script/game/common/SingletonModuleComp.ts index 13ae322b..24d6d43a 100644 --- a/assets/script/game/common/SingletonModuleComp.ts +++ b/assets/script/game/common/SingletonModuleComp.ts @@ -37,6 +37,13 @@ export class SingletonModuleComp extends ecs.Comp { meat:0, exp:0, } + shop:any={ + daily_goods:[], + weekly_goods:[], + monthly_goods:[], + special_goods:[], + goods_count:[1,3,1,3], + } fight_heros:any={ 0:5001, 1:5005, 2:0, 3:0, 4:0, } heros:any = { 5001:{uuid:5001,lv:1}, diff --git a/assets/script/game/map/GoodsComp.ts b/assets/script/game/map/GoodsComp.ts index 4d7e58c5..6dd3d89c 100644 --- a/assets/script/game/map/GoodsComp.ts +++ b/assets/script/game/map/GoodsComp.ts @@ -2,6 +2,8 @@ import { _decorator, Component, Node, Label, Sprite, SpriteFrame, resources } fr import { Goods, GType, CType } from '../common/config/Goods'; import { Items } from '../common/config/Items'; import { NumberFormatter } from '../common/config/BoxSet'; +import { smc } from '../common/SingletonModuleComp'; +import { oops } from 'db://oops-framework/core/Oops'; const { ccclass, property } = _decorator; @ccclass('GoodsComp') @@ -10,12 +12,14 @@ export class GoodsComp extends Component { private goodsData: any = null; private itemData: any = null; private currentUuid: number = 0; + goods_count_key:number=-1 /** * 更新物品数据 * @param uuid 物品UUID */ - update_data(uuid: number) { + update_data(uuid: number,key:number) { + this.goods_count_key=key this.currentUuid = uuid; this.goodsData = Goods[uuid]; @@ -32,19 +36,34 @@ export class GoodsComp extends Component { this.updateIcon(); this.updateTexts(); - this.update_btn(this.goodsData.c_type) + this.update_btn() + this.update_max_num() } - update_btn(type:CType){ - this.node.getChildByName("ad").active=type==CType.AD - this.node.getChildByName("free").active=type==CType.FREE - this.node.getChildByName("cast").active=type==(CType.DIAMOND||CType.GOLD) - this.node.getChildByName("cast").getChildByName("diamond").active=type==CType.DIAMOND - this.node.getChildByName("cast").getChildByName("gold").active=type==CType.GOLD + private update_btn( ){ + if(smc.shop.goods_count[this.goods_count_key]<=0){ + this.node.getChildByName("ad").active=false + this.node.getChildByName("free").active=false + this.node.getChildByName("cast").active=false + this.node.getChildByName("nothing").active=true + this.node.getChildByName("btn").getComponent(Sprite).grayscale=true + return + } + this.node.getChildByName("nothing").active=false + this.node.getChildByName("btn").getComponent(Sprite).grayscale=false + this.node.getChildByName("ad").active=this.goodsData.c_type==CType.AD + this.node.getChildByName("free").active=this.goodsData.c_type==CType.FREE + this.node.getChildByName("cast").active=this.goodsData.c_type==(CType.DIAMOND||CType.GOLD) + this.node.getChildByName("cast").getChildByName("diamond").active=this.goodsData.c_type==CType.DIAMOND + this.node.getChildByName("cast").getChildByName("gold").active=this.goodsData.c_type==CType.GOLD this.node.getChildByName("cast").getChildByName("num").getComponent(Label).string=NumberFormatter.formatNumber(this.goodsData.cast) } /** * 更新图标 */ + private update_max_num(){ + this.node.getChildByName("max").getComponent(Label).string=NumberFormatter.formatNumber(smc.shop.goods_count[this.goods_count_key]) + + } private updateIcon() { const iconSprite = this.node.getChildByName("icon")?.getComponent(Sprite); if (!iconSprite) return; @@ -67,6 +86,72 @@ export class GoodsComp extends Component { const mainNumLabel = this.node.getChildByName("num")?.getComponent(Label); if (mainNumLabel) mainNumLabel.string = NumberFormatter.formatNumber(this.goodsData.num); } + to_buy(){ + if(smc.shop.goods_count[this.goods_count_key]<=0){ + oops.gui.toast("商品已售罄") + return + } + if(this.goodsData.c_type==CType.AD){ + this.do_ad() + }else if(this.goodsData.c_type==CType.FREE){ + this.do_free() + }else if(this.goodsData.c_type==CType.DIAMOND){ + this.do_diamond_cast() + }else if(this.goodsData.c_type==CType.GOLD){ + this.do_gold_cast() + } + } + do_buy(){ + console.log("[GoodsComp]do_buy",this.goodsData,this.itemData) + switch(this.goodsData.type){ + case GType.ITEM: + smc.addItem(this.itemData.uuid,this.goodsData.num) //添加物品 + break + case GType.GOLD: + smc.addGold(this.goodsData.num) //添加金币 + break + case GType.DIAMOND: + smc.addDiamond(this.goodsData.num) //添加钻石 + break + case GType.MEAT: //添加肉 + break + case GType.EXP: //添加经验 + smc.addExp(this.goodsData.num) + break + } + smc.shop.goods_count[this.goods_count_key]-- + this.update_btn() + this.update_max_num() + } + + do_ad(){ + if(this.goodsData.c_type==CType.AD){ + this.do_ad_back(this.do_buy,this.ad_back_false) + } + } + ad_back_false(){ + console.log("ad_back_false") + } + do_ad_back(success:Function,fail:Function){ + success.call(this) + } + do_free(){ + if(this.goodsData.c_type==CType.FREE){ + this.do_buy() + } + } + do_diamond_cast(){ + if(this.goodsData.c_type==CType.DIAMOND){ + smc.spendDiamond(this.goodsData.cast) + this.do_buy() + } + } + do_gold_cast(){ + if(this.goodsData.c_type==CType.GOLD){ + smc.spendGold(this.goodsData.cast) + this.do_buy() + } + } } diff --git a/assets/script/game/map/ShopPageComp.ts b/assets/script/game/map/ShopPageComp.ts index e46f39ba..ed409930 100644 --- a/assets/script/game/map/ShopPageComp.ts +++ b/assets/script/game/map/ShopPageComp.ts @@ -15,7 +15,7 @@ export class ShopPageComp extends Component { let items=this.node.getChildByName("daily").getChildByName("items").children for(let i=0;i