From 122ccb94e20a4b47cc9921d675f58250dd4b4f3f Mon Sep 17 00:00:00 2001 From: zhangqiang <657634622@qq.com> Date: Wed, 27 Jan 2021 17:36:33 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BC=98=E5=8C=96=E3=80=91=E4=B8=BB?= =?UTF-8?q?=E5=9F=8E=E5=81=87=E4=BA=BA=E6=94=B9=E4=B8=BANPC=E6=88=96?= =?UTF-8?q?=E8=80=85=E6=8E=92=E8=A1=8C=E6=A6=9C=E8=A7=92=E8=89=B2=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../~Lua/Modules/Main/MainPanel.lua | 2 +- .../~Lua/Modules/Main/View/MainPlayerView.lua | 4 ++-- .../~Lua/Modules/Player/PlayerManager.lua | 24 ++++++++++--------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Assets/ManagedResources/~Lua/Modules/Main/MainPanel.lua b/Assets/ManagedResources/~Lua/Modules/Main/MainPanel.lua index 583b0cdb24..edba8723bd 100644 --- a/Assets/ManagedResources/~Lua/Modules/Main/MainPanel.lua +++ b/Assets/ManagedResources/~Lua/Modules/Main/MainPanel.lua @@ -531,7 +531,7 @@ function this:BindEvent() -- end PlayerManager.GetMainPlayerNPCData(function(NPCList) for i = 1, #NPCList do - local view = MainPlayerView.New(false, this.btnClickMove, rect, Vector2.New(math.random(rect.xMin, rect.xMax), math.random(rect.yMin, rect.yMax))) + local view = MainPlayerView.New(false, this.btnClickMove, rect, Vector2.New(math.random(rect.xMin, rect.xMax), math.random(rect.yMin, rect.yMax)),NPCList[i].sex) view.NameText.text = NPCList[i].userName or NPCList[i].name view:SetAutoMove() end diff --git a/Assets/ManagedResources/~Lua/Modules/Main/View/MainPlayerView.lua b/Assets/ManagedResources/~Lua/Modules/Main/View/MainPlayerView.lua index 2f30d3bdea..2ebee3cc05 100644 --- a/Assets/ManagedResources/~Lua/Modules/Main/View/MainPlayerView.lua +++ b/Assets/ManagedResources/~Lua/Modules/Main/View/MainPlayerView.lua @@ -2,7 +2,7 @@ MainPlayerView.__index = MainPlayerView local mapNpcOp = "UI_MainPlayer" -function MainPlayerView.New(isSelf, root, rect, pos) +function MainPlayerView.New(isSelf, root, rect, pos,_sex) local instance = {} setmetatable(instance, MainPlayerView) @@ -25,7 +25,7 @@ function MainPlayerView.New(isSelf, root, rect, pos) instance.NameText = Util.GetGameObject(instance.leader, "name/text2"):GetComponent("Text") Util.GetGameObject(instance.leader, "name/text"):SetActive(false) Util.GetGameObject(instance.leader, "name/text2"):SetActive(true) - sex = math.random(0,1) + sex = _sex or math.random(0,1) end instance.NameText.text = PlayerManager.nickName diff --git a/Assets/ManagedResources/~Lua/Modules/Player/PlayerManager.lua b/Assets/ManagedResources/~Lua/Modules/Player/PlayerManager.lua index 5883c19aea..776df7d755 100644 --- a/Assets/ManagedResources/~Lua/Modules/Player/PlayerManager.lua +++ b/Assets/ManagedResources/~Lua/Modules/Player/PlayerManager.lua @@ -460,6 +460,8 @@ function this.StopBattleUpLvTipTime() end ------- 主城NPC 选择star ---------- +local needNum = 7 +local needAllNum = 14 local rankNPCList = {} local friendNPCList = {} function this.GetMainPlayerNPCData(fun) @@ -472,8 +474,8 @@ function this.GetMainPlayerNPCData(fun) end if friendRandomNum == 1 then NetManager.RequestGetFriendInfo(1,function(msg) - if #msg.Friends > 9 then - for i = 1, 9 do + if #msg.Friends > needNum then + for i = 1, needNum do this.RandomFirendNPC(msg.Friends) end else @@ -488,8 +490,8 @@ function this.GetMainPlayerNPCData(fun) else MyGuildManager.RequestMyGuildMembers(function() local MyGuildMemList = MyGuildManager.GetMyGuildMemList() - if #MyGuildMemList > 9 then - for i = 1, 9 do + if #MyGuildMemList > needNum then + for i = 1, needNum do this.RandomFirendNPC(MyGuildMemList) end else @@ -505,8 +507,8 @@ function this.GetMainPlayerNPCData(fun) end function this.GetMainPlayerNPCData2(fun) local rankRandomNum = math.random(1, 4) - local needNum = 9 - LengthOfTable(friendNPCList) - needNum = 9 + needNum + local curAddNum = needNum - LengthOfTable(friendNPCList) + curAddNum = needNum + curAddNum -- LogGreen("rankRandomNum "..rankRandomNum) RankingManager.InitData(rankKingList[rankRandomNum].rankType, function() local rankAllList = RankingManager.GetRankingInfo() @@ -516,8 +518,8 @@ function this.GetMainPlayerNPCData2(fun) table.insert(currankAllList,rankAllList[i]) end end - if #currankAllList > needNum then - for i = 1, needNum do + if #currankAllList > curAddNum then + for i = 1, curAddNum do this.RandomRankNPC(currankAllList) end else @@ -538,11 +540,11 @@ function this.GetMainPlayerNPCData3(fun) for key,val in pairs(rankNPCList) do table.insert(upList,val) end - if #upList < 18 then - for i = 1, 18 - #upList do + if #upList < needAllNum then + for i = 1, needAllNum - #upList do local singleUserData = {} singleUserData.userName = NameManager.GetLocalRandomName() - singleUserData.sex = math.random(1, 2) + singleUserData.sex = math.random(0,1) singleUserData.uid = 1000 + i table.insert(upList,singleUserData) end