feat: 实现游戏核心系统和UI组件

核心系统:
- combatSystem: 战斗逻辑、伤害计算、战斗状态管理
- skillSystem: 技能系统、技能解锁、经验值、里程碑
- taskSystem: 任务系统、任务类型、任务执行和完成
- eventSystem: 事件系统、随机事件处理
- environmentSystem: 环境系统、时间流逝、区域效果
- levelingSystem: 升级系统、属性成长
- soundSystem: 音效系统

配置文件:
- enemies: 敌人配置、掉落表
- events: 事件配置、事件效果
- items: 物品配置、装备属性
- locations: 地点配置、探索事件
- skills: 技能配置、技能树

UI组件:
- CraftingDrawer: 制造界面
- InventoryDrawer: 背包界面
- 其他UI优化和动画

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Claude
2026-01-23 16:20:10 +08:00
parent 021f6a54f5
commit 16223c89a5
25 changed files with 2731 additions and 318 deletions

View File

@@ -265,96 +265,6 @@ export function unlockSkill(playerStore, skillId) {
return true
}
/**
* 检查技能是否可解锁
* @param {Object} playerStore - 玩家Store
* @param {String} skillId - 技能ID
* @returns {Object} { canUnlock: boolean, reason: string }
*/
export function canUnlockSkill(playerStore, skillId) {
const config = SKILL_CONFIG[skillId]
if (!config) {
return { canUnlock: false, reason: '技能不存在' }
}
// 已解锁
if (playerStore.skills[skillId] && playerStore.skills[skillId].unlocked) {
return { canUnlock: true, reason: '已解锁' }
}
// 检查解锁条件
if (config.unlockCondition) {
const condition = config.unlockCondition
// 物品条件
if (condition.type === 'item') {
const hasItem = playerStore.inventory?.some(i => i.id === condition.item)
if (!hasItem) {
return { canUnlock: false, reason: '需要特定物品' }
}
}
// 位置条件
if (condition.location) {
if (playerStore.currentLocation !== condition.location) {
return { canUnlock: false, reason: '需要在特定位置解锁' }
}
}
// 技能等级条件
if (condition.skillLevel) {
const requiredSkill = playerStore.skills[condition.skillId]
if (!requiredSkill || requiredSkill.level < condition.skillLevel) {
return { canUnlock: false, reason: '需要前置技能达到特定等级' }
}
}
}
return { canUnlock: true, reason: '' }
}
/**
* 获取技能经验倍率(含父技能加成)
* @param {Object} playerStore - 玩家Store
* @param {String} skillId - 技能ID
* @returns {Number} 经验倍率
*/
export function getSkillExpRate(playerStore, skillId) {
let rate = 1.0
// 全局经验加成
if (playerStore.globalBonus && playerStore.globalBonus.globalExpRate) {
rate *= (1 + playerStore.globalBonus.globalExpRate / 100)
}
// 父技能加成
const config = SKILL_CONFIG[skillId]
if (config && config.parentSkill) {
const parentSkill = playerStore.skills[config.parentSkill]
if (parentSkill && parentSkill.unlocked) {
const parentConfig = SKILL_CONFIG[config.parentSkill]
if (parentConfig && parentConfig.milestones) {
// 检查父技能里程碑奖励
for (const [level, milestone] of Object.entries(parentConfig.milestones)) {
if (parentSkill.level >= parseInt(level) && milestone.effect?.expRate) {
rate *= milestone.effect.expRate
}
}
}
// 如果子技能等级低于父技能,提供额外加成
if (parentSkill.level > 0 && playerStore.skills[skillId]) {
const childLevel = playerStore.skills[skillId].level
if (childLevel < parentSkill.level) {
rate *= 1.5 // 父技能倍率加成
}
}
}
}
return rate
}
/**
* 获取技能显示信息
* @param {Object} playerStore - 玩家Store