85 lines
3.1 KiB
TypeScript
85 lines
3.1 KiB
TypeScript
import { _decorator,Collider2D ,Contact2DType,v3,IPhysics2DContact,Vec3, tween, math} 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 { BoxSet } from "../common/config/BoxSet";
|
|
import { smc } from "../common/SingletonModuleComp";
|
|
import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
|
|
import { HeroViewComp } from "../hero/HeroViewComp";
|
|
|
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
/** 视图层对象 */
|
|
@ccclass('SkillCom')
|
|
@ecs.register('SkillView', false)
|
|
export class SkillCom extends CCComp {
|
|
s_uuid:number = 0;
|
|
speed:number = 200;
|
|
scale:number = 1;
|
|
ap:number = 10;
|
|
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;
|
|
in_time:number = 0.3; // 不动技能持续时间
|
|
enemys:any = [];
|
|
start() {
|
|
this.node.active=true
|
|
let collider = this.getComponent(Collider2D);
|
|
collider.group = this.box_group;
|
|
collider.tag = this.box_tag;
|
|
collider.sensor = true;
|
|
if (collider) {
|
|
collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
|
// collider.on(Contact2DType.END_CONTACT, this.onEndContact, this);
|
|
collider.on(Contact2DType.POST_SOLVE, this.onPostSolve, this);
|
|
}
|
|
|
|
}
|
|
onBeginContact (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
|
if(otherCollider.group != selfCollider.group&&otherCollider.tag ==0){
|
|
this.atk_count+=1
|
|
// console.log("skill onBeginContact",otherCollider.node.getComponent(HeroViewComp).uuid)
|
|
// let uid=otherCollider.node.getComponent(HeroViewComp).uuid
|
|
// const count = this.enemys.filter(enemy => enemy.uid === uid).length;
|
|
// if(count==0){
|
|
// // otherCollider.node.getComponent(HeroViewComp).check_uatk(this)
|
|
// console.log("count==0",otherCollider.node.getComponent(HeroViewComp).uuid)
|
|
// this.enemys.push(uid)
|
|
// }
|
|
|
|
|
|
// if(this.type==1 ){
|
|
// this.is_destroy=true
|
|
// }
|
|
// console.log("skill onBeginContact",selfCollider.group,otherCollider.group)
|
|
// if(this.type==1 ){
|
|
// this.is_destroy=true
|
|
// }
|
|
}
|
|
}
|
|
onPostSolve (selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {
|
|
|
|
}
|
|
update(deltaTime: number) {
|
|
|
|
this.toDestroy()
|
|
|
|
}
|
|
toDestroy() {
|
|
if(this.is_destroy){
|
|
this.ent.destroy()
|
|
}
|
|
}
|
|
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
|
reset() {
|
|
this.is_destroy=false
|
|
this.node.destroy();
|
|
}
|
|
|
|
} |