hero页 ui再优化

This commit is contained in:
2025-01-02 20:31:33 +08:00
parent caff3e9a83
commit e94a300c1c
13 changed files with 4106 additions and 2694 deletions

View File

@@ -63,14 +63,15 @@ export class HeroHomeComp extends CCComp {
let skill1 = SkillSet[this.hero.sk1[0]]
let skill2 = SkillSet[this.hero.sk2[0]]
var sk_path = "game/skills/skill_icon"
var icon_path = "game/heros/herois"
// var icon_path = "game/heros/herois"
this.node.getChildByName("show").getChildByName("name").getChildByName("value").getComponent(Label).string=this.hero.name
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
const sprite = this.node.getChildByName("show").getChildByName("hero").getChildByName("icon").getComponent(Sprite);
sprite.spriteFrame = atlas.getSpriteFrame(this.hero.path);
});
this.clear_hero()
this.call_hero(uuid)
// resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
// const sprite = this.node.getChildByName("show").getChildByName("hero").getChildByName("icon").getComponent(Sprite);
// sprite.spriteFrame = atlas.getSpriteFrame(this.hero.path);
// });
resources.load(sk_path, SpriteAtlas, (err: any, atlas) => {
const sprite = this.node.getChildByName("show").getChildByName("bottom").getChildByName("sk").getChildByName("skicon").getChildByName("Mask").getChildByName("icon").getComponent(Sprite);
sprite.spriteFrame = atlas.getSpriteFrame(skill1.path);
@@ -117,6 +118,7 @@ export class HeroHomeComp extends CCComp {
}else{
lvup.getChildByName("item").getChildByName("btn").getChildByName("num").getComponent(Label).color = color(255,0,0);
}
lvup.getChildByName("up").active=smc.vmdata.exp.num>=lvneed
// lvup.getChildByName("item").getChildByName("btn").getChildByName("bar").getComponent(ProgressBar).progress = smc.vmdata.exp.num/lvneed
lvup.getChildByName("info").getChildByName("ap").getComponent(Label).string = "+"+this.hero.ap_up
lvup.getChildByName("info").getChildByName("def").getComponent(Label).string = "+"+this.hero.def_up
@@ -125,6 +127,7 @@ export class HeroHomeComp extends CCComp {
// slvup.getChildByName("gold").getChildByName("btn").getChildByName("need").getComponent(Label).string = (UpGold.SlvUp*(this.role.slv+1)).toString()
let slvneed=HeroInfo[this.h_uuid].slvexp*this.role.slv
let slvnum=smc.heros[this.h_uuid].num
slvup.getChildByName("up").active=slvnum>=slvneed
if( slvnum>=slvneed) {
slvup.getChildByName("cost").getChildByName("btn").getChildByName("num").getComponent(Label).color = color(0,255,0);
}else{
@@ -144,19 +147,19 @@ export class HeroHomeComp extends CCComp {
// }else{
// slvup.getChildByName("btned").active=false
// };
if( this.role.slv==0) {
this.node.getChildByName("show").getChildByName("call").getChildByName("Node").getChildByName("cost").getChildByName("need").getComponent(Label).string = ((SlvUp[this.role.slv]-HeroInfo[this.h_uuid].slvexp)*(1+this.role.slv)).toString()
this.node.getChildByName("show").getChildByName("call").getChildByName("Node").getChildByName("cost").getChildByName("num").getComponent(Label).string = smc.heros[this.h_uuid].num.toString()
this.node.getChildByName("show").getChildByName("call").getChildByName("Node").getChildByName("cost").getChildByName("bar").getComponent(ProgressBar).progress = smc.heros[this.h_uuid].num/((SlvUp[this.role.slv]-HeroInfo[this.h_uuid].slvexp)*(1+this.role.slv))
let hchipcomp= this.node.getChildByName("show").getChildByName("call").getChildByName("Node").getChildByName("cost").getChildByName("hchip").getComponent(HChipComp)
hchipcomp.update_data(this.h_uuid,0)
this.node.getChildByName("show").getChildByName("call").active=true
}else{
this.node.getChildByName("show").getChildByName("call").active=false
};
// if( this.role.slv==0) {
// this.node.getChildByName("show").getChildByName("call").getChildByName("Node").getChildByName("cost").getChildByName("need").getComponent(Label).string = ((SlvUp[this.role.slv]-HeroInfo[this.h_uuid].slvexp)*(1+this.role.slv)).toString()
// this.node.getChildByName("show").getChildByName("call").getChildByName("Node").getChildByName("cost").getChildByName("num").getComponent(Label).string = smc.heros[this.h_uuid].num.toString()
// this.node.getChildByName("show").getChildByName("call").getChildByName("Node").getChildByName("cost").getChildByName("bar").getComponent(ProgressBar).progress = smc.heros[this.h_uuid].num/((SlvUp[this.role.slv]-HeroInfo[this.h_uuid].slvexp)*(1+this.role.slv))
// let hchipcomp= this.node.getChildByName("show").getChildByName("call").getChildByName("Node").getChildByName("cost").getChildByName("hchip").getComponent(HChipComp)
// hchipcomp.update_data(this.h_uuid,0)
// this.node.getChildByName("show").getChildByName("call").active=true
// }else{
// this.node.getChildByName("show").getChildByName("call").active=false
// };
attr.getChildByName("ap").getChildByName("val").getComponent(Label).string = ((this.hero.ap+this.hero.ap_up* this.role.lv)*(1+this.hero.sap_up/100*(this.role.slv-1))).toFixed(0).toString()
attr.getChildByName("hp").getChildByName("val").getComponent(Label).string = ((this.hero.hp+this.hero.hp_up* this.role.lv)*(1+this.hero.shp_up/100*(this.role.slv))).toFixed(0).toString()
attr.getChildByName("def").getChildByName("val").getComponent(Label).string = ((this.hero.ap+this.hero.ap_up* this.role.lv)*(1+this.hero.sdef_up/100*(this.role.slv-1))).toFixed(0).toString()
attr.getChildByName("def").getChildByName("val").getComponent(Label).string = ((this.hero.ap+this.hero.def_up* this.role.lv)*(1+this.hero.sdef_up/100*(this.role.slv-1))).toFixed(0).toString()
attr.getChildByName("acd").getChildByName("val").getComponent(Label).string = this.hero.a_cd
attr.getChildByName("speed").getChildByName("val").getComponent(Label).string = this.hero.speed
attr.getChildByName("dis").getChildByName("val").getComponent(Label).string = this.hero.dis
@@ -203,7 +206,33 @@ export class HeroHomeComp extends CCComp {
}
call_hero(uuid:number){
var path = "game/heros/uiheros/"+HeroInfo[uuid].path;
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
node.parent = this.node.getChildByName("show").getChildByName("hero").getChildByName("node")
}
clear_hero(){
this.node.getChildByName("show").getChildByName("hero").getChildByName("node").destroyAllChildren()
}
pre_hero(){
let hi= HeroList.indexOf(this.h_uuid)
if(hi==0){
oops.gui.toast("已经是第一个英雄");
return
}
this.h_uuid=HeroList[hi-1]
this.hero_show(this.h_uuid)
}
next_hero(){
let hi= HeroList.indexOf(this.h_uuid)
if(hi==HeroList.length-1){
oops.gui.toast("已经是最后一个英雄");
return
}
this.h_uuid=HeroList[hi+1]
this.hero_show(this.h_uuid)
}
lv_up(){
if(smc.vmdata.exp.num < ((this.hero.lvexp)*this.role.lv)){
oops.gui.toast("资源不足,升级失败");