| | |
| | | [XLua.LuaCallCSharp]
|
| | | public class CrossServerModel : Model, IBeforePlayerDataInitialize, IAfterPlayerDataInitialize, IPlayerLoginOk
|
| | | {
|
| | | public string PkResultLocalSaveKey { get; private set; }
|
| | | public List<PkResultInfo> localSaveResults { get; private set; }
|
| | |
|
| | | public override void Init()
|
| | | {
|
| | | ParseFuncConfig();
|
| | |
| | |
|
| | | public void OnAfterPlayerDataInitialize()
|
| | | {
|
| | |
|
| | | int playerId = (int)PlayerDatas.Instance.baseData.PlayerID;
|
| | | PkResultLocalSaveKey = StringUtility.Contact("PkResultLocalSaveKey", playerId);
|
| | | GetLocalSaveData();
|
| | | }
|
| | |
|
| | | public void OnPlayerLoginOk()
|
| | |
| | | return Equation.Instance.Eval<int>(priceFormula);
|
| | | }
|
| | |
|
| | | public bool TryGetWinStreakScore(out int score)
|
| | | {
|
| | | score = 0;
|
| | | if (pkResultInfo.WinStreak < 2) return false;
|
| | |
|
| | | Equation.Instance.Clear();
|
| | | Equation.Instance.AddKeyValue("cWinCount",pkResultInfo.WinStreak);
|
| | | score = Equation.Instance.Eval<int>(winStreakScoreFormula);
|
| | | return true;
|
| | | }
|
| | |
|
| | | public List<AwardType> sortDayAwardslist = new List<AwardType>();
|
| | | public void SortDayAwardsList()
|
| | | {
|
| | |
| | | public int freeMaxMatchNum { get; private set; } //每日免费匹配次数
|
| | | public int buyMaxMatchNum { get; private set; } //每日可购买次数
|
| | | public string priceFormula { get;private set;} //购买匹配次数需要价格公式
|
| | | public string winStreakScoreFormula { get; private set; } //连胜积分公式
|
| | | public List<AwardType> dayAwardTypelist { get; private set; }
|
| | | private void ParseFuncConfig()
|
| | | {
|
| | |
| | | freeMaxMatchNum = int.Parse(CrossRealmPKMatchCount.Numerical1);
|
| | | buyMaxMatchNum = int.Parse(CrossRealmPKMatchCount.Numerical2);
|
| | | priceFormula = CrossRealmPKMatchCount.Numerical3;
|
| | |
|
| | | var CrossRealmPKScore = Config.Instance.Get<FuncConfigConfig>("CrossRealmPKScore");
|
| | | winStreakScoreFormula = CrossRealmPKScore.Numerical3;
|
| | | }
|
| | |
|
| | | public class AwardType
|
| | |
| | | public event Action UpdatePkResultEvent;
|
| | | public void UpdatePKResultInfo(HC003_tagGCCrossRealmPKOverInfo pKOverInfo)
|
| | | {
|
| | | pkResultInfo = new PkResultInfo();
|
| | | pkResultInfo.PkEndTime = pKOverInfo.TimeStr;
|
| | | pkResultInfo.OverType = pKOverInfo.OverType;
|
| | | pkResultInfo.WinnerID = (int)pKOverInfo.WinnerID;
|
| | |
| | | pkResultInfo.DanLV = pKOverInfo.DanLV;
|
| | | pkResultInfo.WinStreak = pKOverInfo.CWinCnt;
|
| | | pkResultInfo.VsPlayerName = pKOverInfo.TagName;
|
| | | SetPkInfoLocalSave(pkResultInfo);
|
| | | if(UpdatePkResultEvent != null)
|
| | | {
|
| | | UpdatePkResultEvent();
|
| | |
| | |
|
| | | public int OverType; // 0-正常,1-有人离线
|
| | |
|
| | | public int WinnerID; // 胜方ID
|
| | | public int WinnerID; // 胜方ID(本次战斗结束,不是回合结束)
|
| | |
|
| | | public int RoundCount; // PK回合数
|
| | |
|
| | |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 1 自己离线 2 对手离线
|
| | | /// </summary>
|
| | | /// <param name="type"></param>
|
| | | /// <returns></returns>
|
| | | public bool TryGetOffLine(out int type)
|
| | | {
|
| | | type = 0;
|
| | | int playerId = (int)PlayerDatas.Instance.baseData.PlayerID;
|
| | | if(pkResultInfo.OverType != 0)
|
| | | {
|
| | | type = playerId == pkResultInfo.WinnerID ? 2 : 1;
|
| | | }
|
| | | return pkResultInfo.OverType != 0;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | ///0-取消匹配; 1-进行匹配
|
| | | /// </summary>
|
| | | /// <param name="type"></param>
|
| | |
| | | GameNetSystem.Instance.SendInfo(match);
|
| | | }
|
| | | #endregion
|
| | |
|
| | | #region 匹配记录
|
| | | |
| | | private void GetLocalSaveData()
|
| | | {
|
| | | localSaveResults = new List<PkResultInfo>();
|
| | | string[] localJsons = LocalSave.GeStringArray(PkResultLocalSaveKey);
|
| | | if(localJsons != null)
|
| | | {
|
| | | for(int i = 0; i < localJsons.Length; i++)
|
| | | {
|
| | | PkResultInfo resultInfo = JsonMapper.ToObject<PkResultInfo>(localJsons[i]);
|
| | | localSaveResults.Add(resultInfo);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public void SetPkInfoLocalSave(PkResultInfo resultInfo)
|
| | | {
|
| | | if (localSaveResults.Count >= 30)
|
| | | {
|
| | | localSaveResults.RemoveAt(localSaveResults.Count - 1);
|
| | | }
|
| | | localSaveResults.Insert(0,resultInfo);
|
| | | string[] localJsons = new string[localSaveResults.Count];
|
| | | for(int i = 0; i < localJsons.Length; i++)
|
| | | {
|
| | | string json = JsonMapper.ToJson(localSaveResults[i]);
|
| | | localJsons[i] = json;
|
| | | }
|
| | | LocalSave.SetStringArray(PkResultLocalSaveKey,localJsons);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region 红点
|
| | | #endregion
|
| | |
|