技能组件修改,由skillcom统一负责动画,只负责动画

This commit is contained in:
2025-02-08 08:06:42 +08:00
parent 8a6609f2c2
commit c619b97aa4
47 changed files with 450 additions and 555 deletions

View File

@@ -7,57 +7,117 @@ import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { GameEvent } from "../common/config/GameEvent";
import { SkillSet } from "../common/config/SkillSet";
import { AnimType, endType } from "../common/config/SkillSet";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@ccclass('SkillCom')
@ecs.register('SkillView', false)
@ecs.register('SkillCom')
export class SkillCom extends CCComp {
s_uuid:number = 0;
s_name:string = "";
hero:number = 0;
speed:number = 200;
scale:number = 1;
lv:number = 1;
ap:number = 10;
def:number = 10;
apup:number = 0;//
mhp:number = 0;
hp:number = 0; //治疗总量
shield:number = 0;//护甲总量
cd:number = 1;
debuff:number = 0;
debtime:number = 0;
depb:number = 0;
derate:number = 0;
atk_count:number = 0;
is_crit:boolean = false;
crit_add: number = 0;//暴击伤害加成
angle:number = 0;
t_pos:Vec3 = v3(0,0,0); // 目标增量
is_destroy:boolean = false;
box_group:number = 0;
box_tag:number=0;
type:number = 1;
run:number = 0;
tg:number = 3;
in_time:number = 0.3; // 不动技能持续时间
enemys:any = [];
animType: number = 0; // 运动类型
endType: number = 0; // 结束类型
inTime: number = 0; // 持续时间
startPos: Vec3 = v3(); // 起始位置
targetPos: Vec3 = v3(); // 目标位置
duration: number = 0; // 技能持续时间
prefabName: string = ""; // 预制体名称
group:number = 0; //阵营
animName: string = ""; // 动画名称
start() {
oops.message.on(GameEvent.MissionEnd, this.doDestroy, this);
this.node.active=true
this.node.active = true;
// 根据动画类型开始相应的运动
this.startMovement();
}
private startMovement() {
switch(this.animType) {
case AnimType.linear:
this.startLinearMove();
break;
case AnimType.parabolic:
this.startBezierMove();
break;
case AnimType.fixed:
this.startFixedMove();
break;
}
}
private startLinearMove() {
if (!this.targetPos) return;
const duration = Vec3.distance(this.node.position, this.targetPos) / this.speed;
tween(this.node)
.to(duration, { position: this.targetPos })
.call(() => {
if (this.endType === endType.distanceEnd) {
this.is_destroy = true;
}
})
.start();
}
private startBezierMove() {
if (!this.targetPos) return;
const startPos = this.node.position;
const endPos = this.targetPos;
const controlPos = v3(
(startPos.x + endPos.x) / 2,
Math.max(startPos.y, endPos.y) + 200
);
const duration = Vec3.distance(startPos, endPos) / this.speed;
tween(this.node)
.to(duration, {}, {
onUpdate: (target, ratio) => {
const pos = this.twoBezier(ratio, startPos, controlPos, endPos);
this.node.setPosition(pos);
}
})
.call(() => this.is_destroy = true)
.start();
}
private startFixedMove() {
if (this.endType === endType.timeEnd) {
tween(this.node)
.delay(this.inTime)
.call(() => this.is_destroy = true)
.start();
}
}
private twoBezier(t: number, p1: Vec3, cp: Vec3, p2: Vec3): Vec3 {
const x = (1 - t) * (1 - t) * p1.x + 2 * t * (1 - t) * cp.x + t * t * p2.x;
const y = (1 - t) * (1 - t) * p1.y + 2 * t * (1 - t) * cp.y + t * t * p2.y;
return v3(x, y, 0);
}
to_console(value:any,value2:any=null,value3:any=null){
console.log("["+this.s_name+this.s_uuid+"]:",value,value2,value3)
}
update(deltaTime: number) {
if(smc.mission.pause) return
this.toDestroy()
if(smc.mission.pause) return;
this.toDestroy();
}
toDestroy() {
if(this.is_destroy){
@@ -71,6 +131,12 @@ export class SkillCom extends CCComp {
reset() {
this.is_destroy=false
this.node.destroy();
this.animType = 0;
this.endType = 0;
this.speed = 0;
this.inTime = 0;
this.startPos.set();
this.targetPos.set();
}
}