2025-08-20 22:34:45 +08:00
|
|
|
package controller
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"blazing/common/socket/errorcode"
|
2025-11-20 05:57:29 +08:00
|
|
|
"sync/atomic"
|
2025-09-14 01:35:16 +08:00
|
|
|
|
2025-12-09 14:52:55 +08:00
|
|
|
"blazing/logic/service/fight"
|
2025-08-20 22:34:45 +08:00
|
|
|
"blazing/logic/service/maphot"
|
|
|
|
|
"blazing/logic/service/maps"
|
2025-11-15 22:17:43 +00:00
|
|
|
"blazing/logic/service/maps/info"
|
2025-09-14 01:35:16 +08:00
|
|
|
"blazing/logic/service/player"
|
2025-08-20 22:34:45 +08:00
|
|
|
"blazing/logic/service/space"
|
2025-08-28 21:35:56 +00:00
|
|
|
|
|
|
|
|
"github.com/jinzhu/copier"
|
2025-08-20 22:34:45 +08:00
|
|
|
)
|
|
|
|
|
|
2025-11-15 22:17:43 +00:00
|
|
|
func (h *Controller) MapEnter(data *maps.InInfo, c *player.Player) (result *info.OutInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
|
2025-08-28 21:35:56 +00:00
|
|
|
|
2025-11-16 11:56:57 +08:00
|
|
|
c.Info.MapID = data.MapId //登录地图
|
|
|
|
|
c.GetSpace().User.Store(c.Info.UserID, c) //添加玩家
|
2025-12-08 00:17:04 +08:00
|
|
|
println("进入地图", c.Info.UserID, c.Info.MapID)
|
2025-11-15 22:17:43 +00:00
|
|
|
result = info.NewOutInfo()
|
2025-08-28 21:35:56 +00:00
|
|
|
c.Info.Pos = data.Point
|
2025-08-30 00:36:08 +08:00
|
|
|
copier.Copy(result, c.Info)
|
2025-11-22 22:57:32 +08:00
|
|
|
|
2025-12-09 14:52:55 +08:00
|
|
|
defer c.GetSpace().EnterMap(c)
|
2025-11-22 22:57:32 +08:00
|
|
|
|
2025-11-16 11:56:57 +08:00
|
|
|
return result, 0
|
2025-08-20 22:34:45 +08:00
|
|
|
}
|
2025-09-14 01:35:16 +08:00
|
|
|
func (h Controller) MapHot(data *maphot.InInfo, c *player.Player) (result *maphot.OutInfo, err errorcode.ErrorCode) {
|
2025-08-20 22:34:45 +08:00
|
|
|
|
|
|
|
|
result = &maphot.OutInfo{
|
|
|
|
|
|
|
|
|
|
HotInfos: space.GetMapHot(),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
}
|
2025-11-15 22:17:43 +00:00
|
|
|
func (h *Controller) MapLeave(data *maps.LeaveMapInboundInfo, c *player.Player) (result *info.LeaveMapOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
|
2025-11-18 22:16:55 +00:00
|
|
|
|
2025-11-20 05:57:29 +08:00
|
|
|
//data.Broadcast(c.Info.MapID, info.LeaveMapOutboundInfo{UserID: c.Info.UserID}) //同步广播
|
|
|
|
|
result = &info.LeaveMapOutboundInfo{
|
|
|
|
|
UserID: c.Info.UserID,
|
|
|
|
|
}
|
2025-11-18 22:16:55 +00:00
|
|
|
defer c.GetSpace().LeaveMap(c) //玩家离开地图
|
2025-11-16 11:56:57 +08:00
|
|
|
|
2025-08-23 17:44:12 +08:00
|
|
|
// 如果有正在运行的刷怪协程,发送停止信号
|
2025-09-21 08:00:58 +00:00
|
|
|
|
2025-11-16 12:23:30 +08:00
|
|
|
//c.Info.MapID = 0 // 重置当前地图
|
2025-11-20 05:57:29 +08:00
|
|
|
return
|
2025-08-20 22:34:45 +08:00
|
|
|
}
|
2025-11-16 11:56:57 +08:00
|
|
|
func (h *Controller) MapList(data *maps.ListMapPlayerInboundInfo, c *player.Player) (result *info.ListMapPlayerOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
|
2025-12-09 14:52:55 +08:00
|
|
|
atomic.StoreUint32(&c.Canmon, 2)
|
2025-12-09 16:52:53 +08:00
|
|
|
atomic.StoreUint32(&c.Canmon, 0)
|
|
|
|
|
if atomic.LoadUint32(&c.GetSpace().TimeBoss.Flag) == 1 {
|
|
|
|
|
defer c.SendPackCmd(2022, &c.GetSpace().TimeBoss)
|
|
|
|
|
}
|
2025-11-16 11:56:57 +08:00
|
|
|
result = &info.ListMapPlayerOutboundInfo{
|
|
|
|
|
Player: c.GetSpace().GetInfo(),
|
|
|
|
|
}
|
2025-10-10 20:46:16 +08:00
|
|
|
|
2025-08-20 22:34:45 +08:00
|
|
|
return
|
|
|
|
|
}
|
2025-12-09 14:52:55 +08:00
|
|
|
func (h *Controller) Attack_Boss(data *maps.AttackBossInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
|
|
|
|
|
|
|
|
|
|
if atomic.LoadInt32(&c.GetSpace().MapBossInfo.Hp) > 0 {
|
|
|
|
|
atomic.AddInt32(&c.GetSpace().MapBossInfo.Hp, -1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
}
|