1031 lines
38 KiB
Lua
1031 lines
38 KiB
Lua
|
------------------------------------------------
|
|||
|
--作者: dhq
|
|||
|
--日期: 2019-05-5
|
|||
|
--文件: MarriageSystem.lua
|
|||
|
--模块: MarriageSystem
|
|||
|
--描述: 婚姻系统
|
|||
|
------------------------------------------------
|
|||
|
local L_TimeUtils = CS.Thousandto.Core.Base.TimeUtils;
|
|||
|
local L_SpouseData = require("Logic.Marriage.SpouseData")
|
|||
|
local L_MarriageEnum = require("Logic.Marriage.MarriageEnum")
|
|||
|
local RedPointItemCondition = CS.Thousandto.Code.Logic.RedPointItemCondition
|
|||
|
|
|||
|
--//模块定义
|
|||
|
local MarriageSystem =
|
|||
|
{
|
|||
|
--伴侣的数据
|
|||
|
SpouseData = nil,
|
|||
|
--婚宴预约的数据
|
|||
|
WeddingDataList = nil,
|
|||
|
--预约的状态
|
|||
|
BanquetTimeDict = nil,
|
|||
|
--已结婚了的婚宴类型
|
|||
|
BanquetTypeList = nil,
|
|||
|
--邀请了的宾客成员列表
|
|||
|
InviteMembersDict = nil,
|
|||
|
--索要请帖的成员列表
|
|||
|
DemandMembersDict = nil,
|
|||
|
--结婚的天数
|
|||
|
MarryDay = 0,
|
|||
|
--亲密度
|
|||
|
Intimacy = 0,
|
|||
|
--婚宴次数
|
|||
|
WeddingNum = 0,
|
|||
|
--已购买的邀请次数
|
|||
|
InvitedBuyNum = 0,
|
|||
|
--申诉离婚人的ID [申述人ID Id为0可以申述 Id为自己已经申述 id不等于自己就是确认协商离婚]
|
|||
|
AppealPlayerID = 0,
|
|||
|
--当前选择的婚宴类型
|
|||
|
CurMarriageType = L_MarriageEnum.MarryTypeEnum.Normal,
|
|||
|
--秒
|
|||
|
MapCopyTime = 900,
|
|||
|
--婚姻副本ID
|
|||
|
MarryCopyID = 3001,
|
|||
|
--情缘副本的Id
|
|||
|
MarryQingYuanCopyID = 110001,
|
|||
|
--心锁等级
|
|||
|
HeartLockLv = 0,
|
|||
|
--心锁经验
|
|||
|
HeartLockExp = 0,
|
|||
|
--仙匣数据
|
|||
|
MarryBoxDataDict = nil,
|
|||
|
--仙娃的数据
|
|||
|
MarryChildDataDict = nil,
|
|||
|
--情缘试炼界面需要的数据
|
|||
|
QingYuanCloneData = nil,
|
|||
|
--仙娃激活或者升级的物品ID
|
|||
|
ChildActiveOrUpgradeID = nil,
|
|||
|
ItemChangeEvent = nil,
|
|||
|
--玩法介绍界面状态数据 [ID,States]
|
|||
|
MarryTaskStatesDict = nil,
|
|||
|
IsShowMarryTaskForm = false,
|
|||
|
|
|||
|
--缓存的世界祝福列表
|
|||
|
CacheWorldZhuFuList = nil,
|
|||
|
|
|||
|
--当前婚宴状态,0没有婚宴,1等待开启,2已经开启
|
|||
|
CurHunYanState = 0,
|
|||
|
CurHunYanRemainTime = 0,
|
|||
|
CurHunYanData = nil,
|
|||
|
}
|
|||
|
|
|||
|
--//成员函数定义
|
|||
|
--初始化
|
|||
|
function MarriageSystem:Initialize()
|
|||
|
self.WeddingDataList = List:New()
|
|||
|
self.BanquetTimeDict = Dictionary:New()
|
|||
|
self.InviteMembersDict = Dictionary:New()
|
|||
|
self.DemandMembersDict = Dictionary:New()
|
|||
|
self.SpouseData = L_SpouseData:New()
|
|||
|
self.MarryBoxDataDict = Dictionary:New()
|
|||
|
self.MarryChildDataDict = Dictionary:New()
|
|||
|
self.ChildActiveOrUpgradeID = List:New()
|
|||
|
self.MarryTaskStatesDict = Dictionary:New()
|
|||
|
self.MapCopyTime = tonumber(DataConfig.DataCloneMap[self.MarryCopyID].ExistTime) / 1000
|
|||
|
self:InitChildData()
|
|||
|
self.ItemChangeEvent = Utils.Handler(self.OnItemUpdate, self)
|
|||
|
GameCenter.RegFixEventHandle(LogicEventDefine.EVENT_ITEM_CHANGE_UPDATE, self.ItemChangeEvent)
|
|||
|
end
|
|||
|
|
|||
|
--反初始化
|
|||
|
function MarriageSystem:UnInitialize()
|
|||
|
self.WeddingDataList:Clear()
|
|||
|
self.BanquetTimeDict:Clear()
|
|||
|
self.MarryBoxDataDict:Clear()
|
|||
|
self.InviteMembersDict:Clear()
|
|||
|
self.DemandMembersDict:Clear()
|
|||
|
self.MarryChildDataDict:Clear()
|
|||
|
self.ChildActiveOrUpgradeID:Clear()
|
|||
|
self.MarryTaskStatesDict:Clear()
|
|||
|
GameCenter.UnRegFixEventHandle(LogicEventDefine.EVENT_ITEM_CHANGE_UPDATE, self.ItemChangeEvent)
|
|||
|
end
|
|||
|
|
|||
|
function MarriageSystem:OnItemUpdate(itemID,sender)
|
|||
|
if self.ChildActiveOrUpgradeID:Contains(itemID) then
|
|||
|
self:SetChildRedPoint()
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
--初始化仙娃的数据
|
|||
|
function MarriageSystem:InitChildData()
|
|||
|
DataConfig.DataMarryChild:Foreach(
|
|||
|
function(_curChildId, _cfg)
|
|||
|
local _attrLevelDict = Dictionary:New()
|
|||
|
DataConfig.DataMarryChildAtt:ForeachCanBreak(
|
|||
|
function(_id, _attrCfg)
|
|||
|
--根据主表取属性表的数据
|
|||
|
if _curChildId == _attrCfg.ChildId then
|
|||
|
_attrLevelDict:Add(_attrCfg.Level, _attrCfg)
|
|||
|
end
|
|||
|
end
|
|||
|
)
|
|||
|
local _childData = {
|
|||
|
SData = nil,
|
|||
|
CfgData = _cfg,
|
|||
|
AttrDict = _attrLevelDict
|
|||
|
}
|
|||
|
if not self.MarryChildDataDict:ContainsKey(_curChildId) then
|
|||
|
self.MarryChildDataDict:Add(_curChildId, _childData)
|
|||
|
end
|
|||
|
end
|
|||
|
)
|
|||
|
--初始化玩法介绍的状态数据
|
|||
|
DataConfig.DataMarryShow:Foreach(
|
|||
|
function(_key, _cfg)
|
|||
|
if not self.MarryTaskStatesDict:ContainsKey(_key) then
|
|||
|
self.MarryTaskStatesDict:Add(_key, RewardState.None)
|
|||
|
else
|
|||
|
self.MarryTaskStatesDict[_key] = RewardState.None
|
|||
|
end
|
|||
|
end
|
|||
|
)
|
|||
|
end
|
|||
|
|
|||
|
--更新心跳
|
|||
|
function MarriageSystem:Update(dt)
|
|||
|
self:SetBanquetTime()
|
|||
|
|
|||
|
if self.CacheWorldZhuFuList ~= nil then
|
|||
|
if self.WorldZhuFuUIId == nil then
|
|||
|
self.WorldZhuFuUIId = GameCenter.FormStateSystem:EventIDToFormID(UILuaEventDefine.UIMarryWorldZhuFuForm_OPEN)
|
|||
|
end
|
|||
|
if not GameCenter.FormStateSystem:FormIsOpen(self.WorldZhuFuUIId) then
|
|||
|
local _msg = self.CacheWorldZhuFuList[1]
|
|||
|
self.CacheWorldZhuFuList:RemoveAt(1)
|
|||
|
if #self.CacheWorldZhuFuList <= 0 then
|
|||
|
self.CacheWorldZhuFuList = nil
|
|||
|
end
|
|||
|
GameCenter.PushFixEvent(UILuaEventDefine.UIMarryWorldZhuFuForm_OPEN, _msg)
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
--刷新主界面婚宴按钮的时间显示
|
|||
|
function MarriageSystem:SetBanquetTime()
|
|||
|
if #self.WeddingDataList > 0 then
|
|||
|
local _firstWed = self.WeddingDataList[1]
|
|||
|
local _startTime = _firstWed.timeStart * 60
|
|||
|
local _endTime = _startTime + self.MapCopyTime
|
|||
|
local _serverTime = GameCenter.HeartSystem.ServerTime
|
|||
|
if _serverTime < _startTime and (_startTime - _serverTime) > 1800 then
|
|||
|
--超过30分钟,不做显示
|
|||
|
self.CurHunYanState = 0
|
|||
|
self.CurHunYanData = nil
|
|||
|
elseif _serverTime < _startTime then
|
|||
|
--等待开启
|
|||
|
self.CurHunYanState = 1
|
|||
|
self.CurHunYanRemainTime = _startTime - _serverTime
|
|||
|
self.CurHunYanData = _firstWed
|
|||
|
elseif _serverTime >= _startTime and _serverTime < _endTime then
|
|||
|
--已经开启
|
|||
|
self.CurHunYanState = 2
|
|||
|
self.CurHunYanRemainTime = _endTime - _serverTime
|
|||
|
self.CurHunYanData = _firstWed
|
|||
|
else
|
|||
|
--已经结束,直接移除
|
|||
|
self.WeddingDataList:RemoveAt(1)
|
|||
|
self.CurHunYanState = 0
|
|||
|
self.CurHunYanData = nil
|
|||
|
end
|
|||
|
else
|
|||
|
--没有婚宴
|
|||
|
self.CurHunYanState = 0
|
|||
|
self.CurHunYanData = nil
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
--上线返回需要的数据
|
|||
|
function MarriageSystem:ResMarryOnline(msg)
|
|||
|
self.WeddingDataList:Clear()
|
|||
|
--预约的数据
|
|||
|
local _weddingDataList = msg.weddingDataList
|
|||
|
if _weddingDataList ~= nil then
|
|||
|
for i = 1, #_weddingDataList do
|
|||
|
local _curData = _weddingDataList[i]
|
|||
|
self.WeddingDataList:Add(_curData)
|
|||
|
end
|
|||
|
if #self.WeddingDataList > 0 then
|
|||
|
--根据时间排个序
|
|||
|
self.WeddingDataList:Sort(
|
|||
|
function(a, b)
|
|||
|
return a.timeStart < b.timeStart
|
|||
|
end
|
|||
|
)
|
|||
|
end
|
|||
|
end
|
|||
|
--索要请帖的列表
|
|||
|
local _weddingMembersList = msg.weddingMembersList
|
|||
|
if _weddingMembersList ~= nil then
|
|||
|
for i = 1, #_weddingMembersList do
|
|||
|
local _curMember = _weddingMembersList[i]
|
|||
|
if not self.DemandMembersDict:ContainsKey(_curMember.roleId) then
|
|||
|
self.DemandMembersDict:Add(_curMember.roleId, _curMember.name)
|
|||
|
else
|
|||
|
self.DemandMembersDict[_curMember.roleId] = _curMember.name
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
--设置心锁的红点
|
|||
|
self:SetHeartLockRedPoint()
|
|||
|
--设置仙娃的红点
|
|||
|
self:SetChildRedPoint()
|
|||
|
|
|||
|
--请求婚姻数据,获取对方的信息
|
|||
|
local _msg = ReqMsg.MSG_Marriage.ReqMarryData:New()
|
|||
|
_msg:Send()
|
|||
|
end
|
|||
|
|
|||
|
--婚姻开启通知
|
|||
|
function MarriageSystem:ResWeddingStart(msg)
|
|||
|
--打开副本进入界面
|
|||
|
GameCenter.MainFunctionSystem:DoFunctionCallBack(FunctionStartIdCode.MarryBanquet)
|
|||
|
end
|
|||
|
|
|||
|
function MarriageSystem:GetBanquetTimeDict()
|
|||
|
--已预约的数据
|
|||
|
local _dict = Dictionary:New()
|
|||
|
local _offsetTime = GameCenter.HeartSystem.ServerZoneOffset
|
|||
|
for i = 1, #self.WeddingDataList do
|
|||
|
local _banquetTime = self.WeddingDataList[i].timeStart * 60 + _offsetTime
|
|||
|
_dict:Add(_banquetTime, self.WeddingDataList[i])
|
|||
|
end
|
|||
|
|
|||
|
--当前服务器带时区的时间
|
|||
|
local _serverTime = math.floor(GameCenter.HeartSystem.ServerZoneTime)
|
|||
|
--计算当前时间的时分秒
|
|||
|
local _hour, _min, _sec = L_TimeUtils.GetStampTimeHHMMSSNotZone(_serverTime)
|
|||
|
--今天开始的时间
|
|||
|
local _todayStartTime = _serverTime - _hour * 3600 - _min * 60 - _sec
|
|||
|
|
|||
|
DataConfig.DataMarryOrder:Foreach(
|
|||
|
function(k, v)
|
|||
|
--1:已过期 2:已预约 3:可预约
|
|||
|
local _states = 0
|
|||
|
--每个的开启时间
|
|||
|
local _cfgStartTime = math.floor(_todayStartTime + v.Time * 60)
|
|||
|
--看是否预约过
|
|||
|
if _dict:ContainsKey(_cfgStartTime) then
|
|||
|
_states = 2
|
|||
|
else
|
|||
|
--过期了
|
|||
|
if _serverTime > _cfgStartTime then
|
|||
|
_states = 1
|
|||
|
else
|
|||
|
_states = 3
|
|||
|
end
|
|||
|
end
|
|||
|
if not self.BanquetTimeDict:ContainsKey(k) then
|
|||
|
self.BanquetTimeDict:Add(k, _states)
|
|||
|
else
|
|||
|
self.BanquetTimeDict[k] = _states
|
|||
|
end
|
|||
|
end
|
|||
|
)
|
|||
|
return self.BanquetTimeDict
|
|||
|
end
|
|||
|
|
|||
|
--返回求婚信息
|
|||
|
function MarriageSystem:ResMarryPropose(msg)
|
|||
|
--求婚者角色名
|
|||
|
local _name = msg.name
|
|||
|
--求婚者职业
|
|||
|
local _career = msg.career
|
|||
|
--求婚类型
|
|||
|
local _type = msg.type
|
|||
|
--求婚者id
|
|||
|
local _marrayId = msg.marrayId
|
|||
|
--打开同意界面
|
|||
|
GameCenter.PushFixEvent(UILuaEventDefine.UIMarryPromiseForm_OPEN, {marrayId = _marrayId, name = _name})
|
|||
|
end
|
|||
|
|
|||
|
--返回求婚结果信息
|
|||
|
function MarriageSystem:ResDealMarryPropose(msg)
|
|||
|
--这里需要再请求下婚姻的数据,主要是拿预约的次数
|
|||
|
local _msg = ReqMsg.MSG_Marriage.ReqMarryData:New()
|
|||
|
_msg:Send()
|
|||
|
--更新配偶信息
|
|||
|
local _lp = GameCenter.GameSceneSystem:GetLocalPlayer()
|
|||
|
--先和自己名字对比下,看是否是自己求婚
|
|||
|
if _lp.Name ~= msg.marrayName then
|
|||
|
self.SpouseData.Name = msg.marrayName
|
|||
|
self.SpouseData.Career = msg.marraycareer
|
|||
|
else
|
|||
|
self.SpouseData.Name = msg.bemarrayName
|
|||
|
self.SpouseData.Career = msg.bemarraycareer
|
|||
|
end
|
|||
|
_lp:SetSpouseName(self.SpouseData.Name)
|
|||
|
self:CheckMarryCopyRedPoint()
|
|||
|
--打开缔结姻缘的界面(准备跳转到预约界面)
|
|||
|
GameCenter.MainFunctionSystem:DoFunctionCallBack(FunctionStartIdCode.MarryEngagement, 2)
|
|||
|
end
|
|||
|
|
|||
|
--返回预约结果
|
|||
|
function MarriageSystem:ResSelectWedding(msg)
|
|||
|
--0成功 1:已经预约 2: 被别人预约了 3: 时间过期(1, 2 , 3失败)
|
|||
|
local _code = msg.res
|
|||
|
--预约成功
|
|||
|
if _code == 0 then
|
|||
|
if self.WeddingNum > 0 then
|
|||
|
self.WeddingNum = self.WeddingNum - 1
|
|||
|
end
|
|||
|
Utils.ShowPromptByEnum("C_MARRY_YUYUE_SUCC")
|
|||
|
local _cfg = DataConfig.DataMarryOrder[msg.weddingId]
|
|||
|
local _sHour = _cfg.Time // 60
|
|||
|
local _sMin = _cfg.Time % 60
|
|||
|
local _eHour = _cfg.EndTime // 60
|
|||
|
local _eMin = _cfg.EndTime % 60
|
|||
|
local _timeText = string.format("%0.2d:%0.2d - %0.2d:%0.2d", _sHour, _sMin, _eHour, _eMin)
|
|||
|
local _askText = UIUtils.CSFormat(DataConfig.DataMessageString.Get("C_MARRY_AUTO_YAOQING_ASK"), self.SpouseData.Name, _timeText)
|
|||
|
GameCenter.MsgPromptSystem:ShowMsgBox(_askText,
|
|||
|
DataConfig.DataMessageString.Get("C_MSGBOX_CANCEL"),
|
|||
|
DataConfig.DataMessageString.Get("C_MSGBOX_OK"),
|
|||
|
function (code)
|
|||
|
--同意
|
|||
|
if (code == MsgBoxResultCode.Button2) then
|
|||
|
local _msg = ReqMsg.MSG_Marriage.ReqInvit:New()
|
|||
|
_msg.roleId = 0
|
|||
|
_msg.type = 0
|
|||
|
_msg:Send()
|
|||
|
Utils.ShowPromptByEnum("C_MARRY_AUTO_YUYUE_RESULT")
|
|||
|
end
|
|||
|
end,
|
|||
|
false,
|
|||
|
false, 15, 4, 1, nil, nil, 0, true)
|
|||
|
--已经预约
|
|||
|
elseif _code == 1 then
|
|||
|
Utils.ShowPromptByEnum("C_MARRY_YUYUE_ALREADY")
|
|||
|
--被别人预约了
|
|||
|
elseif _code == 2 then
|
|||
|
Utils.ShowPromptByEnum("C_MARRY_YUYUE_OTHERALREADY")
|
|||
|
--时间过期(1, 2 , 3失败)
|
|||
|
elseif _code == 3 then
|
|||
|
Utils.ShowPromptByEnum("C_MARRY_YUYUE_TIMEOUT")
|
|||
|
end
|
|||
|
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_MARRY_WEDDING_DATA_REFRESH)
|
|||
|
end
|
|||
|
|
|||
|
--返回婚姻信息
|
|||
|
function MarriageSystem:ResMarryData(msg)
|
|||
|
--结婚天数
|
|||
|
self.MarryDay = msg.marryDay
|
|||
|
--婚宴次数
|
|||
|
if msg.weddingNum > 0 then
|
|||
|
self.WeddingNum = msg.weddingNum
|
|||
|
end
|
|||
|
--已结婚了的婚宴类型
|
|||
|
self.BanquetTypeList = List:New(msg.tList)
|
|||
|
if self.BanquetTypeList ~= nil and #self.BanquetTypeList > 0 then
|
|||
|
--排个序,获取最大的那个类型
|
|||
|
self.BanquetTypeList:Sort(
|
|||
|
function(a, b)
|
|||
|
return a > b
|
|||
|
end
|
|||
|
)
|
|||
|
self.CurMarriageType = self.BanquetTypeList[1]
|
|||
|
end
|
|||
|
--申述人ID Id为0可以申述 Id为自己已经申述 id不等于自己就是确认协商离婚
|
|||
|
self.AppealPlayerID = msg.divorceId
|
|||
|
--配偶的数据信息
|
|||
|
self.SpouseData:RefeshData(msg)
|
|||
|
local _lp = GameCenter.GameSceneSystem:GetLocalPlayer()
|
|||
|
if _lp ~= nil then
|
|||
|
_lp:SetSpouseName(self.SpouseData.Name)
|
|||
|
end
|
|||
|
self.SpouseData.PlayerID = msg.playerId
|
|||
|
--亲密度
|
|||
|
if msg.intimacy ~= nil and msg.intimacy > 0 then
|
|||
|
self.Intimacy = msg.intimacy
|
|||
|
else
|
|||
|
if msg.playerId ~= nil and msg.playerId > 0 then
|
|||
|
local _friendData = GameCenter.FriendSystem:GetFriendInfo(FriendType.Friend, msg.playerId)
|
|||
|
if _friendData ~= nil then
|
|||
|
self.Intimacy = _friendData.intimacy
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
--已购买的邀请次数
|
|||
|
if msg.purNum ~= nil and msg.purNum > 0 then
|
|||
|
self.InvitedBuyNum = msg.purNum
|
|||
|
end
|
|||
|
--邀请了的好友列表
|
|||
|
self.InviteMembersDict:Clear()
|
|||
|
local _weddingMembersList = msg.weddingMembersList
|
|||
|
if _weddingMembersList ~= nil then
|
|||
|
for i = 1, #_weddingMembersList do
|
|||
|
local _curMember = _weddingMembersList[i]
|
|||
|
if not self.InviteMembersDict:ContainsKey(_curMember.roleId) then
|
|||
|
self.InviteMembersDict:Add(_curMember.roleId, _curMember.name)
|
|||
|
else
|
|||
|
self.InviteMembersDict[_curMember.roleId] = _curMember.name
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
self:CheckMarryCopyRedPoint()
|
|||
|
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_MARRY_INFO_REFRESH)
|
|||
|
--刷新婚宴的信息
|
|||
|
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_MARRY_WEDDING_DATA_REFRESH)
|
|||
|
--刷新邀请的人数
|
|||
|
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_MARRY_INVITED_FRIEND_UPDATE)
|
|||
|
--刷新称号
|
|||
|
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_TITLE_REFRESH_MARRIAGE_USE)
|
|||
|
end
|
|||
|
|
|||
|
--更新婚宴的数据
|
|||
|
function MarriageSystem:ResUpdateWedding(msg)
|
|||
|
local _count = #self.WeddingDataList
|
|||
|
local _index = 0
|
|||
|
if _count > 0 and msg.weddingData ~= nil then
|
|||
|
local _hasSameData = false
|
|||
|
for i = 1, _count do
|
|||
|
if msg.weddingData.timeStart == self.WeddingDataList[i].timeStart then
|
|||
|
self.WeddingDataList[i] = msg.weddingData
|
|||
|
_hasSameData = true
|
|||
|
_index = i
|
|||
|
break
|
|||
|
end
|
|||
|
end
|
|||
|
if not _hasSameData then
|
|||
|
self.WeddingDataList:Add(msg.weddingData)
|
|||
|
else
|
|||
|
self.WeddingDataList[_index] = msg.weddingData
|
|||
|
end
|
|||
|
else
|
|||
|
self.WeddingDataList:Add(msg.weddingData)
|
|||
|
end
|
|||
|
self.WeddingDataList:Sort(
|
|||
|
function(a, b)
|
|||
|
return a.timeStart < b.timeStart
|
|||
|
end
|
|||
|
)
|
|||
|
end
|
|||
|
|
|||
|
--离婚成功
|
|||
|
function MarriageSystem:ResDivorce(msg)
|
|||
|
local _lp = GameCenter.GameSceneSystem:GetLocalPlayer()
|
|||
|
Utils.ShowPromptByEnum("Divorce_Success_Mail", _lp.Name, self.SpouseData.Name)
|
|||
|
self.SpouseData:ClearData()
|
|||
|
self.Intimacy = 0
|
|||
|
self.MarryDay = 0
|
|||
|
self.MarryBoxData = nil
|
|||
|
self:CheckMarryCopyRedPoint()
|
|||
|
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_MARRY_INFO_REFRESH)
|
|||
|
end
|
|||
|
|
|||
|
--申述成功
|
|||
|
function MarriageSystem:ResDivorceID(msg)
|
|||
|
--申诉离婚人的ID
|
|||
|
local _lpID = GameCenter.GameSceneSystem:GetLocalPlayerID()
|
|||
|
--Id为自己已经申述 id不等于自己就是确认协商离婚
|
|||
|
if msg.roleId ~= _lpID then
|
|||
|
--给个倒计时,倒计时结束关掉MsgBox
|
|||
|
GameCenter.MsgPromptSystem:ShowMsgBox( DataConfig.DataMessageString.Get("C_MARRY_Divorce_Shensu_TIPS"),
|
|||
|
DataConfig.DataMessageString.Get("TEAM_REFUSE"),
|
|||
|
DataConfig.DataMessageString.Get("C_MSGBOX_OK"),
|
|||
|
function (code)
|
|||
|
--同意离婚
|
|||
|
if (code == MsgBoxResultCode.Button2) then
|
|||
|
local _msg = ReqMsg.MSG_Marriage.ReqAffirmDivorce:New()
|
|||
|
--0 拒绝 1 同意
|
|||
|
_msg.opt = 1
|
|||
|
_msg:Send()
|
|||
|
--拒绝离婚
|
|||
|
else
|
|||
|
local _msg = ReqMsg.MSG_Marriage.ReqAffirmDivorce:New()
|
|||
|
--0 拒绝 1 同意
|
|||
|
_msg.opt = 0
|
|||
|
_msg:Send()
|
|||
|
end
|
|||
|
end,
|
|||
|
false,
|
|||
|
true,
|
|||
|
tonumber(DataConfig.DataGlobal[1891].Params)
|
|||
|
)
|
|||
|
else
|
|||
|
--是申诉离婚的情况,弹提示说申诉成功
|
|||
|
Utils.ShowPromptByEnum("Marry_Divorce_Appl_Success")
|
|||
|
end
|
|||
|
self.AppealPlayerID = msg.roleId
|
|||
|
end
|
|||
|
|
|||
|
--删除索要列表
|
|||
|
function MarriageSystem:ResDeleteDemandInvit(msg)
|
|||
|
local _playerId = msg.roleId
|
|||
|
if self.InviteMembersDict:ContainsKey(_playerId) then
|
|||
|
self.InviteMembersDict:Remove(_playerId)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
--更新邀请列表
|
|||
|
function MarriageSystem:ResUpdateInvit(msg)
|
|||
|
if msg.memberList == nil then
|
|||
|
return
|
|||
|
end
|
|||
|
for i = 1, #msg.memberList do
|
|||
|
local _mem = msg.memberList[i]
|
|||
|
if _mem ~= nil then
|
|||
|
self.InviteMembersDict[_mem.roleId] = _mem.name
|
|||
|
end
|
|||
|
end
|
|||
|
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_MARRY_INVITED_FRIEND_UPDATE)
|
|||
|
end
|
|||
|
|
|||
|
--返回索要结果
|
|||
|
function MarriageSystem:ResDemandInvit(msg)
|
|||
|
--0成功 1婚宴不存在 2已经在索要列表中 3已经在邀请列表中 4邀请上限
|
|||
|
local _code = msg.res
|
|||
|
if _code == 0 then
|
|||
|
Utils.ShowPromptByEnum("Marry_Ask_Invitation_Card")
|
|||
|
elseif _code == 1 then
|
|||
|
--"婚宴已不存在"
|
|||
|
Utils.ShowPromptByEnum("Marry_DemandInvit_Dinner_NotFound")
|
|||
|
elseif _code == 2 then
|
|||
|
--"已在请帖索要列表中"
|
|||
|
Utils.ShowPromptByEnum("Marry_Ask_Invitation_Card")
|
|||
|
elseif _code == 3 then
|
|||
|
--已经在邀请列表中
|
|||
|
Utils.ShowPromptByEnum("Marry_DemandInvit_InVited")
|
|||
|
elseif _code == 4 then
|
|||
|
--已达到宾客的邀请上限
|
|||
|
Utils.ShowPromptByEnum("Marry_DemandInvit_NumMax")
|
|||
|
elseif _code == 5 then
|
|||
|
--不能要自己索要请帖
|
|||
|
Utils.ShowPromptByEnum("Marry_DemandInvit_CannotBySelf")
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
--如果新婚人在线通知索要人名单
|
|||
|
function MarriageSystem:ResUpdateDemandInvit(msg)
|
|||
|
local _mem = msg.member
|
|||
|
--这里需要做红点
|
|||
|
if _mem ~= nil then
|
|||
|
if not self.DemandMembersDict:ContainsKey(_mem.roleId) then
|
|||
|
self.DemandMembersDict:Add(_mem.roleId, _mem.name)
|
|||
|
else
|
|||
|
self.DemandMembersDict[_mem.roleId] = _mem.name
|
|||
|
end
|
|||
|
--主界面显示宾客按钮
|
|||
|
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_MAIN_SHOW_BINGKE)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
--购买邀请人数成功
|
|||
|
function MarriageSystem:ResPurInvitNum(msg)
|
|||
|
self.InvitedBuyNum = self.InvitedBuyNum + 1
|
|||
|
--刷新界面的数据
|
|||
|
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_MARRY_ADD_INVITE_NUM_SUCCESS)
|
|||
|
end
|
|||
|
|
|||
|
--心锁升级
|
|||
|
function MarriageSystem:ResUpgradeMarryLockInfo(msg)
|
|||
|
if msg.level ~= nil and msg.level > 0 then
|
|||
|
self.HeartLockLv = msg.level
|
|||
|
end
|
|||
|
if msg.exp ~= nil and msg.exp >= 0 then
|
|||
|
self.HeartLockExp = msg.exp
|
|||
|
end
|
|||
|
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_REFRESH_MARRY_HEARTLOCK_FORM)
|
|||
|
self:SetHeartLockRedPoint()
|
|||
|
self:SetChildRedPoint()
|
|||
|
end
|
|||
|
|
|||
|
--伴侣购买了仙匣
|
|||
|
function MarriageSystem:ResMarryBox(msg)
|
|||
|
if msg ~= nil and msg.box ~= nil then
|
|||
|
local _boxList = msg.box
|
|||
|
local _lpID = GameCenter.GameSceneSystem:GetLocalPlayerID()
|
|||
|
for i = 1, #_boxList do
|
|||
|
local _boxData = _boxList[i]
|
|||
|
local _roleId = _boxData.role
|
|||
|
if not self.MarryBoxDataDict:ContainsKey(_roleId) then
|
|||
|
self.MarryBoxDataDict:Add(_roleId, _boxData)
|
|||
|
else
|
|||
|
self.MarryBoxDataDict[_roleId] = _boxData
|
|||
|
end
|
|||
|
if _lpID == _roleId then
|
|||
|
local _isReceiveToday = _boxData.reward == 1
|
|||
|
local _isBuyForPartner = _boxData.onceReward == 1
|
|||
|
local _showRedPoint = (not _isBuyForPartner and _boxData.remainTime > 0) or (not _isReceiveToday and _boxData.remainTime > 0)
|
|||
|
GameCenter.MainFunctionSystem:SetAlertFlag(FunctionStartIdCode.MarryBox, _showRedPoint)
|
|||
|
end
|
|||
|
end
|
|||
|
--刷新仙匣界面的数据
|
|||
|
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_MARRY_BOX_REFRESH)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
--伴侣求购仙匣
|
|||
|
function MarriageSystem:ResCallBuyMarryBox(msg)
|
|||
|
local _costCfg = Utils.SplitStr(DataConfig.DataGlobal[1522].Params, '_');
|
|||
|
local _costText = UIUtils.CSFormat("{0}{1}", tonumber(_costCfg[2]), DataConfig.DataItem[tonumber(_costCfg[1])].Name)
|
|||
|
Utils.ShowMsgBox(function (code)
|
|||
|
if (code == MsgBoxResultCode.Button2) then
|
|||
|
--购买
|
|||
|
local _msg = ReqMsg.MSG_Marriage.ReqBuyMarryBox:New()
|
|||
|
_msg:Send()
|
|||
|
else
|
|||
|
--拒绝
|
|||
|
local _msg = ReqMsg.MSG_Marriage.ReqRefuseBuyMarryBox:New()
|
|||
|
_msg:Send()
|
|||
|
end
|
|||
|
end, "MARRY_BOX_BUY_DES", _costText, self.SpouseData.Name)
|
|||
|
end
|
|||
|
|
|||
|
--同步仙娃信息
|
|||
|
function MarriageSystem:ResMarryChildInfo(msg)
|
|||
|
if msg.childs ~= nil then
|
|||
|
local _childsList = msg.childs
|
|||
|
local _childCount = self.MarryChildDataDict:Count()
|
|||
|
--是否是仙娃升级的消息
|
|||
|
local _isChildLevelUp = 0
|
|||
|
for i = 1, #_childsList do
|
|||
|
local _childSData = _childsList[i]
|
|||
|
local _childID = _childSData.id
|
|||
|
if self.MarryChildDataDict:ContainsKey(_childID) then
|
|||
|
if self.MarryChildDataDict[_childID].SData ~= nil then
|
|||
|
_isChildLevelUp = 1
|
|||
|
end
|
|||
|
self.MarryChildDataDict[_childID].SData = _childSData
|
|||
|
local _cfg = self.MarryChildDataDict[_childID].CfgData
|
|||
|
--激活需要模型展示界面
|
|||
|
if _childSData.isActive then
|
|||
|
GameCenter.ModelViewSystem:ShowModel(ShowModelType.Pet, _cfg.Model, _cfg.UiScale, _cfg.UiModelHeight / _cfg.UiScale, _cfg.ChildName)
|
|||
|
end
|
|||
|
else
|
|||
|
Debug.LogError(UIUtils.CSFormat("MarryChild!!! Can not fild child id {0} in MarryChild.xlsx", _childID))
|
|||
|
end
|
|||
|
end
|
|||
|
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_MARRY_CHILD_REFRESH, _isChildLevelUp)
|
|||
|
--设置仙娃红点
|
|||
|
self:SetChildRedPoint()
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
--伴侣请求购买
|
|||
|
function MarriageSystem:ResCallMarryCloneBuy(msg)
|
|||
|
local _cloneMapCfg = DataConfig.DataCloneMap[self.MarryQingYuanCopyID]
|
|||
|
local _needNum = tonumber(_cloneMapCfg.BuyNeedGold)
|
|||
|
local _itemName = DataConfig.DataItem[ItemTypeCode.Gold].Name
|
|||
|
local _costText = UIUtils.CSFormat("{0}{1}", _needNum,_itemName)
|
|||
|
Utils.ShowMsgBox(function (code)
|
|||
|
if (code == MsgBoxResultCode.Button2) then
|
|||
|
--购买
|
|||
|
local _msg = ReqMsg.MSG_Marriage.ReqMarryCloneBuy:New()
|
|||
|
_msg:Send()
|
|||
|
else
|
|||
|
--拒绝
|
|||
|
local _msg = ReqMsg.MSG_Marriage.ReqRefuseMarryCloneBuy:New()
|
|||
|
_msg:Send()
|
|||
|
end
|
|||
|
end, "C_MARRY_COPYBUY_ASK", _costText, self.SpouseData.Name)
|
|||
|
end
|
|||
|
|
|||
|
--购买副本次数返回
|
|||
|
function MarriageSystem:ResMarryClone(msg)
|
|||
|
if msg ~= nil and msg.clone ~= nil then
|
|||
|
self.QingYuanCloneData = msg.clone
|
|||
|
self:CheckMarryCopyRedPoint()
|
|||
|
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_MARRY_BLESS_DATA_REFRESH)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
--检查婚姻副本红点
|
|||
|
function MarriageSystem:CheckMarryCopyRedPoint()
|
|||
|
local _showRedPoint = false
|
|||
|
if self:HasPartner() and self.QingYuanCloneData ~= nil then
|
|||
|
--剩余挑战次数和可购买次数
|
|||
|
_showRedPoint = self.QingYuanCloneData.remainTimes > 0
|
|||
|
end
|
|||
|
GameCenter.MainFunctionSystem:SetAlertFlag(FunctionStartIdCode.MarryBless, _showRedPoint)
|
|||
|
end
|
|||
|
|
|||
|
--仙缘任务
|
|||
|
function MarriageSystem:ResMarryTask(msg)
|
|||
|
--已完成任务ID列表
|
|||
|
local _taskIdList = msg.taskId
|
|||
|
--已领取ID列表
|
|||
|
local _overIdList = msg.overId
|
|||
|
local _states = RewardState.None
|
|||
|
if _taskIdList ~= nil then
|
|||
|
for i = 1, #_taskIdList do
|
|||
|
local _finsishedId = _taskIdList[i]
|
|||
|
if self.MarryTaskStatesDict:ContainsKey(_finsishedId) then
|
|||
|
--已完成可领取状态
|
|||
|
self.MarryTaskStatesDict[_finsishedId] = RewardState.CanReceive
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
if _overIdList ~= nil then
|
|||
|
for i = 1, #_overIdList do
|
|||
|
local _receivedId = _overIdList[i]
|
|||
|
if self.MarryTaskStatesDict:ContainsKey(_receivedId) then
|
|||
|
--已领取状态
|
|||
|
self.MarryTaskStatesDict[_receivedId] = RewardState.Received
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
local _showRedPoint = false
|
|||
|
self.MarryTaskStatesDict:ForeachCanBreak(
|
|||
|
function(_key, _states)
|
|||
|
--可领取
|
|||
|
if _states == RewardState.CanReceive then
|
|||
|
_showRedPoint = true
|
|||
|
return true
|
|||
|
end
|
|||
|
end
|
|||
|
)
|
|||
|
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_MARRY_TASK_REFRESH, _showRedPoint)
|
|||
|
local _isShowingRedPoint = GameCenter.MainFunctionSystem:GetAlertFlag(FunctionStartIdCode.MarryInfo)
|
|||
|
local _funcInfo = GameCenter.MainFunctionSystem:GetFunctionInfo(FunctionStartIdCode.MarryInfo)
|
|||
|
if _funcInfo ~= nil then
|
|||
|
if _showRedPoint and not _isShowingRedPoint and _funcInfo.SelfIsVisible and _funcInfo.IsEnable then
|
|||
|
GameCenter.MainFunctionSystem:SetAlertFlag(FunctionStartIdCode.MarryInfo, _showRedPoint)
|
|||
|
if not self.IsShowMarryTaskForm and GameCenter.MainFunctionSystem:FunctionIsVisible(FunctionStartIdCode.MarryTask) then
|
|||
|
GameCenter.PushFixEvent(UILuaEventDefine.UIMarryTaskForm_OPEN)
|
|||
|
self.IsShowMarryTaskForm = true
|
|||
|
end
|
|||
|
else
|
|||
|
if not _showRedPoint and _isShowingRedPoint then
|
|||
|
GameCenter.MainFunctionSystem:SetAlertFlag(FunctionStartIdCode.MarryInfo, false)
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
--是否有伴侣了
|
|||
|
function MarriageSystem:HasPartner()
|
|||
|
if self.SpouseData ~= nil then
|
|||
|
if self.SpouseData.Name == nil then
|
|||
|
return false
|
|||
|
end
|
|||
|
if self.SpouseData.Name ~= nil then
|
|||
|
return true
|
|||
|
end
|
|||
|
end
|
|||
|
return false
|
|||
|
end
|
|||
|
|
|||
|
--是否预约了婚礼
|
|||
|
function MarriageSystem:IsApponitedWedding()
|
|||
|
local _isApponited = false
|
|||
|
local _lp = GameCenter.GameSceneSystem:GetLocalPlayer()
|
|||
|
for i = 1, #self.WeddingDataList do
|
|||
|
local _selfName = self.WeddingDataList[i].marrayName
|
|||
|
local _beMarrayName = self.WeddingDataList[i].beMarrayName
|
|||
|
if _lp.Name ~= nil and _lp.Name == _selfName or _lp.Name == _beMarrayName then
|
|||
|
_isApponited = true
|
|||
|
break
|
|||
|
end
|
|||
|
end
|
|||
|
return _isApponited
|
|||
|
end
|
|||
|
|
|||
|
--预约的婚宴是否过期了
|
|||
|
function MarriageSystem:IsApponitedExpired()
|
|||
|
local _hasExpired = false
|
|||
|
local _heartTime = GameCenter.HeartSystem.ServerTime
|
|||
|
local _lp = GameCenter.GameSceneSystem:GetLocalPlayer()
|
|||
|
for i = 1, #self.WeddingDataList do
|
|||
|
local _selfName = self.WeddingDataList[i].marrayName
|
|||
|
--预约的婚宴时间
|
|||
|
if _lp.Name ~= nil and _lp.Name == _selfName then
|
|||
|
local _timeStart = self.WeddingDataList[i].timeStart * 60
|
|||
|
if _heartTime > _timeStart then
|
|||
|
_hasExpired = true
|
|||
|
break
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
return _hasExpired
|
|||
|
end
|
|||
|
|
|||
|
function MarriageSystem:CauUnObtainMarryTitle()
|
|||
|
local _dict = Dictionary:New()
|
|||
|
--亲密度的进度
|
|||
|
if self.SpouseData ~= nil and self.Intimacy < self.SpouseData:GetIntimacy() then
|
|||
|
self.Intimacy = self.SpouseData:GetIntimacy()
|
|||
|
end
|
|||
|
local _showRedPoint = false
|
|||
|
DataConfig.DataMarryTitle:Foreach(
|
|||
|
function(_level, _cfg)
|
|||
|
--1是要显示的, 0 不显示出来
|
|||
|
if _cfg.IsShow == 1 then
|
|||
|
local _intimacyPro = self.Intimacy / _cfg.NeedValue
|
|||
|
--心锁目标解锁配置表
|
|||
|
local _targetLocKCfg = nil
|
|||
|
local _lockLv = tonumber(_cfg.Lock)
|
|||
|
if DataConfig.DataMarryLock:IsContainKey(_lockLv) then
|
|||
|
_targetLocKCfg = DataConfig.DataMarryLock[_lockLv]
|
|||
|
end
|
|||
|
--心锁当前配置表
|
|||
|
local _lockPro = 0
|
|||
|
local _activeStage = 0
|
|||
|
local _activeGrade = 0
|
|||
|
if DataConfig.DataMarryLock:IsContainKey(self.HeartLockLv) then
|
|||
|
local _activeHeartLocKCfg = DataConfig.DataMarryLock[self.HeartLockLv]
|
|||
|
_activeStage = _activeHeartLocKCfg.Stage
|
|||
|
_activeGrade = _activeHeartLocKCfg.Grade
|
|||
|
end
|
|||
|
if self.HeartLockLv <= 0 then
|
|||
|
--没激活的情况
|
|||
|
_lockPro = 0
|
|||
|
else
|
|||
|
--阶数都超了肯定是达标了
|
|||
|
if _activeStage > _targetLocKCfg.Stage then
|
|||
|
_lockPro = 1.0
|
|||
|
else
|
|||
|
--大于0, 还没达到解锁条件, 阶数 * 10(每阶10级) + 等级
|
|||
|
local _need = _targetLocKCfg.Stage * 10 + _targetLocKCfg.Grade
|
|||
|
local _cur = _activeStage * 10 + _activeGrade
|
|||
|
_lockPro = _cur / _need
|
|||
|
end
|
|||
|
end
|
|||
|
if _lockPro > 1.0 then
|
|||
|
_lockPro = 1.0
|
|||
|
end
|
|||
|
if _intimacyPro > 1.0 then _intimacyPro = 1.0 end
|
|||
|
--称号当前的进度
|
|||
|
local _curPro = (_lockPro + _intimacyPro) / 2
|
|||
|
--防止被四舍五入了
|
|||
|
if _curPro >= 0.99 and _curPro < 1.0 then
|
|||
|
_curPro = 0.991
|
|||
|
end
|
|||
|
--是否获得了当前称号
|
|||
|
local _isGet = GameCenter.RoleTitleSystem.CurrHaveTitleList:Contains(_cfg.TitleId)
|
|||
|
--保留小数点后两位
|
|||
|
_curPro = tonumber(string.format("%.2f", _curPro))
|
|||
|
--最大值只能100%
|
|||
|
if _curPro >= 1.0 and not _isGet then
|
|||
|
_curPro = 1.0
|
|||
|
--设置红点
|
|||
|
_showRedPoint = true
|
|||
|
end
|
|||
|
local _titleData =
|
|||
|
{
|
|||
|
CurPro = _curPro,
|
|||
|
HasGet = _isGet,
|
|||
|
Cfg = _cfg,
|
|||
|
}
|
|||
|
if not _dict:ContainsKey(_cfg.Level) then
|
|||
|
_dict:Add(_cfg.Level, _titleData)
|
|||
|
else
|
|||
|
_dict[_cfg.Level] = _titleData
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
)
|
|||
|
GameCenter.MainFunctionSystem:SetAlertFlag(FunctionStartIdCode.MarryInfo, _showRedPoint)
|
|||
|
local _hasGetAll = false
|
|||
|
_dict:ForeachCanBreak(
|
|||
|
function(_, _titleData)
|
|||
|
if _titleData.HasGet then
|
|||
|
_hasGetAll = true
|
|||
|
else
|
|||
|
_hasGetAll = false
|
|||
|
return true
|
|||
|
end
|
|||
|
end
|
|||
|
)
|
|||
|
--都领完了,红点设置成false
|
|||
|
if _hasGetAll then
|
|||
|
GameCenter.MainFunctionSystem:SetAlertFlag(FunctionStartIdCode.MarryInfo, not _hasGetAll)
|
|||
|
end
|
|||
|
return _dict
|
|||
|
end
|
|||
|
|
|||
|
--设置心锁的红点
|
|||
|
function MarriageSystem:SetHeartLockRedPoint()
|
|||
|
--设置红点
|
|||
|
local _lockCfg = DataConfig.DataMarryLock:GetByIndex(1)
|
|||
|
if DataConfig.DataMarryLock:IsContainKey(self.HeartLockLv) then
|
|||
|
_lockCfg = DataConfig.DataMarryLock[self.HeartLockLv]
|
|||
|
end
|
|||
|
local _cons = {}
|
|||
|
local _items = Utils.SplitNumber(_lockCfg.CostItem, '_')
|
|||
|
local _itemCount = #_items
|
|||
|
for i = 1, _itemCount do
|
|||
|
_cons[i] = RedPointItemCondition(_items[1], 1)
|
|||
|
end
|
|||
|
GameCenter.RedPointSystem:CleraFuncCondition(FunctionStartIdCode.MarryHeartLock)
|
|||
|
GameCenter.RedPointSystem:LuaAddFuncCondition(FunctionStartIdCode.MarryHeartLock, 1, _cons)
|
|||
|
--最大等级了
|
|||
|
if _lockCfg.NextLv == 0 then
|
|||
|
GameCenter.MainFunctionSystem:SetAlertFlag(FunctionStartIdCode.MarryHeartLock, false)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
--设置仙娃的红点
|
|||
|
function MarriageSystem:SetChildRedPoint()
|
|||
|
local _showRedPoint = false
|
|||
|
-- 0 激活 1 升级
|
|||
|
local _isLvUp = 0
|
|||
|
self.MarryChildDataDict:ForeachCanBreak(
|
|||
|
function(_childId, _data)
|
|||
|
if _showRedPoint then
|
|||
|
return true
|
|||
|
end
|
|||
|
if _data.SData ~= nil then
|
|||
|
--激活了的仙娃
|
|||
|
local _childLv = _data.SData.level
|
|||
|
local _upLvItems = Utils.SplitStrByTableS(_data.AttrDict[_childLv].Consume, {';','_'})
|
|||
|
local _itemCount = #_upLvItems
|
|||
|
local _attrCfg = _data.AttrDict[_childLv]
|
|||
|
local _isMaxLv = tonumber(_attrCfg.BlessingValue) <= 0
|
|||
|
if not _isMaxLv then
|
|||
|
for i = 1, _itemCount do
|
|||
|
local _itemId = tonumber(_upLvItems[i][1])
|
|||
|
if not self.ChildActiveOrUpgradeID:Contains(_itemId) then
|
|||
|
self.ChildActiveOrUpgradeID:Add(_itemId)
|
|||
|
end
|
|||
|
local _haveCount = GameCenter.ItemContianerSystem:GetItemCountFromCfgId(_itemId)
|
|||
|
if _haveCount >= 1 then
|
|||
|
_showRedPoint = true
|
|||
|
_isLvUp = 1
|
|||
|
break
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
else
|
|||
|
--没激活的仙娃
|
|||
|
local _cfgData = _data.CfgData
|
|||
|
local _conds = Utils.SplitNumber(_cfgData.ItemCondition, '_')
|
|||
|
local _haveCount = GameCenter.ItemContianerSystem:GetItemCountFromCfgId(_conds[1])
|
|||
|
local _needNum = _conds[2]
|
|||
|
--对比心锁等级是否满足条件
|
|||
|
local _lvCond = self.HeartLockLv >= tonumber(_cfgData.Condition)
|
|||
|
--1或 2且
|
|||
|
if tonumber(_cfgData.Activation) == 1 then
|
|||
|
_showRedPoint = _lvCond or _haveCount >= _needNum
|
|||
|
GameCenter.RedPointSystem:CleraFuncCondition(FunctionStartIdCode.MarryChild)
|
|||
|
GameCenter.RedPointSystem:AddFuncCondition(FunctionStartIdCode.MarryChild, 1, RedPointItemCondition(_conds[1], _needNum))
|
|||
|
if not self.ChildActiveOrUpgradeID:Contains(_conds[1]) then
|
|||
|
self.ChildActiveOrUpgradeID:Add(_conds[1])
|
|||
|
end
|
|||
|
else
|
|||
|
_showRedPoint = _lvCond and _haveCount >= _needNum
|
|||
|
end
|
|||
|
_isLvUp = 1
|
|||
|
end
|
|||
|
end
|
|||
|
)
|
|||
|
GameCenter.MainFunctionSystem:SetAlertFlag(FunctionStartIdCode.MarryChild, _showRedPoint)
|
|||
|
--有红点的话刷新下数据
|
|||
|
if _showRedPoint then
|
|||
|
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_MARRY_CHILD_REFRESH, _isLvUp)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
--请求结婚
|
|||
|
function MarriageSystem:ReqGetMarried(beMarrayId, isBroadcast, notice)
|
|||
|
self.SpouseData.PlayerID = beMarrayId
|
|||
|
local _msg = ReqMsg.MSG_Marriage.ReqGetMarried:New()
|
|||
|
--求婚的类型
|
|||
|
_msg.type = tonumber(self.CurMarriageType)
|
|||
|
--被求婚者的ID
|
|||
|
_msg.beMarrayId = beMarrayId
|
|||
|
_msg.isNotice = isBroadcast
|
|||
|
_msg.notice = notice
|
|||
|
_msg:Send()
|
|||
|
end
|
|||
|
|
|||
|
--展示自动预约
|
|||
|
function MarriageSystem:ShowAutoYuYue()
|
|||
|
if self.WeddingNum <= 0 then
|
|||
|
return
|
|||
|
end
|
|||
|
local _askText = UIUtils.CSFormat(DataConfig.DataMessageString.Get("C_MARRY_AUTO_YUYUE_ASK"), self.SpouseData.Name)
|
|||
|
GameCenter.MsgPromptSystem:ShowMsgBox(_askText,
|
|||
|
DataConfig.DataMessageString.Get("C_MSGBOX_CANCEL"),
|
|||
|
DataConfig.DataMessageString.Get("C_MSGBOX_OK"),
|
|||
|
function (code)
|
|||
|
--同意
|
|||
|
if (code == MsgBoxResultCode.Button2) then
|
|||
|
local _msg = ReqMsg.MSG_Marriage.ReqSelectWedding:New()
|
|||
|
_msg.timeStart = 0 --参数设置为0,需要服务器给客户端自动预约一个时间最近的婚礼
|
|||
|
_msg:Send()
|
|||
|
end
|
|||
|
GameCenter.PushFixEvent(UIEventDefine.UIMarryEngagementForm_CLOSE)
|
|||
|
end,
|
|||
|
false,
|
|||
|
false, 15, 4, 1, nil, nil, 0, true)
|
|||
|
end
|
|||
|
|
|||
|
--收到世界祝福消息
|
|||
|
function MarriageSystem:ResMarryPosterShow(msg)
|
|||
|
if self.WorldZhuFuUIId == nil then
|
|||
|
self.WorldZhuFuUIId = GameCenter.FormStateSystem:EventIDToFormID(UILuaEventDefine.UIMarryWorldZhuFuForm_OPEN)
|
|||
|
end
|
|||
|
if GameCenter.FormStateSystem:FormIsOpen(self.WorldZhuFuUIId) then
|
|||
|
--界面已经打开,缓存消息
|
|||
|
if self.CacheWorldZhuFuList == nil then
|
|||
|
self.CacheWorldZhuFuList = List:New()
|
|||
|
end
|
|||
|
self.CacheWorldZhuFuList:Add(msg)
|
|||
|
else
|
|||
|
--界面没有打开,直接打开界面
|
|||
|
GameCenter.PushFixEvent(UILuaEventDefine.UIMarryWorldZhuFuForm_OPEN, msg)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
return MarriageSystem
|