新增多个 BOSS 相关配置字段,包括任务关联、奖励机制与挑战限制等, 增强 BOSS 精灵的可配置性与业务表达能力。同时完善字段注释以对齐 XML 实际使用情况,并保留原有部分字段用于兼容历史配置。 fix(fight): 调整战斗胜利回调执行顺序以确保数据一致性 将战斗结束回调移至广播之前执行,保证在发送战斗结果前已完成所有状态 更新,尤其是针对胜利宠物的信息同步
79 lines
2.0 KiB
Go
79 lines
2.0 KiB
Go
package controller
|
|
|
|
import (
|
|
"blazing/common/socket/errorcode"
|
|
"sync/atomic"
|
|
|
|
"blazing/logic/service/maphot"
|
|
"blazing/logic/service/maps"
|
|
"blazing/logic/service/maps/info"
|
|
"blazing/logic/service/player"
|
|
"blazing/logic/service/space"
|
|
|
|
"github.com/jinzhu/copier"
|
|
)
|
|
|
|
func (h *Controller) MapEnter(data *maps.InInfo, c *player.Player) (result *info.OutInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
|
|
|
|
c.Info.MapID = data.MapId //登录地图
|
|
c.GetSpace().User.Store(c.Info.UserID, c) //添加玩家
|
|
|
|
result = info.NewOutInfo()
|
|
c.Info.Pos = data.Point
|
|
copier.Copy(result, c.Info)
|
|
|
|
defer c.GetSpace().EnterMap(c)
|
|
|
|
// go func() {
|
|
|
|
// for {
|
|
// <-time.After(time.Second * 5)
|
|
|
|
// var t info.MapBossSInfo
|
|
// t.INFO = make([]info.MapBossInfo, 0)
|
|
// t.INFO = append(t.INFO, info.MapBossInfo{
|
|
// Id: 47,
|
|
|
|
// Hp: 1,
|
|
// Pos: 1,
|
|
// })
|
|
// c.SendPackCmd(2021, &t)
|
|
|
|
// }
|
|
|
|
// }()
|
|
return result, 0
|
|
}
|
|
func (h Controller) MapHot(data *maphot.InInfo, c *player.Player) (result *maphot.OutInfo, err errorcode.ErrorCode) {
|
|
|
|
result = &maphot.OutInfo{
|
|
|
|
HotInfos: space.GetMapHot(),
|
|
}
|
|
|
|
return
|
|
}
|
|
func (h *Controller) MapLeave(data *maps.LeaveMapInboundInfo, c *player.Player) (result *info.LeaveMapOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
|
|
|
|
atomic.StoreUint32(&c.Canmon, 0)
|
|
//data.Broadcast(c.Info.MapID, info.LeaveMapOutboundInfo{UserID: c.Info.UserID}) //同步广播
|
|
result = &info.LeaveMapOutboundInfo{
|
|
UserID: c.Info.UserID,
|
|
}
|
|
defer c.GetSpace().LeaveMap(c) //玩家离开地图
|
|
|
|
// 如果有正在运行的刷怪协程,发送停止信号
|
|
|
|
//c.Info.MapID = 0 // 重置当前地图
|
|
return
|
|
}
|
|
func (h *Controller) MapList(data *maps.ListMapPlayerInboundInfo, c *player.Player) (result *info.ListMapPlayerOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
|
|
|
|
result = &info.ListMapPlayerOutboundInfo{
|
|
Player: c.GetSpace().GetInfo(),
|
|
}
|
|
atomic.StoreUint32(&c.Canmon, 2)
|
|
|
|
return
|
|
}
|