装备和技能获取逻辑改变
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();
|
||||
|
||||
@@ -12,9 +12,6 @@ export class EquipsComp extends Component {
|
||||
weapon:any=null
|
||||
armor:any=null
|
||||
accessory:any=null
|
||||
skill1:any=null
|
||||
skill2:any=null
|
||||
skill3:any=null
|
||||
boxs:Node=null
|
||||
attrs:any={
|
||||
hero_buff:getBuffNum(),
|
||||
@@ -27,11 +24,25 @@ export class EquipsComp extends Component {
|
||||
oops.message.on(GameEvent.EquipAdd,this.equip_add,this)
|
||||
oops.message.on(GameEvent.EquipRemove,this.equip_remove,this)
|
||||
this.boxs=this.node.getChildByName("boxs")
|
||||
oops.message.on(GameEvent.EQUIP_SHOW,this.do_equip_show,this)
|
||||
|
||||
}
|
||||
do_equip_show(e:GameEvent,data:any){
|
||||
console.log("[EquipsComp]:do_equip_show",data)
|
||||
this.show_equip_get("weapon")
|
||||
this.show_equip_get("armor")
|
||||
this.show_equip_get("accessory")
|
||||
}
|
||||
start(){
|
||||
this.fight_ready()
|
||||
}
|
||||
fight_ready(){
|
||||
this.hide_equip_get(null,"weapon")
|
||||
this.hide_equip_get(null,"armor")
|
||||
this.hide_equip_get(null,"accessory")
|
||||
this.hide_equip_change(null,"weapon")
|
||||
this.hide_equip_change(null,"armor")
|
||||
this.hide_equip_change(null,"accessory")
|
||||
this.boxs.getChildByName("weapon").getChildByName("icon").active=false
|
||||
this.boxs.getChildByName("armor").getChildByName("icon").active=false
|
||||
this.boxs.getChildByName("accessory").getChildByName("icon").active=false
|
||||
@@ -81,7 +92,7 @@ export class EquipsComp extends Component {
|
||||
this.count_attrs()
|
||||
}
|
||||
show_weapon(uuid:number){
|
||||
let icon = this.node.getChildByName("boxs").getChildByName("weapon").getChildByName("icon")
|
||||
let icon = this.boxs.getChildByName("weapon").getChildByName("icon")
|
||||
icon.active=true
|
||||
var icon_path = "game/heros/equips"
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
@@ -91,7 +102,7 @@ export class EquipsComp extends Component {
|
||||
|
||||
}
|
||||
show_armor(uuid:number){
|
||||
let icon = this.node.getChildByName("boxs").getChildByName("armor").getChildByName("icon")
|
||||
let icon = this.boxs.getChildByName("armor").getChildByName("icon")
|
||||
icon.active=true
|
||||
var icon_path = "game/heros/equips"
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
@@ -100,7 +111,7 @@ export class EquipsComp extends Component {
|
||||
});
|
||||
}
|
||||
show_accessory(uuid:number){
|
||||
let icon = this.node.getChildByName("boxs").getChildByName("accessory").getChildByName("icon")
|
||||
let icon = this.boxs.getChildByName("accessory").getChildByName("icon")
|
||||
icon.active=true
|
||||
var icon_path = "game/heros/equips"
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
@@ -240,6 +251,24 @@ export class EquipsComp extends Component {
|
||||
update(dt: number): void {
|
||||
if(!smc.mission.play||smc.mission.pause) return
|
||||
}
|
||||
|
||||
private show_equip_get(e:string){
|
||||
|
||||
this.boxs.getChildByName(e).getChildByName("get").active =true
|
||||
}
|
||||
|
||||
private hide_equip_get(e:any,data:string){
|
||||
this.boxs.getChildByName(data).getChildByName("get").active =false
|
||||
}
|
||||
|
||||
private show_equip_change(e:string){
|
||||
this.boxs.getChildByName(e).getChildByName("change").active =true
|
||||
}
|
||||
|
||||
private hide_equip_change(e:any,data:any){
|
||||
this.boxs.getChildByName(data).getChildByName("change").active =false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ export class MissionComp extends CCComp {
|
||||
smc.vmdata.mission_data.gold+=(smc.vmdata.mission_data.add_gold+smc.vmdata.mission_data.buff_add_gold)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -55,37 +56,7 @@ export class MissionComp extends CCComp {
|
||||
let node= this.node.getChildByName("new_hero")
|
||||
tween(node).to(0.3, {position:v3(280,node.position.y,1)}).start()
|
||||
}
|
||||
if(wave==FightSet.BOSS_WAVE_UP_1){
|
||||
console.log("[任务系统] BOSS_WAVE_UP_1 装备选择 :",wave,FightSet.BOSS_WAVE_UP_1)
|
||||
}
|
||||
if(wave==FightSet.BOSS_WAVE_UP_2){
|
||||
console.log("[任务系统] BOSS_WAVE_UP_2 装备选择 :",wave,FightSet.BOSS_WAVE_UP_2)
|
||||
}
|
||||
if(wave==FightSet.BOSS_WAVE_UP_3){
|
||||
console.log("[任务系统] BOSS_WAVE_UP_3 装备选择 :",wave,FightSet.BOSS_WAVE_UP_3)
|
||||
}
|
||||
if(wave==FightSet.EQUIP_WAVE_UP_1){
|
||||
console.log("[任务系统] EQUIP_WAVE_UP_1 装备选择 :",wave,FightSet.EQUIP_WAVE_UP_1)
|
||||
}
|
||||
if(wave==FightSet.EQUIP_WAVE_UP_2){
|
||||
console.log("[任务系统] EQUIP_WAVE_UP_2 装备选择 :",wave,FightSet.EQUIP_WAVE_UP_2)
|
||||
}
|
||||
if(wave==FightSet.EQUIP_WAVE_UP_3){
|
||||
console.log("[任务系统] EQUIP_WAVE_UP_3 装备选择 :",wave,FightSet.EQUIP_WAVE_UP_3)
|
||||
}
|
||||
if(wave==FightSet.SKILL_WAVE_UP_1){
|
||||
console.log("[任务系统] SKILL_WAVE_UP_1 技能选择 :",wave,FightSet.SKILL_WAVE_UP_1)
|
||||
this.show_skill_get("skill1")
|
||||
}
|
||||
if(wave==FightSet.SKILL_WAVE_UP_2){
|
||||
console.log("[任务系统] SKILL_WAVE_UP_2 技能选择 :",wave,FightSet.SKILL_WAVE_UP_2)
|
||||
this.show_skill_get("skill2")
|
||||
}
|
||||
if(wave==FightSet.SKILL_WAVE_UP_3){
|
||||
console.log("[任务系统] SKILL_WAVE_UP_3 技能选择 :",wave,FightSet.SKILL_WAVE_UP_3)
|
||||
this.show_skill_get("skill3")
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
async mission_start(){
|
||||
@@ -120,21 +91,10 @@ export class MissionComp extends CCComp {
|
||||
oops.message.dispatchEvent(GameEvent.FightEnd)
|
||||
}
|
||||
|
||||
private show_skill_get(e:string){
|
||||
this.node.getChildByName("equips").getChildByName("boxs").getChildByName(e).getChildByName("get").active =true
|
||||
}
|
||||
|
||||
private hide_skill_get(e:any,data:string){
|
||||
this.node.getChildByName("equips").getChildByName("boxs").getChildByName(data).getChildByName("get").active =false
|
||||
}
|
||||
|
||||
private show_skill_change(e:string){
|
||||
this.node.getChildByName("equips").getChildByName("boxs").getChildByName(e).getChildByName("change").active =true
|
||||
}
|
||||
|
||||
private hide_skill_change(e:any,data:any){
|
||||
this.node.getChildByName("equips").getChildByName("boxs").getChildByName(data).getChildByName("change").active =false
|
||||
}
|
||||
|
||||
|
||||
|
||||
fight_end(){
|
||||
console.log("任务结束")
|
||||
@@ -160,12 +120,7 @@ export class MissionComp extends CCComp {
|
||||
smc.vmdata.boss = JSON.parse(JSON.stringify(VmInfo));
|
||||
this.GlodAddTimer=new Timer(smc.vmdata.mission_data.refrsh_time)
|
||||
this.hide_call_friend()
|
||||
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")
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user