目录
4.2.5 Building Selection (建筑选择)
4.2.6 Selection Renderer (选择渲染器)
四、建筑
4.1 创建新建筑
RTS Engine —— New Building
- Name: 选择时UI显示的名称
- Code: 建筑唯一标识
- Category: 种类, 给建筑制定类别(可以是多个类别),“,”间隔不可有空格。
- 目前demo中给到的默认种类有:
- civilian_building: 平民建筑(农场, 粮仓, 房屋, 寺庙, 城镇中心, 学校)
- military_building: 军事建筑(兵营, 工程武器工厂, 防御塔)
- npc_reference_entity: npc参考实体? 不知道干啥用的
- 目前demo中给到的默认种类有:
- Description: 描述说明
- Icon: 图标
- 点击右上 Finalize Creation, 新建的预制体在 Assets/Resources/Prefabs 下, 如果将预制件移动到其他路径中,需要确保新路径始终以../Resources/Prefabs结尾。
- 建筑的父游戏对象的锚点是对象的底部。并确保它保持不变。
4.2 建筑组件
4.2.1 Buding(Script)
- 实体 (Entity) 部分: 就是刚刚创建的部分, 可以在这里进行修改
- Radius: 是物体实体占据的半径大小, 定义其他实体与此建筑的交互范围。也就是上图中的蓝色的圈
This field defines the range that the building entity is supposed to occupy within the map. When the building is selected, a blue Gizmo sphere in the scene appears to show you the size defined by the radius that the building entity will occupy. This radius value is useful when defining the ranges from which other entities can interact with this building. For this new building, we will keep the radius value to 1.5 as it seems to cover the size of the house_model object we assigned to it.
- Model: 实体模型
- Radius: 是物体实体占据的半径大小, 定义其他实体与此建筑的交互范围。也就是上图中的蓝色的圈
- 派系实体(Faction Entity)部分: 设置建筑阵营, 颜色等
- isMainEntity: 主要实体是当失败条件设置为“消灭主要”时需要消灭的实体
-
isFactionLocked: 阵营是否在游戏中可以改变
-
initResources:资源被该阵营添加或删除时,向该阵营添加/移除资源。
-
Amount: 代表增加/减少的数值, 例如增加20食物。
-
Capacity: 代表增加/减少的上限, 例如增加10人口上限。
-
onConsumable:禁止派系添加/删除给定的资源值
-
Colored Renderers :建筑物模型的哪些部分使用拥有该建筑物的派系的颜色进行着色。例如指定屋顶设置派系颜色。例如下边这个就是指改变“roofHighGableDetail”的renderer中的第2个材质(roof_light)的颜色为当前派系颜色。transparency为透明通道, 当然这个材质得是支持透明通道的。darkness是指暗度, 值越高越黑
- 建筑(Building)部分: 无 说是以后添加了特定建筑后会在这显示
4.2.2 Building Health(Script)
- General: 全体
- Max/Initial Health: 更新建筑的最大生命值和初始生命值。生命值最小为1.当处于建造状态时无法使用(也不能启用任何任务,其他组件被禁用),直到被完全建造。
- Can Increase/Decrease/Be Attacked: 是否增加/减少/血量, 是否能被攻击
- Attack Target Position: 攻击目标。如果没有分配则为带有Building Selection组件的子对象
- HoverHealthBarData:血条
- HitEffect:实体失去生命时触发
- HitAudio:实体失去生命时触发
-
FetchType: 提取音频时的方式
-
Items: 音频
-
cooldown:在音频剪辑再次播放之前,启用冷却时间
-
- Build Time: 建造时间
- Repair Costs: 维修费用
- Destruction: 摧毁
- Destroy Object/Delay: 延迟摧毁时间, 当生命值 = 0时摧毁它, 实际上是指当生命值 = 0 时刻——延迟时间的期间内处于死亡状态, 无法使用,允许播放破坏动画等.
- DestroyAward:“资源将被授予其实体造成破坏的阵营” ,应该是指“掠夺”的物资
Resources to be awarded to the faction whose entity deals the damage that destroys this
- DestructionEffect: 当实体被摧毁时的效果对象
- DestructionAudio:被摧毁时的音效, 具体参数同上
- HealthStates(生命状态)
-
Construction States:建设状态, 设置多个建造阶段,每阶段在show/hide中设置显示隐藏的模型部分
-
Construction Complete States:建设完成状态,完成时显示与隐藏的物体。字段[Health Range] 雕用没有
-
States:建成后的状态, 根据血量设置,demo中是根据剩余血量显示不同的火焰
-
Destroy State : 被摧毁状态,带有摧毁延迟的话,此处会生效
-
各阶段的 TrggerEvent : 自定义事件
-
4.2.3 AudioSource(音频源)
4.2.4 NavMeshEntityObstacle(Script) : 导航网格障碍(Unity自带组件)
给导航网格添加障碍物(开个洞, 使寻路单位可以绕过该物体)
Carve:
- NavMeshObstacle :
- Move Threshold:该参数代表该障碍物的移动的极限距离超过这个参数时,才会重新雕刻这个障碍物。增大此值,障碍物移动没有超过这个距离,就不会重新雕刻导航网格。
Unity treats the Nav Mesh Obstacle as moving when it has moved more than the distance set by the Move Threshold. Use this property to set the threshold distance for updating a moving carved hole.
- Time To Startionary: 将障碍物视为静止需要等待的时间
The time (in seconds) to wait until the obstacle is treated as stationary.
- Carve Only Startionary: 启用后,障碍物只有在静止时才会被雕刻。
When enabled, the obstacle is carved only when it is stationary. See Logic for moving Nav Mesh Obstacles, below, to learn more.
- Move Threshold:该参数代表该障碍物的移动的极限距离超过这个参数时,才会重新雕刻这个障碍物。增大此值,障碍物移动没有超过这个距离,就不会重新雕刻导航网格。
4.2.5 Building Selection (建筑选择)
用于鼠标选中此建筑的碰撞体,并显示提示
4.2.6 Selection Renderer (选择渲染器)
就是选中建筑后下边的那个选中提示, 这块就不细写了, 比较简单。
4.2.7 其他一些脚本
- building_extension/ building_components: 会在以后得部分学到