技能重构开始
This commit is contained in:
97
assets/script/game/skill/SkillViewCom.ts
Normal file
97
assets/script/game/skill/SkillViewCom.ts
Normal file
@@ -0,0 +1,97 @@
|
||||
import { _decorator } 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";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@ccclass('SkillViewCom')
|
||||
@ecs.register('SkillView', false)
|
||||
export class SkillViewCom extends CCComp {
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
@property({ type: Boolean })
|
||||
hasReady: boolean = false;
|
||||
@property({ type: Number })
|
||||
ReadyTime: number = 0;
|
||||
@property({ type: Number })
|
||||
postion_y: number = 0;
|
||||
|
||||
s_uuid:number=0;
|
||||
s_count:number=1;
|
||||
s_interval:number=0.2;
|
||||
s_cd:number=0;
|
||||
caster:HeroViewComp=null;
|
||||
target:HeroViewComp=null;
|
||||
parent:Node=null;
|
||||
target_postions:any[]=null
|
||||
// 战斗相关运行时数据
|
||||
ap:number=0;
|
||||
burn_count:number=0;
|
||||
burn_value:number=0;
|
||||
stun_time:number=0;
|
||||
stun_ratio:number=0;
|
||||
frost_ratio:number=0;
|
||||
frost_time:number=0;
|
||||
run_time:number=0;
|
||||
hited_time:number=0;
|
||||
hit_count:number=0;
|
||||
caster_crit:number=0;
|
||||
caster_crit_d:number=0;
|
||||
puncture:number=0;
|
||||
puncture_damage:number=0;
|
||||
debuff_up:number=0;
|
||||
debuff_value:number=0;
|
||||
debuff_count:number=0;
|
||||
|
||||
start() {
|
||||
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
|
||||
// this.on(ModuleEvent.Cmd, this.onHandler, this);
|
||||
}
|
||||
protected update(dt: number): void {
|
||||
if(this.hasReady) {
|
||||
this.doTimer(dt)
|
||||
if(this.ReadyTime <= 0) {
|
||||
this.doAtk(dt)
|
||||
}
|
||||
}{
|
||||
this.doAtk(dt)
|
||||
}
|
||||
this.move(dt)
|
||||
}
|
||||
|
||||
doTimer(dt: number){
|
||||
if(this.ReadyTime <= 0) return
|
||||
this.ReadyTime -= dt
|
||||
}
|
||||
doAtk(dt:number): void {
|
||||
if(this.s_cd <= 0&&this.s_count > 0) {
|
||||
this.doSkill()
|
||||
this.s_count--
|
||||
this.s_cd = this.s_interval
|
||||
}
|
||||
this.s_cd -= dt
|
||||
}
|
||||
doSkill(){
|
||||
console.log("doSkill")
|
||||
}
|
||||
move(dt: number): void {
|
||||
if(this.caster == null) return
|
||||
if(this.caster.is_dead) return
|
||||
if(this.caster.node.isValid) return
|
||||
this.node.setPosition(this.caster.node.position.x,this.caster.node.position.y+this.postion_y)
|
||||
console.log("[skillview]move",this.caster.node.position,this.node.position)
|
||||
}
|
||||
/** 全局消息逻辑处理 */
|
||||
// private onHandler(event: string, args: any) {
|
||||
// switch (event) {
|
||||
// case ModuleEvent.Cmd:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user