234 lines
8.0 KiB
Markdown
234 lines
8.0 KiB
Markdown
# 奖励配置
|
||
|
||
<cite>
|
||
**本文档引用文件**
|
||
- [Mission.ts](file://assets/script/game/common/config/Mission.ts)
|
||
- [MissionComp.ts](file://assets/script/game/map/MissionComp.ts)
|
||
- [VictoryComp.ts](file://assets/script/game/map/VictoryComp.ts)
|
||
- [SingletonModuleComp.ts](file://assets/script/game/common/SingletonModuleComp.ts)
|
||
- [RogueConfig.ts](file://assets/script/game/map/RogueConfig.ts)
|
||
- [HeroAttrs.ts](file://assets/script/game/common/config/HeroAttrs.ts)
|
||
</cite>
|
||
|
||
## 目录
|
||
1. [奖励配置概述](#奖励配置概述)
|
||
2. [FightSet枚举中的奖励配置项](#fightset枚举中的奖励配置项)
|
||
3. [常量在奖励机制中的作用](#常量在奖励机制中的作用)
|
||
4. [奖励平衡性调整方法](#奖励平衡性调整方法)
|
||
5. [新增奖励类型的配置方法](#新增奖励类型的配置方法)
|
||
6. [配置数据与运行时逻辑的映射关系](#配置数据与运行时逻辑的映射关系)
|
||
7. [配置变更的正确加载机制](#配置变更的正确加载机制)
|
||
|
||
## 奖励配置概述
|
||
|
||
本节详细解析Mission.ts文件中FightSet枚举的奖励相关配置项,包括金币、经验、钻石的数值定义与获取规则。同时解释TAL_NUM天赋数量、MORE_RC广告奖励次数等常量在奖励机制中的作用,并提供修改FightSet常量调整奖励平衡性的方法。
|
||
|
||
**Section sources**
|
||
- [Mission.ts](file://assets/script/game/common/config/Mission.ts#L0-L59)
|
||
|
||
## FightSet枚举中的奖励配置项
|
||
|
||
FightSet枚举定义了游戏中各种奖励相关的配置项,主要包括:
|
||
|
||
- **金币奖励配置**:
|
||
- GREEN_GOLD=1:绿色金币的数值定义
|
||
- BLUE_GOLD=2:蓝色金币的数值定义
|
||
- PURPLE_GOLD=3:紫色金币的数值定义
|
||
- ORANGE_GOLD=4:橙色金币的数值定义
|
||
|
||
- **经验奖励**:
|
||
- ATK_ADD_GLOD=1:攻击增加金币的数量
|
||
|
||
- **钻石奖励**:
|
||
- 通过广告获取的钻石奖励次数由MORE_RC常量控制
|
||
|
||
这些配置项在游戏运行时被用于计算玩家完成任务后获得的奖励数量。
|
||
|
||
**Section sources**
|
||
- [Mission.ts](file://assets/script/game/common/config/Mission.ts#L0-L35)
|
||
|
||
## 常量在奖励机制中的作用
|
||
|
||
### TAL_NUM天赋数量
|
||
|
||
TAL_NUM=3定义了玩家可选择的天赋数量。这个常量直接影响玩家在游戏中的成长路径和策略选择,是奖励机制中的重要组成部分。
|
||
|
||
### MORE_RC广告奖励次数
|
||
|
||
MORE_RC=10定义了通过观看广告可以获得的额外奖励次数。这个常量控制着玩家通过广告获取奖励的频率和数量,是游戏内经济系统的重要调节参数。
|
||
|
||
### 其他相关常量
|
||
|
||
- ATK_ADD_COUNT=4:伙伴攻击力增加的数量
|
||
- CRIT_DAMAGE=50:暴击伤害的百分比
|
||
- ONE_WAVE_TIME=30:单波次的时间长度
|
||
|
||
这些常量共同构成了游戏奖励机制的基础框架。
|
||
|
||
**Section sources**
|
||
- [Mission.ts](file://assets/script/game/common/config/Mission.ts#L0-L59)
|
||
|
||
## 奖励平衡性调整方法
|
||
|
||
通过修改FightSet常量可以调整游戏的奖励平衡性:
|
||
|
||
### 调整金币奖励
|
||
|
||
```mermaid
|
||
flowchart TD
|
||
A[开始] --> B[修改FightSet中的金币常量]
|
||
B --> C[GREEN_GOLD=1 -> 2]
|
||
B --> D[BLUE_GOLD=2 -> 3]
|
||
B --> E[PURPLE_GOLD=3 -> 4]
|
||
B --> F[ORANGE_GOLD=4 -> 5]
|
||
C --> G[增加金币获取速度]
|
||
D --> G
|
||
E --> G
|
||
F --> G
|
||
G --> H[测试游戏平衡性]
|
||
H --> I[根据反馈进一步调整]
|
||
```
|
||
|
||
**Diagram sources**
|
||
- [Mission.ts](file://assets/script/game/common/config/Mission.ts#L0-L35)
|
||
|
||
### 调整经验获取
|
||
|
||
通过调整ATK_ADD_GLOD等常量可以改变玩家获取经验的速度,从而影响游戏进度和难度曲线。
|
||
|
||
### 调整广告奖励
|
||
|
||
修改MORE_RC常量可以控制玩家通过广告获取奖励的次数,影响游戏内购和广告收入的平衡。
|
||
|
||
**Section sources**
|
||
- [Mission.ts](file://assets/script/game/common/config/Mission.ts#L0-L59)
|
||
- [MissionComp.ts](file://assets/script/game/map/MissionComp.ts#L66-L70)
|
||
|
||
## 新增奖励类型的配置方法
|
||
|
||
### 添加新的奖励类型
|
||
|
||
要在游戏中新增奖励类型,需要执行以下步骤:
|
||
|
||
1. 在FightSet枚举中添加新的奖励常量
|
||
2. 在游戏逻辑中添加对新奖励类型的处理
|
||
3. 在UI界面中添加新奖励类型的显示
|
||
|
||
```mermaid
|
||
classDiagram
|
||
class FightSet {
|
||
+GREEN_GOLD : number
|
||
+BLUE_GOLD : number
|
||
+PURPLE_GOLD : number
|
||
+ORANGE_GOLD : number
|
||
+NEW_REWARD_TYPE : number
|
||
}
|
||
class MissionComp {
|
||
+rewards : any[]
|
||
+game_data : any
|
||
+do_drop(drop_item[], game_data) : void
|
||
}
|
||
class VictoryComp {
|
||
+rewards : any[]
|
||
+game_data : any
|
||
+onAdded(args) : void
|
||
}
|
||
FightSet --> MissionComp : "使用"
|
||
FightSet --> VictoryComp : "使用"
|
||
MissionComp --> VictoryComp : "传递数据"
|
||
```
|
||
|
||
**Diagram sources**
|
||
- [Mission.ts](file://assets/script/game/common/config/Mission.ts#L0-L59)
|
||
- [MissionComp.ts](file://assets/script/game/map/MissionComp.ts#L0-L150)
|
||
- [VictoryComp.ts](file://assets/script/game/map/VictoryComp.ts#L0-L74)
|
||
|
||
### 特殊道具奖励配置
|
||
|
||
要添加特殊道具作为奖励,可以在FightSet枚举中添加新的常量,例如:
|
||
|
||
- SPECIAL_ITEM_1=5:特殊道具1的标识
|
||
- SPECIAL_ITEM_2=6:特殊道具2的标识
|
||
|
||
然后在奖励发放逻辑中处理这些新的奖励类型。
|
||
|
||
**Section sources**
|
||
- [Mission.ts](file://assets/script/game/common/config/Mission.ts#L0-L59)
|
||
- [MissionComp.ts](file://assets/script/game/map/MissionComp.ts#L47-L50)
|
||
|
||
## 配置数据与运行时逻辑的映射关系
|
||
|
||
### 数据流分析
|
||
|
||
```mermaid
|
||
sequenceDiagram
|
||
participant MissionComp as MissionComp
|
||
participant SingletonModuleComp as SingletonModuleComp
|
||
participant VictoryComp as VictoryComp
|
||
participant UI as UI界面
|
||
MissionComp->>SingletonModuleComp : 更新smc.vmdata.mission_data
|
||
SingletonModuleComp->>VictoryComp : 传递game_data和rewards
|
||
VictoryComp->>UI : 显示奖励信息
|
||
UI->>SingletonModuleComp : 确认奖励领取
|
||
SingletonModuleComp->>MissionComp : 更新全局数据
|
||
```
|
||
|
||
**Diagram sources**
|
||
- [MissionComp.ts](file://assets/script/game/map/MissionComp.ts#L0-L150)
|
||
- [SingletonModuleComp.ts](file://assets/script/game/common/SingletonModuleComp.ts#L0-L41)
|
||
- [VictoryComp.ts](file://assets/script/game/map/VictoryComp.ts#L0-L74)
|
||
|
||
### 配置数据的使用
|
||
|
||
FightSet枚举中的常量在多个组件中被引用:
|
||
|
||
- MissionComp使用这些常量来计算奖励
|
||
- VictoryComp使用这些常量来显示奖励信息
|
||
- SingletonModuleComp使用这些常量来存储全局游戏数据
|
||
|
||
这种设计实现了配置数据与运行时逻辑的分离,便于维护和调整。
|
||
|
||
**Section sources**
|
||
- [Mission.ts](file://assets/script/game/common/config/Mission.ts#L0-L59)
|
||
- [MissionComp.ts](file://assets/script/game/map/MissionComp.ts#L0-L150)
|
||
- [VictoryComp.ts](file://assets/script/game/map/VictoryComp.ts#L0-L74)
|
||
- [SingletonModuleComp.ts](file://assets/script/game/common/SingletonModuleComp.ts#L0-L41)
|
||
|
||
## 配置变更的正确加载机制
|
||
|
||
### 配置加载流程
|
||
|
||
```mermaid
|
||
flowchart TD
|
||
A[游戏启动] --> B[加载Mission.ts配置]
|
||
B --> C[初始化FightSet常量]
|
||
C --> D[创建SingletonModuleComp实例]
|
||
D --> E[初始化smc.vmdata.mission_data]
|
||
E --> F[MissionComp引用FightSet常量]
|
||
F --> G[游戏运行时使用配置]
|
||
G --> H[配置变更]
|
||
H --> I[重新加载配置]
|
||
I --> J[更新所有相关组件]
|
||
J --> K[应用新配置]
|
||
```
|
||
|
||
**Diagram sources**
|
||
- [Mission.ts](file://assets/script/game/common/config/Mission.ts#L0-L59)
|
||
- [SingletonModuleComp.ts](file://assets/script/game/common/SingletonModuleComp.ts#L0-L41)
|
||
- [MissionComp.ts](file://assets/script/game/map/MissionComp.ts#L0-L150)
|
||
|
||
### 确保配置正确加载
|
||
|
||
为确保配置变更在游戏中正确加载,需要遵循以下原则:
|
||
|
||
1. 所有组件都应从SingletonModuleComp获取全局数据
|
||
2. 配置变更后需要通知所有相关组件更新
|
||
3. 使用事件机制(如oops.message)来同步配置变更
|
||
|
||
通过这些机制,可以确保配置变更能够正确地应用到游戏的所有部分。
|
||
|
||
**Section sources**
|
||
- [Mission.ts](file://assets/script/game/common/config/Mission.ts#L0-L59)
|
||
- [SingletonModuleComp.ts](file://assets/script/game/common/SingletonModuleComp.ts#L0-L41)
|
||
- [MissionComp.ts](file://assets/script/game/map/MissionComp.ts#L0-L150)
|
||
- [VictoryComp.ts](file://assets/script/game/map/VictoryComp.ts#L0-L74) |