源战役客户端
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.

177 lines
6.9 KiB

  1. ComposeInstructionView = ComposeInstructionView or BaseClass(BaseView)
  2. function ComposeInstructionView:__init()
  3. self.base_file = "common"
  4. self.layout_file = "InstructionSmallView"
  5. self.layer_name = "Activity"
  6. self.use_background = true
  7. self.click_bg_toClose = true
  8. self.background_alpha = 0
  9. self:AddPreLoadList("common",{"InstructionSmallItem"})
  10. self.model = ComposeModel:getInstance()
  11. self.item_list = {}
  12. self.load_callback = function()
  13. self:LoadSuccess()
  14. self:SetData()
  15. end
  16. self.close_callback = function ()
  17. self:Clear()
  18. end
  19. end
  20. function ComposeInstructionView:Clear()
  21. for i,item in ipairs(self.item_list) do
  22. item:DeleteMe()
  23. end
  24. self.item_list = {}
  25. end
  26. function ComposeInstructionView:LoadSuccess()
  27. self.window = self:GetChild("Window")
  28. self.scroll_content = self:GetChild("Window/ScrollView/Viewport/Content")
  29. end
  30. function ComposeInstructionView:Open(data)
  31. self.data = data
  32. BaseView.Open(self)
  33. end
  34. function ComposeInstructionView:SetData()
  35. --self.windowTitleText.text = "合成说明"
  36. local height = 10
  37. local info_list = self:GetInstruction()
  38. if info_list then
  39. local item = nil
  40. for i,vo in ipairs(info_list) do
  41. item = InstructionSmallItem.New(self.scroll_content)
  42. table.insert(self.item_list,item)
  43. item:SetData(vo)
  44. item:SetPosition(0,-height)
  45. height = height + item:GetHeight()
  46. end
  47. end
  48. self.scroll_content.sizeDelta = Vector2(self.scroll_content.sizeDelta.x, height)
  49. height = height + 30
  50. height = height > 400 and 400 or height
  51. self.window.sizeDelta = Vector2(self.window.sizeDelta.x, height)
  52. --self.scroll_content.localPosition = Vector3.zero
  53. end
  54. function ComposeInstructionView:GetInstruction()
  55. local info_list = {[1] = {itemTitle = "", content = ""}}
  56. if self.model.cur_panel_id and self.data then
  57. local consumable = ErlangParser:GetInstance():Parse(self.data.regular_mat)
  58. local Irr_list = ErlangParser:GetInstance():Parse(self.data.irregular_mat)
  59. local ratio = ErlangParser:GetInstance():Parse(self.data.ratio)
  60. local is_god = false
  61. local str = ""
  62. local unit
  63. if consumable and #consumable > 0 then
  64. is_god = true
  65. for i, v in ipairs(consumable) do
  66. local goods_basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(tonumber(v[2]))
  67. if goods_basic then
  68. if goods_basic.type == GoodsModel.TYPE.EQUIP then
  69. local attr = Config.Equipattr[goods_basic.type_id]
  70. if attr then
  71. str = str..string.format("%d件<color=%s>%d阶%d星</color><color=%s>%s%s</color>,",
  72. tonumber(v[3]), ColorUtil.GREEN, attr.stage, attr.star, ColorUtil:GetColor(goods_basic.color), ColorUtil:getColorName(goods_basic.color), Config.ConfigEquipShow[goods_basic.subtype] and Config.ConfigEquipShow[goods_basic.subtype].name or "")
  73. end
  74. else
  75. str = str..tonumber(v[3]).."个<color="..ColorUtil:GetColor(goods_basic.color)..">"..Trim(goods_basic.goods_name).."</color>,"
  76. end
  77. end
  78. end
  79. end
  80. if ratio and #ratio > 0 then
  81. local min = 0
  82. local max = #ratio
  83. for i, v in ipairs(ratio) do
  84. if tonumber(v[2]) > 0 then
  85. min = v[1]
  86. break
  87. end
  88. end
  89. if max then
  90. if min then
  91. str = str..min.."~"..max..""
  92. else
  93. str = str..max..""
  94. end
  95. end
  96. str = "1.本次合成需要消耗"..min.."~"..max.."件装备 \n2.少于最低数量合成概率为0"
  97. end
  98. local equip_attr
  99. local irr_basic
  100. if Irr_list and #Irr_list > 0 then
  101. irr_basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(tonumber(Irr_list[1]))
  102. if self.model.cur_panel_id == ComposeModel.ComposePanelID.EQUIP_BEAST then
  103. equip_attr = Config.Eudemonsequipattr[tonumber(Irr_list[1])]
  104. else
  105. equip_attr = Config.Equipattr[tonumber(Irr_list[1])]
  106. end
  107. end
  108. if self.model.cur_panel_id == ComposeModel.ComposePanelID.EQUIP_BOY or self.model.cur_panel_id == ComposeModel.ComposePanelID.EQUIP_GIRL then
  109. local sex = "装备"
  110. --[[if self.model.cur_panel_id == ComposeModel.ComposePanelID.EQUIP_BOY then
  111. sex = "男装"
  112. else
  113. sex = "女装"
  114. end--]]
  115. if equip_attr and irr_basic then
  116. str = str..string.format("<color=%s>%d阶%d星</color><color=%s>%s%s</color>",
  117. ColorUtil.GREEN, equip_attr.stage, equip_attr.star, ColorUtil:GetColor(irr_basic.color), ColorUtil:getColorName(irr_basic.color), sex)
  118. end
  119. str = str.."合成该装备;\n"
  120. str = str.."2"..self:GetInstructionString(1).."\n"
  121. str = str.."3"..self:GetInstructionString(is_god and 3 or 2)
  122. elseif self.model.cur_panel_id == ComposeModel.ComposePanelID.EQUIP_GUARD then
  123. if equip_attr and irr_basic then
  124. str = str..string.format("<color=%s>%d阶%d星</color><color=%s>%s%s</color>",
  125. ColorUtil.GREEN, equip_attr.stage, equip_attr.star, ColorUtil:GetColor(irr_basic.color), ColorUtil:getColorName(irr_basic.color), Config.ConfigEquipShow[irr_basic.subtype] and Config.ConfigEquipShow[irr_basic.subtype].name or "")
  126. end
  127. str = str.."合成该装备;\n"
  128. str = str.."2"..self:GetInstructionString(1).."\n"
  129. str = str.."3"..self:GetInstructionString(is_god and 3 or 2)
  130. elseif self.model.cur_panel_id == ComposeModel.ComposePanelID.EQUIP_RING then
  131. if equip_attr and irr_basic then
  132. str = str..string.format("<color=%s>%d阶%d星</color><color=%s>%s%s</color>",
  133. ColorUtil.GREEN, equip_attr.stage, equip_attr.star, ColorUtil:GetColor(irr_basic.color), ColorUtil:getColorName(irr_basic.color), Config.ConfigEquipShow[irr_basic.subtype] and Config.ConfigEquipShow[irr_basic.subtype].name or "")
  134. end
  135. str = str.."合成该装备;\n"
  136. str = str.."2"..self:GetInstructionString(1).."\n"
  137. elseif self.model.cur_panel_id == ComposeModel.ComposePanelID.EQUIP_BEAST then
  138. if equip_attr and irr_basic then
  139. str = str..string.format("<color=%s>%d星</color><color=%s>%s幻兽装备</color>",
  140. ColorUtil.GREEN, equip_attr.star, ColorUtil:GetColor(irr_basic.color), ColorUtil:getColorName(irr_basic.color))
  141. end
  142. str = str.."合成该装备;\n"
  143. str = str.."2"..self:GetInstructionString(4).."\n"
  144. elseif self.model.cur_panel_id == ComposeModel.ComposePanelID.EQUIP_SEAL then
  145. --[[if equip_attr and irr_basic then
  146. str = str..string.format("<color=%s>%d阶%d星</color><color=%s>%s%s</color>",
  147. ColorUtil.GREEN, equip_attr.stage, equip_attr.star, ColorUtil:GetColor(irr_basic.color), ColorUtil:getColorName(irr_basic.color), Config.ConfigEquipShow[irr_basic.subtype] and Config.ConfigEquipShow[irr_basic.subtype].name or "")
  148. end
  149. str = str.."合成该装备;\n"
  150. str = str.."2"..self:GetInstructionString(1).."\n"--]]
  151. end
  152. info_list[1].content = str
  153. end
  154. return info_list
  155. end
  156. function ComposeInstructionView:GetInstructionString(index)
  157. local ins_list = {
  158. [1] = "、带有强化、镶嵌、套装、洗练属性的装备,以及绑定、穿戴中的装备不可合成;",
  159. [2] = "、合成有概率失败,放入的装备越多,成功率越高;",
  160. [3] = "、神装合成后可无损拆解,返还所有合成材料和装备,返还的装备部位随机;",
  161. [4] = "、合成后的装备的强化经验为消耗装备的经验之和;",
  162. }
  163. return ins_list[index] or ""
  164. end