ChildModel = ChildModel or BaseClass(BaseVo, true)
|
|
local ChildModel = ChildModel
|
|
|
|
function ChildModel:__init()
|
|
self.Instance = self
|
|
self:Reset()
|
|
end
|
|
function ChildModel:Reset()
|
|
self.mainVo = RoleManager.Instance.mainRoleInfo
|
|
|
|
self.Config_Child_DailyTask = Config.Childdailytask -- 同心前置日常任务配置
|
|
self.Config_Child_VoteReward = Config.Childvotereward -- 投票奖励配置
|
|
self.Config_Child_Skill = Config.Childskill -- 孩子技能配置
|
|
self.Config_Child_ToyNew = Config.Childtoynew -- 孩子玩具配置 新
|
|
self.Config_Child_ToyUpgrade = Config.Childtoyboxupgrade -- 孩子玩具升阶配置
|
|
self.Config_Child_ToySuit = Config.Childtoysuit -- 孩子玩具图鉴
|
|
|
|
-- 初始化各种配置
|
|
self:InitChildfigureCfg()
|
|
self:InitChildkvCfg()
|
|
self:InitChildLinkHeartInfo()
|
|
self:InitChildgrowupCfg()
|
|
self:InitChildfashionCfg()
|
|
self:InitChildvehicleCfg( )
|
|
|
|
self.isPlayerHadChild = false
|
|
self.ChildRedDotList = {} --红点集合
|
|
self.childInfo = {} --宝宝信息
|
|
self.childTaskInfo = {} --任务信息
|
|
self.childSkillList = {}--技能信息
|
|
self.skill_list_open_nearest = nil --最近一个为开启的技能, 技能得按顺序的
|
|
self.childVehicleList = {}--载具信息
|
|
self.childVotedRoleList = {}--宝宝已点过的玩家id List
|
|
self.childEquipList = {}--宝宝玩具装备
|
|
self.childEquipBuildList = {}-- 宝宝玩具打造
|
|
self.childDressList = {}-- 宝宝装扮
|
|
self.childSuitToyList = {} -- 宝宝图鉴
|
|
self.childSuitRewardList = {}-- 宝宝图鉴套装集齐奖励
|
|
self.child_acitve_toy_list = {} --- 给分解list计算激活分解用
|
|
self.red_dot_list_handbook = {}
|
|
self.wear_fashion_id = 0 -- 穿戴中的时装id
|
|
self.can_use_skill_list = {} -- 当前可以使用的技能列表
|
|
end
|
|
|
|
function ChildModel:GetInstance()
|
|
if self.Instance == nil then
|
|
self.Instance = ChildModel.New()
|
|
end
|
|
return self.Instance
|
|
end
|
|
|
|
function ChildModel:getInstance()
|
|
if self.Instance == nil then
|
|
self.Instance = ChildModel.New()
|
|
end
|
|
return self.Instance
|
|
end
|
|
-------------初始化配置--start-----------
|
|
-- 孩子模型对应关系配置
|
|
function ChildModel:InitChildfigureCfg( )
|
|
self.Config_Child_Figure = {}
|
|
self.Config_Child_Figure[1] = {} -- 男
|
|
self.Config_Child_Figure[2] = {} -- 女
|
|
self.max_grow_state = 0 -- 宝宝最大成长期
|
|
self.child_grow_level = 0 -- 婴儿期对应等级
|
|
for k, v in pairs(Config.Childfigure) do
|
|
if v.model_id == 1011 then
|
|
self.child_grow_level = v.grow_up_level
|
|
elseif v.model_id == 1021 then
|
|
self.max_grow_state = v.grow_up_level
|
|
end
|
|
table.insert(self.Config_Child_Figure[v.child_sex], v)
|
|
end
|
|
local function sort_func(a, b)
|
|
return a.grow_up_level < b.grow_up_level
|
|
end
|
|
table.sort(self.Config_Child_Figure[1], sort_func)
|
|
table.sort(self.Config_Child_Figure[2], sort_func)
|
|
end
|
|
|
|
-- 常量表
|
|
function ChildModel:InitChildkvCfg( )
|
|
self.Config_Child_kv = {}
|
|
for k, v in pairs(Config.Childkv) do
|
|
self.Config_Child_kv[Trim(v.key)] = v.constant
|
|
end
|
|
end
|
|
|
|
-- 同心奖励配置
|
|
function ChildModel:InitChildLinkHeartInfo( )
|
|
self.Config_Child_LinkHeart = {}
|
|
local data = self.Config_Child_LinkHeart
|
|
-- 以同心值做key
|
|
local max_value = 0
|
|
for k, v in pairs(Config.Childlinkheart) do
|
|
if max_value < v.need_exp then
|
|
max_value = v.need_exp
|
|
end
|
|
data[v.need_exp] = v
|
|
data[v.need_exp].reward_new = stringtotable(v.reward)
|
|
end
|
|
self.MAX_HERAT_VALUE = max_value
|
|
end
|
|
|
|
-- 获取最大同心值
|
|
function ChildModel:GetMaxHeartValue( )
|
|
return self.MAX_HERAT_VALUE or 0
|
|
end
|
|
|
|
-- 孩子成长属性配置
|
|
function ChildModel:InitChildgrowupCfg( )
|
|
self.Config_Child_GrowUp = {}
|
|
local cfg = self.Config_Child_GrowUp
|
|
for k, v in pairs(Config.Childgrowup) do
|
|
cfg[v.month] = v
|
|
end
|
|
end
|
|
|
|
-- 时装配置
|
|
function ChildModel:InitChildfashionCfg( )
|
|
self.Config_Child_Fashion = {}
|
|
for k,v in pairs(Config.Childfashion) do
|
|
self.Config_Child_Fashion[v.fashion_id] = self.Config_Child_Fashion[v.fashion_id] or {}
|
|
local temp = self.Config_Child_Fashion[v.fashion_id]
|
|
temp[v.lv] = v
|
|
|
|
-- 设置升到下一级的消耗
|
|
local next_cfg = Config.Childfashion[v.fashion_id .. "@" .. v.lv]
|
|
if next_cfg then
|
|
temp[v.lv].upgrade_cost_next = stringtotable(next_cfg.upgrade_cost)
|
|
else
|
|
temp[v.lv].upgrade_cost_next = false
|
|
end
|
|
end
|
|
end
|
|
|
|
-- 载具和时装原本是两个功能 现在合并了 所以配置处理成时装配置的格式
|
|
-- 通过is_vehicle字段区分 用原本的不同协议来处理
|
|
function ChildModel:InitChildvehicleCfg( )
|
|
self.Config_Child_Vehicle = {}
|
|
local cfg_list = self.Config_Child_Vehicle
|
|
for k,v in pairs(Config.Childvehicle) do
|
|
cfg_list[v.vehicle_id] = cfg_list[v.vehicle_id] or {}
|
|
local temp = cfg_list[v.vehicle_id]
|
|
temp[v.stage] = {}
|
|
local temp_cfg = temp[v.stage]
|
|
temp_cfg.is_vehicle = true -- 用来区别时装的字段
|
|
temp_cfg.fashion_id = v.vehicle_id
|
|
temp_cfg.lv = v.stage
|
|
temp_cfg.fashion_name = v.vehicle_name
|
|
temp_cfg.attr_list = v.add_attr
|
|
temp_cfg.model_id = v.model_id
|
|
temp_cfg.upgrade_cost = v.upgrade_cost
|
|
temp_cfg.active_skill = v.active_skill
|
|
temp_cfg.can_on_age = v.can_on_age
|
|
|
|
-- 设置升到下一级的消耗
|
|
local next_cfg = Config.Childvehicle[v.vehicle_id .. "@" .. v.stage]
|
|
if next_cfg then
|
|
temp_cfg.upgrade_cost_next = stringtotable(next_cfg.upgrade_cost)
|
|
else
|
|
temp_cfg.upgrade_cost_next = false
|
|
end
|
|
end
|
|
end
|
|
-------------初始化配置--end---------
|
|
|
|
function ChildModel:GetChildInfo( )
|
|
return self.childInfo
|
|
end
|
|
|
|
--[[
|
|
child_age_month :int8 //孩子年龄 - 月
|
|
child_name :string //孩子名字
|
|
child_sex :int8 //孩子性别
|
|
child_age_year :int8 //孩子年龄 - 年
|
|
child_age_month :int8 //孩子年龄 - 月
|
|
child_age_exp :int32 //孩子成长进度(经验值)
|
|
heart_link_exp :int32 //同心度(经验值)
|
|
heart_reward:array{ //同心奖励
|
|
reward_id :int8 //奖励Id
|
|
status :int8 //奖励领取状态0-未领取 1-已领取
|
|
}
|
|
child_power :int64 //孩子战力
|
|
is_follow :int8 //是否跟随
|
|
can_carry :int16 //孩子可负重上限
|
|
adopt_time :int32 //孩子领养时间 0-未领养 其他-领养时间
|
|
share_reward :int8 //分享奖励领取状态 0-未领取 1-已领取
|
|
yest_rank :int16 //昨日排行
|
|
yest_reward :int8 //昨日榜奖励领取状态 0-未领取 1-已领取
|
|
--]]
|
|
function ChildModel:SetChildInfo(vo)
|
|
-- 孩子成长等级需要保存一下上一次的等级
|
|
self:UpdatePreAgeMonth(self.childInfo.child_age_month)
|
|
local temp = {
|
|
child_age_month = vo.child_age_month or self.childInfo.child_age_month or 0,
|
|
child_name = vo.child_name or self.childInfo.child_name or "",
|
|
child_sex = vo.child_sex or self.childInfo.child_sex or 1,
|
|
child_age_year = vo.child_age_year or self.childInfo.child_age_year or 0,
|
|
child_age_exp = vo.child_age_exp or self.childInfo.child_age_exp or 0,
|
|
heart_link_exp = vo.heart_link_exp or self.childInfo.heart_link_exp or 0,
|
|
child_power = vo.child_power or self.childInfo.child_power or 0,
|
|
is_follow = vo.is_follow or self.childInfo.is_follow or false,
|
|
adopt_time = vo.adopt_time or self.childInfo.adopt_time or 0,
|
|
-- 晒娃
|
|
share_reward = vo.share_reward or self.childInfo.share_reward or 0,
|
|
yest_rank = vo.yest_rank or self.childInfo.yest_rank or 0,
|
|
yest_reward = vo.yest_reward or self.childInfo.yest_reward or 0,
|
|
heart_reward = self.childInfo.heart_reward or {}, -- 默认不直接用协议的数据
|
|
}
|
|
self.childInfo = temp
|
|
self:SetHeartRewardData(vo.heart_reward)
|
|
|
|
if vo.child_sex > 0 then -- 有性别数据 说明已经领养了
|
|
self:SetIsPlayerHadChild(true)
|
|
end
|
|
|
|
--self:SetChildInfoForRoleModelID()
|
|
end
|
|
|
|
function ChildModel:UpdatePreAgeMonth( lv )
|
|
-- logWarn('=======Msh:ChildModel.lua[209]=======')
|
|
-- PrintCallStack()
|
|
self.pre_age_month = lv or 0
|
|
end
|
|
|
|
function ChildModel:GetPreAgeMonth( )
|
|
return self.pre_age_month or -1
|
|
end
|
|
|
|
-- 获取当前同心度
|
|
function ChildModel:GetCurHeartValue( )
|
|
return self:GetChildInfo( ).heart_link_exp or 0
|
|
end
|
|
|
|
-- 判断同心值是否已满
|
|
function ChildModel:IsHeartValueMax()
|
|
return self:GetCurHeartValue( ) >= self:GetMaxHeartValue( )
|
|
end
|
|
|
|
-- 更新数据 need_check:是否强制检查状态变化(用于区分第一次初始化数据)
|
|
function ChildModel:SetHeartRewardData( reward_list, need_check )
|
|
-- 同心奖励
|
|
if not reward_list then return end
|
|
|
|
local old_get_state
|
|
if need_check then
|
|
old_get_state = self:HasGetAllHeartReward( ) -- 更新数据前的领取状态
|
|
end
|
|
|
|
-- 更新数据
|
|
self.childInfo.heart_reward = self.childInfo.heart_reward or {}
|
|
local list = self.childInfo.heart_reward
|
|
for k, v in pairs(reward_list) do
|
|
list[v.reward_id] = v.status
|
|
|
|
end
|
|
|
|
-- 如果本次刷新刚刚领取最后一个奖励 则打开求子界面
|
|
if need_check then
|
|
local new_get_state = self:HasGetAllHeartReward( ) --更新数据后的领取状态
|
|
if new_get_state and not old_get_state then
|
|
self:Fire(ChildConst.OPEN_CHILD_HEART_TASK_VIEW, false) -- 关闭同心界面
|
|
self:Fire(ChildConst.OPEN_CHILD_GET_VIEW, true) -- 打开领养界面
|
|
self:Fire(ChildConst.UPDATA_CHILD_MAIN_INFO) -- 请求刷新图标
|
|
self:Fire(ChildConst.Child_RED_DOT,ChildConst.TabId.GetChild)
|
|
end
|
|
end
|
|
end
|
|
|
|
-- 获取领取状态 1已领取 0未领取
|
|
function ChildModel:GetHeartRewardStatus( reward_id )
|
|
if reward_id and self.childInfo.heart_reward and self.childInfo.heart_reward[reward_id] then
|
|
return self.childInfo.heart_reward[reward_id]
|
|
end
|
|
end
|
|
|
|
-- 完成某个同心任务后 设置数据
|
|
function ChildModel:SetChildInfoForTask(heart_link_exp)
|
|
self.childInfo.heart_link_exp = heart_link_exp or 0 -- 设置同心度
|
|
end
|
|
|
|
--- 仅自己用
|
|
--- 通过当前的同心度和等级获取孩子模型id (如果有时装穿戴中就用时装对应model_id)
|
|
function ChildModel:GetChildCloth()
|
|
local child_age_month = self.childInfo.child_age_month or 0
|
|
local clothe_res_id_self = 1011 -- 默认模型(供未开放宝宝时显示用)
|
|
if self.childInfo.child_sex and self.childInfo.child_sex ~= 0 then
|
|
if self.wear_fashion_id ~= 0 then -- 有穿时装 直接飞回
|
|
return self:GetFashionModelID( self.wear_fashion_id )
|
|
end
|
|
for k,v in ipairs(self.Config_Child_Figure[self.childInfo.child_sex]) do
|
|
if child_age_month >= v.grow_up_level then
|
|
clothe_res_id_self = v.model_id
|
|
end
|
|
end
|
|
end
|
|
return clothe_res_id_self
|
|
end
|
|
|
|
-- 获取当前自己的孩子成熟期模型 (有时装就返回时装)
|
|
function ChildModel:GetBigChildCloth( )
|
|
local child_sex = self.childInfo.child_sex and self.childInfo.child_sex or 1 -- 默认值是男宝宝
|
|
-- 有穿时装 直接飞回
|
|
if self.wear_fashion_id ~= 0 then
|
|
return self:GetFashionModelID( self.wear_fashion_id )
|
|
end
|
|
-- 取得成熟期模型
|
|
local clothe_res_id_self = self:GetBigNormalChildCloth( child_sex )
|
|
|
|
return clothe_res_id_self or 1021
|
|
end
|
|
|
|
-- 获取宝宝成熟模型(不判断时装)
|
|
function ChildModel:GetBigNormalChildCloth( child_sex )
|
|
if not self.normal_big_child_cloth then
|
|
self.normal_big_child_cloth = {} -- 缓存
|
|
for i=1, 2 do
|
|
local temp_age_month = 0
|
|
for k,v in ipairs(self.Config_Child_Figure[i]) do
|
|
if temp_age_month < v.grow_up_level then
|
|
temp_age_month = v.grow_up_level
|
|
self.normal_big_child_cloth[i] = v.model_id
|
|
end
|
|
end
|
|
end
|
|
end
|
|
return self.normal_big_child_cloth[child_sex]
|
|
end
|
|
|
|
-- 根据时装id获取对应模型id
|
|
function ChildModel:GetFashionModelID( fashion_id, child_sex )
|
|
local child_sex = child_sex
|
|
if not child_sex then -- 如果没有指定性别 就拿model记录的自己宝宝的性别
|
|
child_sex = self.childInfo.child_sex or 1
|
|
end
|
|
local cfg = self.Config_Child_Fashion[fashion_id][1]
|
|
local model_list = stringtotable(cfg.model_id)
|
|
return tonumber(model_list[child_sex][2])
|
|
end
|
|
|
|
-- 根据时装id获取对应模型id
|
|
function ChildModel:GetVehicleModelID( fashion_id )
|
|
--print('Msh:ChildModel.lua[282] fashion_id', fashion_id)
|
|
-- PrintCallStack()
|
|
if self.Config_Child_Vehicle[fashion_id] and self.Config_Child_Vehicle[fashion_id][1] then
|
|
local cfg = self.Config_Child_Vehicle[fashion_id][1]
|
|
return cfg.model_id
|
|
else
|
|
return 0 -- 默认值
|
|
end
|
|
|
|
end
|
|
|
|
-- 通过传入的 宝宝年龄月份 + 性别 + 时装id = 获取模型id
|
|
function ChildModel:GetChildClothByParam( child_age_month, child_sex, fashion_id )
|
|
-- print('Msh:ChildModel.lua[295] data', child_age_month, child_sex, fashion_id)
|
|
if fashion_id and child_sex and tonumber(fashion_id) ~= 0 then -- 有时装id和性别
|
|
return self:GetFashionModelID( fashion_id, child_sex )
|
|
elseif child_age_month and child_sex then
|
|
local clothe_res_id_self = 1011
|
|
if not (child_sex == 1 or child_sex == 2) then -- 性别数据异常
|
|
-- print('Msh:ChildModel.lua[287] child_sex', child_sex)
|
|
child_sex = 1
|
|
end
|
|
for k,v in ipairs(self.Config_Child_Figure[child_sex]) do
|
|
if child_age_month >= v.grow_up_level then
|
|
clothe_res_id_self = v.model_id
|
|
end
|
|
end
|
|
return clothe_res_id_self
|
|
else
|
|
print('Msh:ChildModel.lua[259] error:', child_age_month, child_sex, fashion_id )
|
|
end
|
|
end
|
|
|
|
-- 传入child_fashion穿戴时装列表 得到穿戴中的时装(注:类型2装饰已废弃)
|
|
-- fashion_list:array{
|
|
-- type :int8 //时装类型 1-时装 2-装饰
|
|
-- fashion_id :int32 //时装Id 0-没有穿戴时装 其他-具体穿戴时装Id
|
|
-- }
|
|
function ChildModel:GetChildFashionID( fashion_list )
|
|
-- print('Msh:ChildModel.lua[321] data')
|
|
-- PrintTable(fashion_list)
|
|
for i,v in ipairs(fashion_list) do
|
|
if v.type == 1 then
|
|
return v.fashion_id ~= 0 and v.fashion_id or nil
|
|
end
|
|
end
|
|
end
|
|
|
|
--[[-- 设置当前宝宝模型id
|
|
function ChildModel:SetChildInfoForRoleModel(figure_id)
|
|
if figure_id then
|
|
self.childInfo.figure_id = figure_id
|
|
else
|
|
|
|
end
|
|
end
|
|
|
|
function ChildModel:GetChildRoleListData( )
|
|
return self.childInfo.figure_id
|
|
end--]]
|
|
|
|
-- 获取孩子当前的成长属性
|
|
function ChildModel:GetChildNowGrowUpInfo()
|
|
local cfg = self.Config_Child_GrowUp[self.childInfo.child_age_month]
|
|
assert(cfg, string.format("Msh:error! please check: %s", self.childInfo.child_age_month) )
|
|
return cfg
|
|
end
|
|
|
|
-- 获取孩子下一级的成长属性
|
|
function ChildModel:GetChildNextGrowUpInfo()
|
|
if not self.childInfo.child_age_month then return end
|
|
local cfg = self.Config_Child_GrowUp[self.childInfo.child_age_month + 1]
|
|
--assert(cfg, string.format("Msh:error! please check: %s", self.childInfo.child_age_month + 1) )
|
|
return cfg
|
|
end
|
|
|
|
-- 获取同心配置
|
|
function ChildModel:GetChildLinkHeartInfo()
|
|
return self.Config_Child_LinkHeart
|
|
end
|
|
|
|
-- 获取常量键值
|
|
function ChildModel:GetConfigChildKvVal(keyName)
|
|
assert(self.Config_Child_kv[keyName], string.format('Msh:error! please check: %s', keyName) )
|
|
return self.Config_Child_kv[keyName]
|
|
end
|
|
|
|
---获取最基础的一级skillList
|
|
function ChildModel:GetConfigChildSkillBase( )
|
|
local list_base_skill = {}
|
|
for k,v in pairs(self.Config_Child_Skill) do
|
|
if v.level == 1 then
|
|
table.insert(list_base_skill,v)
|
|
end
|
|
end
|
|
return list_base_skill
|
|
end
|
|
|
|
function ChildModel:GetChildSkillList( )
|
|
return self.childSkillList
|
|
end
|
|
|
|
--[[
|
|
与后端结合成目前技能表
|
|
]]
|
|
function ChildModel:SetChildSkillList( vo )
|
|
local baseList = self:GetConfigChildSkillBase()
|
|
local mixList = {}
|
|
for k,v in pairs(baseList) do
|
|
local skillId = stringtotable(v.active_skill)[1][1]
|
|
local skillLv = 0
|
|
for k_s,v_s in pairs(vo.skill_list) do
|
|
if v_s.skill_id == skillId then
|
|
skillLv = v_s.skill_lv
|
|
end
|
|
end
|
|
local new_list = {}
|
|
new_list.skill_id = skillId
|
|
new_list.skill_lv = skillLv
|
|
new_list.sequence = v.sequence
|
|
table.insert(mixList,new_list)
|
|
end
|
|
|
|
local function sort_func(a, b)
|
|
return a.sequence < b.sequence
|
|
end
|
|
table.sort(mixList, sort_func)
|
|
|
|
self.childSkillList = mixList
|
|
self:SetCanUseSkillList()
|
|
end
|
|
|
|
-- 设置当前可以使用的技能列表
|
|
function ChildModel:SetCanUseSkillList( )
|
|
for k,v in pairs(self.childSkillList) do
|
|
local list = ConfigItemMgr.Instance:GetSkillItem(v.skill_id)
|
|
if list and list.type == 1 and v.skill_lv > 0 then -- 是主动且已经学习
|
|
table.insert(self.can_use_skill_list, v.skill_id)
|
|
end
|
|
end
|
|
end
|
|
|
|
function ChildModel:GetCanUseSkillList( )
|
|
return self.can_use_skill_list
|
|
end
|
|
|
|
--
|
|
function ChildModel:GetConfigChildSkillNearActiveLevel(active_skill_lv)
|
|
for k,v in pairs(self.Config_Child_Skill) do
|
|
if stringtotable(v.active_skill)[1][2] == active_skill_lv then
|
|
return v.level
|
|
end
|
|
end
|
|
return false
|
|
end
|
|
|
|
---找技能表info
|
|
function ChildModel:GetConfigChildSkillInfo(skill_id,skill_lv)
|
|
for k,v in pairs(self.Config_Child_Skill) do
|
|
local skillId = stringtotable(v.active_skill)[1][1]
|
|
if v.level == skill_lv and skillId == skill_id then
|
|
return v
|
|
elseif skill_lv == 0 then
|
|
local list_first = self:GetConfigChildSkillInfo(skill_id,1)
|
|
return{
|
|
level = 0,
|
|
skill_desc = list_first.skill_desc,
|
|
add_attr_list = {},
|
|
sequence = list_first.sequence,
|
|
skill_name = list_first.skill_name,
|
|
}
|
|
end
|
|
end
|
|
end
|
|
|
|
-- 检查宝宝技能是否开放
|
|
function ChildModel:CheckSkillIsOpen( )
|
|
return self.childInfo.child_age_month and self.childInfo.child_age_month >= self:GetConfigChildKvVal("skill_open_stage") * 10
|
|
end
|
|
|
|
--选中当前的v
|
|
function ChildModel:GetChildSkillShowAttrList(sequence,level)
|
|
local skill_list_before = {}
|
|
if level > 0 then
|
|
skill_list_before = self.Config_Child_Skill[sequence.."@"..level]
|
|
end
|
|
|
|
local skill_list_after = self.Config_Child_Skill[sequence.."@"..level+1]
|
|
|
|
local attr_list_before = skill_list_before and stringtotable(skill_list_before.add_attr_list) or {}
|
|
local attr_list_after = skill_list_after and stringtotable(skill_list_after.add_attr_list) or {}
|
|
local attr_id,num_after,num_before = 0 -- num_after是配置表的
|
|
local attr_list = {}
|
|
|
|
if not skill_list_after then
|
|
for k,v in pairs(attr_list_before) do
|
|
attr_id = v[1]
|
|
num_before = v[2]
|
|
num_after = ""
|
|
local list = {}
|
|
list.attr_id = attr_id
|
|
list.num_before = num_before
|
|
list.num_after = num_after
|
|
table.insert(attr_list,list)
|
|
end
|
|
else
|
|
for k,v in pairs(attr_list_after) do
|
|
attr_id = v[1]
|
|
num_before = 0
|
|
num_after = v[2]
|
|
for k_b,v_b in pairs(attr_list_before) do
|
|
if v_b[1] == v[1] then
|
|
num_before = v_b[2]
|
|
end
|
|
end
|
|
local list = {}
|
|
list.attr_id = attr_id
|
|
list.num_before = num_before
|
|
list.num_after = num_after
|
|
table.insert(attr_list,list)
|
|
end
|
|
end
|
|
|
|
return attr_list
|
|
--self.attr_item_list[k]:SetData(attr_id,num_before,num_after)
|
|
end
|
|
|
|
--[[
|
|
与后端结合成目前载具表
|
|
]]
|
|
--[[function ChildModel:SetChildVehicleList( vo )
|
|
local list_base_vehicle = {}
|
|
for k,v in pairs(self.Config_Child_Vehicle) do
|
|
if v.stage == 1 then
|
|
table.insert(list_base_vehicle,v)
|
|
end
|
|
end
|
|
local mixList = {}
|
|
for k,v in pairs(list_base_vehicle) do
|
|
--local vehicle_id = 0
|
|
local stage = 0
|
|
for k_s,v_s in pairs(vo.vehicle_list) do
|
|
if v_s.vehicle_id == v.vehicle_id then
|
|
stage = v_s.vehicle_stage
|
|
end
|
|
end
|
|
local new_list = {}
|
|
new_list.vehicle_id = v.vehicle_id
|
|
new_list.stage = stage
|
|
table.insert(mixList,new_list)
|
|
end
|
|
|
|
local function sort_func(a, b)
|
|
return a.vehicle_id < b.vehicle_id
|
|
end
|
|
table.sort(mixList, sort_func)
|
|
|
|
self.childVehicleList.vehicle_list = mixList
|
|
self.childVehicleList.show_vehicle = vo.show_vehicle
|
|
end
|
|
--]]
|
|
|
|
-- ---找载具表info
|
|
-- function ChildModel:GetConfigChildVehicleInfo(vehicle_id,stage)
|
|
-- for k,v in pairs(self.Config_Child_Vehicle) do
|
|
-- --local skillId = stringtotable(v.active_skill)[1][1]
|
|
-- if v.stage == stage and v.vehicle_id == vehicle_id then
|
|
-- return v
|
|
-- elseif stage == 0 then
|
|
-- local list_first = self:GetConfigChildVehicleInfo(vehicle_id,1)
|
|
-- return{
|
|
-- level = 0,
|
|
-- --skill_desc = list_first.skill_desc,
|
|
-- add_attr = {},
|
|
-- vehicle_id = list_first.vehicle_id,
|
|
-- --active_skill = {},
|
|
-- --active_cost = {},
|
|
-- vehicle_name = list_first.vehicle_name,
|
|
-- --pre_sequence = 0,
|
|
-- --need_power = 10000,
|
|
-- }
|
|
-- end
|
|
-- end
|
|
-- --return nil
|
|
-- end
|
|
|
|
--[[function ChildModel:GetChildVehicleShowAttrList(vehicle_id,stage)
|
|
local vehicle_list_before = {}
|
|
if stage > 0 then
|
|
vehicle_list_before = self.Config_Child_Vehicle[vehicle_id.."@"..stage]
|
|
end
|
|
|
|
local vehicle_list_after = self.Config_Child_Vehicle[vehicle_id.."@"..stage+1]
|
|
|
|
local attr_list_before = vehicle_list_before and stringtotable(vehicle_list_before.add_attr) or {}
|
|
local attr_list_after = vehicle_list_after and stringtotable(vehicle_list_after.add_attr) or {}
|
|
local attr_id,num_after,num_before = 0 -- num_after是配置表的
|
|
local attr_list = {}
|
|
|
|
if not vehicle_list_after then
|
|
for k,v in pairs(attr_list_before) do
|
|
attr_id = v[1]
|
|
num_before = v[2]
|
|
num_after = ""
|
|
local list = {}
|
|
list.attr_id = attr_id
|
|
list.num_before = num_before
|
|
list.num_after = num_after
|
|
table.insert(attr_list,list)
|
|
end
|
|
else
|
|
for k,v in pairs(attr_list_after) do
|
|
attr_id = v[1]
|
|
num_before = 0
|
|
num_after = v[2]
|
|
for k_b,v_b in pairs(attr_list_before) do
|
|
if v_b[1] == v[1] then
|
|
num_before = v_b[2]
|
|
end
|
|
end
|
|
local list = {}
|
|
list.attr_id = attr_id
|
|
list.num_before = num_before
|
|
list.num_after = num_after
|
|
table.insert(attr_list,list)
|
|
end
|
|
end
|
|
return attr_list
|
|
end--]]
|
|
|
|
-- 获取载具技能列表
|
|
function ChildModel:GetChildVehicleSkillList(fashion_id)
|
|
local vehicleSkillList = {}
|
|
-- print('=======Msh:ChildModel.lua[658] ===TABLE====')
|
|
-- PrintTable(self.Config_Child_Vehicle)
|
|
for k,v in pairs(self.Config_Child_Vehicle) do
|
|
if k == fashion_id then
|
|
for ii,vv in pairsByKeys(v) do
|
|
if vv.active_skill and vv.active_skill ~= 0 then
|
|
table.insert(vehicleSkillList, vv)
|
|
end
|
|
end
|
|
break
|
|
end
|
|
end
|
|
-- print('=======Msh:ChildModel.lua[671] ===TABLE====')
|
|
-- PrintTable(vehicleSkillList)
|
|
|
|
local function sort_func(a, b)
|
|
if a.stage then
|
|
return a.stage < b.stage
|
|
elseif a.lv then
|
|
return a.lv < b.lv
|
|
end
|
|
end
|
|
table.sort(vehicleSkillList, sort_func)
|
|
|
|
return vehicleSkillList
|
|
end
|
|
|
|
function ChildModel:IsPlayerHadChild( )
|
|
return self.isPlayerHadChild
|
|
end
|
|
|
|
function ChildModel:SetIsPlayerHadChild( bool )
|
|
self.isPlayerHadChild = bool
|
|
end
|
|
|
|
----------领养宝宝前置同心任务-start---------
|
|
-- 是否领取了所有奖励(需求是领完所有同心奖励才可以打开领养界面)
|
|
function ChildModel:HasGetAllHeartReward( )
|
|
local has_get_all = true
|
|
for k,v in pairs(Config.Childlinkheart) do
|
|
if self:GetHeartRewardStatus(v.reward_id) ~= 1 then
|
|
has_get_all = false
|
|
break
|
|
end
|
|
end
|
|
return has_get_all
|
|
end
|
|
|
|
-- 检查图标是否应该开启
|
|
function ChildModel:CheckHeartLinkIconShow( )
|
|
if not GetModuleIsOpen(165, 1, true) then -- 模块未开启
|
|
--logWarn('=======Msh:ChildModel.lua[630]=======')
|
|
return false
|
|
end
|
|
|
|
self.childInfo.adopt_time = self.childInfo.adopt_time or 0
|
|
if self.childInfo.adopt_time == 0 then -- 未领养孩子
|
|
--logWarn('=======Msh:ChildModel.lua[636]=======')
|
|
return true
|
|
end
|
|
|
|
local is_today = TimeUtil:IsToday( self.childInfo.adopt_time )
|
|
if is_today then -- 当天领养 还没过天
|
|
--logWarn('=======Msh:ChildModel.lua[642]=======')
|
|
return true
|
|
end
|
|
--logWarn('=======Msh:ChildModel.lua[645]=======')
|
|
return false
|
|
end
|
|
|
|
-- 更新同心任务列表数据 task_state //任务状态 0-未完成 1-已完成未领取 2-已领取
|
|
function ChildModel:SetTaskInfo(vo_16505)
|
|
--logWarn('=======Msh:ChildModel.lua[629]=======')
|
|
if not vo_16505 then return end
|
|
self.childTaskInfo = {}
|
|
local list1 = {}--两个融一
|
|
local list2 = {}
|
|
local has_can_get = false -- 是否有可以领取的奖励
|
|
-- [1] = {task_id = 1,open_level = 0,desc = [[ 获得135点日常活跃 ]],task_content = [[ [{liveness,0,135}] ]],reward_exp = 20,client_skip = [[ [{157,0}] ]]},
|
|
for k,v in pairs(self.Config_Child_DailyTask) do
|
|
if self.mainVo.level >= v.open_level then
|
|
v.task_state = 0
|
|
v.progress = 0
|
|
v.progress_max = stringtotable(v.task_content)[1][3]
|
|
for k_s,v_s in pairs(vo_16505) do
|
|
if v.task_id == v_s.sequence then
|
|
v.progress = v_s.progress
|
|
v.task_state = v_s.task_state
|
|
end
|
|
end
|
|
if v.task_state == 2 then -- 把已领取的单独拉开之后加到最后
|
|
table.insert(list2,v)
|
|
else
|
|
table.insert(list1,v)
|
|
if v.task_state == 1 then -- 可以领未领
|
|
has_can_get = true
|
|
end
|
|
end
|
|
end
|
|
end
|
|
self.heart_main_task_red = has_can_get
|
|
local sort_func = function ( a, b )
|
|
return a.task_state > b.task_state
|
|
end
|
|
table.sort(list1, sort_func)
|
|
|
|
for k,v in pairs(list2) do
|
|
table.insert(list1,v)
|
|
end
|
|
|
|
self.childTaskInfo = list1
|
|
end
|
|
|
|
-- 获取同心任务列表
|
|
function ChildModel:GetChildDailyTaskList()
|
|
return self.childTaskInfo
|
|
end
|
|
|
|
-- 获取哺乳期的孩子模型id
|
|
function ChildModel:GetChildOriginalModelID( child_sex )
|
|
local model_list = stringtotable( self:GetConfigChildKvVal("original_model") )[1]
|
|
assert(model_list[child_sex], string.format('Msh:error! please check: %s', child_sex) )
|
|
return tonumber( model_list[child_sex] )
|
|
end
|
|
|
|
-- 需求:每次打开同心任务界面,展示的婴儿宝宝性别变更
|
|
-- 同心任务:变更性别
|
|
function ChildModel:ChangeHeartTaskChildSex( )
|
|
self.heart_child_sex = self.heart_child_sex == 1 and 2 or 1
|
|
end
|
|
|
|
-- 同心任务:获取性别
|
|
function ChildModel:GetHeartTaskChildSex( )
|
|
return self.heart_child_sex
|
|
end
|
|
|
|
-- 同心任务红点相关
|
|
function ChildModel:UpdateHeartIconRed( )
|
|
self:UpdateHeartRewardRed()
|
|
self.heart_icon_red = self.heart_main_task_red or self.heart_progress_red
|
|
end
|
|
|
|
-- 获取同心任务图标红点
|
|
function ChildModel:GetHeartIconRed( )
|
|
return self.heart_icon_red
|
|
end
|
|
|
|
-- 更新同心任务进度奖励红点
|
|
function ChildModel:UpdateHeartRewardRed( )
|
|
local cur_heart_value = self:GetCurHeartValue( )
|
|
local bool = false
|
|
for heart_value, data in pairsByKeys(self:GetChildLinkHeartInfo()) do
|
|
if heart_value <= cur_heart_value then -- 可以领
|
|
local reward_status = self:GetHeartRewardStatus(data.reward_id)
|
|
if reward_status ~= 1 then -- 还没领
|
|
bool = true
|
|
end
|
|
elseif heart_value > cur_heart_value then -- 没达到条件
|
|
break
|
|
end
|
|
end
|
|
self.heart_progress_red = bool
|
|
end
|
|
|
|
-- 更新maintaskitem的任务奖励红点
|
|
function ChildModel:UpdateHeartMainTaskRed( )
|
|
|
|
end
|
|
|
|
----------领养宝宝前置同心任务-end-----------
|
|
|
|
-- 获取孩子投票奖励配置
|
|
function ChildModel:GetConfigChildVoteReward( )
|
|
return self.Config_Child_VoteReward
|
|
end
|
|
|
|
-- 获取投票角色列表
|
|
function ChildModel:GetChildVotedRoleList()
|
|
return self.childVotedRoleList
|
|
end
|
|
|
|
-- 设置投票角色列表
|
|
function ChildModel:SetChildVotedRoleList(vo_16519)
|
|
self.childVotedRoleList = vo_16519.role_list
|
|
end
|
|
|
|
------------宝宝玩具宝宝装备:
|
|
--[[function ChildModel:GetChildEquipList()
|
|
return self.childEquipList
|
|
end
|
|
|
|
function ChildModel:RemoveChildEquipList(vo)
|
|
local new_bag_list = {}
|
|
for k,v in pairs(self.childEquipList.bag_list) do
|
|
local isRemove = false
|
|
for k,v_remove in pairs(vo) do
|
|
if v_remove.goods_id == v.goods_id then
|
|
isRemove = true
|
|
end
|
|
end
|
|
if isRemove == false then
|
|
table.insert(new_bag_list,v)
|
|
end
|
|
end
|
|
self.childEquipList.bag_list = new_bag_list
|
|
end
|
|
function ChildModel:SetChildEquipList(vo)
|
|
|
|
self.childEquipList.carry_weight = vo.carry_weight or 0
|
|
self.childEquipList.can_carry = vo.can_carry or 0
|
|
|
|
local newEquipList = {}
|
|
local config_equip_list = DeepCopy(self.Config_Child_Toy)
|
|
--print("============>>> YiRan:ChildModel [start:470] ,#vo.bag_list :",#vo.bag_list)
|
|
for had_i,had_v in ipairs(vo.bag_list) do
|
|
for k,v in pairs(config_equip_list) do
|
|
if v.toy_id == had_v.goods_type_id then
|
|
local item_list = {}
|
|
item_list.goods_id = had_v.goods_id
|
|
item_list.goods_type_id = had_v.goods_type_id
|
|
item_list.lv = had_v.lv
|
|
item_list.toy_color = v.toy_color
|
|
item_list.toy_weight = v.toy_weight
|
|
item_list.attr_list = v.attr_list
|
|
table.insert(newEquipList,item_list)
|
|
end
|
|
end
|
|
end
|
|
self.childEquipList.bag_list = newEquipList
|
|
--print("============>>> YiRan:ChildModel [start:485] #newEquipList :",#newEquipList)
|
|
--------穿戴
|
|
local newSlotList = vo.slot_list
|
|
|
|
for i=1,ChildConst.ChildEquipWearMaxNum do -- 6个槽填满
|
|
local isHave = false
|
|
for k,v in pairs(newSlotList) do
|
|
if v.slot_id == i then
|
|
--print("============>>> YiRan:ChildModel [start:492] v.slot_id :",v.slot_id)
|
|
isHave = true
|
|
for k,v_config in pairs(config_equip_list) do
|
|
if v_config.toy_id == v.goods_type_id then
|
|
print("============>>> YiRan:ChildModel [start:508] v.goods_id :",v.goods_id)
|
|
v.toy_color = v_config.toy_color
|
|
v.toy_weight = v_config.toy_weight
|
|
v.attr_list = v_config.attr_list
|
|
end
|
|
end
|
|
end
|
|
end
|
|
if isHave == false then
|
|
local new_slot_list_item = {}
|
|
new_slot_list_item.goods_type_id = 0
|
|
new_slot_list_item.is_open = 0
|
|
new_slot_list_item.slot_id = i
|
|
new_slot_list_item.lv = 0
|
|
new_slot_list_item.goods_id = 0
|
|
--newSlotList[i] = new_slot_list_item
|
|
table.insert(newSlotList,new_slot_list_item)
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
local function sort_func(a, b)
|
|
return a.slot_id < b.slot_id
|
|
end
|
|
table.sort(newSlotList, sort_func)
|
|
self.childEquipList.slot_list = newSlotList or {}
|
|
--print("=============>>> YiRan:ChildModel [start:506] self.childEquipList.slot_list ------------------------------------------")
|
|
--PrintTable(self.childEquipList.slot_list)
|
|
--print("=============>>> YiRan:ChildModel [end] ------------------------------------------")
|
|
end
|
|
|
|
function ChildModel:SetChildEquipBuildList(vo)
|
|
vo = vo or {}
|
|
local mixBulidList = {}
|
|
for i=1,#self.Config_Child_ForgeSlotOpen do
|
|
local isHave = false
|
|
for k,v in pairs(vo) do
|
|
if v.slot_id == i then
|
|
isHave = true
|
|
if v.use_status == 1 then --打造中的把时间加进去
|
|
for c_k,c_v in pairs(self.Config_Child_ForgetTime) do
|
|
if c_v.id == v.select_id then
|
|
v.need_time = c_v.need_time
|
|
table.insert(mixBulidList,v)
|
|
end
|
|
end
|
|
else --
|
|
table.insert(mixBulidList,v)
|
|
end
|
|
end
|
|
end
|
|
if isHave == false then
|
|
local new_list = {}
|
|
new_list.slot_id = i
|
|
new_list.is_open = 0
|
|
new_list.use_status = 0
|
|
new_list.start_time = 0
|
|
new_list.select_id = 0
|
|
new_list.cost = stringtotable(self.Config_Child_ForgeSlotOpen[i].condition)
|
|
--newSlotList[i] = new_list
|
|
table.insert(mixBulidList,new_list)
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local function sort_func(a, b)
|
|
return a.slot_id < b.slot_id
|
|
end
|
|
table.sort(mixBulidList, sort_func)
|
|
|
|
self.childEquipBuildList = mixBulidList
|
|
end
|
|
function ChildModel:GetChildEquipBuildList()
|
|
return self.childEquipBuildList
|
|
end
|
|
|
|
function ChildModel:GetChildEquipSpeedUpBuildCost( time )
|
|
|
|
for k,v in pairs(self.Config_Child_SpeedUp) do
|
|
if time >= v.time_low and time < v. time_high and v.time_low ~= 0 then
|
|
print("=============>>> YiRan:ChildModel [start:517] v.cost ------------------------------------------")
|
|
PrintTable(v.cost)
|
|
print("=============>>> YiRan:ChildModel [end] ------------------------------------------")
|
|
local cost_list = stringtotable(v.cost)[1]
|
|
if cost_list[1] == 1 then
|
|
return cost_list[2]
|
|
end
|
|
end
|
|
end
|
|
return 0
|
|
end
|
|
|
|
function ChildModel:GetChildEquipBagItemList(goods_id)
|
|
for k,v in pairs(self.childEquipList.bag_list) do
|
|
if v.goods_id == goods_id then
|
|
return v
|
|
end
|
|
end
|
|
end
|
|
|
|
function ChildModel:GetChildEquipWearItemList(goods_id) -- 背包和穿戴的装备两个是不同的list获取
|
|
for k,v in pairs(self.childEquipList.slot_list) do
|
|
if v.goods_id == goods_id then
|
|
return v
|
|
end
|
|
end
|
|
end
|
|
|
|
function ChildModel:GetChildEquipIdAndColorAndTypeAndLv(goods_id)--唯一ID获取玩具类型和重量type
|
|
local goods_type_id = 0
|
|
local toy_type = 0
|
|
local lv = 0
|
|
local toy_color = 0
|
|
for k,v in pairs(self.childEquipList.bag_list) do
|
|
if v.goods_id == goods_id then
|
|
goods_type_id = v.goods_type_id
|
|
lv = v.lv
|
|
end
|
|
end
|
|
if goods_type_id == 0 then -- 没有的话去穿戴获取
|
|
for k,v in pairs(self.childEquipList.slot_list) do
|
|
if v.goods_id == goods_id then
|
|
goods_type_id = v.goods_type_id
|
|
lv = v.lv
|
|
end
|
|
end
|
|
end
|
|
if self.Config_Child_Toy[goods_type_id] then
|
|
toy_type = self.Config_Child_Toy[goods_type_id].toy_type
|
|
toy_color = self.Config_Child_Toy[goods_type_id].toy_color
|
|
end
|
|
|
|
return goods_type_id,toy_color,toy_type,lv
|
|
end
|
|
|
|
function ChildModel:GetChildConfigStrenToyInfo(toy_color,toy_type,stren_lv)
|
|
if stren_lv < 0 then
|
|
return nil
|
|
end
|
|
return self.Config_Child_ToyStren[toy_color.."@"..toy_type.."@"..stren_lv]
|
|
|
|
|
|
end
|
|
|
|
function ChildModel:GetChildStrenShowAttrList(toy_color,toy_type,stren_lv,lvLenth)
|
|
local vehicle_list_before = {}
|
|
if stren_lv > 0 then
|
|
vehicle_list_before = self.Config_Child_ToyStren[toy_color.."@"..toy_type.."@"..stren_lv]
|
|
end
|
|
|
|
local vehicle_list_after = self.Config_Child_ToyStren[toy_color.."@"..toy_type.."@"..stren_lv+lvLenth]
|
|
|
|
local attr_list_before = vehicle_list_before and stringtotable(vehicle_list_before.add_attr) or {}
|
|
local attr_list_after = vehicle_list_after and stringtotable(vehicle_list_after.add_attr) or {}
|
|
local attr_id,num_after,num_before = 0 -- num_after是配置表的
|
|
local attr_list = {}
|
|
|
|
if not vehicle_list_after then
|
|
for k,v in pairs(attr_list_before) do
|
|
attr_id = v[1]
|
|
num_before = v[2]
|
|
num_after = ""
|
|
local list = {}
|
|
list.attr_id = attr_id
|
|
list.num_before = num_before
|
|
list.num_after = num_after
|
|
table.insert(attr_list,list)
|
|
end
|
|
else
|
|
for k,v in pairs(attr_list_after) do
|
|
attr_id = v[1]
|
|
num_before = 0
|
|
num_after = v[2]
|
|
for k_b,v_b in pairs(attr_list_before) do
|
|
if v_b[1] == v[1] then
|
|
num_before = v_b[2]
|
|
end
|
|
end
|
|
local list = {}
|
|
list.attr_id = attr_id
|
|
list.num_before = num_before
|
|
list.num_after = num_after
|
|
table.insert(attr_list,list)
|
|
end
|
|
end
|
|
return attr_list
|
|
end--]]
|
|
|
|
----------宝宝时装-start---------
|
|
-- 根据是时装类型获取时装列表
|
|
function ChildModel:GetChildDressList()
|
|
return self.childDressList
|
|
end
|
|
|
|
-- 判断目标时装是否是满级
|
|
function ChildModel:IsChildFashionLvMax(fashion_id,lv)
|
|
-- local max = 0
|
|
-- for k,v in pairs(self.Config_Child_Fashion) do
|
|
-- if v.fashion_id == fashion_id then
|
|
-- if v.lv > max then
|
|
-- max = v.lv
|
|
-- end
|
|
-- end
|
|
-- end
|
|
-- if max <= lv then
|
|
-- return true
|
|
-- else
|
|
-- return false
|
|
-- end
|
|
-- 没有下一级的配置说明已经满级
|
|
return self.Config_Child_Fashion[fashion_id][lv + 1] == nil
|
|
end
|
|
|
|
-- 获取时装配置
|
|
function ChildModel:GetConfigChildFashionList(fashionId,lv)
|
|
if self.Config_Child_Fashion[fashionId][lv] then
|
|
return self.Config_Child_Fashion[fashionId][lv]
|
|
else
|
|
return self.Config_Child_Fashion[fashionId][lv - 1]
|
|
end
|
|
end
|
|
|
|
-- 设置孩子的时装列表 根据类型
|
|
function ChildModel:SetChildDressList(fashionType, fashion_list)
|
|
if fashionType ~= 1 then return end -- 只要类型1才需要赋值
|
|
local fashion_list = fashion_list or {}
|
|
|
|
self.childDressList = {}
|
|
for fashion_id, v in pairs(self.Config_Child_Fashion) do
|
|
local data = DeepCopy(v[1])
|
|
data.active = false
|
|
data.lv = 0
|
|
data.state = 0
|
|
self.childDressList[fashion_id] = data
|
|
end
|
|
|
|
local wear_id = 0
|
|
for k, v in pairs(fashion_list) do
|
|
local temp = self.childDressList[v.fashion_id]
|
|
temp.lv = v.lv
|
|
temp.state = v.state
|
|
temp.active = true -- 后端返回了这个数据 说明已激活
|
|
temp.attr_list = self:GetConfigChildFashionList(v.fashion_id,v.lv).attr_list
|
|
temp.upgrade_cost = self:GetConfigChildFashionList(v.fashion_id,v.lv + 1).upgrade_cost
|
|
-- 如果穿戴中 记录一下
|
|
if temp.state == 1 then
|
|
wear_id = v.fashion_id
|
|
end
|
|
end
|
|
-- 更新一下穿戴中的时装id
|
|
if wear_id ~= 0 then
|
|
self.wear_fashion_id = wear_id
|
|
else
|
|
self.wear_fashion_id = 0
|
|
end
|
|
end
|
|
|
|
--
|
|
function ChildModel:GetCurWearID( )
|
|
return self.wear_fashion_id or 0
|
|
end
|
|
|
|
-- 检查宝宝时装是否开放
|
|
function ChildModel:CheckDressIsOpen( )
|
|
return self.childInfo.child_age_month and self.childInfo.child_age_month >= self.max_grow_state
|
|
end
|
|
|
|
-- 获取宝宝成熟期成长等级
|
|
function ChildModel:GetChildMaxGrowState( )
|
|
return self.max_grow_state
|
|
end
|
|
|
|
-- 根据物品id获取时装id(目前的时装id就是物品id)
|
|
function ChildModel:GetFashionIdByGoodsId( type_id )
|
|
local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(type_id)
|
|
if basic then
|
|
if basic.type == GoodsModel.TYPE.CHILDTOY then
|
|
if self.Config_Child_Fashion[type_id] then
|
|
return type_id
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
-----------------载具类时装--------------------
|
|
-- 判断目标时装是否是满级
|
|
function ChildModel:IsChildVehicleLvMax(fashion_id,lv)
|
|
-- 没有下一级的配置说明已经满级
|
|
return self.Config_Child_Vehicle[fashion_id][lv + 1] == nil
|
|
end
|
|
-- 拿处理好的载具数据 (后端数据与配置结合)
|
|
function ChildModel:GetChildVehicleList( )
|
|
return self.childVehicleList
|
|
end
|
|
|
|
-- 获取载具配置
|
|
function ChildModel:GetConfigChildVehicleList(fashionId,lv)
|
|
if self.Config_Child_Vehicle[fashionId][lv] then
|
|
return self.Config_Child_Vehicle[fashionId][lv]
|
|
else
|
|
return self.Config_Child_Vehicle[fashionId][lv - 1]
|
|
end
|
|
end
|
|
|
|
-- 设置孩子的载具类时装列表 根据类型
|
|
function ChildModel:SetChildVehicleList(fashion_list)
|
|
local fashion_list = fashion_list or {}
|
|
|
|
self.childVehicleList = {}
|
|
for fashion_id, v in pairs(self.Config_Child_Vehicle) do
|
|
local data = DeepCopy(v[1])
|
|
data.active = false
|
|
data.lv = 0
|
|
data.state = 0
|
|
self.childVehicleList[fashion_id] = data
|
|
end
|
|
|
|
local wear_id = 0
|
|
for k, v in pairs(fashion_list) do
|
|
local temp = self.childVehicleList[v.vehicle_id]
|
|
temp.lv = v.vehicle_stage
|
|
temp.state = self:GetChildVehicleID( ) == v.vehicle_id and 1 or 0
|
|
--print('Msh:ChildModel.lua[1112] data', self:GetChildVehicleID( ), v.vehicle_id, temp.state)
|
|
temp.active = v.vehicle_stage > 0
|
|
temp.attr_list = self:GetConfigChildVehicleList(v.vehicle_id,v.vehicle_stage).attr_list
|
|
temp.upgrade_cost = self:GetConfigChildVehicleList(v.vehicle_id,v.vehicle_stage + 1).upgrade_cost
|
|
end
|
|
end
|
|
|
|
-- 设置孩子当前的坐骑 [set_type 0-没有幻化的载具 其他-具体幻化载具Id]
|
|
function ChildModel:SetChildVehicleFollow( set_type,vehicle_id )
|
|
local show_vehicle = 0
|
|
if set_type == 1 then
|
|
show_vehicle = vehicle_id
|
|
end
|
|
self.show_vehicle_id = show_vehicle
|
|
end
|
|
|
|
-- 获取孩子当前的坐骑
|
|
function ChildModel:GetChildVehicleID( )
|
|
return self.show_vehicle_id or 0
|
|
end
|
|
|
|
-- 根据物品id获取载具id(目前的载具id就是物品id)
|
|
function ChildModel:GetVehicleIdByGoodsId( type_id )
|
|
local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(type_id)
|
|
if basic then
|
|
if basic.type == GoodsModel.TYPE.CHILDTOY then
|
|
if self.Config_Child_Vehicle[type_id] then
|
|
return type_id
|
|
end
|
|
end
|
|
end
|
|
end
|
|
----------宝宝时装-end-----------
|
|
|
|
----------孩子培养(成长)-start---------
|
|
|
|
function ChildModel:GetChildFeedList()
|
|
local feedList = {}
|
|
table.insert(feedList,stringtotable(self:GetConfigChildKvVal("low_feed"))[1])
|
|
table.insert(feedList,stringtotable(self:GetConfigChildKvVal("mid_feed"))[1])
|
|
table.insert(feedList,stringtotable(self:GetConfigChildKvVal("high_feed"))[1])
|
|
return feedList
|
|
end
|
|
|
|
function ChildModel:GetBreakShowList(break_list)
|
|
local config_goods_decompose = Config.Goodsdecompose
|
|
local getList = {}
|
|
|
|
local AddListSamePorp = function ( porpList,getList )
|
|
for k,v in pairs(porpList) do
|
|
if v[1] == 0 then
|
|
local isHad = false
|
|
for k_g,v_g in pairs(getList) do
|
|
if v_g.good_id == v[2] then
|
|
isHad = true
|
|
v_g.num = v_g.num + v[3]
|
|
end
|
|
end
|
|
if isHad == false then
|
|
local list = {}
|
|
list.good_id = v[2]
|
|
list.num = v[3]
|
|
table.insert(getList,list)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
----自身的价值
|
|
for k,v in pairs(break_list) do
|
|
local porpList = stringtotable(config_goods_decompose[v.type_id].regular_mat)
|
|
AddListSamePorp(porpList,getList)
|
|
end
|
|
-----强化的价值
|
|
local AddBagLevelSternBreakShow = function (v_bag)
|
|
for i=1,v_bag.lv do
|
|
local stren_list = self:GetChildConfigStrenToyInfo(v_bag.toy_color,v_bag.toy_weight,i)
|
|
local porpList = stringtotable(stren_list.cost)
|
|
AddListSamePorp(porpList,getList)
|
|
end
|
|
end
|
|
|
|
for k,v in pairs(break_list) do
|
|
for k,v_bag in pairs(self:GetChildEquipList().bag_list) do
|
|
if v.goods_id == v_bag.goods_id then
|
|
if v_bag.lv > 0 then
|
|
AddBagLevelSternBreakShow(v_bag)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
return getList
|
|
|
|
end
|
|
----------孩子培养(成长)-end-----------
|
|
|
|
----------玩具收集(图鉴)-start---------
|
|
|
|
function ChildModel:GetToySuitInfo( )
|
|
local config_Child_ToySuit = self.Config_Child_ToySuit
|
|
local sort_func = function ( a, b )
|
|
return a.sequence < b.sequence
|
|
end
|
|
table.sort(config_Child_ToySuit, sort_func)
|
|
return config_Child_ToySuit
|
|
end
|
|
|
|
function ChildModel:GetChildSuitRewardList( )
|
|
return self.childSuitRewardList
|
|
end
|
|
function ChildModel:SetChildSuitRewardList( vo16534 )
|
|
|
|
for k,v in pairs(vo16534.suit_list) do
|
|
self.childSuitRewardList[v.suit_type] = {}
|
|
self.childSuitRewardList[v.suit_type].suit_type = v.suit_type
|
|
self.childSuitRewardList[v.suit_type].progress = v.progress
|
|
self.childSuitRewardList[v.suit_type].status = v.status
|
|
self.childSuitRewardList[v.suit_type].time = v.time
|
|
|
|
|
|
---算百分比
|
|
local list_base = {}
|
|
for k_c,v_c in pairs(self.Config_Child_ToyNew) do
|
|
if v_c.suit_type == v.suit_type then
|
|
table.insert(list_base,v_c)
|
|
end
|
|
end
|
|
|
|
local collectMaxNum = TableSize(list_base)
|
|
local percentNum = "0%"
|
|
if v.progress > 0 then
|
|
percentNum = (v.progress*100 / collectMaxNum).."%"
|
|
end
|
|
self.childSuitRewardList[v.suit_type].collectMaxNum = collectMaxNum
|
|
self.childSuitRewardList[v.suit_type].percent_txt = percentNum
|
|
|
|
end
|
|
|
|
for i=1,TableSize(self.Config_Child_ToySuit) do
|
|
if TableSize(self.childSuitRewardList[i]) < 1 then
|
|
local list_base = {}
|
|
for k_c,v_c in pairs(self.Config_Child_ToyNew) do
|
|
if v_c.suit_type == i then
|
|
table.insert(list_base,v_c)
|
|
end
|
|
end
|
|
|
|
local collectMaxNum = TableSize(list_base)
|
|
|
|
self.childSuitRewardList[i] = {}
|
|
self.childSuitRewardList[i].suit_type = i
|
|
self.childSuitRewardList[i].progress = 0
|
|
self.childSuitRewardList[i].status = 0
|
|
self.childSuitRewardList[i].time = 0
|
|
self.childSuitRewardList[i].collectMaxNum = collectMaxNum
|
|
self.childSuitRewardList[i].percent_txt = "0%"
|
|
end
|
|
end
|
|
|
|
end
|
|
function ChildModel:GetSuitToyBoxLv( )
|
|
return self.toy_box_lv or 0
|
|
end
|
|
|
|
function ChildModel:GetSuitToyList( suit_type )
|
|
if suit_type then
|
|
local list = {}
|
|
for k,v in pairs(self.childSuitToyList) do
|
|
if v.suit_type == suit_type then
|
|
table.insert(list,v)
|
|
end
|
|
end
|
|
return list
|
|
else
|
|
return self.childSuitToyList
|
|
end
|
|
|
|
end
|
|
|
|
function ChildModel:SetSuitTypeToyList( vo16533 )
|
|
local list_base = {}
|
|
self.child_acitve_toy_list = {}
|
|
self.toy_box_lv = vo16533.toy_box_lv
|
|
for k,v in pairs(DeepCopy(self.Config_Child_ToyNew)) do
|
|
for k_toy,v_toy in pairs(vo16533.toy_list) do
|
|
if v_toy.toy_id == v.toy_id then
|
|
v.isActive = true
|
|
table.insert(self.child_acitve_toy_list,v.toy_id)
|
|
end
|
|
end
|
|
table.insert(list_base,v)
|
|
end
|
|
|
|
local sort_func = function ( a, b )
|
|
return a.toy_id < b.toy_id
|
|
end
|
|
table.sort(list_base, sort_func)
|
|
|
|
--print("=============>>> YiRan:ChildModel [start:933] list_base ------------------------------------------")
|
|
--PrintTable(list_base)
|
|
--print("=============>>> YiRan:ChildModel [end] ------------------------------------------")
|
|
|
|
self.childSuitToyList = list_base
|
|
|
|
end
|
|
|
|
function ChildModel:GetChildHandbookBreakList()
|
|
local goods = GoodsModel:getInstance()
|
|
local colorNums ={
|
|
[0] = {["good_sum"] = 0,["decompose_sum"] = 0,["goods_list"] = {}},
|
|
[1] = {["good_sum"] = 0,["decompose_sum"] = 0,["goods_list"] = {}},
|
|
[2] = {["good_sum"] = 0,["decompose_sum"] = 0,["goods_list"] = {}},
|
|
[3] = {["good_sum"] = 0,["decompose_sum"] = 0,["goods_list"] = {}},
|
|
[4] = {["good_sum"] = 0,["decompose_sum"] = 0,["goods_list"] = {}},
|
|
[5] = {["good_sum"] = 0,["decompose_sum"] = 0,["goods_list"] = {}},
|
|
}
|
|
for k,v in pairs(self.Config_Child_ToyNew) do
|
|
local num = goods:GetTypeGoodsNum(v.toy_id)
|
|
--local decompose_num = stringtotable(v.decompose_reward)[1][3]
|
|
for k,v_active_id in pairs(self.child_acitve_toy_list) do
|
|
if v_active_id == v.toy_id and num > 0 then
|
|
for i=1,5 do
|
|
if v.color == i then
|
|
local list = {}
|
|
list.good_id = v.toy_id
|
|
list.num = num
|
|
table.insert(colorNums[i].goods_list,list)
|
|
local regular_mat = Config.Goodsdecompose[v.toy_id].regular_mat --改成读取通用物品表
|
|
local decompose_num = stringtotable(regular_mat)[1][3]
|
|
|
|
colorNums[i].good_sum = colorNums[i].good_sum + num
|
|
colorNums[i].decompose_sum = colorNums[i].decompose_sum + (num*decompose_num)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
return colorNums
|
|
end
|
|
|
|
|
|
function ChildModel:GetChildHandbookToyUpgradeList(level)
|
|
return self.Config_Child_ToyUpgrade[level]
|
|
end
|
|
--选中当前的v
|
|
function ChildModel:GetChildHandbookItemAttrList(level)
|
|
--print("============>>> YiRan:ChildModel [start:899] level :",level)
|
|
local HbToy_list_before = {}
|
|
if not level then level = 0 end
|
|
if level >= 0 then
|
|
HbToy_list_before = self.Config_Child_ToyUpgrade[level]
|
|
end
|
|
|
|
local HbToy_list_after = self.Config_Child_ToyUpgrade[level+1]
|
|
|
|
local attr_list_before = HbToy_list_before and stringtotable(HbToy_list_before.add_attr) or {}
|
|
local attr_list_after = HbToy_list_after and stringtotable(HbToy_list_after.add_attr) or {}
|
|
local attr_id,num_after,num_before = 0 -- num_after是配置表的
|
|
local attr_list = {}
|
|
|
|
if not HbToy_list_after then
|
|
for k,v in pairs(attr_list_before) do
|
|
attr_id = v[1]
|
|
num_before = v[2]
|
|
num_after = ""
|
|
local list = {}
|
|
list.attr_id = attr_id
|
|
list.num_before = num_before
|
|
list.num_after = num_after
|
|
table.insert(attr_list,list)
|
|
end
|
|
else
|
|
for k,v in pairs(attr_list_after) do
|
|
attr_id = v[1]
|
|
num_before = 0
|
|
num_after = v[2]
|
|
for k_b,v_b in pairs(attr_list_before) do
|
|
if v_b[1] == v[1] then
|
|
num_before = v_b[2]
|
|
end
|
|
end
|
|
local list = {}
|
|
list.attr_id = attr_id
|
|
list.num_before = num_before
|
|
list.num_after = num_after
|
|
table.insert(attr_list,list)
|
|
end
|
|
end
|
|
|
|
return attr_list
|
|
|
|
--self.attr_item_list[k]:SetData(attr_id,num_before,num_after)
|
|
end
|
|
----------玩具收集(图鉴)-end-----------
|
|
|
|
|
|
----------红点逻辑-start---------
|
|
|
|
function ChildModel:IsRedDotChildTrain( )
|
|
if not self:CheckChildFuncIsOpen() then
|
|
return false
|
|
end
|
|
local isRedDot = false
|
|
local feed_list = self:GetChildFeedList()
|
|
if not feed_list then return end
|
|
for k,v in pairs(feed_list) do
|
|
local hadNum = GoodsModel:getInstance():GetTypeGoodsNum(v[1])
|
|
local growUpNextList = self:GetChildNextGrowUpInfo() --下一级列表
|
|
if hadNum > 0 and growUpNextList then
|
|
isRedDot = true
|
|
return isRedDot
|
|
end
|
|
end
|
|
return isRedDot
|
|
end
|
|
|
|
function ChildModel:IsRedDotChildCanGet( )
|
|
-- 检查同心任务是否完成
|
|
local finish_heart_link = self:HasGetAllHeartReward( )
|
|
local has_child = self:IsPlayerHadChild()
|
|
return finish_heart_link and not has_child
|
|
end
|
|
|
|
--[[
|
|
---成长的红点分离开来给变强
|
|
function ChildModel:IsRedDotChildTrainGrow( )
|
|
|
|
local open_level = self:GetConfigChildKvVal("growth_open_lv")
|
|
local heart_link_level = self:GetChildInfo().heart_link_level or 0
|
|
local isRedDot = false
|
|
--local task_list = self:GetChildDailyTaskList()
|
|
local feed_list = self:GetChildFeedList()
|
|
if not feed_list then return end
|
|
if heart_link_level >= open_level then
|
|
for k,v in pairs(feed_list) do
|
|
local hadNum = GoodsModel:getInstance():GetTypeGoodsNum(v[1])
|
|
local growUpNextList = self:GetChildNextGrowUpInfo() --下一级列表
|
|
if hadNum > 0 and growUpNextList then
|
|
isRedDot = true
|
|
return isRedDot
|
|
end
|
|
end
|
|
end
|
|
|
|
return (isRedDot and GetModuleIsOpen(150,1))
|
|
end
|
|
--]]
|
|
|
|
-- 载具红点:有可以升级的载具
|
|
function ChildModel:IsRedDotChildVehicle( )
|
|
if not self:CheckChildFuncIsOpen() then
|
|
return false
|
|
end
|
|
local isRedDot = false
|
|
local redVehicleList = {}
|
|
local vehicleList = self:GetChildVehicleList( )
|
|
if not vehicleList then return end
|
|
for k,v in pairs(vehicleList) do
|
|
local selectList_next = self:GetConfigChildVehicleList(v.fashion_id, v.lv + 1)
|
|
if TableSize(selectList_next) > 0 then -- 是否是最高级
|
|
local upgrade_cost = stringtotable(selectList_next.upgrade_cost)
|
|
if upgrade_cost[1][1] == 0 then
|
|
local hadNum = GoodsModel:getInstance():GetTypeGoodsNum(upgrade_cost[1][2]) or 0
|
|
if hadNum >= upgrade_cost[1][3] then
|
|
isRedDot = true
|
|
return isRedDot
|
|
end
|
|
end
|
|
end
|
|
end
|
|
return isRedDot
|
|
end
|
|
|
|
|
|
function ChildModel:GetOpenSkillNearestId( )
|
|
|
|
-- skill_id = 500003
|
|
-- sequence = 3
|
|
-- skill_lv = 0
|
|
return self.skill_list_open_nearest
|
|
end
|
|
|
|
function ChildModel:IsCanUpSkill( )
|
|
local child_age_month = self:GetChildInfo().child_age_month or 0
|
|
local limit_num = self:GetConfigChildKvVal("skill_open_stage")
|
|
return (child_age_month >= limit_num )
|
|
end
|
|
|
|
function ChildModel:IsRedDotChildSkill( )
|
|
if not self:CheckChildFuncIsOpen() or not self:CheckSkillIsOpen() then
|
|
return false
|
|
end
|
|
local skillList = self:GetChildSkillList( ) --已经按sequence排序过的
|
|
local isRedDot = false
|
|
self.skill_list_open_nearest = nil --最近的为开启那个才有用
|
|
for i,v in ipairs(skillList) do
|
|
if v.skill_lv <= 0 then
|
|
self.skill_list_open_nearest = v --
|
|
break
|
|
end
|
|
end
|
|
if self:IsCanUpSkill() then
|
|
--print("============>>> YiRan:ChildModel [start:530] self.skill_list_open_nearest :",self.skill_list_open_nearest)
|
|
for k,v in pairs(skillList) do
|
|
local skill_list_next = self:GetConfigChildSkillInfo(v.skill_id,v.skill_lv+1)
|
|
if TableSize(skill_list_next) > 0 then -- 是否是最高级
|
|
local active_cost = stringtotable(skill_list_next.active_cost)
|
|
if active_cost[1][1] == 0 then
|
|
local hadNum = GoodsModel:getInstance():GetTypeGoodsNum(active_cost[1][2]) or 0
|
|
if hadNum >= active_cost[1][3] and (not self.skill_list_open_nearest or v.sequence <= self.skill_list_open_nearest.sequence)then
|
|
isRedDot = true
|
|
return isRedDot
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
return isRedDot
|
|
|
|
end
|
|
|
|
function ChildModel:IsRedDotChildFashion( )
|
|
if not self:CheckChildFuncIsOpen() or not self:CheckDressIsOpen() then
|
|
return false
|
|
end
|
|
for k,v in pairs(ChildConst.ChildDressFashionType) do
|
|
local dressList = self:GetChildDressList(v)
|
|
if dressList then
|
|
for k,v_d in pairs(dressList) do
|
|
local cost_num = stringtotable(v_d.upgrade_cost)[1][3]
|
|
local num = GoodsModel:getInstance():GetTypeGoodsNum(v_d.fashion_id)
|
|
if cost_num <= num then
|
|
if not self:IsChildFashionLvMax(v_d.fashion_id,v_d.lv) then
|
|
return true
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
return false
|
|
end
|
|
|
|
function ChildModel:GetRedDotChildHandbook( )
|
|
return self.red_dot_list_handbook
|
|
end
|
|
function ChildModel:IsRedDotChildHandbook( )
|
|
if not self:CheckChildFuncIsOpen() then
|
|
return false
|
|
end
|
|
local isRedDot = false
|
|
|
|
self.red_dot_list_handbook.active_list = {}
|
|
self.red_dot_list_handbook.suit_reward_list = {}
|
|
self.red_dot_list_handbook.is_level_up = false
|
|
self.red_dot_list_handbook.is_can_break = false
|
|
--是否有激活
|
|
|
|
local goods = GoodsModel:getInstance()
|
|
for k,v in pairs(self:GetSuitToyList()) do
|
|
if not v.isActive then --未激活且够数量激活就给红点
|
|
local num = goods:GetTypeGoodsNum(v.toy_id)
|
|
--print("============>>> YiRan:ChildModel [start:1176] num :",num,"v.toy_id:",v.toy_id)
|
|
if num > 0 then
|
|
--logWarn('=======Msh:ChildModel.lua[1559]=======')
|
|
isRedDot = true
|
|
local list = {}
|
|
list.isRedDot = true
|
|
list.toy_id = v.toy_id
|
|
list.suit_type = v.suit_type
|
|
PrintTable(list)
|
|
table.insert(self.red_dot_list_handbook.active_list,list)
|
|
end
|
|
end
|
|
end
|
|
--是否有集满套装
|
|
for k,v in pairs(self:GetChildSuitRewardList()) do
|
|
if v.status == 1 then
|
|
local list = {}
|
|
list.isRedDot = true
|
|
list.suit_type = v.suit_type
|
|
table.insert(self.red_dot_list_handbook.suit_reward_list,list)
|
|
--logWarn('=======Msh:ChildModel.lua[1576]=======')
|
|
isRedDot = true
|
|
end
|
|
end
|
|
----------是否能升级
|
|
local level = self:GetSuitToyBoxLv()
|
|
local next_cost = stringtotable(self:GetChildHandbookToyUpgradeList(level).next_cost)
|
|
--local had_num = GoodsModel:getInstance():GetTypeGoodsNum(next_cost[1][2])
|
|
local had_num = GoodsModel:getInstance():GetSpecialScore(ChildConst.HandBookCoinID)
|
|
local need_num = next_cost[1][3]
|
|
--print('Msh:ChildModel.lua[1588] had_num', had_num, need_num)
|
|
local up_grade_list_next = self:GetChildHandbookToyUpgradeList(level+1)
|
|
if TableSize(up_grade_list_next) > 0 then--非满级
|
|
if had_num >= need_num then
|
|
isRedDot = true
|
|
--logWarn('=======Msh:ChildModel.lua[1587]=======')
|
|
self.red_dot_list_handbook.is_level_up = true
|
|
end
|
|
end
|
|
--------是否可分解
|
|
|
|
local break_list = self:GetChildHandbookBreakList()
|
|
for k,v in pairs(break_list) do
|
|
if v.good_sum > 0 then
|
|
isRedDot = true
|
|
--logWarn('=======Msh:ChildModel.lua[1596]=======')
|
|
self.red_dot_list_handbook.is_can_break = true
|
|
end
|
|
end
|
|
--print("=============>>> YiRan:ChildModel [start:1204] self.red_dot_list_handbook ------------------------------------------")
|
|
--PrintTable(self.red_dot_list_handbook)
|
|
--print("=============>>> YiRan:ChildModel [end] ------------------------------------------")
|
|
return isRedDot
|
|
end
|
|
|
|
|
|
function ChildModel:IsNeedRed(id)
|
|
local isRedChildTrain = self:GetChildRedDotList()[ChildConst.TabId.ChildTrain] or false
|
|
local isRedChildVehicle = self:GetChildRedDotList()[ChildConst.TabId.ChildVehicle] or false
|
|
local isRedChildSKill = self:GetChildRedDotList()[ChildConst.TabId.ChildSkill] or false
|
|
local isRedChildFashion = self:GetChildRedDotList()[ChildConst.TabId.ChildDress] or false
|
|
local isRedChildHandbook = self:GetChildRedDotList()[ChildConst.TabId.ChildHandbook] or false
|
|
local isRedHeartLink = self:GetChildRedDotList()[ChildConst.TabId.HeartLink] or false
|
|
local isRedGetChild = self:GetChildRedDotList()[ChildConst.TabId.GetChild] or false
|
|
local isRedShowBabyReward = self:GetChildRedDotList()[ChildConst.TabId.ShowBabyReward] or false
|
|
if id == ChildConst.TabId.ChildTrain then
|
|
isRedChildTrain = self:IsRedDotChildTrain() or false
|
|
self.ChildRedDotList[id] = isRedChildTrain
|
|
elseif id == ChildConst.TabId.GetChild then
|
|
isRedGetChild = self:IsRedDotChildCanGet() or false
|
|
self.ChildRedDotList[id] = isRedGetChild
|
|
elseif id == ChildConst.TabId.ChildVehicle then
|
|
isRedChildVehicle = self:IsRedDotChildVehicle() or false
|
|
self.ChildRedDotList[id] = isRedChildVehicle
|
|
elseif id == ChildConst.TabId.ChildSkill then
|
|
isRedChildSkill = self:IsRedDotChildSkill() or false
|
|
self.ChildRedDotList[id] = isRedChildSkill
|
|
elseif id == ChildConst.TabId.ChildDress then
|
|
isRedChildFashion = self:IsRedDotChildFashion() or false
|
|
self.ChildRedDotList[id] = isRedChildFashion
|
|
elseif id == ChildConst.TabId.ChildHandbook then
|
|
isRedChildHandbook = self:IsRedDotChildHandbook() or false
|
|
self.ChildRedDotList[id] = isRedChildHandbook
|
|
elseif id == ChildConst.TabId.HeartLink then
|
|
self:UpdateHeartIconRed()
|
|
isRedHeartLink = self:GetHeartIconRed()
|
|
self.ChildRedDotList[id] = isRedHeartLink
|
|
elseif id == ChildConst.TabId.ShowBabyReward then
|
|
-- self:UpdateShowBabyRewardRed()
|
|
isRedShowBabyReward = self:GetShowBabyRewardRed() or self:GetShowBabyRankReward()
|
|
self.ChildRedDotList[id] = isRedShowBabyReward
|
|
self:Fire(ChildConst.UPDATE_RANK_REWARD_RED)
|
|
else
|
|
end
|
|
----------------------
|
|
local bool = isRedChildTrain or isRedChildVehicle or isRedChildSkill or isRedChildFashion or isRedChildHandbook or isRedHeartLink or isRedGetChild or isRedShowBabyReward
|
|
--print('=======Msh:ChildModel.lua[1801] =======', isRedChildTrain , isRedChildVehicle , isRedChildSkill , isRedChildFashion , isRedChildHandbook , isRedHeartLink , isRedGetChild , isRedShowBabyReward)
|
|
GlobalEventSystem:Fire(EventName.SHOW_FUNCTION_RED_POINT, 165, bool)
|
|
end
|
|
|
|
function ChildModel:GetChildRedDotList()
|
|
return self.ChildRedDotList
|
|
end
|
|
|
|
--货币道具id
|
|
function ChildModel:GetChildCoinId()
|
|
local cost_list = stringtotable(self.Config_Child_ToyUpgrade[1].next_cost)
|
|
return cost_list[1][2]
|
|
end
|
|
----------红点逻辑-end-----------
|
|
|
|
-- 获取在宝宝副本内,玩家的宝宝形象
|
|
function ChildModel:GetBabyDunMainRoleBabyClothId( )
|
|
local cloth_id = nil
|
|
-- 考虑到玩家没有激活宝宝的情况,这里需要追加随机一个性别
|
|
local child_sex = self.childInfo.child_sex ~= 0 and self.childInfo.child_sex or math.random(1, 2)
|
|
local child_age_month = self.childInfo.child_age_month or 0
|
|
local figure_size = TableSize(self.Config_Child_Figure[child_sex])
|
|
-- 如果宝宝的阶段低于最终阶段,则使用配置的最终阶段模型,否则使用玩家当前的宝宝形象
|
|
if child_age_month < self.Config_Child_Figure[child_sex][figure_size].grow_up_level then
|
|
cloth_id = ChildConst.BabyDunClothID[child_sex]
|
|
else
|
|
cloth_id = self:GetChildCloth()
|
|
end
|
|
|
|
return cloth_id
|
|
end
|
|
|
|
-- 是否已经开启宝宝的各种功能
|
|
function ChildModel:CheckChildFuncIsOpen( )
|
|
-- 等级是否够
|
|
-- 是否完成宝宝前置(同心任务)
|
|
if RoleManager.Instance.mainRoleInfo.level < Config.Moduleid[165].open_lv or
|
|
not self:HasGetAllHeartReward()
|
|
then
|
|
return false
|
|
end
|
|
return true
|
|
end
|
|
|
|
-- 获得宝宝当前成长状态(自己)
|
|
function ChildModel:GetChildCurState( )
|
|
local child_info = self:GetChildInfo()
|
|
local age_month = child_info.child_age_month and child_info.child_age_month or 0
|
|
return self:GetChildStateByAge( age_month )
|
|
end
|
|
|
|
-- 传入岁数获取宝宝状态
|
|
function ChildModel:GetChildStateByAge( age_month )
|
|
local age_month = age_month or 0
|
|
if age_month >= self:GetChildMaxGrowState( ) then -- 成熟
|
|
return ChildConst.BABY_STATE.YOUNG
|
|
elseif age_month < self.child_grow_level then -- 襁褓
|
|
return ChildConst.BABY_STATE.BABY
|
|
else -- 爬行
|
|
return ChildConst.BABY_STATE.CHILD
|
|
end
|
|
end
|
|
|
|
-- 获取宝宝默认状态
|
|
function ChildModel:GetBaseChildModelID( state, child_sex )
|
|
return ChildConst.BaseModelID[state or 1][child_sex or 1] or 1021
|
|
end
|
|
|
|
-- 判断当前坐骑是否可以穿戴
|
|
function ChildModel:CanUseTargetVehicle( vehicle_id, age_month )
|
|
local cur_state = false
|
|
if age_month then
|
|
cur_state = self:GetChildStateByAge( age_month )
|
|
else
|
|
cur_state = self:GetChildCurState()
|
|
end
|
|
local can_on_age = Config.Childvehicle[vehicle_id .. "@" .. 1].can_on_age
|
|
|
|
return can_on_age and cur_state and cur_state >= can_on_age
|
|
end
|
|
|
|
----------宝宝晒娃奖励红点-start---------
|
|
-- -- 更新每日排行和每日分享红点
|
|
-- function ChildModel:UpdateShowBabyRewardRed( )
|
|
|
|
-- end
|
|
|
|
-- 每日分享红点
|
|
function ChildModel:GetShowBabyRewardRed( )
|
|
if not self:CheckChildFuncIsOpen() then
|
|
return false
|
|
end
|
|
local childList = self:GetChildInfo()
|
|
return childList.share_reward ~= 2
|
|
end
|
|
|
|
-- 每日排行红点
|
|
function ChildModel:GetShowBabyRankReward( )
|
|
if not self:CheckChildFuncIsOpen() then
|
|
return false
|
|
end
|
|
local childList = self:GetChildInfo()
|
|
return childList.yest_reward == 1
|
|
end
|
|
----------宝宝晒娃奖励红点-end-----------
|
|
|
|
----------频道晒娃-start---------
|
|
function ChildModel:SetShowBabyStr( str, need_name )
|
|
-- if need_name then
|
|
-- local childList = self:GetChildInfo()
|
|
-- local child_name = childList.child_name
|
|
-- self.show_baby_str_cache = string.format(str, HtmlColorTxt( child_name, ColorUtil.BLUE_DARK))
|
|
-- else
|
|
self.show_baby_str_cache = str
|
|
-- end
|
|
end
|
|
|
|
function ChildModel:GetShowBabyStr()
|
|
return self.show_baby_str_cache or ""
|
|
end
|
|
----------频道晒娃-end-----------
|