aoe ++
This commit is contained in:
@@ -31,50 +31,81 @@ export class Skill extends ecs.Entity {
|
||||
angle:number=0,
|
||||
dmg:number=0
|
||||
) {
|
||||
|
||||
let FIGHTCON=parent.getComponent(FightConComp);
|
||||
const config = SkillSet[uuid];
|
||||
if (!config) return;
|
||||
if (!config) {
|
||||
console.error("[Skill] 技能配置不存在:", uuid);
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查施法者
|
||||
if (!caster) {
|
||||
console.error("[Skill] 施法者为空");
|
||||
return;
|
||||
}
|
||||
|
||||
// 加载预制体
|
||||
const path = `game/skills/${config.sp_name}`;
|
||||
const prefab = oops.res.get(path, Prefab);
|
||||
if (!prefab) {
|
||||
console.error("[Skill] 预制体加载失败:", path);
|
||||
return;
|
||||
}
|
||||
const node = instantiate(prefab);
|
||||
|
||||
// 设置节点属性
|
||||
node.parent = parent;
|
||||
node.setPosition(startPos);
|
||||
node.angle+=angle
|
||||
// console.log("加载预制体:",startPos,targetPos)
|
||||
console.log("[Skill]:node=>",startPos)
|
||||
// 添加技能组件
|
||||
const skillComp = node.getComponent(SkillCom); // 初始化技能参数
|
||||
skillComp.ap = caster.ap+dmg;
|
||||
const SComp = node.getComponent(SkillCom); // 初始化技能参数
|
||||
if (!SComp) {
|
||||
console.error("[Skill] 技能组件获取失败");
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("[Skill]:caster=>",caster,config.name+"scomp=>",SComp,"fightcon=>",FIGHTCON)
|
||||
|
||||
// 确保caster有必要的属性
|
||||
if (typeof caster.ap === 'undefined') {
|
||||
console.error("[Skill] caster.ap 未定义");
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof caster.box_group === 'undefined') {
|
||||
console.error("[Skill] caster.box_group 未定义");
|
||||
return;
|
||||
}
|
||||
|
||||
SComp.ap = caster.ap*config.ap/100;
|
||||
if(caster.fac==0){
|
||||
if(caster.is_master){
|
||||
skillComp.ap=Math.floor(skillComp.ap*(100+FIGHTCON.hero_buff.ATK)/100);
|
||||
SComp.ap=Math.floor(SComp.ap*(100+FIGHTCON.hero_buff.ATK)/100);
|
||||
}else{
|
||||
skillComp.ap=Math.floor(skillComp.ap*(100+FIGHTCON.friend_buff.ATK)/100);
|
||||
SComp.ap=Math.floor(SComp.ap*(100+FIGHTCON.friend_buff.ATK)/100);
|
||||
}
|
||||
}else{
|
||||
skillComp.ap=Math.floor(skillComp.ap*(100-FIGHTCON.enemy_buff.ATK)/100);
|
||||
SComp.ap=Math.floor(SComp.ap*(100-FIGHTCON.enemy_buff.ATK)/100);
|
||||
}
|
||||
skillComp.s_uuid = uuid;
|
||||
skillComp.animType = config.AnimType;
|
||||
skillComp.endType = config.endType;
|
||||
skillComp.speed = config.speed;
|
||||
skillComp.inTime = config.in;
|
||||
skillComp.atk_count = 0;
|
||||
skillComp.startPos = startPos
|
||||
skillComp.targetPos =targetPos
|
||||
skillComp.caster = caster;
|
||||
skillComp.prefabName = config.sp_name;
|
||||
skillComp.group = caster.box_group;
|
||||
skillComp.fac= caster.box_group==BoxSet.HERO?0:caster.box_group==BoxSet.MONSTER?1:2;
|
||||
SComp.ap=(100+dmg)/100*SComp.ap // master 主将 技能额外百分比加成
|
||||
console.log("[Skill]:caster.box_group=>",caster.box_group,config.name+"scomp.group=>",SComp.group)
|
||||
// 设置技能组件属性
|
||||
Object.assign(SComp, {
|
||||
s_uuid: uuid,
|
||||
animType: config.AnimType,
|
||||
speed: config.speed,
|
||||
atk_count: 0,
|
||||
startPos: startPos,
|
||||
targetPos: targetPos,
|
||||
caster: caster,
|
||||
prefabName: config.sp_name,
|
||||
group: caster.box_group,
|
||||
fac: caster.fac,
|
||||
animName: config.animName
|
||||
});
|
||||
|
||||
// console.log(config.sp_name+"技能配置",skillComp);
|
||||
// 初始化动画名称
|
||||
skillComp.animName = config.animName; // 从配置获取动画名称
|
||||
this.add(skillComp);
|
||||
|
||||
|
||||
this.add(SComp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import { _decorator,Collider2D ,Contact2DType,v3,IPhysics2DContact,Vec3, tween, math, RigidBody2D} from "cc";
|
||||
import { _decorator,Collider2D ,Contact2DType,v3,IPhysics2DContact,Vec3, tween, math, RigidBody2D, Animation, sp} 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 { smc } from "../common/SingletonModuleComp";
|
||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { AnimType, endType, SkillSet } from "../common/config/SkillSet";
|
||||
import { EndAnmCom } from './EndAnmCom';
|
||||
import { BoxSet } from "../common/config/BoxSet";
|
||||
import { HeroFac, HeroSet } from "../common/config/heroSet";
|
||||
import { HeroViewComp } from "../hero/HeroViewComp";
|
||||
import { BezierMove } from "../BezierMove/BezierMove";
|
||||
import { FightConComp } from "../map/FightConComp";
|
||||
import { MonModelComp } from "../hero/MonModelComp";
|
||||
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
@@ -29,8 +29,6 @@ export class SkillCom extends CCComp {
|
||||
is_destroy:boolean = false;
|
||||
enemys:any = [];
|
||||
animType: number = 0; // 运动类型
|
||||
endType: number = 0; // 结束类型
|
||||
inTime: number = 0; // 持续时间
|
||||
startPos: Vec3 = v3(); // 起始位置
|
||||
targetPos: Vec3 = v3(); // 目标位置
|
||||
duration: number = 0; // 技能持续时间
|
||||
@@ -55,32 +53,56 @@ export class SkillCom extends CCComp {
|
||||
oops.message.on(GameEvent.MissionEnd, this.doDestroy, this);
|
||||
this.node.active = true;
|
||||
let collider = this.getComponent(Collider2D);
|
||||
// console.log(this.group +"技能 collider ",collider);
|
||||
collider.group = this.group;
|
||||
if (collider) {
|
||||
if(collider) {
|
||||
collider.group = this.group;
|
||||
collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
||||
}
|
||||
|
||||
if(SkillSet[this.s_uuid].AnimType==AnimType.parabolic){
|
||||
this.node.angle +=10
|
||||
let bm=this.node.getComponent(BezierMove)
|
||||
// bm.speed=700
|
||||
if(this.group==BoxSet.MONSTER) bm.controlPointSide=-1
|
||||
bm.moveTo(this.targetPos)
|
||||
|
||||
}
|
||||
if(SkillSet[this.s_uuid].AnimType==AnimType.linear){
|
||||
let tx =400
|
||||
if(this.group==BoxSet.MONSTER){
|
||||
tx=-400
|
||||
this.node.scale=v3(this.node.scale.x*-1,1,1)
|
||||
// console.log(this.group +"技能 collider ",collider);
|
||||
switch(SkillSet[this.s_uuid].AnimType){
|
||||
case AnimType.parabolic:
|
||||
this.node.angle +=10
|
||||
let bm=this.node.getComponent(BezierMove)
|
||||
// bm.speed=700
|
||||
if(this.group==BoxSet.MONSTER) bm.controlPointSide=-1
|
||||
bm.moveTo(this.targetPos)
|
||||
break;
|
||||
case AnimType.linear:
|
||||
let tx =400
|
||||
if(this.group==BoxSet.MONSTER){
|
||||
tx=-400
|
||||
this.node.scale=v3(this.node.scale.x*-1,1,1)
|
||||
}
|
||||
tween(this.node).to(1, { position:v3(tx,this.node.position.y,0)},{
|
||||
onComplete: (target?: object) => {
|
||||
this.node.setPosition(tx,this.node.position.y-300,0)
|
||||
}
|
||||
}).start()
|
||||
break;
|
||||
case AnimType.fixed:
|
||||
|
||||
break;
|
||||
case AnimType.fixedStart:
|
||||
|
||||
break;
|
||||
case AnimType.fixedEnd:
|
||||
if(this.node.getComponent(Animation)){
|
||||
let anim = this.node.getComponent(Animation);
|
||||
console.log("has anim",anim)
|
||||
anim.on(Animation.EventType.FINISHED, this.onAnimationFinished, this);
|
||||
}
|
||||
if(this.node.getChildByName('anm')){
|
||||
if(this.node.getChildByName('anm').getComponent('sp.Skeleton')){
|
||||
var spine = this.node.getChildByName('anm').getComponent('sp.Skeleton') as sp.Skeleton;
|
||||
console.log("has spine",spine)
|
||||
spine.setCompleteListener((trackEntry) => {
|
||||
this.onAnimationFinished()
|
||||
console.log("[track %s][animation %s] complete: %s", trackEntry.trackIndex);
|
||||
});
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
tween(this.node).to(1, { position:v3(tx,this.node.position.y,0)},{
|
||||
onComplete: (target?: object) => {
|
||||
this.node.setPosition(tx,this.node.position.y-300,0)
|
||||
}
|
||||
}).start()
|
||||
}
|
||||
|
||||
// let dir_x = this.targetPos.x > this.node.position.x ? 1 : -1
|
||||
// this.node.scale = v3(dir_x,1,1)
|
||||
// 根据目标位置设置节点朝向
|
||||
@@ -120,6 +142,21 @@ export class SkillCom extends CCComp {
|
||||
|
||||
// this.startMovement();
|
||||
// console.log("skill start",this.node.parent)
|
||||
}
|
||||
onAnimationFinished(){
|
||||
let remainingDamage = this.ap;
|
||||
remainingDamage=remainingDamage*(100-this.FIGHTCON.enemy_buff.DEF+this.FIGHTCON.enemy_debuff.BURN)/100
|
||||
let enemys=ecs.query(ecs.allOf(MonModelComp))
|
||||
console.log("onAnimationFinished",enemys)
|
||||
|
||||
enemys.forEach(entity => {
|
||||
let view=entity.get(HeroViewComp)
|
||||
if(view){
|
||||
view.do_atked(remainingDamage)
|
||||
}
|
||||
});
|
||||
|
||||
this.is_destroy=true
|
||||
}
|
||||
onBeginContact (seCol: Collider2D, oCol: Collider2D) {
|
||||
// console.log(this.scale+"碰撞开始 ",seCol,oCol);
|
||||
@@ -141,22 +178,6 @@ export class SkillCom extends CCComp {
|
||||
|
||||
|
||||
|
||||
private startMovement() {
|
||||
switch(SkillSet[this.s_uuid].AnimType) {
|
||||
case AnimType.parabolic:
|
||||
this.startBezierMove();
|
||||
break;
|
||||
case AnimType.fixed:
|
||||
this.startFixedMove();
|
||||
break;
|
||||
case AnimType.fixedStart:
|
||||
this.startFixedStartMove();
|
||||
break;
|
||||
case AnimType.fixedEnd:
|
||||
this.startFixedEndMove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private startLinearMove(dt: number) {
|
||||
@@ -188,51 +209,7 @@ export class SkillCom extends CCComp {
|
||||
// }).start();
|
||||
}
|
||||
|
||||
private startFixedMove() {
|
||||
if (this.endType === endType.timeEnd) {
|
||||
tween(this.node)
|
||||
.delay(this.inTime)
|
||||
.call(() => this.is_destroy = true)
|
||||
.start();
|
||||
} else if (this.endType === endType.animationEnd) {
|
||||
if (!this.node.getComponent(EndAnmCom)) {
|
||||
this.node.addComponent(EndAnmCom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private startFixedStartMove() {
|
||||
// console.log("开始固定起点运动")
|
||||
this.node.position = this.startPos;
|
||||
if (this.endType === endType.timeEnd) {
|
||||
// console.log("开始固定起点运动=>time:"+this.inTime)
|
||||
tween(this.node)
|
||||
.delay(this.inTime)
|
||||
.call(() => this.is_destroy = true)
|
||||
.start();
|
||||
} else if (this.endType === endType.animationEnd) {
|
||||
if (!this.node.getComponent(EndAnmCom)) {
|
||||
this.node.addComponent(EndAnmCom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private startFixedEndMove() {
|
||||
// console.log("开始固定终点运动")
|
||||
this.node.position = this.targetPos;
|
||||
if (this.endType === endType.timeEnd) {
|
||||
// console.log("开始固定终点运动=>time:"+this.inTime)
|
||||
tween(this.node)
|
||||
.delay(this.inTime)
|
||||
.call(() => this.is_destroy = true)
|
||||
.start();
|
||||
} else if (this.endType === endType.animationEnd) {
|
||||
if (!this.node.getComponent(EndAnmCom)) {
|
||||
this.node.addComponent(EndAnmCom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static bezierTo(target: any, duration: number, c1: Vec3, c2: Vec3, to: Vec3, opts: any) {
|
||||
opts = opts || Object.create(null);
|
||||
/*
|
||||
@@ -285,9 +262,7 @@ export class SkillCom extends CCComp {
|
||||
reset() {
|
||||
this.is_destroy = false;
|
||||
this.animType = 0;
|
||||
this.endType = 0;
|
||||
this.speed = 0;
|
||||
this.inTime = 0;
|
||||
this.startPos.set();
|
||||
this.targetPos.set();
|
||||
this.moveDirection = null; // 重置移动方向
|
||||
|
||||
Reference in New Issue
Block a user