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

@@ -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()