技能系统修改为 只负责普通技能

This commit is contained in:
2025-03-26 16:42:52 +08:00
parent 8e0aa200a6
commit 8b33abb973
9 changed files with 267 additions and 206 deletions

View File

@@ -6,6 +6,7 @@ import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/O
import { GameEvent } from "../common/config/GameEvent";
import { AnimType, endType } from "../common/config/SkillSet";
import { EndAnmCom } from './EndAnmCom';
import { BoxSet } from "../common/config/BoxSet";
const { ccclass, property } = _decorator;
@@ -14,12 +15,14 @@ const { ccclass, property } = _decorator;
@ccclass('SkillCom')
@ecs.register('SkillCom')
export class SkillCom extends CCComp {
s_uuid:number = 0;
s_name:string = "";
hero:number = 0;
speed:number = 200;
scale:number = 1;
angle:number = 0;
atk_count:number = 0;
is_destroy:boolean = false;
enemys:any = [];
animType: number = 0; // 运动类型
@@ -32,36 +35,37 @@ export class SkillCom extends CCComp {
animName: string = "";
group:number = 0; //阵营
rigid:RigidBody2D=null!; // 动画名称
target:any=null;
caster:any=null;
protected onLoad(): void {
}
start() {
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;
// console.log("hero collider ",this.scale,collider);
if (collider) {
collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
// collider.on(Contact2DType.END_CONTACT, this.onEndContact, this);
collider.on(Contact2DType.PRE_SOLVE, this.onPreSolve, this);
// collider.on(Contact2DType.POST_SOLVE, this.onPostSolve, this);
}
this.rigid = this.getComponent(RigidBody2D);
if(this.rigid.sleep){
console.log("hero rigid sleep ",this.scale,this.rigid);
console.log(this.scale+"技能 rigid sleep ",this.rigid);
this.rigid.wakeUp();
}
}
onBeginContact (seCol: Collider2D, oCol: Collider2D) {
console.log("碰撞开始 ",this.scale,seCol,oCol);
}
onEndContact (seCol: Collider2D, oCol: Collider2D) { console.log("碰撞结束 ",this.scale,seCol,oCol);}
onPreSolve (seCol: Collider2D, oCol: Collider2D) {console.log("碰撞预处理 ",this.scale,seCol,oCol);}
onPostSolve (seCol: Collider2D, oCol: Collider2D) {console.log("碰撞后处理 ",this.scale,seCol,oCol); }
start() {
oops.message.on(GameEvent.MissionEnd, this.doDestroy, this);
this.node.active = true;
// 根据动画类型开始相应的运动
this.startMovement();
}
onBeginContact (seCol: Collider2D, oCol: Collider2D) {
console.log(this.scale+"碰撞开始 ",seCol,oCol);
}
private startMovement() {
switch(this.animType) {
@@ -84,10 +88,14 @@ export class SkillCom extends CCComp {
}
private startLinearMove() {
if (!this.targetPos) return;
const duration = Vec3.distance(this.startPos, this.targetPos) / this.speed;
tween(this.node)
.to(duration, { position: this.targetPos })
if(this.group==BoxSet.HERO){
this.targetPos.x=720
}else{
this.targetPos.x=-720
}
const duration = Vec3.distance(this.startPos, this.targetPos) / this.speed;
tween(this.node)
.to(duration, { position: this.targetPos })
.call(() => {
this.is_destroy = true;
})