-- <*
|
|
-- @Author: huangcong
|
|
-- @Description: 源能转盘
|
|
-- *>
|
|
PowerTurnTableView = PowerTurnTableView or BaseClass(BaseView)
|
|
local PowerTurnTableView = PowerTurnTableView
|
|
|
|
function PowerTurnTableView:__init()
|
|
self.base_file = "powerTurnTable"
|
|
self.layout_file = "PowerTurnTableView"
|
|
self.layer_name = "UI"
|
|
self.destroy_imm = true
|
|
self.use_background = true --全屏界面默认使用这个参数,非全屏界面自行设置
|
|
self.change_scene_close = false
|
|
self.append_to_ctl_queue = true --添加进入控制队列
|
|
self:AddPreLoadList("powerTurnTable", {"PowerTurnTableRecordItem"})
|
|
self.model = PowerTurnTableModel:getInstance()
|
|
self.base_type = CustomActivityModel.CustomActBaseType.POWER_TURNTABLE
|
|
self.sub_type = CustomActivityModel:getInstance():getActMinSubType(self.base_type)
|
|
self.record_item_list = {}
|
|
self.choose_list = {}
|
|
self.choose_index = 0
|
|
self.show_goods_num = 10
|
|
self.cur_pointer_angle = 0--当前指针旋转角度
|
|
self.is_skip_action = self.model.is_skip_turn_table_action--是否跳过抽奖动画
|
|
CustomActivityModel:getInstance():SetGoodsCanFly(false)
|
|
self.load_callback = function ()
|
|
self:LoadSuccess()
|
|
self:AddEvent()
|
|
end
|
|
self.open_callback = function ( )
|
|
self:UpdateView()
|
|
end
|
|
self.destroy_callback = function ( )
|
|
self:DestroySuccess()
|
|
end
|
|
end
|
|
|
|
function PowerTurnTableView:Hide( )
|
|
BaseView.Hide(self)
|
|
CustomActivityModel:getInstance():SetGoodsCanFly(true)
|
|
end
|
|
|
|
function PowerTurnTableView:CancelHide( )
|
|
BaseView.CancelHide(self)
|
|
CustomActivityModel:getInstance():SetGoodsCanFly(false)
|
|
end
|
|
|
|
function PowerTurnTableView:Open(sub_type)
|
|
self.sub_type = sub_type or self.sub_type
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function PowerTurnTableView:LoadSuccess()
|
|
local nodes = {
|
|
"bg:raw","timeText:tmp", "titleText:tmp", "skip_toggle:tog:obj",
|
|
"tipText2:tmp", "tipText1:tmp", "curSoreText:tmp","oneBtn/freeText:tmp",
|
|
"showImg:img", "numText:tmp", "record_scroll/Viewport/record_con", "record_scroll",
|
|
"skip_toggle/Label:tmp", "moneyCon", "btn/btnMax:obj", "btn/btnImg:obj","btn/maxEffect", "scoreBtn/scoreBtnRed:obj",
|
|
--表盘
|
|
"pointer",
|
|
--按钮
|
|
"oneBtn:obj", "oneBtn/oneBtnRedDot:obj", "oneBtn/oneBtnTimeText:tmp", "oneBtn/oneBtnText:tmp", "oneBtn/oneBtnGoodsImg:img",
|
|
"tenBtn:obj", "tenBtn/tenBtnTimeText:tmp", "tenBtn/tenBtnGoodsImg:img", "tenBtn/tenBtnText:tmp",
|
|
"scoreBtn:obj","tipText2/helpBtn:obj", "closeBtn:obj", "scoreBtn/effect", "titleText/probabilityBtn:obj",
|
|
}
|
|
self:GetChildren(nodes)
|
|
|
|
|
|
self.titleText_tmp.text = "获奖记录"
|
|
self.tipText1_tmp.text = "源能值满必得二等奖及以上奖励哦~"
|
|
self.tipText2_tmp.text = string.format("每转动1次获得<color=#fdffc2>%s</color>积分",Config.Sourceturntablekv["turn_score"].val)
|
|
self.tenBtnText_tmp.text = "转动 10 次"
|
|
self.oneBtnText_tmp.text = "转动 1 次"
|
|
self.Label_tmp.text = "跳过动画"
|
|
self.skip_toggle_tog.isOn = self.is_skip_action
|
|
|
|
local show_img_res_index = 1
|
|
local act_list = CustomActivityModel:getInstance():getActList(self.base_type, self.sub_type)
|
|
local is_use_artword = false
|
|
if act_list and act_list.condition_list then
|
|
for k,v in ipairs(act_list.condition_list) do
|
|
if v[1] == "show_bg" then
|
|
show_img_res_index = tonumber(v[2])
|
|
break
|
|
end
|
|
end
|
|
end
|
|
lua_resM:setImageSprite(self, self.showImg_img, "powerTurnTable_asset", "powerTurnTable_show_img"..show_img_res_index)
|
|
|
|
self.item_list = {}
|
|
for i=1,10 do
|
|
self.item_list[i] = {}
|
|
self.item_list[i].box_trm = self:GetChild("box"..i)
|
|
self.item_list[i].award_item = UIObjPool:getInstance():PopItem(UIObjPool.UIType.AwardItem, self.item_list[i].box_trm)
|
|
self.item_list[i].award_item:SetItemSize(78,78)
|
|
self.item_list[i].award_item:SetIsAct(true)
|
|
self.item_list[i].choose_bg_obj = self:GetChild("light"..i).gameObject
|
|
self.item_list[i].tipImg_img = self:GetChild("tipImg"..i):GetComponent("Image")
|
|
self.item_list[i].tipImg_obj = self:GetChild("tipImg"..i).gameObject
|
|
self.item_list[i].awardNum_tmp = self:GetChild("awardNum"..i):GetComponent(typeof(TMPro.TextMeshProUGUI))
|
|
end
|
|
lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetViewBigBg("powerTurnTable_bg"), false)
|
|
|
|
self.model:Fire(PowerTurnTableModel.REQUEST_INFO,33505,self.sub_type)
|
|
|
|
if not self.money_view then
|
|
self.money_view = UIMoneyView.New(self.moneyCon)
|
|
end
|
|
self.money_view:SetPosition(0,0)
|
|
self.money_view:SetData()
|
|
|
|
self:SetActDetailShow()
|
|
|
|
if not self.model.login_red_list[self.sub_type] then--清除登陆红点
|
|
self.model.login_red_list[self.sub_type] = true
|
|
self.model:CheckPowerTurnTableMainRedDot(self.sub_type)
|
|
end
|
|
end
|
|
|
|
function PowerTurnTableView:AddEvent()
|
|
local function on_click( target,x,y )
|
|
if target == self.oneBtn_obj then--抽一次
|
|
self:LuckyDraw(1,x,y)
|
|
elseif target == self.tenBtn_obj then--抽十次
|
|
self:LuckyDraw(10,x,y)
|
|
elseif target == self.skip_toggle_obj then--取消动画
|
|
self.is_skip_action = not self.is_skip_action
|
|
self.model.is_skip_turn_table_action = self.is_skip_action
|
|
elseif target == self.scoreBtn_obj then--积分兑换
|
|
self.model:Fire(PowerTurnTableModel.OPEN_EXCHANGE_VIEW,self.sub_type)
|
|
self.model:SetPowerTTScoreCookie(self.sub_type,TimeUtil:getServerTime( ))
|
|
self:UpdateView()
|
|
elseif target == self.helpBtn_obj then--帮助按钮
|
|
EventSystem.Fire(GlobalEventSystem,EventName.OPEN_INSTRUCTION_VIEW, 33500)
|
|
elseif target == self.closeBtn_obj then--关闭按钮
|
|
if self.is_playing then
|
|
Message.show("正在动画中哦")
|
|
return
|
|
end
|
|
self:Close()
|
|
elseif target == self.probabilityBtn_obj then--概率按钮
|
|
UIToolTipMgr:getInstance():AppendLuckyProbTips(331, self.base_type, self.sub_type)
|
|
end
|
|
end
|
|
AddClickEvent(self.closeBtn_obj, on_click)
|
|
AddClickEvent(self.helpBtn_obj, on_click)
|
|
AddClickEvent(self.skip_toggle_obj, on_click)
|
|
AddClickEvent(self.scoreBtn_obj, on_click)
|
|
AddClickEvent(self.oneBtn_obj, on_click)
|
|
AddClickEvent(self.tenBtn_obj, on_click)
|
|
AddClickEvent(self.probabilityBtn_obj, on_click)
|
|
|
|
|
|
local function start_action(subtype, id_list,cur_point)
|
|
if self.sub_type == subtype and not self._use_delete_method then
|
|
for i,v in ipairs(self.item_list) do--重置一遍状态
|
|
v.choose_bg_obj:SetActive(false)
|
|
v.awardNum_tmp.text = ""
|
|
end
|
|
|
|
self.id_list = id_list
|
|
local choose_list = {}
|
|
local choose_action_list = {}
|
|
for i,v in ipairs(id_list) do
|
|
if not choose_list[v.id] then
|
|
choose_list[v.id] = {num = 0,id = v.id}
|
|
end
|
|
choose_list[v.id] = {num = choose_list[v.id].num + 1,id = v.id}
|
|
choose_action_list[#choose_action_list + 1] = {num = choose_list[v.id].num,id = v.id}
|
|
end
|
|
self.choose_action_list = choose_action_list
|
|
self.show_award_list = DeepCopy(choose_action_list)
|
|
if #self.id_list > 1 then
|
|
self.action_time = Config.Sourceturntablekv["ten_time"].val/self.show_goods_num
|
|
self.quan_num = 2
|
|
else
|
|
self.action_time = Config.Sourceturntablekv["one_time"].val
|
|
self.quan_num = 3
|
|
end
|
|
self.cur_point = cur_point + Config.Sourceturntablekv["turn_luck"].val
|
|
|
|
--提前更新按钮状态
|
|
self:UpdateFreeState()
|
|
|
|
self:PlayAction()
|
|
end
|
|
end
|
|
self:BindEvent(self.model, PowerTurnTableModel.START_TURN_ACTION, start_action)
|
|
|
|
|
|
local function update_view_func(subtype)
|
|
if self.sub_type == subtype and not self._use_delete_method then
|
|
self:UpdateView()
|
|
end
|
|
end
|
|
self:BindEvent(self.model, PowerTurnTableModel.UPDATE_VIEW_INFO, update_view_func)
|
|
|
|
local function update_record_func(subtype)
|
|
if self.sub_type == subtype and not self._use_delete_method then
|
|
self:UpdateRecordItemList()
|
|
end
|
|
end
|
|
self:BindEvent(self.model, PowerTurnTableModel.UPDATE_RECORD_INFO, update_record_func)
|
|
end
|
|
|
|
function PowerTurnTableView:UpdateView()
|
|
self.server_info = self.model:GetPowerTurnTableInfo(self.sub_type)
|
|
if not self.server_info or not self.server_info.sub_type then
|
|
return
|
|
end
|
|
|
|
self:UpdateFreeState()
|
|
self.curSoreText_tmp.text = string.format("当前积分:<color=%s>%s</color>", ColorUtil.YELLOW_DARK, self.server_info.score)
|
|
-- self:ClearUIEffect(self.effect)
|
|
-- if self.server_info.score > 0 then
|
|
-- self:AddUIEffect("ui_effect_shouchong05_1", self.effect, self.layer_name, nil, 1, false,nil,nil,nil,nil,nil)
|
|
-- end
|
|
local cur = self.server_info.point
|
|
local max = Config.Sourceturntablekv["luck_total"].val
|
|
self.numText_tmp.text = string.format("%s/%s",cur,max)
|
|
self.btnMax_obj:SetActive(cur >= max)
|
|
self.btnImg_obj:SetActive(cur < max)
|
|
self:ClearUIEffect(self.maxEffect)
|
|
self.maxEffect.gameObject:SetActive(cur >= max)
|
|
if cur >= max then
|
|
self:AddUIEffect("angericon", self.maxEffect, self.layer_name, nil, 1.2, true, nil, nil, nil)
|
|
self.numText_tmp.text = ""
|
|
end
|
|
self:UpdateTurnTable()
|
|
self:UpdateCost()
|
|
local score_red = false
|
|
local last_time_list = self.model:GetPowerTTScoreCookie()
|
|
if not last_time_list[self.sub_type] then
|
|
score_red = true
|
|
end
|
|
score_red = score_red or (self.model.time_red_list[self.sub_type] and self.model.can_exchange_red_list[self.sub_type])
|
|
self.scoreBtnRed_obj:SetActive(score_red and self.server_info.score > 0)
|
|
end
|
|
|
|
function PowerTurnTableView:UpdateFreeState( )
|
|
local is_free = self.server_info and self.server_info.free_time > 0 and true or false
|
|
self.freeText_tmp.text = not is_free and "" or HtmlColorTxt("免费", ColorUtil.GREEN_DARK)
|
|
self.oneBtnGoodsImg.gameObject:SetActive(not is_free)
|
|
self.oneBtnTimeText.gameObject:SetActive(not is_free)
|
|
self.oneBtnRedDot_obj:SetActive(is_free)
|
|
end
|
|
|
|
function PowerTurnTableView:ShowGetReward( )
|
|
--触发快捷使用
|
|
OperateActivityModel:getInstance():Fire(OperateActivityModel.QUIK_USE, true)
|
|
--道具飞背包
|
|
local goods_data = self.server_info.pool_list[self.choose_index]
|
|
if not goods_data then
|
|
print("huangcong:PowerTurnTableView [start:130] self.choose_index:", self.choose_index)
|
|
return
|
|
end
|
|
local goods_fly_data = {[1] = goods_data.reward[2]}
|
|
if TableSize(goods_fly_data) > 0 then
|
|
MainUIModel:getInstance():PlayGoodsFlyList(goods_fly_data)
|
|
end
|
|
--飘字
|
|
goods_fly_data = {
|
|
[1] = {
|
|
goods_type_id = goods_data.reward[2],
|
|
num = goods_data.reward[3],
|
|
}
|
|
}
|
|
if TableSize(goods_fly_data) > 0 then
|
|
MainUIModel:getInstance():AddFloatInfo(goods_fly_data, true)
|
|
end
|
|
end
|
|
|
|
function PowerTurnTableView:ShowTagAwardList( )
|
|
local need_open = false
|
|
local new_award_list = {}
|
|
for i,v in ipairs(self.show_award_list) do
|
|
local cur_goods_data = self.server_info.pool_list[v.id]
|
|
if cur_goods_data.tag > 0 then
|
|
need_open = true
|
|
end
|
|
new_award_list[#new_award_list + 1] = {cur_goods_data.reward[1], cur_goods_data.reward[2], cur_goods_data.reward[3]}
|
|
end
|
|
if need_open then
|
|
GiftModel:getInstance():Fire(GiftModel.OPEN_SHOW_ACT_GOODS_VIEW, new_award_list)
|
|
end
|
|
end
|
|
|
|
function PowerTurnTableView:PlayAction()
|
|
local choose_data = self.choose_action_list[1]
|
|
if not choose_data or not choose_data.num then return end
|
|
self:ClearTweener()
|
|
self.is_playing = true
|
|
self.choose_index = choose_data.id
|
|
local end_callback = function ()
|
|
self:SetSelectLight(choose_data.id,choose_data.num)
|
|
if #self.choose_action_list > 0 then
|
|
table.remove(self.choose_action_list, 1)
|
|
end
|
|
local cur = self.cur_point
|
|
local max = Config.Sourceturntablekv["luck_total"].val
|
|
self.numText_tmp.text = string.format("%s/%s",cur,max)
|
|
self.btnMax_obj:SetActive(cur >= max)
|
|
self.btnImg_obj:SetActive(cur < max)
|
|
self:ClearUIEffect(self.maxEffect)
|
|
self.maxEffect.gameObject:SetActive(cur >= max)
|
|
self:ShowGetReward()
|
|
if cur >= max then
|
|
self:AddUIEffect("angericon", self.maxEffect, self.layer_name, nil, 1.2, true, nil, nil, nil)
|
|
self.numText_tmp.text = ""
|
|
end
|
|
if #self.choose_action_list > 0 then
|
|
self.cur_point = self.cur_point + Config.Sourceturntablekv["turn_luck"].val
|
|
self:PlayAction()
|
|
else
|
|
self:ShowTagAwardList()
|
|
self.is_playing = false
|
|
self.model:Fire(PowerTurnTableModel.UPDATE_VIEW_INFO,self.sub_type)
|
|
end
|
|
end
|
|
|
|
local angle1 = -(self.choose_index - 1) * 360 / self.show_goods_num - 360 * self.quan_num
|
|
if self.is_skip_action then
|
|
self.pointer.localRotation = Quaternion.Euler(0,0,angle1)
|
|
end_callback()
|
|
else
|
|
self.out_tween_id = TweenLite.to(self, self.pointer, TweenLite.UiAnimationType.ROTATION, angle1, self.action_time, end_callback, TweenFunc.EASE_OUT)
|
|
end
|
|
self.cur_pointer_angle = angle1
|
|
end
|
|
|
|
function PowerTurnTableView:ClearTweener()
|
|
if self.out_tween_id then
|
|
TweenLite.Stop(self.out_tween_id)
|
|
self.out_tween_id = nil
|
|
end
|
|
end
|
|
|
|
function PowerTurnTableView:SetSelectLight( index,num )
|
|
if self.item_list[index] then
|
|
self.item_list[index].choose_bg_obj:SetActive(true)
|
|
if num > 0 then
|
|
self.item_list[index].awardNum_tmp.text = "x"..num
|
|
else
|
|
self.item_list[index].awardNum_tmp.text = ""
|
|
end
|
|
end
|
|
end
|
|
|
|
--更新转盘数据
|
|
function PowerTurnTableView:UpdateTurnTable( )
|
|
local award_cfg_list = self.server_info.pool_list
|
|
if not award_cfg_list or #award_cfg_list == 0 then return end
|
|
for i=1,10 do
|
|
local info = award_cfg_list[i]
|
|
if info then
|
|
self.item_list[i].award_item:SetDataWithMapId(info.reward[2],info.reward[3])
|
|
self.item_list[i].tipImg_obj:SetActive(info.tag > 0)
|
|
if info.tag > 0 then
|
|
lua_resM:setImageSprite(self, self.item_list[i].tipImg_img, "powerTurnTable_asset", "powerTurnTable_tag_"..info.tag)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
--更新消耗
|
|
function PowerTurnTableView:UpdateCost( )
|
|
local one_data = Config.Sourceturntablekv["turn_cost_1"].val
|
|
local ten_data = Config.Sourceturntablekv["turn_cost_10"].val
|
|
if not one_data or not ten_data then return end
|
|
local goods_num = GoodsModel:getInstance():GetTypeGoodsNum(self.cost_id)
|
|
self.cost_id = tonumber(stringtotable(ten_data)[1][2])
|
|
local one_cost_num = tonumber(stringtotable(one_data)[1][3])
|
|
local ten_cost_num = tonumber(stringtotable(ten_data)[1][3])
|
|
-- self.oneBtnTimeText_tmp.text = HtmlColorTxt("X"..one_cost_num, one_cost_num > goods_num and ColorUtil.RED_DARK or ColorUtil.GREEN_DARK)
|
|
-- self.tenBtnTimeText_tmp.text = HtmlColorTxt("X"..ten_cost_num, ten_cost_num > goods_num and ColorUtil.RED_DARK or ColorUtil.GREEN_DARK)
|
|
self.oneBtnTimeText_tmp.text = one_cost_num
|
|
self.tenBtnTimeText_tmp.text = ten_cost_num
|
|
self.one_cost_num = one_cost_num
|
|
self.ten_cost_num = ten_cost_num
|
|
|
|
|
|
local goods_basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(self.cost_id)
|
|
lua_resM:setOutsideImageSprite(self, self.oneBtnGoodsImg_img, GameResPath.GetGoodsIcon(goods_basic.goods_icon), false)
|
|
lua_resM:setOutsideImageSprite(self, self.tenBtnGoodsImg_img, GameResPath.GetGoodsIcon(goods_basic.goods_icon), false)
|
|
self.money_view:ChangeShowFlag("PowerTurnTable",self.cost_id)
|
|
end
|
|
|
|
function PowerTurnTableView:DestroySuccess( )
|
|
self:ClearUIEffect(self.btnImg)
|
|
self:ClearUIEffect(self.effect)
|
|
CustomActivityModel:getInstance():SetGoodsCanFly(true)
|
|
if self.money_view then
|
|
self.money_view:DeleteMe()
|
|
self.money_view = nil
|
|
end
|
|
self:ClearTweener()
|
|
self:StopRecordItemAction()
|
|
for i,v in ipairs(self.item_list) do
|
|
if v.award_item then
|
|
UIObjPool:getInstance():PushItem(UIObjPool.UIType.AwardItem, v.award_item)
|
|
v.award_item = nil
|
|
end
|
|
end
|
|
for i,v in ipairs(self.record_item_list) do
|
|
v:DeleteMe()
|
|
v = nil
|
|
end
|
|
self.record_item_list = {}
|
|
end
|
|
|
|
function PowerTurnTableView:LuckyDraw( lucky_num,x,y )
|
|
if self.is_playing then
|
|
Message.show("正在动画中哦")
|
|
return
|
|
end
|
|
|
|
if self.server_info and self.server_info.free_time > 0 and lucky_num == 1 then
|
|
CustomActivityModel:getInstance():SetGoodsCanFly(false)
|
|
self.model:Fire(PowerTurnTableModel.REQUEST_INFO,33504,self.sub_type,lucky_num>1 and 2 or 1,self.is_skip_action and 1 or 0)
|
|
return
|
|
end
|
|
|
|
local goods_num = GoodsModel:getInstance():GetTypeGoodsNum(self.cost_id)
|
|
if lucky_num > goods_num then
|
|
-- Message.show("转盘道具数量不足哦!")
|
|
-- UIToolTipMgr:getInstance():AppendGoodsTips(self.cost_id, x, y, nil)
|
|
local jin = RoleManager.Instance.mainRoleInfo.jin
|
|
local one_price = GoodsModel:getInstance():GetGoodsPrice(self.cost_id) or 60
|
|
local good_num = GoodsModel:getInstance():GetTypeGoodsNum(self.cost_id)
|
|
local good_name = GoodsModel:getInstance():getGoodsName(self.cost_id,true)
|
|
local num = lucky_num > 1 and self.ten_cost_num or self.one_cost_num
|
|
local function ok( ... )
|
|
if jin >= one_price*(num - good_num) then
|
|
CustomActivityModel:getInstance():SetGoodsCanFly(false)
|
|
self.model:Fire(PowerTurnTableModel.REQUEST_INFO,33504,self.sub_type,lucky_num>1 and 2 or 1,self.is_skip_action and 1 or 0)
|
|
else
|
|
local qc_data = {
|
|
price = one_price*(num - good_num),
|
|
}
|
|
GlobalEventSystem:Fire(EventName.OPEN_RECHARGE_TIP_VIEW, true, qc_data)
|
|
end
|
|
end
|
|
|
|
if self.model.buy_toggle[self.sub_type] then
|
|
ok()
|
|
else
|
|
local need_price = one_price*(num - good_num)
|
|
local need_num = math.ceil(need_price/one_price)
|
|
local cur_type_str = string.format("抽奖 %s 次",HtmlColorTxt(lucky_num, ColorUtil.GREEN_DARK))
|
|
if cur_view_cfg then
|
|
cur_type_str = cur_type_str
|
|
end
|
|
local function toggle_function( flag )
|
|
self.model.buy_toggle[self.sub_type] = flag
|
|
end
|
|
local asset, source = WordManager:GetCommonMoneyIcon(1)
|
|
local toggle_tip_data = {
|
|
gold_ab_res = asset,
|
|
gold_res = source,
|
|
price = need_price,
|
|
insufficientText = "",
|
|
priceText = string.format("<color=%s>%s</color> 补齐所需的 %s\n%s",ColorUtil.YELLOW_DARK,need_price,good_name,cur_type_str),
|
|
titleText = "提示",
|
|
ok_callback = ok,
|
|
toggle_function = toggle_function,
|
|
is_complex_ok_callback = true,
|
|
}
|
|
GlobalEventSystem:Fire(EventName.OPEN_COM_TOGGLE_TIP_VIEW, toggle_tip_data)
|
|
end
|
|
else
|
|
CustomActivityModel:getInstance():SetGoodsCanFly(false)
|
|
self.model:Fire(PowerTurnTableModel.REQUEST_INFO,33504,self.sub_type,lucky_num>1 and 2 or 1,self.is_skip_action and 1 or 0)
|
|
end
|
|
end
|
|
|
|
-- 创建服务器记录
|
|
function PowerTurnTableView:UpdateRecordItemList( )
|
|
-- 创建的时候要暂停动画
|
|
self:StopRecordItemAction()
|
|
local record_list = self.model:GetRecordInfo(self.sub_type) or {}
|
|
for k, v in pairs(self.record_item_list) do
|
|
v:SetVisible(false)
|
|
end
|
|
-- 节点高度
|
|
local max_item_num = 20 -- 最大节点数
|
|
local node_height = self.record_scroll.sizeDelta.y
|
|
local height = 5
|
|
local item
|
|
self.record_count = 0
|
|
for k, v in ipairs(record_list) do
|
|
if k > max_item_num then
|
|
break
|
|
end
|
|
item = self.record_item_list[k]
|
|
if not item then
|
|
item = PowerTurnTableRecordItem.New(self.record_con)
|
|
self.record_item_list[k] = item
|
|
end
|
|
item:SetAnchoredPosition(2, -height)
|
|
item:SetVisible(true)
|
|
height = height + item:SetData(v, self.sub_type, -height)
|
|
self.record_count = self.record_count + 1
|
|
end
|
|
SetSizeDeltaY(self.record_con, height)
|
|
-- 记录一下当前的节点数
|
|
-- 生成节点的高度超过了容器高度,就需要展示轮播
|
|
if height > node_height then
|
|
self:StartRecordItemAction()
|
|
end
|
|
end
|
|
|
|
-- 开始轮播记录动画
|
|
function PowerTurnTableView:StartRecordItemAction()
|
|
self:StopRecordItemAction()
|
|
local time = 3
|
|
local function func()
|
|
self:UpdateRecordItemPos()
|
|
self:MoveRecordItem()
|
|
end
|
|
self.auto_record_item_anim_id = GlobalTimerQuest:AddPeriodQuest(func, time, -1)
|
|
end
|
|
|
|
function PowerTurnTableView:StopRecordItemAction()
|
|
if self.auto_record_item_anim_id then
|
|
GlobalTimerQuest:CancelQuest(self.auto_record_item_anim_id)
|
|
self.auto_record_item_anim_id = nil
|
|
end
|
|
self:StopRecordItemAnim()
|
|
end
|
|
|
|
-- 播放招财记录节点的动画
|
|
function PowerTurnTableView:MoveRecordItem()
|
|
local first_text = self.record_item_list[1]
|
|
local move_height = first_text:GetAnchoredPosition().y
|
|
move_height = move_height > 0 and 0 or move_height
|
|
for k,text in pairs(self.record_item_list) do
|
|
text:StartAction(move_height + 5)
|
|
end
|
|
end
|
|
|
|
-- 停止招财记录节点的动画
|
|
function PowerTurnTableView:StopRecordItemAnim()
|
|
for k,text in pairs(self.record_item_list) do
|
|
text:StopAction()
|
|
end
|
|
end
|
|
|
|
function PowerTurnTableView:UpdateRecordItemPos()
|
|
local delete_index = {}
|
|
local height = 5
|
|
local count = 0
|
|
for i = 1, self.record_count do
|
|
local text = self.record_item_list[i]
|
|
if text then
|
|
local vis = text:GetVisible()
|
|
local h = text:GetRecordHeight()
|
|
local y = text:GetAnchoredPosition().y
|
|
height = height + (vis and h or 0)
|
|
if y + h > 5 and vis then -- 将超出屏幕并显示中的节点保存到移动临时队列 0.1 由于浮点误差有可能出现不该隐藏的节点也添加到队列中,做加大误差处理
|
|
table.insert(delete_index, i)
|
|
end
|
|
end
|
|
end
|
|
|
|
local del_num = 0
|
|
local t = {}
|
|
for i,v in ipairs(delete_index) do
|
|
local index = v - del_num
|
|
local text = table.remove(self.record_item_list, index)
|
|
t[#t+1] = text
|
|
del_num = del_num + 1
|
|
end
|
|
-- 将临时队列的节点存回去
|
|
for i = 1, #t do
|
|
t[i]:SetAnchoredPosition(2, -height)
|
|
table.insert(self.record_item_list, t[i])
|
|
end
|
|
end
|
|
|
|
function PowerTurnTableView:SetActDetailShow()
|
|
if self.is_loaded then
|
|
if self.timer_id then
|
|
GlobalTimerQuest:CancelQuest(self.timer_id)
|
|
self.timer_id = nil
|
|
end
|
|
local act_list = CustomActivityModel:getInstance():getActList(self.base_type, self.sub_type)
|
|
if act_list then
|
|
local sec = act_list.etime - TimeUtil:getServerTime()
|
|
if sec > 0 then
|
|
local function onTimer()
|
|
sec = sec - 1
|
|
if sec > 0 then
|
|
self.timeText_tmp.text = string.format("活动剩余:<color=%s>%s</color>",ColorUtil.GREEN_DARK,TimeUtil:timeConvert6(sec,sec<24*3600))
|
|
else
|
|
self.timeText_tmp.text = string.format("活动剩余:%s",HtmlColorTxt("已结束", ColorUtil.RED_DARK))
|
|
GlobalTimerQuest:CancelQuest(self.timer_id)
|
|
self.timer_id = nil
|
|
end
|
|
end
|
|
if not self.timer_id then
|
|
self.timer_id = GlobalTimerQuest:AddPeriodQuest(onTimer, 1, -1)
|
|
end
|
|
onTimer()
|
|
else
|
|
self.timeText_tmp.text = string.format("活动剩余:%s",HtmlColorTxt("已结束", ColorUtil.RED_DARK))
|
|
end
|
|
end
|
|
end
|
|
end
|