feat(fight_boss): 更新BOSS战斗效果逻辑以使用新的服务接口 将原来直接访问xmlres.EffectMAP获取效果信息的方式, 替换为通过service.NewEffectService().Args方法获取EID与参数, 提高代码解耦性与可维护性。 refactor(item_buy): 调整金币商品购买时的价格计算逻辑 修复购买金币商品时价格未正确乘以100的问题, 确保消耗金币数量准确无
78 lines
2.0 KiB
Go
78 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) //添加玩家
|
|
println("进入地图", c.Info.UserID, c.Info.MapID)
|
|
result = info.NewOutInfo()
|
|
c.Info.Pos = data.Point
|
|
copier.Copy(result, c.Info)
|
|
atomic.StoreUint32(&c.Canmon, 2)
|
|
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(),
|
|
}
|
|
|
|
return
|
|
}
|