mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 03:14:47 +00:00
68 lines
1.4 KiB
TypeScript
68 lines
1.4 KiB
TypeScript
import { TableGRoleSkill } from "../../../resources/config/ts/TableGRoleSkill";
|
|
import GRoleBase from "../base/role/GRoleBase";
|
|
import { GSkillBase, GSkillState } from "./GSkill";
|
|
|
|
|
|
//冷却技能基类 用于多长时间释放技能
|
|
export default abstract class GSkillCDBase implements GSkillBase {
|
|
|
|
//冷却总时间
|
|
cdTatal:number = 0;
|
|
//冷却时间
|
|
cdTime:number = 0;
|
|
|
|
bind(role:GRoleBase<{}>,info: TableGRoleSkill):GSkillCDBase {
|
|
return this;
|
|
}
|
|
|
|
//是否可以释放技能
|
|
isRelease(): boolean {
|
|
return this.cdTime >= this.cdTatal;
|
|
}
|
|
|
|
//释放技能
|
|
release():boolean {
|
|
//是否可以释放技能
|
|
if(!this.isRelease()) return false;
|
|
this.cdTime = 0;
|
|
return this.onRelease();
|
|
}
|
|
|
|
//子类实现释放
|
|
abstract onRelease():boolean;
|
|
|
|
//查询状态
|
|
state(): GSkillState {
|
|
|
|
if(this.isReleasing()){
|
|
return GSkillState.Releasing
|
|
}
|
|
|
|
if(this.isRelease())
|
|
return GSkillState.Releasable
|
|
else
|
|
return GSkillState.NoRelease
|
|
|
|
}
|
|
|
|
//是否正在释放技能
|
|
isReleasing(): boolean{
|
|
return false;
|
|
}
|
|
|
|
//更新
|
|
onUpdate(dt:number){
|
|
|
|
if(this.state() == GSkillState.NoRelease){
|
|
this.cdTime += (dt / 1000);
|
|
}
|
|
|
|
}
|
|
|
|
//返回进度
|
|
getProgress():number{
|
|
return this.cdTime / this.cdTatal;
|
|
}
|
|
|
|
}
|