using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Snxxz.UI { [XLua.Hotfix] public class CrossServerOneVsOnePlayerInfo : Singleton { public int Score { get; private set; } // 当前积分 public int DanLV { get; private set; } // 当前段位 public int PKCount { get; private set; } // PK次数 public int WinCount { get; private set; } // 胜利次数 public int CWinCount { get; private set; } // 连胜次数 public int DayPKCount { get; private set; } // 当日已PK次数 public int DayWinCount { get; private set;} //当日胜利次数 public int DayBuyCount { get; private set; } // 当日已购买次数 public int DayItemAddCount { get; private set; } // 当日物品增加次数 private int preDayPkCount; CrossServerOneVsOneModel crossServerModel { get { return ModelCenter.Instance.GetModel(); } } public event Action UpdatePlayerInfoEvent; public event Action UpdateMatchNumEvent; public void InitData() { preDayPkCount = 0; Score = 0; DanLV = 0; PKCount = 0; WinCount = 0; CWinCount = 0; DayPKCount = 0; DayBuyCount = 0; DayWinCount = 0; } public void UpdatePlayerInfo(HC101_tagMCCrossRealmPKPlayerInfo playerInfo) { this.Score = (int)playerInfo.Score; this.DanLV = playerInfo.DanLV; this.PKCount = playerInfo.PKCount; this.WinCount = playerInfo.WinCount; this.CWinCount = playerInfo.CWinCount; this.DayBuyCount = playerInfo.DayBuyCount; this.DayWinCount = playerInfo.DayWinCount; this.DayItemAddCount = playerInfo.DayItemAddCount; this.DayPKCount = playerInfo.DayPKCount; if (this.preDayPkCount != playerInfo.DayPKCount) { this.preDayPkCount = playerInfo.DayPKCount; if (UpdateMatchNumEvent != null) { UpdateMatchNumEvent(); } } if (UpdatePlayerInfoEvent != null) { UpdatePlayerInfoEvent(); } } public bool TryGetMaxRank(out int upScore) { upScore = 0; var preArenaConfig = CrossServerArenaConfig.Get(DanLV - 1); var arenaConfig = CrossServerArenaConfig.Get(DanLV); if (arenaConfig != null && arenaConfig.LVUpScore > 0) { if(preArenaConfig != null) { upScore = arenaConfig.LVUpScore - preArenaConfig.LVUpScore; } else { upScore = arenaConfig.LVUpScore; } } return upScore == 0; } public int GetBuyMatchNumPrice() { Equation.Instance.Clear(); Equation.Instance.AddKeyValue("todayBuyCount", DayBuyCount); return Equation.Instance.Eval(crossServerModel.priceFormula); } public int GetDayRemainNum() { int remainNum = DayBuyCount + DayItemAddCount + crossServerModel.freeMaxMatchNum - DayPKCount; return remainNum > 0 ? remainNum : 0; } public int GetDayRemainBuyNum() { int remainNum = crossServerModel.buyMaxMatchNum - DayBuyCount; return remainNum > 0 ? remainNum : 0; } public string DisplayWinningRate() { float rate = PKCount != 0 ? (float)WinCount / PKCount : 0; return StringUtility.Contact((float)Math.Round(rate*100,1),"%"); } } }