奖励已经双倍奖励
This commit is contained in:
@@ -19,6 +19,7 @@ export enum UIID {
|
||||
HeroInfo,
|
||||
Victory,
|
||||
HeroSelect,
|
||||
ItemInfo,
|
||||
// Shop_Page,
|
||||
// Hero_Page,
|
||||
}
|
||||
@@ -32,6 +33,7 @@ export var UIConfigData: { [key: number]: UIConfig } = {
|
||||
[UIID.HeroInfo]: { layer: LayerType.UI, prefab: "gui/Hinfo" },
|
||||
[UIID.Victory]: { layer: LayerType.UI, prefab: "gui/element/victory" },
|
||||
[UIID.HeroSelect]: { layer: LayerType.UI, prefab: "gui/hero_select" },
|
||||
[UIID.ItemInfo]: { layer: LayerType.UI, prefab: "gui/element/item_info" },
|
||||
// [UIID.Shop_Page]: { layer: LayerType.UI, prefab: "gui/shop_page" },
|
||||
// [UIID.Hero_Page]: { layer: LayerType.UI, prefab: "gui/heros_page" },
|
||||
// [UIID.Toast]: { layer: LayerType.PopUp, prefab: "common/prefab/toast" },
|
||||
|
||||
@@ -1,31 +1,217 @@
|
||||
/*
|
||||
type:
|
||||
1 普通消耗品,武器升级或技能升级原材料
|
||||
2 可双击打开,如宝箱,
|
||||
ghstone:0, //英雄石 绿色 普通英雄升星
|
||||
bhstone:0, //英雄石 蓝色 稀有英雄升星
|
||||
phlestone:0, //英雄石 紫色 史诗英雄升星
|
||||
rhstone:0, //英雄石 红色 传说英雄升星
|
||||
herocard:0, //英雄卡,抽卡凭证
|
||||
ckey:0, //铜钥匙 解锁稀有英雄 也可以直接兑换金币
|
||||
skey:0, //银钥匙 解锁史诗英雄 也可以直接兑换金币
|
||||
gkey:0, //金钥匙 解锁传说英雄 也可以直接兑换金币
|
||||
|
||||
|
||||
*/
|
||||
|
||||
import * as exp from "constants";
|
||||
import { QualitySet } from "./BoxSet";
|
||||
|
||||
|
||||
export const Items={
|
||||
1001:{uuid: 1001,path: "1001",type:1,quality:QualitySet.GREEN,name: "经验药水",info:"增加英雄经验", },
|
||||
1002:{uuid: 1002,path: "1002",type:1,quality:QualitySet.BLUE,name: "绿色英雄石",info:"稀有英雄升星必须材料", },
|
||||
1003:{uuid: 1003,path: "1003",type:1,quality:QualitySet.BLUE,name: "蓝色英雄石",info:"史诗英雄升星必须材料", },
|
||||
1004:{uuid: 1004,path: "1004",type:1,quality:QualitySet.PURPLE,name: "紫色英雄石",info:"传说英雄升星必须材料", },
|
||||
1005:{uuid: 1005,path: "1005",type:1,quality:QualitySet.ORANGE,name: "红色英雄石",info:"传说英雄升星必须材料", },
|
||||
1006:{uuid: 1006,path: "1006",type:1,quality:QualitySet.GREEN,name: "招募劵",info:"可以在英雄酒馆招募英雄", },
|
||||
1007:{uuid: 1007,path: "1007",type:1,quality:QualitySet.BLUE,name: "铜钥匙",info:"解锁稀有英雄 也可以直接兑换金币", },
|
||||
1008:{uuid: 1008,path: "1008",type:1,quality:QualitySet.PURPLE,name: "银钥匙",info:"解锁史诗英雄 也可以直接兑换金币", },
|
||||
1009:{uuid: 1009,path: "1009",type:1,quality:QualitySet.ORANGE,name: "金钥匙",info:"解锁传说英雄 也可以直接兑换金币", },
|
||||
export enum ItemType{
|
||||
NORMAL=0,//普通
|
||||
SPECIAL=1,//特殊 可双击打开
|
||||
EQUIP=2,//装备
|
||||
}
|
||||
|
||||
// 掉落物品接口
|
||||
export interface DropItem {
|
||||
item_uuid: number; // 物品ID
|
||||
probability: number; // 掉落概率 (0-1之间)
|
||||
minCount: number; // 最小掉落数量
|
||||
maxCount: number; // 最大掉落数量
|
||||
baseCount: number; // 基础掉落数量
|
||||
growthRate: number; // 增长参数
|
||||
}
|
||||
|
||||
// 怪物掉落配置接口
|
||||
export interface MonsterDropConfig {
|
||||
monsterId: number; // 怪物ID
|
||||
quality: QualitySet; // 怪物品质
|
||||
drops: DropItem[]; // 掉落物品列表
|
||||
}
|
||||
|
||||
export const Items={
|
||||
1001:{uuid: 1001,path: "1001",type:1,quality:QualitySet.GREEN,name: "绿色英雄石",info:"稀有英雄升星必须材料", },
|
||||
1002:{uuid: 1002,path: "1002",type:1,quality:QualitySet.BLUE,name: "蓝色英雄石",info:"史诗英雄升星必须材料", },
|
||||
1003:{uuid: 1003,path: "1003",type:1,quality:QualitySet.PURPLE,name: "紫色英雄石",info:"传说英雄升星必须材料", },
|
||||
1004:{uuid: 1004,path: "1004",type:1,quality:QualitySet.ORANGE,name: "红色英雄石",info:"传说英雄升星必须材料", },
|
||||
1005:{uuid: 1005,path: "1005",type:1,quality:QualitySet.ORANGE,name: "招募劵",info:"可以在英雄酒馆招募英雄", },
|
||||
1006:{uuid: 1006,path: "1006",type:1,quality:QualitySet.BLUE,name: "铜钥匙",info:"解锁稀有英雄 也可以直接兑换金币", },
|
||||
1007:{uuid: 1007,path: "1007",type:1,quality:QualitySet.PURPLE,name: "银钥匙",info:"解锁史诗英雄 也可以直接兑换金币", },
|
||||
1008:{uuid: 1008,path: "1008",type:1,quality:QualitySet.ORANGE,name: "金钥匙",info:"解锁传说英雄 也可以直接兑换金币", },
|
||||
}
|
||||
|
||||
export enum DropKey{
|
||||
ItemUUId=0, // 物品ID
|
||||
Pro=1, // 概率
|
||||
Diff=2, // 上下限差值
|
||||
Base=3, // 基础数量
|
||||
GrowthRate=4, // 增长参数
|
||||
}
|
||||
|
||||
// 怪物掉落配置表 - 按照DropKey顺序配置
|
||||
export const MonsterDropTable: { [monsterId: number]: [number, number, number, number, number][] } = {
|
||||
// 普通怪物 - 绿色品质
|
||||
5201: [ // 兽人战士
|
||||
[Items[1001].uuid, 1.0, 0, 1, 0.2], // [item_uuid, probability, diff, baseCount, growthRate] - 100%掉落1个绿色英雄石
|
||||
[Items[1006].uuid, 0.3, 0, 1, 0.1] // [item_uuid, probability, diff, baseCount, growthRate] - 30%概率掉落铜钥匙
|
||||
],
|
||||
5202: [ // 兽人刺客
|
||||
[Items[1001].uuid, 1.0, 0, 1, 0.2], // [item_uuid, probability, diff, baseCount, growthRate] - 100%掉落1个绿色英雄石
|
||||
[Items[1006].uuid, 0.4, 0, 1, 0.1] // [item_uuid, probability, diff, baseCount, growthRate] - 40%概率掉落铜钥匙
|
||||
],
|
||||
5203: [ // 兽人护卫
|
||||
[Items[1001].uuid, 1.0, 0, 1, 0.2], // [item_uuid, probability, diff, baseCount, growthRate] - 100%掉落1个绿色英雄石
|
||||
[Items[1006].uuid, 0.3, 0, 1, 0.1] // [item_uuid, probability, diff, baseCount, growthRate] - 30%概率掉落铜钥匙
|
||||
],
|
||||
5204: [ // 石卫
|
||||
[Items[1001].uuid, 1.0, 0, 1, 0.2], // [item_uuid, probability, diff, baseCount, growthRate] - 100%掉落1个绿色英雄石
|
||||
[Items[1006].uuid, 0.35, 0, 1, 0.1] // [item_uuid, probability, diff, baseCount, growthRate] - 35%概率掉落铜钥匙
|
||||
],
|
||||
5205: [ // 土卫
|
||||
[Items[1001].uuid, 1.0, 0, 1, 0.2], // [item_uuid, probability, diff, baseCount, growthRate] - 100%掉落1个绿色英雄石
|
||||
[Items[1006].uuid, 0.35, 0, 1, 0.1] // [item_uuid, probability, diff, baseCount, growthRate] - 35%概率掉落铜钥匙
|
||||
],
|
||||
5206: [ // 树卫
|
||||
[Items[1001].uuid, 1.0, 0, 1, 0.2], // [item_uuid, probability, diff, baseCount, growthRate] - 100%掉落1个绿色英雄石
|
||||
[Items[1006].uuid, 0.35, 0, 1, 0.1] // [item_uuid, probability, diff, baseCount, growthRate] - 35%概率掉落铜钥匙
|
||||
],
|
||||
5219: [ // 牛头战士
|
||||
[Items[1001].uuid, 1.0, 1, 1, 0.25], // [item_uuid, probability, diff, baseCount, growthRate] - 100%掉落1-2个绿色英雄石
|
||||
[Items[1006].uuid, 0.4, 0, 1, 0.15] // [item_uuid, probability, diff, baseCount, growthRate] - 40%概率掉落铜钥匙
|
||||
],
|
||||
5220: [ // 牛头战士
|
||||
[Items[1001].uuid, 1.0, 0, 1, 0.2], // [item_uuid, probability, diff, baseCount, growthRate] - 100%掉落1个绿色英雄石
|
||||
[Items[1006].uuid, 0.3, 0, 1, 0.1] // [item_uuid, probability, diff, baseCount, growthRate] - 30%概率掉落铜钥匙
|
||||
],
|
||||
5221: [ // 牛头战士
|
||||
[Items[1001].uuid, 1.0, 0, 1, 0.2], // [item_uuid, probability, diff, baseCount, growthRate] - 100%掉落1个绿色英雄石
|
||||
[Items[1006].uuid, 0.4, 0, 1, 0.1] // [item_uuid, probability, diff, baseCount, growthRate] - 40%概率掉落铜钥匙
|
||||
],
|
||||
5222: [ // 独眼巨人
|
||||
[Items[1001].uuid, 1.0, 0, 1, 0.2], // [item_uuid, probability, diff, baseCount, growthRate] - 100%掉落1个绿色英雄石
|
||||
[Items[1006].uuid, 0.3, 0, 1, 0.1] // [item_uuid, probability, diff, baseCount, growthRate] - 30%概率掉落铜钥匙
|
||||
],
|
||||
5223: [ // 独眼巨人
|
||||
[Items[1001].uuid, 1.0, 0, 1, 0.2], // [item_uuid, probability, diff, baseCount, growthRate] - 100%掉落1个绿色英雄石
|
||||
[Items[1006].uuid, 0.3, 0, 1, 0.1] // [item_uuid, probability, diff, baseCount, growthRate] - 30%概率掉落铜钥匙
|
||||
],
|
||||
5224: [ // 独眼巨人
|
||||
[Items[1001].uuid, 1.0, 0, 1, 0.2], // [item_uuid, probability, diff, baseCount, growthRate] - 100%掉落1个绿色英雄石
|
||||
[Items[1006].uuid, 0.4, 0, 1, 0.1] // [item_uuid, probability, diff, baseCount, growthRate] - 40%概率掉落铜钥匙
|
||||
],
|
||||
|
||||
// 精英怪物 - 蓝色品质
|
||||
5225: [ // 精英独眼
|
||||
[Items[1001].uuid, 1.0, 1, 2, 0.3], // [item_uuid, probability, diff, baseCount, growthRate] - 100%掉落2-3个绿色英雄石
|
||||
[Items[1002].uuid, 1.0, 0, 1, 0.25], // [item_uuid, probability, diff, baseCount, growthRate] - 100%掉落1个蓝色英雄石
|
||||
[Items[1006].uuid, 0.6, 1, 1, 0.2], // [item_uuid, probability, diff, baseCount, growthRate] - 60%概率掉落铜钥匙
|
||||
[Items[1007].uuid, 0.2, 0, 1, 0.15] // [item_uuid, probability, diff, baseCount, growthRate] - 20%概率掉落银钥匙
|
||||
],
|
||||
5226: [ // 精英牛头
|
||||
[Items[1001].uuid, 1.0, 1, 2, 0.3], // [item_uuid, probability, diff, baseCount, growthRate] - 100%掉落2-3个绿色英雄石
|
||||
[Items[1002].uuid, 1.0, 0, 1, 0.25], // [item_uuid, probability, diff, baseCount, growthRate] - 100%掉落1个蓝色英雄石
|
||||
[Items[1006].uuid, 0.6, 1, 1, 0.2], // [item_uuid, probability, diff, baseCount, growthRate] - 60%概率掉落铜钥匙
|
||||
[Items[1007].uuid, 0.2, 0, 1, 0.15] // [item_uuid, probability, diff, baseCount, growthRate] - 20%概率掉落银钥匙
|
||||
],
|
||||
5227: [ // 精英兽人
|
||||
[Items[1001].uuid, 1.0, 1, 2, 0.3], // [item_uuid, probability, diff, baseCount, growthRate] - 100%掉落2-3个绿色英雄石
|
||||
[Items[1002].uuid, 1.0, 0, 1, 0.25], // [item_uuid, probability, diff, baseCount, growthRate] - 100%掉落1个蓝色英雄石
|
||||
[Items[1006].uuid, 0.6, 1, 1, 0.2], // [item_uuid, probability, diff, baseCount, growthRate] - 60%概率掉落铜钥匙
|
||||
[Items[1007].uuid, 0.2, 0, 1, 0.15] // [item_uuid, probability, diff, baseCount, growthRate] - 20%概率掉落银钥匙
|
||||
]
|
||||
};
|
||||
|
||||
// 怪物掉落管理器
|
||||
export class MonsterDropManager {
|
||||
|
||||
/**
|
||||
* 根据怪物ID获取掉落配置
|
||||
* @param monsterId 怪物ID
|
||||
* @returns 掉落配置
|
||||
*/
|
||||
static getDropConfig(monsterId: number): [number, number, number, number, number][] | null {
|
||||
return MonsterDropTable[monsterId] || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算指定关卡数的掉落数量
|
||||
* @param baseCount 基础数量
|
||||
* @param growthRate 增长参数
|
||||
* @param stageNumber 关卡数
|
||||
* @param diff 上下限差值
|
||||
* @returns 计算后的掉落数量
|
||||
*/
|
||||
static calculateDropCount(baseCount: number, growthRate: number, stageNumber: number, diff: number): number {
|
||||
// 公式:基础数量 * 增长参数 * 关卡数 + (0-差值的随机数)
|
||||
const calculatedCount = baseCount * growthRate * stageNumber;
|
||||
const randomBonus = Math.floor(Math.random() * (diff + 1)); // 0到diff的随机数
|
||||
const finalCount = calculatedCount + randomBonus;
|
||||
|
||||
// 允许掉落数量为0
|
||||
return Math.max(0, Math.floor(finalCount));
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算怪物掉落物品
|
||||
* @param monsterId 怪物ID
|
||||
* @param stageNumber 关卡数
|
||||
* @param playerLuck 玩家幸运值加成
|
||||
* @returns 掉落物品数组
|
||||
*/
|
||||
static calculateMonsterDrops(monsterId: number, stageNumber: number, playerLuck: number = 0): Array<{item_uuid: number, count: number}> {
|
||||
const dropArray = this.getDropConfig(monsterId);
|
||||
if (!dropArray) {
|
||||
console.warn(`[MonsterDropManager]: No drop config found for monster ${monsterId}`);
|
||||
return [];
|
||||
}
|
||||
|
||||
const result: Array<{item_uuid: number, count: number}> = [];
|
||||
const luckBonus = 1 + (playerLuck * 0.01); // 幸运值加成
|
||||
|
||||
// 处理所有掉落物品(统一按概率处理)
|
||||
dropArray.forEach(dropData => {
|
||||
const [item_uuid, probability, diff, baseCount, growthRate] = dropData;
|
||||
|
||||
if (Math.random() < probability) {
|
||||
// 使用新的计算公式:基础值*关卡数*增长参数+(0-差值的随机数)
|
||||
const finalCount = this.calculateDropCount(baseCount, growthRate, stageNumber, diff);
|
||||
const countWithLuck = Math.floor(finalCount * luckBonus);
|
||||
|
||||
result.push({
|
||||
item_uuid: item_uuid,
|
||||
count: Math.max(1, countWithLuck) // 确保至少掉落1个
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 预览指定关卡数的掉落数量(不包含随机因素)
|
||||
* @param monsterId 怪物ID
|
||||
* @param stageNumber 关卡数
|
||||
* @returns 掉落物品预览数组
|
||||
*/
|
||||
static previewMonsterDrops(monsterId: number, stageNumber: number): Array<{item_uuid: number, baseCount: number, calculatedCount: number, maxCount: number}> {
|
||||
const dropArray = this.getDropConfig(monsterId);
|
||||
if (!dropArray) {
|
||||
console.warn(`[MonsterDropManager]: No drop config found for monster ${monsterId}`);
|
||||
return [];
|
||||
}
|
||||
|
||||
const result: Array<{item_uuid: number, baseCount: number, calculatedCount: number, maxCount: number}> = [];
|
||||
|
||||
// 处理所有掉落物品
|
||||
dropArray.forEach(dropData => {
|
||||
const [item_uuid, probability, diff, baseCount, growthRate] = dropData;
|
||||
const calculatedCount = baseCount * growthRate * stageNumber;
|
||||
const maxCount = calculatedCount + diff;
|
||||
|
||||
result.push({
|
||||
item_uuid: item_uuid,
|
||||
baseCount: baseCount,
|
||||
calculatedCount: Math.floor(calculatedCount),
|
||||
maxCount: Math.floor(maxCount)
|
||||
});
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user