|
ChatDressSubType = ChatDressSubType or
|
|
{
|
|
BUBBLE = 1,
|
|
HEAD = 2,
|
|
BACKGROUND = 3,
|
|
ROLE_HEAD = 4,
|
|
}
|
|
|
|
ChatDressModel = ChatDressModel or BaseClass(BaseModel)
|
|
|
|
ChatDressModel.HeadType = {
|
|
Career = 1,
|
|
Skill = 2,
|
|
Custom = 3
|
|
}
|
|
ChatDressModel.SAVE_CUSTOM_HEAD = "ChatDressModel.SAVE_CUSTOM_HEAD"
|
|
ChatDressModel.TEST_CHANGE_HEAD = "ChatDressModel.TEST_CHANGE_HEAD"
|
|
|
|
ChatDressModel.AcitiveState = {
|
|
Actived = 1,--已激活
|
|
Locked = 2,--未激活且不能激活
|
|
CanActive = 3,--可以激活
|
|
}
|
|
|
|
function ChatDressModel:__init()
|
|
ChatDressModel.Instance = self
|
|
self.bubble_list = {}
|
|
self.head_list = {}
|
|
self.background_list = {}
|
|
self.role_head_list = {}
|
|
self.handbook_data = {lv = 0,exp = 0} --图鉴信息
|
|
self.bubble_data = nil -- 泡泡信息
|
|
self.head_data = nil -- 头像框信息
|
|
self.role_head_data = nil -- 头像信息
|
|
self.background_data = nil -- 背景信息
|
|
self.photo_operate = 0
|
|
self.max_lv = 5 --单个装扮最高等级
|
|
self.last_gm_bubble = -1
|
|
self.last_gm_head = -1
|
|
self.last_gm_background = -1
|
|
self.use_dress_list = {} -- 保存玩家最新的使用列表,mainrole列表那并不是最新
|
|
self.model_tabBtn_index = 1
|
|
end
|
|
|
|
function ChatDressModel:getInstance()
|
|
if ChatDressModel.Instance==nil then
|
|
ChatDressModel.New()
|
|
end
|
|
return ChatDressModel.Instance
|
|
end
|
|
|
|
function ChatDressModel:GetInstance()
|
|
if ChatDressModel.Instance==nil then
|
|
ChatDressModel.New()
|
|
end
|
|
return ChatDressModel.Instance
|
|
end
|
|
|
|
|
|
function ChatDressModel:GetUseDressList( )
|
|
return self.use_dress_list
|
|
end
|
|
|
|
|
|
-- 获取装扮形象列表
|
|
function ChatDressModel:GetChatDressFigure(type)
|
|
if type == ChatDressSubType.BUBBLE then
|
|
if #self.bubble_list == 0 then
|
|
self.last_gm_bubble = gm_flag
|
|
self.bubble_list = {}
|
|
local cfg = Config.Dressup
|
|
for k,v in pairs(cfg) do
|
|
if v.dress_type == ChatDressSubType.BUBBLE then
|
|
table.insert(self.bubble_list,v)
|
|
end
|
|
end
|
|
table.sort(self.bubble_list,function(a,b) return a.dress_id<b.dress_id end)
|
|
end
|
|
return self.bubble_list
|
|
elseif type == ChatDressSubType.HEAD then
|
|
if #self.head_list == 0 then
|
|
self.head_list = {}
|
|
self.last_gm_head = gm_flag
|
|
local cfg = Config.Dressup
|
|
for k,v in pairs(cfg) do
|
|
if v.dress_type == ChatDressSubType.HEAD then
|
|
table.insert(self.head_list,v)
|
|
end
|
|
end
|
|
table.sort(self.head_list,function(a,b) return a.dress_id<b.dress_id end)
|
|
end
|
|
return self.head_list
|
|
elseif type == ChatDressSubType.BACKGROUND then
|
|
if #self.background_list == 0 then
|
|
self.background_list = {}
|
|
self.last_gm_background = gm_flag
|
|
local cfg = Config.Dressup
|
|
for k,v in pairs(cfg) do
|
|
if v.dress_type == ChatDressSubType.BACKGROUND then
|
|
table.insert(self.background_list,v)
|
|
end
|
|
end
|
|
table.sort(self.background_list,function(a,b) return a.dress_id<b.dress_id end)
|
|
end
|
|
return self.background_list
|
|
elseif type == ChatDressSubType.ROLE_HEAD then
|
|
if #self.role_head_list == 0 or RoleManager:getInstance().mainRoleInfo.turn ~= self.turn then
|
|
self.role_head_list = {}
|
|
local career = RoleManager:getInstance().mainRoleInfo.career
|
|
self.turn = RoleManager:getInstance().mainRoleInfo.turn
|
|
local career_list
|
|
for k, v in pairs(Config.Profilephoto) do
|
|
career_list = stringtotable(v.career)
|
|
for k2, v2 in ipairs(career_list) do
|
|
-- 目标转职是0且【目标职业是0】或【存在玩家本身的职业】,代表通用(即运营活动)头像
|
|
if v.turn <= self.turn and ((#career_list == 1 and v2 == 0) or (#career_list >= 1 and v2 == career)) then
|
|
--开始构造 变成上面的同种样式 吐了
|
|
self.role_head_list[#self.role_head_list+1] = v
|
|
self.role_head_list[#self.role_head_list].dress_id = v.photo_id
|
|
self.role_head_list[#self.role_head_list].dress_type = ChatDressSubType.ROLE_HEAD
|
|
self.role_head_list[#self.role_head_list].dress_name = v.name
|
|
self.role_head_list[#self.role_head_list].dress_desc = v.desc
|
|
self.role_head_list[#self.role_head_list].dress_starup_attr = v.attr_list
|
|
self.role_head_list[#self.role_head_list].sequence = v.photo_id--用配置id当排序
|
|
self.role_head_list[#self.role_head_list].dress_consume_id = v.photo_id--依旧没有
|
|
self.role_head_list[#self.role_head_list].is_default = v.turn == 0 and #career_list == 1 and v2 == career--转职0且和自己职业一样的是默认
|
|
break
|
|
end
|
|
end
|
|
end
|
|
end
|
|
return self.role_head_list
|
|
end
|
|
end
|
|
|
|
-- 根据type、id判断dressitem是否已激活
|
|
function ChatDressModel:FindDressIsActive(type,id)
|
|
local data = nil
|
|
if type == ChatDressSubType.BUBBLE then
|
|
data = self.bubble_data
|
|
elseif type == ChatDressSubType.HEAD then
|
|
data = self.head_data
|
|
elseif type == ChatDressSubType.BACKGROUND then
|
|
data = self.background_data
|
|
elseif type == ChatDressSubType.ROLE_HEAD then
|
|
data = self.role_head_data
|
|
end
|
|
if data == nil then return false end
|
|
local isActive = false
|
|
local figure_list = data.enable_list
|
|
for k,v in pairs(figure_list) do
|
|
if tonumber(v.dress_id) == tonumber(id) then
|
|
isActive = true
|
|
break
|
|
end
|
|
end
|
|
|
|
return isActive
|
|
end
|
|
|
|
-- 获取当前等级对应最大exp
|
|
function ChatDressModel:GetMaxExp(id,lv)
|
|
local cfg = Config.Dressup[id]
|
|
if cfg == nil then return end
|
|
return cfg.dress_starup_exp
|
|
end
|
|
|
|
function ChatDressModel:GetUnitExp(id,lv)
|
|
local cfg = Config.Dressup[id]
|
|
if cfg == nil then return end
|
|
return cfg.dress_acti_exp
|
|
end
|
|
|
|
|
|
function ChatDressModel:UpdateDressData(data)
|
|
if data == nil then return end
|
|
if data.dress_type == ChatDressSubType.BUBBLE then
|
|
self.bubble_data = data
|
|
elseif data.dress_type == ChatDressSubType.HEAD then
|
|
self.head_data = data
|
|
elseif data.dress_type == ChatDressSubType.BACKGROUND then
|
|
self.background_data = data
|
|
elseif data.dress_type == ChatDressSubType.ROLE_HEAD then
|
|
self.role_head_data = data
|
|
end
|
|
self.use_dress_list = self.use_dress_list or {}
|
|
if data.dress_type and data.use_dress_id and data.dress_type ~= ChatDressSubType.BACKGROUND then -- 背景已经取消了,先删除掉
|
|
local cfg = self:GetChatDressFigure(data.dress_type)
|
|
self.use_dress_list[data.dress_type] = data.use_dress_id ~= 0 and data.use_dress_id or cfg[1].dress_id -- 没穿戴时默认穿上配置第一个(默认装扮)
|
|
end
|
|
end
|
|
|
|
-- 激活成功返回后的操作
|
|
function ChatDressModel:UpdataEnableList(data)
|
|
if data == nil then return end
|
|
if data.dress_type == ChatDressSubType.BUBBLE then
|
|
table.insert(self.bubble_data.enable_list,{dress_id = data.dress_id})
|
|
elseif data.dress_type == ChatDressSubType.HEAD then
|
|
table.insert(self.head_data.enable_list,{dress_id = data.dress_id})
|
|
elseif data.dress_type == ChatDressSubType.BACKGROUND then
|
|
table.insert(self.background_data.enable_list,{dress_id = data.dress_id})
|
|
elseif data.dress_type == ChatDressSubType.ROLE_HEAD then
|
|
table.insert(self.role_head_data.enable_list,{dress_id = data.dress_id})
|
|
end
|
|
self:Fire(ChatDressEvent.DRESS_ACTIVATE_SUCCESS,data)
|
|
end
|
|
|
|
-- 使用装扮成功的操作
|
|
function ChatDressModel:UpdataUsingDress(data)
|
|
if data == nil or data.dressup_list == nil then return end
|
|
for i,v in ipairs(data.dressup_list) do
|
|
if self.bubble_data and v.dress_type == ChatDressSubType.BUBBLE then
|
|
self.bubble_data.use_dress_id = v.dress_id
|
|
elseif self.head_data and v.dress_type == ChatDressSubType.HEAD then
|
|
self.head_data.use_dress_id = v.dress_id
|
|
elseif self.background_data and v.dress_type == ChatDressSubType.BACKGROUND then
|
|
self.background_data.use_dress_id = v.dress_id
|
|
elseif self.role_head_data and v.dress_type == ChatDressSubType.ROLE_HEAD then
|
|
self.role_head_data.use_dress_id = v.dress_id
|
|
end
|
|
end
|
|
self:Fire(ChatDressEvent.USE_DRESS_SUCCESS, data.dressup_list) -- 传回view
|
|
end
|
|
|
|
-- 判断是否可激活
|
|
function ChatDressModel:CanActivate(type,id)
|
|
local isActive = self:FindDressIsActive(type,id)
|
|
if isActive == true then return false end
|
|
local goods_id = id
|
|
local num = GoodsModel:getInstance():GetTypeGoodsNum(goods_id)
|
|
if num >= 1 then
|
|
return true
|
|
else
|
|
return false
|
|
end
|
|
end
|
|
|
|
-- 判断子界面是否有红点
|
|
function ChatDressModel:ShowSubRedPoint(type)
|
|
local list = self:GetChatDressFigure(type)
|
|
if list == nil then return false end
|
|
local isActive = false
|
|
for k,v in pairs(list) do
|
|
isActive = self:FindDressIsActive(type,v.dress_id)
|
|
if self:CanActivate(type,v.dress_id) then
|
|
return true
|
|
end
|
|
end
|
|
return false
|
|
end
|
|
|
|
-- 判断装扮是否有红点
|
|
function ChatDressModel:ShowChatDressRedPoint()
|
|
if RoleManager.Instance.mainRoleInfo.level < Config.Moduleid[112].open_lv then
|
|
return false
|
|
end
|
|
local bool = (self:ShowSubRedPoint(ChatDressSubType.BUBBLE) or self:ShowSubRedPoint(ChatDressSubType.HEAD) or self:ShowSubRedPoint(ChatDressSubType.BACKGROUND))
|
|
return bool
|
|
end
|
|
|
|
function ChatDressModel:UpdateRedDot()
|
|
GlobalEventSystem:Fire(EventName.REFRESH_CHATDRESS_RED_DOT)
|
|
end
|
|
|
|
function ChatDressModel:IsDefaultDressId(dress_id)
|
|
if dress_id == 425001 or dress_id == 420001 or dress_id == 427501 then
|
|
return true
|
|
end
|
|
return false
|
|
end
|
|
------------------------------------------------以下是新的-------------------
|
|
--获取当前穿戴装扮id
|
|
function ChatDressModel:GetCurUseDressId( type )
|
|
local using_id = 0
|
|
if type == ChatDressSubType.BUBBLE then
|
|
if self.bubble_data == nil then return 0 end
|
|
using_id = self.bubble_data.use_dress_id
|
|
elseif type == ChatDressSubType.HEAD then
|
|
if self.head_data == nil then return 0 end
|
|
using_id = self.head_data.use_dress_id
|
|
elseif type == ChatDressSubType.BACKGROUND then
|
|
if self.background_data == nil then return 0 end
|
|
using_id = self.background_data.use_dress_id
|
|
elseif type == ChatDressSubType.ROLE_HEAD then
|
|
if self.role_head_data == nil then return 0 end
|
|
using_id = self.role_head_data.use_dress_id
|
|
end
|
|
return using_id
|
|
end
|
|
|
|
function ChatDressModel:SetJumpInfo( info )
|
|
self.jump_info = info
|
|
end
|
|
|
|
function ChatDressModel:GetJumpInfo( )
|
|
return self.jump_info
|
|
end
|
|
|
|
function ChatDressModel:CleanJumpInfo( )
|
|
self.jump_info = nil
|
|
end
|