aoe ++
This commit is contained in:
@@ -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