------------------------------------------------ --作者: gzg --日期: 2020-11-12 --文件: RandomNameMaker.lua --模块: RandomNameMaker --描述: 玩家角色信息 ------------------------------------------------ local RandomNameMaker = { FirstNameList = nil, BoyNameList = nil, GirlNameList = nil, } --创建对象 function RandomNameMaker:New() local _m = Utils.DeepCopy(self) _m.FirstNameList = List:New(); _m.BoyNameList = List:New(); _m.GirlNameList = List:New(); return _m end --初始化 function RandomNameMaker:Initialize() self.FirstNameList:Clear(); self.BoyNameList:Clear(); self.GirlNameList:Clear(); math.randomseed(os.time()); DataConfig.DataRandomName:Foreach(function (k,v) if v.QType == 1 then self.FirstNameList:Add(v.QValue); elseif v.QType == 2 then self.BoyNameList:Add(v.QValue); elseif v.QType == 3 then self.GirlNameList:Add(v.QValue); end end) end --随机名字 function RandomNameMaker:RandName(isBoy) local _firstName = ""; local _lastName = ""; --这里做判断,泰文和越南不进行名字组合 if (FLanguage.Default ~= FLanguage.TH and FLanguage.Default ~= FLanguage.VIE) then if (self.FirstNameList:Count() > 0) then local _fidx = math.random(1,self.FirstNameList:Count()); _firstName = self.FirstNameList[_fidx]; end end if (isBoy) then if (self.BoyNameList:Count() > 0) then local _bidx = math.random(1,self.BoyNameList:Count()); _lastName = self.BoyNameList[_bidx]; end else if (self.GirlNameList:Count() > 0) then local _gidx = math.random(1,self.GirlNameList:Count()); _lastName = self.GirlNameList[_gidx]; end end return _firstName .. _lastName; end return RandomNameMaker