英雄信息弹窗
This commit is contained in:
@@ -37,9 +37,9 @@ export class SingletonModuleComp extends ecs.Comp {
|
||||
4:0,
|
||||
}
|
||||
heros:any = {
|
||||
5001:{uuid:5001,lv:1,slv:0},
|
||||
5005:{uuid:5005,lv:1,slv:0},
|
||||
5007:{uuid:5007,lv:1,slv:0},
|
||||
5001:{uuid:5001,lv:1},
|
||||
5005:{uuid:5005,lv:1},
|
||||
5007:{uuid:5007,lv:1},
|
||||
};
|
||||
|
||||
monsters:any = [];
|
||||
|
||||
@@ -18,6 +18,7 @@ export enum UIID {
|
||||
Role_Controller,
|
||||
// /** 提示窗 */
|
||||
// Toast,
|
||||
HeroInfo,
|
||||
}
|
||||
|
||||
/** 打开界面方式的配置数据 */
|
||||
@@ -26,5 +27,6 @@ export var UIConfigData: { [key: number]: UIConfig } = {
|
||||
[UIID.Netinstable]: { layer: LayerType.PopUp, prefab: "common/prefab/netinstable" },
|
||||
[UIID.Window]: { layer: LayerType.Dialog, prefab: "common/prefab/window" },
|
||||
[UIID.Role_Controller]: { layer: LayerType.UI, prefab: "gui/role_controller" },
|
||||
[UIID.HeroInfo]: { layer: LayerType.UI, prefab: "gui/Hinfo" },
|
||||
// [UIID.Toast]: { layer: LayerType.PopUp, prefab: "common/prefab/toast" },
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
import { v3 } from "cc"
|
||||
import { FacSet } from "./BoxSet"
|
||||
|
||||
/**
|
||||
* kind :1:烈焰 2:寒冰 3:自然 4:暗影 5:神圣
|
||||
**/
|
||||
@@ -51,13 +50,6 @@ export const HeroPos={
|
||||
1:{pos:v3(0,0,0)},
|
||||
2:{pos:v3(-100,0,0)},
|
||||
}
|
||||
export const HQuality = {
|
||||
WHITE:1,
|
||||
GREEN:2,
|
||||
BLUE:3,
|
||||
PURPLE:4,
|
||||
ORANGE:5,
|
||||
}
|
||||
export const MonSet = {
|
||||
0:{pos:v3(160,0,0)},
|
||||
1:{pos:v3(220,0,0)},
|
||||
@@ -67,6 +59,17 @@ export const MonSet = {
|
||||
5:{pos:v3(460,0,0)},
|
||||
}
|
||||
|
||||
export const HQuality = {
|
||||
WHITE:1,
|
||||
GREEN:2,
|
||||
BLUE:3,
|
||||
PURPLE:4,
|
||||
ORANGE:5,
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export const HeroInfo = {
|
||||
@@ -179,126 +182,180 @@ export const HeroInfo = {
|
||||
|
||||
};
|
||||
|
||||
// ==================== 怪物系列分类配置 ====================
|
||||
|
||||
// 怪物系列枚举
|
||||
export enum MonsterSeriesType {
|
||||
ORC = "ORC", // 兽人系列
|
||||
CYCLOPS = "CYCLOPS", // 独眼系列
|
||||
MINOTAUR = "MINOTAUR", // 牛头系列
|
||||
NATURE = "NATURE", // 自然系列
|
||||
}
|
||||
|
||||
// 怪物系列配置
|
||||
export const MonsterSeriesConfig = {
|
||||
// 兽人系列 (mor开头)
|
||||
[MonsterSeriesType.ORC]: {
|
||||
name: "兽人系列",
|
||||
description: "来自荒野的兽人族群",
|
||||
monsters: {
|
||||
warrior: [5201, 5203], // 兽人战士、兽人护卫、精英兽人
|
||||
remote: [5202, 5227], // 兽人刺客
|
||||
mage: [] // 无法师
|
||||
},
|
||||
allMonsters: [5201, 5202, 5203, 5227]
|
||||
// 职业属性增长配置
|
||||
export const JobGrowthConfig = {
|
||||
[HType.warrior]: {
|
||||
hp: { base: 1.0, growth: 8, maxLevel: 100, level5Bonus: 0.5 }, // 战士:生命值增长最高,5级额外50%
|
||||
ap: { base: 1.0, growth: 2, maxLevel: 100, level5Bonus: 0.3 }, // 战士:攻击力中等增长,5级额外30%
|
||||
def: { base: 1.0, growth: 1, maxLevel: 100, level5Bonus: 0.2, maxValue: 50 } // 战士:防御力较高增长,5级额外20%,最高50%
|
||||
},
|
||||
|
||||
// 独眼系列 (md开头)
|
||||
[MonsterSeriesType.CYCLOPS]: {
|
||||
name: "独眼系列",
|
||||
description: "古老的独眼巨人族群",
|
||||
monsters: {
|
||||
warrior: [5222, 5223], // 独眼巨人x2、精英独眼
|
||||
remote: [5224, 5225], // 独眼巨人(远程)
|
||||
mage: [] // 无法师
|
||||
},
|
||||
allMonsters: [5222, 5223, 5224, 5225]
|
||||
[HType.remote]: {
|
||||
hp: { base: 1.0, growth: 5, maxLevel: 100, level5Bonus: 0.3 }, // 远程:生命值增长较低,5级额外30%
|
||||
ap: { base: 1.0, growth: 3, maxLevel: 100, level5Bonus: 0.5 }, // 远程:攻击力增长最高,5级额外50%
|
||||
def: { base: 1.0, growth: 0.8, maxLevel: 100, level5Bonus: 0.15, maxValue: 50 } // 远程:防御力增长最低,5级额外15%,最高50%
|
||||
},
|
||||
|
||||
// 牛头系列 (mn开头)
|
||||
[MonsterSeriesType.MINOTAUR]: {
|
||||
name: "牛头系列",
|
||||
description: "迷宫中的牛头怪族群",
|
||||
monsters: {
|
||||
warrior: [5219, 5220], // 牛头战士x2、精英牛头
|
||||
remote: [5221, 5226], // 牛头战士(远程)
|
||||
mage: [] // 无法师
|
||||
},
|
||||
allMonsters: [5219, 5220, 5221, 5226]
|
||||
},
|
||||
|
||||
// 自然系列 (mgem开头)
|
||||
[MonsterSeriesType.NATURE]: {
|
||||
name: "自然系列",
|
||||
description: "大地与自然的守护者",
|
||||
monsters: {
|
||||
warrior: [], // 无战士
|
||||
remote: [], // 无远程
|
||||
mage: [5204, 5205, 5206] // 石卫、土卫、树卫
|
||||
},
|
||||
allMonsters: [5204, 5205, 5206]
|
||||
},
|
||||
|
||||
[HType.mage]: {
|
||||
hp: { base: 1.0, growth: 6, maxLevel: 100, level5Bonus: 0.4 }, // 法师:生命值中等增长,5级额外40%
|
||||
ap: { base: 1.0, growth: 4, maxLevel: 100, level5Bonus: 0.6 }, // 法师:攻击力增长最高,5级额外60%
|
||||
def: { base: 1.0, growth: 0.5, maxLevel: 100, level5Bonus: 0.1, maxValue: 50 } // 法师:防御力增长最低,5级额外10%,最高50%
|
||||
}
|
||||
};
|
||||
|
||||
// 获取指定系列的怪物列表
|
||||
export const getMonstersBySeries = (series: MonsterSeriesType, type?: keyof typeof HType): number[] => {
|
||||
const seriesConfig = MonsterSeriesConfig[series];
|
||||
if (!seriesConfig) {
|
||||
console.warn(`[MonsterSeries]: 未找到系列 ${series}`);
|
||||
return [];
|
||||
}
|
||||
// 全局属性增长配置(可调整)
|
||||
export const GlobalGrowthConfig = {
|
||||
// 基础增长公式:base + (level - 1) * growthValue + level5Bonus
|
||||
// 5级时额外获得百分比提升
|
||||
hpMultiplier: 1.0, // 生命值全局倍数
|
||||
apMultiplier: 1.0, // 攻击力全局倍数
|
||||
defMultiplier: 1.0, // 防御力全局倍数
|
||||
|
||||
if (type !== undefined) {
|
||||
const typeKey = HType[type] === HType.warrior ? "warrior" :
|
||||
HType[type] === HType.remote ? "remote" : "mage";
|
||||
return seriesConfig.monsters[typeKey] || [];
|
||||
}
|
||||
// 5级特殊提升配置
|
||||
level5Bonus: {
|
||||
enabled: true, // 是否启用5级特殊提升
|
||||
triggerLevels: [5, 15, 25, 35, 45, 55, 65, 75, 85, 95], // 触发特殊提升的等级
|
||||
bonusDecay: 0.9 // 每次特殊提升的衰减率
|
||||
},
|
||||
|
||||
return seriesConfig.allMonsters;
|
||||
// 防御力特殊规则
|
||||
defense: {
|
||||
maxDamageReduction: 50, // 最大免伤率50%
|
||||
warningThreshold: 45, // 警告阈值45%
|
||||
growthCurve: 0.8 // 防御力增长曲线(高等级时增长放缓)
|
||||
}
|
||||
};
|
||||
|
||||
// 根据怪物UUID获取所属系列
|
||||
export const getMonsterSeries = (uuid: number): MonsterSeriesType | null => {
|
||||
for (const [seriesKey, config] of Object.entries(MonsterSeriesConfig)) {
|
||||
if (config.allMonsters.includes(uuid)) {
|
||||
return seriesKey as MonsterSeriesType;
|
||||
/**
|
||||
* 计算指定等级的英雄属性
|
||||
* @param baseStats 基础属性 {hp, ap, def}
|
||||
* @param jobType 职业类型 HType
|
||||
* @param level 等级
|
||||
* @param customGrowth 自定义增长配置(可选)
|
||||
* @returns 计算后的属性 {hp, ap, def}
|
||||
*/
|
||||
export const calculateHeroStats = (
|
||||
baseStats: { hp: number, ap: number, def: number },
|
||||
jobType: HType,
|
||||
level: number,
|
||||
customGrowth?: Partial<typeof JobGrowthConfig[0]>
|
||||
) => {
|
||||
// 获取职业增长配置
|
||||
const jobConfig = customGrowth || JobGrowthConfig[jobType];
|
||||
if (!jobConfig) {
|
||||
console.warn(`未找到职业 ${jobType} 的增长配置,使用默认配置`);
|
||||
return baseStats;
|
||||
}
|
||||
|
||||
// 限制等级范围
|
||||
const clampedLevel = Math.max(1, Math.min(level, jobConfig.hp.maxLevel));
|
||||
|
||||
// 计算属性增长
|
||||
const calculateAttribute = (baseValue: number, growthConfig: any, isDefense: boolean = false) => {
|
||||
if (clampedLevel <= 1) return baseValue;
|
||||
|
||||
// 基础数值增长:每级增加固定数值
|
||||
let result = baseValue + (clampedLevel - 1) * growthConfig.growth;
|
||||
|
||||
// 检查是否触发特殊提升(5级、15级、25级等)
|
||||
if (GlobalGrowthConfig.level5Bonus.enabled) {
|
||||
const bonusLevels = GlobalGrowthConfig.level5Bonus.triggerLevels;
|
||||
const bonusIndex = bonusLevels.findIndex(l => clampedLevel >= l);
|
||||
|
||||
if (bonusIndex !== -1) {
|
||||
// 计算特殊提升的衰减
|
||||
const decayMultiplier = Math.pow(GlobalGrowthConfig.level5Bonus.bonusDecay, bonusIndex);
|
||||
const bonusMultiplier = growthConfig.level5Bonus * decayMultiplier;
|
||||
|
||||
// 应用特殊提升(基于当前数值的百分比)
|
||||
result = result * (1 + bonusMultiplier);
|
||||
|
||||
console.log(`[HeroSet] 等级${clampedLevel}触发特殊提升: ${(bonusMultiplier * 100).toFixed(1)}%`);
|
||||
}
|
||||
}
|
||||
|
||||
// 防御力特殊处理:确保免伤率不超过最大值
|
||||
if (isDefense) {
|
||||
const maxDef = growthConfig.maxValue || GlobalGrowthConfig.defense.maxDamageReduction;
|
||||
result = Math.min(result, maxDef);
|
||||
|
||||
// 高等级时应用增长曲线,让防御力增长更平缓
|
||||
if (clampedLevel > 50) {
|
||||
const curveMultiplier = Math.pow(GlobalGrowthConfig.defense.growthCurve, (clampedLevel - 50) / 10);
|
||||
result = baseValue + (result - baseValue) * curveMultiplier;
|
||||
result = Math.min(result, maxDef);
|
||||
}
|
||||
|
||||
// 警告日志
|
||||
if (result >= GlobalGrowthConfig.defense.warningThreshold) {
|
||||
console.warn(`[HeroSet] 警告:等级${clampedLevel}的防御力(${result.toFixed(1)})接近最大值(${maxDef})`);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
// 计算各项属性
|
||||
const hp = calculateAttribute(baseStats.hp, jobConfig.hp);
|
||||
const ap = calculateAttribute(baseStats.ap, jobConfig.ap);
|
||||
const def = calculateAttribute(baseStats.def, jobConfig.def, true); // 标记为防御力
|
||||
|
||||
return {
|
||||
hp: Math.floor(hp * GlobalGrowthConfig.hpMultiplier),
|
||||
ap: Math.floor(ap * GlobalGrowthConfig.apMultiplier),
|
||||
def: Math.floor(def * GlobalGrowthConfig.defMultiplier)
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取指定英雄在指定等级的属性
|
||||
* @param heroUuid 英雄UUID
|
||||
* @param level 等级
|
||||
* @param customGrowth 自定义增长配置(可选)
|
||||
* @returns 计算后的属性 {hp, ap, def} 或 null(如果英雄不存在)
|
||||
*/
|
||||
export const getHeroStatsByLevel = (
|
||||
heroUuid: number,
|
||||
level: number,
|
||||
customGrowth?: Partial<typeof JobGrowthConfig[0]>
|
||||
) => {
|
||||
const hero = HeroInfo[heroUuid];
|
||||
if (!hero) {
|
||||
console.warn(`未找到英雄 ${heroUuid}`);
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
|
||||
const baseStats = {
|
||||
hp: hero.hp || 0,
|
||||
ap: hero.ap || 0,
|
||||
def: hero.def || 0
|
||||
};
|
||||
|
||||
return calculateHeroStats(baseStats, hero.type, level, customGrowth);
|
||||
};
|
||||
|
||||
// 获取系列信息
|
||||
export const getSeriesInfo = (series: MonsterSeriesType) => {
|
||||
return MonsterSeriesConfig[series] || null;
|
||||
};
|
||||
|
||||
// 获取所有系列列表
|
||||
export const getAllMonsterSeries = (): MonsterSeriesType[] => {
|
||||
return Object.values(MonsterSeriesType);
|
||||
};
|
||||
|
||||
// 按类型分组的怪物列表
|
||||
export const MonstersByType = {
|
||||
warrior: [5201, 5203, 5219, 5220, 5222, 5223, 5225, 5226, 5227], // 所有战士类型怪物
|
||||
remote: [5202, 5221, 5224], // 所有远程类型怪物
|
||||
mage: [5204, 5205, 5206,] // 所有法师类型怪物
|
||||
};
|
||||
|
||||
// 随机从指定系列获取怪物
|
||||
export const getRandomMonsterFromSeries = (series: MonsterSeriesType, type?: keyof typeof HType): number => {
|
||||
const monsters = getMonstersBySeries(series, type);
|
||||
if (monsters.length === 0) {
|
||||
console.warn(`[MonsterSeries]: 系列 ${series} 中没有${type ? HType[type] : ''}类型怪物`);
|
||||
return 5201; // 返回默认怪物
|
||||
}
|
||||
return monsters[Math.floor(Math.random() * monsters.length)];
|
||||
};
|
||||
|
||||
// 随机选择一个系列
|
||||
export const getRandomSeries = (): MonsterSeriesType => {
|
||||
const allSeries = getAllMonsterSeries();
|
||||
return allSeries[Math.floor(Math.random() * allSeries.length)];
|
||||
/**
|
||||
* 批量获取英雄等级属性
|
||||
* @param heroUuids 英雄UUID数组
|
||||
* @param level 等级
|
||||
* @param customGrowth 自定义增长配置(可选)
|
||||
* @returns 英雄属性映射表
|
||||
*/
|
||||
export const getMultipleHeroStatsByLevel = (
|
||||
heroUuids: number[],
|
||||
level: number,
|
||||
customGrowth?: Partial<typeof JobGrowthConfig[0]>
|
||||
) => {
|
||||
const result: { [uuid: number]: { hp: number, ap: number, def: number } } = {};
|
||||
|
||||
heroUuids.forEach(uuid => {
|
||||
const stats = getHeroStatsByLevel(uuid, level, customGrowth);
|
||||
if (stats) {
|
||||
result[uuid] = stats;
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { _decorator, Animation, AnimationClip, Component, Label, Node, resources } from 'cc';
|
||||
import { HeroInfo, HQuality, HType } from '../common/config/heroSet';
|
||||
import { smc } from '../common/SingletonModuleComp';
|
||||
import { oops } from 'db://oops-framework/core/Oops';
|
||||
import { UIID } from '../common/config/GameUIConfig';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('HCardUICom')
|
||||
@@ -25,11 +27,11 @@ export class HCardUICom extends Component {
|
||||
});
|
||||
this.node.getChildByName("name").getComponent(Label).string=hero_data.name
|
||||
this.node.getChildByName("lv").getChildByName("num").getComponent(Label).string=smc.heros[uuid].lv.toString()
|
||||
this.node.getChildByName("slv").getChildByName("lv1").active=smc.heros[uuid].slv>=1
|
||||
this.node.getChildByName("slv").getChildByName("lv2").active=smc.heros[uuid].slv>=2
|
||||
this.node.getChildByName("slv").getChildByName("lv3").active=smc.heros[uuid].slv>=3
|
||||
this.node.getChildByName("slv").getChildByName("lv4").active=smc.heros[uuid].slv>=4
|
||||
this.node.getChildByName("slv").getChildByName("lv5").active=smc.heros[uuid].slv>=5
|
||||
// this.node.getChildByName("slv").getChildByName("lv1").active=smc.heros[uuid].slv>=1
|
||||
// this.node.getChildByName("slv").getChildByName("lv2").active=smc.heros[uuid].slv>=2
|
||||
// this.node.getChildByName("slv").getChildByName("lv3").active=smc.heros[uuid].slv>=3
|
||||
// this.node.getChildByName("slv").getChildByName("lv4").active=smc.heros[uuid].slv>=4
|
||||
// this.node.getChildByName("slv").getChildByName("lv5").active=smc.heros[uuid].slv>=5
|
||||
this.node.getChildByName("g").active=hero_data.quality==HQuality.GREEN
|
||||
this.node.getChildByName("gg").active=hero_data.quality==HQuality.GREEN
|
||||
this.node.getChildByName("b").active=hero_data.quality==HQuality.BLUE
|
||||
@@ -42,6 +44,9 @@ export class HCardUICom extends Component {
|
||||
this.node.getChildByName("type").getChildByName("r").active=hero_data.type==HType.remote
|
||||
this.node.getChildByName("type").getChildByName("m").active=hero_data.type==HType.mage
|
||||
}
|
||||
show_info(){
|
||||
oops.gui.open(UIID.HeroInfo,this.h_uuid)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
45
assets/script/game/map/HInfoComp.ts
Normal file
45
assets/script/game/map/HInfoComp.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
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 { smc } from '../common/SingletonModuleComp';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('HInfoComp')
|
||||
export class HInfoComp extends Component {
|
||||
h_uuid:number=0
|
||||
start() {
|
||||
|
||||
}
|
||||
|
||||
onAdded(args: any) {
|
||||
console.log("[HInfoComp]:onAdded",args)
|
||||
this.update_data(args)
|
||||
}
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
update_data(uuid:number){
|
||||
console.log("[HInfoComp]:update_data",uuid)
|
||||
console.log("[HCardUICom]:update_data",uuid)
|
||||
this.h_uuid=uuid
|
||||
let hero_data = HeroInfo[uuid]
|
||||
let hero= this.node.getChildByName("hero")
|
||||
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("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()
|
||||
}
|
||||
close(){
|
||||
oops.gui.removeByNode(this.node)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
9
assets/script/game/map/HInfoComp.ts.meta
Normal file
9
assets/script/game/map/HInfoComp.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "f8dd2383-61ab-4cf9-9879-0d0fe2cd6c2f",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
Reference in New Issue
Block a user