源战役客户端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

107 行
3.1 KiB

  1. FosterRechargeItem = FosterRechargeItem or BaseClass(BaseItem)
  2. local FosterRechargeItem = FosterRechargeItem
  3. function FosterRechargeItem:__init()
  4. self.base_file = "rechargeActivity"
  5. self.layout_file = "FosterRechargeItem"
  6. -- self.model = 2222222222222222end:getInstance()
  7. self:Load()
  8. end
  9. function FosterRechargeItem:Load_callback()
  10. self.nodes = {
  11. "con/modelCon", "con/goBtn:obj", "con/bg:raw", "con/effect",
  12. "con/title:img", "con"
  13. }
  14. self:GetChildren(self.nodes)
  15. self:AddEvents()
  16. SetAnchoredPositionX(self.con, 369)
  17. SetAnchoredPositionY(self.con, -3.5)
  18. self:UpdateBaseView( )
  19. if self.need_refreshData then
  20. self:UpdateView()
  21. end
  22. end
  23. function FosterRechargeItem:AddEvents( )
  24. local on_click = function ( click_obj )
  25. if self.goBtn_obj == click_obj then
  26. OpenFun.Open(158, 0)
  27. if self.click_cb then
  28. self.click_cb()
  29. end
  30. end
  31. end
  32. AddClickEvent(self.goBtn_obj, on_click)
  33. end
  34. function FosterRechargeItem:UpdateBaseView( )
  35. lua_resM:setOutsideRawImage(self, self.bg_raw, GameResPath.GetRechargeActivityImage("foster_recharge_bg"), false)
  36. self:ClearUIEffect(self.effect)
  37. self:AddUIEffect("ui_effect_shouchong01", self.effect, "Top", nil, 0.8, false,nil,nil,nil,nil,nil,nil)
  38. end
  39. function FosterRechargeItem:UpdateView( )
  40. self:PlayShowAnim()
  41. end
  42. function FosterRechargeItem:UpdateModel()
  43. if self.show_type and KfActivityConst.FosterRechargeData[self.show_type] then
  44. local cfg = KfActivityConst.FosterRechargeData[self.show_type]
  45. local scale = cfg.scale or 200
  46. local position = cfg.position or Vector3(0,35,-300)
  47. local figure_data = cfg.show
  48. local res_data = {
  49. father_node = self,
  50. transform = self.modelCon,
  51. fashion_type = tonumber(figure_data[3]),
  52. layer_name = self.layer_name,
  53. size = Vector2(720,720),
  54. scale = scale,
  55. figure_id = tonumber(figure_data[4]),
  56. ui_model_type = UIModelCommon.ModelType.Model,
  57. position = position,
  58. }
  59. FuncOpenModel:getInstance():SetModelRes(res_data)
  60. lua_resM:setOutsideImageSprite(self, self.title_img, GameResPath.GetRechargeActivityImage(cfg.title_res), true)
  61. end
  62. end
  63. function FosterRechargeItem:PlayShowAnim( )
  64. cc.ActionManager:getInstance():removeAllActionsFromTarget(self.con)
  65. local START_POS = 369
  66. local END_POS = -5
  67. local ANIM_TIME = 0.3
  68. SetAnchoredPositionX(self.con, 369)
  69. local function show_func(percent)
  70. SetAnchoredPositionX(self.con, START_POS + (END_POS - START_POS) * percent)
  71. end
  72. local action1 = cc.CustomUpdate.New(ANIM_TIME, show_func)
  73. local function callback_1()
  74. self:UpdateModel()
  75. end
  76. local call_func_1 = cc.CallFunc.New(callback_1)
  77. local action10 = cc.Sequence.New(action1, call_func_1)
  78. cc.ActionManager:getInstance():addAction(action10, self.con)
  79. end
  80. function FosterRechargeItem:SetData( show_type, click_cb )
  81. self.show_type = show_type
  82. self.click_cb = click_cb
  83. if self.is_loaded then
  84. self.need_refreshData = false
  85. self:UpdateView()
  86. else
  87. self.need_refreshData = true
  88. end
  89. end
  90. function FosterRechargeItem:__delete( )
  91. self:ClearUIEffect(self.effect)
  92. cc.ActionManager:getInstance():removeAllActionsFromTarget(self.con)
  93. end