优化格子锁

master
humingxing 3 days ago
parent bf1df7fa49
commit 6deec5af98
  1. 537
      assets/bundles/battleGame/prefab/格子锁.prefab
  2. 107
      assets/script/battle/map/legacy/MapAreaUnlock.ts
  3. 3
      docs/方案-局内Battlebuff三选一.md

@ -26,22 +26,19 @@
}, },
{ {
"__id__": 14 "__id__": 14
},
{
"__id__": 32
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 20 "__id__": 38
},
{
"__id__": 22
},
{
"__id__": 24
} }
], ],
"_prefab": { "_prefab": {
"__id__": 26 "__id__": 40
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@ -74,7 +71,7 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "锁定", "_name": "bg",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"_parent": { "_parent": {
@ -95,7 +92,7 @@
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": -45.1845703125, "x": 0,
"y": 0, "y": 0,
"z": 0 "z": 0
}, },
@ -108,8 +105,8 @@
}, },
"_lscale": { "_lscale": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 1, "x": 1.2,
"y": 1, "y": 1.2,
"z": 1 "z": 1
}, },
"_mobility": 0, "_mobility": 0,
@ -136,8 +133,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 42, "width": 96,
"height": 45 "height": 68
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
@ -148,7 +145,7 @@
}, },
{ {
"__type__": "cc.CompPrefabInfo", "__type__": "cc.CompPrefabInfo",
"fileId": "52BfiQtHBLk5IrGlqyFIeP" "fileId": "eeGzSh9ttB14faENR7nkL1"
}, },
{ {
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
@ -173,7 +170,7 @@
"a": 255 "a": 255
}, },
"_spriteFrame": { "_spriteFrame": {
"__uuid__": "201e9a69-4d94-4182-b893-c972f15ee76e@f9941", "__uuid__": "0b9461e4-38ea-4e13-b133-f28d07bc5178@f9941",
"__expectedType__": "cc.SpriteFrame" "__expectedType__": "cc.SpriteFrame"
}, },
"_type": 0, "_type": 0,
@ -193,7 +190,7 @@
}, },
{ {
"__type__": "cc.CompPrefabInfo", "__type__": "cc.CompPrefabInfo",
"fileId": "50cCFcSOJGPbVuqJkpsr7c" "fileId": "85jSymFOxH47oesupv6Cs1"
}, },
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
@ -203,14 +200,14 @@
"asset": { "asset": {
"__id__": 0 "__id__": 0
}, },
"fileId": "39f4GsgNtNsq8/wCLq3tPA", "fileId": "9fCGAPLiROlKwMBu5E73hC",
"instance": null, "instance": null,
"targetOverrides": null, "targetOverrides": null,
"nestedPrefabInstanceRoots": null "nestedPrefabInstanceRoots": null
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "num", "_name": "box",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"_parent": { "_parent": {
@ -231,8 +228,8 @@
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": -5.5, "x": 0,
"y": 0, "y": 8,
"z": 0 "z": 0
}, },
"_lrot": { "_lrot": {
@ -272,8 +269,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 37.369140625, "width": 48,
"height": 54.4 "height": 39
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
@ -284,10 +281,10 @@
}, },
{ {
"__type__": "cc.CompPrefabInfo", "__type__": "cc.CompPrefabInfo",
"fileId": "a7rWzpiMxPDrFoMqw0xD9h" "fileId": "3c7wrtDV1CJ6wben99cdUf"
}, },
{ {
"__type__": "cc.Label", "__type__": "cc.Sprite",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
@ -308,51 +305,28 @@
"b": 255, "b": 255,
"a": 255 "a": 255
}, },
"_string": "32", "_spriteFrame": {
"_horizontalAlign": 1, "__uuid__": "c284dbf4-a1a8-413d-8d01-7f5fdfaa15dd@f9941",
"_verticalAlign": 1, "__expectedType__": "cc.SpriteFrame"
"_actualFontSize": 30,
"_fontSize": 30,
"_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": 213,
"g": 123,
"b": 85,
"a": 255
},
"_outlineWidth": 2,
"_enableShadow": false,
"_shadowColor": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
}, },
"_shadowOffset": { "_type": 0,
"_fillType": 0,
"_sizeMode": 1,
"_fillCenter": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
"x": 2, "x": 0,
"y": 2 "y": 0
}, },
"_shadowBlur": 2, "_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": "" "_id": ""
}, },
{ {
"__type__": "cc.CompPrefabInfo", "__type__": "cc.CompPrefabInfo",
"fileId": "b8MyhW1LFDR7LJQVwPdPvM" "fileId": "0bX4WRHEZG/ruUMZuQIumt"
}, },
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
@ -362,35 +336,92 @@
"asset": { "asset": {
"__id__": 0 "__id__": 0
}, },
"fileId": "a0kjvwE+JJI7QzpIQAs4CB", "fileId": "1elxSYwQBKopyaVp9y4v2w",
"instance": null, "instance": null,
"targetOverrides": null, "targetOverrides": null,
"nestedPrefabInstanceRoots": null "nestedPrefabInstanceRoots": null
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "box", "_name": "lock",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"_parent": { "_parent": {
"__id__": 1 "__id__": 1
}, },
"_children": [
{
"__id__": 15
},
{
"__id__": 21
}
],
"_active": true,
"_components": [
{
"__id__": 27
},
{
"__id__": 29
}
],
"_prefab": {
"__id__": 31
},
"_lpos": {
"__type__": "cc.Vec3",
"x": -4.059,
"y": -15,
"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": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "锁定",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 14
},
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 15 "__id__": 16
}, },
{ {
"__id__": 17 "__id__": 18
} }
], ],
"_prefab": { "_prefab": {
"__id__": 19 "__id__": 20
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 37.1845703125, "x": -30.369140625,
"y": 0, "y": 0,
"z": 0 "z": 0
}, },
@ -423,16 +454,16 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 14 "__id__": 15
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 16 "__id__": 17
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 48, "width": 42,
"height": 39 "height": 45
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
@ -443,7 +474,7 @@
}, },
{ {
"__type__": "cc.CompPrefabInfo", "__type__": "cc.CompPrefabInfo",
"fileId": "3c7wrtDV1CJ6wben99cdUf" "fileId": "52BfiQtHBLk5IrGlqyFIeP"
}, },
{ {
"__type__": "cc.Sprite", "__type__": "cc.Sprite",
@ -451,11 +482,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 14 "__id__": 15
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 18 "__id__": 19
}, },
"_customMaterial": null, "_customMaterial": null,
"_srcBlendFactor": 2, "_srcBlendFactor": 2,
@ -468,7 +499,7 @@
"a": 255 "a": 255
}, },
"_spriteFrame": { "_spriteFrame": {
"__uuid__": "c284dbf4-a1a8-413d-8d01-7f5fdfaa15dd@f9941", "__uuid__": "201e9a69-4d94-4182-b893-c972f15ee76e@f9941",
"__expectedType__": "cc.SpriteFrame" "__expectedType__": "cc.SpriteFrame"
}, },
"_type": 0, "_type": 0,
@ -488,7 +519,7 @@
}, },
{ {
"__type__": "cc.CompPrefabInfo", "__type__": "cc.CompPrefabInfo",
"fileId": "0bX4WRHEZG/ruUMZuQIumt" "fileId": "50cCFcSOJGPbVuqJkpsr7c"
}, },
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
@ -498,50 +529,100 @@
"asset": { "asset": {
"__id__": 0 "__id__": 0
}, },
"fileId": "1elxSYwQBKopyaVp9y4v2w", "fileId": "39f4GsgNtNsq8/wCLq3tPA",
"instance": null, "instance": null,
"targetOverrides": null, "targetOverrides": null,
"nestedPrefabInstanceRoots": null "nestedPrefabInstanceRoots": null
}, },
{
"__type__": "cc.Node",
"_name": "num",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 14
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 22
},
{
"__id__": 24
}
],
"_prefab": {
"__id__": 26
},
"_lpos": {
"__type__": "cc.Vec3",
"x": -19.369140625,
"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": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{ {
"__type__": "cc.UITransform", "__type__": "cc.UITransform",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 1 "__id__": 21
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 21 "__id__": 23
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 142.369140625, "width": 70.73828125,
"height": 68 "height": 54.4
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
"x": 0.5, "x": 0,
"y": 0.5 "y": 0.5
}, },
"_id": "" "_id": ""
}, },
{ {
"__type__": "cc.CompPrefabInfo", "__type__": "cc.CompPrefabInfo",
"fileId": "85sTDvKSNMXZkiAHpfcCpx" "fileId": "a7rWzpiMxPDrFoMqw0xD9h"
}, },
{ {
"__type__": "cc.Sprite", "__type__": "cc.Label",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 1 "__id__": 21
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 23 "__id__": 25
}, },
"_customMaterial": null, "_customMaterial": null,
"_srcBlendFactor": 2, "_srcBlendFactor": 2,
@ -553,28 +634,92 @@
"b": 255, "b": 255,
"a": 255 "a": 255
}, },
"_spriteFrame": { "_string": "4096",
"__uuid__": "0b9461e4-38ea-4e13-b133-f28d07bc5178@f9941", "_horizontalAlign": 1,
"__expectedType__": "cc.SpriteFrame" "_verticalAlign": 1,
"_actualFontSize": 30,
"_fontSize": 30,
"_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": 213,
"g": 123,
"b": 85,
"a": 255
}, },
"_type": 0, "_outlineWidth": 2,
"_fillType": 0, "_enableShadow": false,
"_sizeMode": 0, "_shadowColor": {
"_fillCenter": { "__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_shadowOffset": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
"x": 0, "x": 2,
"y": 0 "y": 2
}, },
"_fillStart": 0, "_shadowBlur": 2,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": "" "_id": ""
}, },
{ {
"__type__": "cc.CompPrefabInfo", "__type__": "cc.CompPrefabInfo",
"fileId": "715KNuSXlNAabmEpf0YdgP" "fileId": "b8MyhW1LFDR7LJQVwPdPvM"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "a0kjvwE+JJI7QzpIQAs4CB",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 14
},
"_enabled": true,
"__prefab": {
"__id__": 28
},
"_contentSize": {
"__type__": "cc.Size",
"width": 102.73828125,
"height": 100
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "fcv7Wo3AxPX6YsufpIkmuU"
}, },
{ {
"__type__": "cc.Layout", "__type__": "cc.Layout",
@ -582,11 +727,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 1 "__id__": 14
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 25 "__id__": 30
}, },
"_resizeMode": 1, "_resizeMode": 1,
"_layoutType": 1, "_layoutType": 1,
@ -596,11 +741,11 @@
"height": 40 "height": 40
}, },
"_startAxis": 0, "_startAxis": 0,
"_paddingLeft": 5, "_paddingLeft": 0,
"_paddingRight": 10, "_paddingRight": 0,
"_paddingTop": 0, "_paddingTop": 0,
"_paddingBottom": 0, "_paddingBottom": 0,
"_spacingX": 0, "_spacingX": -10,
"_spacingY": 0, "_spacingY": 0,
"_verticalDirection": 1, "_verticalDirection": 1,
"_horizontalDirection": 0, "_horizontalDirection": 0,
@ -612,7 +757,181 @@
}, },
{ {
"__type__": "cc.CompPrefabInfo", "__type__": "cc.CompPrefabInfo",
"fileId": "70ZyhmoIhBg4ERUGYZrVVb" "fileId": "40ylG/THxAkIObTgh+/bGZ"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "00Rgp16ypAhIfVM0NEnr1t",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.Node",
"_name": "five",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 33
},
{
"__id__": 35
}
],
"_prefab": {
"__id__": 37
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 37.075,
"y": 24.626,
"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": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 32
},
"_enabled": true,
"__prefab": {
"__id__": 34
},
"_contentSize": {
"__type__": "cc.Size",
"width": 22,
"height": 23
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "f1QjlLcHlJ1K3GBOYmXjMN"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 32
},
"_enabled": true,
"__prefab": {
"__id__": 36
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_spriteFrame": null,
"_type": 0,
"_fillType": 0,
"_sizeMode": 1,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "bbtyOKny5KSrImNP+Zdigp"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "96svdA705I/bJwg2GxPH7W",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 39
},
"_contentSize": {
"__type__": "cc.Size",
"width": 96,
"height": 68
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "85sTDvKSNMXZkiAHpfcCpx"
}, },
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",

