源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

140 lines
4.1 KiB

  1. --[[
  2. @description:CommonTips
  3. ]]
  4. CommonTips = CommonTips or BaseClass(BaseView)
  5. function CommonTips:__init()
  6. self.base_file = "common"
  7. self.layout_file = "CommonTips"
  8. self.layer_name = "Top"
  9. self.close_mode = CloseMode.CloseDestroy
  10. self.destroy_imm = true
  11. self.use_background = true
  12. self.click_bg_toClose = true
  13. self.pos_x = 0
  14. self.pos_y = 0
  15. self.model = GoodsModel:getInstance()
  16. self.goodsVo = nil
  17. self.main_type = 0
  18. self.load_callback = function ()
  19. self:LoadSuccess()
  20. end
  21. self.open_callback = function ()
  22. self:SetData()
  23. end
  24. self.close_callback = function ()
  25. end
  26. self.destroy_callback = function ()
  27. self:Remove()
  28. end
  29. end
  30. function CommonTips:Remove()
  31. if self.award_item then
  32. self.award_item:DeleteMe()
  33. self.award_item = nil
  34. end
  35. end
  36. function CommonTips:LoadSuccess()
  37. -- self.goodsBorder = self:GetChild("goodsBorder"):GetComponent("Image")
  38. -- self.goodsIcon = self:GetChild("goodsBorder/goodsIcon"):GetComponent("Image")
  39. self.goods_conta = self:GetChild("goodsBorder")
  40. self.award_item = AwardItem.New(self.goods_conta, false)
  41. self.name = self:GetChild("name"):GetComponent("Text")
  42. --英灵石组件
  43. self.main_type_20 = self:GetChild("main_type_20").gameObject
  44. self.only = self:GetChild("main_type_20/only").gameObject
  45. self.stone_fighting = self:GetChild("main_type_20/imgFight/fight"):GetComponent("Text")
  46. self.stone_pos = self:GetChild("main_type_20/txtPos/pos"):GetComponent("Text")
  47. self.stone_level = self:GetChild("main_type_20/txtLevel/level"):GetComponent("Text")
  48. self.stone_pro = self:GetChild("main_type_20/txtAttr/pro"):GetComponent("Text")
  49. --通用信息面板
  50. self.main_type_0 = self:GetChild("main_type_0").gameObject
  51. self.com_introduce = self:GetChild("main_type_0/introduce"):GetComponent("Text")
  52. self:InitEvent()
  53. end
  54. function CommonTips:InitEvent()
  55. local function onClickBtnHandler(target)
  56. self:Close()
  57. end
  58. --AddClickEvent(self.offBtn, onClickBtnHandler)
  59. self:HideAllPanel()
  60. end
  61. function CommonTips:Open(goods_id , x , y , main_type)
  62. print("-------------goods_id:", goods_id)
  63. self.goodsVo = GoodsModel:getInstance():GetGoodsBasicByTypeId(goods_id)
  64. self.main_type = main_type or 0
  65. self.pos_x = x or 0
  66. self.pos_y = y or 0
  67. if self.goodsVo == nil then return end
  68. BaseView.Open(self)
  69. end
  70. function CommonTips:SetData()
  71. local goods_icon = self.goodsVo.goods_icon
  72. local name = self.goodsVo.goods_name
  73. if self.goodsVo.type == 11 and (self.goodsVo.subtype == 10 or self.goodsVo.subtype == 11)then --装备鉴定物, 碎片,显示鉴定物对应的装备图标
  74. local type_id, _name, icon = EquipModel:getInstance():GetIdentifyGoodsNameAndIcon(self.goodsVo.type_id, RoleManager.Instance.mainRoleInfo.career, self.goodsVo.color)
  75. goods_icon = icon
  76. name = _name
  77. end
  78. self.award_item:SetData(self.goodsVo.type_id)
  79. -- lua_resM:setImageSprite(self,self.goodsBorder,"alphaCommon_asset","com_icon_bg_"..self.goodsVo.color)
  80. -- lua_resM:setOutsideImageSprite(self,self.goodsIcon,GameResPath.GetGoodsIcon(goods_icon))
  81. self.name.text = GoodsModel.GetRealGoodsName(self.goodsVo)
  82. if self.main_type == 20 then --英灵石
  83. self:SetEquipStoneData()
  84. else
  85. self:SetCommonData()
  86. end
  87. -- self.transform.localPosition = Vector3(self.pos_x, self.pos_y)
  88. -- self.background_wnd.transform.localPosition = Vector3(-self.pos_x, -self.pos_y)
  89. end
  90. function CommonTips:HideAllPanel()
  91. self.main_type_20:SetActive(false)
  92. self.main_type_0:SetActive(false)
  93. end
  94. --设置英灵石数据
  95. function CommonTips:SetEquipStoneData()
  96. self.main_type_20:SetActive(true)
  97. local cfg = EquipModel:getInstance():GetEquipStoneConfig(self.goodsVo.type_id)
  98. if cfg then
  99. self.stone_fighting.text = cfg.combat_power
  100. if tonumber(cfg.unique) == 1 then
  101. self.only:SetActive(true)
  102. else
  103. self.only:SetActive(false)
  104. end
  105. end
  106. self.stone_pos.text = WordManager:GetEquipStyleStr(self.goodsVo.subtype)
  107. self.stone_level.text = self.goodsVo.level
  108. local pro_str = EquipModel:getInstance():GetStoneProStr(self.goodsVo.type_id)
  109. self.stone_pro.text = pro_str
  110. end
  111. --设置物品简介
  112. function CommonTips:SetCommonData()
  113. self.main_type_0:SetActive(true)
  114. self.com_introduce.text = self.goodsVo.intro
  115. end