local UITreasureActiveSuccess = UIViewClass() local ANIM_TIMER = 2 function UITreasureActiveSuccess:OnOpened(context) self:RegistTriggerEvent(self.btn_Close, UIEventTriggerType.Drag) self:RegistTriggerEvent(self.btn_Close, UIEventTriggerType.EndDrag) self.isDrag = false self.enableClose = false local treasureId = context.treasureId local treasureData = DataSheetManager.TreasureData:GetDataByTreasureID(treasureId) if treasureData then UIUtils.SetLabelText(self.txt_TreasureName, Const_IDS[treasureData.TreasureName]) self:ShowTreasureById(treasureId) self:StartRepeatFunc(self.SetEnableClose, ANIM_TIMER, 1) end CTL.Sound.PlayGameSound("UI_active_treasure") end function UITreasureActiveSuccess:SetEnableClose() self.enableClose = true end function UITreasureActiveSuccess:ShowTreasureById(treasureId) local treasureData = DataSheetManager.TreasureData:GetDataByTreasureID(treasureId) self.renderModel:ShowTreasure(treasureData.TreasureMode, treasureData.CameraRenderId, treasureData.TreasurePreviewModelLight, treasureData.TreasureAnim, treasureData.TreasureShowEffect) end function UITreasureActiveSuccess:OnDrag(comp, eventData) if comp == self.btn_Close then self.isDrag = true self.renderModel:RotatingByManual(eventData) end end function UITreasureActiveSuccess:OnEndDrag(comp, eventData) if comp == self.btn_Close then self.isDrag = false end end function UITreasureActiveSuccess:OnButtonClicked(comp) if comp == self.btn_Close then if self.enableClose and self.isDrag == false then self:CloseView(true) end end end return UITreasureActiveSuccess