【NPC】优化

dev_chengFeng
zhangqiang 2021-01-28 14:48:57 +08:00
parent f1f9c5e118
commit a0a2ac324a
1 changed files with 20 additions and 9 deletions

View File

@ -468,19 +468,25 @@ function this.GetMainPlayerNPCData(fun)
rankNPCList = {}
friendNPCList = {}
local friendRandomNum = math.random(1, 2)
-- LogGreen("friendRandomNum "..friendRandomNum)
if friendRandomNum == 2 and PlayerManager.familyId == 0 then
friendRandomNum = 1
end
-- LogGreen("friendRandomNum "..friendRandomNum)
local curfriendAllList = {}
if friendRandomNum == 1 then
NetManager.RequestGetFriendInfo(1,function(msg)
if #msg.Friends > needNum then
for i = 1, #msg.Friends do
if msg.Friends[i].id ~= PlayerManager.uid then
table.insert(curfriendAllList,msg.Friends[i])
end
end
if #curfriendAllList > needNum then
for i = 1, needNum do
this.RandomFirendNPC(msg.Friends)
this.RandomFirendNPC(curfriendAllList)
end
else
for i = 1, #msg.Friends do
friendNPCList[i] = msg.Friends[i]
for i = 1, #curfriendAllList do
friendNPCList[i] = curfriendAllList[i]
-- LogGreen("friend "..msg.Friends[i].name)
end
end
@ -490,13 +496,18 @@ function this.GetMainPlayerNPCData(fun)
else
MyGuildManager.RequestMyGuildMembers(function()
local MyGuildMemList = MyGuildManager.GetMyGuildMemList()
if #MyGuildMemList > needNum then
for i = 1, #MyGuildMemList do
if MyGuildMemList[i].roleUid ~= PlayerManager.uid then
table.insert(curfriendAllList,MyGuildMemList[i])
end
end
if #curfriendAllList > needNum then
for i = 1, needNum do
this.RandomFirendNPC(MyGuildMemList)
this.RandomFirendNPC(curfriendAllList)
end
else
for i = 1, #MyGuildMemList do
friendNPCList[i] = MyGuildMemList[i]
for i = 1, #curfriendAllList do
friendNPCList[i] = curfriendAllList[i]
-- LogGreen("MyGuildMemList "..MyGuildMemList[i].userName)
end
end