Files
Main/Assets/GameAssets/Resources/Lua/Logic/ArenaShouXi/ArenaShouXiSystem.lua
2025-01-25 04:38:09 +08:00

438 lines
13 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

------------------------------------------------
--作者xihan
--日期2019-05-28
--文件ArenaShouXiSystem.lua
--模块ArenaShouXiSystem
--描述:首席竞技场系统
------------------------------------------------
local RedPointCustomCondition = CS.Thousandto.Code.Logic.RedPointCustomCondition;
local ArenaShouXiSystem = {
--购买次数
BuyCount = 0,
IsWaiteSecKill = false,
IsMiaoSha = false,
WaiteTime = 3,
WaiteTick = 0,
LeftTime = 0,
}
local L_Sort = table.sort
local L_Tonumber = tonumber;
local L_SplitStr = Utils.SplitStr;
local L_Send = GameCenter.Network.Send;
--积分
local L_Score = nil;
--排名
local L_Rank = nil;
--剩余次数
local L_RemainCount = nil;
--剩余CD时间
local L_RemainCD = nil;
--挑战玩家
local L_FightPlayers = nil;
--记录保持者
local L_TopPlayers = nil;
--战斗记录
local L_Reports = nil;
--昨日排名
local L_YesterdayRank = nil;
--是否离开竞技场地图
local L_IsLevelArenaMap = nil;
--当前目标ID
local L_TargetID = nil;
--战斗结果
local L_BattleReport = nil;
--重置每日排名的剩余时间
local L_RemainTimeByResetRank = nil;
--首次排名奖励
local L_FistRankAward = nil;
--首次排名需要展示的数据
local L_ShowData = nil;
--系统初始化
function ArenaShouXiSystem:Initialize()
L_Score = 0;
L_Rank = 0;
L_RemainCount = 0;
L_RemainCD = 0;
end
--系统卸载
function ArenaShouXiSystem:UnInitialize()
L_Score = 0;
L_Rank = 0;
L_RemainCount = 0;
L_RemainCD = 0;
L_FightPlayers = nil;
L_TopPlayers = nil;
L_Reports = nil;
L_YesterdayRank = nil;
L_IsLevelArenaMap = false;
L_TargetID = 0;
L_BattleReport = nil;
end
--刷新小红点
function ArenaShouXiSystem:RefreshRedPoint()
GameCenter.RedPointSystem:RemoveFuncCondition(FunctionStartIdCode.ArenaShouXi, 0)
local _haveAward = false;
if L_FistRankAward then
local _curRank = L_FistRankAward.rank;
local _awardList = L_FistRankAward.rewardList or {};
DataConfig.DataJJCRank:Foreach(function(k, v)
if k ~= 1 then
if v.PosMax >= _curRank and _curRank ~= nil and _curRank ~= 0 and v.FirstRewardItem ~= "" then
local isEqual = false
for i=1,#_awardList do
if v.Id == _awardList[i] then
isEqual = true
end
end
if not isEqual then
_haveAward = true
end
end
end
end)
end
if _haveAward then
GameCenter.RedPointSystem:AddFuncCondition(FunctionStartIdCode.ArenaShouXi, 0, RedPointCustomCondition(true));
end
end
--刷新次数小红点
function ArenaShouXiSystem:RefreshCountRedPoint()
GameCenter.RedPointSystem:RemoveFuncCondition(FunctionStartIdCode.ArenaShouXi, 1)
if L_RemainCount > 0 then
GameCenter.RedPointSystem:AddFuncCondition(FunctionStartIdCode.ArenaShouXi, 1, RedPointCustomCondition(true));
end
end
--刷新购买小红点
function ArenaShouXiSystem:RefreshBuyRedPoint()
GameCenter.RedPointSystem:RemoveFuncCondition(FunctionStartIdCode.ArenaShouXi, 2)
local totalBuyCount = GameCenter.VipSystem:GetCurVipPowerParam(23)
if totalBuyCount > self.BuyCount then
GameCenter.RedPointSystem:AddFuncCondition(FunctionStartIdCode.ArenaShouXi, 2, RedPointCustomCondition(true));
end
end
--获取积分
function ArenaShouXiSystem:GetScore()
return L_Score;
end
--获取排名
function ArenaShouXiSystem:GetRank()
return L_Rank;
end
--剩余次数
function ArenaShouXiSystem:GetRemainCount()
return L_RemainCount;
end
--剩余时间
function ArenaShouXiSystem:GetRemainCD()
return L_RemainCD;
end
--挑战玩家
function ArenaShouXiSystem:GetFightPlayers()
return L_FightPlayers;
end
--记录保持者
function ArenaShouXiSystem:GetTopPlayers()
return L_TopPlayers;
end
--战斗记录
function ArenaShouXiSystem:GetReports()
return L_Reports;
end
--昨日排名
function ArenaShouXiSystem:GetYesterdayRank()
return L_YesterdayRank;
end
--是否离开竞技场地图
function ArenaShouXiSystem:IsLevelArenaMap()
return L_IsLevelArenaMap;
end
--当前目标ID
function ArenaShouXiSystem:GetTargetID()
return L_TargetID;
end
--获取挑战玩家的战斗力
function ArenaShouXiSystem:GetFightPowerByTarget(targetId)
if L_FightPlayers ~= nil then
for i = 1, #L_FightPlayers do
if L_FightPlayers[i].roleID == targetId then
return L_FightPlayers[i].fightPower
end
end
end
end
--战斗结果
function ArenaShouXiSystem:GetBattleReport()
return L_BattleReport;
end
--首次排名奖励信息
function ArenaShouXiSystem:GetFistRankAward()
return L_FistRankAward
end
--获取首次奖励展示数据
function ArenaShouXiSystem:GetShowData()
if not L_ShowData then
L_ShowData = List:New();
DataConfig.DataJJCRank:Foreach(function(_, v)
if v.FirstRewardItem and v.FirstRewardItem ~= "" and v.Id ~= 1 then
local _item = {};
_item.Config = v;
_item.Id = v.Id
_item.RewardState = self:GetAwardState(v.Id)
_item.Awards = List:New();
local _t = L_SplitStr(v.FirstRewardItem, ";_");
for i=1,#_t, 2 do
_item.Awards:Add({tonumber(_t[i]),tonumber(_t[i+1])});
end
L_ShowData:Add(_item);
end
end)
else
for i = 1,#L_ShowData do
L_ShowData[i].RewardState = self:GetAwardState(L_ShowData[i].Config.Id)
end
end
--对数据排序
L_ShowData:Sort(function(a,b)
return a.Config.PosMax > b.Config.PosMax
end )
for i = 1, #L_ShowData do
for j = 1, #L_ShowData - i do
if L_ShowData[j].RewardState > L_ShowData[j + 1].RewardState then
local temp = L_ShowData[j + 1];
L_ShowData[j + 1] = L_ShowData[j];
L_ShowData[j] = temp;
end
end
end
return L_ShowData;
end
--获取是否已领取奖励
function ArenaShouXiSystem:GetAwardState(id)
if L_FistRankAward.rank == 0 then
return ArenaSXFirstAwardEnum.None
end
if L_FistRankAward then
local _cfg = DataConfig.DataJJCRank[id];
local _curRank = L_FistRankAward.rank;
if _cfg.PosMax < _curRank then
return ArenaSXFirstAwardEnum.None;
else
local _awardList = L_FistRankAward.rewardList or {};
for i=1,#_awardList do
if _cfg.Id == _awardList[i] then
return ArenaSXFirstAwardEnum.Finish;
end
end
return ArenaSXFirstAwardEnum.CanGet;
end
end
return ArenaSXFirstAwardEnum.None;
end
function ArenaShouXiSystem:Update(dt)
if self.IsWaiteSecKill then
if self.WaiteTick<self.WaiteTime then
self.WaiteTick = self.WaiteTick + dt
else
self.IsWaiteSecKill = false
self.WaiteTick = 0
end
end
end
--====[msg]====[msg]====[msg]====[msg]====[msg]====[msg]====[msg]====[msg]====[msg]====[msg]====[msg]====[msg]====[msg]====
--================[Req]================[Req]================[Req]================[Req]================[Req]================
--打开jjc
function ArenaShouXiSystem:ReqOpenJJC()
GameCenter.PushFixEvent(UIEventDefine.UI_WAITING_OPEN, DataConfig.DataMessageString.Get("ArenaLoadingTips"));
L_Send("MSG_JJC.ReqOpenJJC");
end
--更换对手
function ArenaShouXiSystem:ReqChangeTarget()
GameCenter.PushFixEvent(UIEventDefine.UI_WAITING_OPEN, DataConfig.DataMessageString.Get("ArenaLoadingTips"));
L_Send("MSG_JJC.ReqChangeTarget");
end
--挑战
function ArenaShouXiSystem:ReqChallenge(targetID, isSecKill)
if L_RemainCount <= 0 then
Utils.ShowPromptByEnum("CountNotEnough")
else
--uint64 targetID
if isSecKill then
self.IsWaiteSecKill = true
self.WaiteTick = 0
end
L_Send("MSG_JJC.ReqChallenge",{targetID = targetID, seckill = isSecKill});
end
end
--领奖
function ArenaShouXiSystem:ReqGetAward()
GameCenter.PushFixEvent(UIEventDefine.UI_WAITING_OPEN);
L_Send("MSG_JJC.ReqGetAward");
end
--添加挑战次数
function ArenaShouXiSystem:ReqAddChance()
GameCenter.PushFixEvent(UIEventDefine.UI_WAITING_OPEN);
L_Send("MSG_JJC.ReqAddChance");
end
--获取昨天排名
function ArenaShouXiSystem:ReqGetYesterdayRank()
GameCenter.PushFixEvent(UIEventDefine.UI_WAITING_OPEN);
L_Send("MSG_JJC.ReqGetYesterdayRank");
end
--获取战报
function ArenaShouXiSystem:ReqGetReport()
GameCenter.PushFixEvent(UIEventDefine.UI_WAITING_OPEN);
L_Send("MSG_JJC.ReqGetReport");
end
--退出jjc
function ArenaShouXiSystem:ReqJJCexit()
if GameCenter.GameSceneSystem.ActivedScene.MapId == 8000 then
GameCenter.PushFixEvent(UIEventDefine.UI_WAITING_OPEN);
L_Send("MSG_JJC.ReqJJCexit");
else
--GameCenter.PushFixEvent(UIEventDefine.UIArenaShouXiForm_Close);
end;
end
--请求一键扫荡
function ArenaShouXiSystem:ReqOneKeySweep()
L_Send("MSG_JJC.ReqOneKeySweep");
end
--获取首次排名奖励
function ArenaShouXiSystem:ReqGetFirstReward(excelId)
GameCenter.PushFixEvent(UIEventDefine.UI_WAITING_OPEN);
L_Send("MSG_JJC.ReqGetFirstReward",{excelId = excelId})
end
--================[Res]================[Res]================[Res]================[Res]================[Res]================
--打开竞技场UI界面获取的信息
function ArenaShouXiSystem:ResOpenJJCresult(msg)
GameCenter.PushFixEvent(UIEventDefine.UI_WAITING_CLOSE);
L_Rank = msg.rank;
L_RemainCount = msg.count;
L_RemainCD = msg.cd;
L_Score = msg.score;
self:RefreshCountRedPoint()
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_JJC_UPDATECOUNT);
L_FightPlayers = List:New(msg.players);
L_TopPlayers = List:New(msg.rank123);
--排序
L_FightPlayers:Sort(function(a,b)
return a.rank>b.rank
end);
L_TopPlayers:Sort(function(a,b)
return a.rank>b.rank
end);
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_JJC_UPDATEPLAYERS);
end
--更新挑战次数、排名
function ArenaShouXiSystem:ResUpdateChance(msg)
GameCenter.PushFixEvent(UIEventDefine.UI_WAITING_CLOSE);
L_Rank = msg.rank;
L_RemainCount = msg.count;
L_RemainCD = msg.cd;
self:RefreshCountRedPoint()
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_JJC_UPDATECOUNT);
end
--更换挑战对象
function ArenaShouXiSystem:ResUpdatePlayers(msg)
GameCenter.PushFixEvent(UIEventDefine.UI_WAITING_CLOSE);
L_FightPlayers = List:New(msg.players);
L_TopPlayers = List:New(msg.rank123);
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_JJC_UPDATEPLAYERS);
end
--返回昨日排名
function ArenaShouXiSystem:ResYesterdayRank(msg)
GameCenter.PushFixEvent(UIEventDefine.UI_WAITING_CLOSE);
L_YesterdayRank = msg.rank;
L_RemainTimeByResetRank = msg.time;
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_JJC_UPDATEYESTERDAY_RANK,msg.rank);
end
--返回战报数据
function ArenaShouXiSystem:ResReports(msg)
GameCenter.PushFixEvent(UIEventDefine.UI_WAITING_CLOSE);
L_Reports = List:New(msg.reports);
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_JJC_RECORDUPDATE);
end
--竞技场通知
function ArenaShouXiSystem:ResJJCTargetID(msg)
GameCenter.PushFixEvent(UIEventDefine.UI_WAITING_CLOSE);
L_TargetID = msg.targetID;
end
--结算界面
function ArenaShouXiSystem:ResJJCBattleReport(msg)
GameCenter.PushFixEvent(UIEventDefine.UI_WAITING_CLOSE);
L_BattleReport = msg;
L_Score = L_Score + msg.score;
L_Rank = msg.curRank;
--关闭倒计时界面
GameCenter.PushFixEvent(UIEventDefine.UIArenaSXCountdownForm_Close)
if self.IsMiaoSha then
self.IsMiaoSha = false
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_JJC_MIAOSHA_RESULT)
else
GameCenter.PushFixEvent(UIEventDefine.UIArenaSXResultForm_OPEN)
end
end
--上线发送jjc提示信息
function ArenaShouXiSystem:ResOnlineJJCInfo(msg)
L_RemainCount = msg.r_count;
self:RefreshCountRedPoint()
end
--挑战开始返回
function ArenaShouXiSystem:ResStartBattleRes(msg)
GameCenter.PushFixEvent(UIEventDefine.UI_WAITING_CLOSE);
--关闭界面
GameCenter.PushFixEvent(UIEventDefine.UIArenaForm_Close);
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_JJC_FIGHTSTART)
end
--首次达到排名奖励
function ArenaShouXiSystem:ResGetFirstReward(msg)
GameCenter.PushFixEvent(UIEventDefine.UI_WAITING_CLOSE);
L_FistRankAward = msg;
ArenaShouXiSystem:RefreshRedPoint();
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_JJC_UPDATECOUNT);
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_JJC_FIRSTAWARD);
end
function ArenaShouXiSystem:ResBuyJJCTimes(msg)
self.BuyCount = msg.buyTimes
self:RefreshBuyRedPoint()
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_JJC_UPDATECOUNT)
end
return ArenaShouXiSystem;