Files
pixelheros/assets/script/game/map/MissionHeroComp.ts
walkpan 6de3a105da refactor(英雄系统): 移除主角特殊逻辑和怪物死亡处理
- 删除 HeroAttrsComp 中的 is_master 字段
- 简化 Hero.load() 方法签名,移除 is_master 和 is_friend 参数
- 移除 MissionComp 中的怪物死亡事件监听和奖励计算逻辑
- 移除 HeroViewComp 中主角复活时恢复怪物行动的逻辑
- 修改 HeroAtkSystem 中复活逻辑,不再区分主角
- 将 MissionHeroComp 中的 CallFriend 事件改为 CallHero,并清理事件监听
- 移除英雄死亡时停止怪物刷新的逻辑,简化阵营判断

这些更改旨在简化英雄系统架构,消除主角与普通英雄之间的特殊处理差异,使系统更加统一和可维护。怪物死亡奖励计算等逻辑被移至其他系统处理。
2026-03-14 13:20:02 +08:00

72 lines
2.2 KiB
TypeScript

import { _decorator, resources, Sprite, SpriteAtlas, SpriteFrame, v3, Vec3 } 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 { Hero } from "../hero/Hero";
import { smc } from "../common/SingletonModuleComp";
import { Timer } from "db://oops-framework/core/common/timer/Timer";
import { GameEvent } from "../common/config/GameEvent";
import { HeroPos } from "../common/config/heroSet";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@ccclass('MissionHeroCompComp')
@ecs.register('MissionHeroComp', false)
export class MissionHeroCompComp extends CCComp {
timer:Timer=new Timer(2)
Friend_is_dead:boolean=false
current_hero_uuid:number=0
current_hero_num:number=-1
heros:any=[]
onLoad(){
this.on(GameEvent.FightReady,this.fight_ready,this)
this.on(GameEvent.Zhaohuan,this.zhao_huan,this)
this.on(GameEvent.MissionEnd,this.clear_heros,this)
oops.message.on(GameEvent.CallHero,this.call_hero,this)
}
onDestroy(){
oops.message.off(GameEvent.CallHero,this.call_hero,this)
oops.message.off(GameEvent.FightReady,this.fight_ready,this)
oops.message.off(GameEvent.Zhaohuan,this.zhao_huan,this)
oops.message.off(GameEvent.MissionEnd,this.clear_heros,this)
}
start() {
// this.test_call()
}
clear_heros(){
}
fight_ready(){
smc.vmdata.mission_data.hero_num=0
}
// protected update(dt: number): void {
// }
private zhao_huan(event: string, args: any){
}
private call_hero(event: string, args: any){
this.addHero(args.uuid)
}
/** 添加英雄 */
private addHero(uuid:number=1001) {
let hero_pos=0
let hero = ecs.getEntity<Hero>(Hero);
let scale = 1
let pos:Vec3 = HeroPos[hero_pos].pos;
hero.load(pos,scale,uuid);
}
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
// this.node.destroy();
}
}