69 lines
1.9 KiB
Lua
69 lines
1.9 KiB
Lua
local RandomName = ConfigManager.GetConfig(ConfigName.RandomName)
|
|
local this = {
|
|
roleName = "",
|
|
roleSex = ROLE_SEX.BOY
|
|
}
|
|
|
|
local function readonly(t,k,v)
|
|
Log(string.format("field \"%s\" is read-only", tostring(k)))
|
|
end
|
|
|
|
local function indexer(t,k)
|
|
if not this[k] then
|
|
Log(string.format("field \"%s\" not found", tostring(k)))
|
|
end
|
|
return this[k]
|
|
end
|
|
|
|
function this.Initialize()
|
|
end
|
|
|
|
function this.SetRoleName(name)
|
|
this.roleName = name
|
|
end
|
|
function this.SetRoleSex(sex)
|
|
local str = sex == ROLE_SEX.BOY and Language[11574] or Language[11575]
|
|
Log(str)
|
|
this.roleSex = sex
|
|
end
|
|
|
|
function this.GetLocalRandomName()
|
|
local random1 = math.random(1, RandomName.__count)
|
|
local random2 = math.random(1, RandomName.__count)
|
|
return RandomName[random1].Sur_name .. RandomName[random2].Name
|
|
end
|
|
|
|
--得到任意名字数据
|
|
function this.GetRandomNameData()
|
|
NetManager.GetRandomNameRequest(function(randomName)
|
|
if randomName~="" then
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Player.OnNameChange, randomName)
|
|
end
|
|
end)
|
|
end
|
|
|
|
--更改玩家姓名
|
|
function this.ChangeUserName(type, name, teamPosId, sex, callBack)
|
|
NetManager.ChangeUserNameRequest(type, name, teamPosId, sex, function()
|
|
this.roleSex = sex
|
|
this.roleName = name
|
|
PlayerManager.nickName = name
|
|
|
|
-- 打点静态数据修改
|
|
ThinkingAnalyticsManager.SetSuperProperties({
|
|
role_name = PlayerManager.nickName,
|
|
})
|
|
-- 创建角色时保存一下头像数据
|
|
if type == 1 then
|
|
local config = ConfigManager.GetConfigDataByKey(ConfigName.PlayerRole, "Role", sex)
|
|
PlayerManager.head = config.RolePic
|
|
end
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Player.OnChangeName)
|
|
if callBack then callBack() end
|
|
end)
|
|
end
|
|
|
|
NameManager = {}
|
|
setmetatable(NameManager, { __index = indexer, __newindex = readonly })
|
|
return NameManager |