改了 好多
This commit is contained in:
@@ -1,16 +1,18 @@
|
||||
import { _decorator,Collider2D ,Contact2DType,v3,IPhysics2DContact,Vec3, tween, math, RigidBody2D, Animation, sp} from "cc";
|
||||
import { _decorator,Collider2D ,Contact2DType,v3,IPhysics2DContact,Vec3, tween, math, RigidBody2D, Animation, sp, Tween} 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 { AType, EType, RType, SkillSet } from "../common/config/SkillSet";
|
||||
import { BoxSet } from "../common/config/BoxSet";
|
||||
import { BoxSet, FacSet } 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";
|
||||
import { FightSet } from "../common/config/Mission";
|
||||
import { HeroModelComp } from "../hero/HeroModelComp";
|
||||
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
@@ -41,10 +43,15 @@ export class SkillCom extends CCComp {
|
||||
distance_y:number=0;
|
||||
ap:number=0;
|
||||
FIGHTCON:FightConComp=null;
|
||||
run_time:number=0;
|
||||
hited_time:number=0;
|
||||
hit_count:number=0;
|
||||
spine:sp.Skeleton=null;
|
||||
anim:Animation=null;
|
||||
tweenInstance:Tween<any> = null;
|
||||
t_end_x:number=0;
|
||||
caster_crt:number=0;
|
||||
caster_crt_d:number=0;
|
||||
private moveDirection: Vec3 | null = null; // 添加一个属性来存储移动方向
|
||||
|
||||
protected onLoad(): void {
|
||||
@@ -53,6 +60,8 @@ export class SkillCom extends CCComp {
|
||||
}
|
||||
|
||||
start() {
|
||||
|
||||
this.node.setPosition(this.startPos.x,this.startPos.y,0)
|
||||
if(this.node.getChildByName('anm')){
|
||||
this.spine=this.node.getChildByName('anm').getComponent('sp.Skeleton') as sp.Skeleton;
|
||||
}else{
|
||||
@@ -60,6 +69,19 @@ export class SkillCom extends CCComp {
|
||||
}
|
||||
oops.message.on(GameEvent.MissionEnd, this.doDestroy, this);
|
||||
this.node.active = true;
|
||||
console.log("[SkillCom]:caster",this.caster)
|
||||
if(this.caster.fac==FacSet.HERO){
|
||||
if(this.caster.is_master){
|
||||
this.caster_crt = this.caster.crt+this.FIGHTCON.hero_buff.CRITICAL+this.FIGHTCON.hero_debuff.CRITICAL
|
||||
this.caster_crt_d = this.caster.crt_d+this.FIGHTCON.hero_buff.CRITICAL_DMG
|
||||
}else{
|
||||
this.caster_crt = this.caster.crt+this.FIGHTCON.friend_buff.CRITICAL+this.FIGHTCON.hero_debuff.CRITICAL
|
||||
this.caster_crt_d = this.caster.crt_d+this.FIGHTCON.friend_buff.CRITICAL_DMG
|
||||
}
|
||||
}else{
|
||||
this.caster_crt = this.caster.crt+this.FIGHTCON.enemy_buff.CRITICAL+this.FIGHTCON.enemy_debuff.CRITICAL
|
||||
this.caster_crt_d = this.caster.crt_d+this.FIGHTCON.enemy_buff.CRITICAL_DMG
|
||||
}
|
||||
let collider = this.getComponent(Collider2D);
|
||||
if(collider) {
|
||||
collider.group = this.group;
|
||||
@@ -71,22 +93,21 @@ export class SkillCom extends CCComp {
|
||||
this.node.angle +=10
|
||||
let bm=this.node.getComponent(BezierMove)
|
||||
// bm.speed=700
|
||||
if(this.group==BoxSet.MONSTER) bm.controlPointSide=-1
|
||||
if(SkillSet[this.s_uuid].RType==RType.linear) bm.controlPointOffset=0
|
||||
|
||||
if(this.group==BoxSet.MONSTER) bm.controlPointSide=-1
|
||||
bm.moveTo(this.targetPos)
|
||||
break;
|
||||
case AType.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()
|
||||
// this.distance_x=SkillSet[this.s_uuid].in*this.speed
|
||||
// this.t_end_x =400
|
||||
// if(this.group==BoxSet.MONSTER){
|
||||
// this.t_end_x=-400
|
||||
// this.node.scale=v3(this.node.scale.x*-1,1,1)
|
||||
// }
|
||||
// this.tweenInstance = tween(this.node).to(SkillSet[this.s_uuid].in, { position:v3(this.t_end_x,this.node.position.y,0)},{
|
||||
// onComplete: (target?: object) => {
|
||||
// // this.node.setPosition(tx,this.node.position.y-300,0)
|
||||
// }
|
||||
// }).start()
|
||||
break;
|
||||
case AType.fixedStart:
|
||||
|
||||
@@ -95,15 +116,15 @@ export class SkillCom extends CCComp {
|
||||
this.node.setPosition(this.targetPos.x,this.targetPos.y,0)
|
||||
if(this.node.getComponent(Animation)){
|
||||
let anim = this.node.getComponent(Animation);
|
||||
console.log("has anim",anim)
|
||||
anim.on(Animation.EventType.FINISHED, this.onAnimationFinishedToDestroy, this);
|
||||
console.log("[SkillCom]:has anim",anim)
|
||||
anim.on(Animation.EventType.FINISHED, this.onAnimationFinished, this);
|
||||
}
|
||||
if(this.node.getChildByName('anm')){
|
||||
if(this.node.getChildByName('anm').getComponent('sp.Skeleton')){
|
||||
console.log("has spine",this.spine)
|
||||
console.log("[SkillCom]:has spine",this.spine)
|
||||
this.spine.setCompleteListener((trackEntry) => {
|
||||
this.onAnimationFinishedToDestroy()
|
||||
console.log("[track %s][animation %s] complete: %s", trackEntry.trackIndex);
|
||||
this.onAnimationFinished()
|
||||
console.log("[SkillCom]:[track %s][animation %s] complete: %s", trackEntry.trackIndex);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -112,55 +133,56 @@ export class SkillCom extends CCComp {
|
||||
|
||||
|
||||
}
|
||||
onAnimationFinishedToDestroy(){
|
||||
|
||||
|
||||
onAnimationFinished(){
|
||||
if(SkillSet[this.s_uuid].EType==EType.timeEnd) return
|
||||
this.is_destroy=true
|
||||
}
|
||||
onAnimationFinished(){
|
||||
//范围伤害
|
||||
range_damage(){
|
||||
this.hit_count++
|
||||
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)
|
||||
|
||||
if(this.fac==FacSet.MON) enemys=ecs.query(ecs.allOf(HeroModelComp))
|
||||
enemys.forEach(entity => {
|
||||
let view=entity.get(HeroViewComp)
|
||||
if(view){
|
||||
let dis =Math.abs(this.node.position.x-view.node.position.x)
|
||||
if(dis > SkillSet[this.s_uuid].with) return
|
||||
view.do_atked(remainingDamage)
|
||||
view.do_atked(this.ap,this.caster_crt,this.caster_crt_d)
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
onBeginContact (seCol: Collider2D, oCol: Collider2D) {
|
||||
//单体伤害
|
||||
single_damage(target:HeroViewComp,crt:number=0,crt_d:number=0){
|
||||
this.hit_count++
|
||||
console.log("[SkillCom]:onBeginContact hit_count:",this.hit_count,SkillSet[this.s_uuid].hit)
|
||||
if(this.hit_count>=SkillSet[this.s_uuid].hit) this.is_destroy=true // 技能命中次数
|
||||
if(target == null) return;
|
||||
target.do_atked(this.ap,crt,crt_d)
|
||||
if(SkillSet[this.s_uuid].debuff>0){
|
||||
target.add_debuff(SkillSet[this.s_uuid].debuff,SkillSet[this.s_uuid].deV,SkillSet[this.s_uuid].deC)
|
||||
}
|
||||
}
|
||||
|
||||
onBeginContact (seCol: Collider2D, oCol: Collider2D) {
|
||||
// console.log(this.scale+"碰撞开始 ",seCol,oCol);
|
||||
let target = oCol.getComponent(HeroViewComp)
|
||||
let caster = seCol.getComponent(HeroViewComp)
|
||||
if(oCol.group!=this.group){
|
||||
if(target == null) return;
|
||||
let remainingDamage = this.ap;
|
||||
if(target.fac == BoxSet.HERO ){
|
||||
remainingDamage=remainingDamage*(100-this.FIGHTCON.hero_buff.DEF+this.FIGHTCON.hero_debuff.BURN)/100
|
||||
}
|
||||
if(target.fac == BoxSet.MONSTER){
|
||||
remainingDamage=remainingDamage*(100-this.FIGHTCON.enemy_buff.DEF+this.FIGHTCON.enemy_debuff.BURN)/100
|
||||
}
|
||||
target.do_atked(remainingDamage)
|
||||
this.ent.destroy()
|
||||
this.single_damage(target,this.caster_crt,this.caster_crt_d)
|
||||
// this.ent.destroy()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private startLinearMove(dt: number) {
|
||||
if (!this.speed || this.is_destroy) return;
|
||||
|
||||
// 使用角度方向移动
|
||||
const newX = this.node.position.x + this.distance_x * dt;
|
||||
const newY = this.node.position.y + this.distance_y * dt;
|
||||
this.node.setPosition(newX, newY, this.node.position.z);
|
||||
const newX = this.node.position.x + this.speed * dt;
|
||||
const newY = this.node.position.y;
|
||||
this.node.setPosition(newX, this.node.position.y, this.node.position.z);
|
||||
|
||||
// 检查是否超出边界
|
||||
if (newX < -400 || newX > 400) {
|
||||
@@ -169,10 +191,6 @@ export class SkillCom extends CCComp {
|
||||
}
|
||||
|
||||
|
||||
to_console(value:any,value2:any=null,value3:any=null){
|
||||
console.log("["+this.s_name+this.s_uuid+"]:",value,value2,value3)
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
let config=SkillSet[this.s_uuid]
|
||||
if(smc.mission.pause) {
|
||||
@@ -183,14 +201,24 @@ export class SkillCom extends CCComp {
|
||||
if(this.anim) this.anim.resume()
|
||||
if(this.spine) this.spine.paused=false
|
||||
if (!this.node || !this.node.isValid) return;
|
||||
this.hited_time+=deltaTime
|
||||
if(this.hited_time>config.hited&&this.AType==AType.fixedEnd&&this.hit_count == 0){
|
||||
this.hited_time=0
|
||||
this.onAnimationFinished()
|
||||
if(config.EType==EType.timeEnd){
|
||||
this.run_time+=deltaTime
|
||||
if(this.run_time>config.in){
|
||||
console.log("[SkillCom]: timeEnd destroy",this.s_uuid,this.run_time)
|
||||
this.is_destroy=true
|
||||
}
|
||||
}
|
||||
// if(this.AType == AType.linear) this.startLinearMove(deltaTime);
|
||||
//范围伤害
|
||||
this.hited_time+=deltaTime
|
||||
if(this.hited_time>config.hited&&this.hit_count == 0&&(config.EType==EType.animationEnd||config.EType==EType.timeEnd)){
|
||||
this.hited_time=0
|
||||
this.range_damage()
|
||||
}
|
||||
//直线移动
|
||||
if(this.AType == AType.linear) this.startLinearMove(deltaTime);
|
||||
this.toDestroy();
|
||||
}
|
||||
|
||||
toDestroy() {
|
||||
if(this.is_destroy){
|
||||
if (this.ent) {
|
||||
@@ -204,9 +232,13 @@ export class SkillCom extends CCComp {
|
||||
}
|
||||
}
|
||||
doDestroy(){
|
||||
// console.log("doDestroy")
|
||||
// console.log("[SkillCom]:doDestroy")
|
||||
this.is_destroy=true
|
||||
}
|
||||
to_console(value:any,value2:any=null,value3:any=null){
|
||||
console.log("[SkillCom]:["+this.s_name+this.s_uuid+"]:",value,value2,value3)
|
||||
}
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.is_destroy = false;
|
||||
|
||||
Reference in New Issue
Block a user