装备和技能获取逻辑改变
This commit is contained in:
@@ -6,7 +6,6 @@ import { SkillSet } from "../common/config/SkillSet";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { oops } from "db://oops-framework/core/Oops";
|
||||
import { MissionEvent } from "../common/config/MissionEvent";
|
||||
import { EquipsComp } from "./EquipsComp";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -17,23 +16,35 @@ export class EquipSkillComp extends CCComp {
|
||||
skill1:any=null
|
||||
skill2:any=null
|
||||
skill3:any=null
|
||||
equips:EquipsComp=null
|
||||
boxs:Node=null
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
onLoad() {
|
||||
this.on(GameEvent.UseSkillCard, this.get_skill, this);
|
||||
this.on(GameEvent.FightReady,this.fight_ready,this)
|
||||
this.on(GameEvent.SKILL_SHOW,this.do_skill_show,this)
|
||||
this.boxs=this.node.getChildByName("boxs")
|
||||
this.equips=this.node.getComponent(EquipsComp)
|
||||
}
|
||||
start(){
|
||||
this.fight_ready()
|
||||
this.equips=this.node.getComponent(EquipsComp)
|
||||
}
|
||||
do_skill_show(e:GameEvent,data:any){
|
||||
console.log("[EquipSkillComp]: do_skill_show",data)
|
||||
this.show_skill_get("skill1")
|
||||
this.show_skill_get("skill2")
|
||||
this.show_skill_get("skill3")
|
||||
}
|
||||
fight_ready(){
|
||||
this.boxs=this.node.getChildByName("boxs")
|
||||
console.log("[EquipSkillComp]: fight_ready",this.node)
|
||||
this.boxs.getChildByName("skill1").getChildByName("icon").active=false
|
||||
this.boxs.getChildByName("skill2").getChildByName("icon").active=false
|
||||
this.boxs.getChildByName("skill3").getChildByName("icon").active=false
|
||||
this.hide_skill_get(null,"skill1")
|
||||
this.hide_skill_get(null,"skill2")
|
||||
this.hide_skill_get(null,"skill3")
|
||||
this.hide_skill_change(null,"skill1")
|
||||
this.hide_skill_change(null,"skill2")
|
||||
this.hide_skill_change(null,"skill3")
|
||||
this.skill1={
|
||||
uuid:0,
|
||||
name:"skill1",
|
||||
@@ -65,7 +76,7 @@ export class EquipSkillComp extends CCComp {
|
||||
update(dt: number): void {
|
||||
if(!smc.mission.play||smc.mission.pause) return
|
||||
if(this.skill1.uuid!=0){
|
||||
if(this.skill1.cd_time < (this.skill1.cd-this.equips.attrs.hero_buff.SKILL_CD)){
|
||||
if(this.skill1.cd_time < (this.skill1.cd)){
|
||||
this.skill1.cd_time+=dt
|
||||
}else{
|
||||
this.skill1.cd_time=0
|
||||
@@ -76,7 +87,7 @@ export class EquipSkillComp extends CCComp {
|
||||
this.boxs.getChildByName("skill1").getChildByName("icon").getChildByName("cd").getComponent(ProgressBar).progress=(1-this.skill1.cd_time/this.skill1.cd)
|
||||
}
|
||||
if(this.skill2.uuid!=0){
|
||||
if(this.skill2.cd_time < (this.skill2.cd-this.equips.attrs.hero_buff.SKILL_CD)){
|
||||
if(this.skill2.cd_time < (this.skill2.cd)){
|
||||
this.skill2.cd_time+=dt
|
||||
}else{
|
||||
this.skill2.cd_time=0
|
||||
@@ -87,7 +98,7 @@ export class EquipSkillComp extends CCComp {
|
||||
this.boxs.getChildByName("skill2").getChildByName("icon").getChildByName("cd").getComponent(ProgressBar).progress=(1-this.skill2.cd_time/this.skill2.cd)
|
||||
}
|
||||
if(this.skill3.uuid!=0){
|
||||
if(this.skill3.cd_time < (this.skill3.cd-this.equips.attrs.hero_buff.SKILL_CD)){
|
||||
if(this.skill3.cd_time < (this.skill3.cd)){
|
||||
this.skill3.cd_time+=dt
|
||||
}else{
|
||||
this.skill3.cd_time=0
|
||||
@@ -137,7 +148,7 @@ export class EquipSkillComp extends CCComp {
|
||||
this.skill1.type=1
|
||||
this.skill1.cd=SkillSet[data.uuid].cd
|
||||
this.skill1.cd_time=SkillSet[data.uuid].cd
|
||||
let icon1 = this.node.getChildByName("boxs").getChildByName("skill1").getChildByName("icon")
|
||||
let icon1 = this.boxs.getChildByName("skill1").getChildByName("icon")
|
||||
icon1.active=true
|
||||
var icon_path = "game/skills/skill_icon"
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
@@ -151,7 +162,7 @@ export class EquipSkillComp extends CCComp {
|
||||
this.skill2.type=1
|
||||
this.skill2.cd=SkillSet[data.uuid].cd
|
||||
this.skill2.cd_time=SkillSet[data.uuid].cd
|
||||
let icon2 = this.node.getChildByName("boxs").getChildByName("skill2").getChildByName("icon")
|
||||
let icon2 = this.boxs.getChildByName("skill2").getChildByName("icon")
|
||||
icon2.active=true
|
||||
var icon_path = "game/skills/skill_icon"
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
@@ -165,7 +176,7 @@ export class EquipSkillComp extends CCComp {
|
||||
this.skill3.type=1
|
||||
this.skill3.cd=SkillSet[data.uuid].cd
|
||||
this.skill3.cd_time=SkillSet[data.uuid].cd
|
||||
let icon = this.node.getChildByName("boxs").getChildByName("skill3").getChildByName("icon")
|
||||
let icon = this.boxs.getChildByName("skill3").getChildByName("icon")
|
||||
icon.active=true
|
||||
var icon_path = "game/skills/skill_icon"
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
@@ -176,6 +187,24 @@ export class EquipSkillComp extends CCComp {
|
||||
}
|
||||
}
|
||||
|
||||
private show_skill_get(e:string){
|
||||
this.boxs.getChildByName(e).getChildByName("get").active =true
|
||||
}
|
||||
|
||||
private hide_skill_get(e:any,data:string){
|
||||
this.boxs.getChildByName(data).getChildByName("get").active =false
|
||||
}
|
||||
|
||||
private show_skill_change(e:string){
|
||||
this.boxs.getChildByName(e).getChildByName("change").active =true
|
||||
}
|
||||
|
||||
private hide_skill_change(e:any,data:any){
|
||||
this.boxs.getChildByName(data).getChildByName("change").active =false
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
|
||||
Reference in New Issue
Block a user