590 lines
19 KiB
Lua
590 lines
19 KiB
Lua
|
------------------------------------------------
|
|||
|
--作者: yangqf
|
|||
|
--日期: 2021-03-12
|
|||
|
--文件: TeamSystem.lua
|
|||
|
--模块: TeamSystem
|
|||
|
--描述: 队伍系统
|
|||
|
------------------------------------------------
|
|||
|
local FreeDomerInfo = require "Logic.Team.FreeDomerInfo"
|
|||
|
local TeamInfo = require "Logic.Team.TeamInfo"
|
|||
|
local TeamMemberInfo = require "Logic.Team.TeamMemberInfo"
|
|||
|
|
|||
|
local TeamSystem = {
|
|||
|
--组队功能开启等级
|
|||
|
TeamOpenLv = 0,
|
|||
|
--最大队员数量
|
|||
|
MaxPlayerNum = 2,
|
|||
|
--队伍信息
|
|||
|
MyTeamInfo = TeamInfo:New(),
|
|||
|
--邀请列表信息
|
|||
|
InviteInfos = List:New(),
|
|||
|
--申请列表信息
|
|||
|
ApplyInfos = List:New(),
|
|||
|
--快速组队的所有队伍信息
|
|||
|
TeamInfos = List:New(),
|
|||
|
HanHuaCDTime = 0,
|
|||
|
CuiCuCDTime = 0,
|
|||
|
ApplyLeaderCDTime = 0,
|
|||
|
--正在匹配
|
|||
|
IsMatching = false,
|
|||
|
-- 当前选中的副本ID
|
|||
|
CurrSelectMapID = 0,
|
|||
|
DeltaTime = 0.0,
|
|||
|
CuiCuDeltaTime = 0.0,
|
|||
|
ApplyLeaderDeltaTime = 0.0,
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
--队伍是否满员
|
|||
|
function TeamSystem:IsMemberFull()
|
|||
|
return #self.MyTeamInfo.MemberList >= self.MaxPlayerNum
|
|||
|
end
|
|||
|
|
|||
|
function TeamSystem:IsExitApply(playerId)
|
|||
|
local _count = #self.ApplyInfos
|
|||
|
for i = 1, _count do
|
|||
|
if self.ApplyInfos[i].PlayerID == playerId then
|
|||
|
return true
|
|||
|
end
|
|||
|
end
|
|||
|
return false
|
|||
|
end
|
|||
|
|
|||
|
function TeamSystem:Initialize()
|
|||
|
self.MaxPlayerNum = tonumber(DataConfig.DataGlobal[1482].Params)
|
|||
|
local _cfg = DataConfig.DataFunctionStart[FunctionStartIdCode.Team]
|
|||
|
if _cfg ~= nil then
|
|||
|
local _param = Utils.SplitNumber(_cfg.StartVariables, '_')
|
|||
|
self.TeamOpenLv = _param[2]
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
-- 请求创建队伍
|
|||
|
function TeamSystem:ReqCreateTeam(cfgID, autoAccept)
|
|||
|
GameCenter.Network.Send("MSG_Team.ReqCreateTeam", {type = cfgID, autoAccept = autoAccept})
|
|||
|
if cfgID == 6002 then
|
|||
|
GameCenter.BISystem:ReqClickEvent(BiIdCode.XMHJCreatTeam)
|
|||
|
elseif cfgID == 6003 then
|
|||
|
GameCenter.BISystem:ReqClickEvent(BiIdCode.SLTCreatTeam)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
--请求队伍的信息
|
|||
|
function TeamSystem:ReqGetTeamInfo()
|
|||
|
GameCenter.Network.Send("MSG_Team.ReqGetTeamInfo")
|
|||
|
end
|
|||
|
--请求调整队伍
|
|||
|
function TeamSystem:ReqAlterTeam(isNotice, inType)
|
|||
|
local _teamid = self.MyTeamInfo.TeamID
|
|||
|
GameCenter.Network.Send("MSG_Team.ReqAlterTeam", {isNotice = isNotice, type = inType})
|
|||
|
self.MyTeamInfo.IsNotice = isNotice
|
|||
|
self.MyTeamInfo.Type = inType
|
|||
|
end
|
|||
|
--一键喊话收人
|
|||
|
function TeamSystem:ReqOneHan(teamType)
|
|||
|
local _type = self.MyTeamInfo.Type
|
|||
|
if teamType ~= nil then
|
|||
|
_type = teamType
|
|||
|
end
|
|||
|
GameCenter.Network.Send("MSG_Team.ReqAlterTeam", {isNotice = true, type = _type, teamId = 0})
|
|||
|
end
|
|||
|
|
|||
|
--催促队长
|
|||
|
function TeamSystem:ReqCuiChuLeader()
|
|||
|
GameCenter.Network.Send("MSG_Team.ReqTeamLeaderOpenState")
|
|||
|
end
|
|||
|
|
|||
|
--获取邀请列表,0周围玩家,1好友,2势力
|
|||
|
function TeamSystem:ReqGetFreedomList(inType)
|
|||
|
GameCenter.Network.Send("MSG_Team.ReqGetFreedomList", {type = inType})
|
|||
|
end
|
|||
|
|
|||
|
--邀请某人加入
|
|||
|
function TeamSystem:ReqInvite(playerId)
|
|||
|
GameCenter.Network.Send("MSG_Team.ReqInvite", {roleid = playerId})
|
|||
|
end
|
|||
|
|
|||
|
--请求是否同意入队
|
|||
|
function TeamSystem:ReqInviteRes(teamId, roleId, inType)
|
|||
|
GameCenter.Network.Send("MSG_Team.ReqInviteRes", {teamdId = teamId, roleId = roleId, type = inType})
|
|||
|
end
|
|||
|
|
|||
|
--请求获取申请列表
|
|||
|
function TeamSystem:ReqGetApplyList()
|
|||
|
GameCenter.Network.Send("MSG_Team.ReqGetApplyList")
|
|||
|
end
|
|||
|
|
|||
|
--操作申请对象,0同意加入 -1拒绝加入
|
|||
|
function TeamSystem:ReqApplyOpt(id, inType)
|
|||
|
GameCenter.Network.Send("MSG_Team.ReqApplyOpt", {id = id, type = inType})
|
|||
|
end
|
|||
|
|
|||
|
--获取等待的队伍列表
|
|||
|
function TeamSystem:ReqGetWaitList(inType)
|
|||
|
GameCenter.Network.Send("MSG_Team.ReqGetWaitList", {type = inType})
|
|||
|
end
|
|||
|
|
|||
|
--申请加入
|
|||
|
function TeamSystem:ReqApplyEnter(teamId)
|
|||
|
if self:IsTeamExist() then
|
|||
|
Utils.ShowPromptByEnum("TEAM_YOUHAVEDTEAM")
|
|||
|
return
|
|||
|
end
|
|||
|
GameCenter.Network.Send("MSG_Team.ReqApplyEnter", {teamId = teamId})
|
|||
|
end
|
|||
|
|
|||
|
--操作队伍 1提升队长 2踢出队伍 3退出队伍 4解散队伍 5自动接受申请(自反)6申请成为队长 7拒绝队员成为队长
|
|||
|
function TeamSystem:ReqTeamOpt(playerId, inType)
|
|||
|
GameCenter.Network.Send("MSG_Team.ReqTeamOpt", {targetId = playerId, opt = inType})
|
|||
|
end
|
|||
|
|
|||
|
--召唤队员
|
|||
|
function TeamSystem:ReqCallAllMember()
|
|||
|
GameCenter.Network.Send("MSG_Team.ReqCallAllMember")
|
|||
|
end
|
|||
|
|
|||
|
--传送到队长
|
|||
|
function TeamSystem:ReqTransport2Leader()
|
|||
|
GameCenter.Network.Send("MSG_Team.ReqTransport2Leader")
|
|||
|
end
|
|||
|
|
|||
|
--请求清空申请列表
|
|||
|
function TeamSystem:ReqCleanApplyList()
|
|||
|
GameCenter.Network.Send("MSG_Team.ReqCleanApplyList")
|
|||
|
end
|
|||
|
|
|||
|
--自动匹配
|
|||
|
function TeamSystem:ReqMatchAll(inType, match)
|
|||
|
self.IsMatching = match
|
|||
|
GameCenter.Network.Send("MSG_Team.ReqMatchAll", {type = inType, match = match})
|
|||
|
GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_UITEAMFORM_UPDATE)
|
|||
|
if match then
|
|||
|
if inType == 6002 then
|
|||
|
GameCenter.BISystem:ReqClickEvent(BiIdCode.XMHJTeamAutoMatch)
|
|||
|
elseif inType == 6003 then
|
|||
|
GameCenter.BISystem:ReqClickEvent(BiIdCode.SLTTeamAutoMatch)
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
--同意召唤
|
|||
|
function TeamSystem:ReqAgreeCall(callid)
|
|||
|
GameCenter.Network.Send("MSG_Team.ReqAgreeCall", {callId = callid})
|
|||
|
end
|
|||
|
|
|||
|
--返回队伍信息
|
|||
|
function TeamSystem:ResTeamInfo(result)
|
|||
|
if result.teamId == 0 then
|
|||
|
return
|
|||
|
end
|
|||
|
local _noTeam = (#self.MyTeamInfo.MemberList <= 0)
|
|||
|
self.MyTeamInfo.MemberList:Clear()
|
|||
|
self.MyTeamInfo.TeamID = result.teamId
|
|||
|
self.MyTeamInfo.Type = result.type
|
|||
|
self.MyTeamInfo.IsAutoAcceptApply = result.autoAccept
|
|||
|
for i = 1, #result.members do
|
|||
|
local _index = TeamMemberInfo:New(result.members[i])
|
|||
|
self.MyTeamInfo.MemberList:Add(_index)
|
|||
|
local _player = GameCenter.GameSceneSystem:FindPlayer(_index.PlayerID)
|
|||
|
if _player ~= nil then
|
|||
|
_player:UpdateNameColor()
|
|||
|
end
|
|||
|
end
|
|||
|
self:MyTeamMemberSort()
|
|||
|
self:OnTeamChanged()
|
|||
|
if _noTeam then
|
|||
|
if self.MyTeamInfo:IsLeader() then
|
|||
|
Utils.ShowPromptByEnum("TEAM_CREATE_SUCCESS")
|
|||
|
else
|
|||
|
Utils.ShowPromptByEnum("TEAM_ADD_SUCCESS")
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
--更新队伍中某个玩家的信息
|
|||
|
function TeamSystem:ResUpdateTeamMemberInfo(result)
|
|||
|
local _isExistPlayer = false
|
|||
|
local _info = nil
|
|||
|
for i = 1, #self.MyTeamInfo.MemberList do
|
|||
|
_info = self.MyTeamInfo.MemberList[i]
|
|||
|
if _info.PlayerID == result.member.roleId then
|
|||
|
_isExistPlayer = true
|
|||
|
break
|
|||
|
end
|
|||
|
end
|
|||
|
if not _isExistPlayer then
|
|||
|
Utils.ShowPromptByEnum("TEAM_PLAYERENTERTEAM", result.member.name)
|
|||
|
_info = TeamMemberInfo:New()
|
|||
|
self.MyTeamInfo.MemberList:Add(_info)
|
|||
|
end
|
|||
|
_info:Parse(result.member)
|
|||
|
self:MyTeamMemberSort()
|
|||
|
self:OnTeamChanged()
|
|||
|
local _player = GameCenter.GameSceneSystem:FindPlayer(_info.PlayerID)
|
|||
|
if _player ~= nil then
|
|||
|
_player:UpdateNameColor()
|
|||
|
end
|
|||
|
self:UpdateApplyList(result.member.roleId)
|
|||
|
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_UITEAM_TEAM_SUCC)
|
|||
|
end
|
|||
|
|
|||
|
--返回邀请成员列表
|
|||
|
function TeamSystem:ResFreedomList(result)
|
|||
|
self.InviteInfos:Clear()
|
|||
|
if result.members ~= nil then
|
|||
|
for i = 1, #result.members do
|
|||
|
if not self:IsExitApply(result.members[i].roleId) then
|
|||
|
local _info = FreeDomerInfo:New(result.members[i])
|
|||
|
self.InviteInfos:Add(_info)
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
self.InviteInfos:Sort(function(x, y)
|
|||
|
return x.Honey > y.Honey
|
|||
|
end)
|
|||
|
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_UITEAMINVITEFORM_UPDATE)
|
|||
|
end
|
|||
|
|
|||
|
--返回某某邀请
|
|||
|
function TeamSystem:ResInviteInfo(result)
|
|||
|
local _teamId = result.teamdId
|
|||
|
local _playerId = result.roleId
|
|||
|
local _name = result.name
|
|||
|
|
|||
|
if GameCenter.GameSetting:GetSetting(GameSettingKeyCode.MandateAutoJoinTeam) > 0 then
|
|||
|
self:ReqInviteRes(_teamId, _playerId, 0)
|
|||
|
else
|
|||
|
Utils.ShowMsgBoxAndBtn(function(x)
|
|||
|
if x == MsgBoxResultCode.Button1 then
|
|||
|
self:ReqInviteRes(_teamId, _playerId, -1)
|
|||
|
elseif x == MsgBoxResultCode.Button2 then
|
|||
|
self:ReqInviteRes(_teamId, _playerId, 0)
|
|||
|
end
|
|||
|
end, "TEAM_REFUSE", "TEAM_JOIN", "TEAM_0INVITEYOU", _name)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
--返回申请列表
|
|||
|
function TeamSystem:ResApplyList(result)
|
|||
|
self.ApplyInfos:Clear()
|
|||
|
if result.members ~= nil then
|
|||
|
for i =1, #result.members do
|
|||
|
if not self:IsExitApply(result.members[i].roleId) then
|
|||
|
local _info = FreeDomerInfo:New(result.members[i])
|
|||
|
self.ApplyInfos:Add(_info)
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
self:SetTeamNotice()
|
|||
|
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_UITEAMAPPLYFORM_UPDATE)
|
|||
|
end
|
|||
|
|
|||
|
--添加申请人
|
|||
|
function TeamSystem:ResAddApplyer(result)
|
|||
|
local _state = self.MyTeamInfo.IsAutoAcceptApply
|
|||
|
if _state then
|
|||
|
self:ReqApplyOpt(result.member.roleId, 0)
|
|||
|
else
|
|||
|
if not self:IsExitApply(result.member.roleId) then
|
|||
|
Utils.ShowPromptByEnum("TEAM_NEWPLAYER_JOIN")
|
|||
|
local _info = FreeDomerInfo:New(result.member)
|
|||
|
self.ApplyInfos:Add(_info)
|
|||
|
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_UITEAMAPPLYFORM_UPDATE)
|
|||
|
self:SetTeamNotice()
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
--返回正在等待的队伍
|
|||
|
function TeamSystem:ResWaitList(result)
|
|||
|
self.TeamInfos:Clear()
|
|||
|
if result.teams ~= nil then
|
|||
|
for i = 1, #result.teams do
|
|||
|
local _info = TeamInfo:New()
|
|||
|
_info.TeamID = result.teams[i].teamId
|
|||
|
_info.Type = result.teams[i].type
|
|||
|
for j = 1, #result.teams[i].members do
|
|||
|
local _index = TeamMemberInfo:New(result.teams[i].members[j])
|
|||
|
_info.MemberList:Add(_index)
|
|||
|
end
|
|||
|
self.TeamInfos:Add(_info)
|
|||
|
end
|
|||
|
end
|
|||
|
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_UITEAMMATCHFORM_UPDATE)
|
|||
|
end
|
|||
|
|
|||
|
--删除队员
|
|||
|
function TeamSystem:ResDeleteTeamMember(result)
|
|||
|
local _roleId = result.roleId
|
|||
|
local _ownId = GameCenter.GameSceneSystem:GetLocalPlayerID()
|
|||
|
if _ownId ~= _roleId then
|
|||
|
for i = 1, #self.MyTeamInfo.MemberList do
|
|||
|
local _playerId = self.MyTeamInfo.MemberList[i].PlayerID
|
|||
|
if _playerId == _roleId then
|
|||
|
Utils.ShowPromptByEnum("TEAM_PLAYERLEAVETEAM", self.MyTeamInfo.MemberList[i].PlayerName)
|
|||
|
self.MyTeamInfo.MemberList:RemoveAt(i)
|
|||
|
break
|
|||
|
end
|
|||
|
end
|
|||
|
self:MyTeamMemberSort()
|
|||
|
local _player = GameCenter.GameSceneSystem:FindPlayer(_roleId)
|
|||
|
if _player ~= nil then
|
|||
|
_player:UpdateNameColor()
|
|||
|
end
|
|||
|
else
|
|||
|
self.MyTeamInfo.Type = 0
|
|||
|
self.MyTeamInfo.TeamID = 0
|
|||
|
self.HanHuaCDTime = 0
|
|||
|
for i = #self.MyTeamInfo.MemberList, 1, -1 do
|
|||
|
local _playerID = self.MyTeamInfo.MemberList[i].PlayerID
|
|||
|
self.MyTeamInfo.MemberList:RemoveAt(i)
|
|||
|
local _player = GameCenter.GameSceneSystem:FindPlayer(_playerID)
|
|||
|
if _player ~= nil then
|
|||
|
_player:UpdateNameColor()
|
|||
|
end
|
|||
|
end
|
|||
|
self.ApplyInfos:Clear()
|
|||
|
self:SetTeamNotice()
|
|||
|
end
|
|||
|
self:OnTeamChanged()
|
|||
|
end
|
|||
|
|
|||
|
--召唤队员返回
|
|||
|
function TeamSystem:ResCallAllMemberRes(result)
|
|||
|
local _callId = result.callId
|
|||
|
local _mapName = string.gsub(result.name, "2&_", "")
|
|||
|
_mapName = GameCenter.LanguageConvertSystem:ConvertLan(_mapName)
|
|||
|
local _posX = math.floor(result.x)
|
|||
|
local _posY = math.floor(result.y)
|
|||
|
Utils.ShowMsgBoxAndBtn(function(x)
|
|||
|
if x == MsgBoxResultCode.Button2 then
|
|||
|
self:ReqAgreeCall(_callId)
|
|||
|
end
|
|||
|
end, "C_MSGBOX_CANEL", "C_MSGBOX_AGREE", "TEAM_LEADER_ZHAOJI", _posX, _posY)
|
|||
|
end
|
|||
|
|
|||
|
--返回实时更新玩家地图和血量
|
|||
|
function TeamSystem:ResUpdateHPAndMapKey(result)
|
|||
|
local _info = nil
|
|||
|
for i= 1, #self.MyTeamInfo.MemberList do
|
|||
|
_info = self.MyTeamInfo.MemberList[i]
|
|||
|
if _info.PlayerID == result.roleId then
|
|||
|
_info.CurMapID = result.mapKey
|
|||
|
_info.HpPro = result.hpPro
|
|||
|
end
|
|||
|
end
|
|||
|
self:OnTeamChanged(1)
|
|||
|
end
|
|||
|
|
|||
|
function TeamSystem:OnTeamChanged(param)
|
|||
|
GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_UITEAMFORM_UPDATE, param)
|
|||
|
end
|
|||
|
|
|||
|
function TeamSystem:ResMatchAll(result)
|
|||
|
self.IsMatching = false
|
|||
|
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_UITEAMAUTOMATCH_OVER)
|
|||
|
GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_UITEAMFORM_UPDATE)
|
|||
|
if result.success then
|
|||
|
Utils.ShowPromptByEnum("TEAM_AUTOMATCHSUCEESS")
|
|||
|
GameCenter.PushFixEvent(UIEventDefine.UITeamForm_CLOSE)
|
|||
|
else
|
|||
|
Utils.ShowPromptByEnum("TEAM_HAVENOTEAMCREATETEAM")
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function TeamSystem:ResTeamLeaderOpenState(result)
|
|||
|
if result.state == 0 then
|
|||
|
local _id = GameCenter.GameSceneSystem:GetLocalPlayerID()
|
|||
|
if _id == result.leaderId then
|
|||
|
Utils.ShowPromptByEnum("TEAM_CUICHULEADERDADAO", self:GetTeamTargetTypeName())
|
|||
|
else
|
|||
|
self.CuiCuCDTime = 10
|
|||
|
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_UITEAMCUICUCD)
|
|||
|
end
|
|||
|
elseif result.state == 1 then
|
|||
|
Utils.ShowPromptByEnum("TEAM_LEADERNOTONLINE")
|
|||
|
else
|
|||
|
Utils.ShowPromptByEnum("TEAM_NOTHAVETEAMCUNZAI")
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function TeamSystem:ResBecomeLeader(result)
|
|||
|
local _player = self.MyTeamInfo:GetMemderInfo(result.targetId)
|
|||
|
if _player ~= nil then
|
|||
|
Utils.ShowMsgBoxAndBtn(function(x)
|
|||
|
if x == MsgBoxResultCode.Button1 or x == MsgBoxResultCode.None then
|
|||
|
self:ReqTeamOpt(result.targetId, 7)
|
|||
|
else
|
|||
|
self:ReqTeamOpt(result.targetId, 1)
|
|||
|
end
|
|||
|
end, "TEAM_REFUSE", "agree", "TEAM_0APPLYLEADER", _player.PlayerName)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
--设置申请提示
|
|||
|
function TeamSystem:SetTeamNotice()
|
|||
|
local _state = (#self.ApplyInfos > 0)
|
|||
|
GameCenter.MainFunctionSystem:SetAlertFlag(FunctionStartIdCode.TeamInfo, state)
|
|||
|
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_UITEAMREDPOINT)
|
|||
|
end
|
|||
|
|
|||
|
--判断玩家是否有队伍
|
|||
|
function TeamSystem:IsTeamExist()
|
|||
|
return #self.MyTeamInfo.MemberList > 0
|
|||
|
end
|
|||
|
|
|||
|
-- 判断某玩家是否是成员
|
|||
|
function TeamSystem:IsTeamMember(ID)
|
|||
|
return self.MyTeamInfo:IsTeamMember(ID)
|
|||
|
end
|
|||
|
|
|||
|
-- 对自身队伍成员进行排序
|
|||
|
function TeamSystem:MyTeamMemberSort()
|
|||
|
local _lpId = GameCenter.GameSceneSystem:GetLocalPlayerID()
|
|||
|
if #self.MyTeamInfo.MemberList > 1 then
|
|||
|
for i = 1, #self.MyTeamInfo.MemberList do
|
|||
|
if self.MyTeamInfo.MemberList[i].PlayerID == _lpId and i ~= 1 then
|
|||
|
local _info = self.MyTeamInfo.MemberList[1]
|
|||
|
self.MyTeamInfo.MemberList[1] = self.MyTeamInfo.MemberList[i]
|
|||
|
self.MyTeamInfo.MemberList[i] = _info
|
|||
|
break
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
--清除申请列表中的某一个玩家的请求
|
|||
|
function TeamSystem:ClearApplyPlayer(playerId)
|
|||
|
for i = 1, #self.ApplyInfos do
|
|||
|
if self.ApplyInfos[i].PlayerID == playerId then
|
|||
|
self.ApplyInfos:RemoveAt(i)
|
|||
|
break
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
--创建一个队伍并且设置队伍目标
|
|||
|
function TeamSystem:CreateTeamAndSetTarget(cfg)
|
|||
|
if not self:IsTeamExist() then
|
|||
|
self:ReqCreateTeam(cfg.Id, self.MyTeamInfo.IsAutoAcceptApply)
|
|||
|
end
|
|||
|
self:SetTeamTarget(cfg)
|
|||
|
end
|
|||
|
|
|||
|
--设置当前队伍目标
|
|||
|
function TeamSystem:SetTeamTarget(cfg)
|
|||
|
self:ReqAlterTeam(false, cfg.Id)
|
|||
|
end
|
|||
|
|
|||
|
-- 更新队伍申请列表
|
|||
|
function TeamSystem:UpdateApplyList(playerId)
|
|||
|
for i= 1, #self.ApplyInfos do
|
|||
|
if self.ApplyInfos[i].PlayerID == playerId then
|
|||
|
self.ApplyInfos:RemoveAt(i)
|
|||
|
break
|
|||
|
end
|
|||
|
end
|
|||
|
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_UITEAMREDPOINT)
|
|||
|
GameCenter.MainFunctionSystem:SetAlertFlag(FunctionStartIdCode.TeamInfo, #self.ApplyInfos > 0)
|
|||
|
end
|
|||
|
|
|||
|
-- 检测邀请玩家是否达到组队等级
|
|||
|
function TeamSystem:CheckInviteIsOpenTeam(playerId)
|
|||
|
for i = 1, #self.InviteInfos do
|
|||
|
local _info = self.InviteInfos[i]
|
|||
|
if _info.PlayerID == playerId then
|
|||
|
return _info.Level >= self.TeamOpenLv, _info.PlayerName
|
|||
|
end
|
|||
|
end
|
|||
|
return false, nil
|
|||
|
end
|
|||
|
|
|||
|
--邀请玩家组队
|
|||
|
function TeamSystem:InviteJoinTeam(playerId, mapId, isOneHan)
|
|||
|
local _lpId = GameCenter.GameSceneSystem:GetLocalPlayerID()
|
|||
|
--存在队伍
|
|||
|
if self:IsTeamExist() then
|
|||
|
--只有自己
|
|||
|
if #self.MyTeamInfo.MemberList == 1 then
|
|||
|
--切换目标地图
|
|||
|
self:ReqAlterTeam(false, mapId)
|
|||
|
--邀请入队
|
|||
|
if playerId > 0 then
|
|||
|
self:ReqInvite(playerId)
|
|||
|
end
|
|||
|
else --有两个人
|
|||
|
local _otherPlayerId = 0
|
|||
|
for i = 1, #self.MyTeamInfo.MemberList do
|
|||
|
if self.MyTeamInfo.MemberList[i].PlayerID ~= _lpId then
|
|||
|
_otherPlayerId = self.MyTeamInfo.MemberList[i].PlayerID
|
|||
|
end
|
|||
|
end
|
|||
|
--如果另一个刚好是邀请的人
|
|||
|
if playerId > 0 and playerId == _otherPlayerId then
|
|||
|
--切换目标地图(自己是队员会切换失败)
|
|||
|
self:ReqAlterTeam(false, mapId)
|
|||
|
else
|
|||
|
Utils.ShowPromptByEnum("C_TEAM_HAVE_TEAM")
|
|||
|
end
|
|||
|
end
|
|||
|
else--不存在队伍
|
|||
|
--创建队伍
|
|||
|
self:ReqCreateTeam(mapId, self.MyTeamInfo.IsAutoAcceptApply)
|
|||
|
--邀请入队
|
|||
|
if playerId > 0 then
|
|||
|
self:ReqInvite(playerId)
|
|||
|
end
|
|||
|
end
|
|||
|
--一键喊话
|
|||
|
if isOneHan then
|
|||
|
self:ReqOneHan(mapId)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
function TeamSystem:GetTeamTargetTypeName()
|
|||
|
local _lp = GameCenter.GameSceneSystem:GetLocalPlayer()
|
|||
|
if _lp == nil then
|
|||
|
return ""
|
|||
|
end
|
|||
|
local _memberList = self.MyTeamInfo.MemberList
|
|||
|
if #_memberList > 0 then
|
|||
|
if self.MyTeamInfo.Type == -1 then
|
|||
|
return DataConfig.DataMessageString.Get("TEAM_ALL_ACTIVITY")
|
|||
|
elseif self.MyTeamInfo.Type == -2 then
|
|||
|
return DataConfig.DataMessageString.Get("TEAM_JINGYINGBOSS")
|
|||
|
end
|
|||
|
else
|
|||
|
return DataConfig.DataMessageString.Get("TEAM_WU")
|
|||
|
end
|
|||
|
return ""
|
|||
|
end
|
|||
|
|
|||
|
--更新
|
|||
|
function TeamSystem:Update(dt)
|
|||
|
if self.HanHuaCDTime > 0 then
|
|||
|
self.DeltaTime = self.DeltaTime + dt
|
|||
|
if self.DeltaTime >= 1 then
|
|||
|
self.DeltaTime = self.DeltaTime - 1
|
|||
|
self.HanHuaCDTime = self.HanHuaCDTime - 1
|
|||
|
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_UITEAMHANHUACD)
|
|||
|
end
|
|||
|
end
|
|||
|
if self.CuiCuCDTime > 0 then
|
|||
|
self.CuiCuDeltaTime = self.CuiCuDeltaTime - dt
|
|||
|
if self.CuiCuDeltaTime >= 1.0 then
|
|||
|
self.CuiCuDeltaTime = self.CuiCuDeltaTime - 1
|
|||
|
self.CuiCuCDTime = self.CuiCuCDTime - 1
|
|||
|
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_UITEAMCUICUCD)
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
if self.ApplyLeaderCDTime > 0 then
|
|||
|
self.ApplyLeaderDeltaTime = self.ApplyLeaderDeltaTime + dt
|
|||
|
if self.ApplyLeaderDeltaTime >= 1.0 then
|
|||
|
self.ApplyLeaderDeltaTime = self.ApplyLeaderDeltaTime - 1
|
|||
|
self.ApplyLeaderCDTime = self.ApplyLeaderCDTime - 1
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
return TeamSystem
|