英雄去除 smchp

This commit is contained in:
2025-08-11 22:33:22 +08:00
parent 5bcf5e737b
commit 919ff09351
5 changed files with 33 additions and 83 deletions

View File

@@ -20,7 +20,6 @@ export class Hero extends ecs.Entity {
HeroModel!: HeroModelComp;
HeroView!: HeroViewComp;
BattleMove!: BattleMoveComp;
vmHero:any={}
protected init() {
this.addComponents<ecs.Comp>(
BattleMoveComp,
@@ -40,34 +39,14 @@ export class Hero extends ecs.Entity {
super.destroy();
}
/**
* 获取所有英雄槽位
* @returns 英雄槽位数组
*/
private getHeroSlots(): any[] {
return [smc.vmdata.hero1, smc.vmdata.hero2, smc.vmdata.hero3]
}
/**
* 查找可用的英雄槽位
* @returns 可用的英雄槽位对象如果没有可用槽位则返回null
*/
private findAvailableHeroSlot(): any {
return this.getHeroSlots().find(slot => slot.uuid === 0) || null
}
/** 加载角色 */
load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001,info:any={ap:0,hp:0,lv:1,crit:0,crit_d:0,dod:0,dod_no:false,crit_no:false},fight_pos:number=1) {
// console.log("英雄加载:",uuid,pos,scale,info)
scale = 1
// 查找空闲英雄槽位
this.vmHero = this.findAvailableHeroSlot()
if (!this.vmHero) {
console.log("[Hero] 英雄已满")
return
}
this.vmHero.uuid=uuid
this.vmHero.count=1
var path = "game/heros/"+HeroInfo[uuid].path;
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
@@ -92,8 +71,6 @@ export class Hero extends ecs.Entity {
hero_init(uuid:number=1001,node:Node,info:any={ap:0,hp:0,lv:1,crit:0,crit_d:0,dod:0,dod_no:false,crit_no:false}) {
var hv = node.getComponent(HeroViewComp)!;
let hero= HeroInfo[uuid] // 共用英雄数据
hv.vmHero=this.vmHero
this.vmHero.name=hero.name
hv.scale = 1;
hv.is_master=true;
hv.lv=1
@@ -106,7 +83,7 @@ export class Hero extends ecs.Entity {
hv.speed =hv.ospeed = hero.speed;
hv.dis = hero.dis;
hv.cd = hv.cd_base = hero.cd
this.vmHero.hp=this.vmHero.hp_max= hv.hp = hv.hp_max = hv.hp_base=hero.hp+info.hp
hv.hp = hv.hp_max = hv.hp_base=hero.hp+info.hp
hv.ap = hv.ap_base=hero.ap+info.ap;
hero.buff.forEach((buff:any)=>{
switch(buff.buff_type){
@@ -161,8 +138,13 @@ export class Hero extends ecs.Entity {
}
})
hv.atk_skill=hero.skills[0]
hv.skills=hero.skills
this.vmHero.cd_max=SkillSet[hv.skills[1]].cd
for(let i=0;i<hero.skills.length;i++){
hv.skills.push({
cd:0,
uuid:hero.skills[i],
cd_max:i==0?hero.cd:SkillSet[hero.skills[i]].cd
})
}
return hv
}

View File

@@ -36,16 +36,13 @@ export class HeroViewComp extends CCComp {
scale: number = 1; /** 角色阵营 1hero -1 :mon */
type: number = 0; /**角色类型 0近战-需要贴身 1远程-保持距离 2辅助 */
fac:number=0; //阵营 0hero 1monster
vmHero:any={}
skill_cd:number=0;
skill_cd_max:number=1.3;
/**
* 获取当前血量 - 根据阵营选择正确的变量
*/
get currentHp(): number {
if (this.fac === FacSet.HERO) {
return this.vmHero.hp || 0;
}
return this.hp;
}
@@ -53,20 +50,13 @@ export class HeroViewComp extends CCComp {
* 设置当前血量 - 根据阵营选择正确的变量
*/
set currentHp(value: number) {
if (this.fac === FacSet.HERO) {
this.vmHero.hp = value;
} else {
this.hp = value;
}
this.hp = value;
}
/**
* 获取最大血量 - 根据阵营选择正确的变量
*/
get currentHpMax(): number {
if (this.fac === FacSet.HERO) {
return this.vmHero.hp_max || 0;
}
return this.hp_max;
}
@@ -74,11 +64,7 @@ export class HeroViewComp extends CCComp {
* 设置最大血量 - 根据阵营选择正确的变量
*/
set currentHpMax(value: number) {
if (this.fac === FacSet.HERO) {
this.vmHero.hp_max = value;
} else {
this.hp_max = value;
}
this.hp_max = value;
}
box_group:number = BoxSet.HERO;

View File

@@ -8,7 +8,7 @@ import { HeroInfo } from "../common/config/heroSet";
import { MonModelComp } from "./MonModelComp";
import { BattleMoveComp } from "../common/ecs/position/BattleMoveComp";
import { SkillConComp } from "./SkillConComp";
import { BuffAttr } from "../common/config/SkillSet";
import { BuffAttr, SkillSet } from "../common/config/SkillSet";
/** 角色实体 */
@ecs.register(`Monster`)
export class Monster extends ecs.Entity {
@@ -104,7 +104,13 @@ export class Monster extends ecs.Entity {
hv.cd = hero.cd
hv.atk_skill=hero.skills[0]
for(let i=0;i<hero.skills.length;i++){
hv.skills.push({
cd:0,
uuid:hero.skills[i],
cd_max:i==0?hero.cd:SkillSet[hero.skills[i]].cd
})
}
// 处理原有Buff
hero.buff.forEach((buff:any)=>{
this.applyBuffToMonster(hv, buff);

View File

@@ -19,6 +19,7 @@ const { ccclass, property } = _decorator;
export class SkillConComp extends CCComp {
HeroView:any=null;
HeroEntity:any=null;
skill_cd=0
private _timers: { [key: string]: number } = {};
private _damageQueue: Array<{ timer: number; callback: () => void }> = [];
@@ -48,26 +49,18 @@ export class SkillConComp extends CCComp {
update(dt: number) {
if(!smc.mission.play||smc.mission.pause) return
if(this.HeroView.DEBUFF_STUN <= 0&&this.HeroView.DEBUFF_FROST <= 0) {
this.HeroView.at += dt;
this.HeroView.vmHero.cd += dt
for(let i=0;i<this.HeroView.skills.length;i++){
this.HeroView.skills[i].cd += dt;
if(this.HeroView.skills[i].cd > this.HeroView.skills[i].cd_max){
let sc=SkillSet[this.HeroView.skills[i].uuid]
if(!sc) return
if(sc.SType==SType.damage&&!this.HeroView.is_atking) return
this.castSkill(sc,false,0)
this.HeroView.skills[i].cd = 0
}
}
}
if(this.HeroView.vmHero.cd > this.HeroView.vmHero.cd_max){
let sc=SkillSet[this.HeroView.skills[1]]
if(!sc) return
if(sc.SType==SType.damage&&!this.HeroView.is_atking) return
this.castSkill(sc,false,0)
this.HeroView.vmHero.cd = 0
}
let cd = this.count_cd(this.HeroView.cd,this.HeroView)
if (this.HeroView.is_atking &&(this.HeroView.at > cd)) {
if(this.HeroView.is_dead) return
const config = SkillSet[this.HeroView.atk_skill];
if (!config) return;
this.castSkill(config,this.check_wfuny());
this.HeroView.count_atk_count()
this.HeroView.at = 0;
}
if (this.aoe_queues.length > 0) {
//console.log("[FightConComp]:aoe_queues:",this.aoe_queues)
@@ -294,21 +287,7 @@ export class SkillConComp extends CCComp {
Object.values(this._timers).forEach(clearTimeout);
}
count_cd(cd:number,view:HeroViewComp){
// 汇总DEBUFF_DECD不再按次数减少改为按时间减少
let decd = 0;
for (let i = view.DEBUFF_DECDS.length - 1; i >= 0; i--) {
decd += view.DEBUFF_DECDS[i].value;
// 不再在这里减少duration改为在update中按时间减少
}
let bcd=0
for (let i = view.BUFF_CDS.length - 1; i >= 0; i--) {
bcd += view.BUFF_CDS[i].value;
// 不再在这里减少duration改为在update中按时间减少
}
return cd/((bcd+decd)/100+1)
}
get_count(count:number,view:HeroViewComp){
let re=count+view.wfuny
if(re<1) re=1

View File

@@ -131,9 +131,6 @@ export class MissionComp extends CCComp {
}
private cleanComponents() {
smc.vmdata.hero1=JSON.parse(JSON.stringify(HeroUI))
smc.vmdata.hero2=JSON.parse(JSON.stringify(HeroUI))
smc.vmdata.hero3=JSON.parse(JSON.stringify(HeroUI))
ecs.query(ecs.allOf(HeroViewComp)).forEach(entity => {entity.remove(HeroViewComp);entity.destroy()});
}