继续技能系统重构
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import { _decorator, instantiate, Node, Prefab } from "cc";
|
||||
import { _decorator, instantiate, Node, Prefab, v3, Vec3 } 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 { HeroViewComp } from "../hero/HeroViewComp";
|
||||
import { BuffAttr, RType, SkillSet } from "../common/config/SkillSet";
|
||||
import { AtkConCom } from "./AtkConCom";
|
||||
import { BoxSet } from "../common/config/BoxSet";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -21,17 +22,26 @@ export class SkillViewCom extends CCComp {
|
||||
@property({ type: Number })
|
||||
ReadyTime: number = 0;
|
||||
@property({ type: Number })
|
||||
postion_y: number = 0;
|
||||
ready_y: number = 0;
|
||||
@property({ type: Number })
|
||||
atk_x: number = 0;
|
||||
@property({ type: Number })
|
||||
atk_y: number = 0;
|
||||
|
||||
endTime: number = 0;
|
||||
readyFinish: boolean = false;
|
||||
caster:HeroViewComp=null!;
|
||||
s_uuid:number=0;
|
||||
s_count:number=1;
|
||||
s_interval:number=0.2;
|
||||
s_cd:number=0;
|
||||
caster:HeroViewComp=null;
|
||||
scale: number = 0;
|
||||
cName:string="";
|
||||
target:HeroViewComp=null;
|
||||
parent:Node=null;
|
||||
target_postions:any[]=null
|
||||
group:0
|
||||
fac: 0
|
||||
// 战斗相关运行时数据
|
||||
ap:number=0;
|
||||
burn_count:number=0;
|
||||
@@ -53,20 +63,13 @@ export class SkillViewCom extends CCComp {
|
||||
targetPos:any[]=null
|
||||
start() {
|
||||
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
|
||||
this.cName = this.caster.hero_name
|
||||
this.node.getChildByName("ready").active = this.hasReady
|
||||
}
|
||||
protected update(dt: number): void {
|
||||
this.doTimer(dt)
|
||||
this.move(dt)
|
||||
this.doEnd(dt)
|
||||
if(this.hasReady) {
|
||||
if(this.ReadyTime <= 0) {
|
||||
this.doAtk(dt)
|
||||
}
|
||||
}{
|
||||
this.doAtk(dt)
|
||||
}
|
||||
if(this.readyFinish) this.doAtk(dt)
|
||||
}
|
||||
doEnd(dt: number) {
|
||||
this.endTime += dt
|
||||
@@ -76,7 +79,8 @@ export class SkillViewCom extends CCComp {
|
||||
}
|
||||
|
||||
doTimer(dt: number){
|
||||
if(this.ReadyTime > 0&&this.hasReady) this.ReadyTime -= dt
|
||||
if(this.ReadyTime > 0) this.ReadyTime -= dt
|
||||
if(this.ReadyTime <=0) this.readyFinish=true
|
||||
}
|
||||
doAtk(dt:number): void {
|
||||
// console.log(`${this.cName}_[SkillViewCom] doAtkC`)
|
||||
@@ -88,37 +92,46 @@ export class SkillViewCom extends CCComp {
|
||||
if(this.s_cd > 0) this.s_cd -= dt
|
||||
}
|
||||
doSkill(){
|
||||
console.log(`${this.cName}_[SkillViewCom] doSkill`,this.atkPrefab)
|
||||
// console.log(`${this.cName}_[SkillViewCom] doSkill`,this.atkPrefab)
|
||||
if(this.atkPrefab!=null){
|
||||
let atkNode:Node = instantiate(this.atkPrefab)
|
||||
atkNode.parent = this.node.parent
|
||||
atkNode.setPosition(this.node.position)
|
||||
atkNode.setPosition(v3(this.node.position.x + this.atk_x*this.scale, this.node.position.y + this.atk_y))
|
||||
// console.log(`${this.cName}_[SkillViewCom] doSkill atkNode`,this.node.position,atkNode.position)
|
||||
let atkCom=atkNode.getComponent(AtkConCom)
|
||||
// 计算延长后的目标点坐标
|
||||
const originalStart = v3(this.node.position.x + this.atk_x, this.node.position.y + this.atk_y);
|
||||
const originalTarget = v3(this.targetPos[0].x, this.targetPos[0].y + BoxSet.ATK_Y);
|
||||
const direction = new Vec3();
|
||||
Vec3.subtract(direction, originalTarget, originalStart);
|
||||
const distance = direction.length();
|
||||
direction.normalize();
|
||||
const extendedTarget = new Vec3();
|
||||
Vec3.scaleAndAdd(extendedTarget, originalTarget, direction, 720);
|
||||
Object.assign(atkCom, {
|
||||
// 核心标识
|
||||
s_uuid: this.s_uuid,
|
||||
// 位置和施法者信息
|
||||
startPos: this.node.position,
|
||||
targetPos: this.targetPos[0],
|
||||
group: this.caster.box_group,
|
||||
fac: this.caster.fac,
|
||||
// 技能数值
|
||||
ap: this.caster.Attrs[BuffAttr.AP],
|
||||
caster: this.caster,
|
||||
caster_crit: this.caster.Attrs[BuffAttr.CRITICAL],
|
||||
caster_crit_d: this.caster.Attrs[BuffAttr.CRITICAL_DMG],
|
||||
puncture: this.caster.Attrs[BuffAttr.PUNCTURE],
|
||||
puncture_damage: this.caster.Attrs[BuffAttr.PUNCTURE_DMG],
|
||||
burn_count: this.caster.Attrs[BuffAttr.BURN_COUNT],
|
||||
burn_value: this.caster.Attrs[BuffAttr.BURN_VALUE],
|
||||
stun_time: this.caster.Attrs[BuffAttr.STUN_TIME],
|
||||
stun_ratio: this.caster.Attrs[BuffAttr.STUN_RATIO],
|
||||
frost_time: this.caster.Attrs[BuffAttr.FROST_TIME],
|
||||
frost_ratio: this.caster.Attrs[BuffAttr.FROST_RATIO],
|
||||
debuff_up: this.caster.Attrs[BuffAttr.DEBUFF_UP],
|
||||
debuff_value: this.caster.Attrs[BuffAttr.DEBUFF_VALUE],
|
||||
debuff_count: this.caster.Attrs[BuffAttr.DEBUFF_COUNT],
|
||||
});
|
||||
// 核心标识
|
||||
s_uuid: this.s_uuid,
|
||||
// 位置和施法者信息
|
||||
startPos: originalStart,
|
||||
targetPos: extendedTarget,
|
||||
group: this.group,
|
||||
fac: this.fac,
|
||||
// 技能数值
|
||||
ap: this.ap,
|
||||
caster_crit: this.caster_crit,
|
||||
caster_crit_d: this.caster_crit_d,
|
||||
puncture: this.puncture,
|
||||
puncture_damage: this.puncture_damage,
|
||||
burn_count: this.burn_count,
|
||||
burn_value: this.burn_value,
|
||||
stun_time: this.stun_time,
|
||||
stun_ratio: this.stun_ratio,
|
||||
frost_time: this.frost_time,
|
||||
frost_ratio: this.frost_ratio,
|
||||
debuff_up: this.debuff_up,
|
||||
debuff_value: this.debuff_value,
|
||||
debuff_count: this.debuff_count,
|
||||
});
|
||||
switch(this.runType){
|
||||
case RType.linear:
|
||||
this.do_linear(atkNode)
|
||||
@@ -133,10 +146,12 @@ export class SkillViewCom extends CCComp {
|
||||
}
|
||||
}
|
||||
do_linear(atkNode:any): void {
|
||||
console.log(`${this.cName}_[SkillViewCom] skille run type: linear`)
|
||||
console.log(`${this.cName}_[SkillViewCom] skille run type: linear`,this.node.position,atkNode.position)
|
||||
atkNode.getComponent(AtkConCom).do_line()
|
||||
}
|
||||
do_bezier(atkNode:any): void {
|
||||
console.log(`${this.cName}_[SkillViewCom] skille run type: bezier`)
|
||||
atkNode.getComponent(AtkConCom).do_parabolic()
|
||||
}
|
||||
do_fixed(atkNode:any): void {
|
||||
console.log(`${this.cName}_[SkillViewCom] skille run type: fixed`)
|
||||
@@ -145,8 +160,8 @@ export class SkillViewCom extends CCComp {
|
||||
|
||||
move(dt: number): void {
|
||||
// console.log(`${this.cName}_[SkillViewCom] move`)
|
||||
if(this.caster != null&&this.caster.node!=null) this.node.setPosition(this.caster.node.position.x,this.caster.node.position.y+this.postion_y)
|
||||
// console.log(`${this.cName}_[skillview]move`,this.caster.node.position,this.node.position)
|
||||
if(this.caster != null&&this.caster.node!=null) this.node.setPosition(this.caster.node.position.x,this.caster.node.position.y+this.ready_y)
|
||||
// console.log(`${this.cName}_[skillview]move`,this.caster.node.position,this.node.position)
|
||||
}
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
|
||||
Reference in New Issue
Block a user