英雄成长基本完成
This commit is contained in:
@@ -8,7 +8,7 @@ import { UIID } from "../common/config/GameUIConfig";
|
||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
import { Items } from "../common/config/Items";
|
||||
import { SkillSet } from "../common/config/SkillSet";
|
||||
import { SlvSet } from "../common/config/RoleSet";
|
||||
import { LvUp, SlvUp, UpGold } from "../common/config/RoleSet";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@@ -16,6 +16,8 @@ const { ccclass, property } = _decorator;
|
||||
@ecs.register('HeroHome', false)
|
||||
export class HeroHomeComp extends CCComp {
|
||||
h_uuid:number=0
|
||||
role:any=null
|
||||
hero:any=null
|
||||
protected onLoad(): void {
|
||||
|
||||
}
|
||||
@@ -40,50 +42,60 @@ export class HeroHomeComp extends CCComp {
|
||||
}
|
||||
hero_show(uuid:number) {
|
||||
console.log("hero_home hero_show:",uuid)
|
||||
let role = smc.heros[uuid]
|
||||
let hero =HeroInfo[uuid]
|
||||
this.h_uuid=uuid
|
||||
let slv_node=this.node.getChildByName("name").getChildByName("slv");
|
||||
let tal=this.node.getChildByName("slvup").getChildByName("tal");
|
||||
this.role=smc.heros[uuid]
|
||||
this.hero=HeroInfo[uuid]
|
||||
console.log("hero_home hero:",this.hero)
|
||||
let tal=this.node.getChildByName("sk").getChildByName("tal");
|
||||
let sk_node= this.node.getChildByName("sk");
|
||||
let skill = SkillSet[hero.sk2[0]]
|
||||
let skill = SkillSet[this.hero.sk2[0]]
|
||||
var sk_path = "game/skills/skill_icon"
|
||||
var icon_path = "game/heros/herois"
|
||||
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = this.node.getChildByName("hero").getChildByName("icon").getComponent(Sprite);
|
||||
sprite.spriteFrame = atlas.getSpriteFrame(hero.path);
|
||||
sprite.spriteFrame = atlas.getSpriteFrame(this.hero.path);
|
||||
});
|
||||
resources.load(sk_path, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = sk_node.getChildByName("skicon").getChildByName("Mask").getChildByName("icon").getComponent(Sprite);
|
||||
const sprite = sk_node.getChildByName("skicon").getChildByName("icon").getComponent(Sprite);
|
||||
sprite.spriteFrame = atlas.getSpriteFrame(skill.path);
|
||||
});
|
||||
sk_node.getChildByName("name").getComponent(Label).string = skill.name;
|
||||
sk_node.getChildByName("info").getComponent(Label).string = skill.info;
|
||||
this.node.getChildByName("name").getChildByName("value").getComponent(Label).string=hero.name
|
||||
this.node.getChildByName("name").getChildByName("lv").getComponent(Label).string = role.lv.toString()+"级";
|
||||
if( role.slv>=1) {slv_node.getChildByName("s1").active=true}else{slv_node.getChildByName("s1").active=false};
|
||||
if( role.slv>=2) {slv_node.getChildByName("s2").active=true}else{slv_node.getChildByName("s2").active=false};
|
||||
if( role.slv>=3) {slv_node.getChildByName("s3").active=true}else{slv_node.getChildByName("s3").active=false};
|
||||
if( role.slv>=4) {slv_node.getChildByName("s4").active=true}else{slv_node.getChildByName("s4").active=false};
|
||||
if( role.slv>=5) {slv_node.getChildByName("s5").active=true}else{slv_node.getChildByName("s5").active=false};
|
||||
this.node.getChildByName("attr").getChildByName("ap").getChildByName("val").getComponent(Label).string = hero.ap+hero.ap_up* role.lv
|
||||
this.node.getChildByName("attr").getChildByName("hp").getChildByName("val").getComponent(Label).string = hero.hp+hero.hp_up* role.lv
|
||||
this.node.getChildByName("attr").getChildByName("def").getChildByName("val").getComponent(Label).string = hero.ap+hero.ap_up* role.lv
|
||||
this.node.getChildByName("attr").getChildByName("acd").getChildByName("val").getComponent(Label).string = hero.a_cd
|
||||
this.node.getChildByName("attr").getChildByName("speed").getChildByName("val").getComponent(Label).string = hero.speed
|
||||
this.node.getChildByName("attr").getChildByName("dis").getChildByName("val").getComponent(Label).string = hero.dis
|
||||
tal.getChildByName("slv1").getChildByName("val").getComponent(Label).string = hero.tals[0]
|
||||
tal.getChildByName("slv2").getChildByName("val").getComponent(Label).string = hero.tals[1]
|
||||
tal.getChildByName("slv3").getChildByName("val").getComponent(Label).string = hero.tals[2]
|
||||
tal.getChildByName("slv4").getChildByName("val").getComponent(Label).string = hero.tals[3]
|
||||
tal.getChildByName("slv5").getChildByName("val").getComponent(Label).string = hero.tals[4]
|
||||
this.node.getChildByName("name").getChildByName("value").getComponent(Label).string=this.hero.name
|
||||
tal.getChildByName("slv1").getChildByName("val").getComponent(Label).string = this.hero.tals[0]
|
||||
tal.getChildByName("slv2").getChildByName("val").getComponent(Label).string = this.hero.tals[1]
|
||||
tal.getChildByName("slv3").getChildByName("val").getComponent(Label).string = this.hero.tals[2]
|
||||
tal.getChildByName("slv4").getChildByName("val").getComponent(Label).string = this.hero.tals[3]
|
||||
tal.getChildByName("slv5").getChildByName("val").getComponent(Label).string = this.hero.tals[4]
|
||||
this.update_data()
|
||||
}
|
||||
update_data(){
|
||||
let slv_node=this.node.getChildByName("name").getChildByName("slv");
|
||||
this.node.getChildByName("name").getChildByName("lv").getComponent(Label).string = this.role.lv.toString()+"级";
|
||||
this.node.getChildByName("lvup").getChildByName("gold").getChildByName("need").getComponent(Label).string = (UpGold.LvUp*this.role.lv).toString()
|
||||
this.node.getChildByName("lvup").getChildByName("item").getChildByName("need").getComponent(Label).string = ((LvUp[0]+this.hero.lvexp)*this.role.lv).toString()
|
||||
this.node.getChildByName("slvup").getChildByName("gold").getChildByName("need").getComponent(Label).string = (UpGold.SlvUp*this.role.slv).toString()
|
||||
this.node.getChildByName("slvup").getChildByName("item").getChildByName("need").getComponent(Label).string = ((SlvUp[this.role.slv]+this.hero.slvexp)*this.role.slv).toString()
|
||||
if( this.role.slv>=1) {slv_node.getChildByName("s1").active=true}else{slv_node.getChildByName("s1").active=false};
|
||||
if( this.role.slv>=2) {slv_node.getChildByName("s2").active=true}else{slv_node.getChildByName("s2").active=false};
|
||||
if( this.role.slv>=3) {slv_node.getChildByName("s3").active=true}else{slv_node.getChildByName("s3").active=false};
|
||||
if( this.role.slv>=4) {slv_node.getChildByName("s4").active=true}else{slv_node.getChildByName("s4").active=false};
|
||||
if( this.role.slv>=5) {slv_node.getChildByName("s5").active=true}else{slv_node.getChildByName("s5").active=false};
|
||||
this.node.getChildByName("attr").getChildByName("ap").getChildByName("val").getComponent(Label).string = this.hero.ap+this.hero.ap_up* this.role.lv
|
||||
this.node.getChildByName("attr").getChildByName("hp").getChildByName("val").getComponent(Label).string = this.hero.hp+this.hero.hp_up* this.role.lv
|
||||
this.node.getChildByName("attr").getChildByName("def").getChildByName("val").getComponent(Label).string = this.hero.ap+this.hero.ap_up* this.role.lv
|
||||
|
||||
this.node.getChildByName("attr").getChildByName("acd").getChildByName("val").getComponent(Label).string = this.hero.a_cd
|
||||
this.node.getChildByName("attr").getChildByName("speed").getChildByName("val").getComponent(Label).string = this.hero.speed
|
||||
this.node.getChildByName("attr").getChildByName("dis").getChildByName("val").getComponent(Label).string = this.hero.dis
|
||||
}
|
||||
lv_selcet(e:any,val:any){
|
||||
let active = this.node.getChildByName("menu").getChildByName("active")
|
||||
tween(active).to(0.1,{position:v3(val,0)}).start()
|
||||
let hero = this.node.getChildByName("hero")
|
||||
let attr = this.node.getChildByName("attr")
|
||||
let attr2 = this.node.getChildByName("attr2")
|
||||
let info = this.node.getChildByName("info")
|
||||
let lvup = this.node.getChildByName("lvup")
|
||||
let sk = this.node.getChildByName("sk")
|
||||
@@ -91,14 +103,14 @@ export class HeroHomeComp extends CCComp {
|
||||
if(val < 0){
|
||||
tween(hero).to(0.2,{position:v3(0,hero.position.y)}).start()
|
||||
tween(attr).to(0.2,{position:v3(0,attr.position.y)}).start()
|
||||
tween(info).to(0.2,{position:v3(0,info.position.y)}).start()
|
||||
tween(attr2).to(0.2,{position:v3(0,attr2.position.y)}).start()
|
||||
tween(lvup).to(0.2,{position:v3(0,lvup.position.y)}).start()
|
||||
tween(sk).to(0.2,{position:v3(1000,sk.position.y)}).start()
|
||||
tween(slvup).to(0.2,{position:v3(1000,slvup.position.y)}).start()
|
||||
}else{
|
||||
tween(hero).to(0.2,{position:v3(-1000,hero.position.y)}).start()
|
||||
tween(attr).to(0.2,{position:v3(-1000,attr.position.y)}).start()
|
||||
tween(info).to(0.2,{position:v3(-1000,info.position.y)}).start()
|
||||
tween(attr2).to(0.2,{position:v3(-1000,attr2.position.y)}).start()
|
||||
tween(lvup).to(0.2,{position:v3(-1000,lvup.position.y)}).start()
|
||||
tween(sk).to(0.2,{position:v3(0,sk.position.y)}).start()
|
||||
tween(slvup).to(0.2,{position:v3(0,slvup.position.y)}).start()
|
||||
@@ -109,22 +121,32 @@ export class HeroHomeComp extends CCComp {
|
||||
|
||||
|
||||
lv_up(){
|
||||
console.log("升级",smc.vmdata.items[1001],smc.heros[this.h_uuid].lv*HeroInfo[this.h_uuid].lvexp)
|
||||
if(smc.vmdata.items[1001] < smc.heros[this.h_uuid].lv*HeroInfo[this.h_uuid].lvexp){
|
||||
console.log("材料不足")
|
||||
console.log("升级",smc.vmdata.items[1001],((LvUp[0]+this.hero.lvexp)*this.role.lv))
|
||||
if(smc.vmdata.items[1001] < ((LvUp[0]+this.hero.lvexp)*this.role.lv)||smc.vmdata.gold < (UpGold.LvUp*this.role.lv)){
|
||||
oops.gui.toast("资源不足,升级失败");
|
||||
return
|
||||
}
|
||||
smc.heros[this.h_uuid].lv++
|
||||
smc.vmdata.items[1001] -= smc.heros[this.h_uuid].lv*HeroInfo[this.h_uuid].lvexp
|
||||
smc.vmdata.items[1001] -= ((LvUp[0]+this.hero.lvexp)*this.role.lv)
|
||||
smc.vmdata.gold -= (UpGold.LvUp*this.role.lv)
|
||||
this.role.lv++
|
||||
this.update_data()
|
||||
}
|
||||
slv_up(){
|
||||
console.log("smc.vmdata.items[1004] SlvSet[smc.heros[this.h_uuid].slv]:",smc.vmdata.items[1004],SlvSet[smc.heros[this.h_uuid].slv])
|
||||
if(smc.vmdata.items[1004] < SlvSet[smc.heros[this.h_uuid].slv]){
|
||||
console.log("材料不足")
|
||||
if(this.role.slv>=5){
|
||||
oops.gui.toast("已经满星,升星失败");
|
||||
return
|
||||
}
|
||||
console.log("smc.vmdata.items[1004] ((SlvUp[this.role.slv]+this.hero.slvexp)*this.role.slv):",smc.vmdata.items[1004],((SlvUp[this.role.slv]+this.hero.slvexp)*this.role.slv))
|
||||
if(smc.vmdata.items[1004] < ((SlvUp[this.role.slv]+this.hero.slvexp)*this.role.slv)||smc.vmdata.gold < (UpGold.SlvUp*this.role.slv)){
|
||||
oops.gui.toast("资源不足,升星失败");
|
||||
return
|
||||
}
|
||||
smc.heros[this.h_uuid].slv++
|
||||
smc.vmdata.items[1004] -= SlvSet[smc.heros[this.h_uuid].slv]
|
||||
smc.vmdata.items[1004] -= ((SlvUp[this.role.slv]+this.hero.slvexp)*this.role.slv)
|
||||
smc.vmdata.gold -= (UpGold.SlvUp*this.role.slv)
|
||||
this.role.slv++
|
||||
this.update_data()
|
||||
|
||||
|
||||
}
|
||||
item_show(e:any,val:any){
|
||||
oops.gui.open(UIID.ItemInfo, Items[val]);
|
||||
|
||||
Reference in New Issue
Block a user