mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-04 16:02:26 +08:00
同一类型载具唯一 载具耐力初步
This commit is contained in:
@@ -65,6 +65,7 @@ type Player struct {
|
||||
SceneLoadState int `bson:"-" msgpack:"-"` // 场景加载状态
|
||||
CoopApplyMap map[uint32]int64 `bson:"-" msgpack:"-"` // 敲门申请的玩家uid及时间
|
||||
StaminaInfo *StaminaInfo `bson:"-" msgpack:"-"` // 耐力临时数据
|
||||
VehicleInfo *VehicleInfo `bson:"-" msgpack:"-"` // 载具临时数据
|
||||
ClientSeq uint32 `bson:"-" msgpack:"-"` // 客户端发包请求的序号
|
||||
CombatInvokeHandler *InvokeHandler[proto.CombatInvokeEntry] `bson:"-" msgpack:"-"` // combat转发器
|
||||
AbilityInvokeHandler *InvokeHandler[proto.AbilityInvokeEntry] `bson:"-" msgpack:"-"` // ability转发器
|
||||
@@ -79,6 +80,7 @@ func (p *Player) InitAll() {
|
||||
p.GameObjectGuidMap = make(map[uint64]GameObject)
|
||||
p.CoopApplyMap = make(map[uint32]int64)
|
||||
p.StaminaInfo = new(StaminaInfo)
|
||||
p.VehicleInfo = new(VehicleInfo)
|
||||
p.InitAllAvatar()
|
||||
p.InitAllWeapon()
|
||||
p.InitAllItem()
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"hk4e/gs/constant"
|
||||
"hk4e/protocol/proto"
|
||||
"time"
|
||||
)
|
||||
|
||||
type StaminaInfo struct {
|
||||
@@ -14,9 +14,46 @@ type StaminaInfo struct {
|
||||
LastSkillTime int64 // 最后释放技能的时间
|
||||
}
|
||||
|
||||
// SetLastSkill 记录技能以便后续使用
|
||||
func (s *StaminaInfo) SetLastSkill(casterId uint32, skillId uint32) {
|
||||
s.LastCasterId = casterId
|
||||
s.LastSkillId = skillId
|
||||
s.LastSkillTime = time.Now().UnixMilli()
|
||||
// SetStaminaCost 设置动作需要消耗的耐力
|
||||
func (s *StaminaInfo) SetStaminaCost(state proto.MotionState) {
|
||||
// 根据状态决定要修改的耐力
|
||||
// TODO 角色天赋 食物 会影响耐力消耗
|
||||
switch state {
|
||||
// 消耗耐力
|
||||
case proto.MotionState_MOTION_STATE_DASH:
|
||||
// 快速跑步
|
||||
s.CostStamina = constant.StaminaCostConst.DASH
|
||||
case proto.MotionState_MOTION_STATE_FLY, proto.MotionState_MOTION_STATE_FLY_FAST, proto.MotionState_MOTION_STATE_FLY_SLOW:
|
||||
// 滑翔
|
||||
s.CostStamina = constant.StaminaCostConst.FLY
|
||||
case proto.MotionState_MOTION_STATE_SWIM_DASH:
|
||||
// 快速游泳
|
||||
s.CostStamina = constant.StaminaCostConst.SWIM_DASH
|
||||
case proto.MotionState_MOTION_STATE_SKIFF_DASH:
|
||||
// 浪船加速
|
||||
s.CostStamina = constant.StaminaCostConst.SKIFF_DASH
|
||||
// 恢复耐力
|
||||
case proto.MotionState_MOTION_STATE_DANGER_RUN, proto.MotionState_MOTION_STATE_RUN:
|
||||
// 正常跑步
|
||||
s.CostStamina = constant.StaminaCostConst.RUN
|
||||
case proto.MotionState_MOTION_STATE_DANGER_STANDBY_MOVE, proto.MotionState_MOTION_STATE_DANGER_STANDBY, proto.MotionState_MOTION_STATE_LADDER_TO_STANDBY, proto.MotionState_MOTION_STATE_STANDBY_MOVE, proto.MotionState_MOTION_STATE_STANDBY:
|
||||
// 站立
|
||||
s.CostStamina = constant.StaminaCostConst.STANDBY
|
||||
case proto.MotionState_MOTION_STATE_DANGER_WALK, proto.MotionState_MOTION_STATE_WALK:
|
||||
// 走路
|
||||
s.CostStamina = constant.StaminaCostConst.WALK
|
||||
case proto.MotionState_MOTION_STATE_SKIFF_BOARDING, proto.MotionState_MOTION_STATE_SKIFF_NORMAL:
|
||||
// 浪船正常移动或停下
|
||||
s.CostStamina = constant.StaminaCostConst.SKIFF_NORMAL
|
||||
case proto.MotionState_MOTION_STATE_POWERED_FLY:
|
||||
// 滑翔加速 (风圈等)
|
||||
s.CostStamina = constant.StaminaCostConst.POWERED_FLY
|
||||
case proto.MotionState_MOTION_STATE_SKIFF_POWERED_DASH:
|
||||
// 浪船加速 (风圈等)
|
||||
s.CostStamina = constant.StaminaCostConst.POWERED_SKIFF
|
||||
// 缓慢动作将在客户端发送消息后消耗
|
||||
case proto.MotionState_MOTION_STATE_CLIMB, proto.MotionState_MOTION_STATE_SWIM_MOVE:
|
||||
// 缓慢攀爬 或 缓慢游泳
|
||||
s.CostStamina = 0
|
||||
}
|
||||
}
|
||||
|
||||
7
gs/model/vehicle.go
Normal file
7
gs/model/vehicle.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package model
|
||||
|
||||
type VehicleInfo struct {
|
||||
InVehicleEntityId uint32 // 玩家所在载具的实体Id
|
||||
LastCreateTime int64 // 最后一次创建载具的时间
|
||||
LastCreateEntityId uint32 // 最后一次创建载具的实体Id
|
||||
}
|
||||
Reference in New Issue
Block a user