local AvatarCell = class("AvatarCell", BaseCell) function AvatarCell:init() self.uiMap = self:getUIMap() self.imgAvatar = self.uiMap["avatar_cell.img_avatar"] self.lock = self.uiMap["avatar_cell.lock"] self.use = self.uiMap["avatar_cell.use"] self.txUse = self.uiMap["avatar_cell.use.tx_use"] self.select = self.uiMap["avatar_cell.select"] self.txUse:setText(I18N:getGlobalText(I18N.GlobalConst.ON_USING_DESC)) self:addClickListener(function() EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.PLAYER_INFO_CLICK_AVATAR, self.id) end) end function AvatarCell:refresh(id, isSelect) self.id = id -- 红点 if DataManager.PlayerData:isNewAvatar(self.id) then self.baseObject:addRedPoint(45, 45, 0.6) else self.baseObject:removeRedPoint() end -- 背景 local smallFrame = DataManager.PlayerData:getAvatarBg(self.id) if smallFrame then self.baseObject:setSprite(GConst.ATLAS_PATH.ICON_HERO, smallFrame) end self.select:setActive(isSelect) self.imgAvatar:setSprite(GConst.ATLAS_PATH.ICON_HERO, DataManager.PlayerData:getAvatarIconId(self.id)) self.lock:setActive(not DataManager.PlayerData:isAvatarUnlock(self.id)) self.use:setActive(DataManager.PlayerData:getUsingAvatarId() == self.id) end return AvatarCell