hero 升级
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { _decorator, Animation, AnimationClip, Component, Label, Node, resources } from 'cc';
|
||||
import { oops } from 'db://oops-framework/core/Oops';
|
||||
import { UIID } from '../common/config/GameUIConfig';
|
||||
import { getHeroStatsByLevel, HeroInfo } from '../common/config/heroSet';
|
||||
import { getHeroStatsByLevel, getUpgradeResources, HeroInfo, HType } from '../common/config/heroSet';
|
||||
import { smc } from '../common/SingletonModuleComp';
|
||||
import { GameEvent } from '../common/config/GameEvent';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('HInfoComp')
|
||||
@@ -25,17 +26,58 @@ export class HInfoComp extends Component {
|
||||
this.h_uuid=uuid
|
||||
let hero_data = HeroInfo[uuid]
|
||||
let hero= this.node.getChildByName("hero")
|
||||
let lv=smc.heros[uuid].lv
|
||||
let anm_path=hero_data.path
|
||||
resources.load("game/heros/hero/"+anm_path+"/idle", AnimationClip, (err, clip) => {
|
||||
hero.getComponent(Animation).addClip(clip);
|
||||
hero.getComponent(Animation).play("idle");
|
||||
});
|
||||
this.node.getChildByName("name").getComponent(Label).string=hero_data.name
|
||||
this.node.getChildByName("lv").getChildByName("num").getComponent(Label).string=smc.heros[uuid].lv.toString()
|
||||
let {hp,ap,def}=getHeroStatsByLevel(uuid,smc.heros[uuid].lv)
|
||||
this.node.getChildByName("lv").getChildByName("num").getComponent(Label).string=lv.toString()
|
||||
this.node.getChildByName("skills").getChildByName("list2").getChildByName("luck").active= lv <5
|
||||
this.node.getChildByName("skills").getChildByName("list3").getChildByName("luck").active= lv <10
|
||||
this.node.getChildByName("skills").getChildByName("list4").getChildByName("luck").active= lv <15
|
||||
let {hp,ap,def}=getHeroStatsByLevel(uuid,lv)
|
||||
this.node.getChildByName("info").getChildByName("hp").getChildByName("num").getComponent(Label).string=hp.toString()
|
||||
this.node.getChildByName("info").getChildByName("ap").getChildByName("num").getComponent(Label).string=ap.toString()
|
||||
this.node.getChildByName("info").getChildByName("def").getChildByName("num").getComponent(Label).string=def.toString()
|
||||
let {experience,gold}=getUpgradeResources(lv)
|
||||
let need_node=this.node.getChildByName("upNeed").getChildByName("need")
|
||||
need_node.getChildByName("exp").getChildByName("need").getComponent(Label).string=experience.toString()
|
||||
need_node.getChildByName("gold").getChildByName("need").getComponent(Label).string=gold.toString()
|
||||
this.node.getChildByName("type").getChildByName("w").active=hero_data.type==HType.warrior
|
||||
this.node.getChildByName("type").getChildByName("r").active=hero_data.type==HType.remote
|
||||
this.node.getChildByName("type").getChildByName("m").active=hero_data.type==HType.mage
|
||||
}
|
||||
uplevel(){
|
||||
let hero_data = HeroInfo[this.h_uuid]
|
||||
let lv=smc.heros[this.h_uuid].lv
|
||||
let {experience,gold}=getUpgradeResources(lv)
|
||||
if(smc.vmdata.mission_data.exp<=experience||smc.vmdata.mission_data.gold<=gold){
|
||||
oops.gui.toast("经验或金币不足")
|
||||
return
|
||||
}
|
||||
smc.spendGameProperty("exp",experience)
|
||||
smc.spendGameProperty("gold",gold)
|
||||
smc.levelUpHero(this.h_uuid)
|
||||
this.update_data(this.h_uuid)
|
||||
oops.message.dispatchEvent(GameEvent.UpdateHero, {})
|
||||
}
|
||||
next_hero(){
|
||||
let heros=smc.getHasHeroUUID()
|
||||
let index = heros.indexOf(this.h_uuid);
|
||||
index++
|
||||
if(index==heros.length) index=0
|
||||
let nextHero = heros[index];
|
||||
this.update_data(nextHero)
|
||||
}
|
||||
prev_hero(){
|
||||
let heros=smc.getHasHeroUUID()
|
||||
let index = heros.indexOf(this.h_uuid);
|
||||
index--
|
||||
if(index==-1) index=heros.length-1
|
||||
let prevHero = heros[index];
|
||||
this.update_data(prevHero)
|
||||
}
|
||||
close(){
|
||||
oops.gui.removeByNode(this.node)
|
||||
|
||||
@@ -40,44 +40,46 @@ export class MissionHomeComp extends CCComp {
|
||||
}
|
||||
btn_func(e:string,data:any){
|
||||
// console.log("[MissionHomeComp]:btn_func",e,data)
|
||||
let page_heros=this.node.getChildByName("heros_page")
|
||||
let page_shop=this.node.getChildByName("shop_page")
|
||||
// let page_fight=this.node.getChildByName("fight_page")
|
||||
// let page_skill=this.node.getChildByName("skill_page")
|
||||
// let page_set=this.node.getChildByName("set_page")
|
||||
let btns=this.node.getChildByName("btns")
|
||||
let shop =btns.getChildByName("shop")
|
||||
let heros =btns.getChildByName("heros")
|
||||
let heros_page=this.node.getChildByName("heros").getComponent(HeroPageComp)!
|
||||
let fight =btns.getChildByName("fight")
|
||||
let skill =btns.getChildByName("skill")
|
||||
let set =btns.getChildByName("set")
|
||||
shop.getChildByName("act").active=false
|
||||
heros.getChildByName("act").active=false
|
||||
fight.getChildByName("act").active=false
|
||||
skill.getChildByName("act").active=false
|
||||
set.getChildByName("act").active=false
|
||||
this.node.getChildByName("shop").active=false
|
||||
this.node.getChildByName("heros").active=false
|
||||
// this.node.getChildByName("fight").active=false
|
||||
// this.node.getChildByName("skill").active=false
|
||||
// this.node.getChildByName("set").active=false
|
||||
let btn_shop =btns.getChildByName("shop")
|
||||
let btn_heros =btns.getChildByName("heros")
|
||||
let btn_fight =btns.getChildByName("fight")
|
||||
let btn_skill =btns.getChildByName("skill")
|
||||
let btn_set =btns.getChildByName("set")
|
||||
btn_shop.getChildByName("act").active=false
|
||||
btn_heros.getChildByName("act").active=false
|
||||
btn_fight.getChildByName("act").active=false
|
||||
btn_skill.getChildByName("act").active=false
|
||||
btn_set.getChildByName("act").active=false
|
||||
page_heros.active=false
|
||||
page_shop.active=false
|
||||
switch(data){
|
||||
case "shop":
|
||||
this.node.getChildByName("shop").active=true
|
||||
shop.getChildByName("act").active=true
|
||||
page_shop.active=true
|
||||
btn_shop.getChildByName("act").active=true
|
||||
break
|
||||
case "heros":
|
||||
this.node.getChildByName("heros").active=true
|
||||
heros_page.update_heros()
|
||||
heros.getChildByName("act").active=true
|
||||
page_heros.active=true
|
||||
let page_heros_com=page_heros.getComponent(HeroPageComp)!
|
||||
page_heros_com.update_heros()
|
||||
btn_heros.getChildByName("act").active=true
|
||||
break
|
||||
case "fight":
|
||||
fight.getChildByName("act").active=true
|
||||
btn_fight.getChildByName("act").active=true
|
||||
break
|
||||
case "skill":
|
||||
skill.getChildByName("act").active=true
|
||||
btn_skill.getChildByName("act").active=true
|
||||
break
|
||||
case "set":
|
||||
set.getChildByName("act").active=true
|
||||
btn_set.getChildByName("act").active=true
|
||||
break
|
||||
default:
|
||||
fight.getChildByName("act").active=true
|
||||
btn_fight.getChildByName("act").active=true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user