@ -1,4 +1,4 @@
import { Label, Layout, Node, Sprite, UITransform, Vec3, isValid } from 'cc'; import { Label, Node, UITransform, Vec3, isValid } from 'cc';
import { SpriteLoad } from 'db://assets/mx/components/SpriteLoad'; import { SpriteLoad } from 'db://assets/mx/components/SpriteLoad';
import { TableNames } from '../../../game/ConfigTableData'; import { TableNames } from '../../../game/ConfigTableData';
import { GBundle, GPath } from '../../../game/ConfigRes'; import { GBundle, GPath } from '../../../game/ConfigRes';
@ -9,14 +9,18 @@ import { MapGrid } from './MapGrid';
const LOCK_TIP_PATH = 'prefab/'; const LOCK_TIP_PATH = 'prefab/';
/** 解锁条件气泡预制体名 */ /** 解锁条件气泡预制体名 */
const LOCK_TIP_NAME = '格子锁'; const LOCK_TIP_NAME = '格子锁';
/** 预制体上显示数字的子节点名 */ /** 锁与数字容器 */
const LOCK_TIP_LOCK = 'lock';
/** 预制体上显示数字的子节点名(在 lock 下) */
const LOCK_TIP_NUM = 'num'; const LOCK_TIP_NUM = 'num';
/** 动态条件图标子节点名前缀 */
const LOCK_TIP_COND = 'cond_';
/** 三选一宝箱提示子节点 */ /** 三选一宝箱提示子节点 */
const LOCK_TIP_BOX = 'box'; const LOCK_TIP_BOX = 'box';
/** 条件图标占位尺寸(与 icons/img 五行图接近) */ /** 五行属性图标子节点 */
const COND_ICON_SIZE = 22; const LOCK_TIP_FIVE = 'five';
/** 无宝箱时 lock 的本地 Y */
const LOCK_Y_NO_BOX = 0;
/** 有宝箱时 lock 的本地 Y */
const LOCK_Y_WITH_BOX = -15;
/** 气泡世界坐标转本地时复用 */ /** 气泡世界坐标转本地时复用 */
const _tipWorld = new Vec3(); const _tipWorld = new Vec3();
/** 气泡本地坐标复用 */ /** 气泡本地坐标复用 */
@ -297,19 +301,18 @@ export class MapAreaUnlock {
this._tipCamps.push(0); this._tipCamps.push(0);
continue; continue;
} }
const numNode = tip.getChildByName(LOCK_TIP_NUM); const lock = tip.getChildByName(LOCK_TIP_LOCK);
const label = numNode?.getComponent(Label); const label = lock?.getChildByName(LOCK_TIP_NUM)?.getComponent(Label);
if (!label) { if (!label) {
console.warn('[MapAreaUnlock] 格子锁缺少 num Label'); console.warn('[MapAreaUnlock] 格子锁缺少 lock/num Label');
tip.active = false; tip.active = false;
this._tipCamps.push(0); this._tipCamps.push(0);
continue; continue;
} }
label.string = String(jobs[i].num); label.string = String(jobs[i].num);
this._syncCondIcons(tip, jobs[i].heroType); this._syncFiveIcon(tip, jobs[i].heroType);
const nextCount = this.completedCount(jobs[i].camp) + 1; const nextCount = this.completedCount(jobs[i].camp) + 1;
this._syncBoxVisible(tip, this._isSelectTriggerCount(nextCount)); this._syncBoxVisible(tip, this._isSelectTriggerCount(nextCount));
tip.getComponent(Layout)?.updateLayout();
this._placeTipCenter(tip, jobs[i].grids); this._placeTipCenter(tip, jobs[i].grids);
tip.active = true; tip.active = true;
this._tipCamps.push(jobs[i].camp); this._tipCamps.push(jobs[i].camp);
@ -321,7 +324,7 @@ export class MapAreaUnlock {
} }
/** /**
* 下次解锁是否触发三选一时显示 box。 * 下次解锁是否触发三选一时显示 box,并调整 lock 的 Y。
* @param tip 格子锁气泡 * @param tip 格子锁气泡
* @param show 是否显示 * @param show 是否显示
*/ */
@ -332,6 +335,13 @@ export class MapAreaUnlock {
return; return;
} }
box.active = show; box.active = show;
const lock = tip.getChildByName(LOCK_TIP_LOCK);
if (!lock) {
console.warn('[MapAreaUnlock] 格子锁缺少 lock');
return;
}
const pos = lock.position;
lock.setPosition(pos.x, show ? LOCK_Y_WITH_BOX : LOCK_Y_NO_BOX, pos.z);
} }
/** /**
@ -349,67 +359,31 @@ export class MapAreaUnlock {
} }
/** /**
* 同步解锁条件五行图标:类型 0 不加载;1–5 各挂一张对应图标(锁与数字之间)。 * 同步 five 五行图标:类型 0 隐藏;1–5 显示并加载对应图标。
* @param tip 格子锁气泡 * @param tip 格子锁气泡
* @param heroType 当前随机到的 Hero.herotype;0 为无属性限制 * @param heroType 当前随机到的 Hero.herotype;0 为无属性限制
*/ */
private _syncCondIcons(tip: Node, heroType: number): void { private _syncFiveIcon(tip: Node, heroType: number): void {
this._clearCondIcons(tip); const five = tip.getChildByName(LOCK_TIP_FIVE);
const names = this._condIconNames(heroType); if (!five) {
if (names.length <= 0) return; console.warn('[MapAreaUnlock] 格子锁缺少 five');
const numNode = tip.getChildByName(LOCK_TIP_NUM); return;
let insertAt = numNode ? numNode.getSiblingIndex() : tip.children.length;
for (let i = 0; i < names.length; i++) {
const icon = this._makeCondIcon(names[i]);
tip.insertChild(icon, insertAt);
insertAt++;
} }
}
/**
* 当前条件需要展示的五行图标名列表;无限制返回空。
* @param heroType Hero.herotype
*/
private _condIconNames(heroType: number): string[] {
const type = Math.floor(Number(heroType) || 0); const type = Math.floor(Number(heroType) || 0);
if (type <= 0) return []; if (type <= 0) {
five.active = false;
return;
}
const name = HERO_TYPE_ICON[type]; const name = HERO_TYPE_ICON[type];
if (!name) { if (!name) {
console.warn('[MapAreaUnlock] 未知解锁 herotype,无法加载条件图标', type); console.warn('[MapAreaUnlock] 未知解锁 herotype,无法加载属性图标', type);
return []; five.active = false;
} return;
return [name];
}
/**
* 创建单张条件图标节点(SpriteLoad 从 icons 包加载)。
* @param name 金/木/水/火/土
*/
private _makeCondIcon(name: string): Node {
const node = new Node(LOCK_TIP_COND + name);
node.layer = 33554432;
const ut = node.addComponent(UITransform);
ut.setContentSize(COND_ICON_SIZE, COND_ICON_SIZE);
const sp = node.addComponent(Sprite);
sp.sizeMode = Sprite.SizeMode.TRIMMED;
node.addComponent(SpriteLoad).setSprite(GPath.ElementAttr(name), GBundle.Items);
return node;
}
/**
* 清除气泡上动态挂的条件图标(池化复用前必须清干净)。
* @param tip 格子锁气泡
*/
private _clearCondIcons(tip: Node): void {
if (!tip?.isValid) return;
const children = tip.children;
for (let i = children.length - 1; i >= 0; i--) {
const child = children[i];
if (!child?.isValid) continue;
if (child.name.indexOf(LOCK_TIP_COND) !== 0) continue;
child.removeFromParent();
child.destroy();
} }
five.active = true;
let sl = five.getComponent(SpriteLoad);
if (!sl) sl = five.addComponent(SpriteLoad);
sl.setSprite(GPath.ElementAttr(name), GBundle.Items);
} }
/** /**
@ -529,7 +503,8 @@ export class MapAreaUnlock {
for (let i = 0; i < this._tips.length; i++) { for (let i = 0; i < this._tips.length; i++) {
const tip = this._tips[i]; const tip = this._tips[i];
if (!tip || !isValid(tip)) continue; if (!tip || !isValid(tip)) continue;
this._clearCondIcons(tip); const five = tip.getChildByName(LOCK_TIP_FIVE);
if (five?.isValid) five.active = false;
if (tip['resKey']) gg.res.putNode(tip); if (tip['resKey']) gg.res.putNode(tip);
else tip.destroy(); else tip.destroy();
} }

@ -12,7 +12,8 @@
| 玩家 | `UIID.PopSelect`(`pauseBattle`) | | 玩家 | `UIID.PopSelect`(`pauseBattle`) |
| AI | `BattleBuffSelectService.autoPickOne`(无 UI) | | AI | `BattleBuffSelectService.autoPickOne`(无 UI) |
| 携带 | `BattleBuffCarryStore`(开战 clear,不写跨天存档) | | 携带 | `BattleBuffCarryStore`(开战 clear,不写跨天存档) |
| box | 格子锁 tip 子节点 `box`:下一次解锁次数在 Const27 时显示 | | box | 格子锁 tip 子节点 `box`:下一次解锁次数在 Const27 时显示;有 box 时 `lock.y=-15`,否则 `0` |
| five | 格子锁 tip 子节点 `five`:解锁条件有五行时显示对应金木水火土图标,无则隐藏 |
## 2. 抽取 ## 2. 抽取

Loading…
Cancel
Save