英雄碎片完成

This commit is contained in:
2024-12-16 20:32:04 +08:00
parent 4ef310674a
commit 85e43929ad
13 changed files with 2904 additions and 18691 deletions

View File

@@ -55,9 +55,9 @@ export class SingletonModuleComp extends ecs.Comp {
};
/** 游戏主角 */
heros:any={
9001:{uuid:9001,lv:1,exp:0,slv:0,stone:0,num:0,x1:0,x10:0},
9002:{uuid:9002,lv:2,exp:0,slv:1,stone:0,num:0,x1:0,x10:0},
9003:{uuid:9003,lv:3,exp:0,slv:2,stone:0,num:0,x1:0,x10:0},
9001:{uuid:9001,lv:1,exp:0,slv:0,stone:0,num:100,x1:0,x10:0},
9002:{uuid:9002,lv:2,exp:0,slv:1,stone:0,num:80,x1:0,x10:0},
9003:{uuid:9003,lv:3,exp:0,slv:2,stone:0,num:90,x1:0,x10:0},
};
goods:any={
free: [ {uuid:9001,num:100000}, {uuid:1001,num:10}, {uuid:1002,num:10}, {uuid:1007,num:10},],

View File

@@ -0,0 +1,32 @@
import { _decorator, Component, Label, Node, resources, Sprite, SpriteAtlas } from 'cc';
import { HeroInfo } from '../common/config/heroSet';
const { ccclass, property } = _decorator;
@ccclass('HChipComp')
export class HChipComp extends Component {
h_uuid:number=0
num:number=0
lv:number=0
start() {
}
update(deltaTime: number) {
}
update_data(h_uuid:number,num:number=0){
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(HeroInfo[h_uuid].path);
});
if(num > 0){
this.node.getChildByName("num").getComponent(Label).string = num.toString();
}else{
this.node.getChildByName("num").getComponent(Label).string = "";
}
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "dc8e3ce8-1ced-41ab-bbf6-72310977465a",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -1,4 +1,4 @@
import { _decorator,Button,EventHandler,EventTouch,instantiate,Label,NodeEventType,Prefab,resources,Sprite,SpriteAtlas,tween,UITransform,v3 } from "cc";
import { _decorator,Button,EventHandler,EventTouch,instantiate,Label,NodeEventType,Prefab,ProgressBar,resources,Sprite,SpriteAtlas,tween,UITransform,v3 } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { HeroInfo, HeroList } from "../common/config/heroSet";
@@ -9,6 +9,7 @@ import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/O
import { Items } from "../common/config/Items";
import { SkillSet } from "../common/config/SkillSet";
import { LvUp, SlvUp, UpGold } from "../common/config/RoleSet";
import { HChipComp } from "../hero/HChipComp";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@@ -81,17 +82,20 @@ export class HeroHomeComp extends CCComp {
if( this.role.slv>=5) {slv_node.getChildByName("s5").active=true}else{slv_node.getChildByName("s5").active=false};
lvup.getChildByName("gold").getChildByName("need").getComponent(Label).string = (UpGold.LvUp*this.role.lv).toString()
// lvup.getChildByName("gold").getChildByName("need").getComponent(Label).string = (UpGold.LvUp*this.role.lv).toString()
lvup.getChildByName("item").getChildByName("need").getComponent(Label).string = ((LvUp[0]+this.hero.lvexp)*this.role.lv).toString()
lvup.getChildByName("info").getChildByName("ap").getComponent(Label).string = "+"+this.hero.ap_up
lvup.getChildByName("info").getChildByName("def").getComponent(Label).string = "+"+this.hero.def_up
lvup.getChildByName("info").getChildByName("hp").getComponent(Label).string = "+"+this.hero.hp_up
slvup.getChildByName("gold").getChildByName("need").getComponent(Label).string = (UpGold.SlvUp*(this.role.slv+1)).toString()
slvup.getChildByName("cost").getChildByName("need").getComponent(Label).string = ((SlvUp[1]+this.hero.slvexp)*1).toString()
// slvup.getChildByName("gold").getChildByName("need").getComponent(Label).string = (UpGold.SlvUp*(this.role.slv+1)).toString()
slvup.getChildByName("cost").getChildByName("need").getComponent(Label).string = ((SlvUp[this.role.slv]-HeroInfo[this.h_uuid].slvexp)*(1+this.role.slv)).toString()
slvup.getChildByName("cost").getChildByName("num").getComponent(Label).string = smc.heros[this.h_uuid].num.toString()
slvup.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= slvup.getChildByName("cost").getChildByName("hchip").getComponent(HChipComp)
hchipcomp.update_data(this.h_uuid,0)
//todo cost icon 需要通过预制体进行变更
slvup.getChildByName("info").getChildByName("ap").getComponent(Label).string = "+"+this.hero.sap_up+"%"
slvup.getChildByName("info").getChildByName("def").getComponent(Label).string = "+"+this.hero.sdef_up+"%"
slvup.getChildByName("info").getChildByName("hp").getComponent(Label).string = "+"+this.hero.shp_up+"%"
@@ -152,31 +156,26 @@ export class HeroHomeComp extends CCComp {
lv_up(){
if(smc.vmdata.items[1001].num < ((LvUp[0]+this.hero.lvexp)*this.role.lv)||smc.vmdata.items[9001].num < (UpGold.LvUp*this.role.lv)){
if(smc.vmdata.items[1001].num < ((LvUp[0]+this.hero.lvexp)*this.role.lv)){
oops.gui.toast("资源不足,升级失败");
return
}
smc.vmdata.items[1001].num -= ((LvUp[0]+this.hero.lvexp)*this.role.lv)
smc.vmdata.items[9001].num -= (UpGold.LvUp*this.role.lv)
this.role.lv++
this.update_data()
}
slv_up(){
if(this.role.slv>=5){
oops.gui.toast("已经满星,升星失败");
return
}
if(smc.heros[this.h_uuid].num < SlvUp[this.role.slv]*(1+this.role.slv)||smc.vmdata.items[9001].num < (UpGold.SlvUp*(this.role.slv+1))){
if(smc.heros[this.h_uuid].num < ((SlvUp[this.role.slv]-HeroInfo[this.h_uuid].slvexp)*(1+this.role.slv))){
oops.gui.toast("资源不足,升星失败");
return
}
smc.heros[this.h_uuid].num -= SlvUp[this.role.slv]*(1+this.role.slv)
smc.vmdata.items[9001].num -= (UpGold.SlvUp*(this.role.slv+1))
this.role.slv++
this.update_data()
}
item_show(e:any,val:any){
oops.gui.open(UIID.ItemInfo, Items[val]);