123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- --[[
- Descripttion:角色管理
- version:
- Author: Neo,Huang
- Date: 2023-11-08 22:38:51
- LastEditors: Neo,Huang
- LastEditTime: 2023-11-23 23:31:37
- --]]
- local role = require "role"
- local root = class("roleMgr")
- function root:ctor()
- self.roleList = {}
- self.amount = 0
- end
- function root:login_role(uid, gSession)
- local roleObj = role.new(uid, gSession)
- roleObj:login(gSession)
- log.print("login_role %s", uid)
- self.roleList[uid] = roleObj
- self.amount = self.amount + 1
- end
- function root:logout_role(uid)
- local roleObj = self:get_role_obj(uid)
- if not roleObj then
- return
- end
- log.print("logout_role %s", uid)
- roleObj:logout()
- self.roleList[uid] = nil
- self.amount = self.amount - 1
- end
- function root:get_role_obj(uid)
- return self.roleList[uid]
- end
- function root:get_role_obj_list()
- return self.roleList
- end
- -- 派发游戏事件
- function root:dispath_game_event(uid, eventId, eventParams)
- local roleObj = self:get_role_obj(uid)
- if not roleObj then
- return
- end
- roleObj:dispath_game_event(eventId, eventParams)
- end
- return root
|