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

166 lines
6.0 KiB

  1. ModelPreviewCon = ModelPreviewCon or BaseClass(BaseItem)
  2. function ModelPreviewCon:__init(parent)
  3. self.parent = parent
  4. self.base_file = "common"
  5. self.layout_file = "ModelPreviewCon"
  6. self.layer_name = "Top"
  7. self.mainVo = RoleManager.Instance.mainRoleInfo
  8. -- self.use_local_view = true
  9. self:Load()
  10. end
  11. function ModelPreviewCon:Load_callback()
  12. self.bg = self:GetChild("bg")
  13. self.ModelBG = self:GetChild("bg/ModelBG")
  14. self.ModelCon = self:GetChild("ModelCon")
  15. if self.need_refreshData then
  16. self:SetData(self.type_id,self.curr_height)
  17. end
  18. self:InitEvent()
  19. end
  20. function ModelPreviewCon:InitEvent()
  21. end
  22. function ModelPreviewCon:__delete()
  23. self:StopAnim()
  24. end
  25. function ModelPreviewCon:SetData( type_id ,curr_height)
  26. self.type_id = type_id
  27. self.curr_height = curr_height
  28. if self.is_loaded then
  29. self.need_refreshData = false
  30. self.transform.anchoredPosition = Vector2(-702, 0)
  31. self.bg.sizeDelta = Vector2(370, self.curr_height)
  32. self.ModelCon.sizeDelta = Vector2(370, self.curr_height-50)
  33. self.ModelCon.transform.anchoredPosition = Vector2(0, -self.curr_height/2)
  34. self.ModelBG.sizeDelta = Vector2(356, self.curr_height-10)
  35. self:StopAnim()
  36. self:ShowModelPreview()
  37. else
  38. self.need_refreshData = true
  39. end
  40. end
  41. function ModelPreviewCon:ShowModelPreview( )
  42. if Config.ConfigModelPreview[self.type_id] then
  43. local cfg = Config.ConfigModelPreview[self.type_id]
  44. local model_id, texture_id = self.mainVo:GetRoleClotheId()
  45. local weapon_model_id, weapon_texture_id = self.mainVo:GetWeaponClotheId()
  46. local head_model_id,head_clothe_id = self.mainVo:GetRoleHeadId()
  47. local fashion_model_id, fashion_texture_id = self.mainVo:GetRoleClotheTextureId()
  48. local footmark_id = 0
  49. local Scene_Type = SceneBaseType.Monster
  50. if cfg.type == 5 then
  51. self.transform.anchoredPosition = Vector2(-486, 0)
  52. end
  53. if cfg.type == 4 or cfg.type == 9 then--时装,限时时装
  54. Scene_Type = SceneBaseType.Role
  55. local type_id = self.type_id
  56. if cfg.type == 9 then
  57. type_id = cfg.model_id
  58. end
  59. local config = Config.Fashionmodel[cfg.subtype.."@"..type_id.."@"..self.mainVo.career]
  60. if config then
  61. if cfg.subtype == FashionPartPos.Clothe then
  62. fashion_model_id = config.model_id
  63. fashion_texture_id = config.color_id or 0
  64. elseif cfg.subtype == FashionPartPos.Weapon then
  65. weapon_model_id = config.model_id
  66. weapon_texture_id = config.color_id or 0
  67. elseif cfg.subtype == FashionPartPos.Head then
  68. head_model_id = config.model_id
  69. head_clothe_id = config.color_id or 0
  70. elseif cfg.subtype == FashionPartPos.Footmark then
  71. footmark_id = config.model_id
  72. end
  73. else
  74. print("服装预览找不到配置")
  75. end
  76. else
  77. model_id = cfg.model_id
  78. fashion_model_id = model_id
  79. fashion_texture_id = 0
  80. weapon_model_id = model_id
  81. weapon_texture_id = model_id
  82. head_model_id = 0
  83. head_clothe_id = 0
  84. end
  85. local data
  86. if cfg.type == 4 and cfg.subtype == FashionPartPos.Footmark then
  87. data = {
  88. career = self.mainVo.career,
  89. sex = self.mainVo.sex,
  90. clothe_res_id = model_id,
  91. weapon_res_id = weapon_model_id,
  92. weapon_clothe_id = weapon_texture_id,
  93. type = SceneBaseType.Role,
  94. layer_name = self.layer_name,
  95. rotate = 45,
  96. action_name_list = {"run"},
  97. can_rotate = false,
  98. scale = cfg.scale,
  99. position = cfg.position,
  100. fashion_model_id = fashion_model_id,
  101. texture_id = fashion_texture_id,
  102. head_wear_id = head_model_id,
  103. head_clothe_id = head_clothe_id,
  104. footmark_id = footmark_id,
  105. layout_file = self.layout_file
  106. }
  107. elseif cfg.type == 11 or cfg.type == 12 then
  108. data = {
  109. res_id = model_id,
  110. texture_id = 0,
  111. modelPartPos = FashionPartPos.Weapon,
  112. type = Config.UIModelConfig[model_id] and Config.UIModelConfig[model_id].type or 3,
  113. raycastParent = false,
  114. layer_name = self.layer_name,
  115. -- action_delta = 100,
  116. rotate = cfg.rotate or 0,
  117. can_rotate = false,
  118. texture_size = {x = 300, y = 300},
  119. scale = cfg.scale,
  120. position = cfg.position,
  121. }
  122. else
  123. data = {
  124. career = self.mainVo.career,
  125. sex = self.mainVo.sex,
  126. clothe_res_id = model_id,
  127. weapon_res_id = weapon_model_id,
  128. weapon_clothe_id = weapon_texture_id,
  129. type = Scene_Type,
  130. layer_name = self.layer_name,
  131. scale = cfg.scale,
  132. position = cfg.position,
  133. fashion_model_id = fashion_model_id,
  134. texture_id = fashion_texture_id,
  135. head_wear_id = head_model_id,
  136. head_clothe_id = head_clothe_id,
  137. rotate = cfg.rotate or 0,
  138. }
  139. end
  140. if cfg.type == 11 or cfg.type == 12 then
  141. self:FloatUDAnima()
  142. lua_resM:NewSetPartModel(self, self.ModelCon, data)
  143. else
  144. lua_resM:SetRoleModel(self, self.ModelCon,data)
  145. end
  146. end
  147. end
  148. --武器的上下浮动效果
  149. function ModelPreviewCon:FloatUDAnima()
  150. self.tween_id3 =TweenLite.to(self, self.ModelCon,TweenLite.UiAnimationType.ANCHORED_POSY,-140, 1.5, call_fun,TweenFunc.PINGPONG,true)
  151. end
  152. function ModelPreviewCon:StopAnim()
  153. if self.tween_id3 then
  154. TweenLite.Stop(self.tween_id3)
  155. self.tween_id3 = nil
  156. end
  157. end