card ui调整

This commit is contained in:
2025-06-19 10:28:31 +08:00
parent 2c9f176912
commit 3accaa1850
5 changed files with 7912 additions and 632 deletions

View File

@@ -9,7 +9,7 @@ import { HeroModelComp } from "../hero/HeroModelComp";
import { HeroViewComp } from "../hero/HeroViewComp";
import { smc } from "../common/SingletonModuleComp";
import { HeroSkillList, SkillSet } from "../common/config/SkillSet";
import { cardType, getRandomCardUUID } from "../common/config/CardSet";
import { cardType, getRandomCardUUID, SuperCards } from "../common/config/CardSet";
import { EquipInfo } from "../common/config/Equips";
const { ccclass, property } = _decorator;
@@ -106,31 +106,18 @@ export class CardComp extends CCComp {
show_skill(uuid:number){
let show=this.node.getChildByName("show")
show.getChildByName("name").getComponent(Label).string=SkillSet[uuid].name
show.getChildByName("ap").active=false
show.getChildByName("hp").active=false
show.getChildByName("mask").getChildByName("skill").active=true
show.getChildByName("mask").getChildByName("s_bg").active=true
show.getChildByName("mask").getChildByName("equip").active=false
show.getChildByName("mask").getChildByName("e_bg").active=false
show.getChildByName("mask").getChildByName("hero").active=false
show.getChildByName("mask").getChildByName("h_bg").active=false
this.do_card_bg_show()
var icon_path = "game/skills/skill_icon"
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
const sprite = show.getChildByName("mask").getChildByName("skill").getComponent(Sprite);
sprite.spriteFrame = atlas.getSpriteFrame(SkillSet[uuid].path);
});
this.node.getChildByName("Button").getChildByName("Label").getComponent(Label).string=this.check_heros()
}
show_hero(uuid:number){
let show=this.node.getChildByName("show")
this.do_card_bg_show()
show.getChildByName("ap").active=true
show.getChildByName("hp").active=true
show.getChildByName("mask").getChildByName("skill").active=false
show.getChildByName("mask").getChildByName("s_bg").active=false
show.getChildByName("mask").getChildByName("equip").active=false
show.getChildByName("mask").getChildByName("e_bg").active=false
show.getChildByName("mask").getChildByName("hero").active=true
show.getChildByName("mask").getChildByName("h_bg").active=true
show.getChildByName("name").getComponent(Label).string=HeroInfo[uuid].name
show.getChildByName("ap").getChildByName("num").getComponent(Label).string=HeroInfo[uuid].ap.toString()
show.getChildByName("hp").getChildByName("num").getComponent(Label).string=HeroInfo[uuid].hp.toString()
@@ -143,27 +130,30 @@ export class CardComp extends CCComp {
const sprite = show.getChildByName("mask").getChildByName("hero").getComponent(Sprite);
sprite.spriteFrame = atlas.getSpriteFrame(HeroInfo[uuid].path);
});
this.node.getChildByName("Button").getChildByName("Label").getComponent(Label).string=this.check_heros()
}
show_equip(uuid:number){
let show=this.node.getChildByName("show")
show.getChildByName("ap").active=false
show.getChildByName("hp").active=false
show.getChildByName("mask").getChildByName("skill").active=false
show.getChildByName("mask").getChildByName("s_bg").active=false
show.getChildByName("mask").getChildByName("equip").active=true
show.getChildByName("mask").getChildByName("e_bg").active=true
show.getChildByName("mask").getChildByName("hero").active=false
show.getChildByName("mask").getChildByName("h_bg").active=false
this.do_card_bg_show()
show.getChildByName("name").getComponent(Label).string=EquipInfo[uuid].name
var icon_path = "game/heros/equips"
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
const sprite = show.getChildByName("mask").getChildByName("equip").getComponent(Sprite);
sprite.spriteFrame = atlas.getSpriteFrame(EquipInfo[uuid].uuid.toString());
});
this.node.getChildByName("Button").getChildByName("Label").getComponent(Label).string=this.check_heros()
}
show_func(uuid:number){
let show=this.node.getChildByName("show")
this.do_card_bg_show()
show.getChildByName("name").getComponent(Label).string=SuperCards[uuid].name
var icon_path = "game/heros/cards"
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
const sprite = show.getChildByName("mask").getChildByName("func").getComponent(Sprite);
sprite.spriteFrame = atlas.getSpriteFrame(SuperCards[uuid].path);
});
}
do_card_bg_show(){
this.node.getChildByName("Button").getChildByName("Label").getComponent(Label).string=this.check_heros()
let show=this.node.getChildByName("show")
show.getChildByName("ap").active=false
show.getChildByName("hp").active=false
@@ -171,6 +161,32 @@ export class CardComp extends CCComp {
show.getChildByName("mask").getChildByName("s_bg").active=false
show.getChildByName("mask").getChildByName("equip").active=false
show.getChildByName("mask").getChildByName("e_bg").active=false
show.getChildByName("mask").getChildByName("hero").active=false
show.getChildByName("mask").getChildByName("h_bg").active=false
show.getChildByName("mask").getChildByName("func").active=false
show.getChildByName("mask").getChildByName("f_bg").active=false
switch(this.c_type){
case cardType.HERO:
show.getChildByName("mask").getChildByName("hero").active=true
show.getChildByName("mask").getChildByName("h_bg").active=true
show.getChildByName("type").getChildByName("name").getComponent(Label).string="英雄"
break
case cardType.SKILL:
show.getChildByName("mask").getChildByName("skill").active=true
show.getChildByName("mask").getChildByName("s_bg").active=true
show.getChildByName("type").getChildByName("name").getComponent(Label).string="技能"
break
case cardType.EQUIP:
show.getChildByName("mask").getChildByName("equip").active=true
show.getChildByName("mask").getChildByName("e_bg").active=true
show.getChildByName("type").getChildByName("name").getComponent(Label).string="装备"
break
case cardType.SPECIAL:
show.getChildByName("mask").getChildByName("func").active=true
show.getChildByName("mask").getChildByName("f_bg").active=true
show.getChildByName("type").getChildByName("name").getComponent(Label).string="特效"
break
}
}
check_heros(){
// let heros=ecs.query(ecs.allOf(HeroModelComp))
@@ -186,7 +202,7 @@ export class CardComp extends CCComp {
}
use_card(){
switch(this.c_type){
case 0:
case cardType.HERO:
if(smc.vmdata.mission_data.gold< smc.vmdata.mission_data.call_gold){
oops.gui.toast("金币不足", false);
return
@@ -195,16 +211,21 @@ export class CardComp extends CCComp {
smc.vmdata.mission_data.gold-=smc.vmdata.mission_data.call_gold
oops.message.dispatchEvent(GameEvent.CardsClose)
break
case 1:
case cardType.SKILL:
console.log("use_card 技能卡")
oops.message.dispatchEvent(GameEvent.UseSkillCard,{uuid:this.c_uuid})
oops.message.dispatchEvent(GameEvent.CardsClose)
break
case 2:
case cardType.EQUIP:
console.log("use_card 装备卡")
oops.message.dispatchEvent(GameEvent.EquipAdd,{uuid:this.c_uuid,type:EquipInfo[this.c_uuid].type})
oops.message.dispatchEvent(GameEvent.CardsClose)
break
case cardType.SPECIAL:
console.log("use_card 功能卡")
oops.message.dispatchEvent(GameEvent.UseSpecialCard,{uuid:this.c_uuid})
oops.message.dispatchEvent(GameEvent.CardsClose)
break
}
}
reset() {