148 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			Lua
		
	
			
		
		
	
	
			148 lines
		
	
	
		
			3.9 KiB
		
	
	
	
		
			Lua
		
	
---
 | 
						|
--- Generated by EmmyLua(https://github.com/EmmyLua)
 | 
						|
--- Created by aaa.
 | 
						|
--- DateTime: 2019/8/30 15:42
 | 
						|
---
 | 
						|
local RankInfoView = quick_class("RankInfoView")
 | 
						|
 | 
						|
-- 头像对象管理
 | 
						|
local _PlayerHeadList = {}
 | 
						|
 | 
						|
function RankInfoView:ctor(parent, root)
 | 
						|
    self.root = root
 | 
						|
    self:InitComponent(root)
 | 
						|
    self:BindEvent()
 | 
						|
 | 
						|
end
 | 
						|
 | 
						|
function RankInfoView:InitComponent(root)
 | 
						|
    self.spLoader = SpriteLoader.New()
 | 
						|
    -- 我的排名
 | 
						|
    self.myRank = Util.GetGameObject(root, "myRankInfo/myRank"):GetComponent("Text")
 | 
						|
    self.atkNum = Util.GetGameObject(root, "myRankInfo/atkNum"):GetComponent("Text")
 | 
						|
 | 
						|
    self.rankGrid = Util.GetGameObject(root, "viewRect")
 | 
						|
    self.rankItem = Util.GetGameObject(root, "viewRect/RankInfoPre")
 | 
						|
 | 
						|
    local rootHight = self.rankGrid.transform.rect.height
 | 
						|
    local width = self.rankGrid.transform.rect.width
 | 
						|
 | 
						|
    -- 设置循滚动组件
 | 
						|
    self.ScrollView = SubUIManager.Open(SubUIConfig.ScrollCycleView,  self.rankGrid.transform,
 | 
						|
            self.rankItem, nil, Vector2.New(width, rootHight), 1, 1, Vector2.New(0,-10))
 | 
						|
    self.ScrollView.moveTween.MomentumAmount = 1
 | 
						|
    self.ScrollView.moveTween.Strength = 2
 | 
						|
 | 
						|
    -- 是否请求过数据
 | 
						|
    self.isRequestData = false
 | 
						|
end
 | 
						|
 | 
						|
function RankInfoView:BindEvent(root)
 | 
						|
 | 
						|
end
 | 
						|
 | 
						|
function RankInfoView:ReShowPanel()
 | 
						|
 | 
						|
end
 | 
						|
 | 
						|
function RankInfoView:OnShow()
 | 
						|
    self.root:SetActive(true)
 | 
						|
    RoomManager.RequestBloodyRank(function (msg)
 | 
						|
        -- 设置个人信息
 | 
						|
        self:SetMyInfo(msg.myRank)
 | 
						|
        -- 设置其他的排名信息
 | 
						|
        self:SetOtherInfo(msg.infos)
 | 
						|
    end)
 | 
						|
 | 
						|
end
 | 
						|
 | 
						|
function RankInfoView:SetMyInfo(myRank)
 | 
						|
    local str = ""
 | 
						|
    if not myRank or myRank <= 0 then
 | 
						|
        str = Language[10036]
 | 
						|
    else
 | 
						|
        str = tonumber(myRank)
 | 
						|
    end
 | 
						|
    self.myRank.text = str
 | 
						|
    self.atkNum.text = FormationManager.GetFormationPower(FormationTypeDef.BLOODY_BATTLE_ATTACK)
 | 
						|
 | 
						|
end
 | 
						|
function RankInfoView:SetOtherInfo(rankInfo)
 | 
						|
    local rankFunc = function (index, item)
 | 
						|
        self:RefeshData(item, rankInfo[index])
 | 
						|
    end
 | 
						|
 | 
						|
    self.ScrollView:SetData(rankInfo, rankFunc)
 | 
						|
    self.ScrollView:SetIndex(1)
 | 
						|
end
 | 
						|
 | 
						|
function RankInfoView:RefeshData(item, data)
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    --需要设置的组件
 | 
						|
    local roleLv = Util.GetGameObject(item, "roleInfo/Lv"):GetComponent("Text")
 | 
						|
    local roleName = Util.GetGameObject(item, "roleInfo/Name"):GetComponent("Text")
 | 
						|
    local roleScore = Util.GetGameObject(item, "score"):GetComponent("Text")
 | 
						|
    local serName = Util.GetGameObject(item, "nickName"):GetComponent("Text")
 | 
						|
    local sortFrame = Util.GetGameObject(item, "sortImage"):GetComponent("Image")
 | 
						|
    local rankNum = Util.GetGameObject(item, "sortImage/Text")
 | 
						|
    local headRoot = Util.GetGameObject(item, "head")
 | 
						|
    local nickName = Util.GetGameObject(item, "killNum"):GetComponent("Text")
 | 
						|
 | 
						|
 | 
						|
    roleLv.text = data.level
 | 
						|
    roleName.text = data.name
 | 
						|
    roleScore.text = data.score
 | 
						|
    nickName.text = MatchDataManager.GetNickNameByScore(data.score)
 | 
						|
    serName.text = Language[10754]
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
    -- 排行头像相关的数据
 | 
						|
    sortFrame.sprite = SetRankNumFrame(self.spLoader, data.rank)
 | 
						|
    if data.rank > 3 then
 | 
						|
        rankNum:SetActive(true)
 | 
						|
        rankNum:GetComponent("Text").text = data.rank
 | 
						|
    else
 | 
						|
        rankNum:SetActive(false)
 | 
						|
    end
 | 
						|
 | 
						|
    if not _PlayerHeadList[item] then
 | 
						|
        _PlayerHeadList[item] = SubUIManager.Open(SubUIConfig.PlayerHeadView, headRoot.transform)
 | 
						|
    end
 | 
						|
    _PlayerHeadList[item]:Reset()
 | 
						|
    _PlayerHeadList[item]:SetHead(data.head)
 | 
						|
    _PlayerHeadList[item]:SetFrame(data.headFrame)
 | 
						|
    _PlayerHeadList[item]:SetScale(Vector3.one * 0.9)
 | 
						|
    _PlayerHeadList[item]:SetLayer(this.sortingOrder)
 | 
						|
    _PlayerHeadList[item]:SetEffectScale(0.85)
 | 
						|
 | 
						|
end
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
function RankInfoView:OnHidePanel()
 | 
						|
    self.root:SetActive(false)
 | 
						|
end
 | 
						|
 | 
						|
 | 
						|
function RankInfoView:OnDestroy()
 | 
						|
    self.spLoader:Destroy()
 | 
						|
    -- 头像回收
 | 
						|
    for _, playerHead in pairs(_PlayerHeadList) do
 | 
						|
        playerHead:Recycle()
 | 
						|
    end
 | 
						|
    _PlayerHeadList = {}
 | 
						|
end
 | 
						|
 | 
						|
return RankInfoView
 | 
						|
 |