完成开箱抽卡 和 怪物掉落设置

This commit is contained in:
walkpan
2025-01-19 23:43:14 +08:00
parent cebf09a58c
commit d756516cc6
30 changed files with 51192 additions and 38040 deletions

View File

@@ -30,7 +30,7 @@ export class HChipComp extends Component {
const sprite = this.node.getChildByName("hero").getChildByName("icon").getComponent(Sprite);
sprite.spriteFrame = atlas.getSpriteFrame(HeroInfo[uuid].path);
});
if(num > 0){
if(num > 1){
this.node.getChildByName("num").getComponent(Label).string = num.toString();
}else{
this.node.getChildByName("num").getComponent(Label).string = "";

View File

@@ -38,7 +38,7 @@ export class HeroCardComp extends CCComp {
}
}
show_bg(val:boolean){
this.node.getChildByName("show").active=val
// this.node.getChildByName("show").active=val
}
update_data(){
let slv = this.node.getChildByName("slv")
@@ -57,17 +57,9 @@ export class HeroCardComp extends CCComp {
this.node.getChildByName("need").getComponent(Label).string = lvneed.toString()
this.node.getChildByName("num").getComponent(Label).string = lvnum.toString()
this.node.getChildByName("bar").getComponent(ProgressBar).progress = lvnum/lvneed
// switch(HeroInfo[this.h_uuid].quality){
// case 1:
// this.node.getChildByName("bg").getComponent(Sprite).color= new Color().fromHEX(ColorSet["BLUE"]);
// break;
// case 2:
// this.node.getChildByName("bg").getComponent(Sprite).color= new Color().fromHEX(ColorSet["YELLOW"]);
// break;
// case 3:
// this.node.getChildByName("bg").getComponent(Sprite).color= new Color().fromHEX(ColorSet["RED"]);
// break;
// }
this.node.getChildByName("g1").active=HeroInfo[this.h_uuid].quality==1
this.node.getChildByName("g2").active=HeroInfo[this.h_uuid].quality==2
this.node.getChildByName("g3").active=HeroInfo[this.h_uuid].quality==3
}
call_hero(uuid:number){

View File

@@ -55,25 +55,17 @@ export class HeroSelectComp extends CCComp {
this.node.getChildByName("show").active=val
}
update_data(){
let slv = this.node.getChildByName("slv")
// let slv = this.node.getChildByName("slv")
this.node.getChildByName("lv").getComponent(Label).string=smc.heros[this.h_uuid].lv.toString()+"级"
if(smc.heros[this.h_uuid].slv==0){
slv.active=false
}else{
slv.active=true
slv.getChildByName("slv").getComponent(Label).string=smc.heros[this.h_uuid].slv.toString()
}
switch(HeroInfo[this.h_uuid].quality){
case 1:
this.node.getChildByName("bg").getComponent(Sprite).color= new Color().fromHEX(ColorSet["BLUE"]);
break;
case 2:
this.node.getChildByName("bg").getComponent(Sprite).color= new Color().fromHEX(ColorSet["YELLOW"]);
break;
case 3:
this.node.getChildByName("bg").getComponent(Sprite).color= new Color().fromHEX(ColorSet["RED"]);
break;
}
// if(smc.heros[this.h_uuid].slv==0){
// slv.active=false
// }else{
// slv.active=true
// slv.getChildByName("slv").getComponent(Label).string=smc.heros[this.h_uuid].slv.toString()
// }
this.node.getChildByName("g1").active=HeroInfo[this.h_uuid].quality==1
this.node.getChildByName("g2").active=HeroInfo[this.h_uuid].quality==2
this.node.getChildByName("g3").active=HeroInfo[this.h_uuid].quality==3
}
/** 全局消息逻辑处理 */
// private onHandler(event: string, args: any) {

View File

@@ -23,6 +23,7 @@ import { TimerManager } from "../../../../extensions/oops-plugin-framework/asset
import { HeroSet } from "../common/config/heroSet";
import { BuffComp } from "./BuffComp";
import { MonModelComp } from "./MonModelComp";
import { getMonsterDrops, MonsterType } from "../common/config/RewardSet";
const { ccclass, property } = _decorator;
/** 角色显示组件 */
@@ -53,6 +54,7 @@ export class HeroViewComp extends CCComp {
is_stop:boolean = false;
is_atking:boolean = false;
is_boss:boolean = false;
is_big_boss:boolean = false;
hp: number = 100; /** 血量 */
hp_max: number = 100; /** 最大血量 */
@@ -848,8 +850,35 @@ export class HeroViewComp extends CCComp {
this.BUFFCOMP.dead()
this.exp_add(this.dexp)
this.power_add(this.dpw)
this.to_drop()
}
//掉落物品
to_drop(){
let Drops = getMonsterDrops(1, MonsterType.Normal, 1.2);
if(this.is_boss) Drops =getMonsterDrops(1, MonsterType.Elite, 1.2);
if(this.is_big_boss) Drops =getMonsterDrops(1, MonsterType.Boss, 1.2);
console.log("掉落物品:",Drops);
//根据掉落类型和uuid 写入用户数据文件SingletonModuleComp =smc英雄碎片对应smc.heros[uuid].num,smc.heros[uuid].x1 记录本局掉落的数量,也需要添加对应值
//金币uuid=9001 对应smc.vmdata.gold.num,宝箱uuid1003,对应smc.vmdata.box.num smc.itmes[9001].x1,smc.itmes[1003].x1 记录本局
for (let i = 0; i < Drops.length; i++) {
const drop = Drops[i];
if(drop.type == 1 ){ //英雄碎片
smc.heros[drop.uuid].num += drop.num
smc.heros[drop.uuid].x1 += drop.num
}
if(drop.type==2){
if(drop.uuid == 9001){
smc.vmdata.gold.num+=drop.num
smc.items[9001].x1+=drop.num
}
if(drop.uuid == 1003){
smc.vmdata.box.num+=drop.num
smc.items[1003].x1+=drop.num
}
}
}
}
//进入墓地
to_grave(){
let pos =v3(-999,this.node.position.y)