CSMainRoleModelItem = CSMainRoleModelItem or BaseClass(BaseItem)
|
|
local CSMainRoleModelItem = CSMainRoleModelItem
|
|
|
|
function CSMainRoleModelItem:__init()
|
|
self.base_file = "csMain"
|
|
self.layout_file = "CSMainRoleModelItem"
|
|
self.model = CSMainModel:getInstance()
|
|
|
|
self:Load()
|
|
end
|
|
|
|
function CSMainRoleModelItem:Load_callback()
|
|
self.nodes = {
|
|
"modelCon:obj", "emptyRole:img:obj", "name:tmp",
|
|
"designationImg:img",
|
|
}
|
|
self:GetChildren(self.nodes)
|
|
|
|
self.name_tmp.text = "<#a9c1e1>虚位以待</color>"
|
|
|
|
lua_resM:setOutsideImageSprite(self, self.emptyRole_img, GameResPath.GetCSMainImage("cs_main_empty_role"))
|
|
|
|
SetLocalScale(self.emptyRole,0.75,0.75,0.75)
|
|
|
|
SetAnchoredPositionY(self.designationImg,150)
|
|
SetAnchoredPositionY(self.name,100)
|
|
|
|
-- SetLocalPositionZ(self.name,-1000)
|
|
|
|
self:AddEvents()
|
|
if self.need_refreshData then
|
|
self:UpdateView()
|
|
end
|
|
end
|
|
|
|
function CSMainRoleModelItem:AddEvents( )
|
|
--60306刷新figure
|
|
local function on_update_role_show(role_id)
|
|
if not self.is_loaded then return end
|
|
if role_id == self.data.rid then
|
|
self.data = self.model:GetCSMainDirectorDataByPos(self.index)
|
|
self:UpdateRoleShow()
|
|
end
|
|
end
|
|
self:BindEvent(self.model, CSMainConst.UPDATE_CS_MAIN_BASE_VIEW_ROLE_REQUEST, on_update_role_show)
|
|
end
|
|
|
|
function CSMainRoleModelItem:UpdateView( )
|
|
local need_request_figure_1 = self.data.rid ~= 0 and self.data.role_id == 0 --位置不为空但figure为空需要重新请求
|
|
local need_request_figure_2 = self.data.rid ~= 0 and TimeUtil:getServerTime() - self.data.time >= 1800 --figure消息过时30分钟以上需要重新请求
|
|
|
|
if need_request_figure_1 or need_request_figure_2 then
|
|
self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60306,self.data.rid)
|
|
else
|
|
self:UpdateRoleShow()
|
|
end
|
|
|
|
local dsgt_type = self.index <= 3 and 1 or 2
|
|
local dsgt_id = self.model:GetCSMainDsgtId(dsgt_type)
|
|
|
|
local data = {
|
|
parent = self,
|
|
dress_id = dsgt_id,
|
|
designationImg = self.designationImg,
|
|
scale = 0.9,
|
|
}
|
|
FuncOpenModel:getInstance():ShowDesign(data)
|
|
|
|
SetAnchoredPositionY(self.emptyRole, CSMainConst.RoleModelPos[self.index].empty_role_y)
|
|
|
|
end
|
|
|
|
function CSMainRoleModelItem:UpdateRoleShow( )
|
|
|
|
local is_empty_role = self.data.rid == 0
|
|
self.modelCon_obj:SetActive(not is_empty_role)
|
|
self.emptyRole_obj:SetActive(is_empty_role)
|
|
if not is_empty_role then
|
|
self.name_tmp.text = self.data.name
|
|
else
|
|
self.name_tmp.text = "<#a9c1e1>虚位以待</color>"
|
|
end
|
|
if not is_empty_role then
|
|
--clothe_res_id如果为空加载模型会报错,这里检查一下,是不是有问题
|
|
local clothe_res_id = GetRoleClotheId(self.data.level_model_list)
|
|
if not clothe_res_id then--如果后端发的figure的clothe_res_id不正常,手动修复一下
|
|
self.data.level_model_list = {
|
|
[1] = {part_pos = 1, level_model_id = self.data.career*1000},
|
|
[2] = {part_pos = 2, level_model_id = self.data.career*1000},
|
|
[3] = {part_pos = 3, level_model_id = self.data.career*1000},
|
|
[4] = {part_pos = 5, level_model_id = self.data.career*1000},
|
|
}
|
|
end
|
|
|
|
local role_y = CSMainConst.RoleModelPos[self.index].role_y
|
|
-- if self.index == 1 then
|
|
-- role_y = role_y + 15
|
|
-- end
|
|
|
|
local res_data = {
|
|
father_node = self,
|
|
transform = self.modelCon,
|
|
-- layer_name = "Activity",
|
|
fashion_type = FuncOpenModel.TypeId.Clothes,
|
|
role_vo = self.data,
|
|
scale = CSMainConst.RoleModelPos[self.index].scale,
|
|
raycast_size = Vector2(0,0),
|
|
ui_model_type = UIModelCommon.ModelType.Model,
|
|
position = Vector3(0, role_y, CSMainConst.RoleModelPos[self.index].model_z_depth)
|
|
}
|
|
FuncOpenModel:getInstance():SetModelRes(res_data)
|
|
end
|
|
end
|
|
|
|
function CSMainRoleModelItem:SetData(index,data)
|
|
self.index = index
|
|
self.data = data
|
|
if self.is_loaded then
|
|
self.need_refreshData = false
|
|
self:UpdateView()
|
|
else
|
|
self.need_refreshData = true
|
|
end
|
|
end
|
|
|
|
function CSMainRoleModelItem:__delete( )
|
|
|
|
end
|