| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- package model
- import (
- "rocommon/util"
- "roserver/serverproto"
- )
- type RoleMapManager struct {
- aoiMapList map[uint64]*AoiMap //根据工会ID创建aoimap
- playerMapList map[uint64]*AoiMap //快速查找玩家所在的地图[cliID, AoiMap]
- playerUidList map[uint64]*MapRole
- updateTimer util.ServerTimer //主循环定时器
- //todo...
- // 所在服务器dump后的处理,玩家主动离线
- // 玩家进入地图时附带当前处于哪个服务器的信息,后续做dump(主动关闭服务器)处理
- }
- //同步地图个数(公会),主城是一个
- const MAX_AOI_MAP_NUM = 20
- func newAoiRoleMapManager() *RoleMapManager {
- roleMapMag := &RoleMapManager{}
- roleMapMag.aoiMapList = make(map[uint64]*AoiMap)
- roleMapMag.playerMapList = make(map[uint64]*AoiMap)
- roleMapMag.playerUidList = make(map[uint64]*MapRole)
- //主城
- roleMapMag.aoiMapList[0] = NewAoiMap(0)
- roleMapMag.updateTimer = util.NewDurationTimer(util.GetCurrentTime(), 300)
- return roleMapMag
- }
- func (this *RoleMapManager) GetAoiMap(mapType int32, guildId uint64) *AoiMap {
- if mapType == 0 {
- return this.aoiMapList[0]
- } else {
- if aoi, ok := this.aoiMapList[guildId]; ok {
- return aoi
- } else {
- aoi := NewAoiMap(guildId)
- aoi.mapType = mapType
- this.aoiMapList[guildId] = aoi
- return aoi
- }
- }
- }
- func (this *RoleMapManager) Move(pos *serverproto.Position, cliId uint64) {
- //服务器根据固定时间做更新操作,移动包还是下发给客户端
- player, ok := this.playerMapList[cliId]
- if ok {
- player.PlayerMove(pos, cliId)
- }
- }
- func (this *RoleMapManager) Leave(cliId uint64, serviceId string) (uint64, bool) {
- player, ok := this.playerMapList[cliId]
- if ok {
- return player.PlayerLeave(cliId)
- }
- return 0, false
- }
- func (this *RoleMapManager) Update(ms uint64) {
- if !this.updateTimer.IsStart() || !this.updateTimer.IsExpired(ms) {
- return
- }
- for _, aoiMap := range this.aoiMapList {
- aoiMap.Update(ms)
- }
- }
- //显示形象变更
- func (this *RoleMapManager) MapRoleChangeShow(cliId uint64, showInfo *serverproto.PlayerShowInfo) {
- tempMap, ok := this.playerMapList[cliId]
- if ok {
- tempMap.PlayerShowChange(cliId, showInfo)
- }
- }
- //播放动画action
- func (this *RoleMapManager) MapRoleDoAction(cliId, uid uint64, actionId int32, pos *serverproto.Position) {
- tempMap, ok := this.playerMapList[cliId]
- if ok {
- tempMap.MapRoleDoAction(cliId, uid, actionId, pos)
- }
- }
- //设置npc显示
- func (this *RoleMapManager) SummonSetVisible(summonId uint64, visible bool) {
- if this.aoiMapList[0] != nil {
- this.aoiMapList[0].SummonSetVisible(summonId, visible)
- }
- }
- func (this *RoleMapManager) FillAoiPlayerShowInfo(info *serverproto.PlayerShowInfo) bool {
- player, ok := this.playerUidList[info.Uid]
- if !ok {
- return false
- }
- *info = *player.showInfo
- return true
- }
|