技能卡槽 需要测试确认

This commit is contained in:
2025-06-26 16:57:55 +08:00
parent b00cc9536f
commit 0a25259cf4
4 changed files with 56 additions and 61 deletions

View File

@@ -23,6 +23,7 @@ export class CardComp extends CCComp {
c_type:number=0; //1英雄,2 技能.3 装备 4.功能卡牌 c_type:number=0; //1英雄,2 技能.3 装备 4.功能卡牌
is_used:boolean=false; is_used:boolean=false;
cost_gold:number=0; cost_gold:number=0;
skill_slot:string="skill1"
onLoad(){ onLoad(){
// this.on(GameEvent.HeroSelect,this.hero_select,this) // this.on(GameEvent.HeroSelect,this.hero_select,this)
} }
@@ -47,13 +48,13 @@ export class CardComp extends CCComp {
this.node.getChildByName("Button").active=true this.node.getChildByName("Button").active=true
}, 0.1); }, 0.1);
} }
hero_skill_select(args: any){ hero_skill_select(args: any,data:any){
this.c_type=cardType.SKILL this.c_type=cardType.SKILL
console.log("[cardcomp]:card hero_skill_select",args) console.log("[cardcomp]:card hero_skill_select",args)
this.c_uuid=args.uuid this.c_uuid=args.uuid
this.node.getChildByName("show").active=false this.node.getChildByName("show").active=false
this.node.getChildByName("anim").getChildByName("up").getComponent(Animation).play('carsup') 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.scheduleOnce(() => {
this.node.getChildByName("show").active=true this.node.getChildByName("show").active=true
this.node.getChildByName("Button").active=true this.node.getChildByName("Button").active=true
@@ -87,12 +88,6 @@ export class CardComp extends CCComp {
let card =getRandomCardUUID() //随机获取卡牌类型 let card =getRandomCardUUID() //随机获取卡牌类型
console.log("[cardcomp]:rad 开始请求卡牌",card) console.log("[cardcomp]:rad 开始请求卡牌",card)
switch(card.type){ switch(card.type){
case cardType.HERO:
this.hero_select(card)
break
case cardType.SKILL:
this.hero_skill_select(card)
break
case cardType.EQUIP: case cardType.EQUIP:
this.equip_select(card) this.equip_select(card)
break 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") let show=this.node.getChildByName("show")
show.getChildByName("name").getChildByName("name").getComponent(Label).string=SkillSet[uuid].name show.getChildByName("name").getChildByName("name").getComponent(Label).string=SkillSet[uuid].name
this.do_card_bg_show(SkillSet[uuid].quality) this.do_card_bg_show(SkillSet[uuid].quality)
this.node.getChildByName("show").getChildByName("coins").active=false this.node.getChildByName("show").getChildByName("coins").active=false
this.skill_slot=data.slot
var icon_path = "game/skills/skill_icon" var icon_path = "game/skills/skill_icon"
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => { resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
const sprite = show.getChildByName("mask").getChildByName("skill").getComponent(Sprite); const sprite = show.getChildByName("mask").getChildByName("skill").getComponent(Sprite);
@@ -246,8 +242,9 @@ export class CardComp extends CCComp {
break break
case cardType.SKILL: case cardType.SKILL:
console.log("[cardcomp]:use_card 技能卡") 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) oops.message.dispatchEvent(GameEvent.CardsClose)
this.skill_slot="skill1"
break break
case cardType.EQUIP: case cardType.EQUIP:
console.log("[cardcomp]:use_card 装备卡") console.log("[cardcomp]:use_card 装备卡")

View File

@@ -63,12 +63,12 @@ export class CardsCompComp extends CCComp {
// this.card4c.hero_select(list[3]) // this.card4c.hero_select(list[3])
} }
hero_skill_select(){ hero_skill_select(data:any){
let list=getRandomCardsByType(cardType.SKILL,3) let list=getRandomCardsByType(cardType.SKILL,3)
console.log("[CardsComp]:技能选择卡牌列表",list) console.log("[CardsComp]:技能选择卡牌列表",list)
this.card1c.hero_skill_select(list[0]) this.card1c.hero_skill_select(list[0],data)
this.card2c.hero_skill_select(list[1]) this.card2c.hero_skill_select(list[1],data)
this.card3c.hero_skill_select(list[2]) this.card3c.hero_skill_select(list[2],data)
// this.card4c.hero_skill_select(list[3]) // this.card4c.hero_skill_select(list[3])
} }
equip_select(){ equip_select(){
@@ -122,7 +122,7 @@ export class CardsCompComp extends CCComp {
break break
case GameEvent.HeroSkillSelect: case GameEvent.HeroSkillSelect:
console.log("[CardsComp]:显示技能选择卡牌") console.log("[CardsComp]:显示技能选择卡牌")
this.hero_skill_select() this.hero_skill_select(data)
break break
case GameEvent.FuncSelect: case GameEvent.FuncSelect:
console.log("[CardsComp]:显示功能卡牌") console.log("[CardsComp]:显示功能卡牌")

View File

@@ -130,52 +130,50 @@ export class EquipSkillComp extends CCComp {
get_skill(e:GameEvent,data:any){ get_skill(e:GameEvent,data:any){
console.log("get_skill") console.log("get_skill")
if(this.skill1.uuid==0){ switch(data.slot){
this.skill1.uuid=data.uuid case "skill1":
this.skill1.skill_name=SkillSet[data.uuid].name this.skill1.uuid=data.uuid
this.skill1.type=1 this.skill1.skill_name=SkillSet[data.uuid].name
this.skill1.cd=SkillSet[data.uuid].cd this.skill1.type=1
this.skill1.cd_time=SkillSet[data.uuid].cd this.skill1.cd=SkillSet[data.uuid].cd
let icon = this.node.getChildByName("boxs").getChildByName("skill1").getChildByName("icon") this.skill1.cd_time=SkillSet[data.uuid].cd
icon.active=true let icon1 = this.node.getChildByName("boxs").getChildByName("skill1").getChildByName("icon")
var icon_path = "game/skills/skill_icon" icon1.active=true
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => { var icon_path = "game/skills/skill_icon"
const sprite = icon.getChildByName("skill").getComponent(Sprite); resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
sprite.spriteFrame = atlas.getSpriteFrame(SkillSet[data.uuid].path); const sprite = icon1.getChildByName("skill").getComponent(Sprite);
}); sprite.spriteFrame = atlas.getSpriteFrame(SkillSet[data.uuid].path);
return });
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) 删除组件是触发组件处理自定义释放逻辑 */ /** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */

View File

@@ -201,7 +201,7 @@ export class MissionComp extends CCComp {
} }
call_skill_card(e:any){ call_skill_card(e:any){
oops.message.dispatchEvent(GameEvent.HeroSkillSelect) oops.message.dispatchEvent(GameEvent.HeroSkillSelect,{slot:e})
} }
private cleanComponents() { private cleanComponents() {
ecs.query(ecs.allOf(HeroViewComp)).forEach(entity => {entity.remove(HeroViewComp);entity.destroy()}); ecs.query(ecs.allOf(HeroViewComp)).forEach(entity => {entity.remove(HeroViewComp);entity.destroy()});