技能cd完成
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { _decorator, resources, Sprite, SpriteAtlas } from "cc";
|
||||
import { _decorator, Label, ProgressBar, resources, Sprite, SpriteAtlas } 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 { SkillSet } from "../common/config/SkillSet";
|
||||
@@ -15,14 +15,17 @@ export class MSkillComp extends CCComp {
|
||||
group: number = 0;
|
||||
lv:number = 0;
|
||||
skill_on:boolean = false;
|
||||
cd:number = 0;
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
start() {
|
||||
console.log("MSkillComp start s_uuid:",this.s_uuid,this.group);
|
||||
}
|
||||
init(){
|
||||
this.lv=0
|
||||
console.log("MSkillComp init s_uuid:",this.s_uuid,this.group);
|
||||
this.node.getChildByName("lv").getComponent(Label).string=this.lv.toString()
|
||||
if(SkillSet[this.s_uuid]==undefined){this.skill_on=false; return}
|
||||
|
||||
this.cd=SkillSet[this.s_uuid].cd;
|
||||
this.s_uuid=smc.mission.mskill
|
||||
smc.vmdata.mission.exp_max=SkillSet[this.s_uuid].exp
|
||||
|
||||
@@ -42,7 +45,17 @@ export class MSkillComp extends CCComp {
|
||||
protected update(dt: number): void {
|
||||
if(!this.skill_on) return
|
||||
this.check_exp()
|
||||
this.doing_cd(dt)
|
||||
}
|
||||
doing_cd(dt: number){
|
||||
this.cd-=dt
|
||||
this.node.getChildByName("cd").getComponent(ProgressBar).progress=this.cd/SkillSet[this.s_uuid].cd
|
||||
if(this.cd<=0){
|
||||
console.log("cd<=0")
|
||||
this.cd=SkillSet[this.s_uuid].cd
|
||||
}
|
||||
}
|
||||
|
||||
check_exp(){
|
||||
switch(this.group){
|
||||
case BoxSet.HERO:
|
||||
@@ -61,7 +74,8 @@ export class MSkillComp extends CCComp {
|
||||
}
|
||||
}
|
||||
lvup(){
|
||||
console.log("MSkillComp lvup s_uuid:",this.s_uuid,this.group);
|
||||
this.lv++
|
||||
this.node.getChildByName("lv").getComponent(Label).string=this.lv.toString()
|
||||
}
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
|
||||
Reference in New Issue
Block a user