From 0a25259cf46fac082b8106e2244a47cc84cc0723 Mon Sep 17 00:00:00 2001 From: panw Date: Thu, 26 Jun 2025 16:57:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=80=E8=83=BD=E5=8D=A1=E6=A7=BD=20?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E6=B5=8B=E8=AF=95=E7=A1=AE=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/script/game/map/CardComp.ts | 17 ++--- assets/script/game/map/CardsComp.ts | 10 +-- assets/script/game/map/EquipSkillComp.ts | 88 ++++++++++++------------ assets/script/game/map/MissionComp.ts | 2 +- 4 files changed, 56 insertions(+), 61 deletions(-) diff --git a/assets/script/game/map/CardComp.ts b/assets/script/game/map/CardComp.ts index 61ab79e1..83b5eeba 100644 --- a/assets/script/game/map/CardComp.ts +++ b/assets/script/game/map/CardComp.ts @@ -23,6 +23,7 @@ export class CardComp extends CCComp { c_type:number=0; //1英雄,2 技能.3 装备 4.功能卡牌 is_used:boolean=false; cost_gold:number=0; + skill_slot:string="skill1" onLoad(){ // this.on(GameEvent.HeroSelect,this.hero_select,this) } @@ -47,13 +48,13 @@ export class CardComp extends CCComp { this.node.getChildByName("Button").active=true }, 0.1); } - hero_skill_select(args: any){ + hero_skill_select(args: any,data:any){ this.c_type=cardType.SKILL console.log("[cardcomp]:card hero_skill_select",args) this.c_uuid=args.uuid this.node.getChildByName("show").active=false this.node.getChildByName("anim").getChildByName("up").getComponent(Animation).play('carsup') - this.show_skill(this.c_uuid) + this.show_skill(this.c_uuid,data) this.scheduleOnce(() => { this.node.getChildByName("show").active=true this.node.getChildByName("Button").active=true @@ -87,12 +88,6 @@ export class CardComp extends CCComp { let card =getRandomCardUUID() //随机获取卡牌类型 console.log("[cardcomp]:rad 开始请求卡牌",card) switch(card.type){ - case cardType.HERO: - this.hero_select(card) - break - case cardType.SKILL: - this.hero_skill_select(card) - break case cardType.EQUIP: this.equip_select(card) break @@ -102,11 +97,12 @@ export class CardComp extends CCComp { } } - show_skill(uuid:number){ + show_skill(uuid:number,data:any){ let show=this.node.getChildByName("show") show.getChildByName("name").getChildByName("name").getComponent(Label).string=SkillSet[uuid].name this.do_card_bg_show(SkillSet[uuid].quality) this.node.getChildByName("show").getChildByName("coins").active=false + this.skill_slot=data.slot var icon_path = "game/skills/skill_icon" resources.load(icon_path, SpriteAtlas, (err: any, atlas) => { const sprite = show.getChildByName("mask").getChildByName("skill").getComponent(Sprite); @@ -246,8 +242,9 @@ export class CardComp extends CCComp { break case cardType.SKILL: console.log("[cardcomp]:use_card 技能卡") - oops.message.dispatchEvent(GameEvent.UseSkillCard,{uuid:this.c_uuid}) + oops.message.dispatchEvent(GameEvent.UseSkillCard,{uuid:this.c_uuid,slot:this.skill_slot}) oops.message.dispatchEvent(GameEvent.CardsClose) + this.skill_slot="skill1" break case cardType.EQUIP: console.log("[cardcomp]:use_card 装备卡") diff --git a/assets/script/game/map/CardsComp.ts b/assets/script/game/map/CardsComp.ts index 0cac5388..2b0fd21d 100644 --- a/assets/script/game/map/CardsComp.ts +++ b/assets/script/game/map/CardsComp.ts @@ -63,12 +63,12 @@ export class CardsCompComp extends CCComp { // this.card4c.hero_select(list[3]) } - hero_skill_select(){ + hero_skill_select(data:any){ let list=getRandomCardsByType(cardType.SKILL,3) console.log("[CardsComp]:技能选择卡牌列表",list) - this.card1c.hero_skill_select(list[0]) - this.card2c.hero_skill_select(list[1]) - this.card3c.hero_skill_select(list[2]) + this.card1c.hero_skill_select(list[0],data) + this.card2c.hero_skill_select(list[1],data) + this.card3c.hero_skill_select(list[2],data) // this.card4c.hero_skill_select(list[3]) } equip_select(){ @@ -122,7 +122,7 @@ export class CardsCompComp extends CCComp { break case GameEvent.HeroSkillSelect: console.log("[CardsComp]:显示技能选择卡牌") - this.hero_skill_select() + this.hero_skill_select(data) break case GameEvent.FuncSelect: console.log("[CardsComp]:显示功能卡牌") diff --git a/assets/script/game/map/EquipSkillComp.ts b/assets/script/game/map/EquipSkillComp.ts index 97918e59..22a4e4e5 100644 --- a/assets/script/game/map/EquipSkillComp.ts +++ b/assets/script/game/map/EquipSkillComp.ts @@ -130,52 +130,50 @@ export class EquipSkillComp extends CCComp { get_skill(e:GameEvent,data:any){ console.log("get_skill") - if(this.skill1.uuid==0){ - this.skill1.uuid=data.uuid - this.skill1.skill_name=SkillSet[data.uuid].name - this.skill1.type=1 - this.skill1.cd=SkillSet[data.uuid].cd - this.skill1.cd_time=SkillSet[data.uuid].cd - let icon = this.node.getChildByName("boxs").getChildByName("skill1").getChildByName("icon") - icon.active=true - var icon_path = "game/skills/skill_icon" - resources.load(icon_path, SpriteAtlas, (err: any, atlas) => { - const sprite = icon.getChildByName("skill").getComponent(Sprite); - sprite.spriteFrame = atlas.getSpriteFrame(SkillSet[data.uuid].path); - }); - return + switch(data.slot){ + case "skill1": + this.skill1.uuid=data.uuid + this.skill1.skill_name=SkillSet[data.uuid].name + 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") + icon1.active=true + var icon_path = "game/skills/skill_icon" + resources.load(icon_path, SpriteAtlas, (err: any, atlas) => { + const sprite = icon1.getChildByName("skill").getComponent(Sprite); + sprite.spriteFrame = atlas.getSpriteFrame(SkillSet[data.uuid].path); + }); + break + case "skill2": + this.skill2.uuid=data.uuid + this.skill2.skill_name=SkillSet[data.uuid].name + 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") + icon2.active=true + var icon_path = "game/skills/skill_icon" + resources.load(icon_path, SpriteAtlas, (err: any, atlas) => { + const sprite = icon2.getChildByName("skill").getComponent(Sprite); + sprite.spriteFrame = atlas.getSpriteFrame(SkillSet[data.uuid].path); + }); + break + case "skill3": + this.skill3.uuid=data.uuid + this.skill3.skill_name=SkillSet[data.uuid].name + 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") + icon.active=true + var icon_path = "game/skills/skill_icon" + resources.load(icon_path, SpriteAtlas, (err: any, atlas) => { + const sprite = icon.getChildByName("skill").getComponent(Sprite); + sprite.spriteFrame = atlas.getSpriteFrame(SkillSet[data.uuid].path); + }); + break } - if(this.skill2.uuid==0){ - this.skill2.uuid=data.uuid - this.skill2.skill_name=SkillSet[data.uuid].name - this.skill2.type=1 - this.skill2.cd=SkillSet[data.uuid].cd - this.skill2.cd_time=SkillSet[data.uuid].cd - let icon = this.node.getChildByName("boxs").getChildByName("skill2").getChildByName("icon") - icon.active=true - var icon_path = "game/skills/skill_icon" - resources.load(icon_path, SpriteAtlas, (err: any, atlas) => { - const sprite = icon.getChildByName("skill").getComponent(Sprite); - sprite.spriteFrame = atlas.getSpriteFrame(SkillSet[data.uuid].path); - }); - return - } - if(this.skill3.uuid==0){ - this.skill3.uuid=data.uuid - this.skill3.skill_name=SkillSet[data.uuid].name - 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") - icon.active=true - var icon_path = "game/skills/skill_icon" - resources.load(icon_path, SpriteAtlas, (err: any, atlas) => { - const sprite = icon.getChildByName("skill").getComponent(Sprite); - sprite.spriteFrame = atlas.getSpriteFrame(SkillSet[data.uuid].path); - }); - return - } - console.log("技能栏满了") } /** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */ diff --git a/assets/script/game/map/MissionComp.ts b/assets/script/game/map/MissionComp.ts index 8f8be04f..09bf2d36 100644 --- a/assets/script/game/map/MissionComp.ts +++ b/assets/script/game/map/MissionComp.ts @@ -201,7 +201,7 @@ export class MissionComp extends CCComp { } call_skill_card(e:any){ - oops.message.dispatchEvent(GameEvent.HeroSkillSelect) + oops.message.dispatchEvent(GameEvent.HeroSkillSelect,{slot:e}) } private cleanComponents() { ecs.query(ecs.allOf(HeroViewComp)).forEach(entity => {entity.remove(HeroViewComp);entity.destroy()});