技能碰撞改回物理碰撞

This commit is contained in:
2025-03-30 16:59:40 +08:00
parent 67704725b2
commit 798a831227
85 changed files with 13428 additions and 7394 deletions

View File

@@ -1,37 +1,22 @@
/*
* @Author: dgflash
* @Date: 2021-11-18 17:47:56
* @LastEditors: dgflash
* @LastEditTime: 2022-08-04 15:43:04
*/
import { instantiate, Node, Prefab, Vec3 ,v3,resources,SpriteFrame,Sprite,SpriteAtlas} from "cc";
import { UICallbacks } from "../../../../extensions/oops-plugin-framework/assets/core/gui/layer/Defines";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { UIID } from "../common/config/GameUIConfig";
import { smc } from "../common/SingletonModuleComp";
import { HeroModelComp } from "./HeroModelComp";
import { HeroSpine } from "./HeroSpine";
import { HeroViewComp } from "./HeroViewComp";
import { BoxSet } from "../common/config/BoxSet";
import { RandomManager } from "../../../../extensions/oops-plugin-framework/assets/core/common/random/RandomManager";
import { HeroInfo } from "../common/config/heroSet";
import { Talents } from "../common/config/TalentSet";
import { MonModelComp } from "./MonModelComp";
import { BattleMoveComp } from "../common/ecs/position/BattleMoveComp";
import { HeroSkillsComp } from "../skill/heroSkillsComp";
/** 角色实体 */
@ecs.register(`Monster`)
export class Monster extends ecs.Entity {
HeroModel!: MonModelComp;
HeroView!: HeroViewComp;
BattleMove!: BattleMoveComp;
HeroSkills!: HeroSkillsComp;
protected init() {
this.addComponents<ecs.Comp>(
BattleMoveComp,
HeroSkillsComp,
MonModelComp
);
}
@@ -46,7 +31,7 @@ export class Monster extends ecs.Entity {
scale=-1
let box_group=BoxSet.MONSTER
console.log("mon load",uuid)
this.addComponents<ecs.Comp>( MonModelComp, BattleMoveComp);
// this.addComponents<ecs.Comp>( MonModelComp, BattleMoveComp);
var path = "game/heros/"+HeroInfo[uuid].path;
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
@@ -67,8 +52,6 @@ export class Monster extends ecs.Entity {
var hv = node.getComponent(HeroViewComp)!;
// console.log("hero_init",buff)
let hero= HeroInfo[uuid] // 共用英雄数据
let talent= smc.vmdata.talent //角色英雄数据
let talents=Talents;
hv.scale = scale;
hv.fac = 1;
hv.type = hero.type;
@@ -84,42 +67,7 @@ export class Monster extends ecs.Entity {
hv.atk_skill=hero.skills[0]
this.add(hv);
// // 初始化多个技能组件
// const skillsComp = this.get(HeroSkillsComp);
// // 正确初始化已有技能
// hero.skills.forEach(skillId => {
// this.addSkill(skillId); // 使用addSkill方法确保初始化
// });
// 初始化移动参数
const move = this.get(BattleMoveComp);
move.direction = 1; // 向右移动
move.targetX = 800; // 右边界
}
// 添加技能
public addSkill(skillId: number) {
const comp = this.get(HeroSkillsComp);
if (comp.skills.indexOf(skillId) === -1) {
comp.skills.push(skillId);
comp.cooldowns.set(skillId, 0);
comp.counters.set(skillId, 0);
console.log(`技能${skillId}初始化完成`,
'当前cooldowns:', comp.cooldowns,
'当前counters:', comp.counters);
}
}
// 移除技能
public removeSkill(skillId: number) {
const comp = this.get(HeroSkillsComp);
comp.skills = comp.skills.filter(id => id !== skillId);
}
public levelUp() {
// ...升级逻辑...
const comp = this.get(HeroSkillsComp);
comp.skills.forEach(skillId => {
comp.resetCooldown(skillId);
});
}
}