using vnxbqy.UI;
|
using System;
|
using System.Collections.Generic;
|
using UnityEngine.UI;
|
using System.Linq;
|
using LitJson;
|
using UnityEngine;
|
using System.Text.RegularExpressions;
|
|
//跨服
|
public class ILCrossServerModel : ILModel<ILCrossServerModel>
|
{
|
|
public int commZoneID; // 所属常规分区ID;用于跨服BOSS分区等,不包含跨服竞技场
|
|
TeamModel teamModel { get { return ModelCenter.Instance.GetModel<TeamModel>(); } }
|
DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
|
AchievementModel achievementModel { get { return ModelCenter.Instance.GetModel<AchievementModel>(); } }
|
|
|
|
public bool isLoginOk = false;
|
protected override void Init()
|
{
|
GameEvent.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize;
|
GlobalTimeEvent.Instance.minuteEvent += OnMinute;
|
achievementModel.achievementAwardableEvent += AchievementAwardableEvent;
|
achievementModel.achievementCompletedEvent += AchievementCompletedEvent;
|
GameEvent.playerLoginOkEvent += OnPlayerLoginOk;
|
ParseConfig();
|
}
|
|
protected override void UnInit()
|
{
|
GameEvent.beforePlayerDataInitializeEvent -= OnBeforePlayerDataInitialize;
|
GameEvent.playerLoginOkEvent -= OnPlayerLoginOk;
|
GlobalTimeEvent.Instance.minuteEvent -= OnMinute;
|
achievementModel.achievementAwardableEvent -= AchievementAwardableEvent;
|
achievementModel.achievementCompletedEvent -= AchievementCompletedEvent;
|
}
|
|
void ParseConfig()
|
{
|
var config = FuncConfigConfig.Get("CrossBattlefieldOpen");
|
var sysTimes = JsonMapper.ToObject<int[][]>(config.Numerical1);
|
for (int i = 0; i < sysTimes.Length; i++)
|
{
|
crossBattleFieldOpenTimes.Add(new Int3(sysTimes[i][0], sysTimes[i][1], 0));
|
}
|
|
var playerTimes = JsonMapper.ToObject<int[][]>(config.Numerical2);
|
if (playerTimes != null)
|
{
|
for (int i = 0; i < playerTimes.Length; i++)
|
{
|
crossBattleFieldOpenTimes.Add(new Int3(playerTimes[i][0], playerTimes[i][1], 1));
|
}
|
}
|
crossBattleFieldOpenTimes.Sort(sortTimes);
|
|
stopBuyTime = int.Parse(config.Numerical4);
|
|
config = FuncConfigConfig.Get("CrossBattlefieldFB");
|
processTime = JsonMapper.ToObject<int[]>(config.Numerical1)[1] / 60;
|
|
config = FuncConfigConfig.Get("CrossBattlefieldAwardSuper");
|
var tmpItemShow = JsonMapper.ToObject<int[][]>(config.Numerical1);
|
for (int i = 0; i < tmpItemShow.Length; i++)
|
{
|
itemsShow.Add(new ItemEx()
|
{
|
id = tmpItemShow[i][1],
|
count = tmpItemShow[i][2],
|
bind = tmpItemShow[i][3],
|
});
|
}
|
contributionMaxValue = int.Parse(config.Numerical2);
|
|
config = FuncConfigConfig.Get("CrossBattlefieldBillboardJoin");
|
var _jsonData = JsonMapper.ToObject(config.Numerical2);
|
var keyList = _jsonData.Keys.ToList();
|
|
rankAwardDict[151] = new Dictionary<int, List<ItemEx>>();
|
for (int i = 0; i < keyList.Count; i++)
|
{
|
var rankIndex = int.Parse(keyList[i]);
|
var _itemArray = JsonMapper.ToObject<int[][]>(_jsonData[keyList[i]].ToJson());
|
List<ItemEx> _award = new List<ItemEx>();
|
for (int j = 0; j < _itemArray.Length; j++)
|
{
|
_award.Add(new ItemEx(_itemArray[j][0], _itemArray[j][1], _itemArray[j][2]));
|
}
|
rankAwardDict[151][rankIndex] = _award;
|
}
|
|
_jsonData = JsonMapper.ToObject(config.Numerical4);
|
keyList = _jsonData.Keys.ToList();
|
|
for (int i = 0; i < keyList.Count; i++)
|
{
|
var rankIndex = int.Parse(keyList[i]);
|
var _itemArray = JsonMapper.ToObject<int[]>(_jsonData[keyList[i]].ToJson());
|
cyBillMoneyDict[rankIndex] = _itemArray;
|
}
|
|
|
|
config = FuncConfigConfig.Get("CrossBattlefieldBillboard");
|
_jsonData = JsonMapper.ToObject(config.Numerical2);
|
keyList = _jsonData.Keys.ToList();
|
|
rankAwardDict[152] = new Dictionary<int, List<ItemEx>>();
|
for (int i = 0; i < keyList.Count; i++)
|
{
|
var rankIndex = int.Parse(keyList[i]);
|
var _itemArray = JsonMapper.ToObject<int[][]>(_jsonData[keyList[i]].ToJson());
|
List<ItemEx> _award = new List<ItemEx>();
|
for (int j = 0; j < _itemArray.Length; j++)
|
{
|
_award.Add(new ItemEx(_itemArray[j][0], _itemArray[j][1], _itemArray[j][2]));
|
}
|
rankAwardDict[152][rankIndex] = _award;
|
}
|
|
_jsonData = JsonMapper.ToObject(config.Numerical3);
|
keyList = _jsonData.Keys.ToList();
|
|
rankAwardDict[153] = new Dictionary<int, List<ItemEx>>();
|
for (int i = 0; i < keyList.Count; i++)
|
{
|
var rankIndex = int.Parse(keyList[i]);
|
var _itemArray = JsonMapper.ToObject<int[][]>(_jsonData[keyList[i]].ToJson());
|
List<ItemEx> _award = new List<ItemEx>();
|
for (int j = 0; j < _itemArray.Length; j++)
|
{
|
_award.Add(new ItemEx(_itemArray[j][0], _itemArray[j][1], _itemArray[j][2]));
|
}
|
rankAwardDict[153][rankIndex] = _award;
|
}
|
|
config = FuncConfigConfig.Get("CrossBattlefieldBuyOpen");
|
callItemID = int.Parse(config.Numerical2);
|
callAward = JsonMapper.ToObject<int[][]>(config.Numerical3);
|
|
ParseFightConfig();
|
ParseSuccessConfig();
|
}
|
|
int sortTimes(Int3 timeA, Int3 timeB)
|
{
|
if (timeA[0] != timeB[0])
|
return timeA[0].CompareTo(timeB[0]);
|
|
return timeA[1].CompareTo(timeB[1]);
|
}
|
|
|
public void OnBeforePlayerDataInitialize()
|
{
|
crossBattleFieldBuyDict.Clear();
|
BuyOpenCountToday = 0;
|
HighScoreToday = 0;
|
EnterCountWeek = 0;
|
BuyOpenCountWeek = 0;
|
HighScoreTotalWeek = 0;
|
newCallMark = Int2.zero;
|
selectJumpIndex = 0;
|
isLoginOk = false;
|
}
|
|
|
public void RequestExit()
|
{
|
var match = new CC104_tagCMExitCrossRealm();
|
GameNetSystem.Instance.SendToCrossServer(match);
|
}
|
|
public bool CanEnter(out int error)
|
{
|
var mapId = PlayerDatas.Instance.baseData.MapID;
|
var mapConfig = MapConfig.Get(mapId);
|
if (mapConfig.MapFBType != (int)MapType.OpenCountry)
|
{
|
error = 1;
|
return false;
|
}
|
|
if (teamModel.isMatching)
|
{
|
error = 2;
|
return false;
|
}
|
|
if (teamModel.teamPrepare.isPreparing)
|
{
|
error = 3;
|
return false;
|
}
|
|
if (CrossServerLogin.Instance.IsEnterCrossServerPreparing())
|
{
|
error = 4;
|
return false;
|
}
|
|
var deadModel = ModelCenter.Instance.GetModel<PlayerDeadModel>();
|
if (deadModel.playerIsDie)
|
{
|
error = 5;
|
return false;
|
}
|
if (PlayerDatas.Instance.extersion.bossState == 1)
|
{
|
error = 6;
|
return false;
|
}
|
|
if (CrossServerUtility.IsCrossServer())
|
{
|
error = 7;
|
return false;
|
}
|
error = 0;
|
return true;
|
}
|
|
public void ProcessEnterError(int error)
|
{
|
switch (error)
|
{
|
case 1:
|
SysNotifyMgr.Instance.ShowTip("InDungeon_CantGo");
|
break;
|
case 2:
|
SysNotifyMgr.Instance.ShowTip("CrossMap1");
|
break;
|
case 3:
|
SysNotifyMgr.Instance.ShowTip("CrossMap2");
|
break;
|
case 4:
|
SysNotifyMgr.Instance.ShowTip("CrossMap3");
|
break;
|
case 5:
|
SysNotifyMgr.Instance.ShowTip("CrossMap4");
|
break;
|
case 6:
|
SysNotifyMgr.Instance.ShowTip("CrossMap11");
|
break;
|
case 7:
|
SysNotifyMgr.Instance.ShowTip("CrossMap10");
|
break;
|
}
|
}
|
|
public void RequestEnter(int mapID)
|
{
|
|
if (!AssetVersionUtility.IsUnpriorAssetDownLoadOk())
|
{
|
InGameDownLoad.Instance.TryDownLoad(InGameDownLoad.Dominant.Whole);
|
return;
|
}
|
|
var sendInfo = new CC105_tagCMEnterCrossServer();
|
sendInfo.DataMapID = (uint)mapID;
|
GameNetSystem.Instance.SendInfo(sendInfo);
|
}
|
|
#region 跨服古神战场-入口
|
|
DailyQuestModel dailyQuestModel { get { return ModelCenter.Instance.GetModel<DailyQuestModel>(); } }
|
RankModel rankModel { get { return ModelCenter.Instance.GetModel<RankModel>(); } }
|
|
public int gszcMapID = 32060;
|
|
public event Action UpdateBuyInfoEvent;
|
|
//活动开启时间int3 = 时 分 类型(0系统1玩家)
|
public List<Int3> crossBattleFieldOpenTimes = new List<Int3>();
|
public int processTime; //游戏运行时间(分),此时间也当作游戏进行中和可进入时间,比实际少了准备时间
|
public int stopBuyTime; //开启前几分钟禁止购买
|
|
//玩家召集信息
|
public Dictionary<Int2, List<IL_HC009_tagGCCrossBattlefieldBuyInfo.tagGCCrossBattlefieldBuyPlayer>> crossBattleFieldBuyDict = new Dictionary<Int2, List<IL_HC009_tagGCCrossBattlefieldBuyInfo.tagGCCrossBattlefieldBuyPlayer>>();
|
public List<ItemEx> itemsShow = new List<ItemEx>(); //大奖
|
public int contributionMaxValue; // 大奖贡献上限
|
public List<int> rankTypes = new List<int>() { 151, 152, 153 };
|
public int selectRankIndex = 0; //选中的排行榜索引
|
|
public event Action onSelectUpdate;
|
int m_SelectIndex = 0; //已确定选择活动场次
|
public int selectIndex
|
{
|
get { return m_SelectIndex; }
|
set
|
{
|
if (m_SelectIndex != value)
|
{
|
m_SelectIndex = value;
|
if (onSelectUpdate != null)
|
{
|
onSelectUpdate();
|
}
|
}
|
}
|
}
|
|
public int selectJumpIndex; //外面跳转
|
|
public event Action onSelectActionCellUpdate;
|
int m_SelectActionCell = 0; //场次点击
|
public int selectActionCell
|
{
|
get { return m_SelectActionCell; }
|
set
|
{
|
if (m_SelectActionCell != value)
|
{
|
m_SelectActionCell = value;
|
onSelectActionCellUpdate?.Invoke();
|
}
|
}
|
}
|
|
public byte BuyOpenCountToday; // 今日已购买开启战场次数
|
public uint HighScoreToday; // 今日最高积分
|
public uint EnterCountWeek; // 本周总参与次数
|
public uint BuyOpenCountWeek; // 本周总购买召集次数
|
public uint HighScoreTotalWeek; // 本周每日最高分累加总分
|
|
//排行榜奖励
|
Dictionary<int, Dictionary<int, List<ItemEx>>> rankAwardDict = new Dictionary<int, Dictionary<int, List<ItemEx>>>();
|
public Dictionary<int, int[]> cyBillMoneyDict = new Dictionary<int, int[]>(); //参与榜才有的货币奖励
|
|
public int callItemID = 0;
|
public int[][] callAward;
|
public const int openUIMark = 2080000;
|
public int zoneID = 0;
|
|
//古神战场是否开启
|
public bool IsOpen()
|
{
|
return FuncOpen.Instance.IsFuncOpen(208)
|
&& TimeUtility.OpenDay >= GeneralDefine.crossServerBattleFieldOpenDay
|
//&& CrossServerOneVsOnePKSeason.Instance.InPkSeason(TimeUtility.ServerNow)
|
&& InOpenTime();
|
}
|
|
//不包含系统开启的,判断是否在开放赛季内,非当天开放时间
|
//public bool IsOpenEx()
|
//{
|
// return FuncOpen.Instance.IsFuncOpen(208)
|
// && TimeUtility.OpenDay >= afterOpenDayOpenCrossBattle;
|
// //&& CrossServerOneVsOnePKSeason.Instance.InPkSeason(TimeUtility.ServerNow);
|
//}
|
|
|
|
|
|
public void UpdatePlayerInfo(HC107_tagMCCrossBattlefieldPlayerInfo netPack)
|
{
|
BuyOpenCountToday = netPack.BuyOpenCountToday;
|
HighScoreToday = netPack.HighScoreToday;
|
EnterCountWeek = netPack.EnterCountWeek;
|
BuyOpenCountWeek = netPack.BuyOpenCountWeek;
|
HighScoreTotalWeek = netPack.HighScoreTotalWeek;
|
zoneID = netPack.ZoneID;
|
}
|
|
|
public string GetFirstRankName(int type)
|
{
|
var datas = rankModel.GetRankPageDatas(type);
|
if (datas != null && datas.ContainsKey(0))
|
{
|
return datas[0].name1;
|
}
|
|
return Language.Get("CrossBattleField37");
|
|
}
|
|
|
public bool InOpenTime()
|
{
|
List<HourMinute> hourMinutes = GetActivityTimes();
|
if (hourMinutes != null)
|
{
|
for (int i = 0; i < hourMinutes.Count; i++)
|
{
|
if (hourMinutes[i].InOpenTime())
|
{
|
return true;
|
}
|
}
|
}
|
|
return false;
|
}
|
|
public List<HourMinute> GetActivityTimes()
|
{
|
DailyQuestOpenTime _openTime = null;
|
dailyQuestModel.TryGetOpenTime((int)DailyQuestType.default4, out _openTime);
|
var dayOfWeek = (int)TimeUtility.ServerNow.DayOfWeek;
|
Dictionary<int, List<HourMinute>> keyValues = null;
|
if (_openTime != null)
|
{
|
keyValues = _openTime.NormalOpenTimes;
|
if (keyValues.ContainsKey(dayOfWeek))
|
{
|
return keyValues[dayOfWeek];
|
}
|
}
|
return null;
|
}
|
|
|
//获得指定场次的状态
|
//系统 :0待开启,1进行中,2已结束
|
//玩家:
|
//开启前5分钟无法购买
|
//无人购买: 3召集中(去召集) 4无人开启 2已结束
|
//有人购买: 0待开启 1进行中 2已结束
|
public int GetActionState(int index)
|
{
|
if (index < 0)
|
{
|
//传入了次日的标识-1
|
index = 0;
|
}
|
int nowTime = ILTimeUtility.ServerCrossNow.Hour * 60 + ILTimeUtility.ServerCrossNow.Minute;
|
int openTime = crossBattleFieldOpenTimes[index].x * 60 + crossBattleFieldOpenTimes[index].y;
|
|
if (crossBattleFieldOpenTimes[index].z == 0)
|
{
|
//系统开启的
|
if (nowTime < openTime)
|
{
|
return 0;
|
}
|
else if (nowTime < openTime + processTime)
|
{
|
return 1;
|
}
|
|
return 2;
|
}
|
else
|
{
|
//开启前5分钟无法购买
|
//无人购买: 3召集中(去召集) 4无人开启 2已结束
|
//有人购买: 0待开启 1进行中 2已结束
|
Int2 timeInt2 = new Int2(crossBattleFieldOpenTimes[index].x, crossBattleFieldOpenTimes[index].y);
|
int buyCnt;
|
if (!crossBattleFieldBuyDict.ContainsKey(timeInt2))
|
{
|
buyCnt = 0;
|
}
|
else
|
{
|
buyCnt = crossBattleFieldBuyDict[timeInt2].Count;
|
}
|
if (nowTime < openTime - stopBuyTime)
|
{
|
//2人购买进入开启状态
|
return buyCnt == 2 ? 0 : 3;
|
}
|
else if (nowTime < openTime)
|
{
|
return buyCnt > 0 ? 0 : 4;
|
}
|
else if (nowTime < openTime + processTime)
|
{
|
return buyCnt > 0 ? 1 : 4; ;
|
}
|
|
return 2;
|
}
|
}
|
|
|
//获得最接近场次索引
|
public int GetCurBattleFieldIndex()
|
{
|
|
int nowTime = ILTimeUtility.ServerCrossNow.Hour * 60 + ILTimeUtility.ServerCrossNow.Minute;
|
for (int i = 0; i < crossBattleFieldOpenTimes.Count; i++)
|
{
|
int openTime = crossBattleFieldOpenTimes[i].x * 60 + crossBattleFieldOpenTimes[i].y + processTime;
|
if (nowTime <= openTime)
|
return i;
|
}
|
|
//次日 过0点后方可召集
|
return -1;
|
}
|
|
public bool IsInFactionCall()
|
{
|
var int3Config = crossBattleFieldOpenTimes[selectIndex];
|
if (int3Config.z == 0)
|
{
|
return false;
|
}
|
|
Int2 timeInt2 = new Int2(int3Config.x, int3Config.y);
|
if (!crossBattleFieldBuyDict.ContainsKey(timeInt2))
|
{
|
return false;
|
}
|
|
for (int i = 0; i < crossBattleFieldBuyDict[timeInt2].Count; i++)
|
{
|
var buyInfo = crossBattleFieldBuyDict[timeInt2][i];
|
for (int j = 0; j < buyInfo.FactionPlayerList.Length; j++)
|
{
|
if (buyInfo.FactionPlayerList[j].PlayerID == PlayerDatas.Instance.baseData.PlayerID)
|
{
|
return true;
|
}
|
}
|
}
|
|
return false;
|
}
|
|
int tipTime = 10; //服务器有限制进场时间,客户端只对应上线是否弹窗提示
|
public Int2 newCallMark = Int2.zero; //有新的场次购买者(双方都算)
|
|
public void UpdateCrossBattlefieldBuyInfo(IL_HC009_tagGCCrossBattlefieldBuyInfo netPack)
|
{
|
if (netPack.HMCount == 0)
|
{
|
crossBattleFieldBuyDict.Clear();
|
}
|
newCallMark = Int2.zero;
|
|
for (int i = 0; i < netPack.HMBuyList.Length; i++)
|
{
|
Int2 callMark = new Int2(netPack.HMBuyList[i].Hour, netPack.HMBuyList[i].Minute);
|
|
//1.未过期的时间(凌晨5点后有效) 2.筛选时间最近的场次 3.场次中有对方阵营购买者
|
if (ILTimeUtility.ServerCrossNow.Hour >= 5 && (ILTimeUtility.ServerCrossNow.Hour < callMark.x ||
|
(ILTimeUtility.ServerCrossNow.Hour == callMark.x && ILTimeUtility.ServerCrossNow.Minute < callMark.y + tipTime)))
|
{
|
if (newCallMark.x == 0 || newCallMark.x > callMark.x ||
|
(newCallMark.x == callMark.x && newCallMark.y > callMark.y))
|
{
|
if (!crossBattleFieldBuyDict.ContainsKey(callMark))
|
{
|
newCallMark = callMark;
|
}
|
else if (crossBattleFieldBuyDict[callMark].Count != netPack.HMBuyList[i].BuyPlayerList.Length)
|
{
|
newCallMark = callMark;
|
}
|
}
|
}
|
|
crossBattleFieldBuyDict[callMark] = netPack.HMBuyList[i].BuyPlayerList.ToList();
|
}
|
|
if (newCallMark != Int2.zero)
|
{
|
HeroControler.Instance.FuncPush(208);
|
}
|
|
UpdateBuyInfoEvent?.Invoke();
|
}
|
|
//活动开启的时候需要通知一次
|
void OnMinute()
|
{
|
var keyList = crossBattleFieldBuyDict.Keys.ToList();
|
for (int i = 0; i < keyList.Count; i++)
|
{
|
var key = keyList[i];
|
if (ILTimeUtility.ServerCrossNow.Hour == key.x && ILTimeUtility.ServerCrossNow.Minute == key.y)
|
{
|
newCallMark = key;
|
HeroControler.Instance.FuncPush(208);
|
ILFuncNotifyBehaviour.m_FuncBtn.Display(); //强推一次
|
return;
|
}
|
}
|
}
|
|
|
public string GetLeaderName(int faction, Int2 time, out int num)
|
{
|
num = 0;
|
if (!crossBattleFieldBuyDict.ContainsKey(time))
|
{
|
return string.Empty;
|
}
|
for (int i = 0; i < crossBattleFieldBuyDict[time].Count; i++)
|
{
|
var data = crossBattleFieldBuyDict[time][i];
|
if (data.Faction == faction)
|
{
|
var findID = data.BuyPlayerID;
|
num = data.FactionPlayerCount;
|
for (int j = 0; j < data.FactionPlayerList.Length; j++)
|
{
|
if (data.FactionPlayerList[j].PlayerID == findID)
|
{
|
return data.FactionPlayerList[j].PlayerName.Trim().Replace("\0", "");
|
}
|
}
|
}
|
}
|
|
return string.Empty;
|
}
|
|
public Dictionary<int, List<ItemEx>> GetRankAwards(int rankType)
|
{
|
return rankAwardDict[rankType];
|
}
|
|
#endregion
|
|
#region 跨服古神战场-战斗
|
|
public int[][] crystalSortFaction; //按阵营水晶图标对应NPC的顺序
|
public Dictionary<int, List<int>> crystaPosDict = new Dictionary<int, List<int>>(); //灰色水晶坐标
|
public event Action WorldInfoEvent;
|
public event Action FactionInfEvent;
|
public event Action PlayerInfoEvent;
|
|
|
// worldInfo {
|
// "crystalFactionInfo": {"30908101": 1, "30908103": 2}, 资源水晶NPCID对应所属阵营 {"npcID":所属阵营
|
// "crystalAtkedList":[30908103, 30908101], 正在被攻击中的资源水晶NPCID列表,可能为空[]
|
// "eventNPCPos": [170, 18], 随机事件NPC坐标,可用于寻路
|
// "eventNPCHP": 4, 随机事件NPC当前血量,可用于展示采集积分墙剩余次数,boss血量百分比等, 仅积分墙、boss事件中该key有下发
|
// "eventEndTick":39234, 事件结束剩余时间,单位毫秒,目前积分光环事件有用到,可用于展示剩余多长时间,仅积分光环事件中该key有下发
|
// "factionBuffNPCInfo": [30908110, 105, 130], 未采集的阵营buff信息,无可采集的阵营buff时为空列表[], [npcID, 坐标x, y]
|
// "eventNPCID": 30908105, 随机事件NPCID
|
// "superItemInfo": [3519, 2, 0], 本场次大奖信息[物品ID, 个数, 是否拍品]
|
// },
|
|
//3 4.双方阵营信息
|
//两个key factionInfo_1 和 factionInfo_2, 子内容key一样
|
// {"factionBuffInfo": [7005, 1645419755], 阵营受影响的阵营buff信息,可能增益或减益[buffID, buff结束时间戳]
|
// "score": 4400, 阵营总积分
|
// "superItemProgress": 1000, 阵营大奖进度值
|
// "superItemPlayerName": "", 阵营获奖玩家名
|
// "faction": 2 阵营ID
|
// , "hurtBossValue": 20496000, 阵营对boss伤害值,仅有伤害时该key有下发
|
// }
|
|
//5.玩家自身信息
|
//playerInfo
|
//{
|
// "itemRebornCount": 0, 已使用物品原地复活次数
|
// "score": 2200, 本场次玩家积分
|
// "killCount": 2, 本场次累计击杀数
|
// "continueKillCount": 0, 连杀数
|
// "superItemContribution": 0 玩家对本阵营大奖进度贡献度,
|
// "addScore": [5000, 2, 1]}, 玩家获得积分,仅玩家获得积分时有该key,所以当有该key值时,可进行获得积分展示,详见下面获得积分内容及类型说明
|
// },
|
//0319里的数据
|
public Dictionary<int, int> warCrystalDict = new Dictionary<int, int>(); //水晶npcid对应阵营
|
public List<int> crystalAtkedList = new List<int>();
|
public List<int> eventNPCPos = new List<int>();
|
public long eventNPCHP;
|
public int eventEndTick;
|
public List<int> factionBuffNPCInfo = new List<int>();
|
public int eventNPCID;
|
public List<int> superItemInfo = new List<int>();
|
public FactionInfo factionInfo_1 = new FactionInfo() { factionBuffInfo = new List<int>(), };
|
public FactionInfo factionInfo_2 = new FactionInfo() { factionBuffInfo = new List<int>(), };
|
public PlayerInfo playerInfo = new PlayerInfo() { addScore = new List<int>(), };
|
|
public int CrossBattlefieldScoreAuraID; //光环ID
|
public int CrossBattlefieldScoreWallID; //墙ID
|
public int CrossBattlefieldBossID; //召集bossID
|
public int CrossBattlefieldWinScore;
|
public int CrossBattlefieldRebornItemID;
|
public int CrossBattlefieldRebornCount; //dungeonRebornClientTimes倒计时时间
|
public int startAuraTime; //用于光环倒计时
|
|
public int seeFaction; //比赛结果查看的阵营方战绩
|
public int[][] winFactionAwards;
|
public int[][] defeatFactionAwards;
|
public Dictionary<int, List<ItemEx>> winRankAwards = new Dictionary<int, List<ItemEx>>();
|
public Dictionary<int, List<ItemEx>> defeatRankAwards = new Dictionary<int, List<ItemEx>>();
|
|
|
private void ParseFightConfig()
|
{
|
var config = FuncConfigConfig.Get("CrossBattlefieldCrystal");
|
var json = JsonMapper.ToObject(config.Numerical1);
|
var keyList = json.Keys.ToList();
|
for (int i = 0; i < keyList.Count; i++)
|
{
|
var key = keyList[i];
|
crystaPosDict[int.Parse(key)] = JsonMapper.ToObject<int[]>(json[key].ToJson()).ToList();
|
}
|
crystalSortFaction = JsonMapper.ToObject<int[][]>(config.Numerical4);
|
|
CrossBattlefieldScoreAuraID = int.Parse(FuncConfigConfig.Get("CrossBattlefieldScoreAura").Numerical1);
|
CrossBattlefieldScoreWallID = int.Parse(FuncConfigConfig.Get("CrossBattlefieldScoreWall").Numerical1);
|
CrossBattlefieldBossID = int.Parse(FuncConfigConfig.Get("CrossBattlefieldBoss").Numerical1);
|
|
CrossBattlefieldWinScore = int.Parse(FuncConfigConfig.Get("CrossBattlefieldScoreBase").Numerical1);
|
CrossBattlefieldRebornItemID = int.Parse(FuncConfigConfig.Get("CrossBattlefieldReborn").Numerical1);
|
CrossBattlefieldRebornCount = int.Parse(FuncConfigConfig.Get("CrossBattlefieldReborn").Numerical2);
|
|
|
var awardConfig = FuncConfigConfig.Get("CrossBattlefieldAward");
|
|
winFactionAwards = JsonMapper.ToObject<int[][]>(awardConfig.Numerical4);
|
defeatFactionAwards = JsonMapper.ToObject<int[][]>(awardConfig.Numerical5);
|
var awardJson = JsonMapper.ToObject(awardConfig.Numerical2);
|
keyList = awardJson.Keys.ToList();
|
for (int i = 0; i < keyList.Count; i++)
|
{
|
var key = keyList[i];
|
var itemArr = JsonMapper.ToObject<int[][]>(awardJson[key].ToJson());
|
List<ItemEx> awards = new List<ItemEx>();
|
for (int j = 0; j < itemArr.Length; j++)
|
{
|
awards.Add(new ItemEx
|
{
|
id = itemArr[j][0],
|
count = itemArr[j][1],
|
bind = itemArr[j][2],
|
});
|
}
|
winRankAwards[int.Parse(key)] = awards;
|
}
|
|
awardJson = JsonMapper.ToObject(awardConfig.Numerical3);
|
keyList = awardJson.Keys.ToList();
|
for (int i = 0; i < keyList.Count; i++)
|
{
|
var key = keyList[i];
|
var itemArr = JsonMapper.ToObject<int[][]>(awardJson[key].ToJson());
|
List<ItemEx> awards = new List<ItemEx>();
|
for (int j = 0; j < itemArr.Length; j++)
|
{
|
awards.Add(new ItemEx
|
{
|
id = itemArr[j][0],
|
count = itemArr[j][1],
|
bind = itemArr[j][2],
|
});
|
}
|
defeatRankAwards[int.Parse(key)] = awards;
|
}
|
|
}
|
|
|
public struct FBResult
|
{
|
public FactionInfoList[] factionInfoList;
|
public int costTime;
|
public int winnerFaction;
|
public string finalSuperItemPlayerName;
|
public int score;
|
public int faction;
|
public int rank;
|
}
|
|
public struct FactionInfoList
|
{
|
public RankPlayerInfo[] rankPlayerList;
|
public string callPlayerName;
|
public string superItemPlayerName;
|
public int faction;
|
}
|
|
|
public struct RankPlayerInfo
|
{
|
public int job;
|
public int score;
|
public int killCount;
|
public string name;
|
public int crystalCollCnt;
|
}
|
|
FBResult m_DungeonResult;
|
public FBResult dungeonResult
|
{
|
get { return m_DungeonResult; }
|
set { m_DungeonResult = value; }
|
}
|
|
public void UpdateFBResult(string msg)
|
{
|
if (dungeonModel.GetDataMapIdByMapId(PlayerDatas.Instance.baseData.MapID) != gszcMapID)
|
return;
|
m_DungeonResult = JsonMapper.ToObject<FBResult>(msg);
|
WindowCenter.Instance.OpenIL<CrossServerBattleFieldResultWin>();
|
}
|
|
// 下发数据只有数据变化才发,避免流量过大,但会导致解析阅读性差
|
public void UpdateMission(string _mission)
|
{
|
var _jsonData = JsonMapper.ToObject(_mission);
|
var keyList = _jsonData.Keys.ToList();
|
for (int i = 0; i < keyList.Count; i++)
|
{
|
var _key = keyList[i];
|
var json = _jsonData[_key];
|
if (_key == "worldInfo")
|
{
|
var keyList1 = json.Keys.ToList();
|
for (int j = 0; j < keyList1.Count; j++)
|
{
|
var key1 = keyList1[j];
|
var json1Str = json[key1].ToJson();
|
if (key1 == "crystalFactionInfo")
|
{
|
warCrystalDict.Clear();
|
var factionDict = JsonMapper.ToObject(json1Str);
|
|
var keyList2 = factionDict.Keys.ToList();
|
for (int k = 0; k < keyList2.Count; k++)
|
{
|
var key2 = keyList2[k];
|
warCrystalDict[int.Parse(key2)] = int.Parse(factionDict[key2].ToJson());
|
}
|
}
|
else if (key1 == "crystalAtkedList")
|
{
|
crystalAtkedList = JsonMapper.ToObject<int[]>(json1Str).ToList();
|
}
|
else if (key1 == "eventNPCPos")
|
{
|
eventNPCPos = JsonMapper.ToObject<int[]>(json1Str).ToList();
|
}
|
else if (key1 == "eventNPCHP")
|
{
|
eventNPCHP = long.Parse(json1Str);
|
}
|
else if (key1 == "eventEndTick")
|
{
|
eventEndTick = int.Parse(json1Str);
|
startAuraTime = (int)Time.time;
|
}
|
else if (key1 == "factionBuffNPCInfo")
|
{
|
factionBuffNPCInfo = JsonMapper.ToObject<int[]>(json1Str).ToList();
|
}
|
else if (key1 == "eventNPCID")
|
{
|
eventNPCID = int.Parse(json1Str);
|
}
|
else if (key1 == "superItemInfo")
|
{
|
superItemInfo = JsonMapper.ToObject<int[]>(json1Str).ToList();
|
}
|
}
|
WorldInfoEvent?.Invoke();
|
|
}
|
else if (_key == "factionInfo_1")
|
{
|
var keyList1 = json.Keys.ToList();
|
for (int j = 0; j < keyList1.Count; j++)
|
{
|
var key1 = keyList1[j];
|
var json1Str = json[key1].ToJson();
|
if (key1 == "factionBuffInfo")
|
{
|
factionInfo_1.factionBuffInfo = JsonMapper.ToObject<int[]>(json1Str).ToList();
|
}
|
else if (key1 == "score")
|
{
|
factionInfo_1.score = int.Parse(json1Str);
|
}
|
else if (key1 == "superItemProgress")
|
{
|
factionInfo_1.superItemProgress = int.Parse(json1Str);
|
}
|
else if (key1 == "superItemPlayerName")
|
{
|
//tojson会变成unicode 直接使用
|
factionInfo_1.superItemPlayerName = json[key1].ToString();
|
}
|
else if (key1 == "faction")
|
{
|
factionInfo_1.faction = int.Parse(json1Str);
|
}
|
else if (key1 == "hurtBossValue")
|
{
|
factionInfo_1.hurtBossValue = long.Parse(json1Str);
|
}
|
else if (key1 == "sysCallBuyIDList")
|
{
|
factionInfo_1.sysCallBuyIDList = JsonMapper.ToObject<List<int>>(json1Str);
|
}
|
}
|
FactionInfEvent?.Invoke();
|
}
|
else if (_key == "factionInfo_2")
|
{
|
var keyList1 = json.Keys.ToList();
|
for (int j = 0; j < keyList1.Count; j++)
|
{
|
var key1 = keyList1[j];
|
var json1Str = json[key1].ToJson();
|
if (key1 == "factionBuffInfo")
|
{
|
factionInfo_2.factionBuffInfo = JsonMapper.ToObject<int[]>(json1Str).ToList();
|
}
|
else if (key1 == "score")
|
{
|
factionInfo_2.score = int.Parse(json1Str);
|
}
|
else if (key1 == "superItemProgress")
|
{
|
factionInfo_2.superItemProgress = int.Parse(json1Str);
|
}
|
else if (key1 == "superItemPlayerName")
|
{
|
factionInfo_2.superItemPlayerName = json[key1].ToString();
|
}
|
else if (key1 == "faction")
|
{
|
factionInfo_2.faction = int.Parse(json1Str);
|
}
|
else if (key1 == "hurtBossValue")
|
{
|
factionInfo_2.hurtBossValue = long.Parse(json1Str);
|
}
|
else if (key1 == "sysCallBuyIDList")
|
{
|
factionInfo_2.sysCallBuyIDList = JsonMapper.ToObject<List<int>>(json1Str);
|
}
|
}
|
FactionInfEvent?.Invoke();
|
}
|
else if (_key == "playerInfo")
|
{
|
var keyList1 = json.Keys.ToList();
|
for (int j = 0; j < keyList1.Count; j++)
|
{
|
var key1 = keyList1[j];
|
var json1Str = json[key1].ToJson();
|
if (key1 == "itemRebornCount")
|
{
|
playerInfo.itemRebornCount = int.Parse(json1Str);
|
}
|
else if (key1 == "score")
|
{
|
playerInfo.score = int.Parse(json1Str);
|
}
|
else if (key1 == "killCount")
|
{
|
playerInfo.killCount = int.Parse(json1Str);
|
}
|
else if (key1 == "continueKillCount")
|
{
|
playerInfo.continueKillCount = int.Parse(json1Str);
|
}
|
else if (key1 == "superItemContribution")
|
{
|
playerInfo.superItemContribution = int.Parse(json1Str);
|
}
|
else if (key1 == "addScore")
|
{
|
playerInfo.addScore = JsonMapper.ToObject<int[]>(json1Str).ToList();
|
}
|
}
|
PlayerInfoEvent?.Invoke();
|
}
|
}
|
}
|
|
public struct FactionInfo
|
{
|
public List<int> factionBuffInfo;
|
public int score;
|
public int superItemProgress;
|
public string superItemPlayerName;
|
public int faction;
|
public long hurtBossValue;
|
public List<int> sysCallBuyIDList;
|
}
|
|
public struct PlayerInfo
|
{
|
public int itemRebornCount;
|
public int score;
|
public int killCount;
|
public int continueKillCount;
|
public int superItemContribution;
|
public List<int> addScore;
|
}
|
|
#endregion
|
|
#region 成就
|
public event Action OnSelectAchievementUpdate;
|
int m_SelectAchievementIndex = 0; //选择的成就项
|
public int selectAchievementIndex
|
{
|
get { return m_SelectAchievementIndex; }
|
set
|
{
|
if (m_SelectAchievementIndex != value)
|
{
|
m_SelectAchievementIndex = value;
|
OnSelectAchievementUpdate?.Invoke();
|
}
|
}
|
}
|
|
public List<int> gszcAchievementGroup = new List<int>(); //古神战场成就组排序
|
public List<Redpoint> successRedPoints = new List<Redpoint>();
|
Redpoint crossOneVsOneRedpoint = new Redpoint(CrossServerUtility.CrossServerRedKey, 21304);
|
Redpoint successMainRedPoint = new Redpoint(21304, MainRedPoint.GSCJRedPoint);
|
public Dictionary<int, List<int>> successGroupTypeDict = new Dictionary<int, List<int>>(); //groputype:成就ID
|
void ParseSuccessConfig()
|
{
|
gszcAchievementGroup = JsonMapper.ToObject<int[]>(FuncConfigConfig.Get("CrossBattlefieldSuccess").Numerical2).ToList();
|
|
var keyList = SuccessConfig.GetKeys();
|
for (int i = 0; i < keyList.Count; i++)
|
{
|
var config = SuccessConfig.Get(keyList[i]);
|
if (!gszcAchievementGroup.Contains(config.Group))
|
{
|
continue;
|
}
|
|
if (!successGroupTypeDict.ContainsKey(config.Group))
|
{
|
successGroupTypeDict[config.Group] = new List<int>();
|
}
|
var ids = successGroupTypeDict[config.Group];
|
if (!ids.Contains(config.ID))
|
{
|
ids.Add(config.ID);
|
}
|
}
|
|
InitSuccessRedPoint();
|
}
|
|
void InitSuccessRedPoint()
|
{
|
successRedPoints.Clear();
|
for (int i = 0; i < gszcAchievementGroup.Count; i++)
|
{
|
successRedPoints.Add(new Redpoint(MainRedPoint.GSCJRedPoint, MainRedPoint.GSCJRedPoint * 10000 + gszcAchievementGroup[i]));
|
}
|
}
|
|
//achievementAwardableEvent 可领取事件
|
//achievementCompletedEvent 领取事件
|
//成就变化和领取时处理
|
public void UpdateSuccessRedPoint()
|
{
|
successMainRedPoint.state = RedPointState.None;
|
for (int i = 0; i < gszcAchievementGroup.Count; i++)
|
{
|
successRedPoints[i].state = RedPointState.None;
|
var keyList = successGroupTypeDict[gszcAchievementGroup[i]];
|
for (int j = 0; j < keyList.Count; j++)
|
{
|
var id = keyList[j];
|
Achievement _achievement;
|
achievementModel.TryGetAchievement(id, out _achievement);
|
if (_achievement.completed) continue;
|
|
if (Achievement.IsReach(id, _achievement.progress))
|
{
|
successRedPoints[i].state = RedPointState.Simple;
|
break;
|
}
|
}
|
}
|
}
|
|
|
public void UpdateSuccessRedPoint(int successId)
|
{
|
var config = SuccessConfig.Get(successId);
|
if (config == null) return;
|
if (!gszcAchievementGroup.Contains(config.Group))
|
{
|
return;
|
}
|
int index = gszcAchievementGroup.IndexOf(config.Group);
|
|
successRedPoints[index].state = RedPointState.None;
|
var keyList = successGroupTypeDict[config.Group];
|
for (int j = 0; j < keyList.Count; j++)
|
{
|
var id = keyList[j];
|
Achievement _achievement;
|
achievementModel.TryGetAchievement(id, out _achievement);
|
if (_achievement.completed) continue;
|
|
if (Achievement.IsReach(id, _achievement.progress))
|
{
|
successRedPoints[index].state = RedPointState.Simple;
|
break;
|
}
|
}
|
|
}
|
|
//找到红点优先索引
|
public int FindRedPointTabIndex()
|
{
|
for (int i = 0; i < gszcAchievementGroup.Count; i++)
|
{
|
if (successRedPoints[i].state != RedPointState.None)
|
{
|
return i;
|
}
|
}
|
return 0;
|
}
|
|
public List<int> sortSueecssIDs = new List<int>();
|
//选择标签和领取后刷新
|
//成就列表排序,可领取,未领取,完成
|
public void SortSuccessItems()
|
{
|
sortSueecssIDs = successGroupTypeDict[gszcAchievementGroup[selectAchievementIndex]];
|
sortSueecssIDs.Sort(CmpSuccessID);
|
}
|
|
int CmpSuccessID(int id1, int id2)
|
{
|
Achievement s1;
|
Achievement s2;
|
|
achievementModel.TryGetAchievement(id1, out s1);
|
achievementModel.TryGetAchievement(id2, out s2);
|
|
//可领取0,进行中1,完成2
|
int state1 = s1.completed ? 2 : Achievement.IsReach(id1, s1.progress) ? 0 : 1;
|
int state2 = s2.completed ? 2 : Achievement.IsReach(id2, s2.progress) ? 0 : 1;
|
|
if (state1 != state2)
|
return state1.CompareTo(state2);
|
|
return id1.CompareTo(id2);
|
}
|
|
void AchievementAwardableEvent(int id)
|
{
|
if (isLoginOk)
|
UpdateSuccessRedPoint(id);
|
}
|
|
void AchievementCompletedEvent(int id)
|
{
|
//避免登录时通知过多导致卡顿
|
if (isLoginOk)
|
UpdateSuccessRedPoint(id);
|
}
|
|
void OnPlayerLoginOk()
|
{
|
isLoginOk = true;
|
UpdateSuccessRedPoint();
|
}
|
|
#endregion
|
|
//public void UpdateCommCrossZone(IL_HC010_tagGCCrossZoneInfo netPack)
|
//{
|
// commZoneID = netPack.CommZoneID;
|
//}
|
}
|