mirror of
https://github.com/FlourishingWorld/hk4e.git
synced 2026-02-04 16:02:26 +08:00
怪物死亡和世界宝箱随机掉落
This commit is contained in:
@@ -1,22 +1,89 @@
|
|||||||
package handle
|
package handle
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"math"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"hk4e/common/constant"
|
||||||
"hk4e/common/mq"
|
"hk4e/common/mq"
|
||||||
"hk4e/gate/kcp"
|
"hk4e/gate/kcp"
|
||||||
"hk4e/node/api"
|
"hk4e/node/api"
|
||||||
|
"hk4e/pkg/logger"
|
||||||
"hk4e/protocol/cmd"
|
"hk4e/protocol/cmd"
|
||||||
"hk4e/protocol/proto"
|
"hk4e/protocol/proto"
|
||||||
|
|
||||||
pb "google.golang.org/protobuf/proto"
|
pb "google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
MoveVectorCacheNum = 100
|
||||||
|
MaxMoveSpeed = 10000.0
|
||||||
|
)
|
||||||
|
|
||||||
|
type MoveVector struct {
|
||||||
|
pos *proto.Vector
|
||||||
|
time int64
|
||||||
|
}
|
||||||
|
|
||||||
|
type AnticheatContext struct {
|
||||||
|
moveVectorList []*MoveVector
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *AnticheatContext) Move(pos *proto.Vector) {
|
||||||
|
a.moveVectorList = append(a.moveVectorList, &MoveVector{
|
||||||
|
pos: pos,
|
||||||
|
time: time.Now().UnixMilli(),
|
||||||
|
})
|
||||||
|
if len(a.moveVectorList) > MoveVectorCacheNum {
|
||||||
|
a.moveVectorList = a.moveVectorList[len(a.moveVectorList)-MoveVectorCacheNum:]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *AnticheatContext) GetMoveSpeed() float32 {
|
||||||
|
avgMoveSpeed := float32(0.0)
|
||||||
|
for index := range a.moveVectorList {
|
||||||
|
if index+1 >= len(a.moveVectorList) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
nextMoveVector := a.moveVectorList[index+1]
|
||||||
|
beforeMoveVector := a.moveVectorList[index]
|
||||||
|
dx := float32(math.Sqrt(
|
||||||
|
float64((nextMoveVector.pos.X-beforeMoveVector.pos.X)*(nextMoveVector.pos.X-beforeMoveVector.pos.X)) +
|
||||||
|
float64((nextMoveVector.pos.Y-beforeMoveVector.pos.Y)*(nextMoveVector.pos.Y-beforeMoveVector.pos.Y)) +
|
||||||
|
float64((nextMoveVector.pos.Z-beforeMoveVector.pos.Z)*(nextMoveVector.pos.Z-beforeMoveVector.pos.Z)),
|
||||||
|
))
|
||||||
|
dt := float32(nextMoveVector.time-beforeMoveVector.time) / 1000.0
|
||||||
|
avgMoveSpeed += dx / dt
|
||||||
|
}
|
||||||
|
avgMoveSpeed /= float32(len(a.moveVectorList))
|
||||||
|
return avgMoveSpeed
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewAnticheatContext() *AnticheatContext {
|
||||||
|
r := &AnticheatContext{
|
||||||
|
moveVectorList: make([]*MoveVector, 0),
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
type Handle struct {
|
type Handle struct {
|
||||||
messageQueue *mq.MessageQueue
|
messageQueue *mq.MessageQueue
|
||||||
|
playerAcCtxMap map[uint32]*AnticheatContext
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handle) GetPlayerAcCtx(userId uint32) *AnticheatContext {
|
||||||
|
ctx, exist := h.playerAcCtxMap[userId]
|
||||||
|
if !exist {
|
||||||
|
ctx = NewAnticheatContext()
|
||||||
|
h.playerAcCtxMap[userId] = ctx
|
||||||
|
}
|
||||||
|
return ctx
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewHandle(messageQueue *mq.MessageQueue) (r *Handle) {
|
func NewHandle(messageQueue *mq.MessageQueue) (r *Handle) {
|
||||||
r = new(Handle)
|
r = new(Handle)
|
||||||
r.messageQueue = messageQueue
|
r.messageQueue = messageQueue
|
||||||
|
r.playerAcCtxMap = make(map[uint32]*AnticheatContext)
|
||||||
r.run()
|
r.run()
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
@@ -53,13 +120,26 @@ func (h *Handle) CombatInvocationsNotify(userId uint32, gateAppId string, payloa
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if entityMoveInfo.MotionInfo.Pos.Y > 3000.0 {
|
if GetEntityType(entityMoveInfo.EntityId) != constant.ENTITY_TYPE_AVATAR {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// 玩家超速移动检测
|
||||||
|
ctx := h.GetPlayerAcCtx(userId)
|
||||||
|
ctx.Move(entityMoveInfo.MotionInfo.Pos)
|
||||||
|
moveSpeed := ctx.GetMoveSpeed()
|
||||||
|
logger.Debug("player move speed: %v, uid: %v", moveSpeed, userId)
|
||||||
|
if moveSpeed > MaxMoveSpeed {
|
||||||
|
logger.Warn("player move overspeed, speed: %v, uid: %v", moveSpeed, userId)
|
||||||
h.KickPlayer(userId, gateAppId)
|
h.KickPlayer(userId, gateAppId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetEntityType(entityId uint32) int {
|
||||||
|
return int(entityId >> 24)
|
||||||
|
}
|
||||||
|
|
||||||
func (h *Handle) KickPlayer(userId uint32, gateAppId string) {
|
func (h *Handle) KickPlayer(userId uint32, gateAppId string) {
|
||||||
h.messageQueue.SendToGate(gateAppId, &mq.NetMsg{
|
h.messageQueue.SendToGate(gateAppId, &mq.NetMsg{
|
||||||
MsgType: mq.MsgTypeConnCtrl,
|
MsgType: mq.MsgTypeConnCtrl,
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ const (
|
|||||||
// DropData 掉落配置表
|
// DropData 掉落配置表
|
||||||
type DropData struct {
|
type DropData struct {
|
||||||
DropId int32 `csv:"掉落ID"`
|
DropId int32 `csv:"掉落ID"`
|
||||||
RandomType int32 `csv:"随机方式,omitempty"` // 0:轮盘选择法掉落单个权重项 1:每个权重项独立随机(分母为10000)
|
RandomType int32 `csv:"随机方式,omitempty"` // 0:轮盘赌选择法掉落单个权重项 1:每个权重项独立随机(分母为10000)
|
||||||
DropLayer int32 `csv:"掉落层级,omitempty"`
|
DropLayer int32 `csv:"掉落层级,omitempty"`
|
||||||
SubDrop1Id int32 `csv:"子掉落1ID,omitempty"`
|
SubDrop1Id int32 `csv:"子掉落1ID,omitempty"`
|
||||||
SubDrop1CountRange FloatArray `csv:"子掉落1数量区间,omitempty"`
|
SubDrop1CountRange FloatArray `csv:"子掉落1数量区间,omitempty"`
|
||||||
|
|||||||
@@ -311,7 +311,7 @@ func UpdateFrame(rgb bool) {
|
|||||||
for _, v := range SCREEN_ENTITY_ID_LIST {
|
for _, v := range SCREEN_ENTITY_ID_LIST {
|
||||||
scene.DestroyEntity(v)
|
scene.DestroyEntity(v)
|
||||||
}
|
}
|
||||||
GAME_MANAGER.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_REMOVE, SCREEN_ENTITY_ID_LIST)
|
GAME.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_REMOVE, SCREEN_ENTITY_ID_LIST)
|
||||||
SCREEN_ENTITY_ID_LIST = make([]uint32, 0)
|
SCREEN_ENTITY_ID_LIST = make([]uint32, 0)
|
||||||
leftTopPos := &model.Vector{
|
leftTopPos := &model.Vector{
|
||||||
X: BASE_POS.X + float64(SCREEN_WIDTH)*SCREEN_DPI/2,
|
X: BASE_POS.X + float64(SCREEN_WIDTH)*SCREEN_DPI/2,
|
||||||
@@ -346,5 +346,5 @@ func UpdateFrame(rgb bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GAME_MANAGER.AddSceneEntityNotify(world.GetOwner(), proto.VisionType_VISION_BORN, SCREEN_ENTITY_ID_LIST, true, false)
|
GAME.AddSceneEntityNotify(world.GetOwner(), proto.VisionType_VISION_BORN, SCREEN_ENTITY_ID_LIST, true, false)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ const (
|
|||||||
BigWorldAiSign = "UnKownOwO"
|
BigWorldAiSign = "UnKownOwO"
|
||||||
)
|
)
|
||||||
|
|
||||||
var GAME_MANAGER *GameManager = nil
|
var GAME *Game = nil
|
||||||
var LOCAL_EVENT_MANAGER *LocalEventManager = nil
|
var LOCAL_EVENT_MANAGER *LocalEventManager = nil
|
||||||
var ROUTE_MANAGER *RouteManager = nil
|
var ROUTE_MANAGER *RouteManager = nil
|
||||||
var USER_MANAGER *UserManager = nil
|
var USER_MANAGER *UserManager = nil
|
||||||
@@ -45,8 +45,8 @@ var ONLINE_PLAYER_NUM int32 = 0 // 当前在线玩家数
|
|||||||
|
|
||||||
var SELF *model.Player
|
var SELF *model.Player
|
||||||
|
|
||||||
type GameManager struct {
|
type Game struct {
|
||||||
discovery *rpc.DiscoveryClient // node服务器客户端
|
discovery *rpc.DiscoveryClient // node节点服务器的natsrpc客户端
|
||||||
dao *dao.Dao
|
dao *dao.Dao
|
||||||
snowflake *alg.SnowflakeWorker
|
snowflake *alg.SnowflakeWorker
|
||||||
gsId uint32
|
gsId uint32
|
||||||
@@ -55,8 +55,8 @@ type GameManager struct {
|
|||||||
ai *model.Player // 本服的Ai玩家对象
|
ai *model.Player // 本服的Ai玩家对象
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGameManager(dao *dao.Dao, messageQueue *mq.MessageQueue, gsId uint32, gsAppid string, mainGsAppid string, discovery *rpc.DiscoveryClient) (r *GameManager) {
|
func NewGameManager(dao *dao.Dao, messageQueue *mq.MessageQueue, gsId uint32, gsAppid string, mainGsAppid string, discovery *rpc.DiscoveryClient) (r *Game) {
|
||||||
r = new(GameManager)
|
r = new(Game)
|
||||||
r.discovery = discovery
|
r.discovery = discovery
|
||||||
r.dao = dao
|
r.dao = dao
|
||||||
MESSAGE_QUEUE = messageQueue
|
MESSAGE_QUEUE = messageQueue
|
||||||
@@ -64,7 +64,7 @@ func NewGameManager(dao *dao.Dao, messageQueue *mq.MessageQueue, gsId uint32, gs
|
|||||||
r.gsId = gsId
|
r.gsId = gsId
|
||||||
r.gsAppid = gsAppid
|
r.gsAppid = gsAppid
|
||||||
r.mainGsAppid = mainGsAppid
|
r.mainGsAppid = mainGsAppid
|
||||||
GAME_MANAGER = r
|
GAME = r
|
||||||
LOCAL_EVENT_MANAGER = NewLocalEventManager()
|
LOCAL_EVENT_MANAGER = NewLocalEventManager()
|
||||||
ROUTE_MANAGER = NewRouteManager()
|
ROUTE_MANAGER = NewRouteManager()
|
||||||
USER_MANAGER = NewUserManager(dao)
|
USER_MANAGER = NewUserManager(dao)
|
||||||
@@ -118,31 +118,31 @@ func NewGameManager(dao *dao.Dao, messageQueue *mq.MessageQueue, gsId uint32, gs
|
|||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) GetGsId() uint32 {
|
func (g *Game) GetGsId() uint32 {
|
||||||
return g.gsId
|
return g.gsId
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) GetGsAppid() string {
|
func (g *Game) GetGsAppid() string {
|
||||||
return g.gsAppid
|
return g.gsAppid
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) GetMainGsAppid() string {
|
func (g *Game) GetMainGsAppid() string {
|
||||||
return g.mainGsAppid
|
return g.mainGsAppid
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) IsMainGs() bool {
|
func (g *Game) IsMainGs() bool {
|
||||||
// 目前的实现逻辑是当前GsId最小的Gs做MainGs
|
// 目前的实现逻辑是当前GsId最小的Gs做MainGs
|
||||||
return g.gsAppid == g.mainGsAppid
|
return g.gsAppid == g.mainGsAppid
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAi 获取本服的Ai玩家对象
|
// GetAi 获取本服的Ai玩家对象
|
||||||
func (g *GameManager) GetAi() *model.Player {
|
func (g *Game) GetAi() *model.Player {
|
||||||
return g.ai
|
return g.ai
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) CreateRobot(uid uint32, name string, sign string) *model.Player {
|
func (g *Game) CreateRobot(uid uint32, name string, sign string) *model.Player {
|
||||||
GAME_MANAGER.OnRegOk(false, &proto.SetPlayerBornDataReq{AvatarId: 10000007, NickName: name}, uid, 0, "")
|
GAME.OnRegOk(false, &proto.SetPlayerBornDataReq{AvatarId: 10000007, NickName: name}, uid, 0, "")
|
||||||
GAME_MANAGER.ServerAppidBindNotify(uid, "", 0)
|
GAME.ServerAppidBindNotify(uid, "", 0)
|
||||||
robot := USER_MANAGER.GetOnlineUser(uid)
|
robot := USER_MANAGER.GetOnlineUser(uid)
|
||||||
robot.DbState = model.DbNormal
|
robot.DbState = model.DbNormal
|
||||||
robot.SceneLoadState = model.SceneEnterDone
|
robot.SceneLoadState = model.SceneEnterDone
|
||||||
@@ -150,11 +150,11 @@ func (g *GameManager) CreateRobot(uid uint32, name string, sign string) *model.P
|
|||||||
return robot
|
return robot
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) run() {
|
func (g *Game) run() {
|
||||||
go g.gameMainLoopD()
|
go g.gameMainLoopD()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) gameMainLoopD() {
|
func (g *Game) gameMainLoopD() {
|
||||||
for times := 1; times <= 10000; times++ {
|
for times := 1; times <= 10000; times++ {
|
||||||
logger.Warn("start game main loop, times: %v", times)
|
logger.Warn("start game main loop, times: %v", times)
|
||||||
g.gameMainLoop()
|
g.gameMainLoop()
|
||||||
@@ -162,7 +162,7 @@ func (g *GameManager) gameMainLoopD() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) gameMainLoop() {
|
func (g *Game) gameMainLoop() {
|
||||||
// panic捕获
|
// panic捕获
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := recover(); err != nil {
|
if err := recover(); err != nil {
|
||||||
@@ -173,7 +173,7 @@ func (g *GameManager) gameMainLoop() {
|
|||||||
logger.Error("the motherfucker player uid: %v", SELF.PlayerID)
|
logger.Error("the motherfucker player uid: %v", SELF.PlayerID)
|
||||||
// info, _ := json.Marshal(SELF)
|
// info, _ := json.Marshal(SELF)
|
||||||
// logger.Error("the motherfucker player info: %v", string(info))
|
// logger.Error("the motherfucker player info: %v", string(info))
|
||||||
GAME_MANAGER.KickPlayer(SELF.PlayerID, kcp.EnetServerKick)
|
GAME.KickPlayer(SELF.PlayerID, kcp.EnetServerKick)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@@ -246,7 +246,7 @@ func (g *GameManager) gameMainLoop() {
|
|||||||
|
|
||||||
var EXIT_SAVE_FIN_CHAN chan bool
|
var EXIT_SAVE_FIN_CHAN chan bool
|
||||||
|
|
||||||
func (g *GameManager) Close() {
|
func (g *Game) Close() {
|
||||||
// 保存玩家数据
|
// 保存玩家数据
|
||||||
onlinePlayerMap := USER_MANAGER.GetAllOnlineUserList()
|
onlinePlayerMap := USER_MANAGER.GetAllOnlineUserList()
|
||||||
saveUserIdList := make([]uint32, 0, len(onlinePlayerMap))
|
saveUserIdList := make([]uint32, 0, len(onlinePlayerMap))
|
||||||
@@ -275,7 +275,7 @@ func (g *GameManager) Close() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SendMsgToGate 发送消息给客户端 指定网关
|
// SendMsgToGate 发送消息给客户端 指定网关
|
||||||
func (g *GameManager) SendMsgToGate(cmdId uint16, userId uint32, clientSeq uint32, gateAppId string, payloadMsg pb.Message) {
|
func (g *Game) SendMsgToGate(cmdId uint16, userId uint32, clientSeq uint32, gateAppId string, payloadMsg pb.Message) {
|
||||||
if userId < PlayerBaseUid {
|
if userId < PlayerBaseUid {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -303,7 +303,7 @@ func (g *GameManager) SendMsgToGate(cmdId uint16, userId uint32, clientSeq uint3
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SendMsg 发送消息给客户端
|
// SendMsg 发送消息给客户端
|
||||||
func (g *GameManager) SendMsg(cmdId uint16, userId uint32, clientSeq uint32, payloadMsg pb.Message) {
|
func (g *Game) SendMsg(cmdId uint16, userId uint32, clientSeq uint32, payloadMsg pb.Message) {
|
||||||
if userId < PlayerBaseUid {
|
if userId < PlayerBaseUid {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -335,7 +335,7 @@ func (g *GameManager) SendMsg(cmdId uint16, userId uint32, clientSeq uint32, pay
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SendError 通用返回错误码
|
// SendError 通用返回错误码
|
||||||
func (g *GameManager) SendError(cmdId uint16, player *model.Player, rsp pb.Message, retCode ...proto.Retcode) {
|
func (g *Game) SendError(cmdId uint16, player *model.Player, rsp pb.Message, retCode ...proto.Retcode) {
|
||||||
if rsp == nil {
|
if rsp == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -356,7 +356,7 @@ func (g *GameManager) SendError(cmdId uint16, player *model.Player, rsp pb.Messa
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SendSucc 通用返回成功
|
// SendSucc 通用返回成功
|
||||||
func (g *GameManager) SendSucc(cmdId uint16, player *model.Player, rsp pb.Message) {
|
func (g *Game) SendSucc(cmdId uint16, player *model.Player, rsp pb.Message) {
|
||||||
if rsp == nil {
|
if rsp == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -368,32 +368,32 @@ func (g *GameManager) SendSucc(cmdId uint16, player *model.Player, rsp pb.Messag
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SendToWorldA 给世界内所有玩家发消息
|
// SendToWorldA 给世界内所有玩家发消息
|
||||||
func (g *GameManager) SendToWorldA(world *World, cmdId uint16, seq uint32, msg pb.Message) {
|
func (g *Game) SendToWorldA(world *World, cmdId uint16, seq uint32, msg pb.Message) {
|
||||||
for _, v := range world.GetAllPlayer() {
|
for _, v := range world.GetAllPlayer() {
|
||||||
GAME_MANAGER.SendMsg(cmdId, v.PlayerID, seq, msg)
|
GAME.SendMsg(cmdId, v.PlayerID, seq, msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendToWorldAEC 给世界内除某玩家(一般是自己)以外的所有玩家发消息
|
// SendToWorldAEC 给世界内除某玩家(一般是自己)以外的所有玩家发消息
|
||||||
func (g *GameManager) SendToWorldAEC(world *World, cmdId uint16, seq uint32, msg pb.Message, uid uint32) {
|
func (g *Game) SendToWorldAEC(world *World, cmdId uint16, seq uint32, msg pb.Message, uid uint32) {
|
||||||
for _, v := range world.GetAllPlayer() {
|
for _, v := range world.GetAllPlayer() {
|
||||||
if uid == v.PlayerID {
|
if uid == v.PlayerID {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
GAME_MANAGER.SendMsg(cmdId, v.PlayerID, seq, msg)
|
GAME.SendMsg(cmdId, v.PlayerID, seq, msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendToWorldH 给世界房主发消息
|
// SendToWorldH 给世界房主发消息
|
||||||
func (g *GameManager) SendToWorldH(world *World, cmdId uint16, seq uint32, msg pb.Message) {
|
func (g *Game) SendToWorldH(world *World, cmdId uint16, seq uint32, msg pb.Message) {
|
||||||
GAME_MANAGER.SendMsg(cmdId, world.GetOwner().PlayerID, seq, msg)
|
GAME.SendMsg(cmdId, world.GetOwner().PlayerID, seq, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) ReLoginPlayer(userId uint32) {
|
func (g *Game) ReLoginPlayer(userId uint32) {
|
||||||
g.SendMsg(cmd.ClientReconnectNotify, userId, 0, new(proto.ClientReconnectNotify))
|
g.SendMsg(cmd.ClientReconnectNotify, userId, 0, new(proto.ClientReconnectNotify))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) KickPlayer(userId uint32, reason uint32) {
|
func (g *Game) KickPlayer(userId uint32, reason uint32) {
|
||||||
player := USER_MANAGER.GetOnlineUser(userId)
|
player := USER_MANAGER.GetOnlineUser(userId)
|
||||||
if player == nil {
|
if player == nil {
|
||||||
return
|
return
|
||||||
@@ -155,7 +155,7 @@ func (c *CommandManager) TeleportCommand(cmd *CommandMessage) {
|
|||||||
// 如果玩家不与目标玩家同一世界或不同服务器
|
// 如果玩家不与目标玩家同一世界或不同服务器
|
||||||
if target == nil || player.WorldId != target.WorldId {
|
if target == nil || player.WorldId != target.WorldId {
|
||||||
// 请求进入目标玩家世界
|
// 请求进入目标玩家世界
|
||||||
GAME_MANAGER.UserApplyEnterWorld(player, targetUid)
|
GAME.UserApplyEnterWorld(player, targetUid)
|
||||||
// 发送消息给执行者
|
// 发送消息给执行者
|
||||||
c.SendMessage(cmd.Executor, "已将玩家 UID:%v 请求加入目标玩家 UID:%v 的世界。", player.PlayerID, targetUid)
|
c.SendMessage(cmd.Executor, "已将玩家 UID:%v 请求加入目标玩家 UID:%v 的世界。", player.PlayerID, targetUid)
|
||||||
} else {
|
} else {
|
||||||
@@ -246,7 +246,7 @@ func (c *CommandManager) GiveCommand(cmd *CommandMessage) {
|
|||||||
switch mode {
|
switch mode {
|
||||||
case "once":
|
case "once":
|
||||||
// 判断是否为物品
|
// 判断是否为物品
|
||||||
_, ok := GAME_MANAGER.GetAllItemDataConfig()[int32(id)]
|
_, ok := GAME.GetAllItemDataConfig()[int32(id)]
|
||||||
if ok {
|
if ok {
|
||||||
// 给予玩家物品
|
// 给予玩家物品
|
||||||
c.gmCmd.GMAddUserItem(player.PlayerID, id, count)
|
c.gmCmd.GMAddUserItem(player.PlayerID, id, count)
|
||||||
@@ -254,7 +254,7 @@ func (c *CommandManager) GiveCommand(cmd *CommandMessage) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 判断是否为武器
|
// 判断是否为武器
|
||||||
_, ok = GAME_MANAGER.GetAllWeaponDataConfig()[int32(id)]
|
_, ok = GAME.GetAllWeaponDataConfig()[int32(id)]
|
||||||
if ok {
|
if ok {
|
||||||
// 给予玩家武器
|
// 给予玩家武器
|
||||||
c.gmCmd.GMAddUserWeapon(player.PlayerID, id, count)
|
c.gmCmd.GMAddUserWeapon(player.PlayerID, id, count)
|
||||||
@@ -263,7 +263,7 @@ func (c *CommandManager) GiveCommand(cmd *CommandMessage) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
// 判断是否为圣遗物
|
// 判断是否为圣遗物
|
||||||
_, ok = GAME_MANAGER.GetAllReliquaryDataConfig()[int32(id)]
|
_, ok = GAME.GetAllReliquaryDataConfig()[int32(id)]
|
||||||
if ok {
|
if ok {
|
||||||
// 给予玩家圣遗物
|
// 给予玩家圣遗物
|
||||||
c.gmCmd.GMAddUserReliquary(player.PlayerID, id, count)
|
c.gmCmd.GMAddUserReliquary(player.PlayerID, id, count)
|
||||||
@@ -272,7 +272,7 @@ func (c *CommandManager) GiveCommand(cmd *CommandMessage) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
// 判断是否为角色
|
// 判断是否为角色
|
||||||
_, ok = GAME_MANAGER.GetAllAvatarDataConfig()[int32(id)]
|
_, ok = GAME.GetAllAvatarDataConfig()[int32(id)]
|
||||||
if ok {
|
if ok {
|
||||||
// 给予玩家角色
|
// 给予玩家角色
|
||||||
c.gmCmd.GMAddUserAvatar(player.PlayerID, id)
|
c.gmCmd.GMAddUserAvatar(player.PlayerID, id)
|
||||||
@@ -329,7 +329,7 @@ func (c *CommandManager) GiveCommand(cmd *CommandMessage) {
|
|||||||
// GcgCommand Gcg测试命令
|
// GcgCommand Gcg测试命令
|
||||||
func (c *CommandManager) GcgCommand(cmd *CommandMessage) {
|
func (c *CommandManager) GcgCommand(cmd *CommandMessage) {
|
||||||
player := cmd.Executor.(*model.Player)
|
player := cmd.Executor.(*model.Player)
|
||||||
GAME_MANAGER.GCGStartChallenge(player)
|
GAME.GCGStartChallenge(player)
|
||||||
c.SendMessage(cmd.Executor, "收到命令")
|
c.SendMessage(cmd.Executor, "收到命令")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ func (g *GMCmd) GMTeleportPlayer(userId, sceneId, dungeonId uint32, posX, posY,
|
|||||||
logger.Error("player is nil, uid: %v", userId)
|
logger.Error("player is nil, uid: %v", userId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
GAME_MANAGER.TeleportPlayer(player, uint16(proto.EnterReason_ENTER_REASON_GM), sceneId, &model.Vector{
|
GAME.TeleportPlayer(player, uint16(proto.EnterReason_ENTER_REASON_GM), sceneId, &model.Vector{
|
||||||
X: posX,
|
X: posX,
|
||||||
Y: posY,
|
Y: posY,
|
||||||
Z: posZ,
|
Z: posZ,
|
||||||
@@ -34,7 +34,7 @@ func (g *GMCmd) GMTeleportPlayer(userId, sceneId, dungeonId uint32, posX, posY,
|
|||||||
|
|
||||||
// GMAddUserItem 给予玩家物品
|
// GMAddUserItem 给予玩家物品
|
||||||
func (g *GMCmd) GMAddUserItem(userId, itemId, itemCount uint32) {
|
func (g *GMCmd) GMAddUserItem(userId, itemId, itemCount uint32) {
|
||||||
GAME_MANAGER.AddUserItem(userId, []*ChangeItem{
|
GAME.AddUserItem(userId, []*ChangeItem{
|
||||||
{
|
{
|
||||||
ItemId: itemId,
|
ItemId: itemId,
|
||||||
ChangeCount: itemCount,
|
ChangeCount: itemCount,
|
||||||
@@ -47,7 +47,7 @@ func (g *GMCmd) GMAddUserWeapon(userId, itemId, itemCount uint32) {
|
|||||||
// 武器数量
|
// 武器数量
|
||||||
for i := uint32(0); i < itemCount; i++ {
|
for i := uint32(0); i < itemCount; i++ {
|
||||||
// 给予武器
|
// 给予武器
|
||||||
GAME_MANAGER.AddUserWeapon(userId, itemId)
|
GAME.AddUserWeapon(userId, itemId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,14 +56,14 @@ func (g *GMCmd) GMAddUserReliquary(userId, itemId, itemCount uint32) {
|
|||||||
// 圣遗物数量
|
// 圣遗物数量
|
||||||
for i := uint32(0); i < itemCount; i++ {
|
for i := uint32(0); i < itemCount; i++ {
|
||||||
// 给予圣遗物
|
// 给予圣遗物
|
||||||
GAME_MANAGER.AddUserReliquary(userId, itemId)
|
GAME.AddUserReliquary(userId, itemId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GMAddUserAvatar 给予玩家角色
|
// GMAddUserAvatar 给予玩家角色
|
||||||
func (g *GMCmd) GMAddUserAvatar(userId, avatarId uint32) {
|
func (g *GMCmd) GMAddUserAvatar(userId, avatarId uint32) {
|
||||||
// 添加角色
|
// 添加角色
|
||||||
GAME_MANAGER.AddUserAvatar(userId, avatarId)
|
GAME.AddUserAvatar(userId, avatarId)
|
||||||
// TODO 设置角色 等以后做到角色升级之类的再说
|
// TODO 设置角色 等以后做到角色升级之类的再说
|
||||||
// avatar := player.AvatarMap[avatarId]
|
// avatar := player.AvatarMap[avatarId]
|
||||||
}
|
}
|
||||||
@@ -71,44 +71,44 @@ func (g *GMCmd) GMAddUserAvatar(userId, avatarId uint32) {
|
|||||||
// GMAddUserCostume 给予玩家时装
|
// GMAddUserCostume 给予玩家时装
|
||||||
func (g *GMCmd) GMAddUserCostume(userId, costumeId uint32) {
|
func (g *GMCmd) GMAddUserCostume(userId, costumeId uint32) {
|
||||||
// 添加时装
|
// 添加时装
|
||||||
GAME_MANAGER.AddUserCostume(userId, costumeId)
|
GAME.AddUserCostume(userId, costumeId)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GMAddUserFlycloak 给予玩家风之翼
|
// GMAddUserFlycloak 给予玩家风之翼
|
||||||
func (g *GMCmd) GMAddUserFlycloak(userId, flycloakId uint32) {
|
func (g *GMCmd) GMAddUserFlycloak(userId, flycloakId uint32) {
|
||||||
// 添加风之翼
|
// 添加风之翼
|
||||||
GAME_MANAGER.AddUserFlycloak(userId, flycloakId)
|
GAME.AddUserFlycloak(userId, flycloakId)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GMAddUserAllItem 给予玩家所有物品
|
// GMAddUserAllItem 给予玩家所有物品
|
||||||
func (g *GMCmd) GMAddUserAllItem(userId, itemCount uint32) {
|
func (g *GMCmd) GMAddUserAllItem(userId, itemCount uint32) {
|
||||||
itemList := make([]*ChangeItem, 0)
|
itemList := make([]*ChangeItem, 0)
|
||||||
for itemId := range GAME_MANAGER.GetAllItemDataConfig() {
|
for itemId := range GAME.GetAllItemDataConfig() {
|
||||||
itemList = append(itemList, &ChangeItem{
|
itemList = append(itemList, &ChangeItem{
|
||||||
ItemId: uint32(itemId),
|
ItemId: uint32(itemId),
|
||||||
ChangeCount: itemCount,
|
ChangeCount: itemCount,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
GAME_MANAGER.AddUserItem(userId, itemList, false, 0)
|
GAME.AddUserItem(userId, itemList, false, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GMAddUserAllWeapon 给予玩家所有武器
|
// GMAddUserAllWeapon 给予玩家所有武器
|
||||||
func (g *GMCmd) GMAddUserAllWeapon(userId, itemCount uint32) {
|
func (g *GMCmd) GMAddUserAllWeapon(userId, itemCount uint32) {
|
||||||
for itemId := range GAME_MANAGER.GetAllWeaponDataConfig() {
|
for itemId := range GAME.GetAllWeaponDataConfig() {
|
||||||
g.GMAddUserWeapon(userId, uint32(itemId), itemCount)
|
g.GMAddUserWeapon(userId, uint32(itemId), itemCount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GMAddUserAllReliquary 给予玩家所有圣遗物
|
// GMAddUserAllReliquary 给予玩家所有圣遗物
|
||||||
func (g *GMCmd) GMAddUserAllReliquary(userId, itemCount uint32) {
|
func (g *GMCmd) GMAddUserAllReliquary(userId, itemCount uint32) {
|
||||||
for itemId := range GAME_MANAGER.GetAllReliquaryDataConfig() {
|
for itemId := range GAME.GetAllReliquaryDataConfig() {
|
||||||
g.GMAddUserReliquary(userId, uint32(itemId), itemCount)
|
g.GMAddUserReliquary(userId, uint32(itemId), itemCount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GMAddUserAllAvatar 给予玩家所有角色
|
// GMAddUserAllAvatar 给予玩家所有角色
|
||||||
func (g *GMCmd) GMAddUserAllAvatar(userId uint32) {
|
func (g *GMCmd) GMAddUserAllAvatar(userId uint32) {
|
||||||
for avatarId := range GAME_MANAGER.GetAllAvatarDataConfig() {
|
for avatarId := range GAME.GetAllAvatarDataConfig() {
|
||||||
g.GMAddUserAvatar(userId, uint32(avatarId))
|
g.GMAddUserAvatar(userId, uint32(avatarId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -155,8 +155,8 @@ func (g *GMCmd) GMAddQuest(userId uint32, questId uint32) {
|
|||||||
ntf := &proto.QuestListUpdateNotify{
|
ntf := &proto.QuestListUpdateNotify{
|
||||||
QuestList: make([]*proto.Quest, 0),
|
QuestList: make([]*proto.Quest, 0),
|
||||||
}
|
}
|
||||||
ntf.QuestList = append(ntf.QuestList, GAME_MANAGER.PacketQuest(player, questId))
|
ntf.QuestList = append(ntf.QuestList, GAME.PacketQuest(player, questId))
|
||||||
GAME_MANAGER.SendMsg(cmd.QuestListUpdateNotify, player.PlayerID, player.ClientSeq, ntf)
|
GAME.SendMsg(cmd.QuestListUpdateNotify, player.PlayerID, player.ClientSeq, ntf)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GMForceFinishAllQuest 强制完成当前所有任务
|
// GMForceFinishAllQuest 强制完成当前所有任务
|
||||||
@@ -172,14 +172,14 @@ func (g *GMCmd) GMForceFinishAllQuest(userId uint32) {
|
|||||||
}
|
}
|
||||||
for _, quest := range dbQuest.GetQuestMap() {
|
for _, quest := range dbQuest.GetQuestMap() {
|
||||||
dbQuest.ForceFinishQuest(quest.QuestId)
|
dbQuest.ForceFinishQuest(quest.QuestId)
|
||||||
pbQuest := GAME_MANAGER.PacketQuest(player, quest.QuestId)
|
pbQuest := GAME.PacketQuest(player, quest.QuestId)
|
||||||
if pbQuest == nil {
|
if pbQuest == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
ntf.QuestList = append(ntf.QuestList, pbQuest)
|
ntf.QuestList = append(ntf.QuestList, pbQuest)
|
||||||
}
|
}
|
||||||
GAME_MANAGER.SendMsg(cmd.QuestListUpdateNotify, player.PlayerID, player.ClientSeq, ntf)
|
GAME.SendMsg(cmd.QuestListUpdateNotify, player.PlayerID, player.ClientSeq, ntf)
|
||||||
GAME_MANAGER.AcceptQuest(player, true)
|
GAME.AcceptQuest(player, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GMUnlockAllPoint 解锁场景全部传送点
|
// GMUnlockAllPoint 解锁场景全部传送点
|
||||||
@@ -199,7 +199,7 @@ func (g *GMCmd) GMUnlockAllPoint(userId uint32, sceneId uint32) {
|
|||||||
for _, pointData := range scenePointMapConfig {
|
for _, pointData := range scenePointMapConfig {
|
||||||
dbScene.UnlockPoint(uint32(pointData.Id))
|
dbScene.UnlockPoint(uint32(pointData.Id))
|
||||||
}
|
}
|
||||||
GAME_MANAGER.SendMsg(cmd.ScenePointUnlockNotify, player.PlayerID, player.ClientSeq, &proto.ScenePointUnlockNotify{
|
GAME.SendMsg(cmd.ScenePointUnlockNotify, player.PlayerID, player.ClientSeq, &proto.ScenePointUnlockNotify{
|
||||||
SceneId: sceneId,
|
SceneId: sceneId,
|
||||||
PointList: dbScene.GetUnlockPointList(),
|
PointList: dbScene.GetUnlockPointList(),
|
||||||
UnhidePointList: nil,
|
UnhidePointList: nil,
|
||||||
@@ -213,7 +213,7 @@ func (g *GMCmd) GMCreateGadget(userId uint32, posX, posY, posZ float64, gadgetId
|
|||||||
logger.Error("player is nil, uid: %v", userId)
|
logger.Error("player is nil, uid: %v", userId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
GAME_MANAGER.CreateDropGadget(player, &model.Vector{
|
GAME.CreateDropGadget(player, &model.Vector{
|
||||||
X: posX,
|
X: posX,
|
||||||
Y: posY,
|
Y: posY,
|
||||||
Z: posZ,
|
Z: posZ,
|
||||||
@@ -254,7 +254,7 @@ func (g *GMCmd) XLuaDebug(userId uint32, luacBase64 string) {
|
|||||||
logger.Error("decode luac error: %v", err)
|
logger.Error("decode luac error: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
GAME_MANAGER.SendMsg(cmd.WindSeedClientNotify, player.PlayerID, 0, &proto.WindSeedClientNotify{
|
GAME.SendMsg(cmd.WindSeedClientNotify, player.PlayerID, 0, &proto.WindSeedClientNotify{
|
||||||
Notify: &proto.WindSeedClientNotify_AreaNotify_{
|
Notify: &proto.WindSeedClientNotify_AreaNotify_{
|
||||||
AreaNotify: &proto.WindSeedClientNotify_AreaNotify{
|
AreaNotify: &proto.WindSeedClientNotify_AreaNotify{
|
||||||
AreaCode: luac,
|
AreaCode: luac,
|
||||||
@@ -343,7 +343,7 @@ func (c *CommandManager) SendMessage(executor any, msg string, param ...any) {
|
|||||||
case *model.Player:
|
case *model.Player:
|
||||||
// 玩家类型
|
// 玩家类型
|
||||||
player := executor.(*model.Player)
|
player := executor.(*model.Player)
|
||||||
GAME_MANAGER.SendPrivateChat(c.system, player.PlayerID, fmt.Sprintf(msg, param...))
|
GAME.SendPrivateChat(c.system, player.PlayerID, fmt.Sprintf(msg, param...))
|
||||||
// case string:
|
// case string:
|
||||||
// GM接口等
|
// GM接口等
|
||||||
// str := executor.(string)
|
// str := executor.(string)
|
||||||
@@ -253,7 +253,7 @@ func (g *GCGManager) PhaseMain(game *GCGGame) {
|
|||||||
game.AddMsgPack(controller, 0, proto.GCGActionType_GCG_ACTION_NOTIFY_COST, game.GCGMsgCostRevise(controller))
|
game.AddMsgPack(controller, 0, proto.GCGActionType_GCG_ACTION_NOTIFY_COST, game.GCGMsgCostRevise(controller))
|
||||||
// 如果玩家当前允许操作则发送技能预览信息
|
// 如果玩家当前允许操作则发送技能预览信息
|
||||||
if controller.allow == 1 && controller.player != nil {
|
if controller.allow == 1 && controller.player != nil {
|
||||||
GAME_MANAGER.SendMsg(cmd.GCGSkillPreviewNotify, controller.player.PlayerID, controller.player.ClientSeq, GAME_MANAGER.PacketGCGSkillPreviewNotify(game, controller))
|
GAME.SendMsg(cmd.GCGSkillPreviewNotify, controller.player.PlayerID, controller.player.ClientSeq, GAME.PacketGCGSkillPreviewNotify(game, controller))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -631,7 +631,7 @@ func (g *GCGGame) onTick() {
|
|||||||
gcgHeartBeatNotify := &proto.GCGHeartBeatNotify{
|
gcgHeartBeatNotify := &proto.GCGHeartBeatNotify{
|
||||||
ServerSeq: controller.serverSeqCounter,
|
ServerSeq: controller.serverSeqCounter,
|
||||||
}
|
}
|
||||||
GAME_MANAGER.SendMsg(cmd.GCGHeartBeatNotify, controller.player.PlayerID, controller.player.ClientSeq, gcgHeartBeatNotify)
|
GAME.SendMsg(cmd.GCGHeartBeatNotify, controller.player.PlayerID, controller.player.ClientSeq, gcgHeartBeatNotify)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g.gameTick++
|
g.gameTick++
|
||||||
@@ -724,7 +724,7 @@ func (g *GCGGame) SendMsgPack(controller *GCGController) {
|
|||||||
// 游戏不处于运行状态仅记录历史消息包
|
// 游戏不处于运行状态仅记录历史消息包
|
||||||
if g.gameState == GCGGameState_Running {
|
if g.gameState == GCGGameState_Running {
|
||||||
controller.serverSeqCounter++
|
controller.serverSeqCounter++
|
||||||
GAME_MANAGER.SendGCGMessagePackNotify(controller, controller.serverSeqCounter, controller.msgPackList)
|
GAME.SendGCGMessagePackNotify(controller, controller.serverSeqCounter, controller.msgPackList)
|
||||||
}
|
}
|
||||||
// 记录发送的历史消息包
|
// 记录发送的历史消息包
|
||||||
for _, pack := range controller.msgPackList {
|
for _, pack := range controller.msgPackList {
|
||||||
@@ -1169,3 +1169,63 @@ func (g *GCGGame) GetControllerByUserId(userId uint32) *GCGController {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type GCGAi struct {
|
||||||
|
game *GCGGame // 所在的游戏
|
||||||
|
controllerId uint32 // 操控者Id
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReceiveGCGMessagePackNotify 接收GCG消息包通知
|
||||||
|
func (g *GCGAi) ReceiveGCGMessagePackNotify(notify *proto.GCGMessagePackNotify) {
|
||||||
|
// 获取玩家的操控者对象
|
||||||
|
gameController := g.game.controllerMap[g.controllerId]
|
||||||
|
if gameController == nil {
|
||||||
|
logger.Error("ai 角色 nil")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, pack := range notify.MsgPackList {
|
||||||
|
for _, message := range pack.MsgList {
|
||||||
|
switch message.Message.(type) {
|
||||||
|
case *proto.GCGMessage_PhaseChange:
|
||||||
|
// 阶段改变
|
||||||
|
msg := message.GetPhaseChange()
|
||||||
|
switch msg.AfterPhase {
|
||||||
|
case proto.GCGPhaseType_GCG_PHASE_ON_STAGE:
|
||||||
|
logger.Error("请选择你的英雄 hhh")
|
||||||
|
go func() {
|
||||||
|
time.Sleep(3 * 1000)
|
||||||
|
// 默认选第一张牌
|
||||||
|
cardInfo := gameController.cardMap[CardInfoType_Char][0]
|
||||||
|
// 操控者选择角色牌
|
||||||
|
g.game.ControllerSelectChar(gameController, cardInfo, []uint32{})
|
||||||
|
}()
|
||||||
|
case proto.GCGPhaseType_GCG_PHASE_MAIN:
|
||||||
|
if gameController.allow == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
go func() {
|
||||||
|
time.Sleep(3 * 1000)
|
||||||
|
g.game.ControllerUseSkill(gameController, gameController.GetSelectedCharCard().skillList[0].skillId, []uint32{})
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
case *proto.GCGMessage_DiceRoll:
|
||||||
|
// 摇完骰子
|
||||||
|
msg := message.GetDiceRoll()
|
||||||
|
if msg.ControllerId != g.controllerId {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
logger.Error("敌方行动意图")
|
||||||
|
go func() {
|
||||||
|
time.Sleep(3 * 1000)
|
||||||
|
cardInfo1 := g.game.controllerMap[g.controllerId].cardMap[CardInfoType_Char][0]
|
||||||
|
cardInfo2 := g.game.controllerMap[g.controllerId].cardMap[CardInfoType_Char][1]
|
||||||
|
g.game.AddAllMsgPack(0, proto.GCGActionType_GCG_ACTION_NONE, g.game.GCGMsgPVEIntention(&proto.GCGMsgPVEIntention{CardGuid: cardInfo1.guid, SkillIdList: []uint32{cardInfo1.skillList[0].skillId}}, &proto.GCGMsgPVEIntention{CardGuid: cardInfo2.guid, SkillIdList: []uint32{cardInfo2.skillList[0].skillId}}))
|
||||||
|
g.game.SendAllMsgPack()
|
||||||
|
g.game.SetControllerAllow(g.game.controllerMap[g.controllerId], false, true)
|
||||||
|
g.game.AddAllMsgPack(0, proto.GCGActionType_GCG_ACTION_SEND_MESSAGE, g.game.GCGMsgPhaseContinue())
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -69,10 +69,10 @@ func (l *LocalEventManager) LocalEventHandle(localEvent *LocalEvent) {
|
|||||||
if playerLoginInfo.Player != nil {
|
if playerLoginInfo.Player != nil {
|
||||||
USER_MANAGER.AddUser(playerLoginInfo.Player)
|
USER_MANAGER.AddUser(playerLoginInfo.Player)
|
||||||
}
|
}
|
||||||
GAME_MANAGER.OnLoginOk(playerLoginInfo.UserId, playerLoginInfo.ClientSeq, playerLoginInfo.GateAppId, false, playerLoginInfo.Player)
|
GAME.OnLoginOk(playerLoginInfo.UserId, playerLoginInfo.ClientSeq, playerLoginInfo.GateAppId, false, playerLoginInfo.Player)
|
||||||
case CheckUserExistOnRegFromDbFinish:
|
case CheckUserExistOnRegFromDbFinish:
|
||||||
playerRegInfo := localEvent.Msg.(*PlayerRegInfo)
|
playerRegInfo := localEvent.Msg.(*PlayerRegInfo)
|
||||||
GAME_MANAGER.OnRegOk(playerRegInfo.Exist, playerRegInfo.Req, playerRegInfo.UserId, playerRegInfo.ClientSeq, playerRegInfo.GateAppId)
|
GAME.OnRegOk(playerRegInfo.Exist, playerRegInfo.Req, playerRegInfo.UserId, playerRegInfo.ClientSeq, playerRegInfo.GateAppId)
|
||||||
case ExitRunUserCopyAndSave:
|
case ExitRunUserCopyAndSave:
|
||||||
fallthrough
|
fallthrough
|
||||||
case RunUserCopyAndSave:
|
case RunUserCopyAndSave:
|
||||||
206
gs/game/game_route_manager.go
Normal file
206
gs/game/game_route_manager.go
Normal file
@@ -0,0 +1,206 @@
|
|||||||
|
package game
|
||||||
|
|
||||||
|
import (
|
||||||
|
"hk4e/common/mq"
|
||||||
|
"hk4e/gate/kcp"
|
||||||
|
"hk4e/gs/model"
|
||||||
|
"hk4e/node/api"
|
||||||
|
"hk4e/pkg/logger"
|
||||||
|
"hk4e/protocol/cmd"
|
||||||
|
|
||||||
|
pb "google.golang.org/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
// 接口路由管理器
|
||||||
|
|
||||||
|
type HandlerFunc func(player *model.Player, payloadMsg pb.Message)
|
||||||
|
|
||||||
|
type RouteManager struct {
|
||||||
|
// k:cmdId v:HandlerFunc
|
||||||
|
handlerFuncRouteMap map[uint16]HandlerFunc
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewRouteManager() (r *RouteManager) {
|
||||||
|
r = new(RouteManager)
|
||||||
|
r.handlerFuncRouteMap = make(map[uint16]HandlerFunc)
|
||||||
|
r.initRoute()
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *RouteManager) registerRouter(cmdId uint16, handlerFunc HandlerFunc) {
|
||||||
|
r.handlerFuncRouteMap[cmdId] = handlerFunc
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *RouteManager) doRoute(cmdId uint16, userId uint32, clientSeq uint32, payloadMsg pb.Message) {
|
||||||
|
handlerFunc, ok := r.handlerFuncRouteMap[cmdId]
|
||||||
|
if !ok {
|
||||||
|
logger.Error("no route for msg, cmdId: %v", cmdId)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
player := USER_MANAGER.GetOnlineUser(userId)
|
||||||
|
if player == nil {
|
||||||
|
logger.Error("player is nil, uid: %v", userId)
|
||||||
|
GAME.KickPlayer(userId, kcp.EnetNotFoundSession)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !player.Online {
|
||||||
|
logger.Error("player not online, uid: %v", userId)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
player.ClientSeq = clientSeq
|
||||||
|
SELF = player
|
||||||
|
handlerFunc(player, payloadMsg)
|
||||||
|
SELF = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *RouteManager) initRoute() {
|
||||||
|
r.registerRouter(cmd.QueryPathReq, GAME.QueryPathReq)
|
||||||
|
r.registerRouter(cmd.UnionCmdNotify, GAME.UnionCmdNotify)
|
||||||
|
r.registerRouter(cmd.MassiveEntityElementOpBatchNotify, GAME.MassiveEntityElementOpBatchNotify)
|
||||||
|
r.registerRouter(cmd.ToTheMoonEnterSceneReq, GAME.ToTheMoonEnterSceneReq)
|
||||||
|
r.registerRouter(cmd.PlayerSetPauseReq, GAME.PlayerSetPauseReq)
|
||||||
|
r.registerRouter(cmd.EnterSceneReadyReq, GAME.EnterSceneReadyReq)
|
||||||
|
r.registerRouter(cmd.PathfindingEnterSceneReq, GAME.PathfindingEnterSceneReq)
|
||||||
|
r.registerRouter(cmd.GetScenePointReq, GAME.GetScenePointReq)
|
||||||
|
r.registerRouter(cmd.GetSceneAreaReq, GAME.GetSceneAreaReq)
|
||||||
|
r.registerRouter(cmd.SceneInitFinishReq, GAME.SceneInitFinishReq)
|
||||||
|
r.registerRouter(cmd.EnterSceneDoneReq, GAME.EnterSceneDoneReq)
|
||||||
|
r.registerRouter(cmd.EnterWorldAreaReq, GAME.EnterWorldAreaReq)
|
||||||
|
r.registerRouter(cmd.PostEnterSceneReq, GAME.PostEnterSceneReq)
|
||||||
|
r.registerRouter(cmd.TowerAllDataReq, GAME.TowerAllDataReq)
|
||||||
|
r.registerRouter(cmd.SceneTransToPointReq, GAME.SceneTransToPointReq)
|
||||||
|
r.registerRouter(cmd.UnlockTransPointReq, GAME.UnlockTransPointReq)
|
||||||
|
r.registerRouter(cmd.MarkMapReq, GAME.MarkMapReq)
|
||||||
|
r.registerRouter(cmd.ChangeAvatarReq, GAME.ChangeAvatarReq)
|
||||||
|
r.registerRouter(cmd.SetUpAvatarTeamReq, GAME.SetUpAvatarTeamReq)
|
||||||
|
r.registerRouter(cmd.ChooseCurAvatarTeamReq, GAME.ChooseCurAvatarTeamReq)
|
||||||
|
r.registerRouter(cmd.GetGachaInfoReq, GAME.GetGachaInfoReq)
|
||||||
|
r.registerRouter(cmd.DoGachaReq, GAME.DoGachaReq)
|
||||||
|
r.registerRouter(cmd.CombatInvocationsNotify, GAME.CombatInvocationsNotify)
|
||||||
|
r.registerRouter(cmd.AbilityInvocationsNotify, GAME.AbilityInvocationsNotify)
|
||||||
|
r.registerRouter(cmd.ClientAbilityInitFinishNotify, GAME.ClientAbilityInitFinishNotify)
|
||||||
|
r.registerRouter(cmd.EvtDoSkillSuccNotify, GAME.EvtDoSkillSuccNotify)
|
||||||
|
r.registerRouter(cmd.ClientAbilityChangeNotify, GAME.ClientAbilityChangeNotify)
|
||||||
|
r.registerRouter(cmd.EntityAiSyncNotify, GAME.EntityAiSyncNotify)
|
||||||
|
r.registerRouter(cmd.WearEquipReq, GAME.WearEquipReq)
|
||||||
|
r.registerRouter(cmd.ChangeGameTimeReq, GAME.ChangeGameTimeReq)
|
||||||
|
r.registerRouter(cmd.GetPlayerSocialDetailReq, GAME.GetPlayerSocialDetailReq)
|
||||||
|
r.registerRouter(cmd.SetPlayerBirthdayReq, GAME.SetPlayerBirthdayReq)
|
||||||
|
r.registerRouter(cmd.SetNameCardReq, GAME.SetNameCardReq)
|
||||||
|
r.registerRouter(cmd.SetPlayerSignatureReq, GAME.SetPlayerSignatureReq)
|
||||||
|
r.registerRouter(cmd.SetPlayerNameReq, GAME.SetPlayerNameReq)
|
||||||
|
r.registerRouter(cmd.SetPlayerHeadImageReq, GAME.SetPlayerHeadImageReq)
|
||||||
|
r.registerRouter(cmd.GetAllUnlockNameCardReq, GAME.GetAllUnlockNameCardReq)
|
||||||
|
r.registerRouter(cmd.GetPlayerFriendListReq, GAME.GetPlayerFriendListReq)
|
||||||
|
r.registerRouter(cmd.GetPlayerAskFriendListReq, GAME.GetPlayerAskFriendListReq)
|
||||||
|
r.registerRouter(cmd.AskAddFriendReq, GAME.AskAddFriendReq)
|
||||||
|
r.registerRouter(cmd.DealAddFriendReq, GAME.DealAddFriendReq)
|
||||||
|
r.registerRouter(cmd.GetOnlinePlayerListReq, GAME.GetOnlinePlayerListReq)
|
||||||
|
r.registerRouter(cmd.PlayerApplyEnterMpReq, GAME.PlayerApplyEnterMpReq)
|
||||||
|
r.registerRouter(cmd.PlayerApplyEnterMpResultReq, GAME.PlayerApplyEnterMpResultReq)
|
||||||
|
r.registerRouter(cmd.PlayerGetForceQuitBanInfoReq, GAME.PlayerGetForceQuitBanInfoReq)
|
||||||
|
r.registerRouter(cmd.GetShopmallDataReq, GAME.GetShopmallDataReq)
|
||||||
|
r.registerRouter(cmd.GetShopReq, GAME.GetShopReq)
|
||||||
|
r.registerRouter(cmd.BuyGoodsReq, GAME.BuyGoodsReq)
|
||||||
|
r.registerRouter(cmd.McoinExchangeHcoinReq, GAME.McoinExchangeHcoinReq)
|
||||||
|
r.registerRouter(cmd.AvatarChangeCostumeReq, GAME.AvatarChangeCostumeReq)
|
||||||
|
r.registerRouter(cmd.AvatarWearFlycloakReq, GAME.AvatarWearFlycloakReq)
|
||||||
|
r.registerRouter(cmd.PullRecentChatReq, GAME.PullRecentChatReq)
|
||||||
|
r.registerRouter(cmd.PullPrivateChatReq, GAME.PullPrivateChatReq)
|
||||||
|
r.registerRouter(cmd.PrivateChatReq, GAME.PrivateChatReq)
|
||||||
|
r.registerRouter(cmd.ReadPrivateChatReq, GAME.ReadPrivateChatReq)
|
||||||
|
r.registerRouter(cmd.PlayerChatReq, GAME.PlayerChatReq)
|
||||||
|
r.registerRouter(cmd.BackMyWorldReq, GAME.BackMyWorldReq)
|
||||||
|
r.registerRouter(cmd.ChangeWorldToSingleModeReq, GAME.ChangeWorldToSingleModeReq)
|
||||||
|
r.registerRouter(cmd.SceneKickPlayerReq, GAME.SceneKickPlayerReq)
|
||||||
|
r.registerRouter(cmd.ChangeMpTeamAvatarReq, GAME.ChangeMpTeamAvatarReq)
|
||||||
|
r.registerRouter(cmd.SceneAvatarStaminaStepReq, GAME.SceneAvatarStaminaStepReq)
|
||||||
|
r.registerRouter(cmd.JoinPlayerSceneReq, GAME.JoinPlayerSceneReq)
|
||||||
|
r.registerRouter(cmd.EvtAvatarEnterFocusNotify, GAME.EvtAvatarEnterFocusNotify)
|
||||||
|
r.registerRouter(cmd.EvtAvatarUpdateFocusNotify, GAME.EvtAvatarUpdateFocusNotify)
|
||||||
|
r.registerRouter(cmd.EvtAvatarExitFocusNotify, GAME.EvtAvatarExitFocusNotify)
|
||||||
|
r.registerRouter(cmd.EvtEntityRenderersChangedNotify, GAME.EvtEntityRenderersChangedNotify)
|
||||||
|
r.registerRouter(cmd.EvtCreateGadgetNotify, GAME.EvtCreateGadgetNotify)
|
||||||
|
r.registerRouter(cmd.EvtDestroyGadgetNotify, GAME.EvtDestroyGadgetNotify)
|
||||||
|
r.registerRouter(cmd.CreateVehicleReq, GAME.CreateVehicleReq)
|
||||||
|
r.registerRouter(cmd.VehicleInteractReq, GAME.VehicleInteractReq)
|
||||||
|
r.registerRouter(cmd.SceneEntityDrownReq, GAME.SceneEntityDrownReq)
|
||||||
|
r.registerRouter(cmd.GetOnlinePlayerInfoReq, GAME.GetOnlinePlayerInfoReq)
|
||||||
|
r.registerRouter(cmd.GCGAskDuelReq, GAME.GCGAskDuelReq)
|
||||||
|
r.registerRouter(cmd.GCGInitFinishReq, GAME.GCGInitFinishReq)
|
||||||
|
r.registerRouter(cmd.GCGOperationReq, GAME.GCGOperationReq)
|
||||||
|
r.registerRouter(cmd.ObstacleModifyNotify, GAME.ObstacleModifyNotify)
|
||||||
|
r.registerRouter(cmd.AvatarUpgradeReq, GAME.AvatarUpgradeReq)
|
||||||
|
r.registerRouter(cmd.AvatarPromoteReq, GAME.AvatarPromoteReq)
|
||||||
|
r.registerRouter(cmd.CalcWeaponUpgradeReturnItemsReq, GAME.CalcWeaponUpgradeReturnItemsReq)
|
||||||
|
r.registerRouter(cmd.WeaponUpgradeReq, GAME.WeaponUpgradeReq)
|
||||||
|
r.registerRouter(cmd.WeaponPromoteReq, GAME.WeaponPromoteReq)
|
||||||
|
r.registerRouter(cmd.WeaponAwakenReq, GAME.WeaponAwakenReq)
|
||||||
|
r.registerRouter(cmd.AvatarPromoteGetRewardReq, GAME.AvatarPromoteGetRewardReq)
|
||||||
|
r.registerRouter(cmd.SetEquipLockStateReq, GAME.SetEquipLockStateReq)
|
||||||
|
r.registerRouter(cmd.TakeoffEquipReq, GAME.TakeoffEquipReq)
|
||||||
|
r.registerRouter(cmd.AddQuestContentProgressReq, GAME.AddQuestContentProgressReq)
|
||||||
|
r.registerRouter(cmd.NpcTalkReq, GAME.NpcTalkReq)
|
||||||
|
r.registerRouter(cmd.EvtAiSyncSkillCdNotify, GAME.EvtAiSyncSkillCdNotify)
|
||||||
|
r.registerRouter(cmd.EvtAiSyncCombatThreatInfoNotify, GAME.EvtAiSyncCombatThreatInfoNotify)
|
||||||
|
r.registerRouter(cmd.EntityConfigHashNotify, GAME.EntityConfigHashNotify)
|
||||||
|
r.registerRouter(cmd.MonsterAIConfigHashNotify, GAME.MonsterAIConfigHashNotify)
|
||||||
|
r.registerRouter(cmd.DungeonEntryInfoReq, GAME.DungeonEntryInfoReq)
|
||||||
|
r.registerRouter(cmd.PlayerEnterDungeonReq, GAME.PlayerEnterDungeonReq)
|
||||||
|
r.registerRouter(cmd.PlayerQuitDungeonReq, GAME.PlayerQuitDungeonReq)
|
||||||
|
r.registerRouter(cmd.GadgetInteractReq, GAME.GadgetInteractReq)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *RouteManager) RouteHandle(netMsg *mq.NetMsg) {
|
||||||
|
switch netMsg.MsgType {
|
||||||
|
case mq.MsgTypeGame:
|
||||||
|
if netMsg.OriginServerType != api.GATE {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
gameMsg := netMsg.GameMsg
|
||||||
|
switch netMsg.EventId {
|
||||||
|
case mq.NormalMsg:
|
||||||
|
if gameMsg.CmdId == cmd.PlayerLoginReq {
|
||||||
|
GAME.PlayerLoginReq(gameMsg.UserId, gameMsg.ClientSeq, netMsg.OriginServerAppId, gameMsg.PayloadMessage)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if gameMsg.CmdId == cmd.SetPlayerBornDataReq {
|
||||||
|
GAME.SetPlayerBornDataReq(gameMsg.UserId, gameMsg.ClientSeq, netMsg.OriginServerAppId, gameMsg.PayloadMessage)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
r.doRoute(gameMsg.CmdId, gameMsg.UserId, gameMsg.ClientSeq, gameMsg.PayloadMessage)
|
||||||
|
}
|
||||||
|
case mq.MsgTypeConnCtrl:
|
||||||
|
if netMsg.OriginServerType != api.GATE {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
connCtrlMsg := netMsg.ConnCtrlMsg
|
||||||
|
switch netMsg.EventId {
|
||||||
|
case mq.ClientRttNotify:
|
||||||
|
GAME.ClientRttNotify(connCtrlMsg.UserId, connCtrlMsg.ClientRtt)
|
||||||
|
case mq.ClientTimeNotify:
|
||||||
|
GAME.ClientTimeNotify(connCtrlMsg.UserId, connCtrlMsg.ClientTime)
|
||||||
|
case mq.UserOfflineNotify:
|
||||||
|
GAME.OnUserOffline(connCtrlMsg.UserId, &ChangeGsInfo{
|
||||||
|
IsChangeGs: false,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
case mq.MsgTypeServer:
|
||||||
|
serverMsg := netMsg.ServerMsg
|
||||||
|
switch netMsg.EventId {
|
||||||
|
case mq.ServerUserOnlineStateChangeNotify:
|
||||||
|
logger.Debug("remote user online state change, uid: %v, online: %v", serverMsg.UserId, serverMsg.IsOnline)
|
||||||
|
USER_MANAGER.SetRemoteUserOnlineState(serverMsg.UserId, serverMsg.IsOnline, netMsg.OriginServerAppId)
|
||||||
|
case mq.ServerAppidBindNotify:
|
||||||
|
GAME.ServerAppidBindNotify(serverMsg.UserId, serverMsg.AnticheatServerAppId, serverMsg.JoinHostUserId)
|
||||||
|
case mq.ServerUserMpReq:
|
||||||
|
GAME.ServerUserMpReq(serverMsg.UserMpInfo, netMsg.OriginServerAppId)
|
||||||
|
case mq.ServerUserMpRsp:
|
||||||
|
GAME.ServerUserMpRsp(serverMsg.UserMpInfo)
|
||||||
|
case mq.ServerChatMsgNotify:
|
||||||
|
GAME.ServerChatMsgNotify(serverMsg.ChatMsgInfo)
|
||||||
|
case mq.ServerAddFriendNotify:
|
||||||
|
GAME.ServerAddFriendNotify(serverMsg.AddFriendInfo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -93,7 +93,7 @@ func (t *TickManager) onUserTickMinute(userId uint32, now int64) {
|
|||||||
}
|
}
|
||||||
if uint32(now/1000)-player.LastKeepaliveTime > 60 {
|
if uint32(now/1000)-player.LastKeepaliveTime > 60 {
|
||||||
logger.Error("remove keepalive timeout user, uid: %v", userId)
|
logger.Error("remove keepalive timeout user, uid: %v", userId)
|
||||||
GAME_MANAGER.OnUserOffline(userId, &ChangeGsInfo{
|
GAME.OnUserOffline(userId, &ChangeGsInfo{
|
||||||
IsChangeGs: false,
|
IsChangeGs: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -186,29 +186,29 @@ func (t *TickManager) onTickHour(now int64) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *TickManager) onTickMinute(now int64) {
|
func (t *TickManager) onTickMinute(now int64) {
|
||||||
// GAME_MANAGER.ServerAnnounceNotify(100, "test123")
|
// GAME.ServerAnnounceNotify(100, "test123")
|
||||||
gdconf.LuaStateLruRemove()
|
gdconf.LuaStateLruRemove()
|
||||||
for _, world := range WORLD_MANAGER.GetAllWorld() {
|
for _, world := range WORLD_MANAGER.GetAllWorld() {
|
||||||
for _, player := range world.GetAllPlayer() {
|
for _, player := range world.GetAllPlayer() {
|
||||||
// 随机物品
|
// 随机物品
|
||||||
allItemDataConfig := GAME_MANAGER.GetAllItemDataConfig()
|
allItemDataConfig := GAME.GetAllItemDataConfig()
|
||||||
count := random.GetRandomInt32(0, 4)
|
count := random.GetRandomInt32(0, 4)
|
||||||
i := int32(0)
|
i := int32(0)
|
||||||
for itemId := range allItemDataConfig {
|
for itemId := range allItemDataConfig {
|
||||||
num := random.GetRandomInt32(1, 9)
|
num := random.GetRandomInt32(1, 9)
|
||||||
GAME_MANAGER.AddUserItem(player.PlayerID, []*ChangeItem{{ItemId: uint32(itemId), ChangeCount: uint32(num)}}, true, 0)
|
GAME.AddUserItem(player.PlayerID, []*ChangeItem{{ItemId: uint32(itemId), ChangeCount: uint32(num)}}, true, 0)
|
||||||
i++
|
i++
|
||||||
if i > count {
|
if i > count {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GAME_MANAGER.AddUserItem(player.PlayerID, []*ChangeItem{{ItemId: 102, ChangeCount: 30}}, true, 0)
|
GAME.AddUserItem(player.PlayerID, []*ChangeItem{{ItemId: 102, ChangeCount: 30}}, true, 0)
|
||||||
GAME_MANAGER.AddUserItem(player.PlayerID, []*ChangeItem{{ItemId: 201, ChangeCount: 10}}, true, 0)
|
GAME.AddUserItem(player.PlayerID, []*ChangeItem{{ItemId: 201, ChangeCount: 10}}, true, 0)
|
||||||
GAME_MANAGER.AddUserItem(player.PlayerID, []*ChangeItem{{ItemId: 202, ChangeCount: 100}}, true, 0)
|
GAME.AddUserItem(player.PlayerID, []*ChangeItem{{ItemId: 202, ChangeCount: 100}}, true, 0)
|
||||||
GAME_MANAGER.AddUserItem(player.PlayerID, []*ChangeItem{{ItemId: 203, ChangeCount: 10}}, true, 0)
|
GAME.AddUserItem(player.PlayerID, []*ChangeItem{{ItemId: 203, ChangeCount: 10}}, true, 0)
|
||||||
// 蓝球粉球
|
// 蓝球粉球
|
||||||
GAME_MANAGER.AddUserItem(player.PlayerID, []*ChangeItem{{ItemId: 223, ChangeCount: 1}}, true, 0)
|
GAME.AddUserItem(player.PlayerID, []*ChangeItem{{ItemId: 223, ChangeCount: 1}}, true, 0)
|
||||||
GAME_MANAGER.AddUserItem(player.PlayerID, []*ChangeItem{{ItemId: 224, ChangeCount: 1}}, true, 0)
|
GAME.AddUserItem(player.PlayerID, []*ChangeItem{{ItemId: 224, ChangeCount: 1}}, true, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -222,7 +222,7 @@ func (t *TickManager) onTick10Second(now int64) {
|
|||||||
SceneId: player.SceneId,
|
SceneId: player.SceneId,
|
||||||
SceneTime: uint64(scene.GetSceneTime()),
|
SceneTime: uint64(scene.GetSceneTime()),
|
||||||
}
|
}
|
||||||
GAME_MANAGER.SendMsg(cmd.SceneTimeNotify, player.PlayerID, 0, sceneTimeNotify)
|
GAME.SendMsg(cmd.SceneTimeNotify, player.PlayerID, 0, sceneTimeNotify)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, player := range world.GetAllPlayer() {
|
for _, player := range world.GetAllPlayer() {
|
||||||
@@ -231,7 +231,7 @@ func (t *TickManager) onTick10Second(now int64) {
|
|||||||
PlayerTime: uint64(player.TotalOnlineTime),
|
PlayerTime: uint64(player.TotalOnlineTime),
|
||||||
ServerTime: uint64(time.Now().UnixMilli()),
|
ServerTime: uint64(time.Now().UnixMilli()),
|
||||||
}
|
}
|
||||||
GAME_MANAGER.SendMsg(cmd.PlayerTimeNotify, player.PlayerID, 0, playerTimeNotify)
|
GAME.SendMsg(cmd.PlayerTimeNotify, player.PlayerID, 0, playerTimeNotify)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -240,7 +240,7 @@ func (t *TickManager) onTick5Second(now int64) {
|
|||||||
for _, world := range WORLD_MANAGER.GetAllWorld() {
|
for _, world := range WORLD_MANAGER.GetAllWorld() {
|
||||||
if WORLD_MANAGER.IsAiWorld(world) {
|
if WORLD_MANAGER.IsAiWorld(world) {
|
||||||
for applyUid := range world.owner.CoopApplyMap {
|
for applyUid := range world.owner.CoopApplyMap {
|
||||||
GAME_MANAGER.UserDealEnterWorld(world.owner, applyUid, true)
|
GAME.UserDealEnterWorld(world.owner, applyUid, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 多人世界其他玩家的坐标位置广播
|
// 多人世界其他玩家的坐标位置广播
|
||||||
@@ -266,7 +266,7 @@ func (t *TickManager) onTick5Second(now int64) {
|
|||||||
}
|
}
|
||||||
worldPlayerLocationNotify.PlayerWorldLocList = append(worldPlayerLocationNotify.PlayerWorldLocList, playerWorldLocationInfo)
|
worldPlayerLocationNotify.PlayerWorldLocList = append(worldPlayerLocationNotify.PlayerWorldLocList, playerWorldLocationInfo)
|
||||||
}
|
}
|
||||||
GAME_MANAGER.SendToWorldA(world, cmd.WorldPlayerLocationNotify, 0, worldPlayerLocationNotify)
|
GAME.SendToWorldA(world, cmd.WorldPlayerLocationNotify, 0, worldPlayerLocationNotify)
|
||||||
|
|
||||||
for _, scene := range world.GetAllScene() {
|
for _, scene := range world.GetAllScene() {
|
||||||
scenePlayerLocationNotify := &proto.ScenePlayerLocationNotify{
|
scenePlayerLocationNotify := &proto.ScenePlayerLocationNotify{
|
||||||
@@ -320,7 +320,7 @@ func (t *TickManager) onTick5Second(now int64) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GAME_MANAGER.SendToWorldA(world, cmd.ScenePlayerLocationNotify, 0, scenePlayerLocationNotify)
|
GAME.SendToWorldA(world, cmd.ScenePlayerLocationNotify, 0, scenePlayerLocationNotify)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -336,7 +336,7 @@ func (t *TickManager) onTickSecond(now int64) {
|
|||||||
playerRTTInfo := &proto.PlayerRTTInfo{Uid: worldPlayer.PlayerID, Rtt: worldPlayer.ClientRTT}
|
playerRTTInfo := &proto.PlayerRTTInfo{Uid: worldPlayer.PlayerID, Rtt: worldPlayer.ClientRTT}
|
||||||
worldPlayerRTTNotify.PlayerRttList = append(worldPlayerRTTNotify.PlayerRttList, playerRTTInfo)
|
worldPlayerRTTNotify.PlayerRttList = append(worldPlayerRTTNotify.PlayerRttList, playerRTTInfo)
|
||||||
}
|
}
|
||||||
GAME_MANAGER.SendMsg(cmd.WorldPlayerRTTNotify, player.PlayerID, 0, worldPlayerRTTNotify)
|
GAME.SendMsg(cmd.WorldPlayerRTTNotify, player.PlayerID, 0, worldPlayerRTTNotify)
|
||||||
// 玩家安全位置更新
|
// 玩家安全位置更新
|
||||||
switch player.StaminaInfo.State {
|
switch player.StaminaInfo.State {
|
||||||
case proto.MotionState_MOTION_DANGER_RUN, proto.MotionState_MOTION_RUN,
|
case proto.MotionState_MOTION_DANGER_RUN, proto.MotionState_MOTION_RUN,
|
||||||
@@ -360,9 +360,9 @@ func (t *TickManager) onTick200MilliSecond(now int64) {
|
|||||||
for _, world := range WORLD_MANAGER.GetAllWorld() {
|
for _, world := range WORLD_MANAGER.GetAllWorld() {
|
||||||
for _, player := range world.GetAllPlayer() {
|
for _, player := range world.GetAllPlayer() {
|
||||||
// 耐力消耗
|
// 耐力消耗
|
||||||
GAME_MANAGER.SustainStaminaHandler(player)
|
GAME.SustainStaminaHandler(player)
|
||||||
GAME_MANAGER.VehicleRestoreStaminaHandler(player)
|
GAME.VehicleRestoreStaminaHandler(player)
|
||||||
GAME_MANAGER.DrownBackHandler(player)
|
GAME.DrownBackHandler(player)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -374,7 +374,7 @@ func (t *TickManager) onTick50MilliSecond(now int64) {
|
|||||||
// 音乐播放器
|
// 音乐播放器
|
||||||
for i := 0; i < len(AUDIO_CHAN); i++ {
|
for i := 0; i < len(AUDIO_CHAN); i++ {
|
||||||
world := WORLD_MANAGER.GetAiWorld()
|
world := WORLD_MANAGER.GetAiWorld()
|
||||||
GAME_MANAGER.SendToWorldA(world, cmd.SceneAudioNotify, 0, &proto.SceneAudioNotify{
|
GAME.SendToWorldA(world, cmd.SceneAudioNotify, 0, &proto.SceneAudioNotify{
|
||||||
Type: 5,
|
Type: 5,
|
||||||
SourceUid: world.owner.PlayerID,
|
SourceUid: world.owner.PlayerID,
|
||||||
Param1: []uint32{1, <-AUDIO_CHAN},
|
Param1: []uint32{1, <-AUDIO_CHAN},
|
||||||
@@ -265,7 +265,7 @@ func (u *UserManager) autoSyncRemotePlayerMap() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserManager) syncRemotePlayerMap() {
|
func (u *UserManager) syncRemotePlayerMap() {
|
||||||
rsp, err := GAME_MANAGER.discovery.GetGlobalGsOnlineMap(context.TODO(), nil)
|
rsp, err := GAME.discovery.GetGlobalGsOnlineMap(context.TODO(), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("get global gs online map error: %v", err)
|
logger.Error("get global gs online map error: %v", err)
|
||||||
return
|
return
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
package game
|
|
||||||
|
|
||||||
import (
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"hk4e/pkg/logger"
|
|
||||||
"hk4e/protocol/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GCGAi struct {
|
|
||||||
game *GCGGame // 所在的游戏
|
|
||||||
controllerId uint32 // 操控者Id
|
|
||||||
}
|
|
||||||
|
|
||||||
// ReceiveGCGMessagePackNotify 接收GCG消息包通知
|
|
||||||
func (g *GCGAi) ReceiveGCGMessagePackNotify(notify *proto.GCGMessagePackNotify) {
|
|
||||||
// 获取玩家的操控者对象
|
|
||||||
gameController := g.game.controllerMap[g.controllerId]
|
|
||||||
if gameController == nil {
|
|
||||||
logger.Error("ai 角色 nil")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, pack := range notify.MsgPackList {
|
|
||||||
for _, message := range pack.MsgList {
|
|
||||||
switch message.Message.(type) {
|
|
||||||
case *proto.GCGMessage_PhaseChange:
|
|
||||||
// 阶段改变
|
|
||||||
msg := message.GetPhaseChange()
|
|
||||||
switch msg.AfterPhase {
|
|
||||||
case proto.GCGPhaseType_GCG_PHASE_ON_STAGE:
|
|
||||||
logger.Error("请选择你的英雄 hhh")
|
|
||||||
go func() {
|
|
||||||
time.Sleep(3 * 1000)
|
|
||||||
// 默认选第一张牌
|
|
||||||
cardInfo := gameController.cardMap[CardInfoType_Char][0]
|
|
||||||
// 操控者选择角色牌
|
|
||||||
g.game.ControllerSelectChar(gameController, cardInfo, []uint32{})
|
|
||||||
}()
|
|
||||||
case proto.GCGPhaseType_GCG_PHASE_MAIN:
|
|
||||||
if gameController.allow == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
go func() {
|
|
||||||
time.Sleep(3 * 1000)
|
|
||||||
g.game.ControllerUseSkill(gameController, gameController.GetSelectedCharCard().skillList[0].skillId, []uint32{})
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
case *proto.GCGMessage_DiceRoll:
|
|
||||||
// 摇完骰子
|
|
||||||
msg := message.GetDiceRoll()
|
|
||||||
if msg.ControllerId != g.controllerId {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
logger.Error("敌方行动意图")
|
|
||||||
go func() {
|
|
||||||
time.Sleep(3 * 1000)
|
|
||||||
cardInfo1 := g.game.controllerMap[g.controllerId].cardMap[CardInfoType_Char][0]
|
|
||||||
cardInfo2 := g.game.controllerMap[g.controllerId].cardMap[CardInfoType_Char][1]
|
|
||||||
g.game.AddAllMsgPack(0, proto.GCGActionType_GCG_ACTION_NONE, g.game.GCGMsgPVEIntention(&proto.GCGMsgPVEIntention{CardGuid: cardInfo1.guid, SkillIdList: []uint32{cardInfo1.skillList[0].skillId}}, &proto.GCGMsgPVEIntention{CardGuid: cardInfo2.guid, SkillIdList: []uint32{cardInfo2.skillList[0].skillId}}))
|
|
||||||
g.game.SendAllMsgPack()
|
|
||||||
g.game.SetControllerAllow(g.game.controllerMap[g.controllerId], false, true)
|
|
||||||
g.game.AddAllMsgPack(0, proto.GCGActionType_GCG_ACTION_SEND_MESSAGE, g.game.GCGMsgPhaseContinue())
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -182,7 +182,7 @@ func BeginCameraSceneLook(luaState *lua.LState) int {
|
|||||||
}
|
}
|
||||||
ntf := new(proto.BeginCameraSceneLookNotify)
|
ntf := new(proto.BeginCameraSceneLookNotify)
|
||||||
gdconf.ParseLuaTableToObject(cameraLockInfo, ntf)
|
gdconf.ParseLuaTableToObject(cameraLockInfo, ntf)
|
||||||
GAME_MANAGER.SendMsg(cmd.BeginCameraSceneLookNotify, player.PlayerID, player.ClientSeq, ntf)
|
GAME.SendMsg(cmd.BeginCameraSceneLookNotify, player.PlayerID, player.ClientSeq, ntf)
|
||||||
luaState.Push(lua.LNumber(0))
|
luaState.Push(lua.LNumber(0))
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
@@ -237,7 +237,7 @@ func ChangeGroupGadget(luaState *lua.LState) int {
|
|||||||
gadgetStateInfo := new(gdconf.Gadget)
|
gadgetStateInfo := new(gdconf.Gadget)
|
||||||
gdconf.ParseLuaTableToObject(gadgetInfo, gadgetStateInfo)
|
gdconf.ParseLuaTableToObject(gadgetInfo, gadgetStateInfo)
|
||||||
entity := group.GetEntityByConfigId(uint32(gadgetStateInfo.ConfigId))
|
entity := group.GetEntityByConfigId(uint32(gadgetStateInfo.ConfigId))
|
||||||
GAME_MANAGER.ChangeGadgetState(player, entity.GetId(), uint32(gadgetStateInfo.State))
|
GAME.ChangeGadgetState(player, entity.GetId(), uint32(gadgetStateInfo.State))
|
||||||
luaState.Push(lua.LNumber(0))
|
luaState.Push(lua.LNumber(0))
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
@@ -261,7 +261,7 @@ func SetGadgetStateByConfigId(luaState *lua.LState) int {
|
|||||||
configId := luaState.ToInt(2)
|
configId := luaState.ToInt(2)
|
||||||
state := luaState.ToInt(3)
|
state := luaState.ToInt(3)
|
||||||
entity := group.GetEntityByConfigId(uint32(configId))
|
entity := group.GetEntityByConfigId(uint32(configId))
|
||||||
GAME_MANAGER.ChangeGadgetState(player, entity.GetId(), uint32(state))
|
GAME.ChangeGadgetState(player, entity.GetId(), uint32(state))
|
||||||
luaState.Push(lua.LNumber(0))
|
luaState.Push(lua.LNumber(0))
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// SceneRegionTriggerCheck 场景区域触发器检测
|
// SceneRegionTriggerCheck 场景区域触发器检测
|
||||||
func (g *GameManager) SceneRegionTriggerCheck(player *model.Player, scene *Scene, oldPos *model.Vector, newPos *model.Vector, entityId uint32) {
|
func (g *Game) SceneRegionTriggerCheck(player *model.Player, scene *Scene, oldPos *model.Vector, newPos *model.Vector, entityId uint32) {
|
||||||
for groupId, group := range scene.GetAllGroup() {
|
for groupId, group := range scene.GetAllGroup() {
|
||||||
groupConfig := gdconf.GetSceneGroup(int32(groupId))
|
groupConfig := gdconf.GetSceneGroup(int32(groupId))
|
||||||
if groupConfig == nil {
|
if groupConfig == nil {
|
||||||
@@ -116,7 +116,7 @@ func (g *GameManager) SceneRegionTriggerCheck(player *model.Player, scene *Scene
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MonsterDieTriggerCheck 怪物死亡触发器检测
|
// MonsterDieTriggerCheck 怪物死亡触发器检测
|
||||||
func (g *GameManager) MonsterDieTriggerCheck(player *model.Player, groupId uint32, group *Group) {
|
func (g *Game) MonsterDieTriggerCheck(player *model.Player, groupId uint32, group *Group) {
|
||||||
groupConfig := gdconf.GetSceneGroup(int32(groupId))
|
groupConfig := gdconf.GetSceneGroup(int32(groupId))
|
||||||
if groupConfig == nil {
|
if groupConfig == nil {
|
||||||
logger.Error("get group config is nil, groupId: %v, uid: %v", groupId, player.PlayerID)
|
logger.Error("get group config is nil, groupId: %v, uid: %v", groupId, player.PlayerID)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// AvatarUpgradeReq 角色升级请求
|
// AvatarUpgradeReq 角色升级请求
|
||||||
func (g *GameManager) AvatarUpgradeReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) AvatarUpgradeReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.AvatarUpgradeReq)
|
req := payloadMsg.(*proto.AvatarUpgradeReq)
|
||||||
// 是否拥有角色
|
// 是否拥有角色
|
||||||
avatar, ok := player.GameObjectGuidMap[req.AvatarGuid].(*model.Avatar)
|
avatar, ok := player.GameObjectGuidMap[req.AvatarGuid].(*model.Avatar)
|
||||||
@@ -97,7 +97,7 @@ func (g *GameManager) AvatarUpgradeReq(player *model.Player, payloadMsg pb.Messa
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AvatarPromoteReq 角色突破请求
|
// AvatarPromoteReq 角色突破请求
|
||||||
func (g *GameManager) AvatarPromoteReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) AvatarPromoteReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.AvatarPromoteReq)
|
req := payloadMsg.(*proto.AvatarPromoteReq)
|
||||||
// 是否拥有角色
|
// 是否拥有角色
|
||||||
avatar, ok := player.GameObjectGuidMap[req.Guid].(*model.Avatar)
|
avatar, ok := player.GameObjectGuidMap[req.Guid].(*model.Avatar)
|
||||||
@@ -187,7 +187,7 @@ func (g *GameManager) AvatarPromoteReq(player *model.Player, payloadMsg pb.Messa
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AvatarPromoteGetRewardReq 角色突破获取奖励请求
|
// AvatarPromoteGetRewardReq 角色突破获取奖励请求
|
||||||
func (g *GameManager) AvatarPromoteGetRewardReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) AvatarPromoteGetRewardReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.AvatarPromoteGetRewardReq)
|
req := payloadMsg.(*proto.AvatarPromoteGetRewardReq)
|
||||||
// 是否拥有角色
|
// 是否拥有角色
|
||||||
avatar, ok := player.GameObjectGuidMap[req.AvatarGuid].(*model.Avatar)
|
avatar, ok := player.GameObjectGuidMap[req.AvatarGuid].(*model.Avatar)
|
||||||
@@ -237,7 +237,7 @@ func (g *GameManager) AvatarPromoteGetRewardReq(player *model.Player, payloadMsg
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AvatarWearFlycloakReq 角色装备风之翼请求
|
// AvatarWearFlycloakReq 角色装备风之翼请求
|
||||||
func (g *GameManager) AvatarWearFlycloakReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) AvatarWearFlycloakReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.AvatarWearFlycloakReq)
|
req := payloadMsg.(*proto.AvatarWearFlycloakReq)
|
||||||
|
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
@@ -288,7 +288,7 @@ func (g *GameManager) AvatarWearFlycloakReq(player *model.Player, payloadMsg pb.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AvatarChangeCostumeReq 角色更换时装请求
|
// AvatarChangeCostumeReq 角色更换时装请求
|
||||||
func (g *GameManager) AvatarChangeCostumeReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) AvatarChangeCostumeReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.AvatarChangeCostumeReq)
|
req := payloadMsg.(*proto.AvatarChangeCostumeReq)
|
||||||
|
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
@@ -349,7 +349,7 @@ func (g *GameManager) AvatarChangeCostumeReq(player *model.Player, payloadMsg pb
|
|||||||
g.SendMsg(cmd.AvatarChangeCostumeRsp, player.PlayerID, player.ClientSeq, avatarChangeCostumeRsp)
|
g.SendMsg(cmd.AvatarChangeCostumeRsp, player.PlayerID, player.ClientSeq, avatarChangeCostumeRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PacketAvatarInfo(avatar *model.Avatar) *proto.AvatarInfo {
|
func (g *Game) PacketAvatarInfo(avatar *model.Avatar) *proto.AvatarInfo {
|
||||||
isFocus := false
|
isFocus := false
|
||||||
if avatar.AvatarId == 10000005 || avatar.AvatarId == 10000007 {
|
if avatar.AvatarId == 10000005 || avatar.AvatarId == 10000007 {
|
||||||
isFocus = true
|
isFocus = true
|
||||||
@@ -425,7 +425,7 @@ func (g *GameManager) PacketAvatarInfo(avatar *model.Avatar) *proto.AvatarInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PacketAvatarPropNotify 角色属性表更新通知
|
// PacketAvatarPropNotify 角色属性表更新通知
|
||||||
func (g *GameManager) PacketAvatarPropNotify(avatar *model.Avatar) *proto.AvatarPropNotify {
|
func (g *Game) PacketAvatarPropNotify(avatar *model.Avatar) *proto.AvatarPropNotify {
|
||||||
avatarPropNotify := &proto.AvatarPropNotify{
|
avatarPropNotify := &proto.AvatarPropNotify{
|
||||||
PropMap: make(map[uint32]int64, 5),
|
PropMap: make(map[uint32]int64, 5),
|
||||||
AvatarGuid: avatar.Guid,
|
AvatarGuid: avatar.Guid,
|
||||||
@@ -444,7 +444,7 @@ func (g *GameManager) PacketAvatarPropNotify(avatar *model.Avatar) *proto.Avatar
|
|||||||
return avatarPropNotify
|
return avatarPropNotify
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) GetAllAvatarDataConfig() map[int32]*gdconf.AvatarData {
|
func (g *Game) GetAllAvatarDataConfig() map[int32]*gdconf.AvatarData {
|
||||||
allAvatarDataConfig := make(map[int32]*gdconf.AvatarData)
|
allAvatarDataConfig := make(map[int32]*gdconf.AvatarData)
|
||||||
for avatarId, avatarData := range gdconf.GetAvatarDataMap() {
|
for avatarId, avatarData := range gdconf.GetAvatarDataMap() {
|
||||||
if avatarId <= 10000001 || avatarId >= 11000000 {
|
if avatarId <= 10000001 || avatarId >= 11000000 {
|
||||||
@@ -460,7 +460,7 @@ func (g *GameManager) GetAllAvatarDataConfig() map[int32]*gdconf.AvatarData {
|
|||||||
return allAvatarDataConfig
|
return allAvatarDataConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) AddUserAvatar(userId uint32, avatarId uint32) {
|
func (g *Game) AddUserAvatar(userId uint32, avatarId uint32) {
|
||||||
player := USER_MANAGER.GetOnlineUser(userId)
|
player := USER_MANAGER.GetOnlineUser(userId)
|
||||||
if player == nil {
|
if player == nil {
|
||||||
logger.Error("player is nil, uid: %v", userId)
|
logger.Error("player is nil, uid: %v", userId)
|
||||||
@@ -496,7 +496,7 @@ func (g *GameManager) AddUserAvatar(userId uint32, avatarId uint32) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AddUserFlycloak 给予玩家风之翼
|
// AddUserFlycloak 给予玩家风之翼
|
||||||
func (g *GameManager) AddUserFlycloak(userId uint32, flyCloakId uint32) {
|
func (g *Game) AddUserFlycloak(userId uint32, flyCloakId uint32) {
|
||||||
player := USER_MANAGER.GetOnlineUser(userId)
|
player := USER_MANAGER.GetOnlineUser(userId)
|
||||||
if player == nil {
|
if player == nil {
|
||||||
logger.Error("player is nil, uid: %v", userId)
|
logger.Error("player is nil, uid: %v", userId)
|
||||||
@@ -518,7 +518,7 @@ func (g *GameManager) AddUserFlycloak(userId uint32, flyCloakId uint32) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AddUserCostume 给予玩家时装
|
// AddUserCostume 给予玩家时装
|
||||||
func (g *GameManager) AddUserCostume(userId uint32, costumeId uint32) {
|
func (g *Game) AddUserCostume(userId uint32, costumeId uint32) {
|
||||||
player := USER_MANAGER.GetOnlineUser(userId)
|
player := USER_MANAGER.GetOnlineUser(userId)
|
||||||
if player == nil {
|
if player == nil {
|
||||||
logger.Error("player is nil, uid: %v", userId)
|
logger.Error("player is nil, uid: %v", userId)
|
||||||
@@ -540,7 +540,7 @@ func (g *GameManager) AddUserCostume(userId uint32, costumeId uint32) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpgradePlayerAvatar 玩家角色升级
|
// UpgradePlayerAvatar 玩家角色升级
|
||||||
func (g *GameManager) UpgradePlayerAvatar(player *model.Player, avatar *model.Avatar, expCount uint32) {
|
func (g *Game) UpgradePlayerAvatar(player *model.Player, avatar *model.Avatar, expCount uint32) {
|
||||||
// 获取角色配置表
|
// 获取角色配置表
|
||||||
avatarDataConfig := gdconf.GetAvatarDataById(int32(avatar.AvatarId))
|
avatarDataConfig := gdconf.GetAvatarDataById(int32(avatar.AvatarId))
|
||||||
if avatarDataConfig == nil {
|
if avatarDataConfig == nil {
|
||||||
@@ -583,7 +583,7 @@ func (g *GameManager) UpgradePlayerAvatar(player *model.Player, avatar *model.Av
|
|||||||
g.SendMsg(cmd.AvatarPropNotify, player.PlayerID, player.ClientSeq, g.PacketAvatarPropNotify(avatar))
|
g.SendMsg(cmd.AvatarPropNotify, player.PlayerID, player.ClientSeq, g.PacketAvatarPropNotify(avatar))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) UpdateUserAvatarFightProp(userId uint32, avatarId uint32) {
|
func (g *Game) UpdateUserAvatarFightProp(userId uint32, avatarId uint32) {
|
||||||
player := USER_MANAGER.GetOnlineUser(userId)
|
player := USER_MANAGER.GetOnlineUser(userId)
|
||||||
if player == nil {
|
if player == nil {
|
||||||
logger.Error("player is nil, uid: %v", userId)
|
logger.Error("player is nil, uid: %v", userId)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// HandlePlayerExpAdd 玩家冒险阅历增加处理
|
// HandlePlayerExpAdd 玩家冒险阅历增加处理
|
||||||
func (g *GameManager) HandlePlayerExpAdd(userId uint32) {
|
func (g *Game) HandlePlayerExpAdd(userId uint32) {
|
||||||
player := USER_MANAGER.GetOnlineUser(userId)
|
player := USER_MANAGER.GetOnlineUser(userId)
|
||||||
if player == nil {
|
if player == nil {
|
||||||
logger.Error("player is nil, uid: %v", userId)
|
logger.Error("player is nil, uid: %v", userId)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const (
|
|||||||
MaxMsgListLen = 100 // 与某人的最大聊天记录条数
|
MaxMsgListLen = 100 // 与某人的最大聊天记录条数
|
||||||
)
|
)
|
||||||
|
|
||||||
func (g *GameManager) PullRecentChatReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) PullRecentChatReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.PullRecentChatReq)
|
req := payloadMsg.(*proto.PullRecentChatReq)
|
||||||
// 经研究发现 原神现网环境 客户端仅拉取最新的5条未读聊天消息 所以人太多的话小姐姐不回你消息是有原因的
|
// 经研究发现 原神现网环境 客户端仅拉取最新的5条未读聊天消息 所以人太多的话小姐姐不回你消息是有原因的
|
||||||
// 因此 阿米你这样做真的合适吗 不过现在代码到了我手上我想怎么写就怎么写 我才不会重蹈覆辙
|
// 因此 阿米你这样做真的合适吗 不过现在代码到了我手上我想怎么写就怎么写 我才不会重蹈覆辙
|
||||||
@@ -55,7 +55,7 @@ func (g *GameManager) PullRecentChatReq(player *model.Player, payloadMsg pb.Mess
|
|||||||
g.SendMsg(cmd.PullRecentChatRsp, player.PlayerID, player.ClientSeq, pullRecentChatRsp)
|
g.SendMsg(cmd.PullRecentChatRsp, player.PlayerID, player.ClientSeq, pullRecentChatRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PullPrivateChatReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) PullPrivateChatReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.PullPrivateChatReq)
|
req := payloadMsg.(*proto.PullPrivateChatReq)
|
||||||
targetUid := req.TargetUid
|
targetUid := req.TargetUid
|
||||||
pullNum := req.PullNum
|
pullNum := req.PullNum
|
||||||
@@ -81,7 +81,7 @@ func (g *GameManager) PullPrivateChatReq(player *model.Player, payloadMsg pb.Mes
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SendPrivateChat 发送私聊文本消息给玩家
|
// SendPrivateChat 发送私聊文本消息给玩家
|
||||||
func (g *GameManager) SendPrivateChat(player *model.Player, targetUid uint32, content any) {
|
func (g *Game) SendPrivateChat(player *model.Player, targetUid uint32, content any) {
|
||||||
chatMsg := &model.ChatMsg{
|
chatMsg := &model.ChatMsg{
|
||||||
Sequence: 0,
|
Sequence: 0,
|
||||||
Time: uint32(time.Now().Unix()),
|
Time: uint32(time.Now().Unix()),
|
||||||
@@ -170,7 +170,7 @@ func (g *GameManager) SendPrivateChat(player *model.Player, targetUid uint32, co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PrivateChatReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) PrivateChatReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.PrivateChatReq)
|
req := payloadMsg.(*proto.PrivateChatReq)
|
||||||
targetUid := req.TargetUid
|
targetUid := req.TargetUid
|
||||||
content := req.Content
|
content := req.Content
|
||||||
@@ -198,7 +198,7 @@ func (g *GameManager) PrivateChatReq(player *model.Player, payloadMsg pb.Message
|
|||||||
g.SendMsg(cmd.PrivateChatRsp, player.PlayerID, player.ClientSeq, new(proto.PrivateChatRsp))
|
g.SendMsg(cmd.PrivateChatRsp, player.PlayerID, player.ClientSeq, new(proto.PrivateChatRsp))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) ReadPrivateChatReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) ReadPrivateChatReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.ReadPrivateChatReq)
|
req := payloadMsg.(*proto.ReadPrivateChatReq)
|
||||||
targetUid := req.TargetUid
|
targetUid := req.TargetUid
|
||||||
|
|
||||||
@@ -218,7 +218,7 @@ func (g *GameManager) ReadPrivateChatReq(player *model.Player, payloadMsg pb.Mes
|
|||||||
g.SendMsg(cmd.ReadPrivateChatRsp, player.PlayerID, player.ClientSeq, new(proto.ReadPrivateChatRsp))
|
g.SendMsg(cmd.ReadPrivateChatRsp, player.PlayerID, player.ClientSeq, new(proto.ReadPrivateChatRsp))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PlayerChatReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) PlayerChatReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.PlayerChatReq)
|
req := payloadMsg.(*proto.PlayerChatReq)
|
||||||
channelId := req.ChannelId
|
channelId := req.ChannelId
|
||||||
chatInfo := req.ChatInfo
|
chatInfo := req.ChatInfo
|
||||||
@@ -260,7 +260,7 @@ func (g *GameManager) PlayerChatReq(player *model.Player, payloadMsg pb.Message)
|
|||||||
g.SendMsg(cmd.PlayerChatRsp, player.PlayerID, player.ClientSeq, new(proto.PlayerChatRsp))
|
g.SendMsg(cmd.PlayerChatRsp, player.PlayerID, player.ClientSeq, new(proto.PlayerChatRsp))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) ConvChatInfoToChatMsg(chatInfo *proto.ChatInfo) (chatMsg *model.ChatMsg) {
|
func (g *Game) ConvChatInfoToChatMsg(chatInfo *proto.ChatInfo) (chatMsg *model.ChatMsg) {
|
||||||
chatMsg = &model.ChatMsg{
|
chatMsg = &model.ChatMsg{
|
||||||
Sequence: chatInfo.Sequence,
|
Sequence: chatInfo.Sequence,
|
||||||
Time: chatInfo.Time,
|
Time: chatInfo.Time,
|
||||||
@@ -283,7 +283,7 @@ func (g *GameManager) ConvChatInfoToChatMsg(chatInfo *proto.ChatInfo) (chatMsg *
|
|||||||
return chatMsg
|
return chatMsg
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) ConvChatMsgToChatInfo(chatMsg *model.ChatMsg) (chatInfo *proto.ChatInfo) {
|
func (g *Game) ConvChatMsgToChatInfo(chatMsg *model.ChatMsg) (chatInfo *proto.ChatInfo) {
|
||||||
chatInfo = &proto.ChatInfo{
|
chatInfo = &proto.ChatInfo{
|
||||||
Time: chatMsg.Time,
|
Time: chatMsg.Time,
|
||||||
Sequence: chatMsg.Sequence,
|
Sequence: chatMsg.Sequence,
|
||||||
@@ -308,7 +308,7 @@ func (g *GameManager) ConvChatMsgToChatInfo(chatMsg *model.ChatMsg) (chatInfo *p
|
|||||||
|
|
||||||
// 跨服玩家聊天通知
|
// 跨服玩家聊天通知
|
||||||
|
|
||||||
func (g *GameManager) ServerChatMsgNotify(chatMsgInfo *mq.ChatMsgInfo) {
|
func (g *Game) ServerChatMsgNotify(chatMsgInfo *mq.ChatMsgInfo) {
|
||||||
targetPlayer := USER_MANAGER.GetOnlineUser(chatMsgInfo.ToUid)
|
targetPlayer := USER_MANAGER.GetOnlineUser(chatMsgInfo.ToUid)
|
||||||
if targetPlayer == nil {
|
if targetPlayer == nil {
|
||||||
logger.Error("player is nil, uid: %v", chatMsgInfo.ToUid)
|
logger.Error("player is nil, uid: %v", chatMsgInfo.ToUid)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package game
|
package game
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"math"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"hk4e/gate/kcp"
|
"hk4e/gate/kcp"
|
||||||
@@ -12,15 +13,14 @@ import (
|
|||||||
pb "google.golang.org/protobuf/proto"
|
pb "google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (g *GameManager) PlayerSetPauseReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) PlayerSetPauseReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.PlayerSetPauseReq)
|
req := payloadMsg.(*proto.PlayerSetPauseReq)
|
||||||
isPaused := req.IsPaused
|
isPaused := req.IsPaused
|
||||||
player.Pause = isPaused
|
player.Pause = isPaused
|
||||||
|
|
||||||
g.SendMsg(cmd.PlayerSetPauseRsp, player.PlayerID, player.ClientSeq, new(proto.PlayerSetPauseRsp))
|
g.SendMsg(cmd.PlayerSetPauseRsp, player.PlayerID, player.ClientSeq, new(proto.PlayerSetPauseRsp))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) TowerAllDataReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) TowerAllDataReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
towerAllDataRsp := &proto.TowerAllDataRsp{
|
towerAllDataRsp := &proto.TowerAllDataRsp{
|
||||||
TowerScheduleId: 29,
|
TowerScheduleId: 29,
|
||||||
TowerFloorRecordList: []*proto.TowerFloorRecord{{FloorId: 1001}},
|
TowerFloorRecordList: []*proto.TowerFloorRecord{{FloorId: 1001}},
|
||||||
@@ -37,34 +37,7 @@ func (g *GameManager) TowerAllDataReq(player *model.Player, payloadMsg pb.Messag
|
|||||||
g.SendMsg(cmd.TowerAllDataRsp, player.PlayerID, player.ClientSeq, towerAllDataRsp)
|
g.SendMsg(cmd.TowerAllDataRsp, player.PlayerID, player.ClientSeq, towerAllDataRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) QueryPathReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) ClientRttNotify(userId uint32, clientRtt uint32) {
|
||||||
req := payloadMsg.(*proto.QueryPathReq)
|
|
||||||
|
|
||||||
queryPathRsp := &proto.QueryPathRsp{
|
|
||||||
QueryId: req.QueryId,
|
|
||||||
QueryStatus: proto.QueryPathRsp_STATUS_SUCC,
|
|
||||||
Corners: []*proto.Vector{req.DestinationPos[0]},
|
|
||||||
}
|
|
||||||
g.SendMsg(cmd.QueryPathRsp, player.PlayerID, player.ClientSeq, queryPathRsp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *GameManager) EntityAiSyncNotify(player *model.Player, payloadMsg pb.Message) {
|
|
||||||
req := payloadMsg.(*proto.EntityAiSyncNotify)
|
|
||||||
|
|
||||||
entityAiSyncNotify := &proto.EntityAiSyncNotify{
|
|
||||||
InfoList: make([]*proto.AiSyncInfo, 0),
|
|
||||||
}
|
|
||||||
for _, monsterId := range req.LocalAvatarAlertedMonsterList {
|
|
||||||
entityAiSyncNotify.InfoList = append(entityAiSyncNotify.InfoList, &proto.AiSyncInfo{
|
|
||||||
EntityId: monsterId,
|
|
||||||
HasPathToTarget: true,
|
|
||||||
IsSelfKilling: false,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
g.SendMsg(cmd.EntityAiSyncNotify, player.PlayerID, player.ClientSeq, entityAiSyncNotify)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *GameManager) ClientRttNotify(userId uint32, clientRtt uint32) {
|
|
||||||
player := USER_MANAGER.GetOnlineUser(userId)
|
player := USER_MANAGER.GetOnlineUser(userId)
|
||||||
if player == nil {
|
if player == nil {
|
||||||
logger.Error("player is nil, uid: %v", userId)
|
logger.Error("player is nil, uid: %v", userId)
|
||||||
@@ -74,23 +47,23 @@ func (g *GameManager) ClientRttNotify(userId uint32, clientRtt uint32) {
|
|||||||
player.ClientRTT = clientRtt
|
player.ClientRTT = clientRtt
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) ClientTimeNotify(userId uint32, clientTime uint32) {
|
func (g *Game) ClientTimeNotify(userId uint32, clientTime uint32) {
|
||||||
player := USER_MANAGER.GetOnlineUser(userId)
|
player := USER_MANAGER.GetOnlineUser(userId)
|
||||||
if player == nil {
|
if player == nil {
|
||||||
logger.Error("player is nil, uid: %v", userId)
|
logger.Error("player is nil, uid: %v", userId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
player.ClientTime = clientTime
|
player.ClientTime = clientTime
|
||||||
now := time.Now().Unix()
|
now := uint32(time.Now().Unix())
|
||||||
// 客户端与服务器时间相差太过严重
|
// 客户端与服务器时间相差太过严重
|
||||||
if now-int64(player.ClientTime) > 60 || int64(player.ClientTime)-now > 60 {
|
if math.Abs(float64(now-player.ClientTime)) > 60.0 {
|
||||||
g.KickPlayer(player.PlayerID, kcp.EnetServerKick)
|
g.KickPlayer(player.PlayerID, kcp.EnetServerKick)
|
||||||
logger.Error("abs of client time and server time above 60, uid: %v", userId)
|
logger.Error("abs of client time and server time above 60s, uid: %v", userId)
|
||||||
}
|
}
|
||||||
player.LastKeepaliveTime = uint32(now)
|
player.LastKeepaliveTime = now
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) ServerAnnounceNotify(announceId uint32, announceMsg string) {
|
func (g *Game) ServerAnnounceNotify(announceId uint32, announceMsg string) {
|
||||||
for _, onlinePlayer := range USER_MANAGER.GetAllOnlineUserList() {
|
for _, onlinePlayer := range USER_MANAGER.GetAllOnlineUserList() {
|
||||||
now := uint32(time.Now().Unix())
|
now := uint32(time.Now().Unix())
|
||||||
serverAnnounceNotify := &proto.ServerAnnounceNotify{
|
serverAnnounceNotify := &proto.ServerAnnounceNotify{
|
||||||
@@ -106,7 +79,7 @@ func (g *GameManager) ServerAnnounceNotify(announceId uint32, announceMsg string
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) ServerAnnounceRevokeNotify(announceId uint32) {
|
func (g *Game) ServerAnnounceRevokeNotify(announceId uint32) {
|
||||||
for _, onlinePlayer := range USER_MANAGER.GetAllOnlineUserList() {
|
for _, onlinePlayer := range USER_MANAGER.GetAllOnlineUserList() {
|
||||||
serverAnnounceRevokeNotify := &proto.ServerAnnounceRevokeNotify{
|
serverAnnounceRevokeNotify := &proto.ServerAnnounceRevokeNotify{
|
||||||
ConfigIdList: []uint32{announceId},
|
ConfigIdList: []uint32{announceId},
|
||||||
@@ -115,27 +88,37 @@ func (g *GameManager) ServerAnnounceRevokeNotify(announceId uint32) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) ToTheMoonEnterSceneReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) ToTheMoonEnterSceneReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
logger.Debug("player ttm enter scene, uid: %v", player.PlayerID)
|
logger.Debug("player ttm enter scene, uid: %v", player.PlayerID)
|
||||||
req := payloadMsg.(*proto.ToTheMoonEnterSceneReq)
|
req := payloadMsg.(*proto.ToTheMoonEnterSceneReq)
|
||||||
_ = req
|
_ = req
|
||||||
g.SendMsg(cmd.ToTheMoonEnterSceneRsp, player.PlayerID, player.ClientSeq, new(proto.ToTheMoonEnterSceneRsp))
|
g.SendMsg(cmd.ToTheMoonEnterSceneRsp, player.PlayerID, player.ClientSeq, new(proto.ToTheMoonEnterSceneRsp))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PathfindingEnterSceneReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) PathfindingEnterSceneReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
logger.Debug("player pf enter scene, uid: %v", player.PlayerID)
|
logger.Debug("player pf enter scene, uid: %v", player.PlayerID)
|
||||||
req := payloadMsg.(*proto.PathfindingEnterSceneReq)
|
req := payloadMsg.(*proto.PathfindingEnterSceneReq)
|
||||||
_ = req
|
_ = req
|
||||||
g.SendMsg(cmd.PathfindingEnterSceneRsp, player.PlayerID, player.ClientSeq, new(proto.PathfindingEnterSceneRsp))
|
g.SendMsg(cmd.PathfindingEnterSceneRsp, player.PlayerID, player.ClientSeq, new(proto.PathfindingEnterSceneRsp))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) SetEntityClientDataNotify(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) QueryPathReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
logger.Debug("user set entity client data, uid: %v", player.PlayerID)
|
req := payloadMsg.(*proto.QueryPathReq)
|
||||||
ntf := payloadMsg.(*proto.SetEntityClientDataNotify)
|
queryPathRsp := &proto.QueryPathRsp{
|
||||||
g.SendMsg(cmd.SetEntityClientDataNotify, player.PlayerID, player.ClientSeq, ntf)
|
QueryId: req.QueryId,
|
||||||
|
QueryStatus: proto.QueryPathRsp_STATUS_SUCC,
|
||||||
|
Corners: []*proto.Vector{req.DestinationPos[0]},
|
||||||
|
}
|
||||||
|
g.SendMsg(cmd.QueryPathRsp, player.PlayerID, player.ClientSeq, queryPathRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) ServerAppidBindNotify(userId uint32, anticheatAppId string, joinHostUserId uint32) {
|
func (g *Game) ObstacleModifyNotify(player *model.Player, payloadMsg pb.Message) {
|
||||||
|
ntf := payloadMsg.(*proto.ObstacleModifyNotify)
|
||||||
|
_ = ntf
|
||||||
|
// logger.Debug("ObstacleModifyNotify: %v, uid: %v", ntf, player.PlayerID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Game) ServerAppidBindNotify(userId uint32, anticheatAppId string, joinHostUserId uint32) {
|
||||||
player := USER_MANAGER.GetOnlineUser(userId)
|
player := USER_MANAGER.GetOnlineUser(userId)
|
||||||
if player == nil {
|
if player == nil {
|
||||||
logger.Error("player is nil, uid: %v", userId)
|
logger.Error("player is nil, uid: %v", userId)
|
||||||
@@ -161,9 +144,3 @@ func (g *GameManager) ServerAppidBindNotify(userId uint32, anticheatAppId string
|
|||||||
player.SceneLoadState = model.SceneNone
|
player.SceneLoadState = model.SceneNone
|
||||||
g.SendMsg(cmd.PlayerEnterSceneNotify, userId, player.ClientSeq, g.PacketPlayerEnterSceneNotifyLogin(player, proto.EnterType_ENTER_SELF))
|
g.SendMsg(cmd.PlayerEnterSceneNotify, userId, player.ClientSeq, g.PacketPlayerEnterSceneNotifyLogin(player, proto.EnterType_ENTER_SELF))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) ObstacleModifyNotify(player *model.Player, payloadMsg pb.Message) {
|
|
||||||
ntf := payloadMsg.(*proto.ObstacleModifyNotify)
|
|
||||||
_ = ntf
|
|
||||||
// logger.Debug("ObstacleModifyNotify: %v, uid: %v", ntf, player.PlayerID)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// SetEquipLockStateReq 设置装备上锁状态请求
|
// SetEquipLockStateReq 设置装备上锁状态请求
|
||||||
func (g *GameManager) SetEquipLockStateReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) SetEquipLockStateReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.SetEquipLockStateReq)
|
req := payloadMsg.(*proto.SetEquipLockStateReq)
|
||||||
|
|
||||||
// 获取目标装备
|
// 获取目标装备
|
||||||
@@ -47,7 +47,7 @@ func (g *GameManager) SetEquipLockStateReq(player *model.Player, payloadMsg pb.M
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TakeoffEquipReq 装备卸下请求
|
// TakeoffEquipReq 装备卸下请求
|
||||||
func (g *GameManager) TakeoffEquipReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) TakeoffEquipReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.TakeoffEquipReq)
|
req := payloadMsg.(*proto.TakeoffEquipReq)
|
||||||
|
|
||||||
// 获取目标角色
|
// 获取目标角色
|
||||||
@@ -81,7 +81,7 @@ func (g *GameManager) TakeoffEquipReq(player *model.Player, payloadMsg pb.Messag
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WearEquipReq 穿戴装备请求
|
// WearEquipReq 穿戴装备请求
|
||||||
func (g *GameManager) WearEquipReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) WearEquipReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.WearEquipReq)
|
req := payloadMsg.(*proto.WearEquipReq)
|
||||||
|
|
||||||
// 获取目标角色
|
// 获取目标角色
|
||||||
@@ -139,7 +139,7 @@ func (g *GameManager) WearEquipReq(player *model.Player, payloadMsg pb.Message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WearUserAvatarReliquary 玩家角色装备圣遗物
|
// WearUserAvatarReliquary 玩家角色装备圣遗物
|
||||||
func (g *GameManager) WearUserAvatarReliquary(userId uint32, avatarId uint32, reliquaryId uint64) {
|
func (g *Game) WearUserAvatarReliquary(userId uint32, avatarId uint32, reliquaryId uint64) {
|
||||||
player := USER_MANAGER.GetOnlineUser(userId)
|
player := USER_MANAGER.GetOnlineUser(userId)
|
||||||
if player == nil {
|
if player == nil {
|
||||||
logger.Error("player is nil, uid: %v", userId)
|
logger.Error("player is nil, uid: %v", userId)
|
||||||
@@ -198,7 +198,7 @@ func (g *GameManager) WearUserAvatarReliquary(userId uint32, avatarId uint32, re
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WearUserAvatarWeapon 玩家角色装备武器
|
// WearUserAvatarWeapon 玩家角色装备武器
|
||||||
func (g *GameManager) WearUserAvatarWeapon(userId uint32, avatarId uint32, weaponId uint64) {
|
func (g *Game) WearUserAvatarWeapon(userId uint32, avatarId uint32, weaponId uint64) {
|
||||||
player := USER_MANAGER.GetOnlineUser(userId)
|
player := USER_MANAGER.GetOnlineUser(userId)
|
||||||
if player == nil {
|
if player == nil {
|
||||||
logger.Error("player is nil, uid: %v", userId)
|
logger.Error("player is nil, uid: %v", userId)
|
||||||
@@ -266,7 +266,7 @@ func (g *GameManager) WearUserAvatarWeapon(userId uint32, avatarId uint32, weapo
|
|||||||
g.SendMsg(cmd.AvatarEquipChangeNotify, userId, player.ClientSeq, avatarEquipChangeNotify)
|
g.SendMsg(cmd.AvatarEquipChangeNotify, userId, player.ClientSeq, avatarEquipChangeNotify)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PacketAvatarEquipChangeNotifyByReliquary(avatar *model.Avatar, slot uint8) *proto.AvatarEquipChangeNotify {
|
func (g *Game) PacketAvatarEquipChangeNotifyByReliquary(avatar *model.Avatar, slot uint8) *proto.AvatarEquipChangeNotify {
|
||||||
// 获取角色对应位置的圣遗物
|
// 获取角色对应位置的圣遗物
|
||||||
reliquary, ok := avatar.EquipReliquaryMap[slot]
|
reliquary, ok := avatar.EquipReliquaryMap[slot]
|
||||||
if !ok {
|
if !ok {
|
||||||
@@ -297,7 +297,7 @@ func (g *GameManager) PacketAvatarEquipChangeNotifyByReliquary(avatar *model.Ava
|
|||||||
return avatarEquipChangeNotify
|
return avatarEquipChangeNotify
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PacketAvatarEquipChangeNotifyByWeapon(avatar *model.Avatar, weapon *model.Weapon, entityId uint32) *proto.AvatarEquipChangeNotify {
|
func (g *Game) PacketAvatarEquipChangeNotifyByWeapon(avatar *model.Avatar, weapon *model.Weapon, entityId uint32) *proto.AvatarEquipChangeNotify {
|
||||||
weaponConfig := gdconf.GetItemDataById(int32(weapon.ItemId))
|
weaponConfig := gdconf.GetItemDataById(int32(weapon.ItemId))
|
||||||
if weaponConfig == nil {
|
if weaponConfig == nil {
|
||||||
logger.Error("weapon config error, itemId: %v", weapon.ItemId)
|
logger.Error("weapon config error, itemId: %v", weapon.ItemId)
|
||||||
|
|||||||
@@ -33,19 +33,19 @@ func DoForward[IET model.InvokeEntryType](player *model.Player, invokeHandler *m
|
|||||||
}
|
}
|
||||||
if invokeHandler.AllLen() > 0 {
|
if invokeHandler.AllLen() > 0 {
|
||||||
reflection.SetStructFieldValue(newNtf, forwardField, invokeHandler.EntryListForwardAll)
|
reflection.SetStructFieldValue(newNtf, forwardField, invokeHandler.EntryListForwardAll)
|
||||||
GAME_MANAGER.SendToWorldA(world, cmdId, player.ClientSeq, newNtf)
|
GAME.SendToWorldA(world, cmdId, player.ClientSeq, newNtf)
|
||||||
}
|
}
|
||||||
if invokeHandler.AllExceptCurLen() > 0 {
|
if invokeHandler.AllExceptCurLen() > 0 {
|
||||||
reflection.SetStructFieldValue(newNtf, forwardField, invokeHandler.EntryListForwardAllExceptCur)
|
reflection.SetStructFieldValue(newNtf, forwardField, invokeHandler.EntryListForwardAllExceptCur)
|
||||||
GAME_MANAGER.SendToWorldAEC(world, cmdId, player.ClientSeq, newNtf, player.PlayerID)
|
GAME.SendToWorldAEC(world, cmdId, player.ClientSeq, newNtf, player.PlayerID)
|
||||||
}
|
}
|
||||||
if invokeHandler.HostLen() > 0 {
|
if invokeHandler.HostLen() > 0 {
|
||||||
reflection.SetStructFieldValue(newNtf, forwardField, invokeHandler.EntryListForwardHost)
|
reflection.SetStructFieldValue(newNtf, forwardField, invokeHandler.EntryListForwardHost)
|
||||||
GAME_MANAGER.SendToWorldH(world, cmdId, player.ClientSeq, newNtf)
|
GAME.SendToWorldH(world, cmdId, player.ClientSeq, newNtf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) UnionCmdNotify(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) UnionCmdNotify(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.UnionCmdNotify)
|
req := payloadMsg.(*proto.UnionCmdNotify)
|
||||||
_ = req
|
_ = req
|
||||||
if player.SceneLoadState != model.SceneEnterDone {
|
if player.SceneLoadState != model.SceneEnterDone {
|
||||||
@@ -61,7 +61,7 @@ func (g *GameManager) UnionCmdNotify(player *model.Player, payloadMsg pb.Message
|
|||||||
player.AbilityInvokeHandler.Clear()
|
player.AbilityInvokeHandler.Clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) MassiveEntityElementOpBatchNotify(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) MassiveEntityElementOpBatchNotify(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.MassiveEntityElementOpBatchNotify)
|
req := payloadMsg.(*proto.MassiveEntityElementOpBatchNotify)
|
||||||
if player.SceneLoadState != model.SceneEnterDone {
|
if player.SceneLoadState != model.SceneEnterDone {
|
||||||
return
|
return
|
||||||
@@ -80,7 +80,7 @@ func (g *GameManager) MassiveEntityElementOpBatchNotify(player *model.Player, pa
|
|||||||
g.SendToWorldA(world, cmd.MassiveEntityElementOpBatchNotify, player.ClientSeq, req)
|
g.SendToWorldA(world, cmd.MassiveEntityElementOpBatchNotify, player.ClientSeq, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) CombatInvocationsNotify(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) CombatInvocationsNotify(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.CombatInvocationsNotify)
|
req := payloadMsg.(*proto.CombatInvocationsNotify)
|
||||||
if player.SceneLoadState != model.SceneEnterDone {
|
if player.SceneLoadState != model.SceneEnterDone {
|
||||||
return
|
return
|
||||||
@@ -232,7 +232,7 @@ func (g *GameManager) CombatInvocationsNotify(player *model.Player, payloadMsg p
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) AoiPlayerMove(player *model.Player, oldPos *model.Vector, newPos *model.Vector) {
|
func (g *Game) AoiPlayerMove(player *model.Player, oldPos *model.Vector, newPos *model.Vector) {
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
if world == nil {
|
if world == nil {
|
||||||
logger.Error("get player world is nil, uid: %v", player.PlayerID)
|
logger.Error("get player world is nil, uid: %v", player.PlayerID)
|
||||||
@@ -303,7 +303,7 @@ func (g *GameManager) AoiPlayerMove(player *model.Player, oldPos *model.Vector,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) AbilityInvocationsNotify(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) AbilityInvocationsNotify(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.AbilityInvocationsNotify)
|
req := payloadMsg.(*proto.AbilityInvocationsNotify)
|
||||||
if player.SceneLoadState != model.SceneEnterDone {
|
if player.SceneLoadState != model.SceneEnterDone {
|
||||||
return
|
return
|
||||||
@@ -341,7 +341,7 @@ func (g *GameManager) AbilityInvocationsNotify(player *model.Player, payloadMsg
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) ClientAbilityInitFinishNotify(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) ClientAbilityInitFinishNotify(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.ClientAbilityInitFinishNotify)
|
req := payloadMsg.(*proto.ClientAbilityInitFinishNotify)
|
||||||
if player.SceneLoadState != model.SceneEnterDone {
|
if player.SceneLoadState != model.SceneEnterDone {
|
||||||
return
|
return
|
||||||
@@ -356,7 +356,7 @@ func (g *GameManager) ClientAbilityInitFinishNotify(player *model.Player, payloa
|
|||||||
req, []string{"EntityId"})
|
req, []string{"EntityId"})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) ClientAbilityChangeNotify(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) ClientAbilityChangeNotify(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.ClientAbilityChangeNotify)
|
req := payloadMsg.(*proto.ClientAbilityChangeNotify)
|
||||||
if player.SceneLoadState != model.SceneEnterDone {
|
if player.SceneLoadState != model.SceneEnterDone {
|
||||||
return
|
return
|
||||||
@@ -428,7 +428,7 @@ func (g *GameManager) ClientAbilityChangeNotify(player *model.Player, payloadMsg
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) EvtDoSkillSuccNotify(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) EvtDoSkillSuccNotify(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.EvtDoSkillSuccNotify)
|
req := payloadMsg.(*proto.EvtDoSkillSuccNotify)
|
||||||
if player.SceneLoadState != model.SceneEnterDone {
|
if player.SceneLoadState != model.SceneEnterDone {
|
||||||
return
|
return
|
||||||
@@ -438,7 +438,7 @@ func (g *GameManager) EvtDoSkillSuccNotify(player *model.Player, payloadMsg pb.M
|
|||||||
g.SkillStartStamina(player, req.CasterId, req.SkillId)
|
g.SkillStartStamina(player, req.CasterId, req.SkillId)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) EvtAvatarEnterFocusNotify(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) EvtAvatarEnterFocusNotify(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.EvtAvatarEnterFocusNotify)
|
req := payloadMsg.(*proto.EvtAvatarEnterFocusNotify)
|
||||||
if player.SceneLoadState != model.SceneEnterDone {
|
if player.SceneLoadState != model.SceneEnterDone {
|
||||||
return
|
return
|
||||||
@@ -448,7 +448,7 @@ func (g *GameManager) EvtAvatarEnterFocusNotify(player *model.Player, payloadMsg
|
|||||||
g.SendToWorldA(world, cmd.EvtAvatarEnterFocusNotify, player.ClientSeq, req)
|
g.SendToWorldA(world, cmd.EvtAvatarEnterFocusNotify, player.ClientSeq, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) EvtAvatarUpdateFocusNotify(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) EvtAvatarUpdateFocusNotify(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.EvtAvatarUpdateFocusNotify)
|
req := payloadMsg.(*proto.EvtAvatarUpdateFocusNotify)
|
||||||
if player.SceneLoadState != model.SceneEnterDone {
|
if player.SceneLoadState != model.SceneEnterDone {
|
||||||
return
|
return
|
||||||
@@ -458,7 +458,7 @@ func (g *GameManager) EvtAvatarUpdateFocusNotify(player *model.Player, payloadMs
|
|||||||
g.SendToWorldA(world, cmd.EvtAvatarUpdateFocusNotify, player.ClientSeq, req)
|
g.SendToWorldA(world, cmd.EvtAvatarUpdateFocusNotify, player.ClientSeq, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) EvtAvatarExitFocusNotify(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) EvtAvatarExitFocusNotify(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.EvtAvatarExitFocusNotify)
|
req := payloadMsg.(*proto.EvtAvatarExitFocusNotify)
|
||||||
if player.SceneLoadState != model.SceneEnterDone {
|
if player.SceneLoadState != model.SceneEnterDone {
|
||||||
return
|
return
|
||||||
@@ -468,7 +468,7 @@ func (g *GameManager) EvtAvatarExitFocusNotify(player *model.Player, payloadMsg
|
|||||||
g.SendToWorldA(world, cmd.EvtAvatarExitFocusNotify, player.ClientSeq, req)
|
g.SendToWorldA(world, cmd.EvtAvatarExitFocusNotify, player.ClientSeq, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) EvtEntityRenderersChangedNotify(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) EvtEntityRenderersChangedNotify(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.EvtEntityRenderersChangedNotify)
|
req := payloadMsg.(*proto.EvtEntityRenderersChangedNotify)
|
||||||
if player.SceneLoadState != model.SceneEnterDone {
|
if player.SceneLoadState != model.SceneEnterDone {
|
||||||
return
|
return
|
||||||
@@ -478,7 +478,7 @@ func (g *GameManager) EvtEntityRenderersChangedNotify(player *model.Player, payl
|
|||||||
g.SendToWorldA(world, cmd.EvtEntityRenderersChangedNotify, player.ClientSeq, req)
|
g.SendToWorldA(world, cmd.EvtEntityRenderersChangedNotify, player.ClientSeq, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) EvtCreateGadgetNotify(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) EvtCreateGadgetNotify(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.EvtCreateGadgetNotify)
|
req := payloadMsg.(*proto.EvtCreateGadgetNotify)
|
||||||
if player.SceneLoadState != model.SceneEnterDone {
|
if player.SceneLoadState != model.SceneEnterDone {
|
||||||
return
|
return
|
||||||
@@ -505,38 +505,58 @@ func (g *GameManager) EvtCreateGadgetNotify(player *model.Player, payloadMsg pb.
|
|||||||
g.AddSceneEntityNotify(player, proto.VisionType_VISION_BORN, []uint32{req.EntityId}, true, true)
|
g.AddSceneEntityNotify(player, proto.VisionType_VISION_BORN, []uint32{req.EntityId}, true, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) EvtDestroyGadgetNotify(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) EvtDestroyGadgetNotify(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.EvtDestroyGadgetNotify)
|
req := payloadMsg.(*proto.EvtDestroyGadgetNotify)
|
||||||
if player.SceneLoadState != model.SceneEnterDone {
|
if player.SceneLoadState != model.SceneEnterDone {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// logger.Debug("EvtDestroyGadgetNotify: %v", req)
|
// logger.Debug("EvtDestroyGadgetNotify: %v", req)
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
scene := world.GetSceneById(player.SceneId)
|
if world == nil {
|
||||||
if scene == nil {
|
logger.Error("world is nil, worldId: %v", player.WorldId)
|
||||||
logger.Error("scene is nil, sceneId: %v", player.SceneId)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
scene := world.GetSceneById(player.SceneId)
|
||||||
scene.DestroyEntity(req.EntityId)
|
scene.DestroyEntity(req.EntityId)
|
||||||
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_MISS, []uint32{req.EntityId})
|
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_MISS, []uint32{req.EntityId})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) EvtAiSyncSkillCdNotify(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) EvtAiSyncSkillCdNotify(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.EvtAiSyncSkillCdNotify)
|
req := payloadMsg.(*proto.EvtAiSyncSkillCdNotify)
|
||||||
_ = req
|
_ = req
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) EvtAiSyncCombatThreatInfoNotify(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) EvtAiSyncCombatThreatInfoNotify(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.EvtAiSyncCombatThreatInfoNotify)
|
req := payloadMsg.(*proto.EvtAiSyncCombatThreatInfoNotify)
|
||||||
_ = req
|
_ = req
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) EntityConfigHashNotify(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) EntityConfigHashNotify(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.EntityConfigHashNotify)
|
req := payloadMsg.(*proto.EntityConfigHashNotify)
|
||||||
_ = req
|
_ = req
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) MonsterAIConfigHashNotify(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) MonsterAIConfigHashNotify(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.MonsterAIConfigHashNotify)
|
req := payloadMsg.(*proto.MonsterAIConfigHashNotify)
|
||||||
_ = req
|
_ = req
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *Game) SetEntityClientDataNotify(player *model.Player, payloadMsg pb.Message) {
|
||||||
|
req := payloadMsg.(*proto.SetEntityClientDataNotify)
|
||||||
|
g.SendMsg(cmd.SetEntityClientDataNotify, player.PlayerID, player.ClientSeq, req)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Game) EntityAiSyncNotify(player *model.Player, payloadMsg pb.Message) {
|
||||||
|
req := payloadMsg.(*proto.EntityAiSyncNotify)
|
||||||
|
entityAiSyncNotify := &proto.EntityAiSyncNotify{
|
||||||
|
InfoList: make([]*proto.AiSyncInfo, 0),
|
||||||
|
}
|
||||||
|
for _, monsterId := range req.LocalAvatarAlertedMonsterList {
|
||||||
|
entityAiSyncNotify.InfoList = append(entityAiSyncNotify.InfoList, &proto.AiSyncInfo{
|
||||||
|
EntityId: monsterId,
|
||||||
|
HasPathToTarget: true,
|
||||||
|
IsSelfKilling: false,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
g.SendMsg(cmd.EntityAiSyncNotify, player.PlayerID, player.ClientSeq, entityAiSyncNotify)
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ type UserInfo struct {
|
|||||||
jwt.RegisteredClaims
|
jwt.RegisteredClaims
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取卡池信息
|
// GetGachaInfoReq 获取卡池信息
|
||||||
func (g *GameManager) GetGachaInfoReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) GetGachaInfoReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
serverAddr := config.GetConfig().Hk4e.GachaHistoryServer
|
serverAddr := config.GetConfig().Hk4e.GachaHistoryServer
|
||||||
userInfo := &UserInfo{
|
userInfo := &UserInfo{
|
||||||
UserId: player.PlayerID,
|
UserId: player.PlayerID,
|
||||||
@@ -37,7 +37,6 @@ func (g *GameManager) GetGachaInfoReq(player *model.Player, payloadMsg pb.Messag
|
|||||||
logger.Error("generate jwt error: %v", err)
|
logger.Error("generate jwt error: %v", err)
|
||||||
jwtStr = "default.jwt.token"
|
jwtStr = "default.jwt.token"
|
||||||
}
|
}
|
||||||
|
|
||||||
getGachaInfoRsp := new(proto.GetGachaInfoRsp)
|
getGachaInfoRsp := new(proto.GetGachaInfoRsp)
|
||||||
getGachaInfoRsp.GachaRandom = 12345
|
getGachaInfoRsp.GachaRandom = 12345
|
||||||
getGachaInfoRsp.GachaInfoList = []*proto.GachaInfo{
|
getGachaInfoRsp.GachaInfoList = []*proto.GachaInfo{
|
||||||
@@ -57,10 +56,10 @@ func (g *GameManager) GetGachaInfoReq(player *model.Player, payloadMsg pb.Messag
|
|||||||
CostItemNum: 1,
|
CostItemNum: 1,
|
||||||
TenCostItemId: 223,
|
TenCostItemId: 223,
|
||||||
TenCostItemNum: 10,
|
TenCostItemNum: 10,
|
||||||
GachaRecordUrl: serverAddr + "/gm/gacha?gachaType=300&jwt=" + jwtStr,
|
GachaRecordUrl: serverAddr + "/gacha?gachaType=300&jwt=" + jwtStr,
|
||||||
GachaRecordUrlOversea: serverAddr + "/gm/gacha?gachaType=300&jwt=" + jwtStr,
|
GachaRecordUrlOversea: serverAddr + "/gacha?gachaType=300&jwt=" + jwtStr,
|
||||||
GachaProbUrl: serverAddr + "/gm/gacha/details?scheduleId=823&jwt=" + jwtStr,
|
GachaProbUrl: serverAddr + "/gacha/details?scheduleId=823&jwt=" + jwtStr,
|
||||||
GachaProbUrlOversea: serverAddr + "/gm/gacha/details?scheduleId=823&jwt=" + jwtStr,
|
GachaProbUrlOversea: serverAddr + "/gacha/details?scheduleId=823&jwt=" + jwtStr,
|
||||||
GachaUpInfoList: []*proto.GachaUpInfo{
|
GachaUpInfoList: []*proto.GachaUpInfo{
|
||||||
{
|
{
|
||||||
ItemParentType: 1,
|
ItemParentType: 1,
|
||||||
@@ -94,10 +93,10 @@ func (g *GameManager) GetGachaInfoReq(player *model.Player, payloadMsg pb.Messag
|
|||||||
CostItemNum: 1,
|
CostItemNum: 1,
|
||||||
TenCostItemId: 223,
|
TenCostItemId: 223,
|
||||||
TenCostItemNum: 10,
|
TenCostItemNum: 10,
|
||||||
GachaRecordUrl: serverAddr + "/gm/gacha?gachaType=400&jwt=" + jwtStr,
|
GachaRecordUrl: serverAddr + "/gacha?gachaType=400&jwt=" + jwtStr,
|
||||||
GachaRecordUrlOversea: serverAddr + "/gm/gacha?gachaType=400&jwt=" + jwtStr,
|
GachaRecordUrlOversea: serverAddr + "/gacha?gachaType=400&jwt=" + jwtStr,
|
||||||
GachaProbUrl: serverAddr + "/gm/gacha/details?scheduleId=833&jwt=" + jwtStr,
|
GachaProbUrl: serverAddr + "/gacha/details?scheduleId=833&jwt=" + jwtStr,
|
||||||
GachaProbUrlOversea: serverAddr + "/gm/gacha/details?scheduleId=833&jwt=" + jwtStr,
|
GachaProbUrlOversea: serverAddr + "/gacha/details?scheduleId=833&jwt=" + jwtStr,
|
||||||
GachaUpInfoList: []*proto.GachaUpInfo{
|
GachaUpInfoList: []*proto.GachaUpInfo{
|
||||||
{
|
{
|
||||||
ItemParentType: 1,
|
ItemParentType: 1,
|
||||||
@@ -131,10 +130,10 @@ func (g *GameManager) GetGachaInfoReq(player *model.Player, payloadMsg pb.Messag
|
|||||||
CostItemNum: 1,
|
CostItemNum: 1,
|
||||||
TenCostItemId: 223,
|
TenCostItemId: 223,
|
||||||
TenCostItemNum: 10,
|
TenCostItemNum: 10,
|
||||||
GachaRecordUrl: serverAddr + "/gm/gacha?gachaType=431&jwt=" + jwtStr,
|
GachaRecordUrl: serverAddr + "/gacha?gachaType=431&jwt=" + jwtStr,
|
||||||
GachaRecordUrlOversea: serverAddr + "/gm/gacha?gachaType=431&jwt=" + jwtStr,
|
GachaRecordUrlOversea: serverAddr + "/gacha?gachaType=431&jwt=" + jwtStr,
|
||||||
GachaProbUrl: serverAddr + "/gm/gacha/details?scheduleId=1143&jwt=" + jwtStr,
|
GachaProbUrl: serverAddr + "/gacha/details?scheduleId=1143&jwt=" + jwtStr,
|
||||||
GachaProbUrlOversea: serverAddr + "/gm/gacha/details?scheduleId=1143&jwt=" + jwtStr,
|
GachaProbUrlOversea: serverAddr + "/gacha/details?scheduleId=1143&jwt=" + jwtStr,
|
||||||
GachaUpInfoList: []*proto.GachaUpInfo{
|
GachaUpInfoList: []*proto.GachaUpInfo{
|
||||||
{
|
{
|
||||||
ItemParentType: 1,
|
ItemParentType: 1,
|
||||||
@@ -168,10 +167,10 @@ func (g *GameManager) GetGachaInfoReq(player *model.Player, payloadMsg pb.Messag
|
|||||||
CostItemNum: 1,
|
CostItemNum: 1,
|
||||||
TenCostItemId: 224,
|
TenCostItemId: 224,
|
||||||
TenCostItemNum: 10,
|
TenCostItemNum: 10,
|
||||||
GachaRecordUrl: serverAddr + "/gm/gacha?gachaType=201&jwt=" + jwtStr,
|
GachaRecordUrl: serverAddr + "/gacha?gachaType=201&jwt=" + jwtStr,
|
||||||
GachaRecordUrlOversea: serverAddr + "/gm/gacha?gachaType=201&jwt=" + jwtStr,
|
GachaRecordUrlOversea: serverAddr + "/gacha?gachaType=201&jwt=" + jwtStr,
|
||||||
GachaProbUrl: serverAddr + "/gm/gacha/details?scheduleId=813&jwt=" + jwtStr,
|
GachaProbUrl: serverAddr + "/gacha/details?scheduleId=813&jwt=" + jwtStr,
|
||||||
GachaProbUrlOversea: serverAddr + "/gm/gacha/details?scheduleId=813&jwt=" + jwtStr,
|
GachaProbUrlOversea: serverAddr + "/gacha/details?scheduleId=813&jwt=" + jwtStr,
|
||||||
GachaUpInfoList: []*proto.GachaUpInfo{
|
GachaUpInfoList: []*proto.GachaUpInfo{
|
||||||
{
|
{
|
||||||
ItemParentType: 1,
|
ItemParentType: 1,
|
||||||
@@ -193,11 +192,10 @@ func (g *GameManager) GetGachaInfoReq(player *model.Player, payloadMsg pb.Messag
|
|||||||
g.SendMsg(cmd.GetGachaInfoRsp, player.PlayerID, player.ClientSeq, getGachaInfoRsp)
|
g.SendMsg(cmd.GetGachaInfoRsp, player.PlayerID, player.ClientSeq, getGachaInfoRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) DoGachaReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) DoGachaReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.DoGachaReq)
|
req := payloadMsg.(*proto.DoGachaReq)
|
||||||
gachaScheduleId := req.GachaScheduleId
|
gachaScheduleId := req.GachaScheduleId
|
||||||
gachaTimes := req.GachaTimes
|
gachaTimes := req.GachaTimes
|
||||||
|
|
||||||
gachaType := uint32(0)
|
gachaType := uint32(0)
|
||||||
costItemId := uint32(0)
|
costItemId := uint32(0)
|
||||||
switch gachaScheduleId {
|
switch gachaScheduleId {
|
||||||
@@ -218,13 +216,11 @@ func (g *GameManager) DoGachaReq(player *model.Player, payloadMsg pb.Message) {
|
|||||||
gachaType = 201
|
gachaType = 201
|
||||||
costItemId = 224
|
costItemId = 224
|
||||||
}
|
}
|
||||||
|
|
||||||
// 先扣掉粉球或蓝球再进行抽卡
|
// 先扣掉粉球或蓝球再进行抽卡
|
||||||
ok := g.CostUserItem(player.PlayerID, []*ChangeItem{{ItemId: costItemId, ChangeCount: gachaTimes}})
|
ok := g.CostUserItem(player.PlayerID, []*ChangeItem{{ItemId: costItemId, ChangeCount: gachaTimes}})
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
doGachaRsp := &proto.DoGachaRsp{
|
doGachaRsp := &proto.DoGachaRsp{
|
||||||
GachaType: gachaType,
|
GachaType: gachaType,
|
||||||
GachaScheduleId: gachaScheduleId,
|
GachaScheduleId: gachaScheduleId,
|
||||||
@@ -238,7 +234,6 @@ func (g *GameManager) DoGachaReq(player *model.Player, payloadMsg pb.Message) {
|
|||||||
TenCostItemNum: 10,
|
TenCostItemNum: 10,
|
||||||
GachaItemList: make([]*proto.GachaItem, 0),
|
GachaItemList: make([]*proto.GachaItem, 0),
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := uint32(0); i < gachaTimes; i++ {
|
for i := uint32(0); i < gachaTimes; i++ {
|
||||||
var ok bool
|
var ok bool
|
||||||
var itemId uint32
|
var itemId uint32
|
||||||
@@ -260,7 +255,6 @@ func (g *GameManager) DoGachaReq(player *model.Player, payloadMsg pb.Message) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
itemId = 11301
|
itemId = 11301
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加抽卡获得的道具
|
// 添加抽卡获得的道具
|
||||||
if itemId > 1000 && itemId < 2000 {
|
if itemId > 1000 && itemId < 2000 {
|
||||||
avatarId := (itemId % 1000) + 10000000
|
avatarId := (itemId % 1000) + 10000000
|
||||||
@@ -279,11 +273,9 @@ func (g *GameManager) DoGachaReq(player *model.Player, payloadMsg pb.Message) {
|
|||||||
} else {
|
} else {
|
||||||
g.AddUserItem(player.PlayerID, []*ChangeItem{{ItemId: itemId, ChangeCount: 1}}, false, 0)
|
g.AddUserItem(player.PlayerID, []*ChangeItem{{ItemId: itemId, ChangeCount: 1}}, false, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算星尘星辉
|
// 计算星尘星辉
|
||||||
xc := uint32(random.GetRandomInt32(0, 10))
|
xc := uint32(random.GetRandomInt32(0, 10))
|
||||||
xh := uint32(random.GetRandomInt32(0, 10))
|
xh := uint32(random.GetRandomInt32(0, 10))
|
||||||
|
|
||||||
gachaItem := new(proto.GachaItem)
|
gachaItem := new(proto.GachaItem)
|
||||||
gachaItem.GachaItem = &proto.ItemParam{
|
gachaItem.GachaItem = &proto.ItemParam{
|
||||||
ItemId: itemId,
|
ItemId: itemId,
|
||||||
@@ -315,13 +307,12 @@ func (g *GameManager) DoGachaReq(player *model.Player, payloadMsg pb.Message) {
|
|||||||
}
|
}
|
||||||
doGachaRsp.GachaItemList = append(doGachaRsp.GachaItemList, gachaItem)
|
doGachaRsp.GachaItemList = append(doGachaRsp.GachaItemList, gachaItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Debug("doGachaRsp: %v", doGachaRsp.String())
|
logger.Debug("doGachaRsp: %v", doGachaRsp.String())
|
||||||
g.SendMsg(cmd.DoGachaRsp, player.PlayerID, player.ClientSeq, doGachaRsp)
|
g.SendMsg(cmd.DoGachaRsp, player.PlayerID, player.ClientSeq, doGachaRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 扣1给可莉刷烧烤酱
|
// 扣1给可莉刷烧烤酱
|
||||||
func (g *GameManager) doGachaKlee() (bool, uint32) {
|
func (g *Game) doGachaKlee() (bool, uint32) {
|
||||||
allAvatarList := make([]uint32, 0)
|
allAvatarList := make([]uint32, 0)
|
||||||
allAvatarDataConfig := g.GetAllAvatarDataConfig()
|
allAvatarDataConfig := g.GetAllAvatarDataConfig()
|
||||||
for k, v := range allAvatarDataConfig {
|
for k, v := range allAvatarDataConfig {
|
||||||
@@ -374,20 +365,18 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// 单抽一次
|
// 单抽一次
|
||||||
func (g *GameManager) doGachaOnce(userId uint32, gachaType uint32, mustGetUpEnable bool, weaponFix bool) (bool, uint32) {
|
func (g *Game) doGachaOnce(userId uint32, gachaType uint32, mustGetUpEnable bool, weaponFix bool) (bool, uint32) {
|
||||||
player := USER_MANAGER.GetOnlineUser(userId)
|
player := USER_MANAGER.GetOnlineUser(userId)
|
||||||
if player == nil {
|
if player == nil {
|
||||||
logger.Error("player is nil, uid: %v", userId)
|
logger.Error("player is nil, uid: %v", userId)
|
||||||
return false, 0
|
return false, 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// 找到卡池对应的掉落组
|
// 找到卡池对应的掉落组
|
||||||
dropGroupDataConfig := gdconf.CONF.GachaDropGroupDataMap[int32(gachaType)]
|
dropGroupDataConfig := gdconf.CONF.GachaDropGroupDataMap[int32(gachaType)]
|
||||||
if dropGroupDataConfig == nil {
|
if dropGroupDataConfig == nil {
|
||||||
logger.Error("drop group not found, drop id: %v", gachaType)
|
logger.Error("drop group not found, drop id: %v", gachaType)
|
||||||
return false, 0
|
return false, 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取用户的卡池保底信息
|
// 获取用户的卡池保底信息
|
||||||
dbGacha := player.GetDbGacha()
|
dbGacha := player.GetDbGacha()
|
||||||
gachaPoolInfo := dbGacha.GachaPoolInfo[gachaType]
|
gachaPoolInfo := dbGacha.GachaPoolInfo[gachaType]
|
||||||
@@ -395,11 +384,9 @@ func (g *GameManager) doGachaOnce(userId uint32, gachaType uint32, mustGetUpEnab
|
|||||||
logger.Error("user gacha pool info not found, gacha type: %v", gachaType)
|
logger.Error("user gacha pool info not found, gacha type: %v", gachaType)
|
||||||
return false, 0
|
return false, 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保底计数+1
|
// 保底计数+1
|
||||||
gachaPoolInfo.OrangeTimes++
|
gachaPoolInfo.OrangeTimes++
|
||||||
gachaPoolInfo.PurpleTimes++
|
gachaPoolInfo.PurpleTimes++
|
||||||
|
|
||||||
// 4星和5星概率修正
|
// 4星和5星概率修正
|
||||||
OrangeTimesFixThreshold := uint32(0)
|
OrangeTimesFixThreshold := uint32(0)
|
||||||
OrangeTimesFixValue := int32(0)
|
OrangeTimesFixValue := int32(0)
|
||||||
@@ -453,9 +440,8 @@ func (g *GameManager) doGachaOnce(userId uint32, gachaType uint32, mustGetUpEnab
|
|||||||
}
|
}
|
||||||
dropGroupDataConfig = fixDropGroupDataConfig
|
dropGroupDataConfig = fixDropGroupDataConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
// 掉落
|
// 掉落
|
||||||
ok, drop := g.doFullRandDrop(dropGroupDataConfig)
|
ok, drop := g.doGachaRandDropFull(dropGroupDataConfig)
|
||||||
if !ok {
|
if !ok {
|
||||||
return false, 0
|
return false, 0
|
||||||
}
|
}
|
||||||
@@ -530,7 +516,7 @@ func (g *GameManager) doGachaOnce(userId uint32, gachaType uint32, mustGetUpEnab
|
|||||||
logger.Error("drop group not found, drop id: %v", upOrangeDropId)
|
logger.Error("drop group not found, drop id: %v", upOrangeDropId)
|
||||||
return false, 0
|
return false, 0
|
||||||
}
|
}
|
||||||
upOrangeOk, upOrangeDrop := g.doFullRandDrop(upOrangeDropGroupDataConfig)
|
upOrangeOk, upOrangeDrop := g.doGachaRandDropFull(upOrangeDropGroupDataConfig)
|
||||||
if !upOrangeOk {
|
if !upOrangeOk {
|
||||||
return false, 0
|
return false, 0
|
||||||
}
|
}
|
||||||
@@ -557,7 +543,7 @@ func (g *GameManager) doGachaOnce(userId uint32, gachaType uint32, mustGetUpEnab
|
|||||||
logger.Error("drop group not found, drop id: %v", upPurpleDropId)
|
logger.Error("drop group not found, drop id: %v", upPurpleDropId)
|
||||||
return false, 0
|
return false, 0
|
||||||
}
|
}
|
||||||
upPurpleOk, upPurpleDrop := g.doFullRandDrop(upPurpleDropGroupDataConfig)
|
upPurpleOk, upPurpleDrop := g.doGachaRandDropFull(upPurpleDropGroupDataConfig)
|
||||||
if !upPurpleOk {
|
if !upPurpleOk {
|
||||||
return false, 0
|
return false, 0
|
||||||
}
|
}
|
||||||
@@ -576,11 +562,11 @@ func (g *GameManager) doGachaOnce(userId uint32, gachaType uint32, mustGetUpEnab
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 走一次完整流程的掉落组
|
// 走一次完整流程的掉落组
|
||||||
func (g *GameManager) doFullRandDrop(dropGroupDataConfig *gdconf.GachaDropGroupData) (bool, *gdconf.GachaDrop) {
|
func (g *Game) doGachaRandDropFull(gachaDropGroupDataConfig *gdconf.GachaDropGroupData) (bool, *gdconf.GachaDrop) {
|
||||||
for {
|
for i := 0; i < 1000; i++ {
|
||||||
drop := g.doRandDropOnce(dropGroupDataConfig)
|
drop := g.doGachaRandDropOnce(gachaDropGroupDataConfig)
|
||||||
if drop == nil {
|
if drop == nil {
|
||||||
logger.Error("weight error, drop group config: %v", dropGroupDataConfig)
|
logger.Error("weight error, drop config: %v", gachaDropGroupDataConfig)
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
if drop.IsEnd {
|
if drop.IsEnd {
|
||||||
@@ -588,19 +574,20 @@ func (g *GameManager) doFullRandDrop(dropGroupDataConfig *gdconf.GachaDropGroupD
|
|||||||
return true, drop
|
return true, drop
|
||||||
}
|
}
|
||||||
// 进行下一步掉落流程
|
// 进行下一步掉落流程
|
||||||
dropGroupDataConfig = gdconf.CONF.GachaDropGroupDataMap[drop.Result]
|
gachaDropGroupDataConfig = gdconf.CONF.GachaDropGroupDataMap[drop.Result]
|
||||||
if dropGroupDataConfig == nil {
|
if gachaDropGroupDataConfig == nil {
|
||||||
logger.Error("drop config tab exist error, invalid drop id: %v", drop.Result)
|
logger.Error("drop config error, drop id: %v", drop.Result)
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
logger.Error("drop overtimes, drop config: %v", gachaDropGroupDataConfig)
|
||||||
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 进行单次随机掉落
|
// 进行单次随机掉落 轮盘赌选择法RWS
|
||||||
func (g *GameManager) doRandDropOnce(dropGroupDataConfig *gdconf.GachaDropGroupData) *gdconf.GachaDrop {
|
func (g *Game) doGachaRandDropOnce(dropGroupDataConfig *gdconf.GachaDropGroupData) *gdconf.GachaDrop {
|
||||||
randNum := random.GetRandomInt32(0, dropGroupDataConfig.WeightAll-1)
|
randNum := random.GetRandomInt32(0, dropGroupDataConfig.WeightAll-1)
|
||||||
sumWeight := int32(0)
|
sumWeight := int32(0)
|
||||||
// 轮盘选择法
|
|
||||||
for _, drop := range dropGroupDataConfig.DropConfig {
|
for _, drop := range dropGroupDataConfig.DropConfig {
|
||||||
sumWeight += drop.Weight
|
sumWeight += drop.Weight
|
||||||
if sumWeight > randNum {
|
if sumWeight > randNum {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
pb "google.golang.org/protobuf/proto"
|
pb "google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (g *GameManager) GCGLogin(player *model.Player) {
|
func (g *Game) GCGLogin(player *model.Player) {
|
||||||
// player.SceneId = 1076
|
// player.SceneId = 1076
|
||||||
// player.Pos.X = 8.974
|
// player.Pos.X = 8.974
|
||||||
// player.Pos.Y = 0
|
// player.Pos.Y = 0
|
||||||
@@ -33,7 +33,7 @@ func (g *GameManager) GCGLogin(player *model.Player) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GCGTavernInit GCG酒馆初始化
|
// GCGTavernInit GCG酒馆初始化
|
||||||
func (g *GameManager) GCGTavernInit(player *model.Player) {
|
func (g *Game) GCGTavernInit(player *model.Player) {
|
||||||
// if player.SceneId == 1076 {
|
// if player.SceneId == 1076 {
|
||||||
// // GCG酒馆信息通知
|
// // GCG酒馆信息通知
|
||||||
// g.SendMsg(cmd.GCGTCTavernInfoNotify, player.PlayerID, player.ClientSeq, g.PacketGCGTCTavernInfoNotify(player))
|
// g.SendMsg(cmd.GCGTCTavernInfoNotify, player.PlayerID, player.ClientSeq, g.PacketGCGTCTavernInfoNotify(player))
|
||||||
@@ -43,7 +43,7 @@ func (g *GameManager) GCGTavernInit(player *model.Player) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GCGStartChallenge GCG开始挑战
|
// GCGStartChallenge GCG开始挑战
|
||||||
func (g *GameManager) GCGStartChallenge(player *model.Player) {
|
func (g *Game) GCGStartChallenge(player *model.Player) {
|
||||||
// GCG开始游戏通知
|
// GCG开始游戏通知
|
||||||
// gcgStartChallengeByCheckRewardRsp := &proto.GCGStartChallengeByCheckRewardRsp{
|
// gcgStartChallengeByCheckRewardRsp := &proto.GCGStartChallengeByCheckRewardRsp{
|
||||||
// ExceededItemTypeList: make([]uint32, 0, 0),
|
// ExceededItemTypeList: make([]uint32, 0, 0),
|
||||||
@@ -59,7 +59,7 @@ func (g *GameManager) GCGStartChallenge(player *model.Player) {
|
|||||||
game := GCG_MANAGER.CreateGame(30101, []*model.Player{player})
|
game := GCG_MANAGER.CreateGame(30101, []*model.Player{player})
|
||||||
|
|
||||||
// GCG游戏简要信息通知
|
// GCG游戏简要信息通知
|
||||||
GAME_MANAGER.SendMsg(cmd.GCGGameBriefDataNotify, player.PlayerID, player.ClientSeq,
|
GAME.SendMsg(cmd.GCGGameBriefDataNotify, player.PlayerID, player.ClientSeq,
|
||||||
g.PacketGCGGameBriefDataNotify(player, proto.GCGGameBusinessType_GCG_GAME_GUIDE_GROUP, game))
|
g.PacketGCGGameBriefDataNotify(player, proto.GCGGameBusinessType_GCG_GAME_GUIDE_GROUP, game))
|
||||||
|
|
||||||
// 玩家进入GCG界面
|
// 玩家进入GCG界面
|
||||||
@@ -67,7 +67,7 @@ func (g *GameManager) GCGStartChallenge(player *model.Player) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GCGAskDuelReq GCG决斗请求
|
// GCGAskDuelReq GCG决斗请求
|
||||||
func (g *GameManager) GCGAskDuelReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) GCGAskDuelReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
// 获取玩家所在的游戏
|
// 获取玩家所在的游戏
|
||||||
game, ok := GCG_MANAGER.gameMap[player.GCGCurGameGuid]
|
game, ok := GCG_MANAGER.gameMap[player.GCGCurGameGuid]
|
||||||
if !ok {
|
if !ok {
|
||||||
@@ -258,11 +258,11 @@ func (g *GameManager) GCGAskDuelReq(player *model.Player, payloadMsg pb.Message)
|
|||||||
// })
|
// })
|
||||||
// }
|
// }
|
||||||
|
|
||||||
GAME_MANAGER.SendMsg(cmd.GCGAskDuelRsp, player.PlayerID, player.ClientSeq, gcgAskDuelRsp)
|
GAME.SendMsg(cmd.GCGAskDuelRsp, player.PlayerID, player.ClientSeq, gcgAskDuelRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GCGInitFinishReq GCG初始化完成请求
|
// GCGInitFinishReq GCG初始化完成请求
|
||||||
func (g *GameManager) GCGInitFinishReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) GCGInitFinishReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
// 获取玩家所在的游戏
|
// 获取玩家所在的游戏
|
||||||
game, ok := GCG_MANAGER.gameMap[player.GCGCurGameGuid]
|
game, ok := GCG_MANAGER.gameMap[player.GCGCurGameGuid]
|
||||||
if !ok {
|
if !ok {
|
||||||
@@ -279,14 +279,14 @@ func (g *GameManager) GCGInitFinishReq(player *model.Player, payloadMsg pb.Messa
|
|||||||
// 更改操控者加载状态
|
// 更改操控者加载状态
|
||||||
gameController.loadState = ControllerLoadState_InitFinish
|
gameController.loadState = ControllerLoadState_InitFinish
|
||||||
|
|
||||||
GAME_MANAGER.SendMsg(cmd.GCGInitFinishRsp, player.PlayerID, player.ClientSeq, &proto.GCGInitFinishRsp{})
|
GAME.SendMsg(cmd.GCGInitFinishRsp, player.PlayerID, player.ClientSeq, &proto.GCGInitFinishRsp{})
|
||||||
|
|
||||||
// 检查所有玩家是否已加载完毕
|
// 检查所有玩家是否已加载完毕
|
||||||
game.CheckAllInitFinish()
|
game.CheckAllInitFinish()
|
||||||
}
|
}
|
||||||
|
|
||||||
// GCGOperationReq GCG游戏客户端操作请求
|
// GCGOperationReq GCG游戏客户端操作请求
|
||||||
func (g *GameManager) GCGOperationReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) GCGOperationReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.GCGOperationReq)
|
req := payloadMsg.(*proto.GCGOperationReq)
|
||||||
|
|
||||||
// 获取玩家所在的游戏
|
// 获取玩家所在的游戏
|
||||||
@@ -309,7 +309,7 @@ func (g *GameManager) GCGOperationReq(player *model.Player, payloadMsg pb.Messag
|
|||||||
// 操作者是否拥有该卡牌
|
// 操作者是否拥有该卡牌
|
||||||
cardInfo := gameController.GetCharCardByGuid(op.CardGuid)
|
cardInfo := gameController.GetCharCardByGuid(op.CardGuid)
|
||||||
if cardInfo == nil {
|
if cardInfo == nil {
|
||||||
GAME_MANAGER.SendError(cmd.GCGOperationRsp, player, &proto.GCGOperationRsp{}, proto.Retcode_RET_GCG_SELECT_HAND_CARD_GUID_ERROR)
|
GAME.SendError(cmd.GCGOperationRsp, player, &proto.GCGOperationRsp{}, proto.Retcode_RET_GCG_SELECT_HAND_CARD_GUID_ERROR)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// 操控者选择角色牌
|
// 操控者选择角色牌
|
||||||
@@ -356,11 +356,11 @@ func (g *GameManager) GCGOperationReq(player *model.Player, payloadMsg pb.Messag
|
|||||||
gcgOperationRsp := &proto.GCGOperationRsp{
|
gcgOperationRsp := &proto.GCGOperationRsp{
|
||||||
OpSeq: req.OpSeq,
|
OpSeq: req.OpSeq,
|
||||||
}
|
}
|
||||||
GAME_MANAGER.SendMsg(cmd.GCGOperationRsp, player.PlayerID, player.ClientSeq, gcgOperationRsp)
|
GAME.SendMsg(cmd.GCGOperationRsp, player.PlayerID, player.ClientSeq, gcgOperationRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PacketGCGSkillPreviewNotify GCG游戏技能预览通知
|
// PacketGCGSkillPreviewNotify GCG游戏技能预览通知
|
||||||
func (g *GameManager) PacketGCGSkillPreviewNotify(game *GCGGame, controller *GCGController) *proto.GCGSkillPreviewNotify {
|
func (g *Game) PacketGCGSkillPreviewNotify(game *GCGGame, controller *GCGController) *proto.GCGSkillPreviewNotify {
|
||||||
selectedCharCard := controller.GetSelectedCharCard()
|
selectedCharCard := controller.GetSelectedCharCard()
|
||||||
// 确保玩家选择了角色牌
|
// 确保玩家选择了角色牌
|
||||||
if selectedCharCard == nil {
|
if selectedCharCard == nil {
|
||||||
@@ -449,7 +449,7 @@ func (g *GameManager) PacketGCGSkillPreviewNotify(game *GCGGame, controller *GCG
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SendGCGMessagePackNotify 发送GCG游戏消息包通知
|
// SendGCGMessagePackNotify 发送GCG游戏消息包通知
|
||||||
func (g *GameManager) SendGCGMessagePackNotify(controller *GCGController, serverSeq uint32, msgPackList []*proto.GCGMessagePack) {
|
func (g *Game) SendGCGMessagePackNotify(controller *GCGController, serverSeq uint32, msgPackList []*proto.GCGMessagePack) {
|
||||||
// 确保加载完成
|
// 确保加载完成
|
||||||
if controller.loadState != ControllerLoadState_InitFinish {
|
if controller.loadState != ControllerLoadState_InitFinish {
|
||||||
return
|
return
|
||||||
@@ -462,7 +462,7 @@ func (g *GameManager) SendGCGMessagePackNotify(controller *GCGController, server
|
|||||||
// 根据操控者的类型发送消息包
|
// 根据操控者的类型发送消息包
|
||||||
switch controller.controllerType {
|
switch controller.controllerType {
|
||||||
case ControllerType_Player:
|
case ControllerType_Player:
|
||||||
GAME_MANAGER.SendMsg(cmd.GCGMessagePackNotify, controller.player.PlayerID, controller.player.ClientSeq, gcgMessagePackNotify)
|
GAME.SendMsg(cmd.GCGMessagePackNotify, controller.player.PlayerID, controller.player.ClientSeq, gcgMessagePackNotify)
|
||||||
case ControllerType_AI:
|
case ControllerType_AI:
|
||||||
controller.ai.ReceiveGCGMessagePackNotify(gcgMessagePackNotify)
|
controller.ai.ReceiveGCGMessagePackNotify(gcgMessagePackNotify)
|
||||||
default:
|
default:
|
||||||
@@ -472,7 +472,7 @@ func (g *GameManager) SendGCGMessagePackNotify(controller *GCGController, server
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PacketGCGGameBriefDataNotify GCG游戏简要数据通知
|
// PacketGCGGameBriefDataNotify GCG游戏简要数据通知
|
||||||
func (g *GameManager) PacketGCGGameBriefDataNotify(player *model.Player, businessType proto.GCGGameBusinessType, game *GCGGame) *proto.GCGGameBriefDataNotify {
|
func (g *Game) PacketGCGGameBriefDataNotify(player *model.Player, businessType proto.GCGGameBusinessType, game *GCGGame) *proto.GCGGameBriefDataNotify {
|
||||||
gcgGameBriefDataNotify := &proto.GCGGameBriefDataNotify{
|
gcgGameBriefDataNotify := &proto.GCGGameBriefDataNotify{
|
||||||
GcgBriefData: &proto.GCGGameBriefData{
|
GcgBriefData: &proto.GCGGameBriefData{
|
||||||
BusinessType: businessType,
|
BusinessType: businessType,
|
||||||
@@ -507,7 +507,7 @@ func (g *GameManager) PacketGCGGameBriefDataNotify(player *model.Player, busines
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PacketGCGTavernNpcInfoNotify GCG酒馆NPC信息通知
|
// PacketGCGTavernNpcInfoNotify GCG酒馆NPC信息通知
|
||||||
func (g *GameManager) PacketGCGTavernNpcInfoNotify(player *model.Player) *proto.GCGTavernNpcInfoNotify {
|
func (g *Game) PacketGCGTavernNpcInfoNotify(player *model.Player) *proto.GCGTavernNpcInfoNotify {
|
||||||
gcgTavernNpcInfoNotify := &proto.GCGTavernNpcInfoNotify{
|
gcgTavernNpcInfoNotify := &proto.GCGTavernNpcInfoNotify{
|
||||||
WeekNpcList: make([]*proto.GCGTavernNpcInfo, 0, 0),
|
WeekNpcList: make([]*proto.GCGTavernNpcInfo, 0, 0),
|
||||||
ConstNpcList: make([]*proto.GCGTavernNpcInfo, 0, 0),
|
ConstNpcList: make([]*proto.GCGTavernNpcInfo, 0, 0),
|
||||||
@@ -521,7 +521,7 @@ func (g *GameManager) PacketGCGTavernNpcInfoNotify(player *model.Player) *proto.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PacketGCGTCTavernInfoNotify GCG酒馆信息通知
|
// PacketGCGTCTavernInfoNotify GCG酒馆信息通知
|
||||||
func (g *GameManager) PacketGCGTCTavernInfoNotify(player *model.Player) *proto.GCGTCTavernInfoNotify {
|
func (g *Game) PacketGCGTCTavernInfoNotify(player *model.Player) *proto.GCGTCTavernInfoNotify {
|
||||||
gcgTCTavernInfoNotify := &proto.GCGTCTavernInfoNotify{
|
gcgTCTavernInfoNotify := &proto.GCGTCTavernInfoNotify{
|
||||||
LevelId: 0,
|
LevelId: 0,
|
||||||
IsLastDuelWin: false,
|
IsLastDuelWin: false,
|
||||||
@@ -535,7 +535,7 @@ func (g *GameManager) PacketGCGTCTavernInfoNotify(player *model.Player) *proto.G
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PacketGCGTCTavernChallengeDataNotify GCG酒馆挑战数据
|
// PacketGCGTCTavernChallengeDataNotify GCG酒馆挑战数据
|
||||||
func (g *GameManager) PacketGCGTCTavernChallengeDataNotify(player *model.Player) *proto.GCGTCTavernChallengeDataNotify {
|
func (g *Game) PacketGCGTCTavernChallengeDataNotify(player *model.Player) *proto.GCGTCTavernChallengeDataNotify {
|
||||||
gcgTCTavernChallengeDataNotify := &proto.GCGTCTavernChallengeDataNotify{
|
gcgTCTavernChallengeDataNotify := &proto.GCGTCTavernChallengeDataNotify{
|
||||||
TavernChallengeList: make([]*proto.GCGTCTavernChallengeData, 0, 0),
|
TavernChallengeList: make([]*proto.GCGTCTavernChallengeData, 0, 0),
|
||||||
}
|
}
|
||||||
@@ -550,7 +550,7 @@ func (g *GameManager) PacketGCGTCTavernChallengeDataNotify(player *model.Player)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PacketGCGBasicDataNotify GCG基础数据通知
|
// PacketGCGBasicDataNotify GCG基础数据通知
|
||||||
func (g *GameManager) PacketGCGBasicDataNotify(player *model.Player) *proto.GCGBasicDataNotify {
|
func (g *Game) PacketGCGBasicDataNotify(player *model.Player) *proto.GCGBasicDataNotify {
|
||||||
gcgBasicDataNotify := &proto.GCGBasicDataNotify{
|
gcgBasicDataNotify := &proto.GCGBasicDataNotify{
|
||||||
Level: player.GCGInfo.Level,
|
Level: player.GCGInfo.Level,
|
||||||
Exp: player.GCGInfo.Exp,
|
Exp: player.GCGInfo.Exp,
|
||||||
@@ -560,7 +560,7 @@ func (g *GameManager) PacketGCGBasicDataNotify(player *model.Player) *proto.GCGB
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PacketGCGLevelChallengeNotify GCG等级挑战通知
|
// PacketGCGLevelChallengeNotify GCG等级挑战通知
|
||||||
func (g *GameManager) PacketGCGLevelChallengeNotify(player *model.Player) *proto.GCGLevelChallengeNotify {
|
func (g *Game) PacketGCGLevelChallengeNotify(player *model.Player) *proto.GCGLevelChallengeNotify {
|
||||||
gcgLevelChallengeNotify := &proto.GCGLevelChallengeNotify{
|
gcgLevelChallengeNotify := &proto.GCGLevelChallengeNotify{
|
||||||
UnlockBossChallengeList: make([]*proto.GCGBossChallengeData, 0, 0),
|
UnlockBossChallengeList: make([]*proto.GCGBossChallengeData, 0, 0),
|
||||||
UnlockWorldChallengeList: player.GCGInfo.UnlockWorldChallengeList,
|
UnlockWorldChallengeList: player.GCGInfo.UnlockWorldChallengeList,
|
||||||
@@ -586,7 +586,7 @@ func (g *GameManager) PacketGCGLevelChallengeNotify(player *model.Player) *proto
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PacketGCGDSBanCardNotify GCG禁止的卡牌通知
|
// PacketGCGDSBanCardNotify GCG禁止的卡牌通知
|
||||||
func (g *GameManager) PacketGCGDSBanCardNotify(player *model.Player) *proto.GCGDSBanCardNotify {
|
func (g *Game) PacketGCGDSBanCardNotify(player *model.Player) *proto.GCGDSBanCardNotify {
|
||||||
gcgDSBanCardNotify := &proto.GCGDSBanCardNotify{
|
gcgDSBanCardNotify := &proto.GCGDSBanCardNotify{
|
||||||
CardList: player.GCGInfo.BanCardList,
|
CardList: player.GCGInfo.BanCardList,
|
||||||
}
|
}
|
||||||
@@ -594,7 +594,7 @@ func (g *GameManager) PacketGCGDSBanCardNotify(player *model.Player) *proto.GCGD
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PacketGCGDSDataNotify GCG数据通知
|
// PacketGCGDSDataNotify GCG数据通知
|
||||||
func (g *GameManager) PacketGCGDSDataNotify(player *model.Player) *proto.GCGDSDataNotify {
|
func (g *Game) PacketGCGDSDataNotify(player *model.Player) *proto.GCGDSDataNotify {
|
||||||
gcgDSDataNotify := &proto.GCGDSDataNotify{
|
gcgDSDataNotify := &proto.GCGDSDataNotify{
|
||||||
CurDeckId: player.GCGInfo.CurDeckId,
|
CurDeckId: player.GCGInfo.CurDeckId,
|
||||||
DeckList: make([]*proto.GCGDSDeckData, 0, len(player.GCGInfo.DeckList)),
|
DeckList: make([]*proto.GCGDSDeckData, 0, len(player.GCGInfo.DeckList)),
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ type ChangeItem struct {
|
|||||||
ChangeCount uint32
|
ChangeCount uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) GetAllItemDataConfig() map[int32]*gdconf.ItemData {
|
func (g *Game) GetAllItemDataConfig() map[int32]*gdconf.ItemData {
|
||||||
allItemDataConfig := make(map[int32]*gdconf.ItemData)
|
allItemDataConfig := make(map[int32]*gdconf.ItemData)
|
||||||
for itemId, itemData := range gdconf.GetItemDataMap() {
|
for itemId, itemData := range gdconf.GetItemDataMap() {
|
||||||
if itemData.Type == constant.ITEM_TYPE_WEAPON {
|
if itemData.Type == constant.ITEM_TYPE_WEAPON {
|
||||||
@@ -29,7 +29,7 @@ func (g *GameManager) GetAllItemDataConfig() map[int32]*gdconf.ItemData {
|
|||||||
return allItemDataConfig
|
return allItemDataConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) GetPlayerItemCount(userId uint32, itemId uint32) uint32 {
|
func (g *Game) GetPlayerItemCount(userId uint32, itemId uint32) uint32 {
|
||||||
player := USER_MANAGER.GetOnlineUser(userId)
|
player := USER_MANAGER.GetOnlineUser(userId)
|
||||||
if player == nil {
|
if player == nil {
|
||||||
logger.Error("player is nil, uid: %v", userId)
|
logger.Error("player is nil, uid: %v", userId)
|
||||||
@@ -47,7 +47,7 @@ func (g *GameManager) GetPlayerItemCount(userId uint32, itemId uint32) uint32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AddUserItem 玩家添加物品
|
// AddUserItem 玩家添加物品
|
||||||
func (g *GameManager) AddUserItem(userId uint32, itemList []*ChangeItem, isHint bool, hintReason uint16) bool {
|
func (g *Game) AddUserItem(userId uint32, itemList []*ChangeItem, isHint bool, hintReason uint16) bool {
|
||||||
player := USER_MANAGER.GetOnlineUser(userId)
|
player := USER_MANAGER.GetOnlineUser(userId)
|
||||||
if player == nil {
|
if player == nil {
|
||||||
logger.Error("player is nil, uid: %v", userId)
|
logger.Error("player is nil, uid: %v", userId)
|
||||||
@@ -122,7 +122,7 @@ func (g *GameManager) AddUserItem(userId uint32, itemList []*ChangeItem, isHint
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) CostUserItem(userId uint32, itemList []*ChangeItem) bool {
|
func (g *Game) CostUserItem(userId uint32, itemList []*ChangeItem) bool {
|
||||||
player := USER_MANAGER.GetOnlineUser(userId)
|
player := USER_MANAGER.GetOnlineUser(userId)
|
||||||
if player == nil {
|
if player == nil {
|
||||||
logger.Error("player is nil, uid: %v", userId)
|
logger.Error("player is nil, uid: %v", userId)
|
||||||
|
|||||||
@@ -15,14 +15,14 @@ import (
|
|||||||
pb "google.golang.org/protobuf/proto"
|
pb "google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (g *GameManager) PlayerLoginReq(userId uint32, clientSeq uint32, gateAppId string, payloadMsg pb.Message) {
|
func (g *Game) PlayerLoginReq(userId uint32, clientSeq uint32, gateAppId string, payloadMsg pb.Message) {
|
||||||
logger.Info("user login req, uid: %v, gateAppId: %v", userId, gateAppId)
|
logger.Info("user login req, uid: %v, gateAppId: %v", userId, gateAppId)
|
||||||
req := payloadMsg.(*proto.PlayerLoginReq)
|
req := payloadMsg.(*proto.PlayerLoginReq)
|
||||||
logger.Debug("login data: %v", req)
|
logger.Debug("login data: %v", req)
|
||||||
g.OnLogin(userId, clientSeq, gateAppId, false, nil)
|
g.OnLogin(userId, clientSeq, gateAppId, false, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) SetPlayerBornDataReq(userId uint32, clientSeq uint32, gateAppId string, payloadMsg pb.Message) {
|
func (g *Game) SetPlayerBornDataReq(userId uint32, clientSeq uint32, gateAppId string, payloadMsg pb.Message) {
|
||||||
logger.Info("user reg req, uid: %v, gateAppId: %v", userId, gateAppId)
|
logger.Info("user reg req, uid: %v, gateAppId: %v", userId, gateAppId)
|
||||||
req := payloadMsg.(*proto.SetPlayerBornDataReq)
|
req := payloadMsg.(*proto.SetPlayerBornDataReq)
|
||||||
logger.Debug("reg data: %v", req)
|
logger.Debug("reg data: %v", req)
|
||||||
@@ -33,7 +33,7 @@ func (g *GameManager) SetPlayerBornDataReq(userId uint32, clientSeq uint32, gate
|
|||||||
g.OnReg(userId, clientSeq, gateAppId, req)
|
g.OnReg(userId, clientSeq, gateAppId, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) OnLogin(userId uint32, clientSeq uint32, gateAppId string, isReg bool, regPlayer *model.Player) {
|
func (g *Game) OnLogin(userId uint32, clientSeq uint32, gateAppId string, isReg bool, regPlayer *model.Player) {
|
||||||
logger.Info("user login, uid: %v", userId)
|
logger.Info("user login, uid: %v", userId)
|
||||||
if isReg {
|
if isReg {
|
||||||
g.OnLoginOk(userId, clientSeq, gateAppId, true, regPlayer)
|
g.OnLoginOk(userId, clientSeq, gateAppId, true, regPlayer)
|
||||||
@@ -45,7 +45,7 @@ func (g *GameManager) OnLogin(userId uint32, clientSeq uint32, gateAppId string,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) OnLoginOk(userId uint32, clientSeq uint32, gateAppId string, isReg bool, player *model.Player) {
|
func (g *Game) OnLoginOk(userId uint32, clientSeq uint32, gateAppId string, isReg bool, player *model.Player) {
|
||||||
if player == nil {
|
if player == nil {
|
||||||
g.SendMsgToGate(cmd.DoSetPlayerBornDataNotify, userId, clientSeq, gateAppId, new(proto.DoSetPlayerBornDataNotify))
|
g.SendMsgToGate(cmd.DoSetPlayerBornDataNotify, userId, clientSeq, gateAppId, new(proto.DoSetPlayerBornDataNotify))
|
||||||
return
|
return
|
||||||
@@ -121,7 +121,7 @@ func (g *GameManager) OnLoginOk(userId uint32, clientSeq uint32, gateAppId strin
|
|||||||
SELF = nil
|
SELF = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) OnReg(userId uint32, clientSeq uint32, gateAppId string, payloadMsg pb.Message) {
|
func (g *Game) OnReg(userId uint32, clientSeq uint32, gateAppId string, payloadMsg pb.Message) {
|
||||||
logger.Debug("user reg, uid: %v", userId)
|
logger.Debug("user reg, uid: %v", userId)
|
||||||
req := payloadMsg.(*proto.SetPlayerBornDataReq)
|
req := payloadMsg.(*proto.SetPlayerBornDataReq)
|
||||||
logger.Debug("avatar id: %v, nickname: %v", req.AvatarId, req.NickName)
|
logger.Debug("avatar id: %v, nickname: %v", req.AvatarId, req.NickName)
|
||||||
@@ -131,7 +131,7 @@ func (g *GameManager) OnReg(userId uint32, clientSeq uint32, gateAppId string, p
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) OnRegOk(exist bool, req *proto.SetPlayerBornDataReq, userId uint32, clientSeq uint32, gateAppId string) {
|
func (g *Game) OnRegOk(exist bool, req *proto.SetPlayerBornDataReq, userId uint32, clientSeq uint32, gateAppId string) {
|
||||||
if exist {
|
if exist {
|
||||||
logger.Error("recv reg req, but user is already exist, uid: %v", userId)
|
logger.Error("recv reg req, but user is already exist, uid: %v", userId)
|
||||||
return
|
return
|
||||||
@@ -153,7 +153,7 @@ func (g *GameManager) OnRegOk(exist bool, req *proto.SetPlayerBornDataReq, userI
|
|||||||
g.OnLogin(userId, clientSeq, gateAppId, true, player)
|
g.OnLogin(userId, clientSeq, gateAppId, true, player)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) CreatePlayer(userId uint32, nickName string, mainCharAvatarId uint32) *model.Player {
|
func (g *Game) CreatePlayer(userId uint32, nickName string, mainCharAvatarId uint32) *model.Player {
|
||||||
player := new(model.Player)
|
player := new(model.Player)
|
||||||
player.PlayerID = userId
|
player.PlayerID = userId
|
||||||
player.NickName = nickName
|
player.NickName = nickName
|
||||||
@@ -212,7 +212,7 @@ func (g *GameManager) CreatePlayer(userId uint32, nickName string, mainCharAvata
|
|||||||
return player
|
return player
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) OnUserOffline(userId uint32, changeGsInfo *ChangeGsInfo) {
|
func (g *Game) OnUserOffline(userId uint32, changeGsInfo *ChangeGsInfo) {
|
||||||
logger.Info("user offline, uid: %v", userId)
|
logger.Info("user offline, uid: %v", userId)
|
||||||
player := USER_MANAGER.GetOnlineUser(userId)
|
player := USER_MANAGER.GetOnlineUser(userId)
|
||||||
if player == nil {
|
if player == nil {
|
||||||
@@ -231,7 +231,7 @@ func (g *GameManager) OnUserOffline(userId uint32, changeGsInfo *ChangeGsInfo) {
|
|||||||
atomic.AddInt32(&ONLINE_PLAYER_NUM, -1)
|
atomic.AddInt32(&ONLINE_PLAYER_NUM, -1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) LoginNotify(userId uint32, player *model.Player, clientSeq uint32) {
|
func (g *Game) LoginNotify(userId uint32, player *model.Player, clientSeq uint32) {
|
||||||
g.SendMsg(cmd.PlayerDataNotify, userId, clientSeq, g.PacketPlayerDataNotify(player))
|
g.SendMsg(cmd.PlayerDataNotify, userId, clientSeq, g.PacketPlayerDataNotify(player))
|
||||||
g.SendMsg(cmd.StoreWeightLimitNotify, userId, clientSeq, g.PacketStoreWeightLimitNotify())
|
g.SendMsg(cmd.StoreWeightLimitNotify, userId, clientSeq, g.PacketStoreWeightLimitNotify())
|
||||||
g.SendMsg(cmd.PlayerStoreNotify, userId, clientSeq, g.PacketPlayerStoreNotify(player))
|
g.SendMsg(cmd.PlayerStoreNotify, userId, clientSeq, g.PacketPlayerStoreNotify(player))
|
||||||
@@ -254,7 +254,7 @@ func (g *GameManager) LoginNotify(userId uint32, player *model.Player, clientSeq
|
|||||||
g.SendMsg(cmd.PlayerLoginRsp, userId, clientSeq, playerLoginRsp)
|
g.SendMsg(cmd.PlayerLoginRsp, userId, clientSeq, playerLoginRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PacketPlayerDataNotify(player *model.Player) *proto.PlayerDataNotify {
|
func (g *Game) PacketPlayerDataNotify(player *model.Player) *proto.PlayerDataNotify {
|
||||||
playerDataNotify := &proto.PlayerDataNotify{
|
playerDataNotify := &proto.PlayerDataNotify{
|
||||||
NickName: player.NickName,
|
NickName: player.NickName,
|
||||||
ServerTime: uint64(time.Now().UnixMilli()),
|
ServerTime: uint64(time.Now().UnixMilli()),
|
||||||
@@ -273,7 +273,7 @@ func (g *GameManager) PacketPlayerDataNotify(player *model.Player) *proto.Player
|
|||||||
return playerDataNotify
|
return playerDataNotify
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PacketStoreWeightLimitNotify() *proto.StoreWeightLimitNotify {
|
func (g *Game) PacketStoreWeightLimitNotify() *proto.StoreWeightLimitNotify {
|
||||||
storeWeightLimitNotify := &proto.StoreWeightLimitNotify{
|
storeWeightLimitNotify := &proto.StoreWeightLimitNotify{
|
||||||
StoreType: proto.StoreType_STORE_PACK,
|
StoreType: proto.StoreType_STORE_PACK,
|
||||||
// 背包容量限制
|
// 背包容量限制
|
||||||
@@ -286,7 +286,7 @@ func (g *GameManager) PacketStoreWeightLimitNotify() *proto.StoreWeightLimitNoti
|
|||||||
return storeWeightLimitNotify
|
return storeWeightLimitNotify
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PacketPlayerStoreNotify(player *model.Player) *proto.PlayerStoreNotify {
|
func (g *Game) PacketPlayerStoreNotify(player *model.Player) *proto.PlayerStoreNotify {
|
||||||
dbItem := player.GetDbItem()
|
dbItem := player.GetDbItem()
|
||||||
dbWeapon := player.GetDbWeapon()
|
dbWeapon := player.GetDbWeapon()
|
||||||
dbReliquary := player.GetDbReliquary()
|
dbReliquary := player.GetDbReliquary()
|
||||||
@@ -386,7 +386,7 @@ func (g *GameManager) PacketPlayerStoreNotify(player *model.Player) *proto.Playe
|
|||||||
return playerStoreNotify
|
return playerStoreNotify
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PacketAvatarDataNotify(player *model.Player) *proto.AvatarDataNotify {
|
func (g *Game) PacketAvatarDataNotify(player *model.Player) *proto.AvatarDataNotify {
|
||||||
dbAvatar := player.GetDbAvatar()
|
dbAvatar := player.GetDbAvatar()
|
||||||
dbTeam := player.GetDbTeam()
|
dbTeam := player.GetDbTeam()
|
||||||
avatarDataNotify := &proto.AvatarDataNotify{
|
avatarDataNotify := &proto.AvatarDataNotify{
|
||||||
@@ -415,7 +415,7 @@ func (g *GameManager) PacketAvatarDataNotify(player *model.Player) *proto.Avatar
|
|||||||
return avatarDataNotify
|
return avatarDataNotify
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PacketOpenStateUpdateNotify() *proto.OpenStateUpdateNotify {
|
func (g *Game) PacketOpenStateUpdateNotify() *proto.OpenStateUpdateNotify {
|
||||||
openStateUpdateNotify := &proto.OpenStateUpdateNotify{
|
openStateUpdateNotify := &proto.OpenStateUpdateNotify{
|
||||||
OpenStateMap: make(map[uint32]uint32),
|
OpenStateMap: make(map[uint32]uint32),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import (
|
|||||||
|
|
||||||
// 进入世界
|
// 进入世界
|
||||||
|
|
||||||
func (g *GameManager) PlayerApplyEnterMpReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) PlayerApplyEnterMpReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.PlayerApplyEnterMpReq)
|
req := payloadMsg.(*proto.PlayerApplyEnterMpReq)
|
||||||
targetUid := req.TargetUid
|
targetUid := req.TargetUid
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ func (g *GameManager) PlayerApplyEnterMpReq(player *model.Player, payloadMsg pb.
|
|||||||
g.UserApplyEnterWorld(player, targetUid)
|
g.UserApplyEnterWorld(player, targetUid)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PlayerApplyEnterMpResultReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) PlayerApplyEnterMpResultReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.PlayerApplyEnterMpResultReq)
|
req := payloadMsg.(*proto.PlayerApplyEnterMpResultReq)
|
||||||
applyUid := req.ApplyUid
|
applyUid := req.ApplyUid
|
||||||
isAgreed := req.IsAgreed
|
isAgreed := req.IsAgreed
|
||||||
@@ -42,7 +42,7 @@ func (g *GameManager) PlayerApplyEnterMpResultReq(player *model.Player, payloadM
|
|||||||
g.UserDealEnterWorld(player, applyUid, isAgreed)
|
g.UserDealEnterWorld(player, applyUid, isAgreed)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) JoinPlayerSceneReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) JoinPlayerSceneReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.JoinPlayerSceneReq)
|
req := payloadMsg.(*proto.JoinPlayerSceneReq)
|
||||||
|
|
||||||
joinPlayerSceneRsp := new(proto.JoinPlayerSceneRsp)
|
joinPlayerSceneRsp := new(proto.JoinPlayerSceneRsp)
|
||||||
@@ -73,7 +73,7 @@ func (g *GameManager) JoinPlayerSceneReq(player *model.Player, payloadMsg pb.Mes
|
|||||||
g.JoinOtherWorld(player, hostPlayer)
|
g.JoinOtherWorld(player, hostPlayer)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) JoinOtherWorld(player *model.Player, hostPlayer *model.Player) {
|
func (g *Game) JoinOtherWorld(player *model.Player, hostPlayer *model.Player) {
|
||||||
hostWorld := WORLD_MANAGER.GetWorldByID(hostPlayer.WorldId)
|
hostWorld := WORLD_MANAGER.GetWorldByID(hostPlayer.WorldId)
|
||||||
if hostPlayer.SceneLoadState == model.SceneEnterDone {
|
if hostPlayer.SceneLoadState == model.SceneEnterDone {
|
||||||
player.SceneJump = true
|
player.SceneJump = true
|
||||||
@@ -96,7 +96,7 @@ func (g *GameManager) JoinOtherWorld(player *model.Player, hostPlayer *model.Pla
|
|||||||
|
|
||||||
// 退出世界
|
// 退出世界
|
||||||
|
|
||||||
func (g *GameManager) PlayerGetForceQuitBanInfoReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) PlayerGetForceQuitBanInfoReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
ok := true
|
ok := true
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
for _, worldPlayer := range world.GetAllPlayer() {
|
for _, worldPlayer := range world.GetAllPlayer() {
|
||||||
@@ -112,7 +112,7 @@ func (g *GameManager) PlayerGetForceQuitBanInfoReq(player *model.Player, payload
|
|||||||
g.SendSucc(cmd.PlayerGetForceQuitBanInfoRsp, player, &proto.PlayerGetForceQuitBanInfoRsp{})
|
g.SendSucc(cmd.PlayerGetForceQuitBanInfoRsp, player, &proto.PlayerGetForceQuitBanInfoRsp{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) BackMyWorldReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) BackMyWorldReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
// 其他玩家
|
// 其他玩家
|
||||||
ok := g.UserLeaveWorld(player)
|
ok := g.UserLeaveWorld(player)
|
||||||
|
|
||||||
@@ -123,7 +123,7 @@ func (g *GameManager) BackMyWorldReq(player *model.Player, payloadMsg pb.Message
|
|||||||
g.SendSucc(cmd.BackMyWorldRsp, player, &proto.BackMyWorldRsp{})
|
g.SendSucc(cmd.BackMyWorldRsp, player, &proto.BackMyWorldRsp{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) ChangeWorldToSingleModeReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) ChangeWorldToSingleModeReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
// 房主
|
// 房主
|
||||||
ok := g.UserLeaveWorld(player)
|
ok := g.UserLeaveWorld(player)
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ func (g *GameManager) ChangeWorldToSingleModeReq(player *model.Player, payloadMs
|
|||||||
g.SendSucc(cmd.ChangeWorldToSingleModeRsp, player, &proto.ChangeWorldToSingleModeRsp{})
|
g.SendSucc(cmd.ChangeWorldToSingleModeRsp, player, &proto.ChangeWorldToSingleModeRsp{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) SceneKickPlayerReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) SceneKickPlayerReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.SceneKickPlayerReq)
|
req := payloadMsg.(*proto.SceneKickPlayerReq)
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
if player.PlayerID != world.GetOwner().PlayerID {
|
if player.PlayerID != world.GetOwner().PlayerID {
|
||||||
@@ -167,7 +167,7 @@ func (g *GameManager) SceneKickPlayerReq(player *model.Player, payloadMsg pb.Mes
|
|||||||
g.SendMsg(cmd.SceneKickPlayerRsp, player.PlayerID, player.ClientSeq, sceneKickPlayerRsp)
|
g.SendMsg(cmd.SceneKickPlayerRsp, player.PlayerID, player.ClientSeq, sceneKickPlayerRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) UserApplyEnterWorld(player *model.Player, targetUid uint32) {
|
func (g *Game) UserApplyEnterWorld(player *model.Player, targetUid uint32) {
|
||||||
applyFailNotify := func(reason proto.PlayerApplyEnterMpResultNotify_Reason) {
|
applyFailNotify := func(reason proto.PlayerApplyEnterMpResultNotify_Reason) {
|
||||||
playerApplyEnterMpResultNotify := &proto.PlayerApplyEnterMpResultNotify{
|
playerApplyEnterMpResultNotify := &proto.PlayerApplyEnterMpResultNotify{
|
||||||
TargetUid: targetUid,
|
TargetUid: targetUid,
|
||||||
@@ -249,7 +249,7 @@ func (g *GameManager) UserApplyEnterWorld(player *model.Player, targetUid uint32
|
|||||||
g.SendMsg(cmd.PlayerApplyEnterMpNotify, targetPlayer.PlayerID, targetPlayer.ClientSeq, playerApplyEnterMpNotify)
|
g.SendMsg(cmd.PlayerApplyEnterMpNotify, targetPlayer.PlayerID, targetPlayer.ClientSeq, playerApplyEnterMpNotify)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) UserDealEnterWorld(hostPlayer *model.Player, otherUid uint32, agree bool) {
|
func (g *Game) UserDealEnterWorld(hostPlayer *model.Player, otherUid uint32, agree bool) {
|
||||||
applyTime, exist := hostPlayer.CoopApplyMap[otherUid]
|
applyTime, exist := hostPlayer.CoopApplyMap[otherUid]
|
||||||
if !exist || time.Now().UnixNano() > applyTime+int64(10*time.Second) {
|
if !exist || time.Now().UnixNano() > applyTime+int64(10*time.Second) {
|
||||||
return
|
return
|
||||||
@@ -308,7 +308,7 @@ func (g *GameManager) UserDealEnterWorld(hostPlayer *model.Player, otherUid uint
|
|||||||
g.SendMsg(cmd.PlayerApplyEnterMpResultNotify, otherPlayer.PlayerID, otherPlayer.ClientSeq, playerApplyEnterMpResultNotify)
|
g.SendMsg(cmd.PlayerApplyEnterMpResultNotify, otherPlayer.PlayerID, otherPlayer.ClientSeq, playerApplyEnterMpResultNotify)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) HostEnterMpWorld(hostPlayer *model.Player, otherUid uint32) {
|
func (g *Game) HostEnterMpWorld(hostPlayer *model.Player, otherUid uint32) {
|
||||||
world := WORLD_MANAGER.GetWorldByID(hostPlayer.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(hostPlayer.WorldId)
|
||||||
if world.GetMultiplayer() {
|
if world.GetMultiplayer() {
|
||||||
return
|
return
|
||||||
@@ -351,7 +351,7 @@ func (g *GameManager) HostEnterMpWorld(hostPlayer *model.Player, otherUid uint32
|
|||||||
g.RemoveSceneEntityNotifyToPlayer(hostPlayer, proto.VisionType_VISION_MISS, []uint32{world.GetPlayerWorldAvatarEntityId(hostPlayer, activeAvatarId)})
|
g.RemoveSceneEntityNotifyToPlayer(hostPlayer, proto.VisionType_VISION_MISS, []uint32{world.GetPlayerWorldAvatarEntityId(hostPlayer, activeAvatarId)})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) UserLeaveWorld(player *model.Player) bool {
|
func (g *Game) UserLeaveWorld(player *model.Player) bool {
|
||||||
oldWorld := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
oldWorld := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
if !oldWorld.GetMultiplayer() {
|
if !oldWorld.GetMultiplayer() {
|
||||||
return false
|
return false
|
||||||
@@ -365,7 +365,7 @@ func (g *GameManager) UserLeaveWorld(player *model.Player) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) UserWorldAddPlayer(world *World, player *model.Player) {
|
func (g *Game) UserWorldAddPlayer(world *World, player *model.Player) {
|
||||||
if !WORLD_MANAGER.IsBigWorld(world) && world.GetWorldPlayerNum() >= 4 {
|
if !WORLD_MANAGER.IsBigWorld(world) && world.GetWorldPlayerNum() >= 4 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -380,7 +380,7 @@ func (g *GameManager) UserWorldAddPlayer(world *World, player *model.Player) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) UserWorldRemovePlayer(world *World, player *model.Player) {
|
func (g *Game) UserWorldRemovePlayer(world *World, player *model.Player) {
|
||||||
if world.GetMultiplayer() && player.PlayerID == world.GetOwner().PlayerID {
|
if world.GetMultiplayer() && player.PlayerID == world.GetOwner().PlayerID {
|
||||||
// 多人世界房主离开剔除所有其他玩家
|
// 多人世界房主离开剔除所有其他玩家
|
||||||
for _, worldPlayer := range world.GetAllPlayer() {
|
for _, worldPlayer := range world.GetAllPlayer() {
|
||||||
@@ -427,7 +427,7 @@ func (g *GameManager) UserWorldRemovePlayer(world *World, player *model.Player)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) UpdateWorldPlayerInfo(hostWorld *World, excludePlayer *model.Player) {
|
func (g *Game) UpdateWorldPlayerInfo(hostWorld *World, excludePlayer *model.Player) {
|
||||||
for _, worldPlayer := range hostWorld.GetAllPlayer() {
|
for _, worldPlayer := range hostWorld.GetAllPlayer() {
|
||||||
if worldPlayer.PlayerID == excludePlayer.PlayerID {
|
if worldPlayer.PlayerID == excludePlayer.PlayerID {
|
||||||
continue
|
continue
|
||||||
@@ -521,7 +521,7 @@ func (g *GameManager) UpdateWorldPlayerInfo(hostWorld *World, excludePlayer *mod
|
|||||||
|
|
||||||
// 跨服玩家多人世界相关请求
|
// 跨服玩家多人世界相关请求
|
||||||
|
|
||||||
func (g *GameManager) ServerUserMpReq(userMpInfo *mq.UserMpInfo, gsAppId string) {
|
func (g *Game) ServerUserMpReq(userMpInfo *mq.UserMpInfo, gsAppId string) {
|
||||||
switch userMpInfo.OriginInfo.CmdName {
|
switch userMpInfo.OriginInfo.CmdName {
|
||||||
case "PlayerApplyEnterMpReq":
|
case "PlayerApplyEnterMpReq":
|
||||||
applyFailNotify := func(reason proto.PlayerApplyEnterMpResultNotify_Reason) {
|
applyFailNotify := func(reason proto.PlayerApplyEnterMpResultNotify_Reason) {
|
||||||
@@ -623,7 +623,7 @@ func (g *GameManager) ServerUserMpReq(userMpInfo *mq.UserMpInfo, gsAppId string)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) ServerUserMpRsp(userMpInfo *mq.UserMpInfo) {
|
func (g *Game) ServerUserMpRsp(userMpInfo *mq.UserMpInfo) {
|
||||||
switch userMpInfo.OriginInfo.CmdName {
|
switch userMpInfo.OriginInfo.CmdName {
|
||||||
case "PlayerApplyEnterMpReq":
|
case "PlayerApplyEnterMpReq":
|
||||||
player := USER_MANAGER.GetOnlineUser(userMpInfo.OriginInfo.UserId)
|
player := USER_MANAGER.GetOnlineUser(userMpInfo.OriginInfo.UserId)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// AddQuestContentProgressReq 添加任务内容进度请求
|
// AddQuestContentProgressReq 添加任务内容进度请求
|
||||||
func (g *GameManager) AddQuestContentProgressReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) AddQuestContentProgressReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.AddQuestContentProgressReq)
|
req := payloadMsg.(*proto.AddQuestContentProgressReq)
|
||||||
logger.Debug("AddQuestContentProgressReq: %v", req)
|
logger.Debug("AddQuestContentProgressReq: %v", req)
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ func (g *GameManager) AddQuestContentProgressReq(player *model.Player, payloadMs
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AddQuestProgress 添加任务进度
|
// AddQuestProgress 添加任务进度
|
||||||
func (g *GameManager) AddQuestProgress(player *model.Player, req *proto.AddQuestContentProgressReq) {
|
func (g *Game) AddQuestProgress(player *model.Player, req *proto.AddQuestContentProgressReq) {
|
||||||
dbQuest := player.GetDbQuest()
|
dbQuest := player.GetDbQuest()
|
||||||
updateQuestIdList := make([]uint32, 0)
|
updateQuestIdList := make([]uint32, 0)
|
||||||
for _, quest := range dbQuest.GetQuestMap() {
|
for _, quest := range dbQuest.GetQuestMap() {
|
||||||
@@ -62,7 +62,7 @@ func (g *GameManager) AddQuestProgress(player *model.Player, req *proto.AddQuest
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AcceptQuest 接取当前条件下能接取到的全部任务
|
// AcceptQuest 接取当前条件下能接取到的全部任务
|
||||||
func (g *GameManager) AcceptQuest(player *model.Player, notifyClient bool) {
|
func (g *Game) AcceptQuest(player *model.Player, notifyClient bool) {
|
||||||
dbQuest := player.GetDbQuest()
|
dbQuest := player.GetDbQuest()
|
||||||
addQuestIdList := make([]uint32, 0)
|
addQuestIdList := make([]uint32, 0)
|
||||||
for _, questData := range gdconf.GetQuestDataMap() {
|
for _, questData := range gdconf.GetQuestDataMap() {
|
||||||
@@ -148,7 +148,7 @@ func (g *GameManager) AcceptQuest(player *model.Player, notifyClient bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TriggerQuest 触发任务
|
// TriggerQuest 触发任务
|
||||||
func (g *GameManager) TriggerQuest(player *model.Player, cond int32, param ...int32) {
|
func (g *Game) TriggerQuest(player *model.Player, cond int32, param ...int32) {
|
||||||
dbQuest := player.GetDbQuest()
|
dbQuest := player.GetDbQuest()
|
||||||
updateQuestIdList := make([]uint32, 0)
|
updateQuestIdList := make([]uint32, 0)
|
||||||
for _, quest := range dbQuest.GetQuestMap() {
|
for _, quest := range dbQuest.GetQuestMap() {
|
||||||
@@ -210,7 +210,7 @@ func (g *GameManager) TriggerQuest(player *model.Player, cond int32, param ...in
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PacketQuest 打包一个任务
|
// PacketQuest 打包一个任务
|
||||||
func (g *GameManager) PacketQuest(player *model.Player, questId uint32) *proto.Quest {
|
func (g *Game) PacketQuest(player *model.Player, questId uint32) *proto.Quest {
|
||||||
dbQuest := player.GetDbQuest()
|
dbQuest := player.GetDbQuest()
|
||||||
questDataConfig := gdconf.GetQuestDataById(int32(questId))
|
questDataConfig := gdconf.GetQuestDataById(int32(questId))
|
||||||
if questDataConfig == nil {
|
if questDataConfig == nil {
|
||||||
@@ -235,7 +235,7 @@ func (g *GameManager) PacketQuest(player *model.Player, questId uint32) *proto.Q
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PacketQuestListNotify 打包任务列表通知
|
// PacketQuestListNotify 打包任务列表通知
|
||||||
func (g *GameManager) PacketQuestListNotify(player *model.Player) *proto.QuestListNotify {
|
func (g *Game) PacketQuestListNotify(player *model.Player) *proto.QuestListNotify {
|
||||||
questListNotify := &proto.QuestListNotify{
|
questListNotify := &proto.QuestListNotify{
|
||||||
QuestList: make([]*proto.Quest, 0),
|
QuestList: make([]*proto.Quest, 0),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
"hk4e/protocol/proto"
|
"hk4e/protocol/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (g *GameManager) GetAllReliquaryDataConfig() map[int32]*gdconf.ItemData {
|
func (g *Game) GetAllReliquaryDataConfig() map[int32]*gdconf.ItemData {
|
||||||
allReliquaryDataConfig := make(map[int32]*gdconf.ItemData)
|
allReliquaryDataConfig := make(map[int32]*gdconf.ItemData)
|
||||||
for itemId, itemData := range gdconf.GetItemDataMap() {
|
for itemId, itemData := range gdconf.GetItemDataMap() {
|
||||||
if itemData.Type != constant.ITEM_TYPE_RELIQUARY {
|
if itemData.Type != constant.ITEM_TYPE_RELIQUARY {
|
||||||
@@ -21,7 +21,7 @@ func (g *GameManager) GetAllReliquaryDataConfig() map[int32]*gdconf.ItemData {
|
|||||||
return allReliquaryDataConfig
|
return allReliquaryDataConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) GetReliquaryMainDataRandomByDepotId(mainPropDepotId int32) *gdconf.ReliquaryMainData {
|
func (g *Game) GetReliquaryMainDataRandomByDepotId(mainPropDepotId int32) *gdconf.ReliquaryMainData {
|
||||||
mainPropMap, exist := gdconf.GetReliquaryMainDataMap()[mainPropDepotId]
|
mainPropMap, exist := gdconf.GetReliquaryMainDataMap()[mainPropDepotId]
|
||||||
if !exist {
|
if !exist {
|
||||||
return nil
|
return nil
|
||||||
@@ -34,7 +34,7 @@ func (g *GameManager) GetReliquaryMainDataRandomByDepotId(mainPropDepotId int32)
|
|||||||
}
|
}
|
||||||
randNum := random.GetRandomInt32(0, weightAll-1)
|
randNum := random.GetRandomInt32(0, weightAll-1)
|
||||||
sumWeight := int32(0)
|
sumWeight := int32(0)
|
||||||
// 轮盘选择法
|
// RWS随机
|
||||||
for _, data := range mainPropList {
|
for _, data := range mainPropList {
|
||||||
sumWeight += data.RandomWeight
|
sumWeight += data.RandomWeight
|
||||||
if sumWeight > randNum {
|
if sumWeight > randNum {
|
||||||
@@ -44,7 +44,7 @@ func (g *GameManager) GetReliquaryMainDataRandomByDepotId(mainPropDepotId int32)
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) AddUserReliquary(userId uint32, itemId uint32) uint64 {
|
func (g *Game) AddUserReliquary(userId uint32, itemId uint32) uint64 {
|
||||||
player := USER_MANAGER.GetOnlineUser(userId)
|
player := USER_MANAGER.GetOnlineUser(userId)
|
||||||
if player == nil {
|
if player == nil {
|
||||||
logger.Error("player is nil, uid: %v", userId)
|
logger.Error("player is nil, uid: %v", userId)
|
||||||
@@ -81,7 +81,7 @@ func (g *GameManager) AddUserReliquary(userId uint32, itemId uint32) uint64 {
|
|||||||
return reliquaryId
|
return reliquaryId
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) GetReliquaryAffixDataRandomByDepotId(appendPropDepotId int32, excludeTypeList ...uint32) *gdconf.ReliquaryAffixData {
|
func (g *Game) GetReliquaryAffixDataRandomByDepotId(appendPropDepotId int32, excludeTypeList ...uint32) *gdconf.ReliquaryAffixData {
|
||||||
appendPropMap, exist := gdconf.GetReliquaryAffixDataMap()[appendPropDepotId]
|
appendPropMap, exist := gdconf.GetReliquaryAffixDataMap()[appendPropDepotId]
|
||||||
if !exist {
|
if !exist {
|
||||||
return nil
|
return nil
|
||||||
@@ -105,7 +105,7 @@ func (g *GameManager) GetReliquaryAffixDataRandomByDepotId(appendPropDepotId int
|
|||||||
}
|
}
|
||||||
randNum := random.GetRandomInt32(0, weightAll-1)
|
randNum := random.GetRandomInt32(0, weightAll-1)
|
||||||
sumWeight := int32(0)
|
sumWeight := int32(0)
|
||||||
// 轮盘选择法
|
// RWS随机
|
||||||
for _, data := range appendPropList {
|
for _, data := range appendPropList {
|
||||||
sumWeight += data.RandomWeight
|
sumWeight += data.RandomWeight
|
||||||
if sumWeight > randNum {
|
if sumWeight > randNum {
|
||||||
@@ -116,7 +116,7 @@ func (g *GameManager) GetReliquaryAffixDataRandomByDepotId(appendPropDepotId int
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AppendReliquaryProp 圣遗物追加属性
|
// AppendReliquaryProp 圣遗物追加属性
|
||||||
func (g *GameManager) AppendReliquaryProp(reliquary *model.Reliquary, count int32) {
|
func (g *Game) AppendReliquaryProp(reliquary *model.Reliquary, count int32) {
|
||||||
// 获取圣遗物配置表
|
// 获取圣遗物配置表
|
||||||
reliquaryConfig := gdconf.GetItemDataById(int32(reliquary.ItemId))
|
reliquaryConfig := gdconf.GetItemDataById(int32(reliquary.ItemId))
|
||||||
if reliquaryConfig == nil {
|
if reliquaryConfig == nil {
|
||||||
@@ -155,7 +155,7 @@ func (g *GameManager) AppendReliquaryProp(reliquary *model.Reliquary, count int3
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) CostUserReliquary(userId uint32, reliquaryIdList []uint64) {
|
func (g *Game) CostUserReliquary(userId uint32, reliquaryIdList []uint64) {
|
||||||
player := USER_MANAGER.GetOnlineUser(userId)
|
player := USER_MANAGER.GetOnlineUser(userId)
|
||||||
if player == nil {
|
if player == nil {
|
||||||
logger.Error("player is nil, uid: %v", userId)
|
logger.Error("player is nil, uid: %v", userId)
|
||||||
@@ -177,7 +177,7 @@ func (g *GameManager) CostUserReliquary(userId uint32, reliquaryIdList []uint64)
|
|||||||
g.SendMsg(cmd.StoreItemDelNotify, userId, player.ClientSeq, storeItemDelNotify)
|
g.SendMsg(cmd.StoreItemDelNotify, userId, player.ClientSeq, storeItemDelNotify)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PacketStoreItemChangeNotifyByReliquary(reliquary *model.Reliquary) *proto.StoreItemChangeNotify {
|
func (g *Game) PacketStoreItemChangeNotifyByReliquary(reliquary *model.Reliquary) *proto.StoreItemChangeNotify {
|
||||||
storeItemChangeNotify := &proto.StoreItemChangeNotify{
|
storeItemChangeNotify := &proto.StoreItemChangeNotify{
|
||||||
StoreType: proto.StoreType_STORE_PACK,
|
StoreType: proto.StoreType_STORE_PACK,
|
||||||
ItemList: make([]*proto.Item, 0),
|
ItemList: make([]*proto.Item, 0),
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ const (
|
|||||||
GROUP_LOAD_DISTANCE = 250 // 场景组加载距离
|
GROUP_LOAD_DISTANCE = 250 // 场景组加载距离
|
||||||
)
|
)
|
||||||
|
|
||||||
func (g *GameManager) EnterSceneReadyReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) EnterSceneReadyReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.EnterSceneReadyReq)
|
req := payloadMsg.(*proto.EnterSceneReadyReq)
|
||||||
logger.Debug("player enter scene ready, uid: %v", player.PlayerID)
|
logger.Debug("player enter scene ready, uid: %v", player.PlayerID)
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
@@ -62,7 +62,7 @@ func (g *GameManager) EnterSceneReadyReq(player *model.Player, payloadMsg pb.Mes
|
|||||||
g.SendMsg(cmd.EnterSceneReadyRsp, player.PlayerID, player.ClientSeq, enterSceneReadyRsp)
|
g.SendMsg(cmd.EnterSceneReadyRsp, player.PlayerID, player.ClientSeq, enterSceneReadyRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) SceneInitFinishReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) SceneInitFinishReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.SceneInitFinishReq)
|
req := payloadMsg.(*proto.SceneInitFinishReq)
|
||||||
logger.Debug("player scene init finish, uid: %v", player.PlayerID)
|
logger.Debug("player scene init finish, uid: %v", player.PlayerID)
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
@@ -265,7 +265,7 @@ func (g *GameManager) SceneInitFinishReq(player *model.Player, payloadMsg pb.Mes
|
|||||||
player.SceneLoadState = model.SceneInitFinish
|
player.SceneLoadState = model.SceneInitFinish
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.EnterSceneDoneReq)
|
req := payloadMsg.(*proto.EnterSceneDoneReq)
|
||||||
logger.Debug("player enter scene done, uid: %v", player.PlayerID)
|
logger.Debug("player enter scene done, uid: %v", player.PlayerID)
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
@@ -340,7 +340,7 @@ func (g *GameManager) EnterSceneDoneReq(player *model.Player, payloadMsg pb.Mess
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PostEnterSceneReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) PostEnterSceneReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.PostEnterSceneReq)
|
req := payloadMsg.(*proto.PostEnterSceneReq)
|
||||||
logger.Debug("player post enter scene, uid: %v", player.PlayerID)
|
logger.Debug("player post enter scene, uid: %v", player.PlayerID)
|
||||||
|
|
||||||
@@ -350,7 +350,7 @@ func (g *GameManager) PostEnterSceneReq(player *model.Player, payloadMsg pb.Mess
|
|||||||
g.SendMsg(cmd.PostEnterSceneRsp, player.PlayerID, player.ClientSeq, postEnterSceneRsp)
|
g.SendMsg(cmd.PostEnterSceneRsp, player.PlayerID, player.ClientSeq, postEnterSceneRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) SceneEntityDrownReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) SceneEntityDrownReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.SceneEntityDrownReq)
|
req := payloadMsg.(*proto.SceneEntityDrownReq)
|
||||||
|
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
@@ -366,7 +366,7 @@ func (g *GameManager) SceneEntityDrownReq(player *model.Player, payloadMsg pb.Me
|
|||||||
g.SendMsg(cmd.SceneEntityDrownRsp, player.PlayerID, player.ClientSeq, sceneEntityDrownRsp)
|
g.SendMsg(cmd.SceneEntityDrownRsp, player.PlayerID, player.ClientSeq, sceneEntityDrownRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) AddSceneEntityNotifyToPlayer(player *model.Player, visionType proto.VisionType, entityList []*proto.SceneEntityInfo) {
|
func (g *Game) AddSceneEntityNotifyToPlayer(player *model.Player, visionType proto.VisionType, entityList []*proto.SceneEntityInfo) {
|
||||||
sceneEntityAppearNotify := &proto.SceneEntityAppearNotify{
|
sceneEntityAppearNotify := &proto.SceneEntityAppearNotify{
|
||||||
AppearType: visionType,
|
AppearType: visionType,
|
||||||
EntityList: entityList,
|
EntityList: entityList,
|
||||||
@@ -376,7 +376,7 @@ func (g *GameManager) AddSceneEntityNotifyToPlayer(player *model.Player, visionT
|
|||||||
player.PlayerID, sceneEntityAppearNotify.AppearType, len(sceneEntityAppearNotify.EntityList))
|
player.PlayerID, sceneEntityAppearNotify.AppearType, len(sceneEntityAppearNotify.EntityList))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) AddSceneEntityNotifyBroadcast(player *model.Player, scene *Scene, visionType proto.VisionType, entityList []*proto.SceneEntityInfo, aec bool) {
|
func (g *Game) AddSceneEntityNotifyBroadcast(player *model.Player, scene *Scene, visionType proto.VisionType, entityList []*proto.SceneEntityInfo, aec bool) {
|
||||||
sceneEntityAppearNotify := &proto.SceneEntityAppearNotify{
|
sceneEntityAppearNotify := &proto.SceneEntityAppearNotify{
|
||||||
AppearType: visionType,
|
AppearType: visionType,
|
||||||
EntityList: entityList,
|
EntityList: entityList,
|
||||||
@@ -391,7 +391,7 @@ func (g *GameManager) AddSceneEntityNotifyBroadcast(player *model.Player, scene
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) RemoveSceneEntityNotifyToPlayer(player *model.Player, visionType proto.VisionType, entityIdList []uint32) {
|
func (g *Game) RemoveSceneEntityNotifyToPlayer(player *model.Player, visionType proto.VisionType, entityIdList []uint32) {
|
||||||
sceneEntityDisappearNotify := &proto.SceneEntityDisappearNotify{
|
sceneEntityDisappearNotify := &proto.SceneEntityDisappearNotify{
|
||||||
EntityList: entityIdList,
|
EntityList: entityIdList,
|
||||||
DisappearType: visionType,
|
DisappearType: visionType,
|
||||||
@@ -401,7 +401,7 @@ func (g *GameManager) RemoveSceneEntityNotifyToPlayer(player *model.Player, visi
|
|||||||
player.PlayerID, sceneEntityDisappearNotify.DisappearType, len(sceneEntityDisappearNotify.EntityList))
|
player.PlayerID, sceneEntityDisappearNotify.DisappearType, len(sceneEntityDisappearNotify.EntityList))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) RemoveSceneEntityNotifyBroadcast(scene *Scene, visionType proto.VisionType, entityIdList []uint32) {
|
func (g *Game) RemoveSceneEntityNotifyBroadcast(scene *Scene, visionType proto.VisionType, entityIdList []uint32) {
|
||||||
sceneEntityDisappearNotify := &proto.SceneEntityDisappearNotify{
|
sceneEntityDisappearNotify := &proto.SceneEntityDisappearNotify{
|
||||||
EntityList: entityIdList,
|
EntityList: entityIdList,
|
||||||
DisappearType: visionType,
|
DisappearType: visionType,
|
||||||
@@ -413,7 +413,7 @@ func (g *GameManager) RemoveSceneEntityNotifyBroadcast(scene *Scene, visionType
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) AddSceneEntityNotify(player *model.Player, visionType proto.VisionType, entityIdList []uint32, broadcast bool, aec bool) {
|
func (g *Game) AddSceneEntityNotify(player *model.Player, visionType proto.VisionType, entityIdList []uint32, broadcast bool, aec bool) {
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
scene := world.GetSceneById(player.SceneId)
|
scene := world.GetSceneById(player.SceneId)
|
||||||
if scene == nil {
|
if scene == nil {
|
||||||
@@ -471,7 +471,7 @@ func (g *GameManager) AddSceneEntityNotify(player *model.Player, visionType prot
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) EntityFightPropUpdateNotifyBroadcast(world *World, entity *Entity) {
|
func (g *Game) EntityFightPropUpdateNotifyBroadcast(world *World, entity *Entity) {
|
||||||
ntf := &proto.EntityFightPropUpdateNotify{
|
ntf := &proto.EntityFightPropUpdateNotify{
|
||||||
FightPropMap: entity.GetFightProp(),
|
FightPropMap: entity.GetFightProp(),
|
||||||
EntityId: entity.GetId(),
|
EntityId: entity.GetId(),
|
||||||
@@ -479,7 +479,7 @@ func (g *GameManager) EntityFightPropUpdateNotifyBroadcast(world *World, entity
|
|||||||
g.SendToWorldA(world, cmd.EntityFightPropUpdateNotify, 0, ntf)
|
g.SendToWorldA(world, cmd.EntityFightPropUpdateNotify, 0, ntf)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) KillPlayerAvatar(player *model.Player, dieType proto.PlayerDieType) {
|
func (g *Game) KillPlayerAvatar(player *model.Player, dieType proto.PlayerDieType) {
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
if world == nil {
|
if world == nil {
|
||||||
return
|
return
|
||||||
@@ -510,7 +510,7 @@ func (g *GameManager) KillPlayerAvatar(player *model.Player, dieType proto.Playe
|
|||||||
g.SendToWorldA(world, cmd.AvatarLifeStateChangeNotify, 0, ntf)
|
g.SendToWorldA(world, cmd.AvatarLifeStateChangeNotify, 0, ntf)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) RevivePlayerAvatar(player *model.Player) {
|
func (g *Game) RevivePlayerAvatar(player *model.Player) {
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
if world == nil {
|
if world == nil {
|
||||||
return
|
return
|
||||||
@@ -543,7 +543,7 @@ func (g *GameManager) RevivePlayerAvatar(player *model.Player) {
|
|||||||
g.SendToWorldA(world, cmd.AvatarLifeStateChangeNotify, 0, ntf)
|
g.SendToWorldA(world, cmd.AvatarLifeStateChangeNotify, 0, ntf)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) KillEntity(player *model.Player, scene *Scene, entityId uint32, dieType proto.PlayerDieType) {
|
func (g *Game) KillEntity(player *model.Player, scene *Scene, entityId uint32, dieType proto.PlayerDieType) {
|
||||||
entity := scene.GetEntity(entityId)
|
entity := scene.GetEntity(entityId)
|
||||||
if entity == nil {
|
if entity == nil {
|
||||||
return
|
return
|
||||||
@@ -552,8 +552,28 @@ func (g *GameManager) KillEntity(player *model.Player, scene *Scene, entityId ui
|
|||||||
// 设置血量
|
// 设置血量
|
||||||
entity.fightProp[constant.FIGHT_PROP_CUR_HP] = 0
|
entity.fightProp[constant.FIGHT_PROP_CUR_HP] = 0
|
||||||
g.EntityFightPropUpdateNotifyBroadcast(scene.world, entity)
|
g.EntityFightPropUpdateNotifyBroadcast(scene.world, entity)
|
||||||
// TODO
|
// 随机掉落
|
||||||
g.CreateDropGadget(player, entity.pos, 70600055, 104003, 10)
|
sceneGroupConfig := gdconf.GetSceneGroup(int32(entity.GetGroupId()))
|
||||||
|
monsterConfig := sceneGroupConfig.MonsterMap[int32(entity.GetConfigId())]
|
||||||
|
monsterDropDataConfig := gdconf.GetMonsterDropDataByDropTagAndLevel(monsterConfig.DropTag, monsterConfig.Level)
|
||||||
|
if monsterDropDataConfig == nil {
|
||||||
|
logger.Error("get monster drop data config is nil, monsterConfig: %v, uid: %v", monsterConfig, player.PlayerID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
dropDataConfig := gdconf.GetDropDataById(monsterDropDataConfig.DropId)
|
||||||
|
if dropDataConfig == nil {
|
||||||
|
logger.Error("get drop data config is nil, dropId: %v, uid: %v", monsterDropDataConfig.DropId, player.PlayerID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
totalItemMap := g.doRandDropFullTimes(dropDataConfig, int(monsterDropDataConfig.DropCount))
|
||||||
|
for itemId, count := range totalItemMap {
|
||||||
|
itemDataConfig := gdconf.GetItemDataById(int32(itemId))
|
||||||
|
if itemDataConfig == nil {
|
||||||
|
logger.Error("get item data config is nil, itemId: %v, uid: %v", itemId, player.PlayerID)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
g.CreateDropGadget(player, entity.pos, uint32(itemDataConfig.GadgetId), itemId, count)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
entity.lifeState = constant.LIFE_STATE_DEAD
|
entity.lifeState = constant.LIFE_STATE_DEAD
|
||||||
ntf := &proto.LifeStateChangeNotify{
|
ntf := &proto.LifeStateChangeNotify{
|
||||||
@@ -565,20 +585,20 @@ func (g *GameManager) KillEntity(player *model.Player, scene *Scene, entityId ui
|
|||||||
g.SendToWorldA(scene.world, cmd.LifeStateChangeNotify, 0, ntf)
|
g.SendToWorldA(scene.world, cmd.LifeStateChangeNotify, 0, ntf)
|
||||||
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_DIE, []uint32{entity.id})
|
g.RemoveSceneEntityNotifyBroadcast(scene, proto.VisionType_VISION_DIE, []uint32{entity.id})
|
||||||
// 删除实体
|
// 删除实体
|
||||||
|
scene.DestroyEntity(entity.GetId())
|
||||||
group := scene.GetGroupById(entity.groupId)
|
group := scene.GetGroupById(entity.groupId)
|
||||||
if group == nil {
|
if group == nil {
|
||||||
logger.Error("get scene group is nil, groupId: %v, uid: %v", entity.groupId, player.PlayerID)
|
logger.Error("get scene group is nil, groupId: %v, uid: %v", entity.groupId, player.PlayerID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
group.DestroyEntity(entity.GetId())
|
group.DestroyEntity(entity.GetId())
|
||||||
scene.DestroyEntity(entity.GetId())
|
|
||||||
// 怪物死亡触发器检测
|
// 怪物死亡触发器检测
|
||||||
if entity.GetEntityType() == constant.ENTITY_TYPE_MONSTER {
|
if entity.GetEntityType() == constant.ENTITY_TYPE_MONSTER {
|
||||||
g.MonsterDieTriggerCheck(player, entity.GetGroupId(), group)
|
g.MonsterDieTriggerCheck(player, entity.GetGroupId(), group)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) ChangeGadgetState(player *model.Player, entityId uint32, state uint32) {
|
func (g *Game) ChangeGadgetState(player *model.Player, entityId uint32, state uint32) {
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
if world == nil {
|
if world == nil {
|
||||||
logger.Error("get world is nil, worldId: %v", player.WorldId)
|
logger.Error("get world is nil, worldId: %v", player.WorldId)
|
||||||
@@ -604,7 +624,7 @@ func (g *GameManager) ChangeGadgetState(player *model.Player, entityId uint32, s
|
|||||||
g.SendMsg(cmd.GadgetStateNotify, player.PlayerID, player.ClientSeq, ntf)
|
g.SendMsg(cmd.GadgetStateNotify, player.PlayerID, player.ClientSeq, ntf)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) GetVisionEntity(scene *Scene, pos *model.Vector) map[uint32]*Entity {
|
func (g *Game) GetVisionEntity(scene *Scene, pos *model.Vector) map[uint32]*Entity {
|
||||||
visionEntity := make(map[uint32]*Entity)
|
visionEntity := make(map[uint32]*Entity)
|
||||||
for _, entity := range scene.GetAllEntity() {
|
for _, entity := range scene.GetAllEntity() {
|
||||||
if math.Abs(pos.X-entity.pos.X) > ENTITY_VISION_DISTANCE ||
|
if math.Abs(pos.X-entity.pos.X) > ENTITY_VISION_DISTANCE ||
|
||||||
@@ -616,7 +636,7 @@ func (g *GameManager) GetVisionEntity(scene *Scene, pos *model.Vector) map[uint3
|
|||||||
return visionEntity
|
return visionEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) GetNeighborGroup(sceneId uint32, pos *model.Vector) map[uint32]*gdconf.Group {
|
func (g *Game) GetNeighborGroup(sceneId uint32, pos *model.Vector) map[uint32]*gdconf.Group {
|
||||||
aoiManager, exist := WORLD_MANAGER.GetSceneBlockAoiMap()[sceneId]
|
aoiManager, exist := WORLD_MANAGER.GetSceneBlockAoiMap()[sceneId]
|
||||||
if !exist {
|
if !exist {
|
||||||
logger.Error("scene not exist in aoi, sceneId: %v", sceneId)
|
logger.Error("scene not exist in aoi, sceneId: %v", sceneId)
|
||||||
@@ -638,7 +658,7 @@ func (g *GameManager) GetNeighborGroup(sceneId uint32, pos *model.Vector) map[ui
|
|||||||
return neighborGroup
|
return neighborGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) AddSceneGroup(player *model.Player, scene *Scene, groupConfig *gdconf.Group) {
|
func (g *Game) AddSceneGroup(player *model.Player, scene *Scene, groupConfig *gdconf.Group) {
|
||||||
initSuiteId := int(groupConfig.GroupInitConfig.Suite)
|
initSuiteId := int(groupConfig.GroupInitConfig.Suite)
|
||||||
if initSuiteId < 1 || initSuiteId > len(groupConfig.SuiteList) {
|
if initSuiteId < 1 || initSuiteId > len(groupConfig.SuiteList) {
|
||||||
logger.Error("invalid init suite id: %v, uid: %v", initSuiteId, player.PlayerID)
|
logger.Error("invalid init suite id: %v, uid: %v", initSuiteId, player.PlayerID)
|
||||||
@@ -652,7 +672,7 @@ func (g *GameManager) AddSceneGroup(player *model.Player, scene *Scene, groupCon
|
|||||||
g.SendMsg(cmd.GroupSuiteNotify, player.PlayerID, player.ClientSeq, ntf)
|
g.SendMsg(cmd.GroupSuiteNotify, player.PlayerID, player.ClientSeq, ntf)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) RemoveSceneGroup(player *model.Player, scene *Scene, groupConfig *gdconf.Group) {
|
func (g *Game) RemoveSceneGroup(player *model.Player, scene *Scene, groupConfig *gdconf.Group) {
|
||||||
group := scene.GetGroupById(uint32(groupConfig.Id))
|
group := scene.GetGroupById(uint32(groupConfig.Id))
|
||||||
if group == nil {
|
if group == nil {
|
||||||
logger.Error("group not exist, groupId: %v, uid: %v", groupConfig.Id, player.PlayerID)
|
logger.Error("group not exist, groupId: %v, uid: %v", groupConfig.Id, player.PlayerID)
|
||||||
@@ -668,15 +688,13 @@ func (g *GameManager) RemoveSceneGroup(player *model.Player, scene *Scene, group
|
|||||||
g.SendMsg(cmd.GroupUnloadNotify, player.PlayerID, player.ClientSeq, ntf)
|
g.SendMsg(cmd.GroupUnloadNotify, player.PlayerID, player.ClientSeq, ntf)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) CreateDropGadget(player *model.Player, pos *model.Vector, gadgetId, itemId, count uint32) {
|
func (g *Game) CreateDropGadget(player *model.Player, pos *model.Vector, gadgetId, itemId, count uint32) {
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
if world == nil {
|
if world == nil {
|
||||||
logger.Error("get world is nil, worldId: %v", player.WorldId)
|
logger.Error("get world is nil, worldId: %v", player.WorldId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
scene := world.GetSceneById(player.SceneId)
|
scene := world.GetSceneById(player.SceneId)
|
||||||
pos.X += random.GetRandomFloat64(-5.0, 5.0)
|
|
||||||
pos.Z += random.GetRandomFloat64(-5.0, 5.0)
|
|
||||||
rot := new(model.Vector)
|
rot := new(model.Vector)
|
||||||
rot.Y = random.GetRandomFloat64(0.0, 360.0)
|
rot.Y = random.GetRandomFloat64(0.0, 360.0)
|
||||||
entityId := scene.CreateEntityGadgetNormal(
|
entityId := scene.CreateEntityGadgetNormal(
|
||||||
@@ -695,7 +713,7 @@ func (g *GameManager) CreateDropGadget(player *model.Player, pos *model.Vector,
|
|||||||
|
|
||||||
var SceneTransactionSeq uint32 = 0
|
var SceneTransactionSeq uint32 = 0
|
||||||
|
|
||||||
func (g *GameManager) PacketPlayerEnterSceneNotifyLogin(player *model.Player, enterType proto.EnterType) *proto.PlayerEnterSceneNotify {
|
func (g *Game) PacketPlayerEnterSceneNotifyLogin(player *model.Player, enterType proto.EnterType) *proto.PlayerEnterSceneNotify {
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
if world == nil {
|
if world == nil {
|
||||||
logger.Error("get world is nil, worldId: %v", player.WorldId)
|
logger.Error("get world is nil, worldId: %v", player.WorldId)
|
||||||
@@ -732,7 +750,7 @@ func (g *GameManager) PacketPlayerEnterSceneNotifyLogin(player *model.Player, en
|
|||||||
return playerEnterSceneNotify
|
return playerEnterSceneNotify
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PacketPlayerEnterSceneNotifyTp(
|
func (g *Game) PacketPlayerEnterSceneNotifyTp(
|
||||||
player *model.Player,
|
player *model.Player,
|
||||||
enterType proto.EnterType,
|
enterType proto.EnterType,
|
||||||
enterReason uint32,
|
enterReason uint32,
|
||||||
@@ -743,7 +761,7 @@ func (g *GameManager) PacketPlayerEnterSceneNotifyTp(
|
|||||||
return g.PacketPlayerEnterSceneNotifyMp(player, player, enterType, enterReason, prevSceneId, prevPos, dungeonId)
|
return g.PacketPlayerEnterSceneNotifyMp(player, player, enterType, enterReason, prevSceneId, prevPos, dungeonId)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PacketPlayerEnterSceneNotifyMp(
|
func (g *Game) PacketPlayerEnterSceneNotifyMp(
|
||||||
player *model.Player,
|
player *model.Player,
|
||||||
targetPlayer *model.Player,
|
targetPlayer *model.Player,
|
||||||
enterType proto.EnterType,
|
enterType proto.EnterType,
|
||||||
@@ -800,7 +818,7 @@ func (g *GameManager) PacketPlayerEnterSceneNotifyMp(
|
|||||||
return playerEnterSceneNotify
|
return playerEnterSceneNotify
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PacketFightPropMapToPbFightPropList(fightPropMap map[uint32]float32) []*proto.FightPropPair {
|
func (g *Game) PacketFightPropMapToPbFightPropList(fightPropMap map[uint32]float32) []*proto.FightPropPair {
|
||||||
fightPropList := []*proto.FightPropPair{
|
fightPropList := []*proto.FightPropPair{
|
||||||
{PropType: constant.FIGHT_PROP_BASE_HP, PropValue: fightPropMap[constant.FIGHT_PROP_BASE_HP]},
|
{PropType: constant.FIGHT_PROP_BASE_HP, PropValue: fightPropMap[constant.FIGHT_PROP_BASE_HP]},
|
||||||
{PropType: constant.FIGHT_PROP_BASE_ATTACK, PropValue: fightPropMap[constant.FIGHT_PROP_BASE_ATTACK]},
|
{PropType: constant.FIGHT_PROP_BASE_ATTACK, PropValue: fightPropMap[constant.FIGHT_PROP_BASE_ATTACK]},
|
||||||
@@ -816,7 +834,7 @@ func (g *GameManager) PacketFightPropMapToPbFightPropList(fightPropMap map[uint3
|
|||||||
return fightPropList
|
return fightPropList
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PacketSceneEntityInfoAvatar(scene *Scene, player *model.Player, avatarId uint32) *proto.SceneEntityInfo {
|
func (g *Game) PacketSceneEntityInfoAvatar(scene *Scene, player *model.Player, avatarId uint32) *proto.SceneEntityInfo {
|
||||||
entity := scene.GetEntity(scene.GetWorld().GetPlayerWorldAvatarEntityId(player, avatarId))
|
entity := scene.GetEntity(scene.GetWorld().GetPlayerWorldAvatarEntityId(player, avatarId))
|
||||||
if entity == nil {
|
if entity == nil {
|
||||||
return new(proto.SceneEntityInfo)
|
return new(proto.SceneEntityInfo)
|
||||||
@@ -912,7 +930,7 @@ func (g *GameManager) PacketSceneEntityInfoAvatar(scene *Scene, player *model.Pl
|
|||||||
return sceneEntityInfo
|
return sceneEntityInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PacketSceneEntityInfoMonster(scene *Scene, entityId uint32) *proto.SceneEntityInfo {
|
func (g *Game) PacketSceneEntityInfoMonster(scene *Scene, entityId uint32) *proto.SceneEntityInfo {
|
||||||
entity := scene.GetEntity(entityId)
|
entity := scene.GetEntity(entityId)
|
||||||
if entity == nil {
|
if entity == nil {
|
||||||
return new(proto.SceneEntityInfo)
|
return new(proto.SceneEntityInfo)
|
||||||
@@ -960,7 +978,7 @@ func (g *GameManager) PacketSceneEntityInfoMonster(scene *Scene, entityId uint32
|
|||||||
return sceneEntityInfo
|
return sceneEntityInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PacketSceneEntityInfoNpc(scene *Scene, entityId uint32) *proto.SceneEntityInfo {
|
func (g *Game) PacketSceneEntityInfoNpc(scene *Scene, entityId uint32) *proto.SceneEntityInfo {
|
||||||
entity := scene.GetEntity(entityId)
|
entity := scene.GetEntity(entityId)
|
||||||
if entity == nil {
|
if entity == nil {
|
||||||
return new(proto.SceneEntityInfo)
|
return new(proto.SceneEntityInfo)
|
||||||
@@ -1008,7 +1026,7 @@ func (g *GameManager) PacketSceneEntityInfoNpc(scene *Scene, entityId uint32) *p
|
|||||||
return sceneEntityInfo
|
return sceneEntityInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PacketSceneEntityInfoGadget(player *model.Player, scene *Scene, entityId uint32) *proto.SceneEntityInfo {
|
func (g *Game) PacketSceneEntityInfoGadget(player *model.Player, scene *Scene, entityId uint32) *proto.SceneEntityInfo {
|
||||||
entity := scene.GetEntity(entityId)
|
entity := scene.GetEntity(entityId)
|
||||||
if entity == nil {
|
if entity == nil {
|
||||||
return new(proto.SceneEntityInfo)
|
return new(proto.SceneEntityInfo)
|
||||||
@@ -1068,7 +1086,7 @@ func (g *GameManager) PacketSceneEntityInfoGadget(player *model.Player, scene *S
|
|||||||
return sceneEntityInfo
|
return sceneEntityInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PacketSceneAvatarInfo(scene *Scene, player *model.Player, avatarId uint32) *proto.SceneAvatarInfo {
|
func (g *Game) PacketSceneAvatarInfo(scene *Scene, player *model.Player, avatarId uint32) *proto.SceneAvatarInfo {
|
||||||
dbAvatar := player.GetDbAvatar()
|
dbAvatar := player.GetDbAvatar()
|
||||||
avatar, ok := dbAvatar.AvatarMap[avatarId]
|
avatar, ok := dbAvatar.AvatarMap[avatarId]
|
||||||
if !ok {
|
if !ok {
|
||||||
@@ -1118,7 +1136,7 @@ func (g *GameManager) PacketSceneAvatarInfo(scene *Scene, player *model.Player,
|
|||||||
return sceneAvatarInfo
|
return sceneAvatarInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PacketSceneMonsterInfo(entity *Entity) *proto.SceneMonsterInfo {
|
func (g *Game) PacketSceneMonsterInfo(entity *Entity) *proto.SceneMonsterInfo {
|
||||||
sceneMonsterInfo := &proto.SceneMonsterInfo{
|
sceneMonsterInfo := &proto.SceneMonsterInfo{
|
||||||
MonsterId: entity.GetMonsterEntity().GetMonsterId(),
|
MonsterId: entity.GetMonsterEntity().GetMonsterId(),
|
||||||
AuthorityPeerId: 1,
|
AuthorityPeerId: 1,
|
||||||
@@ -1130,7 +1148,7 @@ func (g *GameManager) PacketSceneMonsterInfo(entity *Entity) *proto.SceneMonster
|
|||||||
return sceneMonsterInfo
|
return sceneMonsterInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PacketSceneNpcInfo(entity *NpcEntity) *proto.SceneNpcInfo {
|
func (g *Game) PacketSceneNpcInfo(entity *NpcEntity) *proto.SceneNpcInfo {
|
||||||
sceneNpcInfo := &proto.SceneNpcInfo{
|
sceneNpcInfo := &proto.SceneNpcInfo{
|
||||||
NpcId: entity.NpcId,
|
NpcId: entity.NpcId,
|
||||||
RoomId: entity.RoomId,
|
RoomId: entity.RoomId,
|
||||||
@@ -1140,7 +1158,7 @@ func (g *GameManager) PacketSceneNpcInfo(entity *NpcEntity) *proto.SceneNpcInfo
|
|||||||
return sceneNpcInfo
|
return sceneNpcInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PacketSceneGadgetInfoNormal(player *model.Player, entity *Entity) *proto.SceneGadgetInfo {
|
func (g *Game) PacketSceneGadgetInfoNormal(player *model.Player, entity *Entity) *proto.SceneGadgetInfo {
|
||||||
gadgetEntity := entity.GetGadgetEntity()
|
gadgetEntity := entity.GetGadgetEntity()
|
||||||
gadgetDataConfig := gdconf.GetGadgetDataById(int32(gadgetEntity.GetGadgetId()))
|
gadgetDataConfig := gdconf.GetGadgetDataById(int32(gadgetEntity.GetGadgetId()))
|
||||||
if gadgetDataConfig == nil {
|
if gadgetDataConfig == nil {
|
||||||
@@ -1180,7 +1198,7 @@ func (g *GameManager) PacketSceneGadgetInfoNormal(player *model.Player, entity *
|
|||||||
return sceneGadgetInfo
|
return sceneGadgetInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PacketSceneGadgetInfoClient(gadgetClientEntity *GadgetClientEntity) *proto.SceneGadgetInfo {
|
func (g *Game) PacketSceneGadgetInfoClient(gadgetClientEntity *GadgetClientEntity) *proto.SceneGadgetInfo {
|
||||||
sceneGadgetInfo := &proto.SceneGadgetInfo{
|
sceneGadgetInfo := &proto.SceneGadgetInfo{
|
||||||
GadgetId: gadgetClientEntity.GetConfigId(),
|
GadgetId: gadgetClientEntity.GetConfigId(),
|
||||||
OwnerEntityId: gadgetClientEntity.GetOwnerEntityId(),
|
OwnerEntityId: gadgetClientEntity.GetOwnerEntityId(),
|
||||||
@@ -1199,7 +1217,7 @@ func (g *GameManager) PacketSceneGadgetInfoClient(gadgetClientEntity *GadgetClie
|
|||||||
return sceneGadgetInfo
|
return sceneGadgetInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PacketSceneGadgetInfoVehicle(gadgetVehicleEntity *GadgetVehicleEntity) *proto.SceneGadgetInfo {
|
func (g *Game) PacketSceneGadgetInfoVehicle(gadgetVehicleEntity *GadgetVehicleEntity) *proto.SceneGadgetInfo {
|
||||||
sceneGadgetInfo := &proto.SceneGadgetInfo{
|
sceneGadgetInfo := &proto.SceneGadgetInfo{
|
||||||
GadgetId: gadgetVehicleEntity.GetVehicleId(),
|
GadgetId: gadgetVehicleEntity.GetVehicleId(),
|
||||||
AuthorityPeerId: WORLD_MANAGER.GetWorldByID(gadgetVehicleEntity.GetOwner().WorldId).GetPlayerPeerId(gadgetVehicleEntity.GetOwner()),
|
AuthorityPeerId: WORLD_MANAGER.GetWorldByID(gadgetVehicleEntity.GetOwner().WorldId).GetPlayerPeerId(gadgetVehicleEntity.GetOwner()),
|
||||||
@@ -1215,7 +1233,7 @@ func (g *GameManager) PacketSceneGadgetInfoVehicle(gadgetVehicleEntity *GadgetVe
|
|||||||
return sceneGadgetInfo
|
return sceneGadgetInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PacketDelTeamEntityNotify(scene *Scene, player *model.Player) *proto.DelTeamEntityNotify {
|
func (g *Game) PacketDelTeamEntityNotify(scene *Scene, player *model.Player) *proto.DelTeamEntityNotify {
|
||||||
delTeamEntityNotify := &proto.DelTeamEntityNotify{
|
delTeamEntityNotify := &proto.DelTeamEntityNotify{
|
||||||
SceneId: player.SceneId,
|
SceneId: player.SceneId,
|
||||||
DelEntityIdList: []uint32{scene.GetWorld().GetPlayerTeamEntityId(player)},
|
DelEntityIdList: []uint32{scene.GetWorld().GetPlayerTeamEntityId(player)},
|
||||||
|
|||||||
@@ -10,14 +10,14 @@ import (
|
|||||||
pb "google.golang.org/protobuf/proto"
|
pb "google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (g *GameManager) GetShopmallDataReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) GetShopmallDataReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
getShopmallDataRsp := &proto.GetShopmallDataRsp{
|
getShopmallDataRsp := &proto.GetShopmallDataRsp{
|
||||||
ShopTypeList: []uint32{900, 1052, 902, 1001, 903},
|
ShopTypeList: []uint32{900, 1052, 902, 1001, 903},
|
||||||
}
|
}
|
||||||
g.SendMsg(cmd.GetShopmallDataRsp, player.PlayerID, player.ClientSeq, getShopmallDataRsp)
|
g.SendMsg(cmd.GetShopmallDataRsp, player.PlayerID, player.ClientSeq, getShopmallDataRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) GetShopReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) GetShopReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.GetShopReq)
|
req := payloadMsg.(*proto.GetShopReq)
|
||||||
shopType := req.ShopType
|
shopType := req.ShopType
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ func (g *GameManager) GetShopReq(player *model.Player, payloadMsg pb.Message) {
|
|||||||
g.SendMsg(cmd.GetShopRsp, player.PlayerID, player.ClientSeq, getShopRsp)
|
g.SendMsg(cmd.GetShopRsp, player.PlayerID, player.ClientSeq, getShopRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) BuyGoodsReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) BuyGoodsReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.BuyGoodsReq)
|
req := payloadMsg.(*proto.BuyGoodsReq)
|
||||||
buyItemId := req.Goods.GoodsItem.ItemId
|
buyItemId := req.Goods.GoodsItem.ItemId
|
||||||
buyItemCount := req.BuyCount
|
buyItemCount := req.BuyCount
|
||||||
@@ -96,7 +96,7 @@ func (g *GameManager) BuyGoodsReq(player *model.Player, payloadMsg pb.Message) {
|
|||||||
g.SendMsg(cmd.BuyGoodsRsp, player.PlayerID, player.ClientSeq, buyGoodsRsp)
|
g.SendMsg(cmd.BuyGoodsRsp, player.PlayerID, player.ClientSeq, buyGoodsRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) McoinExchangeHcoinReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) McoinExchangeHcoinReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.McoinExchangeHcoinReq)
|
req := payloadMsg.(*proto.McoinExchangeHcoinReq)
|
||||||
if req.Hcoin != req.McoinCost {
|
if req.Hcoin != req.McoinCost {
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import (
|
|||||||
pb "google.golang.org/protobuf/proto"
|
pb "google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (g *GameManager) GetPlayerSocialDetailReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) GetPlayerSocialDetailReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.GetPlayerSocialDetailReq)
|
req := payloadMsg.(*proto.GetPlayerSocialDetailReq)
|
||||||
targetUid := req.Uid
|
targetUid := req.Uid
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ func (g *GameManager) GetPlayerSocialDetailReq(player *model.Player, payloadMsg
|
|||||||
g.SendMsg(cmd.GetPlayerSocialDetailRsp, player.PlayerID, player.ClientSeq, getPlayerSocialDetailRsp)
|
g.SendMsg(cmd.GetPlayerSocialDetailRsp, player.PlayerID, player.ClientSeq, getPlayerSocialDetailRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) SetPlayerBirthdayReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) SetPlayerBirthdayReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.SetPlayerBirthdayReq)
|
req := payloadMsg.(*proto.SetPlayerBirthdayReq)
|
||||||
if player.Birthday[0] != 0 || player.Birthday[1] != 0 {
|
if player.Birthday[0] != 0 || player.Birthday[1] != 0 {
|
||||||
g.SendError(cmd.SetPlayerBirthdayRsp, player, &proto.SetPlayerBirthdayRsp{})
|
g.SendError(cmd.SetPlayerBirthdayRsp, player, &proto.SetPlayerBirthdayRsp{})
|
||||||
@@ -61,7 +61,7 @@ func (g *GameManager) SetPlayerBirthdayReq(player *model.Player, payloadMsg pb.M
|
|||||||
g.SendMsg(cmd.SetPlayerBirthdayRsp, player.PlayerID, player.ClientSeq, setPlayerBirthdayRsp)
|
g.SendMsg(cmd.SetPlayerBirthdayRsp, player.PlayerID, player.ClientSeq, setPlayerBirthdayRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) SetNameCardReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) SetNameCardReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.SetNameCardReq)
|
req := payloadMsg.(*proto.SetNameCardReq)
|
||||||
nameCardId := req.NameCardId
|
nameCardId := req.NameCardId
|
||||||
exist := false
|
exist := false
|
||||||
@@ -82,7 +82,7 @@ func (g *GameManager) SetNameCardReq(player *model.Player, payloadMsg pb.Message
|
|||||||
g.SendMsg(cmd.SetNameCardRsp, player.PlayerID, player.ClientSeq, setNameCardRsp)
|
g.SendMsg(cmd.SetNameCardRsp, player.PlayerID, player.ClientSeq, setNameCardRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) SetPlayerSignatureReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) SetPlayerSignatureReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.SetPlayerSignatureReq)
|
req := payloadMsg.(*proto.SetPlayerSignatureReq)
|
||||||
signature := req.Signature
|
signature := req.Signature
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ func (g *GameManager) SetPlayerSignatureReq(player *model.Player, payloadMsg pb.
|
|||||||
g.SendMsg(cmd.SetPlayerSignatureRsp, player.PlayerID, player.ClientSeq, setPlayerSignatureRsp)
|
g.SendMsg(cmd.SetPlayerSignatureRsp, player.PlayerID, player.ClientSeq, setPlayerSignatureRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) SetPlayerNameReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) SetPlayerNameReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.SetPlayerNameReq)
|
req := payloadMsg.(*proto.SetPlayerNameReq)
|
||||||
nickName := req.NickName
|
nickName := req.NickName
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ func (g *GameManager) SetPlayerNameReq(player *model.Player, payloadMsg pb.Messa
|
|||||||
g.SendMsg(cmd.SetPlayerNameRsp, player.PlayerID, player.ClientSeq, setPlayerNameRsp)
|
g.SendMsg(cmd.SetPlayerNameRsp, player.PlayerID, player.ClientSeq, setPlayerNameRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) SetPlayerHeadImageReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) SetPlayerHeadImageReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.SetPlayerHeadImageReq)
|
req := payloadMsg.(*proto.SetPlayerHeadImageReq)
|
||||||
avatarId := req.AvatarId
|
avatarId := req.AvatarId
|
||||||
dbAvatar := player.GetDbAvatar()
|
dbAvatar := player.GetDbAvatar()
|
||||||
@@ -135,14 +135,14 @@ func (g *GameManager) SetPlayerHeadImageReq(player *model.Player, payloadMsg pb.
|
|||||||
g.SendMsg(cmd.SetPlayerHeadImageRsp, player.PlayerID, player.ClientSeq, setPlayerHeadImageRsp)
|
g.SendMsg(cmd.SetPlayerHeadImageRsp, player.PlayerID, player.ClientSeq, setPlayerHeadImageRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) GetAllUnlockNameCardReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) GetAllUnlockNameCardReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
getAllUnlockNameCardRsp := &proto.GetAllUnlockNameCardRsp{
|
getAllUnlockNameCardRsp := &proto.GetAllUnlockNameCardRsp{
|
||||||
NameCardList: player.NameCardList,
|
NameCardList: player.NameCardList,
|
||||||
}
|
}
|
||||||
g.SendMsg(cmd.GetAllUnlockNameCardRsp, player.PlayerID, player.ClientSeq, getAllUnlockNameCardRsp)
|
g.SendMsg(cmd.GetAllUnlockNameCardRsp, player.PlayerID, player.ClientSeq, getAllUnlockNameCardRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) GetPlayerFriendListReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) GetPlayerFriendListReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
getPlayerFriendListRsp := &proto.GetPlayerFriendListRsp{
|
getPlayerFriendListRsp := &proto.GetPlayerFriendListRsp{
|
||||||
FriendList: make([]*proto.FriendBrief, 0),
|
FriendList: make([]*proto.FriendBrief, 0),
|
||||||
}
|
}
|
||||||
@@ -183,7 +183,7 @@ func (g *GameManager) GetPlayerFriendListReq(player *model.Player, payloadMsg pb
|
|||||||
g.SendMsg(cmd.GetPlayerFriendListRsp, player.PlayerID, player.ClientSeq, getPlayerFriendListRsp)
|
g.SendMsg(cmd.GetPlayerFriendListRsp, player.PlayerID, player.ClientSeq, getPlayerFriendListRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) GetPlayerAskFriendListReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) GetPlayerAskFriendListReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
getPlayerAskFriendListRsp := &proto.GetPlayerAskFriendListRsp{
|
getPlayerAskFriendListRsp := &proto.GetPlayerAskFriendListRsp{
|
||||||
AskFriendList: make([]*proto.FriendBrief, 0),
|
AskFriendList: make([]*proto.FriendBrief, 0),
|
||||||
}
|
}
|
||||||
@@ -219,7 +219,7 @@ func (g *GameManager) GetPlayerAskFriendListReq(player *model.Player, payloadMsg
|
|||||||
g.SendMsg(cmd.GetPlayerAskFriendListRsp, player.PlayerID, player.ClientSeq, getPlayerAskFriendListRsp)
|
g.SendMsg(cmd.GetPlayerAskFriendListRsp, player.PlayerID, player.ClientSeq, getPlayerAskFriendListRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) AskAddFriendReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) AskAddFriendReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.AskAddFriendReq)
|
req := payloadMsg.(*proto.AskAddFriendReq)
|
||||||
targetUid := req.TargetUid
|
targetUid := req.TargetUid
|
||||||
|
|
||||||
@@ -305,7 +305,7 @@ func (g *GameManager) AskAddFriendReq(player *model.Player, payloadMsg pb.Messag
|
|||||||
g.SendMsg(cmd.AskAddFriendNotify, targetPlayer.PlayerID, targetPlayer.ClientSeq, askAddFriendNotify)
|
g.SendMsg(cmd.AskAddFriendNotify, targetPlayer.PlayerID, targetPlayer.ClientSeq, askAddFriendNotify)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) DealAddFriendReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) DealAddFriendReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.DealAddFriendReq)
|
req := payloadMsg.(*proto.DealAddFriendReq)
|
||||||
targetUid := req.TargetUid
|
targetUid := req.TargetUid
|
||||||
result := req.DealAddFriendResult
|
result := req.DealAddFriendResult
|
||||||
@@ -364,7 +364,7 @@ func (g *GameManager) DealAddFriendReq(player *model.Player, payloadMsg pb.Messa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) GetOnlinePlayerListReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) GetOnlinePlayerListReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
count := 0
|
count := 0
|
||||||
getOnlinePlayerListRsp := &proto.GetOnlinePlayerListRsp{
|
getOnlinePlayerListRsp := &proto.GetOnlinePlayerListRsp{
|
||||||
PlayerInfoList: make([]*proto.OnlinePlayerInfo, 0),
|
PlayerInfoList: make([]*proto.OnlinePlayerInfo, 0),
|
||||||
@@ -416,7 +416,7 @@ func (g *GameManager) GetOnlinePlayerListReq(player *model.Player, payloadMsg pb
|
|||||||
g.SendMsg(cmd.GetOnlinePlayerListRsp, player.PlayerID, player.ClientSeq, getOnlinePlayerListRsp)
|
g.SendMsg(cmd.GetOnlinePlayerListRsp, player.PlayerID, player.ClientSeq, getOnlinePlayerListRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) GetOnlinePlayerInfoReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) GetOnlinePlayerInfoReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.GetOnlinePlayerInfoReq)
|
req := payloadMsg.(*proto.GetOnlinePlayerInfoReq)
|
||||||
targetUid, ok := req.PlayerId.(*proto.GetOnlinePlayerInfoReq_TargetUid)
|
targetUid, ok := req.PlayerId.(*proto.GetOnlinePlayerInfoReq_TargetUid)
|
||||||
if !ok {
|
if !ok {
|
||||||
@@ -435,7 +435,7 @@ func (g *GameManager) GetOnlinePlayerInfoReq(player *model.Player, payloadMsg pb
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PacketOnlinePlayerInfo(player *model.Player) *proto.OnlinePlayerInfo {
|
func (g *Game) PacketOnlinePlayerInfo(player *model.Player) *proto.OnlinePlayerInfo {
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
worldPlayerNum := uint32(1)
|
worldPlayerNum := uint32(1)
|
||||||
// TODO 远程玩家的世界内人数
|
// TODO 远程玩家的世界内人数
|
||||||
@@ -457,7 +457,7 @@ func (g *GameManager) PacketOnlinePlayerInfo(player *model.Player) *proto.Online
|
|||||||
|
|
||||||
// 跨服添加好友通知
|
// 跨服添加好友通知
|
||||||
|
|
||||||
func (g *GameManager) ServerAddFriendNotify(addFriendInfo *mq.AddFriendInfo) {
|
func (g *Game) ServerAddFriendNotify(addFriendInfo *mq.AddFriendInfo) {
|
||||||
switch addFriendInfo.OriginInfo.CmdName {
|
switch addFriendInfo.OriginInfo.CmdName {
|
||||||
case "AskAddFriendReq":
|
case "AskAddFriendReq":
|
||||||
targetPlayer := USER_MANAGER.GetOnlineUser(addFriendInfo.TargetUserId)
|
targetPlayer := USER_MANAGER.GetOnlineUser(addFriendInfo.TargetUserId)
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// HandleAbilityStamina 处理来自ability的耐力消耗
|
// HandleAbilityStamina 处理来自ability的耐力消耗
|
||||||
func (g *GameManager) HandleAbilityStamina(player *model.Player, entry *proto.AbilityInvokeEntry) {
|
func (g *Game) HandleAbilityStamina(player *model.Player, entry *proto.AbilityInvokeEntry) {
|
||||||
switch entry.ArgumentType {
|
switch entry.ArgumentType {
|
||||||
case proto.AbilityInvokeArgument_ABILITY_MIXIN_COST_STAMINA:
|
case proto.AbilityInvokeArgument_ABILITY_MIXIN_COST_STAMINA:
|
||||||
// 大剑重击 或 持续技能 耐力消耗
|
// 大剑重击 或 持续技能 耐力消耗
|
||||||
@@ -77,7 +77,7 @@ func (g *GameManager) HandleAbilityStamina(player *model.Player, entry *proto.Ab
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SceneAvatarStaminaStepReq 缓慢游泳或缓慢攀爬时消耗耐力
|
// SceneAvatarStaminaStepReq 缓慢游泳或缓慢攀爬时消耗耐力
|
||||||
func (g *GameManager) SceneAvatarStaminaStepReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) SceneAvatarStaminaStepReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.SceneAvatarStaminaStepReq)
|
req := payloadMsg.(*proto.SceneAvatarStaminaStepReq)
|
||||||
|
|
||||||
// 根据动作状态消耗耐力
|
// 根据动作状态消耗耐力
|
||||||
@@ -122,7 +122,7 @@ func (g *GameManager) SceneAvatarStaminaStepReq(player *model.Player, payloadMsg
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ImmediateStamina 处理即时耐力消耗
|
// ImmediateStamina 处理即时耐力消耗
|
||||||
func (g *GameManager) ImmediateStamina(player *model.Player, motionState proto.MotionState) {
|
func (g *Game) ImmediateStamina(player *model.Player, motionState proto.MotionState) {
|
||||||
// 玩家暂停状态不更新耐力
|
// 玩家暂停状态不更新耐力
|
||||||
if player.Pause {
|
if player.Pause {
|
||||||
return
|
return
|
||||||
@@ -159,7 +159,7 @@ func (g *GameManager) ImmediateStamina(player *model.Player, motionState proto.M
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SkillSustainStamina 处理技能持续时的耐力消耗
|
// SkillSustainStamina 处理技能持续时的耐力消耗
|
||||||
func (g *GameManager) SkillSustainStamina(player *model.Player, isSwim bool) {
|
func (g *Game) SkillSustainStamina(player *model.Player, isSwim bool) {
|
||||||
staminaInfo := player.StaminaInfo
|
staminaInfo := player.StaminaInfo
|
||||||
skillId := staminaInfo.LastSkillId
|
skillId := staminaInfo.LastSkillId
|
||||||
|
|
||||||
@@ -210,7 +210,7 @@ func (g *GameManager) SkillSustainStamina(player *model.Player, isSwim bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ChargedAttackStamina 处理重击技能即时耐力消耗
|
// ChargedAttackStamina 处理重击技能即时耐力消耗
|
||||||
func (g *GameManager) ChargedAttackStamina(player *model.Player, worldAvatar *WorldAvatar, skillData *gdconf.AvatarSkillData) {
|
func (g *Game) ChargedAttackStamina(player *model.Player, worldAvatar *WorldAvatar, skillData *gdconf.AvatarSkillData) {
|
||||||
// 确保技能为重击
|
// 确保技能为重击
|
||||||
if !strings.Contains(skillData.AbilityName, "ExtraAttack") {
|
if !strings.Contains(skillData.AbilityName, "ExtraAttack") {
|
||||||
return
|
return
|
||||||
@@ -250,7 +250,7 @@ func (g *GameManager) ChargedAttackStamina(player *model.Player, worldAvatar *Wo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SkillStartStamina 处理技能开始时的即时耐力消耗
|
// SkillStartStamina 处理技能开始时的即时耐力消耗
|
||||||
func (g *GameManager) SkillStartStamina(player *model.Player, casterId uint32, skillId uint32) {
|
func (g *Game) SkillStartStamina(player *model.Player, casterId uint32, skillId uint32) {
|
||||||
staminaInfo := player.StaminaInfo
|
staminaInfo := player.StaminaInfo
|
||||||
|
|
||||||
// 获取该技能开始时所需消耗的耐力
|
// 获取该技能开始时所需消耗的耐力
|
||||||
@@ -276,7 +276,7 @@ func (g *GameManager) SkillStartStamina(player *model.Player, casterId uint32, s
|
|||||||
}
|
}
|
||||||
|
|
||||||
// VehicleRestoreStaminaHandler 处理载具持续回复耐力
|
// VehicleRestoreStaminaHandler 处理载具持续回复耐力
|
||||||
func (g *GameManager) VehicleRestoreStaminaHandler(player *model.Player) {
|
func (g *Game) VehicleRestoreStaminaHandler(player *model.Player) {
|
||||||
// 玩家暂停状态不更新耐力
|
// 玩家暂停状态不更新耐力
|
||||||
if player.Pause {
|
if player.Pause {
|
||||||
return
|
return
|
||||||
@@ -307,7 +307,7 @@ func (g *GameManager) VehicleRestoreStaminaHandler(player *model.Player) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SustainStaminaHandler 处理持续耐力消耗
|
// SustainStaminaHandler 处理持续耐力消耗
|
||||||
func (g *GameManager) SustainStaminaHandler(player *model.Player) {
|
func (g *Game) SustainStaminaHandler(player *model.Player) {
|
||||||
// 玩家暂停状态不更新耐力
|
// 玩家暂停状态不更新耐力
|
||||||
if player.Pause {
|
if player.Pause {
|
||||||
return
|
return
|
||||||
@@ -337,7 +337,7 @@ func (g *GameManager) SustainStaminaHandler(player *model.Player) {
|
|||||||
|
|
||||||
// GetChangeStamina 获取变更的耐力
|
// GetChangeStamina 获取变更的耐力
|
||||||
// 当前耐力值 + 消耗的耐力值
|
// 当前耐力值 + 消耗的耐力值
|
||||||
func (g *GameManager) GetChangeStamina(curStamina int32, maxStamina int32, staminaCost int32) uint32 {
|
func (g *Game) GetChangeStamina(curStamina int32, maxStamina int32, staminaCost int32) uint32 {
|
||||||
// 即将更改为的耐力值
|
// 即将更改为的耐力值
|
||||||
stamina := curStamina + staminaCost
|
stamina := curStamina + staminaCost
|
||||||
|
|
||||||
@@ -351,7 +351,7 @@ func (g *GameManager) GetChangeStamina(curStamina int32, maxStamina int32, stami
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateVehicleStamina 更新载具耐力
|
// UpdateVehicleStamina 更新载具耐力
|
||||||
func (g *GameManager) UpdateVehicleStamina(player *model.Player, vehicleEntity *Entity, staminaCost int32) {
|
func (g *Game) UpdateVehicleStamina(player *model.Player, vehicleEntity *Entity, staminaCost int32) {
|
||||||
// 耐力消耗为0代表不更改 仍然执行后面的话会导致回复出问题
|
// 耐力消耗为0代表不更改 仍然执行后面的话会导致回复出问题
|
||||||
if staminaCost == 0 {
|
if staminaCost == 0 {
|
||||||
return
|
return
|
||||||
@@ -397,7 +397,7 @@ func (g *GameManager) UpdateVehicleStamina(player *model.Player, vehicleEntity *
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdatePlayerStamina 更新玩家耐力
|
// UpdatePlayerStamina 更新玩家耐力
|
||||||
func (g *GameManager) UpdatePlayerStamina(player *model.Player, staminaCost int32) {
|
func (g *Game) UpdatePlayerStamina(player *model.Player, staminaCost int32) {
|
||||||
// 耐力消耗为0代表不更改 仍然执行后面的话会导致回复出问题
|
// 耐力消耗为0代表不更改 仍然执行后面的话会导致回复出问题
|
||||||
if staminaCost == 0 {
|
if staminaCost == 0 {
|
||||||
return
|
return
|
||||||
@@ -438,7 +438,7 @@ func (g *GameManager) UpdatePlayerStamina(player *model.Player, staminaCost int3
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DrownBackHandler 玩家溺水返回安全点
|
// DrownBackHandler 玩家溺水返回安全点
|
||||||
func (g *GameManager) DrownBackHandler(player *model.Player) {
|
func (g *Game) DrownBackHandler(player *model.Player) {
|
||||||
// 玩家暂停跳过
|
// 玩家暂停跳过
|
||||||
if player.Pause {
|
if player.Pause {
|
||||||
return
|
return
|
||||||
@@ -482,7 +482,7 @@ func (g *GameManager) DrownBackHandler(player *model.Player) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HandleDrown 处理玩家溺水
|
// HandleDrown 处理玩家溺水
|
||||||
func (g *GameManager) HandleDrown(player *model.Player, stamina uint32) {
|
func (g *Game) HandleDrown(player *model.Player, stamina uint32) {
|
||||||
// 溺水需要耐力等于0 返回延时不等于0代表已处理过溺水正在等待返回
|
// 溺水需要耐力等于0 返回延时不等于0代表已处理过溺水正在等待返回
|
||||||
if stamina != 0 || player.StaminaInfo.DrownBackDelay != 0 {
|
if stamina != 0 || player.StaminaInfo.DrownBackDelay != 0 {
|
||||||
return
|
return
|
||||||
@@ -499,7 +499,7 @@ func (g *GameManager) HandleDrown(player *model.Player, stamina uint32) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetVehicleStamina 设置载具耐力
|
// SetVehicleStamina 设置载具耐力
|
||||||
func (g *GameManager) SetVehicleStamina(player *model.Player, vehicleEntity *Entity, stamina float32) {
|
func (g *Game) SetVehicleStamina(player *model.Player, vehicleEntity *Entity, stamina float32) {
|
||||||
// 设置载具的耐力
|
// 设置载具的耐力
|
||||||
gadgetEntity := vehicleEntity.GetGadgetEntity()
|
gadgetEntity := vehicleEntity.GetGadgetEntity()
|
||||||
gadgetEntity.GetGadgetVehicleEntity().SetCurStamina(stamina)
|
gadgetEntity.GetGadgetVehicleEntity().SetCurStamina(stamina)
|
||||||
@@ -513,7 +513,7 @@ func (g *GameManager) SetVehicleStamina(player *model.Player, vehicleEntity *Ent
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetPlayerStamina 设置玩家耐力
|
// SetPlayerStamina 设置玩家耐力
|
||||||
func (g *GameManager) SetPlayerStamina(player *model.Player, stamina uint32) {
|
func (g *Game) SetPlayerStamina(player *model.Player, stamina uint32) {
|
||||||
// 设置玩家的耐力
|
// 设置玩家的耐力
|
||||||
prop := constant.PLAYER_PROP_CUR_PERSIST_STAMINA
|
prop := constant.PLAYER_PROP_CUR_PERSIST_STAMINA
|
||||||
player.PropertiesMap[prop] = stamina
|
player.PropertiesMap[prop] = stamina
|
||||||
@@ -523,7 +523,7 @@ func (g *GameManager) SetPlayerStamina(player *model.Player, stamina uint32) {
|
|||||||
g.PlayerPropNotify(player, prop)
|
g.PlayerPropNotify(player, prop)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PlayerPropNotify(player *model.Player, playerPropId uint16) {
|
func (g *Game) PlayerPropNotify(player *model.Player, playerPropId uint16) {
|
||||||
// PacketPlayerPropNotify
|
// PacketPlayerPropNotify
|
||||||
playerPropNotify := new(proto.PlayerPropNotify)
|
playerPropNotify := new(proto.PlayerPropNotify)
|
||||||
playerPropNotify.PropMap = make(map[uint32]*proto.PropValue)
|
playerPropNotify.PropMap = make(map[uint32]*proto.PropValue)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
pb "google.golang.org/protobuf/proto"
|
pb "google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (g *GameManager) ChangeAvatarReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) ChangeAvatarReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.ChangeAvatarReq)
|
req := payloadMsg.(*proto.ChangeAvatarReq)
|
||||||
targetAvatarGuid := req.Guid
|
targetAvatarGuid := req.Guid
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
@@ -75,7 +75,7 @@ func (g *GameManager) ChangeAvatarReq(player *model.Player, payloadMsg pb.Messag
|
|||||||
g.SendMsg(cmd.ChangeAvatarRsp, player.PlayerID, player.ClientSeq, changeAvatarRsp)
|
g.SendMsg(cmd.ChangeAvatarRsp, player.PlayerID, player.ClientSeq, changeAvatarRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) SetUpAvatarTeamReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) SetUpAvatarTeamReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.SetUpAvatarTeamReq)
|
req := payloadMsg.(*proto.SetUpAvatarTeamReq)
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
if world == nil {
|
if world == nil {
|
||||||
@@ -152,7 +152,7 @@ func (g *GameManager) SetUpAvatarTeamReq(player *model.Player, payloadMsg pb.Mes
|
|||||||
g.SendMsg(cmd.SetUpAvatarTeamRsp, player.PlayerID, player.ClientSeq, setUpAvatarTeamRsp)
|
g.SendMsg(cmd.SetUpAvatarTeamRsp, player.PlayerID, player.ClientSeq, setUpAvatarTeamRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) ChooseCurAvatarTeamReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) ChooseCurAvatarTeamReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.ChooseCurAvatarTeamReq)
|
req := payloadMsg.(*proto.ChooseCurAvatarTeamReq)
|
||||||
teamId := req.TeamId
|
teamId := req.TeamId
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
@@ -182,7 +182,7 @@ func (g *GameManager) ChooseCurAvatarTeamReq(player *model.Player, payloadMsg pb
|
|||||||
g.SendMsg(cmd.ChooseCurAvatarTeamRsp, player.PlayerID, player.ClientSeq, chooseCurAvatarTeamRsp)
|
g.SendMsg(cmd.ChooseCurAvatarTeamRsp, player.PlayerID, player.ClientSeq, chooseCurAvatarTeamRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) ChangeMpTeamAvatarReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) ChangeMpTeamAvatarReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.ChangeMpTeamAvatarReq)
|
req := payloadMsg.(*proto.ChangeMpTeamAvatarReq)
|
||||||
avatarGuidList := req.AvatarGuidList
|
avatarGuidList := req.AvatarGuidList
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
@@ -226,7 +226,7 @@ func (g *GameManager) ChangeMpTeamAvatarReq(player *model.Player, payloadMsg pb.
|
|||||||
g.SendMsg(cmd.ChangeMpTeamAvatarRsp, player.PlayerID, player.ClientSeq, changeMpTeamAvatarRsp)
|
g.SendMsg(cmd.ChangeMpTeamAvatarRsp, player.PlayerID, player.ClientSeq, changeMpTeamAvatarRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PacketSceneTeamUpdateNotify(world *World) *proto.SceneTeamUpdateNotify {
|
func (g *Game) PacketSceneTeamUpdateNotify(world *World) *proto.SceneTeamUpdateNotify {
|
||||||
sceneTeamUpdateNotify := &proto.SceneTeamUpdateNotify{
|
sceneTeamUpdateNotify := &proto.SceneTeamUpdateNotify{
|
||||||
IsInMp: world.GetMultiplayer(),
|
IsInMp: world.GetMultiplayer(),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// VehicleDestroyMotion 载具销毁动作
|
// VehicleDestroyMotion 载具销毁动作
|
||||||
func (g *GameManager) VehicleDestroyMotion(player *model.Player, entity *Entity, state proto.MotionState) {
|
func (g *Game) VehicleDestroyMotion(player *model.Player, entity *Entity, state proto.MotionState) {
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
scene := world.GetSceneById(player.SceneId)
|
scene := world.GetSceneById(player.SceneId)
|
||||||
if scene == nil {
|
if scene == nil {
|
||||||
@@ -28,7 +28,7 @@ func (g *GameManager) VehicleDestroyMotion(player *model.Player, entity *Entity,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CreateVehicleReq 创建载具
|
// CreateVehicleReq 创建载具
|
||||||
func (g *GameManager) CreateVehicleReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) CreateVehicleReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.CreateVehicleReq)
|
req := payloadMsg.(*proto.CreateVehicleReq)
|
||||||
|
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
@@ -65,7 +65,7 @@ func (g *GameManager) CreateVehicleReq(player *model.Player, payloadMsg pb.Messa
|
|||||||
g.SendError(cmd.VehicleInteractRsp, player, &proto.VehicleInteractRsp{})
|
g.SendError(cmd.VehicleInteractRsp, player, &proto.VehicleInteractRsp{})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
GAME_MANAGER.AddSceneEntityNotify(player, proto.VisionType_VISION_BORN, []uint32{entityId}, true, false)
|
GAME.AddSceneEntityNotify(player, proto.VisionType_VISION_BORN, []uint32{entityId}, true, false)
|
||||||
// 记录创建的载具信息
|
// 记录创建的载具信息
|
||||||
player.VehicleInfo.LastCreateEntityIdMap[req.VehicleId] = entityId
|
player.VehicleInfo.LastCreateEntityIdMap[req.VehicleId] = entityId
|
||||||
player.VehicleInfo.LastCreateTime = time.Now().UnixMilli()
|
player.VehicleInfo.LastCreateTime = time.Now().UnixMilli()
|
||||||
@@ -79,7 +79,7 @@ func (g *GameManager) CreateVehicleReq(player *model.Player, payloadMsg pb.Messa
|
|||||||
}
|
}
|
||||||
|
|
||||||
// IsPlayerInVehicle 判断玩家是否在载具中
|
// IsPlayerInVehicle 判断玩家是否在载具中
|
||||||
func (g *GameManager) IsPlayerInVehicle(player *model.Player, gadgetVehicleEntity *GadgetVehicleEntity) bool {
|
func (g *Game) IsPlayerInVehicle(player *model.Player, gadgetVehicleEntity *GadgetVehicleEntity) bool {
|
||||||
if gadgetVehicleEntity == nil {
|
if gadgetVehicleEntity == nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -92,7 +92,7 @@ func (g *GameManager) IsPlayerInVehicle(player *model.Player, gadgetVehicleEntit
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DestroyVehicleEntity 删除载具实体
|
// DestroyVehicleEntity 删除载具实体
|
||||||
func (g *GameManager) DestroyVehicleEntity(player *model.Player, scene *Scene, vehicleId uint32, entityId uint32) {
|
func (g *Game) DestroyVehicleEntity(player *model.Player, scene *Scene, vehicleId uint32, entityId uint32) {
|
||||||
entity := scene.GetEntity(entityId)
|
entity := scene.GetEntity(entityId)
|
||||||
if entity == nil {
|
if entity == nil {
|
||||||
return
|
return
|
||||||
@@ -124,7 +124,7 @@ func (g *GameManager) DestroyVehicleEntity(player *model.Player, scene *Scene, v
|
|||||||
}
|
}
|
||||||
|
|
||||||
// EnterVehicle 进入载具
|
// EnterVehicle 进入载具
|
||||||
func (g *GameManager) EnterVehicle(player *model.Player, entity *Entity, avatarGuid uint64) {
|
func (g *Game) EnterVehicle(player *model.Player, entity *Entity, avatarGuid uint64) {
|
||||||
maxSlot := 1 // TODO 读取配置表
|
maxSlot := 1 // TODO 读取配置表
|
||||||
// 判断载具是否已满
|
// 判断载具是否已满
|
||||||
gadgetEntity := entity.GetGadgetEntity()
|
gadgetEntity := entity.GetGadgetEntity()
|
||||||
@@ -162,7 +162,7 @@ func (g *GameManager) EnterVehicle(player *model.Player, entity *Entity, avatarG
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ExitVehicle 离开载具
|
// ExitVehicle 离开载具
|
||||||
func (g *GameManager) ExitVehicle(player *model.Player, entity *Entity, avatarGuid uint64) {
|
func (g *Game) ExitVehicle(player *model.Player, entity *Entity, avatarGuid uint64) {
|
||||||
// 玩家是否进入载具
|
// 玩家是否进入载具
|
||||||
gadgetEntity := entity.GetGadgetEntity()
|
gadgetEntity := entity.GetGadgetEntity()
|
||||||
if !g.IsPlayerInVehicle(player, gadgetEntity.GetGadgetVehicleEntity()) {
|
if !g.IsPlayerInVehicle(player, gadgetEntity.GetGadgetVehicleEntity()) {
|
||||||
@@ -196,7 +196,7 @@ func (g *GameManager) ExitVehicle(player *model.Player, entity *Entity, avatarGu
|
|||||||
}
|
}
|
||||||
|
|
||||||
// VehicleInteractReq 载具交互
|
// VehicleInteractReq 载具交互
|
||||||
func (g *GameManager) VehicleInteractReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) VehicleInteractReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.VehicleInteractReq)
|
req := payloadMsg.(*proto.VehicleInteractReq)
|
||||||
|
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import (
|
|||||||
pb "google.golang.org/protobuf/proto"
|
pb "google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (g *GameManager) GetAllWeaponDataConfig() map[int32]*gdconf.ItemData {
|
func (g *Game) GetAllWeaponDataConfig() map[int32]*gdconf.ItemData {
|
||||||
allWeaponDataConfig := make(map[int32]*gdconf.ItemData)
|
allWeaponDataConfig := make(map[int32]*gdconf.ItemData)
|
||||||
for itemId, itemData := range gdconf.GetItemDataMap() {
|
for itemId, itemData := range gdconf.GetItemDataMap() {
|
||||||
if itemData.Type != constant.ITEM_TYPE_WEAPON {
|
if itemData.Type != constant.ITEM_TYPE_WEAPON {
|
||||||
@@ -25,7 +25,7 @@ func (g *GameManager) GetAllWeaponDataConfig() map[int32]*gdconf.ItemData {
|
|||||||
return allWeaponDataConfig
|
return allWeaponDataConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) AddUserWeapon(userId uint32, itemId uint32) uint64 {
|
func (g *Game) AddUserWeapon(userId uint32, itemId uint32) uint64 {
|
||||||
player := USER_MANAGER.GetOnlineUser(userId)
|
player := USER_MANAGER.GetOnlineUser(userId)
|
||||||
if player == nil {
|
if player == nil {
|
||||||
logger.Error("player is nil, uid: %v", userId)
|
logger.Error("player is nil, uid: %v", userId)
|
||||||
@@ -47,7 +47,7 @@ func (g *GameManager) AddUserWeapon(userId uint32, itemId uint32) uint64 {
|
|||||||
return weaponId
|
return weaponId
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) CostUserWeapon(userId uint32, weaponIdList []uint64) {
|
func (g *Game) CostUserWeapon(userId uint32, weaponIdList []uint64) {
|
||||||
player := USER_MANAGER.GetOnlineUser(userId)
|
player := USER_MANAGER.GetOnlineUser(userId)
|
||||||
if player == nil {
|
if player == nil {
|
||||||
logger.Error("player is nil, uid: %v", userId)
|
logger.Error("player is nil, uid: %v", userId)
|
||||||
@@ -69,7 +69,7 @@ func (g *GameManager) CostUserWeapon(userId uint32, weaponIdList []uint64) {
|
|||||||
g.SendMsg(cmd.StoreItemDelNotify, userId, player.ClientSeq, storeItemDelNotify)
|
g.SendMsg(cmd.StoreItemDelNotify, userId, player.ClientSeq, storeItemDelNotify)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PacketStoreItemChangeNotifyByWeapon(weapon *model.Weapon) *proto.StoreItemChangeNotify {
|
func (g *Game) PacketStoreItemChangeNotifyByWeapon(weapon *model.Weapon) *proto.StoreItemChangeNotify {
|
||||||
storeItemChangeNotify := &proto.StoreItemChangeNotify{
|
storeItemChangeNotify := &proto.StoreItemChangeNotify{
|
||||||
StoreType: proto.StoreType_STORE_PACK,
|
StoreType: proto.StoreType_STORE_PACK,
|
||||||
ItemList: make([]*proto.Item, 0),
|
ItemList: make([]*proto.Item, 0),
|
||||||
@@ -101,7 +101,7 @@ func (g *GameManager) PacketStoreItemChangeNotifyByWeapon(weapon *model.Weapon)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WeaponAwakenReq 武器精炼请求
|
// WeaponAwakenReq 武器精炼请求
|
||||||
func (g *GameManager) WeaponAwakenReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) WeaponAwakenReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.WeaponAwakenReq)
|
req := payloadMsg.(*proto.WeaponAwakenReq)
|
||||||
// 确保精炼的武器与精炼材料不是同一个
|
// 确保精炼的武器与精炼材料不是同一个
|
||||||
if req.TargetWeaponGuid == req.ItemGuid {
|
if req.TargetWeaponGuid == req.ItemGuid {
|
||||||
@@ -259,7 +259,7 @@ func (g *GameManager) WeaponAwakenReq(player *model.Player, payloadMsg pb.Messag
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WeaponPromoteReq 武器突破请求
|
// WeaponPromoteReq 武器突破请求
|
||||||
func (g *GameManager) WeaponPromoteReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) WeaponPromoteReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.WeaponPromoteReq)
|
req := payloadMsg.(*proto.WeaponPromoteReq)
|
||||||
// 是否拥有武器
|
// 是否拥有武器
|
||||||
weapon, ok := player.GameObjectGuidMap[req.TargetWeaponGuid].(*model.Weapon)
|
weapon, ok := player.GameObjectGuidMap[req.TargetWeaponGuid].(*model.Weapon)
|
||||||
@@ -362,7 +362,7 @@ func (g *GameManager) WeaponPromoteReq(player *model.Player, payloadMsg pb.Messa
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetWeaponUpgradeReturnMaterial 获取武器强化返回的材料
|
// GetWeaponUpgradeReturnMaterial 获取武器强化返回的材料
|
||||||
func (g *GameManager) GetWeaponUpgradeReturnMaterial(overflowExp uint32) (returnItemList []*proto.ItemParam) {
|
func (g *Game) GetWeaponUpgradeReturnMaterial(overflowExp uint32) (returnItemList []*proto.ItemParam) {
|
||||||
returnItemList = make([]*proto.ItemParam, 0, 0)
|
returnItemList = make([]*proto.ItemParam, 0, 0)
|
||||||
// 武器强化材料返还
|
// 武器强化材料返还
|
||||||
type materialExpData struct {
|
type materialExpData struct {
|
||||||
@@ -411,7 +411,7 @@ func (g *GameManager) GetWeaponUpgradeReturnMaterial(overflowExp uint32) (return
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CalcWeaponUpgradeExpAndCoin 计算使用材料给武器强化后能获得的经验以及摩拉消耗
|
// CalcWeaponUpgradeExpAndCoin 计算使用材料给武器强化后能获得的经验以及摩拉消耗
|
||||||
func (g *GameManager) CalcWeaponUpgradeExpAndCoin(player *model.Player, itemParamList []*proto.ItemParam, foodWeaponGuidList []uint64) (expCount uint32, coinCost uint32, success bool) {
|
func (g *Game) CalcWeaponUpgradeExpAndCoin(player *model.Player, itemParamList []*proto.ItemParam, foodWeaponGuidList []uint64) (expCount uint32, coinCost uint32, success bool) {
|
||||||
// 武器经验计算
|
// 武器经验计算
|
||||||
for _, weaponGuid := range foodWeaponGuidList {
|
for _, weaponGuid := range foodWeaponGuidList {
|
||||||
foodWeapon, ok := player.GameObjectGuidMap[weaponGuid].(*model.Weapon)
|
foodWeapon, ok := player.GameObjectGuidMap[weaponGuid].(*model.Weapon)
|
||||||
@@ -483,7 +483,7 @@ func (g *GameManager) CalcWeaponUpgradeExpAndCoin(player *model.Player, itemPara
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CalcWeaponUpgrade 计算使用材料给武器强化后的等级经验以及返回的矿石
|
// CalcWeaponUpgrade 计算使用材料给武器强化后的等级经验以及返回的矿石
|
||||||
func (g *GameManager) CalcWeaponUpgrade(weapon *model.Weapon, expCount uint32) (weaponLevel uint8, weaponExp uint32, returnItemList []*proto.ItemParam, success bool) {
|
func (g *Game) CalcWeaponUpgrade(weapon *model.Weapon, expCount uint32) (weaponLevel uint8, weaponExp uint32, returnItemList []*proto.ItemParam, success bool) {
|
||||||
// 获取武器配置表
|
// 获取武器配置表
|
||||||
weaponConfig := gdconf.GetItemDataById(int32(weapon.ItemId))
|
weaponConfig := gdconf.GetItemDataById(int32(weapon.ItemId))
|
||||||
if weaponConfig == nil {
|
if weaponConfig == nil {
|
||||||
@@ -534,7 +534,7 @@ func (g *GameManager) CalcWeaponUpgrade(weapon *model.Weapon, expCount uint32) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WeaponUpgradeReq 武器升级请求
|
// WeaponUpgradeReq 武器升级请求
|
||||||
func (g *GameManager) WeaponUpgradeReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) WeaponUpgradeReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.WeaponUpgradeReq)
|
req := payloadMsg.(*proto.WeaponUpgradeReq)
|
||||||
// 是否拥有武器
|
// 是否拥有武器
|
||||||
weapon, ok := player.GameObjectGuidMap[req.TargetWeaponGuid].(*model.Weapon)
|
weapon, ok := player.GameObjectGuidMap[req.TargetWeaponGuid].(*model.Weapon)
|
||||||
@@ -674,7 +674,7 @@ func (g *GameManager) WeaponUpgradeReq(player *model.Player, payloadMsg pb.Messa
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CalcWeaponUpgradeReturnItemsReq 计算武器升级返回矿石请求
|
// CalcWeaponUpgradeReturnItemsReq 计算武器升级返回矿石请求
|
||||||
func (g *GameManager) CalcWeaponUpgradeReturnItemsReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) CalcWeaponUpgradeReturnItemsReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.CalcWeaponUpgradeReturnItemsReq)
|
req := payloadMsg.(*proto.CalcWeaponUpgradeReturnItemsReq)
|
||||||
// 是否拥有武器
|
// 是否拥有武器
|
||||||
weapon, ok := player.GameObjectGuidMap[req.TargetWeaponGuid].(*model.Weapon)
|
weapon, ok := player.GameObjectGuidMap[req.TargetWeaponGuid].(*model.Weapon)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"hk4e/gdconf"
|
"hk4e/gdconf"
|
||||||
"hk4e/gs/model"
|
"hk4e/gs/model"
|
||||||
"hk4e/pkg/logger"
|
"hk4e/pkg/logger"
|
||||||
|
"hk4e/pkg/random"
|
||||||
"hk4e/protocol/cmd"
|
"hk4e/protocol/cmd"
|
||||||
"hk4e/protocol/proto"
|
"hk4e/protocol/proto"
|
||||||
|
|
||||||
@@ -15,7 +16,7 @@ import (
|
|||||||
|
|
||||||
// 大地图模块 大世界相关的所有逻辑
|
// 大地图模块 大世界相关的所有逻辑
|
||||||
|
|
||||||
func (g *GameManager) SceneTransToPointReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) SceneTransToPointReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.SceneTransToPointReq)
|
req := payloadMsg.(*proto.SceneTransToPointReq)
|
||||||
dbWorld := player.GetDbWorld()
|
dbWorld := player.GetDbWorld()
|
||||||
dbScene := dbWorld.GetSceneById(req.SceneId)
|
dbScene := dbWorld.GetSceneById(req.SceneId)
|
||||||
@@ -52,7 +53,7 @@ func (g *GameManager) SceneTransToPointReq(player *model.Player, payloadMsg pb.M
|
|||||||
g.SendMsg(cmd.SceneTransToPointRsp, player.PlayerID, player.ClientSeq, sceneTransToPointRsp)
|
g.SendMsg(cmd.SceneTransToPointRsp, player.PlayerID, player.ClientSeq, sceneTransToPointRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) UnlockTransPointReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) UnlockTransPointReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.UnlockTransPointReq)
|
req := payloadMsg.(*proto.UnlockTransPointReq)
|
||||||
|
|
||||||
dbWorld := player.GetDbWorld()
|
dbWorld := player.GetDbWorld()
|
||||||
@@ -78,7 +79,7 @@ func (g *GameManager) UnlockTransPointReq(player *model.Player, payloadMsg pb.Me
|
|||||||
g.SendSucc(cmd.UnlockTransPointRsp, player, &proto.UnlockTransPointRsp{})
|
g.SendSucc(cmd.UnlockTransPointRsp, player, &proto.UnlockTransPointRsp{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) GetScenePointReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) GetScenePointReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.GetScenePointReq)
|
req := payloadMsg.(*proto.GetScenePointReq)
|
||||||
|
|
||||||
dbWorld := player.GetDbWorld()
|
dbWorld := player.GetDbWorld()
|
||||||
@@ -111,7 +112,7 @@ func (g *GameManager) GetScenePointReq(player *model.Player, payloadMsg pb.Messa
|
|||||||
g.SendMsg(cmd.GetScenePointRsp, player.PlayerID, player.ClientSeq, getScenePointRsp)
|
g.SendMsg(cmd.GetScenePointRsp, player.PlayerID, player.ClientSeq, getScenePointRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) MarkMapReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) MarkMapReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.MarkMapReq)
|
req := payloadMsg.(*proto.MarkMapReq)
|
||||||
if req.Op == proto.MarkMapReq_ADD {
|
if req.Op == proto.MarkMapReq_ADD {
|
||||||
logger.Debug("user mark type: %v", req.Mark.PointType)
|
logger.Debug("user mark type: %v", req.Mark.PointType)
|
||||||
@@ -133,7 +134,7 @@ func (g *GameManager) MarkMapReq(player *model.Player, payloadMsg pb.Message) {
|
|||||||
g.SendMsg(cmd.MarkMapRsp, player.PlayerID, player.ClientSeq, &proto.MarkMapRsp{})
|
g.SendMsg(cmd.MarkMapRsp, player.PlayerID, player.ClientSeq, &proto.MarkMapRsp{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) GetSceneAreaReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) GetSceneAreaReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.GetSceneAreaReq)
|
req := payloadMsg.(*proto.GetSceneAreaReq)
|
||||||
|
|
||||||
getSceneAreaRsp := &proto.GetSceneAreaRsp{
|
getSceneAreaRsp := &proto.GetSceneAreaRsp{
|
||||||
@@ -165,7 +166,7 @@ func (g *GameManager) GetSceneAreaReq(player *model.Player, payloadMsg pb.Messag
|
|||||||
g.SendMsg(cmd.GetSceneAreaRsp, player.PlayerID, player.ClientSeq, getSceneAreaRsp)
|
g.SendMsg(cmd.GetSceneAreaRsp, player.PlayerID, player.ClientSeq, getSceneAreaRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) EnterWorldAreaReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) EnterWorldAreaReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
logger.Debug("player enter world area, uid: %v", player.PlayerID)
|
logger.Debug("player enter world area, uid: %v", player.PlayerID)
|
||||||
req := payloadMsg.(*proto.EnterWorldAreaReq)
|
req := payloadMsg.(*proto.EnterWorldAreaReq)
|
||||||
|
|
||||||
@@ -178,7 +179,7 @@ func (g *GameManager) EnterWorldAreaReq(player *model.Player, payloadMsg pb.Mess
|
|||||||
g.SendMsg(cmd.EnterWorldAreaRsp, player.PlayerID, player.ClientSeq, enterWorldAreaRsp)
|
g.SendMsg(cmd.EnterWorldAreaRsp, player.PlayerID, player.ClientSeq, enterWorldAreaRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) ChangeGameTimeReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) ChangeGameTimeReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.ChangeGameTimeReq)
|
req := payloadMsg.(*proto.ChangeGameTimeReq)
|
||||||
gameTime := req.GameTime
|
gameTime := req.GameTime
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
@@ -203,7 +204,7 @@ func (g *GameManager) ChangeGameTimeReq(player *model.Player, payloadMsg pb.Mess
|
|||||||
g.SendMsg(cmd.ChangeGameTimeRsp, player.PlayerID, player.ClientSeq, changeGameTimeRsp)
|
g.SendMsg(cmd.ChangeGameTimeRsp, player.PlayerID, player.ClientSeq, changeGameTimeRsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) NpcTalkReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) NpcTalkReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.NpcTalkReq)
|
req := payloadMsg.(*proto.NpcTalkReq)
|
||||||
rsp := &proto.NpcTalkRsp{
|
rsp := &proto.NpcTalkRsp{
|
||||||
CurTalkId: req.TalkId,
|
CurTalkId: req.TalkId,
|
||||||
@@ -213,7 +214,7 @@ func (g *GameManager) NpcTalkReq(player *model.Player, payloadMsg pb.Message) {
|
|||||||
g.SendMsg(cmd.NpcTalkRsp, player.PlayerID, player.ClientSeq, rsp)
|
g.SendMsg(cmd.NpcTalkRsp, player.PlayerID, player.ClientSeq, rsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) DungeonEntryInfoReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) DungeonEntryInfoReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.DungeonEntryInfoReq)
|
req := payloadMsg.(*proto.DungeonEntryInfoReq)
|
||||||
pointDataConfig := gdconf.GetScenePointBySceneIdAndPointId(int32(req.SceneId), int32(req.PointId))
|
pointDataConfig := gdconf.GetScenePointBySceneIdAndPointId(int32(req.SceneId), int32(req.PointId))
|
||||||
if pointDataConfig == nil {
|
if pointDataConfig == nil {
|
||||||
@@ -233,7 +234,7 @@ func (g *GameManager) DungeonEntryInfoReq(player *model.Player, payloadMsg pb.Me
|
|||||||
g.SendMsg(cmd.DungeonEntryInfoRsp, player.PlayerID, player.ClientSeq, rsp)
|
g.SendMsg(cmd.DungeonEntryInfoRsp, player.PlayerID, player.ClientSeq, rsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PlayerEnterDungeonReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) PlayerEnterDungeonReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.PlayerEnterDungeonReq)
|
req := payloadMsg.(*proto.PlayerEnterDungeonReq)
|
||||||
dungeonDataConfig := gdconf.GetDungeonDataById(int32(req.DungeonId))
|
dungeonDataConfig := gdconf.GetDungeonDataById(int32(req.DungeonId))
|
||||||
if dungeonDataConfig == nil {
|
if dungeonDataConfig == nil {
|
||||||
@@ -262,7 +263,7 @@ func (g *GameManager) PlayerEnterDungeonReq(player *model.Player, payloadMsg pb.
|
|||||||
g.SendMsg(cmd.PlayerEnterDungeonRsp, player.PlayerID, player.ClientSeq, rsp)
|
g.SendMsg(cmd.PlayerEnterDungeonRsp, player.PlayerID, player.ClientSeq, rsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) PlayerQuitDungeonReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) PlayerQuitDungeonReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.PlayerQuitDungeonReq)
|
req := payloadMsg.(*proto.PlayerQuitDungeonReq)
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
if world == nil {
|
if world == nil {
|
||||||
@@ -284,7 +285,7 @@ func (g *GameManager) PlayerQuitDungeonReq(player *model.Player, payloadMsg pb.M
|
|||||||
g.SendMsg(cmd.PlayerQuitDungeonRsp, player.PlayerID, player.ClientSeq, rsp)
|
g.SendMsg(cmd.PlayerQuitDungeonRsp, player.PlayerID, player.ClientSeq, rsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *GameManager) GadgetInteractReq(player *model.Player, payloadMsg pb.Message) {
|
func (g *Game) GadgetInteractReq(player *model.Player, payloadMsg pb.Message) {
|
||||||
req := payloadMsg.(*proto.GadgetInteractReq)
|
req := payloadMsg.(*proto.GadgetInteractReq)
|
||||||
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
world := WORLD_MANAGER.GetWorldByID(player.WorldId)
|
||||||
if world == nil {
|
if world == nil {
|
||||||
@@ -333,10 +334,31 @@ func (g *GameManager) GadgetInteractReq(player *model.Player, payloadMsg pb.Mess
|
|||||||
case constant.GADGET_TYPE_CHEST:
|
case constant.GADGET_TYPE_CHEST:
|
||||||
// 宝箱开启
|
// 宝箱开启
|
||||||
interactType = proto.InteractType_INTERACT_OPEN_CHEST
|
interactType = proto.InteractType_INTERACT_OPEN_CHEST
|
||||||
if req.OpType == proto.InterOpType_INTER_OP_FINISH {
|
|
||||||
// 宝箱交互结束 开启宝箱
|
// 宝箱交互结束 开启宝箱
|
||||||
// TODO
|
if req.OpType == proto.InterOpType_INTER_OP_FINISH {
|
||||||
g.CreateDropGadget(player, entity.pos, 70600055, 104003, 1)
|
// 随机掉落
|
||||||
|
sceneGroupConfig := gdconf.GetSceneGroup(int32(entity.GetGroupId()))
|
||||||
|
gadgetConfig := sceneGroupConfig.GadgetMap[int32(entity.GetConfigId())]
|
||||||
|
chestDropDataConfig := gdconf.GetChestDropDataByDropTagAndLevel(gadgetConfig.DropTag, gadgetConfig.Level)
|
||||||
|
if chestDropDataConfig == nil {
|
||||||
|
logger.Error("get chest drop data config is nil, gadgetConfig: %v, uid: %v", gadgetConfig, player.PlayerID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
dropDataConfig := gdconf.GetDropDataById(chestDropDataConfig.DropId)
|
||||||
|
if dropDataConfig == nil {
|
||||||
|
logger.Error("get drop data config is nil, dropId: %v, uid: %v", chestDropDataConfig.DropId, player.PlayerID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
totalItemMap := g.doRandDropFullTimes(dropDataConfig, int(chestDropDataConfig.DropCount))
|
||||||
|
for itemId, count := range totalItemMap {
|
||||||
|
itemDataConfig := gdconf.GetItemDataById(int32(itemId))
|
||||||
|
if itemDataConfig == nil {
|
||||||
|
logger.Error("get item data config is nil, itemId: %v, uid: %v", itemId, player.PlayerID)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
g.CreateDropGadget(player, entity.pos, uint32(itemDataConfig.GadgetId), itemId, count)
|
||||||
|
}
|
||||||
|
// 更新宝箱状态
|
||||||
g.SendMsg(cmd.WorldChestOpenNotify, player.PlayerID, player.ClientSeq, &proto.WorldChestOpenNotify{
|
g.SendMsg(cmd.WorldChestOpenNotify, player.PlayerID, player.ClientSeq, &proto.WorldChestOpenNotify{
|
||||||
GroupId: entity.GetGroupId(),
|
GroupId: entity.GetGroupId(),
|
||||||
SceneId: scene.GetId(),
|
SceneId: scene.GetId(),
|
||||||
@@ -356,8 +378,73 @@ func (g *GameManager) GadgetInteractReq(player *model.Player, payloadMsg pb.Mess
|
|||||||
g.SendMsg(cmd.GadgetInteractRsp, player.PlayerID, player.ClientSeq, rsp)
|
g.SendMsg(cmd.GadgetInteractRsp, player.PlayerID, player.ClientSeq, rsp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *Game) doRandDropFullTimes(dropDataConfig *gdconf.DropData, times int) map[uint32]uint32 {
|
||||||
|
totalItemMap := make(map[uint32]uint32)
|
||||||
|
for i := 0; i < times; i++ {
|
||||||
|
itemMap := g.doRandDropFull(dropDataConfig)
|
||||||
|
if itemMap == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for itemId, count := range itemMap {
|
||||||
|
totalItemMap[itemId] += count
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return totalItemMap
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Game) doRandDropFull(dropDataConfig *gdconf.DropData) map[uint32]uint32 {
|
||||||
|
itemMap := make(map[uint32]uint32)
|
||||||
|
dropList := make([]*gdconf.DropData, 0)
|
||||||
|
dropList = append(dropList, dropDataConfig)
|
||||||
|
for i := 0; i < 1000; i++ {
|
||||||
|
if len(dropList) == 0 {
|
||||||
|
// 掉落结束
|
||||||
|
return itemMap
|
||||||
|
}
|
||||||
|
dropMap := g.doRandDropOnce(dropList[0])
|
||||||
|
dropList = dropList[1:]
|
||||||
|
for dropId, count := range dropMap {
|
||||||
|
subDropDataConfig := gdconf.GetDropDataById(dropId)
|
||||||
|
if subDropDataConfig != nil {
|
||||||
|
// 添加子掉落
|
||||||
|
dropList = append(dropList, subDropDataConfig)
|
||||||
|
} else {
|
||||||
|
itemMap[uint32(dropId)] += uint32(count)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logger.Error("drop overtimes, drop config: %v", dropDataConfig)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Game) doRandDropOnce(dropDataConfig *gdconf.DropData) map[int32]int32 {
|
||||||
|
dropMap := make(map[int32]int32)
|
||||||
|
switch dropDataConfig.RandomType {
|
||||||
|
case gdconf.RandomTypeChoose:
|
||||||
|
// RWS随机
|
||||||
|
randNum := random.GetRandomInt32(0, dropDataConfig.SubDropTotalWeight-1)
|
||||||
|
sumWeight := int32(0)
|
||||||
|
for _, subDrop := range dropDataConfig.SubDropList {
|
||||||
|
sumWeight += subDrop.Weight
|
||||||
|
if sumWeight > randNum {
|
||||||
|
dropMap[subDrop.Id] = random.GetRandomInt32(subDrop.CountRange[0], subDrop.CountRange[1])
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case gdconf.RandomTypeIndep:
|
||||||
|
// 独立随机
|
||||||
|
randNum := random.GetRandomInt32(0, gdconf.RandomTypeIndepWeight-1)
|
||||||
|
for _, subDrop := range dropDataConfig.SubDropList {
|
||||||
|
if subDrop.Weight > randNum {
|
||||||
|
dropMap[subDrop.Id] += random.GetRandomInt32(subDrop.CountRange[0], subDrop.CountRange[1])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dropMap
|
||||||
|
}
|
||||||
|
|
||||||
// TeleportPlayer 传送玩家至地图上的某个位置
|
// TeleportPlayer 传送玩家至地图上的某个位置
|
||||||
func (g *GameManager) TeleportPlayer(player *model.Player, enterReason uint16, sceneId uint32, pos, rot *model.Vector, dungeonId uint32) {
|
func (g *Game) TeleportPlayer(player *model.Player, enterReason uint16, sceneId uint32, pos, rot *model.Vector, dungeonId uint32) {
|
||||||
// 传送玩家
|
// 传送玩家
|
||||||
newSceneId := sceneId
|
newSceneId := sceneId
|
||||||
oldSceneId := player.SceneId
|
oldSceneId := player.SceneId
|
||||||
|
|||||||
@@ -1,206 +0,0 @@
|
|||||||
package game
|
|
||||||
|
|
||||||
import (
|
|
||||||
"hk4e/common/mq"
|
|
||||||
"hk4e/gate/kcp"
|
|
||||||
"hk4e/gs/model"
|
|
||||||
"hk4e/node/api"
|
|
||||||
"hk4e/pkg/logger"
|
|
||||||
"hk4e/protocol/cmd"
|
|
||||||
|
|
||||||
pb "google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
// 接口路由管理器
|
|
||||||
|
|
||||||
type HandlerFunc func(player *model.Player, payloadMsg pb.Message)
|
|
||||||
|
|
||||||
type RouteManager struct {
|
|
||||||
// k:cmdId v:HandlerFunc
|
|
||||||
handlerFuncRouteMap map[uint16]HandlerFunc
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewRouteManager() (r *RouteManager) {
|
|
||||||
r = new(RouteManager)
|
|
||||||
r.handlerFuncRouteMap = make(map[uint16]HandlerFunc)
|
|
||||||
r.initRoute()
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *RouteManager) registerRouter(cmdId uint16, handlerFunc HandlerFunc) {
|
|
||||||
r.handlerFuncRouteMap[cmdId] = handlerFunc
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *RouteManager) doRoute(cmdId uint16, userId uint32, clientSeq uint32, payloadMsg pb.Message) {
|
|
||||||
handlerFunc, ok := r.handlerFuncRouteMap[cmdId]
|
|
||||||
if !ok {
|
|
||||||
logger.Error("no route for msg, cmdId: %v", cmdId)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
player := USER_MANAGER.GetOnlineUser(userId)
|
|
||||||
if player == nil {
|
|
||||||
logger.Error("player is nil, uid: %v", userId)
|
|
||||||
GAME_MANAGER.KickPlayer(userId, kcp.EnetNotFoundSession)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !player.Online {
|
|
||||||
logger.Error("player not online, uid: %v", userId)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
player.ClientSeq = clientSeq
|
|
||||||
SELF = player
|
|
||||||
handlerFunc(player, payloadMsg)
|
|
||||||
SELF = nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *RouteManager) initRoute() {
|
|
||||||
r.registerRouter(cmd.QueryPathReq, GAME_MANAGER.QueryPathReq)
|
|
||||||
r.registerRouter(cmd.UnionCmdNotify, GAME_MANAGER.UnionCmdNotify)
|
|
||||||
r.registerRouter(cmd.MassiveEntityElementOpBatchNotify, GAME_MANAGER.MassiveEntityElementOpBatchNotify)
|
|
||||||
r.registerRouter(cmd.ToTheMoonEnterSceneReq, GAME_MANAGER.ToTheMoonEnterSceneReq)
|
|
||||||
r.registerRouter(cmd.PlayerSetPauseReq, GAME_MANAGER.PlayerSetPauseReq)
|
|
||||||
r.registerRouter(cmd.EnterSceneReadyReq, GAME_MANAGER.EnterSceneReadyReq)
|
|
||||||
r.registerRouter(cmd.PathfindingEnterSceneReq, GAME_MANAGER.PathfindingEnterSceneReq)
|
|
||||||
r.registerRouter(cmd.GetScenePointReq, GAME_MANAGER.GetScenePointReq)
|
|
||||||
r.registerRouter(cmd.GetSceneAreaReq, GAME_MANAGER.GetSceneAreaReq)
|
|
||||||
r.registerRouter(cmd.SceneInitFinishReq, GAME_MANAGER.SceneInitFinishReq)
|
|
||||||
r.registerRouter(cmd.EnterSceneDoneReq, GAME_MANAGER.EnterSceneDoneReq)
|
|
||||||
r.registerRouter(cmd.EnterWorldAreaReq, GAME_MANAGER.EnterWorldAreaReq)
|
|
||||||
r.registerRouter(cmd.PostEnterSceneReq, GAME_MANAGER.PostEnterSceneReq)
|
|
||||||
r.registerRouter(cmd.TowerAllDataReq, GAME_MANAGER.TowerAllDataReq)
|
|
||||||
r.registerRouter(cmd.SceneTransToPointReq, GAME_MANAGER.SceneTransToPointReq)
|
|
||||||
r.registerRouter(cmd.UnlockTransPointReq, GAME_MANAGER.UnlockTransPointReq)
|
|
||||||
r.registerRouter(cmd.MarkMapReq, GAME_MANAGER.MarkMapReq)
|
|
||||||
r.registerRouter(cmd.ChangeAvatarReq, GAME_MANAGER.ChangeAvatarReq)
|
|
||||||
r.registerRouter(cmd.SetUpAvatarTeamReq, GAME_MANAGER.SetUpAvatarTeamReq)
|
|
||||||
r.registerRouter(cmd.ChooseCurAvatarTeamReq, GAME_MANAGER.ChooseCurAvatarTeamReq)
|
|
||||||
r.registerRouter(cmd.GetGachaInfoReq, GAME_MANAGER.GetGachaInfoReq)
|
|
||||||
r.registerRouter(cmd.DoGachaReq, GAME_MANAGER.DoGachaReq)
|
|
||||||
r.registerRouter(cmd.CombatInvocationsNotify, GAME_MANAGER.CombatInvocationsNotify)
|
|
||||||
r.registerRouter(cmd.AbilityInvocationsNotify, GAME_MANAGER.AbilityInvocationsNotify)
|
|
||||||
r.registerRouter(cmd.ClientAbilityInitFinishNotify, GAME_MANAGER.ClientAbilityInitFinishNotify)
|
|
||||||
r.registerRouter(cmd.EvtDoSkillSuccNotify, GAME_MANAGER.EvtDoSkillSuccNotify)
|
|
||||||
r.registerRouter(cmd.ClientAbilityChangeNotify, GAME_MANAGER.ClientAbilityChangeNotify)
|
|
||||||
r.registerRouter(cmd.EntityAiSyncNotify, GAME_MANAGER.EntityAiSyncNotify)
|
|
||||||
r.registerRouter(cmd.WearEquipReq, GAME_MANAGER.WearEquipReq)
|
|
||||||
r.registerRouter(cmd.ChangeGameTimeReq, GAME_MANAGER.ChangeGameTimeReq)
|
|
||||||
r.registerRouter(cmd.GetPlayerSocialDetailReq, GAME_MANAGER.GetPlayerSocialDetailReq)
|
|
||||||
r.registerRouter(cmd.SetPlayerBirthdayReq, GAME_MANAGER.SetPlayerBirthdayReq)
|
|
||||||
r.registerRouter(cmd.SetNameCardReq, GAME_MANAGER.SetNameCardReq)
|
|
||||||
r.registerRouter(cmd.SetPlayerSignatureReq, GAME_MANAGER.SetPlayerSignatureReq)
|
|
||||||
r.registerRouter(cmd.SetPlayerNameReq, GAME_MANAGER.SetPlayerNameReq)
|
|
||||||
r.registerRouter(cmd.SetPlayerHeadImageReq, GAME_MANAGER.SetPlayerHeadImageReq)
|
|
||||||
r.registerRouter(cmd.GetAllUnlockNameCardReq, GAME_MANAGER.GetAllUnlockNameCardReq)
|
|
||||||
r.registerRouter(cmd.GetPlayerFriendListReq, GAME_MANAGER.GetPlayerFriendListReq)
|
|
||||||
r.registerRouter(cmd.GetPlayerAskFriendListReq, GAME_MANAGER.GetPlayerAskFriendListReq)
|
|
||||||
r.registerRouter(cmd.AskAddFriendReq, GAME_MANAGER.AskAddFriendReq)
|
|
||||||
r.registerRouter(cmd.DealAddFriendReq, GAME_MANAGER.DealAddFriendReq)
|
|
||||||
r.registerRouter(cmd.GetOnlinePlayerListReq, GAME_MANAGER.GetOnlinePlayerListReq)
|
|
||||||
r.registerRouter(cmd.PlayerApplyEnterMpReq, GAME_MANAGER.PlayerApplyEnterMpReq)
|
|
||||||
r.registerRouter(cmd.PlayerApplyEnterMpResultReq, GAME_MANAGER.PlayerApplyEnterMpResultReq)
|
|
||||||
r.registerRouter(cmd.PlayerGetForceQuitBanInfoReq, GAME_MANAGER.PlayerGetForceQuitBanInfoReq)
|
|
||||||
r.registerRouter(cmd.GetShopmallDataReq, GAME_MANAGER.GetShopmallDataReq)
|
|
||||||
r.registerRouter(cmd.GetShopReq, GAME_MANAGER.GetShopReq)
|
|
||||||
r.registerRouter(cmd.BuyGoodsReq, GAME_MANAGER.BuyGoodsReq)
|
|
||||||
r.registerRouter(cmd.McoinExchangeHcoinReq, GAME_MANAGER.McoinExchangeHcoinReq)
|
|
||||||
r.registerRouter(cmd.AvatarChangeCostumeReq, GAME_MANAGER.AvatarChangeCostumeReq)
|
|
||||||
r.registerRouter(cmd.AvatarWearFlycloakReq, GAME_MANAGER.AvatarWearFlycloakReq)
|
|
||||||
r.registerRouter(cmd.PullRecentChatReq, GAME_MANAGER.PullRecentChatReq)
|
|
||||||
r.registerRouter(cmd.PullPrivateChatReq, GAME_MANAGER.PullPrivateChatReq)
|
|
||||||
r.registerRouter(cmd.PrivateChatReq, GAME_MANAGER.PrivateChatReq)
|
|
||||||
r.registerRouter(cmd.ReadPrivateChatReq, GAME_MANAGER.ReadPrivateChatReq)
|
|
||||||
r.registerRouter(cmd.PlayerChatReq, GAME_MANAGER.PlayerChatReq)
|
|
||||||
r.registerRouter(cmd.BackMyWorldReq, GAME_MANAGER.BackMyWorldReq)
|
|
||||||
r.registerRouter(cmd.ChangeWorldToSingleModeReq, GAME_MANAGER.ChangeWorldToSingleModeReq)
|
|
||||||
r.registerRouter(cmd.SceneKickPlayerReq, GAME_MANAGER.SceneKickPlayerReq)
|
|
||||||
r.registerRouter(cmd.ChangeMpTeamAvatarReq, GAME_MANAGER.ChangeMpTeamAvatarReq)
|
|
||||||
r.registerRouter(cmd.SceneAvatarStaminaStepReq, GAME_MANAGER.SceneAvatarStaminaStepReq)
|
|
||||||
r.registerRouter(cmd.JoinPlayerSceneReq, GAME_MANAGER.JoinPlayerSceneReq)
|
|
||||||
r.registerRouter(cmd.EvtAvatarEnterFocusNotify, GAME_MANAGER.EvtAvatarEnterFocusNotify)
|
|
||||||
r.registerRouter(cmd.EvtAvatarUpdateFocusNotify, GAME_MANAGER.EvtAvatarUpdateFocusNotify)
|
|
||||||
r.registerRouter(cmd.EvtAvatarExitFocusNotify, GAME_MANAGER.EvtAvatarExitFocusNotify)
|
|
||||||
r.registerRouter(cmd.EvtEntityRenderersChangedNotify, GAME_MANAGER.EvtEntityRenderersChangedNotify)
|
|
||||||
r.registerRouter(cmd.EvtCreateGadgetNotify, GAME_MANAGER.EvtCreateGadgetNotify)
|
|
||||||
r.registerRouter(cmd.EvtDestroyGadgetNotify, GAME_MANAGER.EvtDestroyGadgetNotify)
|
|
||||||
r.registerRouter(cmd.CreateVehicleReq, GAME_MANAGER.CreateVehicleReq)
|
|
||||||
r.registerRouter(cmd.VehicleInteractReq, GAME_MANAGER.VehicleInteractReq)
|
|
||||||
r.registerRouter(cmd.SceneEntityDrownReq, GAME_MANAGER.SceneEntityDrownReq)
|
|
||||||
r.registerRouter(cmd.GetOnlinePlayerInfoReq, GAME_MANAGER.GetOnlinePlayerInfoReq)
|
|
||||||
r.registerRouter(cmd.GCGAskDuelReq, GAME_MANAGER.GCGAskDuelReq)
|
|
||||||
r.registerRouter(cmd.GCGInitFinishReq, GAME_MANAGER.GCGInitFinishReq)
|
|
||||||
r.registerRouter(cmd.GCGOperationReq, GAME_MANAGER.GCGOperationReq)
|
|
||||||
r.registerRouter(cmd.ObstacleModifyNotify, GAME_MANAGER.ObstacleModifyNotify)
|
|
||||||
r.registerRouter(cmd.AvatarUpgradeReq, GAME_MANAGER.AvatarUpgradeReq)
|
|
||||||
r.registerRouter(cmd.AvatarPromoteReq, GAME_MANAGER.AvatarPromoteReq)
|
|
||||||
r.registerRouter(cmd.CalcWeaponUpgradeReturnItemsReq, GAME_MANAGER.CalcWeaponUpgradeReturnItemsReq)
|
|
||||||
r.registerRouter(cmd.WeaponUpgradeReq, GAME_MANAGER.WeaponUpgradeReq)
|
|
||||||
r.registerRouter(cmd.WeaponPromoteReq, GAME_MANAGER.WeaponPromoteReq)
|
|
||||||
r.registerRouter(cmd.WeaponAwakenReq, GAME_MANAGER.WeaponAwakenReq)
|
|
||||||
r.registerRouter(cmd.AvatarPromoteGetRewardReq, GAME_MANAGER.AvatarPromoteGetRewardReq)
|
|
||||||
r.registerRouter(cmd.SetEquipLockStateReq, GAME_MANAGER.SetEquipLockStateReq)
|
|
||||||
r.registerRouter(cmd.TakeoffEquipReq, GAME_MANAGER.TakeoffEquipReq)
|
|
||||||
r.registerRouter(cmd.AddQuestContentProgressReq, GAME_MANAGER.AddQuestContentProgressReq)
|
|
||||||
r.registerRouter(cmd.NpcTalkReq, GAME_MANAGER.NpcTalkReq)
|
|
||||||
r.registerRouter(cmd.EvtAiSyncSkillCdNotify, GAME_MANAGER.EvtAiSyncSkillCdNotify)
|
|
||||||
r.registerRouter(cmd.EvtAiSyncCombatThreatInfoNotify, GAME_MANAGER.EvtAiSyncCombatThreatInfoNotify)
|
|
||||||
r.registerRouter(cmd.EntityConfigHashNotify, GAME_MANAGER.EntityConfigHashNotify)
|
|
||||||
r.registerRouter(cmd.MonsterAIConfigHashNotify, GAME_MANAGER.MonsterAIConfigHashNotify)
|
|
||||||
r.registerRouter(cmd.DungeonEntryInfoReq, GAME_MANAGER.DungeonEntryInfoReq)
|
|
||||||
r.registerRouter(cmd.PlayerEnterDungeonReq, GAME_MANAGER.PlayerEnterDungeonReq)
|
|
||||||
r.registerRouter(cmd.PlayerQuitDungeonReq, GAME_MANAGER.PlayerQuitDungeonReq)
|
|
||||||
r.registerRouter(cmd.GadgetInteractReq, GAME_MANAGER.GadgetInteractReq)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *RouteManager) RouteHandle(netMsg *mq.NetMsg) {
|
|
||||||
switch netMsg.MsgType {
|
|
||||||
case mq.MsgTypeGame:
|
|
||||||
if netMsg.OriginServerType != api.GATE {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
gameMsg := netMsg.GameMsg
|
|
||||||
switch netMsg.EventId {
|
|
||||||
case mq.NormalMsg:
|
|
||||||
if gameMsg.CmdId == cmd.PlayerLoginReq {
|
|
||||||
GAME_MANAGER.PlayerLoginReq(gameMsg.UserId, gameMsg.ClientSeq, netMsg.OriginServerAppId, gameMsg.PayloadMessage)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if gameMsg.CmdId == cmd.SetPlayerBornDataReq {
|
|
||||||
GAME_MANAGER.SetPlayerBornDataReq(gameMsg.UserId, gameMsg.ClientSeq, netMsg.OriginServerAppId, gameMsg.PayloadMessage)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
r.doRoute(gameMsg.CmdId, gameMsg.UserId, gameMsg.ClientSeq, gameMsg.PayloadMessage)
|
|
||||||
}
|
|
||||||
case mq.MsgTypeConnCtrl:
|
|
||||||
if netMsg.OriginServerType != api.GATE {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
connCtrlMsg := netMsg.ConnCtrlMsg
|
|
||||||
switch netMsg.EventId {
|
|
||||||
case mq.ClientRttNotify:
|
|
||||||
GAME_MANAGER.ClientRttNotify(connCtrlMsg.UserId, connCtrlMsg.ClientRtt)
|
|
||||||
case mq.ClientTimeNotify:
|
|
||||||
GAME_MANAGER.ClientTimeNotify(connCtrlMsg.UserId, connCtrlMsg.ClientTime)
|
|
||||||
case mq.UserOfflineNotify:
|
|
||||||
GAME_MANAGER.OnUserOffline(connCtrlMsg.UserId, &ChangeGsInfo{
|
|
||||||
IsChangeGs: false,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
case mq.MsgTypeServer:
|
|
||||||
serverMsg := netMsg.ServerMsg
|
|
||||||
switch netMsg.EventId {
|
|
||||||
case mq.ServerUserOnlineStateChangeNotify:
|
|
||||||
logger.Debug("remote user online state change, uid: %v, online: %v", serverMsg.UserId, serverMsg.IsOnline)
|
|
||||||
USER_MANAGER.SetRemoteUserOnlineState(serverMsg.UserId, serverMsg.IsOnline, netMsg.OriginServerAppId)
|
|
||||||
case mq.ServerAppidBindNotify:
|
|
||||||
GAME_MANAGER.ServerAppidBindNotify(serverMsg.UserId, serverMsg.AnticheatServerAppId, serverMsg.JoinHostUserId)
|
|
||||||
case mq.ServerUserMpReq:
|
|
||||||
GAME_MANAGER.ServerUserMpReq(serverMsg.UserMpInfo, netMsg.OriginServerAppId)
|
|
||||||
case mq.ServerUserMpRsp:
|
|
||||||
GAME_MANAGER.ServerUserMpRsp(serverMsg.UserMpInfo)
|
|
||||||
case mq.ServerChatMsgNotify:
|
|
||||||
GAME_MANAGER.ServerChatMsgNotify(serverMsg.ChatMsgInfo)
|
|
||||||
case mq.ServerAddFriendNotify:
|
|
||||||
GAME_MANAGER.ServerAddFriendNotify(serverMsg.AddFriendInfo)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
var _ api.GMNATSRPCServer = (*GMService)(nil)
|
var _ api.GMNATSRPCServer = (*GMService)(nil)
|
||||||
|
|
||||||
type GMService struct {
|
type GMService struct {
|
||||||
g *game.GameManager
|
g *game.Game
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *GMService) Cmd(ctx context.Context, req *api.CmdRequest) (*api.CmdReply, error) {
|
func (s *GMService) Cmd(ctx context.Context, req *api.CmdRequest) (*api.CmdReply, error) {
|
||||||
|
|||||||
@@ -71,6 +71,11 @@ func (w *WorldStatic) SetTerrain(x int16, y int16, z int16) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *WorldStatic) Pathfinding(startPos alg.MeshVector, endPos alg.MeshVector) (bool, []alg.MeshVector) {
|
func (w *WorldStatic) Pathfinding(startPos alg.MeshVector, endPos alg.MeshVector) (bool, []alg.MeshVector) {
|
||||||
|
defer func() {
|
||||||
|
if err := recover(); err != nil {
|
||||||
|
logger.Error("pathfinding error, panic, startPos: %v, endPos: %v", startPos, endPos)
|
||||||
|
}
|
||||||
|
}()
|
||||||
bfs := alg.NewBFS()
|
bfs := alg.NewBFS()
|
||||||
bfs.InitMap(
|
bfs.InitMap(
|
||||||
w.terrain,
|
w.terrain,
|
||||||
|
|||||||
Reference in New Issue
Block a user