feat(map): 新增IBoxComp组件并调整ibox.prefab布局
新增IBoxComp组件用于游戏地图中的宝箱功能,包含基础UI属性定义和生命周期方法。 调整ibox.prefab的布局尺寸和子节点位置,优化视觉呈现。 移除VictoryComp中已废弃的广告复活相关代码,保持代码简洁。
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user