2020-06-28 17:48:49 +08:00
|
|
|
|
local RewardPreview= quick_class("RewardPreview")
|
|
|
|
|
local lotterySetting=ConfigManager.GetConfig(ConfigName.LotterySetting)
|
|
|
|
|
local data={}
|
|
|
|
|
local listPre={}
|
|
|
|
|
local curtimes=0
|
|
|
|
|
function RewardPreview:ctor(gameObject)
|
|
|
|
|
self.gameObject = gameObject
|
|
|
|
|
self:InitComponent(gameObject)
|
|
|
|
|
self:BindEvent()
|
|
|
|
|
self:OnShow()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function RewardPreview:InitComponent(gameObject)
|
|
|
|
|
self.closeBtn=Util.GetGameObject(self.gameObject,"close")
|
|
|
|
|
self.itemGrid=Util.GetGameObject(self.gameObject,"itemGrid")
|
|
|
|
|
self.itemPre=Util.GetGameObject(self.gameObject,"itemprefab")
|
|
|
|
|
self.curtimes=Util.GetGameObject(self.gameObject,"tip1"):GetComponent("Text")
|
2020-07-08 16:19:46 +08:00
|
|
|
|
self.slider=Util.GetGameObject(self.gameObject,"Background/Fill"):GetComponent("Image")
|
2020-06-28 17:48:49 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function RewardPreview:BindEvent()
|
|
|
|
|
Util.AddClick(self.closeBtn.gameObject,function() self:OnHide() end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function RewardPreview:OnShow()
|
|
|
|
|
self.gameObject:SetActive(true)
|
|
|
|
|
local maxtimesId=lotterySetting[RecruitType.TimeLimitSingle].MaxTimes;
|
|
|
|
|
curtimes=PrivilegeManager.GetPrivilegeUsedTimes(maxtimesId)
|
2020-07-08 16:19:46 +08:00
|
|
|
|
self.slider.fillAmount =self: CalculateInterval(curtimes)
|
2020-06-28 17:48:49 +08:00
|
|
|
|
self: RefreshRewarid()
|
|
|
|
|
self.curtimes.text=Language[12181]..curtimes
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function RewardPreview:RefreshRewarid()
|
|
|
|
|
local curActivityId=ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.FindFairy)
|
2020-07-08 16:19:46 +08:00
|
|
|
|
data = ConfigManager.GetAllConfigsDataByKey(ConfigName.ActivityRewardConfig,"ActivityId",curActivityId)
|
2020-06-28 17:48:49 +08:00
|
|
|
|
local tmp=0
|
2020-07-08 16:19:46 +08:00
|
|
|
|
--间隔的总次数 比如:30 60 120 210 300 count=(60-30)+ (120 - 60)+ (210 - 120)+ (300 - 210)= 300 - 30 =270
|
2020-06-28 17:48:49 +08:00
|
|
|
|
local count=0
|
2020-07-08 16:19:46 +08:00
|
|
|
|
-- for n,m in ipairs(data) do
|
|
|
|
|
-- if n~=1 then
|
|
|
|
|
-- count = count + m.Values[1][1]-tmp
|
|
|
|
|
-- end
|
|
|
|
|
-- tmp = m.Values[1][1]
|
|
|
|
|
-- --self.slider.fillAmount = curtimes / m.Values[1][1]
|
|
|
|
|
-- end
|
|
|
|
|
count = data[#data].Values[1][1]
|
2020-06-28 17:48:49 +08:00
|
|
|
|
tmp=0
|
|
|
|
|
local position = 0
|
|
|
|
|
local width = self.itemPre.transform:GetComponent("RectTransform").sizeDelta.x
|
|
|
|
|
local interval = self.itemGrid.transform:GetComponent("RectTransform").sizeDelta.x - (width * #data)
|
|
|
|
|
if(not listPre) then
|
|
|
|
|
listPre={}
|
|
|
|
|
end
|
|
|
|
|
for n,m in ipairs(data) do
|
|
|
|
|
if m then
|
|
|
|
|
if not listPre[n] then
|
|
|
|
|
listPre[n]=newObjToParent(self.itemPre,self.itemGrid)
|
|
|
|
|
listPre[n].gameObject:SetActive(true)
|
|
|
|
|
end
|
|
|
|
|
local o= SubUIManager.Open(SubUIConfig.ItemView,listPre[n].transform)
|
|
|
|
|
o:OnOpen(false, {m.Reward[1][1], m.Reward[1][2]}, 1.1, true)
|
|
|
|
|
o.gameObject:SetActive(true)
|
2020-07-08 16:19:46 +08:00
|
|
|
|
Util.GetGameObject(listPre[n].gameObject,"progress"):GetComponent("Text").text=m.Values[1][1]
|
|
|
|
|
local tempinterval = (m.Values[1][1] - tmp) / count * interval
|
2020-06-28 17:48:49 +08:00
|
|
|
|
if n==1 then
|
2020-07-08 16:19:46 +08:00
|
|
|
|
position = tempinterval
|
|
|
|
|
else
|
|
|
|
|
position = tempinterval + width + position
|
2020-06-28 17:48:49 +08:00
|
|
|
|
end
|
2020-07-08 16:19:46 +08:00
|
|
|
|
listPre[n].transform:GetComponent("RectTransform").anchoredPosition3D=Vector3.New(position,0,0)
|
2020-06-28 17:48:49 +08:00
|
|
|
|
tmp=m.Values[1][1]
|
|
|
|
|
end
|
2020-07-08 16:19:46 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function RewardPreview:CalculateInterval(count)
|
|
|
|
|
local curActivityId=ActivityGiftManager.IsActivityTypeOpen(ActivityTypeDef.FindFairy)
|
|
|
|
|
local data= ConfigManager.GetAllConfigsDataByKey(ConfigName.ActivityRewardConfig,"ActivityId",curActivityId)
|
|
|
|
|
local interval = 0
|
|
|
|
|
LogBlue(#data)
|
|
|
|
|
for n,m in ipairs(data) do
|
|
|
|
|
LogBlue(n.." "..m.Values[1][1])
|
|
|
|
|
end
|
|
|
|
|
if count>=data[1].Values[1][1] then
|
|
|
|
|
interval=0.099
|
|
|
|
|
if count>=data[2].Values[1][1] then
|
|
|
|
|
interval=0.3
|
|
|
|
|
if count>=data[3].Values[1][1] then
|
|
|
|
|
interval=0.54
|
|
|
|
|
if count>=data[4].Values[1][1] then
|
|
|
|
|
interval=0.75
|
|
|
|
|
if count>=data[5].Values[1][1] then
|
|
|
|
|
interval=1
|
|
|
|
|
else
|
|
|
|
|
interval = 0.75+ (count - data[4].Values[1][1]) * (1-0.75)/(data[5].Values[1][1]-data[4].Values[1][1])
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
interval = 0.54+ (count -data[3].Values[1][1])*(0.75-0.54)/(data[4].Values[1][1]-data[3].Values[1][1])
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
interval = 0.3+ (count -data[2].Values[1][1])*(0.54-0.3)/(data[3].Values[1][1]-data[2].Values[1][1])
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
interval = 0.099+ (count -data[1].Values[1][1])*(0.3-0.099)/(data[2].Values[1][1]-data[1].Values[1][1])
|
2020-06-28 17:48:49 +08:00
|
|
|
|
end
|
2020-07-08 16:19:46 +08:00
|
|
|
|
else
|
|
|
|
|
interval = count*0.001
|
|
|
|
|
end
|
|
|
|
|
return interval
|
2020-06-28 17:48:49 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function RewardPreview:OnHide()
|
|
|
|
|
self.gameObject:SetActive(false)
|
|
|
|
|
data={}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function RewardPreview:OnDestroy()
|
|
|
|
|
listPre=nil
|
|
|
|
|
data=nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return RewardPreview
|