【优化】主城假人改为NPC或者排行榜角色 2
parent
bae3ec50cd
commit
122ccb94e2
|
@ -531,7 +531,7 @@ function this:BindEvent()
|
||||||
-- end
|
-- end
|
||||||
PlayerManager.GetMainPlayerNPCData(function(NPCList)
|
PlayerManager.GetMainPlayerNPCData(function(NPCList)
|
||||||
for i = 1, #NPCList do
|
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.NameText.text = NPCList[i].userName or NPCList[i].name
|
||||||
view:SetAutoMove()
|
view:SetAutoMove()
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
MainPlayerView.__index = MainPlayerView
|
MainPlayerView.__index = MainPlayerView
|
||||||
|
|
||||||
local mapNpcOp = "UI_MainPlayer"
|
local mapNpcOp = "UI_MainPlayer"
|
||||||
function MainPlayerView.New(isSelf, root, rect, pos)
|
function MainPlayerView.New(isSelf, root, rect, pos,_sex)
|
||||||
local instance = {}
|
local instance = {}
|
||||||
setmetatable(instance, MainPlayerView)
|
setmetatable(instance, MainPlayerView)
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ function MainPlayerView.New(isSelf, root, rect, pos)
|
||||||
instance.NameText = Util.GetGameObject(instance.leader, "name/text2"):GetComponent("Text")
|
instance.NameText = Util.GetGameObject(instance.leader, "name/text2"):GetComponent("Text")
|
||||||
Util.GetGameObject(instance.leader, "name/text"):SetActive(false)
|
Util.GetGameObject(instance.leader, "name/text"):SetActive(false)
|
||||||
Util.GetGameObject(instance.leader, "name/text2"):SetActive(true)
|
Util.GetGameObject(instance.leader, "name/text2"):SetActive(true)
|
||||||
sex = math.random(0,1)
|
sex = _sex or math.random(0,1)
|
||||||
end
|
end
|
||||||
instance.NameText.text = PlayerManager.nickName
|
instance.NameText.text = PlayerManager.nickName
|
||||||
|
|
||||||
|
|
|
@ -460,6 +460,8 @@ function this.StopBattleUpLvTipTime()
|
||||||
end
|
end
|
||||||
|
|
||||||
------- 主城NPC 选择star ----------
|
------- 主城NPC 选择star ----------
|
||||||
|
local needNum = 7
|
||||||
|
local needAllNum = 14
|
||||||
local rankNPCList = {}
|
local rankNPCList = {}
|
||||||
local friendNPCList = {}
|
local friendNPCList = {}
|
||||||
function this.GetMainPlayerNPCData(fun)
|
function this.GetMainPlayerNPCData(fun)
|
||||||
|
@ -472,8 +474,8 @@ function this.GetMainPlayerNPCData(fun)
|
||||||
end
|
end
|
||||||
if friendRandomNum == 1 then
|
if friendRandomNum == 1 then
|
||||||
NetManager.RequestGetFriendInfo(1,function(msg)
|
NetManager.RequestGetFriendInfo(1,function(msg)
|
||||||
if #msg.Friends > 9 then
|
if #msg.Friends > needNum then
|
||||||
for i = 1, 9 do
|
for i = 1, needNum do
|
||||||
this.RandomFirendNPC(msg.Friends)
|
this.RandomFirendNPC(msg.Friends)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -488,8 +490,8 @@ function this.GetMainPlayerNPCData(fun)
|
||||||
else
|
else
|
||||||
MyGuildManager.RequestMyGuildMembers(function()
|
MyGuildManager.RequestMyGuildMembers(function()
|
||||||
local MyGuildMemList = MyGuildManager.GetMyGuildMemList()
|
local MyGuildMemList = MyGuildManager.GetMyGuildMemList()
|
||||||
if #MyGuildMemList > 9 then
|
if #MyGuildMemList > needNum then
|
||||||
for i = 1, 9 do
|
for i = 1, needNum do
|
||||||
this.RandomFirendNPC(MyGuildMemList)
|
this.RandomFirendNPC(MyGuildMemList)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -505,8 +507,8 @@ function this.GetMainPlayerNPCData(fun)
|
||||||
end
|
end
|
||||||
function this.GetMainPlayerNPCData2(fun)
|
function this.GetMainPlayerNPCData2(fun)
|
||||||
local rankRandomNum = math.random(1, 4)
|
local rankRandomNum = math.random(1, 4)
|
||||||
local needNum = 9 - LengthOfTable(friendNPCList)
|
local curAddNum = needNum - LengthOfTable(friendNPCList)
|
||||||
needNum = 9 + needNum
|
curAddNum = needNum + curAddNum
|
||||||
-- LogGreen("rankRandomNum "..rankRandomNum)
|
-- LogGreen("rankRandomNum "..rankRandomNum)
|
||||||
RankingManager.InitData(rankKingList[rankRandomNum].rankType, function()
|
RankingManager.InitData(rankKingList[rankRandomNum].rankType, function()
|
||||||
local rankAllList = RankingManager.GetRankingInfo()
|
local rankAllList = RankingManager.GetRankingInfo()
|
||||||
|
@ -516,8 +518,8 @@ function this.GetMainPlayerNPCData2(fun)
|
||||||
table.insert(currankAllList,rankAllList[i])
|
table.insert(currankAllList,rankAllList[i])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if #currankAllList > needNum then
|
if #currankAllList > curAddNum then
|
||||||
for i = 1, needNum do
|
for i = 1, curAddNum do
|
||||||
this.RandomRankNPC(currankAllList)
|
this.RandomRankNPC(currankAllList)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -538,11 +540,11 @@ function this.GetMainPlayerNPCData3(fun)
|
||||||
for key,val in pairs(rankNPCList) do
|
for key,val in pairs(rankNPCList) do
|
||||||
table.insert(upList,val)
|
table.insert(upList,val)
|
||||||
end
|
end
|
||||||
if #upList < 18 then
|
if #upList < needAllNum then
|
||||||
for i = 1, 18 - #upList do
|
for i = 1, needAllNum - #upList do
|
||||||
local singleUserData = {}
|
local singleUserData = {}
|
||||||
singleUserData.userName = NameManager.GetLocalRandomName()
|
singleUserData.userName = NameManager.GetLocalRandomName()
|
||||||
singleUserData.sex = math.random(1, 2)
|
singleUserData.sex = math.random(0,1)
|
||||||
singleUserData.uid = 1000 + i
|
singleUserData.uid = 1000 + i
|
||||||
table.insert(upList,singleUserData)
|
table.insert(upList,singleUserData)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue