Files
pixelheros/assets/script/game/map/MissionHeroComp.ts
panw 35af88d570 feat: 重构英雄与怪物系统并添加等级机制
- 调整怪物配置映射,将兽人系列怪物ID从5xxx改为6xxx
- 为英雄系统添加等级支持,英雄属性随等级线性增长
- 重构卡牌系统,区分英雄卡和功能卡显示逻辑
- 重新组织英雄配置数据,按职业分类并添加等级字段
- 扩展技能配置,为各等级添加对应技能变体
- 简化特殊卡配置结构,添加名称和描述字段
2026-03-20 10:54:29 +08:00

76 lines
2.5 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 {
private static readonly HERO_DROP_HEIGHT = 260
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,args.hero_lv)
}
/** 添加英雄 */
private addHero(uuid:number=1001,hero_lv:number=1) {
console.log("addHero uuid:",uuid)
let hero_pos=0
let hero = ecs.getEntity<Hero>(Hero);
let scale = 1
let landingPos:Vec3 = HeroPos[hero_pos].pos;
let spawnPos:Vec3 = v3(landingPos.x, landingPos.y + MissionHeroCompComp.HERO_DROP_HEIGHT, 0);
hero.load(spawnPos,scale,uuid,landingPos.y,hero_lv);
}
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
reset() {
// this.node.destroy();
}
}