using vnxbqy.UI;
|
using System;
|
using System.Collections.Generic;
|
using UnityEngine.UI;
|
using System.Linq;
|
using LitJson;
|
using UnityEngine;
|
using System.Collections;
|
|
|
//跨服排位赛的数据来源上一赛季的跨服天梯前64位
|
public class CrossServerQualifyingModel : ILModel<CrossServerQualifyingModel>
|
{
|
public const int DATA_MAPID = 32070;
|
public int selectIndex; // 跨服排位主标签选择
|
public int select64Index = 0; // 选中的64强比赛标签,非当前赛程
|
public List<uint> groupBtnMarks = new List<uint>() { 64, 32, 16 };//64强标签按钮对应的赛程
|
public List<uint> group8BtnMarks = new List<uint>() { 8, 4, 2 };//8强
|
public uint select64Mark
|
{
|
get { return groupBtnMarks[select64Index]; }
|
}
|
|
public int actID; // 活动ID,活动ID不同则可重置前端排位赛相关缓存数据
|
public int stateError; // 本次活动是否已经出现流程状态异常;如服务器异常或维护服务器导致跳过步骤,则会废弃该次比赛,直到下次新活动;
|
public int zoneID; //上一赛季所在的赛区ID, 以C015为准过滤其他不匹配的封包
|
public int officialZoneID; //官职相关所在赛区可能是上上赛季的赛区
|
|
//所有参赛者总名单
|
public Dictionary<uint, CrossChampionshipPKPlayer> fightersInfo = new Dictionary<uint, CrossChampionshipPKPlayer>();
|
//赛程对战列表 <赛程分组(如64强/32强),<赛程内分组, 分组信息>>
|
public Dictionary<uint, Dictionary<uint, CrossChampionshipPKBattle>> battleInfo = new Dictionary<uint, Dictionary<uint, CrossChampionshipPKBattle>>();
|
public event Action UpdateCrossChampionshipPKZoneGroupInfoEvent;
|
//当前赛程(如64强/32强),0代表不在比赛流程中
|
public uint nowGroupMark
|
{
|
get
|
{
|
var battleID = GetBattleID();
|
if (battleID == -1) return 0;
|
var state = ILChampionshipTimeConfig.Get(battleID).StateValue;
|
if (state == 80) return 64; //8强竞猜
|
if (state == 40) return 8; //四强竞猜
|
return (uint)state / 10;
|
}
|
}
|
|
public List<DateTime> openTimes = new List<DateTime>();
|
|
//竞猜公共和个人信息
|
public Dictionary<int, int> guess8Common = new Dictionary<int, int>();
|
public Dictionary<int, int> guess4Common = new Dictionary<int, int>();
|
public Dictionary<int, Int2> guess8Personal = new Dictionary<int, Int2>();
|
public Dictionary<int, Int2> guess4Personal = new Dictionary<int, Int2>(); //投注额度和名次
|
public List<int> guessPlayer64List = new List<int>();
|
public List<int> guessPlayer8List = new List<int>(); //8强名单,由16强列表中筛选胜者
|
public Dictionary<int, int> myGuessInfo = new Dictionary<int, int>();
|
public event Action UpdateGuessEvent;
|
|
public int guessMoneyType;
|
public int guessMoney;
|
public int guessMaxCnt;
|
public bool isNetPackRefreshGuess4; //界面打开的情况下 封包刷新不刷名次,避免玩家选名次后被刷0
|
//对阵表
|
public List<int> raceList = new List<int>() { 82, 82, 82, 82, 42, 42, 42, 42, 22, 22, 22, 22 };
|
|
//官职ID:官职信息
|
public Dictionary<int, ChampionshipOfficial> rankOfficialDict = new Dictionary<int, ChampionshipOfficial>();
|
|
public int myOfficialID = 0; //我的官职
|
public int selectOffcialID; //选中的界主官场
|
public int selectOffcialSub;//0上界 1中界
|
public int selectApplyOfficialID; //申请列表的仙官 或者查看挑战的仙官
|
//官职上下管理 界主下包含哪些官职分上中界
|
public Dictionary<int, List<List<int>>> offcialOperList = new Dictionary<int, List<List<int>>>();
|
public event Action UpdateOffcialEvent;
|
|
public int applyMaxTimes; //可同时申请的不同官位数量
|
public int applyPlayerMaxCnt; //一个官可以有几个玩家申请
|
public int offcialNeedRealm;
|
public int kickSeconds;
|
public int myApplyCnt;
|
|
Redpoint redpoint = new Redpoint(MainRedPoint.CrossServerQualifyingRedPoint);
|
public Redpoint mobaiRedpoint = new Redpoint(MainRedPoint.CrossServerQualifyingRedPoint, 4232);//膜拜
|
public Redpoint officialRedpoint = new Redpoint(MainRedPoint.CrossServerQualifyingRedPoint, 4233);
|
public Redpoint loginRedpoint = new Redpoint(MainRedPoint.CrossServerQualifyingRedPoint, 4239);//登录
|
|
public int worshipCntToday; //今日膜拜次数
|
public event Action UpdateWorshipEvent;
|
public int worshipMaxCnt;
|
public int[][] doubleTimeArr;
|
public int challengeMaxCnt; //挑战次数
|
|
public Action<uint, uint> QueryRaceScoreEvent; // 查询比分
|
|
DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
|
ServerMirrorFightModel mirrorFightModel { get { return ModelCenter.Instance.GetModel<ServerMirrorFightModel>(); } }
|
|
protected override void Init()
|
{
|
ParseConfig();
|
GameEvent.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize;
|
GlobalTimeEvent.Instance.minuteEvent += OnMinuteEvent;
|
GameEvent.playerLoginOkEvent += PlayerLoginOkEvent;
|
}
|
|
protected override void UnInit()
|
{
|
GameEvent.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitialize;
|
GlobalTimeEvent.Instance.minuteEvent -= OnMinuteEvent;
|
GameEvent.playerLoginOkEvent -= PlayerLoginOkEvent;
|
}
|
|
void ParseConfig()
|
{
|
var config = FuncConfigConfig.Get("CrossChamFB");
|
var openTimeArr = JsonMapper.ToObject<string[]>(config.Numerical1);
|
for (int i = 0; i < openTimeArr.Length; i++)
|
{
|
openTimes.Add(Convert.ToDateTime(openTimeArr[i]));
|
}
|
|
config = FuncConfigConfig.Get("CrossChamGuess");
|
var moneyInfo = config.Numerical1.Split('|');
|
guessMoneyType = int.Parse(moneyInfo[0]);
|
guessMoney = int.Parse(moneyInfo[1]);
|
guessMaxCnt = int.Parse(config.Numerical2);
|
|
for (int i = 1; i <= 8; i++)
|
{
|
var subArr = JsonMapper.ToObject<int[]>(ILChampionshipOfficialConfig.Get(i).JuniorOfficialIDList);
|
|
if (!offcialOperList.ContainsKey(i))
|
{
|
List<List<int>> tmp = new List<List<int>>();
|
tmp.Add(new List<int>());
|
tmp.Add(new List<int>());
|
offcialOperList[i] = tmp;
|
}
|
|
for (int j = 0; j < subArr.Length; j++)
|
{
|
if (ILChampionshipOfficialConfig.Get(subArr[j]).CanBeReplace == 0)
|
{
|
//上界
|
offcialOperList[i][0].Add(subArr[j]);
|
}
|
else
|
{
|
//中界
|
offcialOperList[i][1].Add(subArr[j]);
|
}
|
}
|
}
|
|
config = FuncConfigConfig.Get("CrossChamOfficial");
|
applyPlayerMaxCnt = int.Parse(config.Numerical1);
|
applyMaxTimes = int.Parse(config.Numerical2);
|
offcialNeedRealm = int.Parse(config.Numerical3);
|
kickSeconds = int.Parse(config.Numerical4);
|
|
config = FuncConfigConfig.Get("CrossChamWorship");
|
worshipMaxCnt = int.Parse(config.Numerical1);
|
doubleTimeArr = JsonMapper.ToObject<int[][]>(config.Numerical3);
|
|
config = FuncConfigConfig.Get("CrossChamMirrorPK");
|
challengeMaxCnt = int.Parse(config.Numerical1);
|
}
|
|
|
//下一次开启时间
|
public int GetNextOpenTimeIndex()
|
{
|
for (int i = 0; i < openTimes.Count; i++)
|
{
|
if (ILTimeUtility.ServerCrossNow < openTimes[i])
|
{
|
return i;
|
}
|
}
|
|
return -1;
|
}
|
|
//获取当前开启阶段
|
public int GetOpenTimeIndex()
|
{
|
if (openTimes.Count == 0) return -1;
|
var index = 0;
|
for (int i = 0; i < openTimes.Count; i++)
|
{
|
if (ILTimeUtility.ServerCrossNow < openTimes[i])
|
{
|
return index;
|
}
|
index = i;
|
}
|
|
return index;
|
}
|
|
//界面可打开的情况,判断是否赛程中
|
public bool IsOpen()
|
{
|
if (stateError != 0)
|
{
|
return false;
|
}
|
|
if (fightersInfo.Count == 0)
|
{
|
return false;
|
}
|
|
return true;
|
}
|
|
public void UpdateCrossChampionshipPKZoneGroupInfo(HC015_tagGCCrossChampionshipPKZoneGroupInfo netPack)
|
{
|
stateError = netPack.StateError;
|
|
if (actID != (int)netPack.ActID)
|
{
|
actID = (int)netPack.ActID;
|
zoneID = netPack.ZoneID;
|
fightersInfo.Clear();
|
battleInfo.Clear();
|
}
|
|
for (int i = 0; i < netPack.PlayerList.Length; i++)
|
{
|
var player = netPack.PlayerList[i];
|
fightersInfo[player.PlayerID] = new CrossChampionshipPKPlayer()
|
{
|
PlayerID = player.PlayerID,
|
PlayerName = player.PlayerName,
|
FightPower = (long)player.FightPowerEx * (long)Constants.ExpPointValue + player.FightPower,
|
Job = player.Job,
|
LV = player.LV,
|
Face = player.Face,
|
FacePic = player.FacePic,
|
};
|
}
|
|
for (int i = 0; i < netPack.GroupList.Length; i++)
|
{
|
var group = netPack.GroupList[i];
|
if (!battleInfo.ContainsKey(group.GroupMark))
|
{
|
battleInfo[group.GroupMark] = new Dictionary<uint, CrossChampionshipPKBattle>();
|
}
|
for (int j = 0; j < group.BattleList.Length; j++)
|
{
|
var battleList = group.BattleList[j];
|
battleInfo[group.GroupMark][battleList.BattleNum] = new CrossChampionshipPKBattle()
|
{
|
BattleNum = battleList.BattleNum,
|
WinPlayerID = battleList.WinPlayerID,
|
PlayerIDA = battleList.PlayerIDA,
|
PlayerIDB = battleList.PlayerIDB,
|
battleResult = ConfigParse.ParseIntArray2Dict(battleList.BattleRet),
|
};
|
}
|
}
|
|
UpdateCrossChampionshipPKZoneGroupInfoEvent?.Invoke();
|
}
|
|
|
public void OnBeforePlayerDataInitialize()
|
{
|
actID = 0;
|
zoneID = 0;
|
officialZoneID = 0;
|
fightersInfo.Clear();
|
battleInfo.Clear();
|
guessPlayer8List.Clear();
|
guessPlayer64List.Clear();
|
guess8Common.Clear();
|
guess4Common.Clear();
|
guess8Personal.Clear();
|
guess4Personal.Clear();
|
myGuessInfo.Clear();
|
rankOfficialDict.Clear();
|
myOfficialID = 0;
|
myApplyCnt = 0;
|
worshipCntToday = 0;
|
pushGroupMark = 0;
|
isShowRaceInfoYet = false;
|
}
|
|
//获取当前的比赛赛程节点,-1代表当前时间不在排位赛流程中
|
public int GetBattleID()
|
{
|
var index = GetOpenTimeIndex();
|
if (index == -1) return -1;
|
var startDay = openTimes[index];
|
if (startDay > ILTimeUtility.ServerCrossNow)
|
{
|
//流程未开始
|
return -1;
|
}
|
//第一天 从1开始
|
var passDays = (ILTimeUtility.ServerCrossNow - startDay).Days + 1;
|
|
var keys = ILChampionshipTimeConfig.GetKeys();
|
//流程结束
|
if (ILChampionshipTimeConfig.Get(keys[keys.Count - 1]).StartDay < passDays)
|
return -1;
|
for (int i = 0; i < keys.Count; i++)
|
{
|
var config = ILChampionshipTimeConfig.Get(keys[i]);
|
if (passDays != config.StartDay && config.EndDay == config.StartDay)
|
continue;
|
|
var startTime = startDay.AddDays(config.StartDay - 1).AddSeconds(config.StartHour * 60 * 60 + config.StartMinute * 60);
|
var endTime = startDay.AddDays(config.EndDay - 1).AddSeconds(config.EndHour * 60 * 60 + config.EndMinute * 60 + 59);
|
if (ILTimeUtility.ServerCrossNow >= startTime && ILTimeUtility.ServerCrossNow <= endTime)
|
return int.Parse(keys[i]);
|
}
|
|
return -1;
|
}
|
|
//获取流程的开始时间
|
public string GetStartBattleTime(int battleID)
|
{
|
var index = GetOpenTimeIndex();
|
if (index == -1) return string.Empty;
|
var startDay = openTimes[index];
|
|
var config = ILChampionshipTimeConfig.Get(battleID);
|
var startTime = startDay.AddDays(config.StartDay - 1).AddSeconds(config.StartHour * 60 * 60 + config.StartMinute * 60);
|
|
return startTime.ToString("yyyy-MM-dd HH:mm");
|
}
|
|
//获取流程的结束时间 分钟,负数代表未开始
|
public double GetRaceEndRemindMinute(int battleID)
|
{
|
var index = GetOpenTimeIndex();
|
if (index == -1) return -1;
|
var startDay = openTimes[index];
|
|
var config = ILChampionshipTimeConfig.Get(battleID);
|
var endTime = startDay.AddDays(config.StartDay - 1).AddSeconds(config.EndHour * 60 * 60 + config.EndMinute * 60);
|
|
return (endTime - ILTimeUtility.ServerCrossNow).TotalMinutes;
|
}
|
|
public struct CrossChampionshipPKPlayer
|
{
|
public uint PlayerID;
|
public string PlayerName;
|
public byte Job;
|
public long FightPower;
|
public ushort LV;
|
public ushort RealmLV;
|
public uint Face; //基本脸型
|
public uint FacePic; //头像框
|
}
|
|
public struct CrossChampionshipPKBattle
|
{
|
public byte BattleNum; // 对战组编号 1~n
|
public uint WinPlayerID; // 获胜玩家ID
|
public uint PlayerIDA; // 玩家IDA
|
public uint PlayerIDB; // 玩家IDB
|
public Dictionary<int, int[][]> battleResult; // 战斗结果明细 {"playerID":[[第1局胜负,第1局总积分,胜负基础分,hp分,时间分], ...], ...}
|
}
|
|
public struct ChampionshipOfficial
|
{
|
public uint LastDismissJuniorTime; // 上次辞退下级仙官时间戳,跨服时间,如果自己是本界主时,用于计算辞退CD
|
public uint WorshipCount; // 被膜拜次数
|
public byte WorshipDouble; // 今日是否双倍膜拜,仅在规定时间点内有用
|
public CrossChampionshipPKPlayer OfficialPlayer; // 任职玩家信息,可能没有
|
public List<CrossChampionshipPKPlayer> ApplyPlayerList; // 申请该仙官玩家列表
|
}
|
|
|
//进入跨服排位赛,借用跨服竞技1v1模拟
|
public void EnterCrossServerQualifying()
|
{
|
uint tagPlayerID;
|
var battleResult = GetMyBattleInfo(nowGroupMark, out tagPlayerID);
|
int challengeCnt = battleResult.ContainsKey((int)PlayerDatas.Instance.baseData.PlayerID) ? battleResult[(int)PlayerDatas.Instance.baseData.PlayerID].Length : 0;
|
if (challengeCnt >= challengeMaxCnt)
|
{
|
SysNotifyMgr.Instance.ShowTip("CrossServerQualifying11");
|
return;
|
}
|
|
int error;
|
if (!dungeonModel.CanEnter(out error))
|
{
|
dungeonModel.ProcessEnterError(error);
|
return;
|
}
|
|
|
var teamModel = ModelCenter.Instance.GetModel<TeamModel>();
|
if (teamModel.isMatching)
|
{
|
teamModel.RequestCancelAutoMatchTeam();
|
}
|
|
|
var otherPlayerInfo = fightersInfo[tagPlayerID];
|
|
var opponent = new HC001_tagGCCrossRealmPKMatchOK.tagGCCrossRealmPKMatchPlayer();
|
opponent.Job = otherPlayerInfo.Job;
|
opponent.PlayerName = otherPlayerInfo.PlayerName;
|
opponent.PlayerID = otherPlayerInfo.PlayerID;
|
|
opponent.LV = otherPlayerInfo.LV;
|
opponent.RealmLV = otherPlayerInfo.RealmLV;
|
opponent.Face = otherPlayerInfo.Face;
|
opponent.FacePic = otherPlayerInfo.FacePic;
|
opponent.FightPower = (uint)((ulong)otherPlayerInfo.FightPower % Constants.ExpPointValue);
|
opponent.FightPowerEx = (uint)((ulong)otherPlayerInfo.FightPower / Constants.ExpPointValue);
|
|
CrossServerLogin.Instance.InitOneVsOnePlayerInfo(opponent);
|
mirrorFightModel.SendMirrorFight(DATA_MAPID, (ushort)(zoneID * 100 + nowGroupMark), tagPlayerID, 0);
|
return;
|
}
|
|
//查找自己是否有比赛,包含竞猜 分组和战斗结束的缓存时间
|
public bool HaveMyBattle(uint groupMark)
|
{
|
if (battleInfo.ContainsKey(groupMark))
|
{
|
var playerID = PlayerDatas.Instance.baseData.PlayerID;
|
var battle = battleInfo[groupMark];
|
var battleNums = battle.Keys.ToList();
|
for (int i = 0; i < battleNums.Count; i++)
|
{
|
var battleNum = battleNums[i];
|
//搜索玩家是否参赛者
|
if (battle[battleNum].PlayerIDA == playerID || battle[battleNum].PlayerIDB == playerID)
|
{
|
return true;
|
}
|
}
|
}
|
|
return false;
|
}
|
|
// 8强之前,查找玩家的下一场比赛,胜出未分组前也算
|
public int GetMyNextBattle()
|
{
|
int nextGroupMark = 0;
|
bool haveBattle = false;
|
for (int k = 0; k < groupBtnMarks.Count; k++)
|
{
|
var groupMark = groupBtnMarks[k];
|
nextGroupMark = (int)groupMark;
|
if (battleInfo.ContainsKey(groupMark))
|
{
|
var playerID = PlayerDatas.Instance.baseData.PlayerID;
|
var battle = battleInfo[groupMark];
|
var battleNums = battle.Keys.ToList();
|
for (int i = 0; i < battleNums.Count; i++)
|
{
|
var battleNum = battleNums[i];
|
//搜索玩家是否参赛者
|
if (battle[battleNum].WinPlayerID == playerID)
|
{
|
haveBattle = true;
|
continue;
|
}
|
if (battle[battleNum].PlayerIDA == playerID || battle[battleNum].PlayerIDB == playerID)
|
{
|
haveBattle = true;
|
return nextGroupMark;
|
}
|
}
|
}
|
}
|
|
return haveBattle ? nextGroupMark : 0;
|
}
|
|
|
//当前的比赛比分情况
|
public Dictionary<int, int[][]> GetMyBattleInfo(uint groupMark, out uint tagPlayerID)
|
{
|
tagPlayerID = 0;
|
if (battleInfo.ContainsKey(groupMark))
|
{
|
var playerID = PlayerDatas.Instance.baseData.PlayerID;
|
var battle = battleInfo[groupMark];
|
var battleNums = battle.Keys.ToList();
|
for (int i = 0; i < battleNums.Count; i++)
|
{
|
var battleNum = battleNums[i];
|
|
if (battle[battleNum].PlayerIDA == playerID || battle[battleNum].PlayerIDB == playerID)
|
{
|
tagPlayerID = battle[battleNum].PlayerIDA == playerID ? battle[battleNum].PlayerIDB : battle[battleNum].PlayerIDA;
|
return battle[battleNum].battleResult;
|
}
|
}
|
}
|
|
return null;
|
}
|
|
public CrossChampionshipPKBattle QueryPKScoreInfoByPlayerID(uint groupMark, uint playerID)
|
{
|
if (battleInfo.ContainsKey(groupMark))
|
{
|
var battle = battleInfo[groupMark];
|
var battleNums = battle.Keys.ToList();
|
for (int i = 0; i < battleNums.Count; i++)
|
{
|
var battleNum = battleNums[i];
|
if (battle[battleNum].PlayerIDA == playerID || battle[battleNum].PlayerIDB == playerID)
|
{
|
return battle[battleNum];
|
}
|
}
|
}
|
|
return new CrossChampionshipPKBattle();
|
}
|
|
|
|
|
public uint WinnerID; // 胜方ID
|
public int score;
|
|
public void UpdatePKResult()
|
{
|
if (dungeonModel.dungeonResult.isWin == 1)
|
{
|
WinnerID = PlayerDatas.Instance.baseData.PlayerID;
|
}
|
else
|
{
|
WinnerID = 0;
|
}
|
|
score = dungeonModel.dungeonResult.addScore;
|
|
if (WindowCenter.Instance.IsOpen<FightingPKWin>())
|
{
|
WindowCenter.Instance.Close<FightingPKWin>();
|
}
|
WindowCenter.Instance.OpenIL<CrossServerQualifyingSettlementWin>();
|
}
|
|
|
|
//竞猜公共信息:支持人数
|
public void UpdateGuessCommon(IL_HC022_tagGCChampionshipGuessPubInfo netPack)
|
{
|
for (int i = 0; i < netPack.GuessList.Length; i++)
|
{
|
if (netPack.GuessList[i].GuessType == 8)
|
{
|
for (int j = 0; j < netPack.GuessList[i].GuessPlayerList.Length; j++)
|
{
|
var player = netPack.GuessList[i].GuessPlayerList[j];
|
guess8Common[(int)player.PlayerID] = (int)player.SupportCount;
|
}
|
}
|
else if (netPack.GuessList[i].GuessType == 4)
|
{
|
for (int j = 0; j < netPack.GuessList[i].GuessPlayerList.Length; j++)
|
{
|
var player = netPack.GuessList[i].GuessPlayerList[j];
|
guess4Common[(int)player.PlayerID] = (int)player.SupportCount;
|
}
|
}
|
}
|
|
UpdateGuessEvent?.Invoke();
|
}
|
|
//竞猜个人信息:投注额度和名次
|
public void UpdateGuessPersonal(IL_HC023_tagGCChampionshipGuessPriInfo netPack)
|
{
|
for (int i = 0; i < netPack.GuessList.Length; i++)
|
{
|
if (netPack.GuessList[i].GuessType == 8)
|
{
|
for (int j = 0; j < netPack.GuessList[i].GuessPlayerList.Length; j++)
|
{
|
var player = netPack.GuessList[i].GuessPlayerList[j];
|
guess8Personal[(int)player.PlayerID] = new Int2((int)player.MoneyTotal, player.GuessRank);
|
}
|
}
|
else if (netPack.GuessList[i].GuessType == 4)
|
{
|
for (int j = 0; j < netPack.GuessList[i].GuessPlayerList.Length; j++)
|
{
|
var player = netPack.GuessList[i].GuessPlayerList[j];
|
guess4Personal[(int)player.PlayerID] = new Int2((int)player.MoneyTotal, player.GuessRank);
|
if (player.GuessRank != 0)
|
{
|
myGuessInfo[player.GuessRank] = (int)player.PlayerID;
|
}
|
}
|
}
|
}
|
|
UpdateGuessEvent?.Invoke();
|
}
|
|
////竞猜列表顺序,是否投注-战力-玩家ID
|
public void Player64ListSort()
|
{
|
guessPlayer64List.Clear();
|
|
var tList = fightersInfo.Keys.ToList();
|
for (int i = 0; i < tList.Count; i++)
|
{
|
guessPlayer64List.Add((int)tList[i]);
|
}
|
guessPlayer64List.Sort(CompareGuess64);
|
return;
|
}
|
|
int CompareGuess64(int idA, int idB)
|
{
|
bool isGuessA = guess8Personal.ContainsKey(idA);
|
bool isGusssB = guess8Personal.ContainsKey(idB);
|
|
if (isGuessA != isGusssB)
|
{
|
return isGusssB.CompareTo(isGuessA);
|
}
|
|
long fightPowerA = fightersInfo[(uint)idA].FightPower;
|
long fightPowerB = fightersInfo[(uint)idB].FightPower;
|
|
if (fightPowerA != fightPowerB)
|
{
|
return fightPowerB.CompareTo(fightPowerA);
|
}
|
|
return idA.CompareTo(idB);
|
}
|
|
//8强名单来源于 16强淘汰赛后的胜者
|
public void Player8ListSort()
|
{
|
if (!battleInfo.ContainsKey(16))
|
{
|
return;
|
}
|
guessPlayer8List.Clear();
|
var tList = battleInfo[16].Keys.ToList();
|
for (int i = 0; i < tList.Count; i++)
|
{
|
var battle = battleInfo[16][tList[i]];
|
if (battle.WinPlayerID != 0)
|
{
|
guessPlayer8List.Add((int)battle.WinPlayerID);
|
}
|
}
|
|
guessPlayer8List.Sort(CompareGuess8);
|
return;
|
}
|
|
int CompareGuess8(int idA, int idB)
|
{
|
bool isGuessA = guess4Personal.ContainsKey(idA);
|
bool isGusssB = guess4Personal.ContainsKey(idB);
|
|
if (isGuessA != isGusssB)
|
{
|
return isGusssB.CompareTo(isGuessA);
|
}
|
|
long fightPowerA = fightersInfo[(uint)idA].FightPower;
|
long fightPowerB = fightersInfo[(uint)idB].FightPower;
|
|
if (fightPowerA != fightPowerB)
|
{
|
return fightPowerB.CompareTo(fightPowerA);
|
}
|
|
return idA.CompareTo(idB);
|
}
|
|
public bool isShowRaceInfoYet = false; //是否已经显示过赛程信息小提示
|
uint pushGroupMark = 0; //每场比赛只推送一次
|
void OnMinuteEvent()
|
{
|
if (!WindowCenter.Instance.IsOpen("CrossServerQualifyingWin") &&
|
dungeonModel.GetDataMapIdByMapId(PlayerDatas.Instance.baseData.MapID) != DATA_MAPID)
|
{
|
uint nowMark = nowGroupMark;
|
//准备入场的时候推送
|
if (pushGroupMark != nowMark && HaveMyBattle(nowMark))
|
{
|
int battleID = GetBattleID();
|
if (ILChampionshipTimeConfig.Get(battleID).StateValue % 10 == 2)
|
{
|
HeroControler.Instance.FuncPush(210);
|
pushGroupMark = nowMark;
|
}
|
}
|
}
|
}
|
|
//官职
|
public void UpdateOfficialInfo(HC018_tagGCChampionshipOfficialInfo netPack)
|
{
|
officialZoneID = netPack.ZoneID;
|
var playerID = PlayerDatas.Instance.baseData.PlayerID;
|
for (int i = 0; i < netPack.OfficialList.Length; i++)
|
{
|
var officialInfo = netPack.OfficialList[i];
|
List<CrossChampionshipPKPlayer> applyList = new List<CrossChampionshipPKPlayer>();
|
|
for (int j = 0; j < officialInfo.ApplyPlayerList.Length; j++)
|
{
|
applyList.Add(new CrossChampionshipPKPlayer()
|
{
|
PlayerID = officialInfo.ApplyPlayerList[j].PlayerID,
|
Job = officialInfo.ApplyPlayerList[j].Job,
|
PlayerName = officialInfo.ApplyPlayerList[j].PlayerName,
|
FightPower = officialInfo.ApplyPlayerList[j].FightPowerEx * (long)Constants.ExpPointValue + officialInfo.ApplyPlayerList[j].FightPower,
|
RealmLV = officialInfo.ApplyPlayerList[j].RealmLV,
|
Face = officialInfo.ApplyPlayerList[j].Face,
|
FacePic = officialInfo.ApplyPlayerList[j].FacePic,
|
});
|
}
|
|
rankOfficialDict[(int)officialInfo.OfficialID] = new ChampionshipOfficial()
|
{
|
LastDismissJuniorTime = officialInfo.LastDismissJuniorTime,
|
WorshipCount = officialInfo.WorshipCount,
|
WorshipDouble = officialInfo.WorshipDouble,
|
|
OfficialPlayer = new CrossChampionshipPKPlayer()
|
{
|
PlayerID = officialInfo.OfficialPlayer.PlayerID,
|
Job = officialInfo.OfficialPlayer.Job,
|
PlayerName = officialInfo.OfficialPlayer.PlayerName,
|
FightPower = officialInfo.OfficialPlayer.FightPowerEx * (long)Constants.ExpPointValue + officialInfo.OfficialPlayer.FightPower,
|
RealmLV = officialInfo.OfficialPlayer.RealmLV,
|
Face = officialInfo.OfficialPlayer.Face,
|
FacePic = officialInfo.OfficialPlayer.FacePic,
|
},
|
|
ApplyPlayerList = applyList,
|
};
|
if (myOfficialID == (int)officialInfo.OfficialID && playerID != (int)officialInfo.OfficialPlayer.PlayerID)
|
{
|
//被辞退了
|
myOfficialID = 0;
|
officialRedpoint.state = RedPointState.Simple;
|
LocalSave.SetInt("myOfficialID", 0);
|
}
|
if (playerID == (int)officialInfo.OfficialPlayer.PlayerID)
|
{
|
myOfficialID = (int)officialInfo.OfficialID;
|
if (LocalSave.GetInt("myOfficialID") == 0 && ILChampionshipOfficialConfig.Get(myOfficialID).CanBeReplace == 0)
|
{
|
//申请通过
|
officialRedpoint.state = RedPointState.Simple;
|
}
|
LocalSave.SetInt("myOfficialID", myOfficialID);
|
}
|
}
|
RefreshMyApplyCnt();
|
RefreshRedPoint();
|
UpdateOffcialEvent?.Invoke();
|
}
|
|
//界主的申请列表红点
|
void RefreshRedPoint()
|
{
|
RefreshMobaiRedpoint();
|
if (myOfficialID > 0 && myOfficialID <= 8)
|
{
|
officialRedpoint.state = RedPointState.None;
|
//写死了前4个申请
|
for (int i = 0; i < 4; i++)
|
{
|
var id = myOfficialID * 100 + i + 1;
|
if (GetOfficialPlayer(id).PlayerID != 0)
|
{
|
return;
|
}
|
if (rankOfficialDict.ContainsKey(id) && rankOfficialDict[id].ApplyPlayerList.Count != 0)
|
{
|
officialRedpoint.state = RedPointState.Simple;
|
}
|
}
|
}
|
}
|
|
void RefreshMyApplyCnt()
|
{
|
if (myOfficialID != 0)
|
{
|
myApplyCnt = 0;
|
return;
|
}
|
var playerID = PlayerDatas.Instance.baseData.PlayerID;
|
var keys = rankOfficialDict.Keys.ToList();
|
myApplyCnt = 0;
|
for (int i = 0; i < keys.Count; i++)
|
{
|
var applyList = rankOfficialDict[keys[i]].ApplyPlayerList;
|
for (int j = 0; j < applyList.Count; j++)
|
{
|
if (playerID == applyList[j].PlayerID)
|
{
|
myApplyCnt++;
|
}
|
}
|
}
|
}
|
|
public CrossChampionshipPKPlayer GetOfficialPlayer(int officialID)
|
{
|
|
if (!rankOfficialDict.ContainsKey(officialID))
|
return new CrossChampionshipPKPlayer();
|
|
return rankOfficialDict[officialID].OfficialPlayer;
|
}
|
|
public int GeDefaultOffcialSub()
|
{
|
if (myOfficialID <= 8)
|
return 0;
|
if (offcialOperList[selectOffcialID][1].IndexOf(myOfficialID) != -1)
|
{
|
return 1;
|
}
|
return 0;
|
}
|
|
public bool IsInApply(int officialID)
|
{
|
var playerID = PlayerDatas.Instance.baseData.PlayerID;
|
if (!rankOfficialDict.ContainsKey(officialID))
|
{
|
return false;
|
}
|
var applyList = rankOfficialDict[officialID].ApplyPlayerList;
|
for (int i = 0; i < applyList.Count; i++)
|
{
|
if (applyList[i].PlayerID == playerID)
|
{
|
return true;
|
}
|
}
|
return false;
|
}
|
|
public void UpdateChampionshipOfficialChallengeRet(IL_HC020_tagGCChampionshipOfficialChallengeRet netPack)
|
{
|
string tip;
|
if (netPack.Ret == 0)
|
tip = "CrossServerQualifying59";
|
else if (netPack.Ret == 1)
|
tip = "CrossServerQualifying61";
|
else
|
tip = "CrossServerQualifying60";
|
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get(tip));
|
}
|
|
public void UpdateChampionshipOfficialApplyReplyRet(IL_HC019_tagGCChampionshipOfficialApplyReplyRet netPack)
|
{
|
if (netPack.IsOK == 1)
|
{
|
SysNotifyMgr.Instance.ShowTip("CrossServerQualifying9");
|
}
|
else
|
{
|
SysNotifyMgr.Instance.ShowTip("CrossServerQualifying10");
|
}
|
}
|
|
public string challengeRecord;
|
public void UpdateChampionshipOfficialChallengeRecordInfo(IL_HC021_tagGCChampionshipOfficialChallengeRecordInfo netPack)
|
{
|
for (int i = 0; i < netPack.RecordList.Length; i++)
|
{
|
var record = netPack.RecordList[i];
|
if (record.Ret == 1)
|
{
|
challengeRecord += Language.Get("CrossServerQualifying62",
|
TimeUtility.GetTime(record.ChallengeTime).ToString("yyyy-MM-dd HH:mm:ss"), record.PlayerName);
|
}
|
else
|
{
|
challengeRecord += Language.Get("CrossServerQualifying63",
|
TimeUtility.GetTime(record.ChallengeTime).ToString("yyyy-MM-dd HH:mm:ss"), record.PlayerName);
|
}
|
}
|
WindowCenter.Instance.OpenIL<CrossServerQualifyingOfficialNoteWin>();
|
}
|
|
|
public void UpdateWorship(IL_HC109_tagMCChampionshipPlayerInfo netPack)
|
{
|
worshipCntToday = netPack.WorshipCount;
|
RefreshMobaiRedpoint();
|
UpdateWorshipEvent?.Invoke();
|
}
|
|
bool queryKai = false; //进入游戏后请求一次即可
|
uint lastGroupMark = 0; //从非0到0说明需要更新界主
|
public List<uint> playerIDList = new List<uint>();
|
|
//查询界主信息
|
public void QueryAllKaiKingInfo()
|
{
|
if (queryKai)
|
{
|
if (!(lastGroupMark != 0 && nowGroupMark == 0))
|
{
|
return;
|
}
|
}
|
|
playerIDList.Clear();
|
for (int i = 1; i <= 8; i++)
|
{
|
var playerID = GetOfficialPlayer(i).PlayerID;
|
if (playerID == 0)
|
break;
|
playerIDList.Add(playerID);
|
}
|
if (playerIDList.IsNullOrEmpty())
|
return;
|
|
SnxxzGame.Instance.StartCoroutine(PlayerQuery());
|
lastGroupMark = nowGroupMark;
|
queryKai = true;
|
}
|
|
private IEnumerator PlayerQuery()
|
{
|
for (int i = 0; i < playerIDList.Count; i++)
|
{
|
QueryKaiKingInfo(playerIDList[i]);
|
yield return null;
|
}
|
}
|
|
public void QueryKaiKingInfo(uint playerID)
|
{
|
ModelCenter.Instance.GetModel<RoleParticularModel>().ViewCrossPlayerCacheData((int)playerID);
|
}
|
|
void PlayerLoginOkEvent()
|
{
|
RefreshMobaiRedpoint();
|
loginRedpoint.state = RedPointState.Simple;
|
}
|
|
void RefreshMobaiRedpoint()
|
{
|
mobaiRedpoint.state = RedPointState.None;
|
if (rankOfficialDict.Count == 0)
|
return;
|
for (int i = 1; i <= 8; i++)
|
{
|
if (GetOfficialPlayer(1).PlayerID != 0)
|
{
|
//有膜拜对象且有次数
|
if (worshipCntToday < worshipMaxCnt)
|
{
|
mobaiRedpoint.state = RedPointState.Simple;
|
}
|
return;
|
}
|
}
|
|
}
|
}
|