miduo_client/Assets/ManagedResources/~Lua/Modules/Popup/NameManager.lua

71 lines
2.0 KiB
Lua
Raw Normal View History

2020-08-25 15:46:38 +08:00
local RandomName = ConfigManager.GetConfig(ConfigName.RandomName)
2020-05-09 13:31:21 +08:00
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.LateUpdate()
end
2020-05-09 13:31:21 +08:00
function this.SetRoleName(name)
this.roleName = name
end
function this.SetRoleSex(sex)
2021-03-02 15:49:02 +08:00
local str = sex == ROLE_SEX.BOY and "你是闷骚的小伙子" or "你就是个放荡的丫头片子"
2020-05-09 13:31:21 +08:00
Log(str)
this.roleSex = sex
end
function this.GetLocalRandomName()
local random1 = math.random(1, RandomName.__count)
local random2 = math.random(1, RandomName.__count)
2021-01-26 17:08:39 +08:00
return GetLanguageStrById(RandomName[random1].Sur_name) .. GetLanguageStrById(RandomName[random2].Name)
2020-05-09 13:31:21 +08:00
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,
})
2020-05-09 13:31:21 +08:00
-- 创建角色时保存一下头像数据
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 })
2020-06-23 18:36:24 +08:00
return NameManager