feat(map): 新增IBoxComp组件并调整ibox.prefab布局

新增IBoxComp组件用于游戏地图中的宝箱功能,包含基础UI属性定义和生命周期方法。
调整ibox.prefab的布局尺寸和子节点位置,优化视觉呈现。
移除VictoryComp中已废弃的广告复活相关代码,保持代码简洁。
This commit is contained in:
panw
2026-03-27 16:51:39 +08:00
parent 87eea006ad
commit 84a217df50
4 changed files with 118 additions and 86 deletions

View File

@@ -32,10 +32,13 @@
},
{
"__id__": 80
},
{
"__id__": 82
}
],
"_prefab": {
"__id__": 82
"__id__": 84
},
"_lpos": {
"__type__": "cc.Vec3",
@@ -134,7 +137,7 @@
"_contentSize": {
"__type__": "cc.Size",
"width": 660,
"height": 150
"height": 200
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -338,7 +341,7 @@
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 30,
"y": 50,
"z": 0
},
"_lrot": {
@@ -713,7 +716,7 @@
"_contentSize": {
"__type__": "cc.Size",
"width": 620,
"height": 50
"height": 40
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -806,7 +809,7 @@
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": -30,
"y": 0,
"z": 0
},
"_lrot": {
@@ -933,7 +936,7 @@
"a": 255
},
"_spriteFrame": {
"__uuid__": "6165ffc9-a838-4a33-b569-bdbaaab0e6b4@8a9eb",
"__uuid__": "6165ffc9-a838-4a33-b569-bdbaaab0e6b4@7a4bc",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
@@ -948,7 +951,10 @@
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_atlas": {
"__uuid__": "6165ffc9-a838-4a33-b569-bdbaaab0e6b4",
"__expectedType__": "cc.SpriteAtlas"
},
"_id": ""
},
{
@@ -1181,7 +1187,7 @@
"_contentSize": {
"__type__": "cc.Size",
"width": 620,
"height": 50
"height": 40
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -1259,7 +1265,7 @@
"__id__": 58
}
],
"_active": false,
"_active": true,
"_components": [
{
"__id__": 66
@@ -1274,7 +1280,7 @@
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": -60,
"y": -50,
"z": 0
},
"_lrot": {
@@ -1401,7 +1407,7 @@
"a": 255
},
"_spriteFrame": {
"__uuid__": "6165ffc9-a838-4a33-b569-bdbaaab0e6b4@8a9eb",
"__uuid__": "6165ffc9-a838-4a33-b569-bdbaaab0e6b4@7a4bc",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
@@ -1416,7 +1422,10 @@
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_atlas": {
"__uuid__": "6165ffc9-a838-4a33-b569-bdbaaab0e6b4",
"__expectedType__": "cc.SpriteAtlas"
},
"_id": ""
},
{
@@ -1649,7 +1658,7 @@
"_contentSize": {
"__type__": "cc.Size",
"width": 620,
"height": 50
"height": 40
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -1726,7 +1735,7 @@
"_contentSize": {
"__type__": "cc.Size",
"width": 660,
"height": 160
"height": 150
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -1755,8 +1764,8 @@
"_target": null,
"_left": 0,
"_right": 0,
"_top": -5,
"_bottom": -5,
"_top": 25,
"_bottom": 25,
"_horizontalCenter": 0,
"_verticalCenter": 0,
"_isAbsLeft": true,
@@ -1797,8 +1806,8 @@
"_startAxis": 0,
"_paddingLeft": 0,
"_paddingRight": 0,
"_paddingTop": 25,
"_paddingBottom": 25,
"_paddingTop": 5,
"_paddingBottom": 5,
"_spacingX": 0,
"_spacingY": 10,
"_verticalDirection": 1,
@@ -1841,7 +1850,7 @@
"_contentSize": {
"__type__": "cc.Size",
"width": 660,
"height": 150
"height": 200
},
"_anchorPoint": {
"__type__": "cc.Vec2",
@@ -1890,6 +1899,33 @@
"__type__": "cc.CompPrefabInfo",
"fileId": "88vjsnrkhKvrT5BHQt/TeZ"
},
{
"__type__": "ac90fNha41BoplcQri3SjpL",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 83
},
"Line1": {
"__id__": 11
},
"Line2": {
"__id__": 31
},
"Line3": {
"__id__": 51
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "caFlytW6dOyKuX32MnVcBt"
},
{
"__type__": "cc.PrefabInfo",
"root": {

View File

@@ -0,0 +1,53 @@
import { mLogger } from "../common/Logger";
import { _decorator, Animation, AnimationClip, EventTouch, Label, Node, NodeEventType, Sprite, SpriteAtlas, Tween, tween, UIOpacity, Vec3, resources } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { CardConfig, CardType, SpecialCardList } from "../common/config/CardSet";
import { CardUseComp } from "./CardUseComp";
import { HeroInfo } from "../common/config/heroSet";
import { SkillSet } from "../common/config/SkillSet";
import { GameEvent } from "../common/config/GameEvent";
import { oops } from "db://oops-framework/core/Oops";
import { smc } from "../common/SingletonModuleComp";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@ccclass('IBoxComp')
@ecs.register('IBoxComp', false)
export class IBoxComp extends CCComp {
private debugMode: boolean = true;
/** 锁定态图标节点(显示时表示本槽位锁定) */
@property(Node)
Line1: Node = null!
@property(Node)
Line2: Node = null!
@property(Node)
Line3: Node = null!
@property(Node)
Line4: Node = null!
@property(Node)
Line5: Node = null!
onAdded(args: any) {
}
onLoad() {
}
onDestroy() {
}
init(){
}
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
this.node.destroy();
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "ac90f361-6b8d-41a2-995c-42b8b74a3a4b",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -118,75 +118,9 @@ export class VictoryComp extends CCComp {
double_reward(){
}
/** 看广告复活 */
watch_ad_revive() {
if (!this.canRevive) {
mLogger.log(this.debugMode, 'VictoryComp', "已经复活过,无法再次复活");
return;
}
// TODO: 接入广告SDK这里先模拟广告播放成功回调
this.onAdReviveSuccess();
}
/** 广告复活成功回调 */
private onAdReviveSuccess() {
mLogger.log(this.debugMode, 'VictoryComp', "[VictoryComp] 广告复活成功");
mLogger.log(this.debugMode, 'VictoryComp', "[VictoryComp] 广告复活成功")
// 1. 标记已复活
// this.reviveCount++;
this.canRevive = false;
// 2. 执行复活逻辑
this.doReviveHero();
// 2.1 通知 MissionComp 扣除次数
oops.message.dispatchEvent(GameEvent.ReviveSuccess);
// 3. 恢复游戏状态
// smc.mission.play = true;
smc.mission.pause = false;
// 4. 关闭结算界面
oops.gui.removeByNode(this.node);
}
/** 执行英雄复活逻辑 */
private doReviveHero() {
// 查找所有英雄实体并复活
const heroes = ecs.query(ecs.allOf(HeroAttrsComp, HeroViewComp));
let hasRevived = false;
heroes.forEach(e => {
const attrs = e.get(HeroAttrsComp);
const view = e.get(HeroViewComp);
if (attrs.fac === FacSet.HERO && attrs.is_dead) {
// 重置属性
attrs.is_dead = false;
attrs.hp = attrs.Attrs[Attrs.HP_MAX]; // 满血复活
attrs.mp = attrs.Attrs[Attrs.MP_MAX];
attrs.is_reviving = false;
// 视图层复活
if (view) {
view.alive();
}
hasRevived = true;
mLogger.log(this.debugMode, 'VictoryComp', `[VictoryComp] 复活英雄: ${attrs.hero_name}`);
}
});
if (hasRevived) {
// 发送复活事件(如果有需要)
// oops.message.dispatchEvent(GameEvent.HeroRevived);
} else {
mLogger.log(this.debugMode, 'VictoryComp', "[VictoryComp] 未找到可复活的英雄实体");
}
}
restart(){
this.clear_data()