master
humingxing 3 days ago
parent ab20e7e835
commit c6953865da
  1. 153
      assets/bundles/battleGame/prefab/宝箱.prefab
  2. 2
      assets/script/battle/config/BattleHeroTable.ts
  3. 56
      assets/script/battle/map/MapDigChestHost.ts
  4. 4
      assets/script/battle/view/TextGrid.ts
  5. 2
      assets/script/interface/AutoTable.ts
  6. 5
      assets/script/ui/BattleGame/BattleDigChestFxPresenter.ts
  7. 4
      assets/script/ui/BattleWeaponDescHero/UIBattleWeaponDescHero.ts

@ -20,19 +20,16 @@
"_children": [ "_children": [
{ {
"__id__": 2 "__id__": 2
},
{
"__id__": 8
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 14 "__id__": 8
} }
], ],
"_prefab": { "_prefab": {
"__id__": 16 "__id__": 10
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@ -65,7 +62,7 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "bg", "_name": "box",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"_parent": { "_parent": {
@ -87,7 +84,7 @@
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": 0, "y": -2.64,
"z": 0 "z": 0
}, },
"_lrot": { "_lrot": {
@ -125,142 +122,6 @@
"__prefab": { "__prefab": {
"__id__": 4 "__id__": 4
}, },
"_contentSize": {
"__type__": "cc.Size",
"width": 96,
"height": 68
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "eeGzSh9ttB14faENR7nkL1"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": {
"__id__": 6
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_spriteFrame": {
"__uuid__": "0b9461e4-38ea-4e13-b133-f28d07bc5178@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_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": "85jSymFOxH47oesupv6Cs1"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "9fCGAPLiROlKwMBu5E73hC",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.Node",
"_name": "box",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 9
},
{
"__id__": 11
}
],
"_prefab": {
"__id__": 13
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": -2.64,
"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__": 8
},
"_enabled": true,
"__prefab": {
"__id__": 10
},
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 48, "width": 48,
@ -283,11 +144,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 8 "__id__": 2
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 12 "__id__": 6
}, },
"_customMaterial": null, "_customMaterial": null,
"_srcBlendFactor": 2, "_srcBlendFactor": 2,
@ -345,7 +206,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 15 "__id__": 9
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",

@ -224,7 +224,7 @@ export function textDisplayName(text: ITableText): string {
if (hero) { if (hero) {
const name = (hero.name ?? '').trim(); const name = (hero.name ?? '').trim();
if (name) return name; if (name) return name;
const num = Math.floor(Number(hero.number)); const num = Math.floor(Number(hero.num));
if (num > 0) return String(num); if (num > 0) return String(num);
} }
return textIconName(text); return textIconName(text);

@ -200,7 +200,7 @@ export class MapDigChestHost {
} }
/** /**
* 挂宝箱到地图根(与格子锁同层),对齐格子世界坐标,避免被字块层挡住。 * 挂宝箱到 MapManager 根(勿挂「格子」:该节点有 Layout,多一个子节点会整图重排偏移)。
* @param slot 宝箱槽 * @param slot 宝箱槽
* @param grid 格子 * @param grid 格子
*/ */
@ -210,13 +210,13 @@ export class MapDigChestHost {
console.warn('[MapDigChestHost] 格子节点无效,无法挂宝箱', grid.Index); console.warn('[MapDigChestHost] 格子节点无效,无法挂宝箱', grid.Index);
return; return;
} }
const mapRoot = this._map?.mapGridParent; const tipLayer = this._tipLayer();
if (!mapRoot?.isValid) { if (!tipLayer?.isValid) {
console.warn('[MapDigChestHost] mapGridParent 无效,无法挂宝箱', grid.Index); console.warn('[MapDigChestHost] 宝箱挂点无效', grid.Index);
return; return;
} }
if (slot.tip?.isValid) { if (slot.tip?.isValid) {
this._placeTipOnMap(slot.tip, cell, mapRoot); this._placeTipOnMap(slot.tip, cell, tipLayer);
this._resetTipVisual(slot.tip); this._resetTipVisual(slot.tip);
slot.tip.active = true; slot.tip.active = true;
return; return;
@ -230,38 +230,52 @@ export class MapDigChestHost {
console.warn('[MapDigChestHost] 缺少宝箱预制体', CHEST_TIP_NAME); console.warn('[MapDigChestHost] 缺少宝箱预制体', CHEST_TIP_NAME);
return; return;
} }
this._placeTipOnMap(tip, cell, mapRoot); this._placeTipOnMap(tip, cell, tipLayer);
this._resetTipVisual(tip); this._resetTipVisual(tip);
tip.active = true; tip.active = true;
slot.tip = tip; slot.tip = tip;
} }
/**
* 宝箱 tip 层:MapManager 根下独立节点,压在「格子」之上、不受 Layout 影响。
*/
private _tipLayer(): Node | null {
const map = this._map;
if (!map?.node?.isValid) return null;
let layer = map.node.getChildByName('宝箱提示层');
if (layer?.isValid) return layer;
layer = new Node('宝箱提示层');
layer.layer = map.node.layer;
layer.parent = map.node;
const grids = map.mapGridParent;
if (grids?.isValid) {
layer.setSiblingIndex(grids.getSiblingIndex() + 1);
} else {
layer.setSiblingIndex(map.node.children.length - 1);
}
return layer;
}
/** /**
* @param tip 宝箱节点 * @param tip 宝箱节点
* @param cell 格子节点 * @param cell 格子节点
* @param mapRoot 地图格子父节点 * @param tipLayer 宝箱提示层
*/ */
private _placeTipOnMap(tip: Node, cell: Node, mapRoot: Node): void { private _placeTipOnMap(tip: Node, cell: Node, tipLayer: Node): void {
tip.parent = mapRoot; tip.parent = tipLayer;
tip.setSiblingIndex(mapRoot.children.length - 1); tip.setSiblingIndex(tipLayer.children.length - 1);
cell.getWorldPosition(_tipWorld); cell.getWorldPosition(_tipWorld);
const ut = mapRoot.getComponent(UITransform); const ut = tipLayer.getComponent(UITransform) ?? tipLayer.addComponent(UITransform);
if (ut) { ut.convertToNodeSpaceAR(_tipWorld, _tipLocal);
ut.convertToNodeSpaceAR(_tipWorld, _tipLocal); tip.setPosition(_tipLocal);
tip.setPosition(_tipLocal);
} else {
tip.setWorldPosition(_tipWorld);
}
} }
/** 对象池取出后复位显隐(飞入曾关 bg / 改 opacity) */ /** 对象池取出后复位显隐(飞入曾改 scale / opacity) */
private _resetTipVisual(tip: Node): void { private _resetTipVisual(tip: Node): void {
tip.setScale(1, 1, 1); tip.setScale(1, 1, 1);
const bg = tip.getChildByName('bg');
if (bg?.isValid) bg.active = true;
const box = tip.getChildByName('box'); const box = tip.getChildByName('box');
if (box?.isValid) box.active = true; if (box?.isValid) box.active = true;
let op = tip.getComponent(UIOpacity); const op = tip.getComponent(UIOpacity);
if (op) op.opacity = 255; if (op) op.opacity = 255;
} }

