using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using LitJson;
|
|
namespace vnxbqy.UI
|
{
|
|
public class HeavenBattleInfo : Singleton<HeavenBattleInfo>
|
|
{
|
public HeavenBattleInfo()
|
{
|
ResetModel();
|
}
|
|
public void ResetModel()
|
{
|
Score1 = 0;
|
Score2 = 0;
|
TopScore = 0;
|
TopName = "";
|
battleResultDict.Clear();
|
Faction = 0;
|
PlayerScore = 0;
|
WinCnt = 0;
|
getAwardDict.Clear();
|
bettingRecordDict.Clear();
|
}
|
|
#region 仙魔之争的信息
|
public int Score1 { get; private set; } // 仙界阵营积分
|
|
public int Score2 { get; private set; } // 魔界阵营积分
|
|
public int TopScore { get; private set; } // 积分第1名积分
|
|
public string TopName { get; private set; } // 积分第1名名字
|
|
private Dictionary<int, int> battleResultDict = new Dictionary<int, int>();// 阶段胜负记录{"0":1,"1":2,"2":3,"3":1}
|
public event Action bettingResultAct;
|
public void SetHeavenBattleInfo(HAC02_tagGCXMZZInfo info)
|
{
|
battleResultDict.Clear();
|
this.Score1 = (int)info.Score1;
|
this.Score2 = (int)info.Score2;
|
this.TopScore = (int)info.TopScore;
|
this.TopName = info.TopName;
|
|
JsonData jsonData = JsonMapper.ToObject(info.StageRecord);
|
foreach (var key in jsonData.Keys)
|
{
|
int index = int.Parse(key);
|
int result = int.Parse(jsonData[key].ToString());
|
if (!battleResultDict.ContainsKey(index))
|
{
|
battleResultDict.Add(index, result);
|
}
|
else
|
{
|
battleResultDict[index] = result;
|
}
|
|
DebugEx.Log("阶段胜利:" + index + "结果:" + result);
|
}
|
|
if (bettingResultAct != null)
|
{
|
bettingResultAct();
|
}
|
}
|
|
public int GetBattleResultByIndex(int index)
|
{
|
int result = 0;
|
battleResultDict.TryGetValue(index, out result);
|
return result;
|
}
|
|
#endregion
|
|
#region 仙魔之争玩家信息
|
public int Faction { get; private set; } // 所属阵营
|
public int PlayerScore { get; private set; } // 积分
|
public int WinCnt { get; private set; } // 胜场数
|
private Dictionary<int, bool> getAwardDict = new Dictionary<int, bool>(); // 胜场奖励领取记录
|
private Dictionary<int, List<int>> bettingRecordDict = new Dictionary<int, List<int>>(); // 押注记录 1 阵营1 2 阵营2
|
public event Action bettingRecordAct;
|
public void SetHeavenBattlePlayerInfo(HAC03_tagGCXMZZSelfInfo info)
|
{
|
bettingRecordDict.Clear();
|
getAwardDict.Clear();
|
|
this.Faction = (int)info.Faction;
|
this.PlayerScore = (int)info.Score;
|
this.WinCnt = (int)info.WinCnt;
|
string awardRecord = info.WinCntAwardRecord.ToString();
|
int sumIndex = ModelCenter.Instance.GetModel<HeavenBattleModel>().heavenAwardDict.Count;
|
for (int i = 0; i < sumIndex; i++)
|
{
|
bool isRecord = MathUtility.GetBitValue(info.WinCntAwardRecord, (ushort)i);
|
if (isRecord)
|
{
|
getAwardDict.Add(i, true);
|
}
|
else
|
{
|
getAwardDict.Add(i, false);
|
}
|
}
|
|
JsonData jsonData = JsonMapper.ToObject(info.BetRecord);
|
foreach (var key in jsonData.Keys)
|
{
|
int index = int.Parse(key);
|
if (jsonData[key].IsArray)
|
{
|
int betRecord = int.Parse(jsonData[key][0].ToString());
|
int betMoney = int.Parse(jsonData[key][1].ToString());
|
if (!bettingRecordDict.ContainsKey(index))
|
{
|
List<int> betlist = new List<int>();
|
betlist.Add(betRecord);
|
betlist.Add(betMoney);
|
bettingRecordDict.Add(index, betlist);
|
}
|
else
|
{
|
bettingRecordDict[index][0] = betRecord;
|
bettingRecordDict[index][1] = betMoney;
|
}
|
}
|
|
|
}
|
|
if (bettingRecordAct != null)
|
{
|
bettingRecordAct();
|
}
|
}
|
|
public bool IsGetAwardByIndex(int index)
|
{
|
bool isGet = false;
|
getAwardDict.TryGetValue(index, out isGet);
|
return isGet;
|
}
|
|
public int GetBetRecordByIndex(int index)
|
{
|
int record = 0;
|
List<int> betlist = null;
|
bettingRecordDict.TryGetValue(index, out betlist);
|
if (betlist != null)
|
{
|
record = betlist[0];
|
}
|
return record;
|
}
|
|
public int GetBetMoneyByIndex(int index)
|
{
|
int betMoney = 0;
|
List<int> betlist = null;
|
bettingRecordDict.TryGetValue(index, out betlist);
|
if (betlist != null)
|
{
|
betMoney = betlist[1];
|
}
|
return betMoney;
|
}
|
#endregion
|
|
}
|
}
|