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

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

View File

@@ -28,8 +28,8 @@ export class SingletonModuleComp extends ecs.Comp {
mmskill:6002,
};
skills: any = {
6001:{uuid:6001,slv:0,num:4,x1:1},
6002:{uuid:6002,slv:0,num:3,x1:2},
6001:{uuid:6001,slv:0,num:4,x1:0},
6002:{uuid:6002,slv:0,num:3,x1:0},
6003:{uuid:6003,slv:0,num:0,x1:0},
6004:{uuid:6004,slv:0,num:0,x1:0},
6005:{uuid:6005,slv:0,num:0,x1:0},
@@ -40,66 +40,60 @@ export class SingletonModuleComp extends ecs.Comp {
};
/** 游戏主角 */
heros:any={
5001:{uuid:5001,lv:1,exp:0,slv:1,num:10000,x1:0},
5002:{uuid:5002,lv:2,exp:0,slv:1,num:0,x1:0},
5003:{uuid:5003,lv:3,exp:0,slv:1,num:0,x1:0},
5001:{uuid:5001,lv:1,exp:0,slv:1,num:0,x1:0},
5002:{uuid:5002,lv:1,exp:0,slv:1,num:0,x1:0},
5003:{uuid:5003,lv:1,exp:0,slv:1,num:0,x1:0},
5004:{uuid:5004,lv:1,exp:0,slv:1,num:0,x1:0},
5005:{uuid:5005,lv:2,exp:0,slv:1,num:0,x1:0},
5006:{uuid:5006,lv:3,exp:0,slv:1,num:0,x1:0},
5007:{uuid:5007,lv:3,exp:0,slv:1,num:0,x1:0},
5008:{uuid:5008,lv:3,exp:0,slv:1,num:0,x1:0},
5009:{uuid:5009,lv:3,exp:0,slv:1,num:0,x1:0},
5010:{uuid:5010,lv:3,exp:0,slv:1,num:0,x1:0},
5011:{uuid:5011,lv:3,exp:0,slv:1,num:0,x1:0},
5012:{uuid:5012,lv:3,exp:0,slv:1,num:0,x1:0},
5013:{uuid:5013,lv:3,exp:0,slv:1,num:0,x1:0},
5014:{uuid:5014,lv:3,exp:0,slv:1,num:0,x1:0},
5015:{uuid:5015,lv:3,exp:0,slv:1,num:0,x1:0},
5016:{uuid:5016,lv:3,exp:0,slv:1,num:0,x1:0},
5017:{uuid:5017,lv:3,exp:0,slv:1,num:0,x1:0},
5018:{uuid:5018,lv:3,exp:0,slv:1,num:0,x1:0},
5019:{uuid:5019,lv:3,exp:0,slv:1,num:0,x1:0},
5020:{uuid:5020,lv:3,exp:0,slv:1,num:0,x1:0},
5021:{uuid:5021,lv:3,exp:0,slv:1,num:0,x1:0},
5022:{uuid:5022,lv:3,exp:0,slv:1,num:0,x1:0},
5023:{uuid:5023,lv:3,exp:0,slv:1,num:0,x1:0},
5024:{uuid:5024,lv:3,exp:0,slv:1,num:0,x1:0},
5025:{uuid:5025,lv:3,exp:0,slv:1,num:0,x1:0},
5026:{uuid:5026,lv:3,exp:0,slv:1,num:0,x1:0},
5027:{uuid:5027,lv:3,exp:0,slv:1,num:0,x1:0},
5028:{uuid:5028,lv:3,exp:0,slv:1,num:0,x1:0},
5029:{uuid:5029,lv:3,exp:0,slv:1,num:0,x1:0},
5030:{uuid:5030,lv:3,exp:0,slv:1,num:0,x1:0},
5005:{uuid:5005,lv:1,exp:0,slv:1,num:0,x1:0},
5006:{uuid:5006,lv:1,exp:0,slv:1,num:0,x1:0},
5007:{uuid:5007,lv:1,exp:0,slv:1,num:0,x1:0},
5008:{uuid:5008,lv:1,exp:0,slv:1,num:0,x1:0},
5009:{uuid:5009,lv:1,exp:0,slv:1,num:0,x1:0},
5010:{uuid:5010,lv:1,exp:0,slv:1,num:0,x1:0},
5011:{uuid:5011,lv:1,exp:0,slv:1,num:0,x1:0},
5012:{uuid:5012,lv:1,exp:0,slv:1,num:0,x1:0},
5013:{uuid:5013,lv:1,exp:0,slv:1,num:0,x1:0},
5014:{uuid:5014,lv:1,exp:0,slv:1,num:0,x1:0},
5015:{uuid:5015,lv:1,exp:0,slv:1,num:0,x1:0},
5016:{uuid:5016,lv:1,exp:0,slv:1,num:0,x1:0},
5017:{uuid:5017,lv:1,exp:0,slv:1,num:0,x1:0},
5018:{uuid:5018,lv:1,exp:0,slv:1,num:0,x1:0},
5019:{uuid:5019,lv:1,exp:0,slv:1,num:0,x1:0},
5020:{uuid:5020,lv:1,exp:0,slv:1,num:0,x1:0},
5021:{uuid:5021,lv:1,exp:0,slv:1,num:0,x1:0},
5022:{uuid:5022,lv:1,exp:0,slv:1,num:0,x1:0},
5023:{uuid:5023,lv:1,exp:0,slv:1,num:0,x1:0},
5024:{uuid:5024,lv:1,exp:0,slv:1,num:0,x1:0},
5025:{uuid:5025,lv:1,exp:0,slv:1,num:0,x1:0},
5026:{uuid:5026,lv:1,exp:0,slv:1,num:0,x1:0},
5027:{uuid:5027,lv:1,exp:0,slv:1,num:0,x1:0},
// 5028:{uuid:5028,lv:1,exp:0,slv:1,num:0,x1:0},
// 5029:{uuid:5029,lv:1,exp:0,slv:1,num:0,x1:0},
// 5030:{uuid:5030,lv:1,exp:0,slv:1,num:0,x1:0},
};
goods:any=[
{uuid:9001,num:100000,type:0,cost:0,inventory:5},
{uuid:9003,num:1000,type:1,cost:0,inventory:5},
{uuid:1001,num:10,type:2,cost:10000,inventory:99},
{uuid:1001,num:10,type:2,cost:10000,inventory:99},
{uuid:1001,num:10,type:2,cost:10000,inventory:99},
{uuid:1001,num:10,type:2,cost:10000,inventory:99},
{uuid:1001,num:10,type:2,cost:10000,inventory:99},
{uuid:1001,num:10,type:2,cost:10000,inventory:99},
{uuid:9001,num:100000,type:0,cost:0,inventory:5},
{uuid:1003,num:10,type:2,cost:10000,inventory:99},
];
items:any={
1001:{uuid:1001,num:10,x1:1},
1002:{uuid:1002,num:10,x1:1},
1003:{uuid:1003,num:10,x1:1},
1004:{uuid:1004,num:1000,x1:0},
1005:{uuid:1005,num:1000,x1:0},
1006:{uuid:1006,num:1000,x1:0},
1007:{uuid:1007,num:1000,x1:0},
1008:{uuid:1008,num:1000,x1:0},
1009:{uuid:1009,num:1000,x1:0},
1010:{uuid:1010,num:1000,x1:0},
1011:{uuid:1011,num:1000,x1:0},
1012:{uuid:1012,num:1000,x1:0},
1013:{uuid:1013,num:1000,x1:0},
1014:{uuid:1014,num:1000,x1:0},
1015:{uuid:1015,num:1000,x1:0},
1016:{uuid:1016,num:1000,x1:0},
9001:{uuid:9001,num:1000,x1:1000},
9003:{uuid:9003,num:1000,x1:2000},
1001:{uuid:1001,num:0,x1:0},
1002:{uuid:1002,num:0,x1:0},
1003:{uuid:1003,num:0,x1:0},
1004:{uuid:1004,num:0,x1:0},
1005:{uuid:1005,num:0,x1:0},
1006:{uuid:1006,num:0,x1:0},
1007:{uuid:1007,num:0,x1:0},
1008:{uuid:1008,num:0,x1:0},
1009:{uuid:1009,num:0,x1:0},
1010:{uuid:1010,num:0,x1:0},
1011:{uuid:1011,num:0,x1:0},
1012:{uuid:1012,num:0,x1:0},
1013:{uuid:1013,num:0,x1:0},
1014:{uuid:1014,num:0,x1:0},
1015:{uuid:1015,num:0,x1:0},
1016:{uuid:1016,num:0,x1:0},
9001:{uuid:9001,num:0,x1:0},
9003:{uuid:9003,num:0,x1:0},
};
fight_heros=[]
mheros:any = [];
@@ -127,7 +121,7 @@ export class SingletonModuleComp extends ecs.Comp {
exp_max:100,
mexp:0,
mexp_max:100,
drop:0,
buff_num:0,
hp:0,
ap:0,
@@ -158,11 +152,11 @@ export class SingletonModuleComp extends ecs.Comp {
reward_gold:0,
reward_exp:0,
},
gold:{num:999999,x1:1},
exp:{num:1000,x1:1},
skp:{num:2000,x1:1}, //技能升级点数
energy:{num:10,x1:1},
gold:{num:999999,x1:0},
exp:{num:1000,x1:0},
skp:{num:2000,x1:0}, //技能升级点数
energy:{num:10,x1:0},
box:{num:10,x1:0},
free:{ cost:0,num:3,buy:3,},
goods1:{ cost:20000,num:3,buy:3,},
herochips:{ cost:30000,num:4,buy:3,},

View File

@@ -55,6 +55,10 @@ export enum GameSet {
}
export const ColorSet: { [key: string]: string } = {
RED: "ff364d",
BLUE: "04b0f5",
YELLOW: "fed64f"
BLUE: "2CBEFF",
BLUE2: "00A8FF",
YELLOW: "E0C300" ,
YELLOW2: "DBAD00" ,
GREEN:"83CE00",
GREEN2:"17A047",
};

View File

@@ -9,22 +9,22 @@ export const Items={
1001:{uuid: 1001,path: "1001",type:1,lv:2,name: "宝箱",info:"随机获取物品", },
1002:{uuid: 1002,path: "1002",type:1,lv:3,name: "稀有宝箱",info:"随机获取少量英雄碎片", },
1003:{uuid: 1003,path: "1003",type:1,lv:4,name: "传说宝箱",info:"随机获取大量英雄碎片", },
1004:{uuid: 1004,path: "1004",type:1,lv:3,name: "xxx",info:"英雄升级三星需要的凭证", },
1005:{uuid: 1005,path: "1005",type:1,lv:3,name: "xxx",info:"英雄升级四星需要的凭证", },
1006:{uuid: 1006,path: "1006",type:1,lv:4,name: "xxx",info:"英雄升级五星需要的凭证", },
1007:{uuid: 1007,path: "1007",type:1,lv:4,name: "xxx",info:"英雄升级五星需要的凭证", },
1008:{uuid: 1008,path: "1008",type:1,lv:4,name: "黄色叶子",info:"未知功能", },
1009:{uuid: 1009,path: "1001",type:1,lv:1,name: "普通攻击石",info:"增加装备攻击力10,成功几率20%", },
1010:{uuid: 1010,path: "1010",type:1,lv:2,name: "高级攻击石",info:"增加装备攻击力10,成功几率30%", },
1011:{uuid: 1011,path: "1011",type:1,lv:3,name: "稀有攻击石",info:"增加装备攻击力10,成功几率40%", },
1012:{uuid: 1012,path: "1012",type:1,lv:4,name: "传说攻击石",info:"增加装备攻击力10,成功几率50%", },
1013:{uuid: 1013,path: "1013",type:1,lv:1,name: "普通生命石",info:"增加装备生命值50,成功几率20%", },
1014:{uuid: 1015,path: "1014",type:1,lv:2,name: "高级生命石",info:"增加装备生命值50,成功几率30%", },
1015:{uuid: 1015,path: "1015",type:1,lv:3,name: "稀有生命石",info:"增加装备生命值50,成功几率40%", },
1016:{uuid: 1016,path: "1016",type:1,lv:4,name: "传说生命石",info:"增加装备生命值50,成功几率50%", },
1003:{uuid: 1003,path: "1003",type:1,lv:4,name: "勇者宝箱",info:"可以获取英雄碎片", },
// 1004:{uuid: 1004,path: "1004",type:1,lv:3,name: "xxx",info:"英雄升级三星需要的凭证", },
// 1005:{uuid: 1005,path: "1005",type:1,lv:3,name: "xxx",info:"英雄升级四星需要的凭证", },
// 1006:{uuid: 1006,path: "1006",type:1,lv:4,name: "xxx",info:"英雄升级五星需要的凭证", },
// 1007:{uuid: 1007,path: "1007",type:1,lv:4,name: "xxx",info:"英雄升级五星需要的凭证", },
// 1008:{uuid: 1008,path: "1008",type:1,lv:4,name: "黄色叶子",info:"未知功能", },
// 1009:{uuid: 1009,path: "1001",type:1,lv:1,name: "普通攻击石",info:"增加装备攻击力10,成功几率20%", },
// 1010:{uuid: 1010,path: "1010",type:1,lv:2,name: "高级攻击石",info:"增加装备攻击力10,成功几率30%", },
// 1011:{uuid: 1011,path: "1011",type:1,lv:3,name: "稀有攻击石",info:"增加装备攻击力10,成功几率40%", },
// 1012:{uuid: 1012,path: "1012",type:1,lv:4,name: "传说攻击石",info:"增加装备攻击力10,成功几率50%", },
// 1013:{uuid: 1013,path: "1013",type:1,lv:1,name: "普通生命石",info:"增加装备生命值50,成功几率20%", },
// 1014:{uuid: 1015,path: "1014",type:1,lv:2,name: "高级生命石",info:"增加装备生命值50,成功几率30%", },
// 1015:{uuid: 1015,path: "1015",type:1,lv:3,name: "稀有生命石",info:"增加装备生命值50,成功几率40%", },
// 1016:{uuid: 1016,path: "1016",type:1,lv:4,name: "传说生命石",info:"增加装备生命值50,成功几率50%", },
9001:{uuid: 9001,path: "9001",type:1,lv:0,name: "金币",info:"金币不是万能的,但是没有金币是万万不能的", },
9002:{uuid: 9002,path: "9002",type:1,lv:1,name: "叶子",info:"提升英雄等级的神奇叶子", },
9003:{uuid: 9003,path: "9003",type:1,lv:1,name: "经验",info:"提升英雄等级", },
// 9002:{uuid: 9002,path: "9002",type:1,lv:1,name: "叶子",info:"提升英雄等级的神奇叶子", },
// 9003:{uuid: 9003,path: "9003",type:1,lv:1,name: "经验",info:"提升英雄等级", },
}

View File

@@ -1,3 +1,222 @@
// 掉落物品接口
export interface DropItem {
uuid: number; // 物品ID
num: number; // 数量
type: number; // 类型
quality?: number; // 品质
}
// 怪物类型
export enum MonsterType {
Normal = 1, // 普通怪
Elite = 2, // 精英怪
Boss = 3, // Boss怪
}
// 掉落倍率配置
export const DropRateConfig = {
[MonsterType.Normal]: 1,
[MonsterType.Elite]: 2,
[MonsterType.Boss]: 10,
}
// Boss掉落示例最多5个不同英雄的碎片
// const bossDrops = getMonsterDrops(50, MonsterType.Boss, 1.2);
// 精英怪掉落示例最多2个不同英雄的碎片
// const eliteDrops = getMonsterDrops(50, MonsterType.Elite, 1.2);
// 普通怪掉落示例最多1个英雄的碎片
// const normalDrops = getMonsterDrops(50, MonsterType.Normal, 1.2);
/**
* 获取怪物掉落
* @param monsterLevel 怪物等级
* @param monsterType 怪物类型
* @param extraRate 额外倍率(比如玩家的幸运值加成)
* @returns 掉落物品数组
*/
export function getMonsterDrops(
monsterLevel: number,
monsterType: MonsterType = MonsterType.Normal,
extraRate: number = 1
): DropItem[] {
const drops: DropItem[] = [];
const baseMultiplier = getDropMultiplier(monsterLevel);
const monsterMultiplier = DropRateConfig[monsterType];
const totalMultiplier = baseMultiplier * monsterMultiplier * extraRate;
// 分离英雄碎片和道具配置
const heroChipConfigs = DropConfigList.filter(config => config.type === dorptype.hero_chip);
const itemConfigs = DropConfigList.filter(config => config.type === dorptype.items);
// 获取当前怪物类型可以掉落的英雄碎片数量
const maxHeroChips = HeroChipDropCount[monsterType];
// 随机选择指定数量的英雄碎片
const selectedHeroChips = shuffleArray(heroChipConfigs).slice(0, maxHeroChips);
// 处理英雄碎片掉落
for (const config of selectedHeroChips) {
if (monsterType === MonsterType.Normal) {
// 普通怪按概率掉落
if (shouldDrop(config.dropRate * totalMultiplier)) {
const dropItem = calculateDrop(config, monsterLevel, monsterType);
if (dropItem) {
drops.push(dropItem);
}
}
} else {
// 精英怪和Boss必定掉落
const dropItem = calculateDrop(config, monsterLevel, monsterType);
if (dropItem) {
drops.push(dropItem);
}
}
}
// 处理道具掉落
for (const config of itemConfigs) {
if (config.uuid === 9001) {
// 金币必定掉落
const dropItem = calculateDrop(config, monsterLevel, monsterType);
if (dropItem) {
drops.push(dropItem);
}
} else {
// 其他道具按概率掉落
if (shouldDrop(config.dropRate * totalMultiplier)) {
const dropItem = calculateDrop(config, monsterLevel, monsterType);
if (dropItem) {
drops.push(dropItem);
}
}
}
}
return drops;
}
/**
* 计算是否掉落
* @param rate 掉落概率
*/
function shouldDrop(rate: number): boolean {
return Math.random() * 100 <= Math.min(rate, 100);
}
/**
* 计算单个物品掉落
*/
function calculateDrop(
config: typeof DropConfigList[0],
monsterLevel: number,
monsterType: MonsterType
): DropItem | null {
// 计算掉落数量
let num = Math.floor(Math.random() * config.num_max) + 1;
// Boss额外保底
if (monsterType === MonsterType.Boss && num < config.num_max * 0.3) {
num = Math.floor(config.num_max * 0.3);
}
// 根据类型应用不同规则
if (config.type === dorptype.hero_chip) {
// 英雄碎片特殊处理
return {
uuid: config.uuid,
num: Math.min(num, 10), // 英雄碎片单次最多10个
type: config.type,
quality: getHeroQuality(config.uuid)
};
} else if (config.type === dorptype.items) {
// 普通道具处理
return {
uuid: config.uuid,
num: num,
type: config.type
};
}
return null;
}
/**
* 获取英雄品质需要和heroSet配置关联
*/
function getHeroQuality(heroId: number): number {
// 这里可以从heroSet中获取英雄品质
return 1; // 默认品质
}
/**
* 获取掉落倍率
* @param monsterLevel 怪物等级
*/
export function getDropMultiplier(monsterLevel: number): number {
// 基础倍率
let multiplier = Math.max(1, Math.floor(monsterLevel / 10));
// 等级档位加成
if (monsterLevel >= 50) multiplier *= 1.5;
if (monsterLevel >= 100) multiplier *= 2;
return multiplier;
}
/**
* 批量生成掉落
* @param times 掉落次数
* @param params 掉落参数
*/
export function batchGenerateDrops(
times: number,
monsterLevel: number,
monsterType: MonsterType = MonsterType.Normal,
extraRate: number = 1
): DropItem[] {
const allDrops: DropItem[] = [];
for (let i = 0; i < times; i++) {
const drops = getMonsterDrops(monsterLevel, monsterType, extraRate);
allDrops.push(...drops);
}
// 合并相同物品
return mergeDrops(allDrops);
}
/**
* 合并相同物品的掉落
*/
function mergeDrops(drops: DropItem[]): DropItem[] {
const mergedMap = new Map<string, DropItem>();
drops.forEach(drop => {
const key = `${drop.uuid}-${drop.type}`;
if (mergedMap.has(key)) {
const existing = mergedMap.get(key)!;
existing.num += drop.num;
} else {
mergedMap.set(key, {...drop});
}
});
return Array.from(mergedMap.values());
}
/**
* 随机打乱数组
*/
function shuffleArray<T>(array: T[]): T[] {
const newArray = [...array];
for (let i = newArray.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[newArray[i], newArray[j]] = [newArray[j], newArray[i]];
}
return newArray;
}
export const BoxDrop={
1:[
@@ -5,14 +224,62 @@ export const BoxDrop={
{uuid: 9003,dropRate: 10,num_max: 500,type:0},
],
2:[
{uuid: 5001,dropRate: 10,num_max: 10,type:0},
{uuid: 5002,dropRate: 10,num_max: 10,type:0},
{uuid: 5003,dropRate: 50,num_max: 10,type:0},
{uuid: 5001,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5002,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5003,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5004,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5005,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5006,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5007,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5008,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5009,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5010,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5011,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5012,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5013,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5014,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5015,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5016,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5017,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5018,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5019,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5020,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5021,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5022,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5023,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5024,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5025,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5026,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5027,dropRate: 100/7,num_max: 5,type:1},
],
3:[
{uuid: 5001,dropRate: 20,num_max: 10,type:0},
{uuid: 5002,dropRate: 20,num_max: 10,type:0},
{uuid: 5003,dropRate: 50,num_max: 10,type:0},
{uuid: 5001,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5002,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5003,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5004,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5005,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5006,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5007,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5008,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5009,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5010,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5011,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5012,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5013,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5014,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5015,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5016,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5017,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5018,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5019,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5020,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5021,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5022,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5023,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5024,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5025,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5026,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5027,dropRate: 100/7,num_max: 5,type:1},
],
}
export const BoxDropCount={
@@ -20,4 +287,66 @@ export const BoxDropCount={
2:3,
3:3,
}
export const dorptype={
hero_chip:1,
items:2,
}
export const HeroChipDropCount={
1:1,
2:2,
3:5,
}
//HeroChipList = [5001,5002,5003,5004,5005,5006,5007,5008,5009,5010,5011,5012,5013,5014,5015,5016,5017,5018,5019,5020,5021,5022,5023,5024,5025,5026,5027]
//ItemsList=[9001,1003]
//根据HeroChipListItemsList设置掉落概率
export const DropConfigList=[
{uuid: 5001,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5002,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5003,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5004,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5005,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5006,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5007,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5008,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5009,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5010,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5011,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5012,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5013,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5014,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5015,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5016,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5017,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5018,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5019,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5020,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5021,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5022,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5023,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5024,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5025,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5026,dropRate: 100/7,num_max: 5,type:1},
{uuid: 5027,dropRate: 100/7,num_max: 5,type:1},
{uuid: 9001,dropRate: 100,num_max: 1000,type:2},
{uuid: 1003,dropRate: 20,num_max: 1,type:2},
]
// 使用示例:
/*
// 单次掉落
const drops = getMonsterDrops(50, MonsterType.Boss, 1.2);
// 批量掉落(比如连续击杀多个怪物)
const batchDrops = batchGenerateDrops(5, 50, MonsterType.Elite, 1.2);
// 处理掉落物品
drops.forEach(item => {
if (item.type === dorptype.hero_chip) {
// 处理英雄碎片
console.log(`获得英雄碎片: ${item.uuid} x${item.num}`);
} else if (item.type === dorptype.items) {
// 处理道具
console.log(`获得道具: ${item.uuid} x${item.num}`);
}
});
*/

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)

View File

@@ -37,18 +37,10 @@ export class HCardComp extends CCComp {
this.pw=this.node.getChildByName("pow").getComponent(ProgressBar)!
this.hc_name.string= this.heros[this.hi].HeroView.hero_name
// this.node.getChildByName("lv").getComponent(Label).string=this.heros[this.hi].HeroView.lv.toString()+"级";
// console.log("hcard start",this.heros[this.hi].HeroView.hero_uuid)
switch(HeroInfo[this.heros[this.hi].HeroView.hero_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;
}
// // console.log("hcard start",this.heros[this.hi].HeroView.hero_uuid)
// this.node.getChildByName("g1").active=HeroInfo[this.heros[this.hi].HeroView.hero_uuid].quality==1
// this.node.getChildByName("g2").active=HeroInfo[this.heros[this.hi].HeroView.hero_uuid].quality==2
// this.node.getChildByName("g3").active=HeroInfo[this.heros[this.hi].HeroView.hero_uuid].quality==3
}
protected update(dt: number): void {
if(this.is_dead) return

View File

@@ -36,7 +36,7 @@ export class HeroHomeComp extends CCComp {
loads(){
let hc:number =HeroList.length
let parent= this.node.getChildByName("heros").getChildByName("view").getChildByName("content")
parent.getComponent(UITransform).setContentSize(720,Math.ceil(HeroList.length/4)*200)
parent.getComponent(UITransform).setContentSize(720,Math.ceil(HeroList.length/4)*230)
console.log("parent",parent)
for (let i = 0; i < hc; i++) {
if (HeroInfo[HeroList[i]].quality==3) {

View File

@@ -33,85 +33,42 @@ export class LuckHomeCompComp extends CCComp {
start() {
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
// this.on(ModuleEvent.Cmd, this.onHandler, this);
this.frist();
// this.frist();
}
frist(){
if(smc.items[1001].num > 0){this.select_box(null,"sb");}
else if(smc.items[1002].num > 0){this.select_box(null,"mb");}
else if(smc.items[1003].num > 0){this.select_box(null,"lb");}
this.check_num();
this.colse_reward()
}
check_num(){
this.sbn.getChildByName("num").getComponent(Label).string = smc.items[1001].num.toString();
this.mbn.getChildByName("num").getComponent(Label).string = smc.items[1002].num.toString();
this.lbn.getChildByName("num").getComponent(Label).string = smc.items[1003].num.toString();
}
select_box(e:any, val:string){
this.sbn.setScale(1,1,1);
this.mbn.setScale(1,1,1);
this.lbn.setScale(1,1,1);
switch(val){
case "sb":
this.sbn.setScale(1.2,1.2,1);
if(smc.items[1001].num > 0){
this.btnno.active = false;
this.selected="sb"
}else{
this.btnno.active = true
}
break;
case "mb":
this.mbn.setScale(1.2,1.2,1);
if(smc.items[1002].num > 0){
this.btnno.active = false;
this.selected="mb"
}else{
this.btnno.active = true
}
break;
case "lb":
this.lbn.setScale(1.2,1.2,1);
if(smc.items[1003].num > 0){
this.btnno.active = false;
this.selected="lb"
}else{
this.btnno.active = true
}
break;
default:
this.selected="";
break;
}
}
open_sb() {
smc.items[1001].num--;
this.show_bbox()
this.check_num()
this.scheduleOnce(()=>{
this.get_reward(1)
}, 0.5)
smc.vmdata.box.num--;
this.open_reward()
this.get_reward(1)
}
open_mb() {
smc.items[1002].num--;
this.show_bbox()
this.check_num()
this.scheduleOnce(()=>{
if (smc.vmdata.box.num <=0) {oops.gui.toast("宝箱数量不足");return;}
smc.vmdata.box.num=smc.vmdata.box.num-5;
this.open_reward()
for (let x = 0; x < 5; x++) {
this.get_reward(2)
}, 0.5)
}
}
open_lb() {
smc.items[1003].num--;
this.show_bbox()
this.check_num()
this.scheduleOnce(()=>{
this.get_reward(3)
}, 0.5)
if (smc.vmdata.box.num <=0) {oops.gui.toast("宝箱数量不足");return;}
smc.vmdata.box.num=smc.vmdata.box.num-15;
this.open_reward()
for (let x = 0; x < 15; x++) {
this.get_reward(2)
}
}
colse_reward() {
this.node.getChildByName("reward").setScale(0,0,0);
this.node.getChildByName("reward").getChildByName("items").removeAllChildren();
}
open_reward() {
this.node.getChildByName("reward").setScale(1,1,1);
}
get_reward(reward:number){
console.log("get_reward",reward)
let list =BoxDrop[reward];
let uuid= 0
let num =1
@@ -156,53 +113,30 @@ export class LuckHomeCompComp extends CCComp {
}
}
show_hero_chip(uuid:number,num:number){
console.log("show_hero_chip",uuid,num)
let path = "game/gui/hchip";
let prefab: Prefab = oops.res.get(path, Prefab)!;
let node = instantiate(prefab);
node.setScale(2,2)
let hc= node.getComponent(HChipComp)
hc.update_data(uuid,num)
node.parent = this.node.getChildByName("bbox");
this.scheduleOnce(()=>{
node.parent = this.node.getChildByName("items");
node.setScale(1,1)
}, 0.5)
this.scheduleOnce(()=>{
node.destroy();
}, 10)
node.parent = this.node.getChildByName("reward").getChildByName("items");
}
show_item(uuid:number,num:number){
var path = "game/gui/item";
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
node.setScale(2,2)
let ic= node.getComponent(ItemComp)
ic.update_data(uuid,num)
node.parent = this.node.getChildByName("bbox");
this.scheduleOnce(()=>{
node.parent = this.node.getChildByName("items");
node.setScale(1,1)
}, 0.5)
this.scheduleOnce(()=>{
node.destroy();
}, 10)
node.parent = this.node.getChildByName("reward").getChildByName("items");
}
show_skill_chip(uuid:number,num:number){
let path = "game/gui/schip";
let prefab: Prefab = oops.res.get(path, Prefab)!;
let node = instantiate(prefab);
node.setScale(2,2)
let sc= node.getComponent(SChipComp)
sc.update_data(uuid,num)
node.parent = this.node.getChildByName("bbox");
this.scheduleOnce(()=>{
node.parent = this.node.getChildByName("items");
node.setScale(1,1)
}, 0.5)
this.scheduleOnce(()=>{
node.destroy();
}, 10)
node.parent = this.node.getChildByName("reward").getChildByName("items");
}
show_bbox() {
var parent = this.node.getChildByName("bbox")

View File

@@ -50,41 +50,46 @@ export class VictoryComp extends CCComp {
}
}
do_x10(){
for (let i in smc.items) {
if(smc.items[i].uuid == 9001){
smc.vmdata.gold.num+=smc.items[i].x1*10
}
if(smc.items[i].uuid == 9003){
smc.vmdata.exp.num+=smc.items[i].x1*10
}
if(smc.items[i].uuid < 9000){
smc.items[i].num+=smc.items[i].x1*10
// for (let i in smc.items) {
// if(smc.items[i].uuid == 9001){
// smc.vmdata.gold.num+=smc.items[i].x1*10
// }
// if(smc.items[i].uuid == 9003){
// smc.vmdata.exp.num+=smc.items[i].x1*10
// }
// if(smc.items[i].uuid == 1003){
// smc.vmdata.box.num+=smc.items[i].x1*10
// }
// if(smc.items[i].uuid < 9000){
// smc.items[i].num+=smc.items[i].x1*10
}
}
for (let i in smc.heros) {
smc.heros[i].num+=smc.heros[i].x1*10
}
// }
// }
// for (let i in smc.heros) {
// smc.heros[i].num+=smc.heros[i].x1*10
// }
this.clear_x1()
}
do_x1(){
for (let i in smc.items) {
if(smc.items[i].uuid == 9001){
smc.vmdata.gold.num+=smc.items[i].x1
}
if(smc.items[i].uuid == 9003){
smc.vmdata.exp.num+=smc.items[i].x1
}
if(smc.items[i].uuid < 9000){
smc.items[i].num+=smc.items[i].x1
// for (let i in smc.items) {
// if(smc.items[i].uuid == 9001){
// smc.vmdata.gold.num+=smc.items[i].x1
// }
// if(smc.items[i].uuid == 9003){
// smc.vmdata.exp.num+=smc.items[i].x1
// }
// if(smc.items[i].uuid == 1003){
// smc.vmdata.box.num+=smc.items[i].x1
// }
// if(smc.items[i].uuid < 9000){
// smc.items[i].num+=smc.items[i].x1
}
}
for (let i in smc.heros) {
smc.heros[i].num+=smc.heros[i].x1
}
// }
// }
// for (let i in smc.heros) {
// smc.heros[i].num+=smc.heros[i].x1
// }
this.clear_x1()
}
clear_x1(){