@ -2205,9 +2205,9 @@ export class TextGrid extends Component {
this._hideNumberNodes(); this._hideNumberNodes();
return; return;
} }
const num = Math.floor(Number(hero.number)); const num = Math.floor(Number(hero.num));
if (!(num > 0)) { if (!(num > 0)) {
console.log('[TextGrid] Hero.number 无效', hero.id, hero.number); console.log('[TextGrid] Hero.number 无效', hero.id, hero.num);
this._hideNumberNodes(); this._hideNumberNodes();
return; return;
} }

@ -164,7 +164,7 @@ declare global {
/** 资源 */ /** 资源 */
readonly res: string; readonly res: string;
/** 数字 */ /** 数字 */
readonly number: number; readonly num: number;
/** 等级 */ /** 等级 */
readonly level: number; readonly level: number;
/** 攻击力 /** 攻击力

@ -68,9 +68,6 @@ export class BattleDigChestFxPresenter {
fly.setSiblingIndex(layer.children.length - 1); fly.setSiblingIndex(layer.children.length - 1);
fly.active = true; fly.active = true;
fly.setScale(1, 1, 1); fly.setScale(1, 1, 1);
// 飞入只放大箱体,不带 bg
const bg = fly.getChildByName('bg');
if (bg?.isValid) bg.active = false;
let opacity = fly.getComponent(UIOpacity); let opacity = fly.getComponent(UIOpacity);
if (!opacity) opacity = fly.addComponent(UIOpacity); if (!opacity) opacity = fly.addComponent(UIOpacity);
opacity.opacity = 255; opacity.opacity = 255;
@ -107,8 +104,6 @@ export class BattleDigChestFxPresenter {
Tween.stopAllByTarget(fly); Tween.stopAllByTarget(fly);
const op = fly.getComponent(UIOpacity); const op = fly.getComponent(UIOpacity);
if (op) Tween.stopAllByTarget(op); if (op) Tween.stopAllByTarget(op);
const bg = fly.getChildByName('bg');
if (bg?.isValid) bg.active = true;
fly.setScale(1, 1, 1); fly.setScale(1, 1, 1);
if (op) op.opacity = 255; if (op) op.opacity = 255;
if (fly['resKey'] && typeof gg !== 'undefined' && gg.res?.putNode) { if (fly['resKey'] && typeof gg !== 'undefined' && gg.res?.putNode) {

@ -341,9 +341,9 @@ export class UIBattleWeaponDescHero extends Auto_BattleWeaponDescHero {
if (!this.ui_node?.isValid) return; if (!this.ui_node?.isValid) return;
this._clearNumNode(); this._clearNumNode();
const num = Math.floor(Number(w1.number) || 0); const num = Math.floor(Number(w1.num) || 0);
if (!(num > 0)) { if (!(num > 0)) {
console.warn(LOG, 'Hero.number 无效', w1.id, w1.number); console.warn(LOG, 'Hero.number 无效', w1.id, w1.num);
this.ui_node.active = false; this.ui_node.active = false;
return; return;
} }

Loading…
Cancel
Save