summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/XSpriteSystemDocument.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Client/Assets/Scripts/XMainClient/XSpriteSystemDocument.cs')
-rw-r--r--Client/Assets/Scripts/XMainClient/XSpriteSystemDocument.cs1560
1 files changed, 1560 insertions, 0 deletions
diff --git a/Client/Assets/Scripts/XMainClient/XSpriteSystemDocument.cs b/Client/Assets/Scripts/XMainClient/XSpriteSystemDocument.cs
new file mode 100644
index 00000000..c076e0c2
--- /dev/null
+++ b/Client/Assets/Scripts/XMainClient/XSpriteSystemDocument.cs
@@ -0,0 +1,1560 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using KKSG;
+using UnityEngine;
+using XMainClient.UI;
+using XMainClient.UI.UICommon;
+using XUtliPoolLib;
+
+namespace XMainClient
+{
+ internal class XSpriteSystemDocument : XDocComponent
+ {
+ public override uint ID
+ {
+ get
+ {
+ return XSpriteSystemDocument.uuID;
+ }
+ }
+
+ public XOutlookSprite OutLookData
+ {
+ get
+ {
+ return XSingleton<XAttributeMgr>.singleton.XPlayerData.Outlook.sprite;
+ }
+ }
+
+ public uint CurrentLotteryType { get; set; }
+
+ public uint NormalMaxCount { get; set; }
+
+ public uint NormalCoolDown { get; set; }
+
+ public uint NormalFreeCount { get; set; }
+
+ public uint SpecialCoolDown { get; set; }
+
+ public uint SpecialSafeCount { get; set; }
+
+ public bool AutoShowEpicSprite { get; set; }
+
+ public SpritePreviewTable _SpritePreviewTable
+ {
+ get
+ {
+ return XSpriteSystemDocument._spritePreviewTable;
+ }
+ }
+
+ public List<uint> SpriteShowInIllustration
+ {
+ get
+ {
+ return XSpriteSystemDocument._spriteShowInIllustration;
+ }
+ }
+
+ public Dictionary<int, List<uint>> _SpriteEggPreviewDict
+ {
+ get
+ {
+ return XSpriteSystemDocument._spriteEggIllustrationDict;
+ }
+ }
+
+ public SpriteTable _SpriteTable
+ {
+ get
+ {
+ return XSpriteSystemDocument._spriteTable;
+ }
+ }
+
+ public SpriteLevel _SpriteLevelTable
+ {
+ get
+ {
+ return XSpriteSystemDocument._spriteLevelTable;
+ }
+ }
+
+ public SpriteEvolution _SpriteEvolutionTable
+ {
+ get
+ {
+ return XSpriteSystemDocument._spriteEvolutionTable;
+ }
+ }
+
+ public SpriteSkill _SpriteSkillTable
+ {
+ get
+ {
+ return XSpriteSystemDocument._spriteSkillTable;
+ }
+ }
+
+ public List<SpriteInfo> SpriteList
+ {
+ get
+ {
+ return this._spriteList;
+ }
+ }
+
+ public List<SpriteInfo> ResolveList
+ {
+ get
+ {
+ return this._resolveList;
+ }
+ }
+
+ public List<ulong> FightingList
+ {
+ get
+ {
+ return this._fightingList;
+ }
+ }
+
+ public List<bool> BookList
+ {
+ get
+ {
+ return this._bookList;
+ }
+ }
+
+ public uint MaxFightNum
+ {
+ get
+ {
+ return this._maxFightNum;
+ }
+ }
+
+ public new static readonly uint uuID = XSingleton<XCommon>.singleton.XHash("SpriteSystemDocument");
+
+ public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader();
+
+ private static SpriteTable _spriteTable = new SpriteTable();
+
+ private static SpriteLevel _spriteLevelTable = new SpriteLevel();
+
+ private static SpriteEvolution _spriteEvolutionTable = new SpriteEvolution();
+
+ private static SpriteSkill _spriteSkillTable = new SpriteSkill();
+
+ private static SpritePreviewTable _spritePreviewTable = new SpritePreviewTable();
+
+ private List<SpriteInfo> _spriteList = new List<SpriteInfo>();
+
+ private List<SpriteInfo> _resolveList = new List<SpriteInfo>();
+
+ private List<ulong> _fightingList = new List<ulong>();
+
+ private List<bool> _bookList = new List<bool>();
+
+ private HashSet<ulong> _fightHash = new HashSet<ulong>();
+
+ private HashSet<ulong> _redPointSpriteHash = new HashSet<ulong>();
+
+ private static Dictionary<uint, uint> _levelUpExpDict = new Dictionary<uint, uint>();
+
+ private static Dictionary<short, List<SpriteSkill.RowData>> _spriteSkillDict = new Dictionary<short, List<SpriteSkill.RowData>>();
+
+ private static Dictionary<int, List<uint>> _spriteEggIllustrationDict = new Dictionary<int, List<uint>>();
+
+ private static List<uint> _spriteShowInIllustration = new List<uint>();
+
+ public List<uint> PositionLevelCondition = new List<uint>();
+
+ private uint _maxFightNum;
+
+ private static readonly uint K_LEVELUPQUALITY = 10000u;
+
+ public static List<uint> MAXSTARLEVEL = new List<uint>
+ {
+ 0u,
+ 0u,
+ 0u,
+ 0u,
+ 0u,
+ 0u
+ };
+
+ public static uint MOONWORTH = 6u;
+
+ public string[] NAMECOLOR = new string[6];
+
+ private int SpriteRedPointShowIntervel;
+
+ private uint _timerToken;
+
+ private double _showExpTime;
+
+ private uint _expTotal = 0u;
+
+ public SeqList<int> FoodList;
+
+ public SpriteHandlerTag CurrentTag;
+
+ private uint GroupRatio;
+
+ private int _starUpLimitLevel;
+
+ public List<ItemBrief> CachedLotteryResult = new List<ItemBrief>();
+
+ public List<uint> CachedLotteryPPT = new List<uint>();
+
+ public List<bool> ResultShowList = new List<bool>();
+
+ private float LastLotteryTime = 0f;
+
+ public SpriteInfo _AwakeSpriteData = null;
+
+ public static void Execute(OnLoadedCallback callback = null)
+ {
+ XSpriteSystemDocument.AsyncLoader.AddTask("Table/SpriteTable", XSpriteSystemDocument._spriteTable, false);
+ XSpriteSystemDocument.AsyncLoader.AddTask("Table/SpriteLevel", XSpriteSystemDocument._spriteLevelTable, false);
+ XSpriteSystemDocument.AsyncLoader.AddTask("Table/SpriteEvolution", XSpriteSystemDocument._spriteEvolutionTable, false);
+ XSpriteSystemDocument.AsyncLoader.AddTask("Table/SpriteSkill", XSpriteSystemDocument._spriteSkillTable, false);
+ XSpriteSystemDocument.AsyncLoader.AddTask("Table/SpritePreviewTable", XSpriteSystemDocument._spritePreviewTable, false);
+ XSpriteSystemDocument.AsyncLoader.Execute(callback);
+ }
+
+ public static void OnTableLoaded()
+ {
+ XSpriteSystemDocument._levelUpExpDict.Clear();
+ for (int i = 0; i < XSpriteSystemDocument._spriteLevelTable.Table.Length; i++)
+ {
+ SpriteLevel.RowData rowData = XSpriteSystemDocument._spriteLevelTable.Table[i];
+ XSpriteSystemDocument._levelUpExpDict[rowData.Quality * XSpriteSystemDocument.K_LEVELUPQUALITY + rowData.Level] = rowData.Exp;
+ }
+ XSpriteSystemDocument._spriteSkillDict.Clear();
+ for (int j = 0; j < XSpriteSystemDocument._spriteSkillTable.Table.Length; j++)
+ {
+ short skillID = XSpriteSystemDocument._spriteSkillTable.Table[j].SkillID;
+ List<SpriteSkill.RowData> value;
+ bool flag = !XSpriteSystemDocument._spriteSkillDict.TryGetValue(skillID, out value);
+ if (flag)
+ {
+ value = new List<SpriteSkill.RowData>();
+ XSpriteSystemDocument._spriteSkillDict.Add(skillID, value);
+ }
+ XSpriteSystemDocument._spriteSkillDict[skillID].Add(XSpriteSystemDocument._spriteSkillTable.Table[j]);
+ }
+ XSpriteSystemDocument._spriteShowInIllustration.Clear();
+ for (int k = 0; k < XSpriteSystemDocument._spriteTable.Table.Length; k++)
+ {
+ bool flag2 = XSpriteSystemDocument._spriteTable.Table[k].IllustrationShow == 1;
+ if (flag2)
+ {
+ XSpriteSystemDocument._spriteShowInIllustration.Add(XSpriteSystemDocument._spriteTable.Table[k].SpriteID);
+ }
+ }
+ XSpriteSystemDocument._spriteEggIllustrationDict.Clear();
+ for (int l = 0; l < XSpriteSystemDocument._spritePreviewTable.Table.Length; l++)
+ {
+ int[] spriteShow = XSpriteSystemDocument._spritePreviewTable.Table[l].SpriteShow;
+ bool flag3 = spriteShow == null;
+ if (!flag3)
+ {
+ foreach (int key in spriteShow)
+ {
+ List<uint> list;
+ bool flag4 = !XSpriteSystemDocument._spriteEggIllustrationDict.TryGetValue(key, out list);
+ if (flag4)
+ {
+ list = new List<uint>();
+ XSpriteSystemDocument._spriteEggIllustrationDict[key] = list;
+ }
+ list.Add(XSpriteSystemDocument._spritePreviewTable.Table[l].ItemID);
+ }
+ }
+ }
+ for (int n = 0; n < XSpriteSystemDocument._spriteEvolutionTable.Table.Length; n++)
+ {
+ bool flag5 = (uint)XSpriteSystemDocument._spriteEvolutionTable.Table[n].EvolutionLevel > XSpriteSystemDocument.MAXSTARLEVEL[(int)XSpriteSystemDocument._spriteEvolutionTable.Table[n].Quality];
+ if (flag5)
+ {
+ XSpriteSystemDocument.MAXSTARLEVEL[(int)XSpriteSystemDocument._spriteEvolutionTable.Table[n].Quality] = (uint)XSpriteSystemDocument._spriteEvolutionTable.Table[n].EvolutionLevel;
+ }
+ }
+ }
+
+ public SpriteSkill.RowData GetMySpriteInitiativeSkill()
+ {
+ bool flag = this._fightingList.Count == 0 || this._fightingList[0] == 0UL;
+ SpriteSkill.RowData result;
+ if (flag)
+ {
+ result = null;
+ }
+ else
+ {
+ int indexByUid = this.GetIndexByUid(this._fightingList[0]);
+ result = this.GetSpriteInitiativeSkill(this._spriteList[indexByUid].SpriteID, this._spriteList[indexByUid].EvolutionLevel);
+ }
+ return result;
+ }
+
+ public SpriteSkill.RowData GetSpriteInitiativeSkill(uint spriteID, uint star)
+ {
+ SpriteTable.RowData bySpriteID = XSpriteSystemDocument._spriteTable.GetBySpriteID(spriteID);
+ return this.GetSpriteSkillData((short)bySpriteID.SpriteSkillID, true, star);
+ }
+
+ public override void OnEnterSceneFinally()
+ {
+ bool flag = this._maxFightNum == 0u;
+ if (flag)
+ {
+ this.DealWithPositionLevelCondition();
+ }
+ }
+
+ private int Compare(SpriteInfo x, SpriteInfo y)
+ {
+ bool flag = x.uid == y.uid;
+ int result;
+ if (flag)
+ {
+ result = 0;
+ }
+ else
+ {
+ bool flag2 = this.isSpriteFight(x.uid) != this.isSpriteFight(y.uid);
+ if (flag2)
+ {
+ result = (this.isSpriteFight(x.uid) ? -1 : 1);
+ }
+ else
+ {
+ result = (int)(y.PowerPoint - x.PowerPoint);
+ }
+ }
+ return result;
+ }
+
+ public void SortList()
+ {
+ this._spriteList.Sort(new Comparison<SpriteInfo>(this.Compare));
+ this.CalNeed2FightSprite();
+ this._resolveList.Sort(new Comparison<SpriteInfo>(this.Compare));
+ }
+
+ public SpriteSkill.RowData GetSpriteSkillData(short skillID, bool mainSkill, uint starLevel)
+ {
+ List<SpriteSkill.RowData> list;
+ bool flag = XSpriteSystemDocument._spriteSkillDict.TryGetValue(skillID, out list);
+ if (flag)
+ {
+ bool flag2 = !mainSkill;
+ if (flag2)
+ {
+ bool flag3 = list.Count > 0;
+ if (flag3)
+ {
+ return list[0];
+ }
+ }
+ else
+ {
+ uint num = starLevel + 1u;
+ for (int i = 0; i < list.Count; i++)
+ {
+ bool flag4 = (uint)list[i].SkillQuality == num;
+ if (flag4)
+ {
+ return list[i];
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ public override void OnAttachToHost(XObject host)
+ {
+ base.OnAttachToHost(host);
+ this.SpriteRedPointShowIntervel = XSingleton<XGlobalConfig>.singleton.GetInt("SpriteRedPointShowIntervel");
+ for (int i = 0; i < 6; i++)
+ {
+ this.NAMECOLOR[i] = XSingleton<XGlobalConfig>.singleton.GetValue(string.Format("Quality{0}Color", i));
+ }
+ for (int j = 0; j < 4; j++)
+ {
+ this._fightingList.Add(0UL);
+ }
+ this.GroupRatio = (uint)XSingleton<XGlobalConfig>.singleton.GetInt("SpriteGrowUpRatio");
+ this.NormalMaxCount = (uint)XSingleton<XGlobalConfig>.singleton.GetInt("SpriteGoldDrawFreeDayCount");
+ this._showExpTime = double.Parse(XSingleton<XGlobalConfig>.singleton.GetValue("SpriteExpShowTime"));
+ this.FoodList = XSingleton<XGlobalConfig>.singleton.GetSequenceList("SpriteFoodExp", false);
+ this._starUpLimitLevel = XSingleton<XGlobalConfig>.singleton.GetInt("SpriteEvolutionMinLevel");
+ XWelfareDocument specificDocument = XDocuments.GetSpecificDocument<XWelfareDocument>(XWelfareDocument.uuID);
+ PayMemberTable.RowData memberPrivilegeConfig = specificDocument.GetMemberPrivilegeConfig(MemberPrivilege.KingdomPrivilege_Commerce);
+ }
+
+ protected override void EventSubscribe()
+ {
+ base.EventSubscribe();
+ base.RegisterEvent(XEventDefine.XEvent_BuffChange, new XComponent.XEventHandler(this._OnBuffChange));
+ base.RegisterEvent(XEventDefine.XEvent_AddItem, new XComponent.XEventHandler(this.OnAddItem));
+ base.RegisterEvent(XEventDefine.XEvent_RemoveItem, new XComponent.XEventHandler(this.OnRemoveItem));
+ base.RegisterEvent(XEventDefine.XEvent_PlayerLevelChange, new XComponent.XEventHandler(this.OnPlayerLevelChange));
+ }
+
+ protected bool OnAddItem(XEventArgs args)
+ {
+ XAddItemEventArgs xaddItemEventArgs = args as XAddItemEventArgs;
+ for (int i = 0; i < xaddItemEventArgs.items.Count; i++)
+ {
+ bool flag = xaddItemEventArgs.items[i].Type == ItemType.SPRITEFOOD;
+ if (flag)
+ {
+ this.CalSpriteMainRedPoint();
+ return true;
+ }
+ }
+ return true;
+ }
+
+ protected bool OnRemoveItem(XEventArgs args)
+ {
+ XRemoveItemEventArgs xremoveItemEventArgs = args as XRemoveItemEventArgs;
+ for (int i = 0; i < xremoveItemEventArgs.types.Count; i++)
+ {
+ bool flag = xremoveItemEventArgs.types[i] == ItemType.SPRITEFOOD;
+ if (flag)
+ {
+ this.CalSpriteMainRedPoint();
+ return true;
+ }
+ }
+ return true;
+ }
+
+ public int GetIndexByUid(ulong uid)
+ {
+ for (int i = 0; i < this._spriteList.Count; i++)
+ {
+ bool flag = this._spriteList[i].uid == uid;
+ if (flag)
+ {
+ return i;
+ }
+ }
+ XSingleton<XDebug>.singleton.AddErrorLog(string.Format("Can't find the index by uid = {0}", uid), null, null, null, null, null);
+ return -1;
+ }
+
+ protected override void OnReconnected(XReconnectedEventArgs arg)
+ {
+ this.SetAllInfo(arg.PlayerInfo.SpriteRecord);
+ }
+
+ public void DealWithPositionLevelCondition()
+ {
+ this.PositionLevelCondition = XSingleton<XGlobalConfig>.singleton.GetUIntList("SpritePositionLevel");
+ bool flag = this.PositionLevelCondition.Count != 4;
+ if (flag)
+ {
+ XSingleton<XDebug>.singleton.AddErrorLog("Error! get PositionLevelCondition's cout from globalconfig error! the cout isn't 4", null, null, null, null, null);
+ }
+ uint level = XSingleton<XAttributeMgr>.singleton.XPlayerData.Level;
+ this._maxFightNum = 4u;
+ for (int i = 0; i < this.PositionLevelCondition.Count; i++)
+ {
+ bool flag2 = this.PositionLevelCondition[i] > level;
+ if (flag2)
+ {
+ this._maxFightNum = (uint)i;
+ break;
+ }
+ }
+ this.CalNeed2FightSprite();
+ bool flag3 = DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteFightFrame != null;
+ if (flag3)
+ {
+ DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteFightFrame.RefreshPosition();
+ }
+ }
+
+ private void CalNeed2FightSprite()
+ {
+ this._redPointSpriteHash.Clear();
+ int num = (int)(this._maxFightNum - (uint)this._fightHash.Count);
+ bool flag = num <= 0;
+ if (flag)
+ {
+ this.CalSpriteFightRedPoint();
+ }
+ else
+ {
+ HashSet<ulong> hashSet = new HashSet<ulong>();
+ for (int i = 0; i < num; i++)
+ {
+ int num2 = -1;
+ for (int j = 0; j < this._spriteList.Count; j++)
+ {
+ bool flag2 = this._fightHash.Contains(this._spriteList[j].uid);
+ if (!flag2)
+ {
+ bool flag3 = hashSet.Contains(this._spriteList[j].uid);
+ if (!flag3)
+ {
+ bool flag4 = num2 == -1;
+ if (flag4)
+ {
+ num2 = j;
+ }
+ else
+ {
+ bool flag5 = this._spriteList[j].PowerPoint > this._spriteList[num2].PowerPoint;
+ if (flag5)
+ {
+ num2 = j;
+ }
+ }
+ }
+ }
+ }
+ bool flag6 = num2 == -1;
+ if (flag6)
+ {
+ break;
+ }
+ hashSet.Add(this._spriteList[num2].uid);
+ this._redPointSpriteHash.Add(this._spriteList[num2].uid);
+ }
+ this.CalSpriteFightRedPoint();
+ }
+ }
+
+ public void SetAllInfo(SpriteRecord data)
+ {
+ bool flag = data == null;
+ if (flag)
+ {
+ this._bookList = new List<bool>(new bool[XSpriteSystemDocument._spriteTable.Table.Length]);
+ XSingleton<XDebug>.singleton.AddLog("Get sprite Info from server is null.", null, null, null, null, null, XDebugColor.XDebug_None);
+ }
+ else
+ {
+ this._bookList = data.Books;
+ this._spriteList = data.SpriteData;
+ this._AwakeSpriteData = data.NewAwake;
+ this.SetFightList(data.InFight);
+ this.SortList();
+ this.CheckView();
+ }
+ }
+
+ private void SetOutLookData()
+ {
+ bool flag = this._fightingList[0] == 0UL;
+ if (flag)
+ {
+ bool flag2 = this.OutLookData.leaderid == 0u;
+ if (flag2)
+ {
+ return;
+ }
+ XSingleton<XAttributeMgr>.singleton.XPlayerData.Outlook.SetSpriteData(0u);
+ }
+ else
+ {
+ int indexByUid = this.GetIndexByUid(this._fightingList[0]);
+ bool flag3 = this.OutLookData.leaderid == this._spriteList[indexByUid].SpriteID;
+ if (flag3)
+ {
+ return;
+ }
+ XSingleton<XAttributeMgr>.singleton.XPlayerData.Outlook.SetSpriteData(this._spriteList[indexByUid].SpriteID);
+ }
+ bool flag4 = XSingleton<XEntityMgr>.singleton.Player != null;
+ if (flag4)
+ {
+ XEquipComponent xequipComponent = XSingleton<XEntityMgr>.singleton.Player.GetXComponent(XEquipComponent.uuID) as XEquipComponent;
+ uint presentID = xequipComponent.SpriteFromAttr();
+ XSingleton<X3DAvatarMgr>.singleton.OnSpriteChanged(XSingleton<XEntityMgr>.singleton.Player, presentID);
+ }
+ }
+
+ private void SetFightList(List<ulong> list)
+ {
+ bool flag = list.Count != 4;
+ if (flag)
+ {
+ this._fightingList.Clear();
+ for (int i = 0; i < 4; i++)
+ {
+ this._fightingList.Add(0UL);
+ }
+ }
+ else
+ {
+ this._fightingList = list;
+ }
+ this.SetOutLookData();
+ this.FightHashChange();
+ }
+
+ private void FightHashChange()
+ {
+ this._fightHash.Clear();
+ for (int i = 0; i < this._fightingList.Count; i++)
+ {
+ bool flag = this._fightingList[i] > 0UL;
+ if (flag)
+ {
+ this._fightHash.Add(this._fightingList[i]);
+ }
+ }
+ this.DealWithResolveList();
+ }
+
+ public bool isSpriteFight(ulong uid)
+ {
+ return this._fightHash.Contains(uid);
+ }
+
+ public bool isFightFull()
+ {
+ return (long)this._fightHash.Count == (long)((ulong)this._maxFightNum);
+ }
+
+ public bool isSpriteNeed2Fight(int index)
+ {
+ return this._redPointSpriteHash.Contains(this._spriteList[index].uid);
+ }
+
+ public void CalSpriteFightRedPoint()
+ {
+ XSingleton<XGameSysMgr>.singleton.SetSysRedPointState(XSysDefine.XSys_SpriteSystem_Fight, this._redPointSpriteHash.Count != 0);
+ XSingleton<XGameSysMgr>.singleton.RecalculateRedPointState(XSysDefine.XSys_SpriteSystem, true);
+ this.CalSpriteMainRedPoint();
+ }
+
+ public void CalSpriteMainRedPoint()
+ {
+ bool bState = !this.isSpriteFoodEmpty() && this.isFightSpriteNeed2Feed(true);
+ XSingleton<XGameSysMgr>.singleton.SetSysRedPointState(XSysDefine.XSys_SpriteSystem_Main, bState);
+ XSingleton<XGameSysMgr>.singleton.RecalculateRedPointState(XSysDefine.XSys_SpriteSystem, true);
+ }
+
+ public uint GetSpriteQuality(int index)
+ {
+ return XSpriteSystemDocument._spriteTable.GetBySpriteID(this._spriteList[index].SpriteID).SpriteQuality;
+ }
+
+ public uint GetSpriteLevelUpExp(int index)
+ {
+ uint result = 0u;
+ uint key = this.GetSpriteQuality(index) * XSpriteSystemDocument.K_LEVELUPQUALITY + this._spriteList[index].Level;
+ bool flag = !XSpriteSystemDocument._levelUpExpDict.TryGetValue(key, out result);
+ if (flag)
+ {
+ XSingleton<XDebug>.singleton.AddErrorLog(string.Format("Can't find the sprite's exp, quality = {0}, level = {1}.", this.GetSpriteQuality(index), this._spriteList[index].Level), null, null, null, null, null);
+ }
+ return result;
+ }
+
+ public uint GetSpriteLevelUpExpByLevel(int index, int level)
+ {
+ uint result = 0u;
+ uint key = this.GetSpriteQuality(index) * XSpriteSystemDocument.K_LEVELUPQUALITY + (uint)level;
+ bool flag = !XSpriteSystemDocument._levelUpExpDict.TryGetValue(key, out result);
+ if (flag)
+ {
+ XSingleton<XDebug>.singleton.AddErrorLog(string.Format("Can't find the sprite's exp, quality = {0}, level = {1}.", this.GetSpriteQuality(index), this._spriteList[index].Level), null, null, null, null, null);
+ }
+ return result;
+ }
+
+ public SpriteEvolution.RowData GetStarUpData(uint quality, uint star)
+ {
+ for (int i = 0; i < XSpriteSystemDocument._spriteEvolutionTable.Table.Length; i++)
+ {
+ SpriteEvolution.RowData rowData = XSpriteSystemDocument._spriteEvolutionTable.Table[i];
+ bool flag = (uint)rowData.Quality == quality && (uint)rowData.EvolutionLevel == star + 1u;
+ if (flag)
+ {
+ return rowData;
+ }
+ }
+ XSingleton<XDebug>.singleton.AddErrorLog(string.Format("Can't find the sprite starUp's condition from SpriteEvolution.txt, quality = {0}, star = {1}.", quality, star + 1u), null, null, null, null, null);
+ return null;
+ }
+
+ public double CalAptitude(uint AttrID, double AttrValue, XAttributes attributes = null)
+ {
+ return XSingleton<XPowerPointCalculator>.singleton.GetPPT(AttrID, AttrValue, null, 0) * this.GroupRatio;
+ }
+
+ public double GetMaxAptitude(uint spriteID, int index)
+ {
+ SpriteTable.RowData bySpriteID = XSpriteSystemDocument._spriteTable.GetBySpriteID(spriteID);
+ double result;
+ switch (index)
+ {
+ case 0:
+ result = this.CalAptitude(bySpriteID.AttrID1, bySpriteID.Range1[1], null);
+ break;
+ case 1:
+ result = this.CalAptitude(bySpriteID.AttrID2, bySpriteID.Range2[1], null);
+ break;
+ case 2:
+ result = this.CalAptitude(bySpriteID.AttrID3, bySpriteID.Range3[1], null);
+ break;
+ case 3:
+ result = this.CalAptitude(bySpriteID.AttrID4, bySpriteID.Range4[1], null);
+ break;
+ case 4:
+ result = this.CalAptitude(bySpriteID.AttrID5, bySpriteID.Range5[1], null);
+ break;
+ default:
+ XSingleton<XDebug>.singleton.AddErrorLog("GetMaxAptitude error. index is out of the range. index = ", index.ToString(), null, null, null, null);
+ result = 0.0;
+ break;
+ }
+ return result;
+ }
+
+ public void OnSpriteChange(PtcG2C_SpriteChangedNtf ptc)
+ {
+ bool flag = ptc.Data.NewSprites.Count != 0;
+ if (flag)
+ {
+ this.DealWithSpriteAdd(ptc.Data.NewSprites);
+ }
+ bool flag2 = ptc.Data.ChangedSprites.Count != 0;
+ if (flag2)
+ {
+ this.DealWithSpriteChange(ptc.Data.ChangedSprites);
+ }
+ bool flag3 = ptc.Data.RemovedSprites.Count != 0;
+ if (flag3)
+ {
+ this.DealWithSpriteRemove(ptc.Data.RemovedSprites);
+ }
+ this.CalNeed2FightSprite();
+ this.CheckView();
+ }
+
+ private void DealWithSpriteAdd(List<SpriteInfo> list)
+ {
+ for (int i = 0; i < list.Count; i++)
+ {
+ this._spriteList.Add(list[i]);
+ int num = -1;
+ for (int j = 0; j < XSpriteSystemDocument._spriteTable.Table.Length; j++)
+ {
+ bool flag = list[i].SpriteID == XSpriteSystemDocument._spriteTable.Table[j].SpriteID;
+ if (flag)
+ {
+ num = j;
+ break;
+ }
+ }
+ bool flag2 = num < this._bookList.Count && num >= 0;
+ if (flag2)
+ {
+ this._bookList[num] = true;
+ }
+ }
+ this.DealWithResolveList();
+ }
+
+ private void DealWithSpriteChange(List<SpriteInfo> list)
+ {
+ Dictionary<ulong, SpriteInfo> dictionary = new Dictionary<ulong, SpriteInfo>();
+ for (int i = 0; i < list.Count; i++)
+ {
+ dictionary[list[i].uid] = list[i];
+ }
+ SpriteInfo value = null;
+ for (int j = 0; j < this._spriteList.Count; j++)
+ {
+ bool flag = dictionary.TryGetValue(this._spriteList[j].uid, out value);
+ if (flag)
+ {
+ this._spriteList[j] = value;
+ }
+ }
+ }
+
+ private void DealWithSpriteRemove(List<ulong> list)
+ {
+ List<SpriteInfo> list2 = new List<SpriteInfo>();
+ HashSet<ulong> hashSet = new HashSet<ulong>();
+ for (int i = 0; i < list.Count; i++)
+ {
+ hashSet.Add(list[i]);
+ }
+ for (int j = 0; j < this._spriteList.Count; j++)
+ {
+ bool flag = !hashSet.Contains(this._spriteList[j].uid);
+ if (flag)
+ {
+ list2.Add(this._spriteList[j]);
+ }
+ }
+ this._spriteList = list2;
+ this.DealWithResolveList();
+ }
+
+ public void DealWithResolveList()
+ {
+ this._resolveList.Clear();
+ for (int i = 0; i < this._spriteList.Count; i++)
+ {
+ bool flag = !this.isSpriteFight(this._spriteList[i].uid);
+ if (flag)
+ {
+ this._resolveList.Add(this._spriteList[i]);
+ }
+ }
+ }
+
+ private void LevelUp()
+ {
+ XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("SpriteLevelUpTips"), "fece00");
+ bool flag = DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteMainFrame != null && DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteMainFrame.IsVisible();
+ if (flag)
+ {
+ DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteMainFrame._SpriteSelectHandler.SetSpriteList(this._spriteList, false);
+ }
+ }
+
+ public bool QueryFeedSprite(int index, uint feedItemID)
+ {
+ bool flag = index > this._spriteList.Count;
+ bool result;
+ if (flag)
+ {
+ XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("SpriteNull"), "fece00");
+ result = false;
+ }
+ else
+ {
+ bool flag2 = this.SpriteList[index].Level >= XSingleton<XAttributeMgr>.singleton.XPlayerData.Level;
+ if (flag2)
+ {
+ XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("ERR_SPRITE_LEVELMAX"), "fece00");
+ result = false;
+ }
+ else
+ {
+ bool flag3 = XBagDocument.BagDoc.GetItemCount((int)feedItemID) <= 0UL;
+ if (flag3)
+ {
+ XSingleton<UiUtility>.singleton.ShowItemAccess((int)feedItemID, null);
+ result = false;
+ }
+ else
+ {
+ XSingleton<XDebug>.singleton.AddLog(string.Format("Feed sprite index : {0}, food : {1}", index, feedItemID), null, null, null, null, null, XDebugColor.XDebug_None);
+ RpcC2G_SpriteOperation rpcC2G_SpriteOperation = new RpcC2G_SpriteOperation();
+ rpcC2G_SpriteOperation.oArg.Type = SpriteType.Sprite_Feed;
+ rpcC2G_SpriteOperation.oArg.uid = this._spriteList[index].uid;
+ rpcC2G_SpriteOperation.oArg.FeedItemID = feedItemID;
+ XSingleton<XClientNetwork>.singleton.Send(rpcC2G_SpriteOperation);
+ result = true;
+ }
+ }
+ }
+ return result;
+ }
+
+ public void QueryTrain(int index, List<uint> lockAttrList)
+ {
+ RpcC2G_SpriteOperation rpcC2G_SpriteOperation = new RpcC2G_SpriteOperation();
+ rpcC2G_SpriteOperation.oArg.Type = SpriteType.Sprite_Train;
+ rpcC2G_SpriteOperation.oArg.uid = this._spriteList[index].uid;
+ for (int i = 0; i < lockAttrList.Count; i++)
+ {
+ rpcC2G_SpriteOperation.oArg.notToChoose.Add(lockAttrList[i]);
+ }
+ XSingleton<XClientNetwork>.singleton.Send(rpcC2G_SpriteOperation);
+ }
+
+ public void QueryResetTrain(int index, SpriteType type, uint costChoose = 0u)
+ {
+ RpcC2G_SpriteOperation rpcC2G_SpriteOperation = new RpcC2G_SpriteOperation();
+ rpcC2G_SpriteOperation.oArg.Type = type;
+ rpcC2G_SpriteOperation.oArg.uid = this._spriteList[index].uid;
+ rpcC2G_SpriteOperation.oArg.resetTrainChoose = costChoose;
+ XSingleton<XClientNetwork>.singleton.Send(rpcC2G_SpriteOperation);
+ }
+
+ public void QueryStarUp(int index)
+ {
+ RpcC2G_SpriteOperation rpcC2G_SpriteOperation = new RpcC2G_SpriteOperation();
+ rpcC2G_SpriteOperation.oArg.Type = SpriteType.Sprite_Evolution;
+ rpcC2G_SpriteOperation.oArg.uid = this._spriteList[index].uid;
+ XSingleton<XClientNetwork>.singleton.Send(rpcC2G_SpriteOperation);
+ }
+
+ public void QueryFightOut(ulong uid)
+ {
+ RpcC2G_SpriteOperation rpcC2G_SpriteOperation = new RpcC2G_SpriteOperation();
+ rpcC2G_SpriteOperation.oArg.Type = SpriteType.Sprite_OutFight;
+ rpcC2G_SpriteOperation.oArg.uid = uid;
+ XSingleton<XClientNetwork>.singleton.Send(rpcC2G_SpriteOperation);
+ }
+
+ public void QueryFightIn(ulong uid)
+ {
+ RpcC2G_SpriteOperation rpcC2G_SpriteOperation = new RpcC2G_SpriteOperation();
+ rpcC2G_SpriteOperation.oArg.Type = SpriteType.Sprite_InFight;
+ rpcC2G_SpriteOperation.oArg.uid = uid;
+ XSingleton<XClientNetwork>.singleton.Send(rpcC2G_SpriteOperation);
+ }
+
+ public void QuerySwapTeamLeader(ulong uid)
+ {
+ RpcC2G_SpriteOperation rpcC2G_SpriteOperation = new RpcC2G_SpriteOperation();
+ rpcC2G_SpriteOperation.oArg.Type = SpriteType.Sprite_SwapLeader;
+ rpcC2G_SpriteOperation.oArg.uid = uid;
+ XSingleton<XClientNetwork>.singleton.Send(rpcC2G_SpriteOperation);
+ }
+
+ public void QueryOpenStarUpWindow(ulong uid)
+ {
+ bool flag = (ulong)XSingleton<XAttributeMgr>.singleton.XPlayerData.Level < (ulong)((long)this._starUpLimitLevel);
+ if (flag)
+ {
+ XSingleton<UiUtility>.singleton.ShowSystemTip(string.Format(XStringDefineProxy.GetString("SpriteStarUpLevelLimit"), this._starUpLimitLevel), "fece00");
+ }
+ else
+ {
+ RpcC2G_SpriteOperation rpcC2G_SpriteOperation = new RpcC2G_SpriteOperation();
+ rpcC2G_SpriteOperation.oArg.Type = SpriteType.Sprite_QueryEvolutionPPT;
+ rpcC2G_SpriteOperation.oArg.uid = uid;
+ XSingleton<XClientNetwork>.singleton.Send(rpcC2G_SpriteOperation);
+ }
+ }
+
+ public void QueryResolveSprite(List<SpriteInfo> list)
+ {
+ RpcC2G_SpriteOperation rpcC2G_SpriteOperation = new RpcC2G_SpriteOperation();
+ rpcC2G_SpriteOperation.oArg.Type = SpriteType.Sprite_Decompose;
+ rpcC2G_SpriteOperation.oArg.uids.Clear();
+ for (int i = 0; i < list.Count; i++)
+ {
+ rpcC2G_SpriteOperation.oArg.uids.Add(list[i].uid);
+ }
+ XSingleton<XClientNetwork>.singleton.Send(rpcC2G_SpriteOperation);
+ }
+
+ public void CheckView()
+ {
+ bool flag = DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteMainFrame != null && DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteMainFrame.IsVisible();
+ if (flag)
+ {
+ DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteMainFrame._SpriteSelectHandler.SetSpriteList(this._spriteList, false);
+ }
+ bool flag2 = DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteResolveFrame != null && DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteResolveFrame.IsVisible();
+ if (flag2)
+ {
+ DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteResolveFrame._SpriteSelectHandler.SetSpriteList(this._resolveList, true);
+ }
+ bool flag3 = DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteMainFrame != null && DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteMainFrame.IsVisible();
+ if (flag3)
+ {
+ bool flag4 = DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteMainFrame.CurrentClick < this.SpriteList.Count;
+ if (flag4)
+ {
+ SpriteInfo spriteData = this.SpriteList[DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteMainFrame.CurrentClick];
+ DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteMainFrame._SpritePropertyHandler.SetSpriteAttributeInfo(spriteData, XSingleton<XAttributeMgr>.singleton.XPlayerData, null);
+ DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteMainFrame._SpriteAvatarHandler.SetSpriteInfo(spriteData, XSingleton<XAttributeMgr>.singleton.XPlayerData, 0, false, false);
+ }
+ }
+ }
+
+ public void SendLotteryRpc(uint lotteryType)
+ {
+ bool flag = Time.time - this.LastLotteryTime < 3f;
+ if (!flag)
+ {
+ this.LastLotteryTime = Time.time;
+ this.CurrentLotteryType = lotteryType;
+ RpcC2G_DrawLottery rpcC2G_DrawLottery = new RpcC2G_DrawLottery();
+ rpcC2G_DrawLottery.oArg.type = lotteryType;
+ XSingleton<XClientNetwork>.singleton.Send(rpcC2G_DrawLottery);
+ }
+ }
+
+ public void SendBuySpriteEggRpc(uint lotteryType)
+ {
+ RpcC2G_BuySpriteEgg rpcC2G_BuySpriteEgg = new RpcC2G_BuySpriteEgg();
+ rpcC2G_BuySpriteEgg.oArg.type = lotteryType;
+ XSingleton<XClientNetwork>.singleton.Send(rpcC2G_BuySpriteEgg);
+ }
+
+ public void QueryBuyEggCD()
+ {
+ RpcC2G_QueryLotteryCD rpc = new RpcC2G_QueryLotteryCD();
+ XSingleton<XClientNetwork>.singleton.Send(rpc);
+ }
+
+ public void OnQueryLotteryCD(uint normalCoolDown, uint specialCoolDown, uint normalFreeCount, uint specialSafeCount)
+ {
+ this.SpecialSafeCount = specialSafeCount;
+ this.SetBuyEggData(normalCoolDown, specialCoolDown, normalFreeCount);
+ this.RefreshSafeCountUI();
+ }
+
+ public void SetBuyEggData(uint normalCoolDown, uint specialCoolDown, uint normalFreeCount)
+ {
+ this.NormalCoolDown = normalCoolDown;
+ this.NormalFreeCount = normalFreeCount;
+ this.SpecialCoolDown = specialCoolDown;
+ XSingleton<XGameSysMgr>.singleton.SetSysRedPointState(XSysDefine.XSys_SpriteSystem_Shop, (this.NormalCoolDown == 0u && this.NormalFreeCount != this.NormalMaxCount) || this.SpecialCoolDown == 0u);
+ XSingleton<XGameSysMgr>.singleton.RecalculateRedPointState(XSysDefine.XSys_SpriteSystem_Shop, true);
+ bool flag = DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteShopHandler == null;
+ if (!flag)
+ {
+ bool flag2 = !DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteShopHandler.IsVisible();
+ if (!flag2)
+ {
+ DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteShopHandler.RefreshLotteryFrame();
+ }
+ }
+ }
+
+ public void SetBuyEggItem(List<ItemBrief> item)
+ {
+ bool flag = !DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton.IsVisible();
+ if (!flag)
+ {
+ bool flag2 = DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteShopHandler == null;
+ if (!flag2)
+ {
+ bool flag3 = !DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteShopHandler.IsVisible();
+ if (!flag3)
+ {
+ DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteShopHandler.ShowResultFrame(item);
+ DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton.CheckSpriteSummonRedpoint();
+ }
+ }
+ }
+ }
+
+ public void SetLotteryData(uint specialSafeCount)
+ {
+ this.SpecialSafeCount = specialSafeCount;
+ this.RefreshSafeCountUI();
+ }
+
+ private void RefreshSafeCountUI()
+ {
+ bool flag = !DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton.IsVisible();
+ if (!flag)
+ {
+ bool flag2 = DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteLotteryHandler == null;
+ if (!flag2)
+ {
+ bool flag3 = !DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteLotteryHandler.IsVisible();
+ if (!flag3)
+ {
+ DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteLotteryHandler.RefreshSafeCountUI();
+ }
+ }
+ }
+ }
+
+ public void SetLotteryResultData(List<ItemBrief> itemList, List<uint> spritePPT, LotteryType type)
+ {
+ this.CachedLotteryResult.Clear();
+ this.ResultShowList.Clear();
+ this.CachedLotteryPPT.Clear();
+ int num = 0;
+ for (int i = 0; i < itemList.Count; i++)
+ {
+ this.CachedLotteryResult.Add(itemList[i]);
+ ItemList.RowData itemConf = XBagDocument.GetItemConf((int)itemList[i].itemID);
+ this.ResultShowList.Add(itemConf != null && itemConf.ItemType == 18 && itemConf.ItemQuality > 2);
+ bool flag = itemConf != null && itemConf.ItemType == 18 && num < spritePPT.Count;
+ if (flag)
+ {
+ this.CachedLotteryPPT.Add(spritePPT[num]);
+ num++;
+ }
+ else
+ {
+ this.CachedLotteryPPT.Add(0u);
+ }
+ }
+ bool flag2 = !DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton.IsVisible();
+ if (!flag2)
+ {
+ bool flag3 = DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteLotteryHandler == null;
+ if (!flag3)
+ {
+ bool flag4 = !DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteLotteryHandler.IsVisible();
+ if (!flag4)
+ {
+ DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton.CheckSpriteSummonRedpoint();
+ if (type - LotteryType.Sprite_Draw_One > 2)
+ {
+ if (type - LotteryType.Sprite_GoldDraw_One <= 2)
+ {
+ this.PlayLotteryCutscene("CutScene/Spirit_lottery_cutscene_fall_gold", false, true);
+ }
+ }
+ else
+ {
+ this.PlayLotteryCutscene("CutScene/Spirit_lottery_cutscene_fall_diamond", false, true);
+ }
+ XSingleton<XTimerMgr>.singleton.SetTimer(XSingleton<XCutScene>.singleton.Length - 0.05f, new XTimerMgr.ElapsedEventHandler(this.RestoreLotteryUI), null);
+ }
+ }
+ }
+ }
+
+ public void EpicSpriteShow(int id)
+ {
+ this.ResultShowList[id] = false;
+ this.PlayLotteryCutscene("CutScene/Spirit_lottery_cutscene_short", false, false);
+ XSingleton<XTimerMgr>.singleton.SetTimer(XSingleton<XCutScene>.singleton.Length - 0.05f, new XTimerMgr.ElapsedEventHandler(this.RestoreLotteryResultUI), id);
+ }
+
+ private void PlayLotteryCutscene(string path, bool bFadeAtBegin, bool bFadeAtEnd)
+ {
+ XSingleton<XCutScene>.singleton.Start(path, bFadeAtBegin, bFadeAtEnd);
+ XSingleton<XScene>.singleton.GameCamera.UnityCamera.enabled = true;
+ XSingleton<XTimerMgr>.singleton.SetTimer(0.05f, new XTimerMgr.ElapsedEventHandler(this.HideAllUIWithOutCall), null);
+ }
+
+ private void RestoreUI(object o = null)
+ {
+ XSingleton<XScene>.singleton.GameCamera.UnityCamera.enabled = false;
+ XSingleton<UIManager>.singleton.RestoreAllUIWithOutCall();
+ }
+
+ private void HideAllUIWithOutCall(object o)
+ {
+ XSingleton<UIManager>.singleton.HideAllUIWithOutCall();
+ }
+
+ private void SendWorldNotice(uint itemid)
+ {
+ PtcC2G_OpenSpriteEggNtf ptcC2G_OpenSpriteEggNtf = new PtcC2G_OpenSpriteEggNtf();
+ ptcC2G_OpenSpriteEggNtf.Data.itemid = itemid;
+ XSingleton<XClientNetwork>.singleton.Send(ptcC2G_OpenSpriteEggNtf);
+ }
+
+ private void RestoreLotteryUI(object o)
+ {
+ this.RestoreUI(null);
+ DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteLotteryHandler.ShowResultFrame();
+ }
+
+ private void RestoreLotteryResultUI(object o)
+ {
+ int index = (int)o;
+ this.SendWorldNotice(this.CachedLotteryResult[index].itemID);
+ this.RestoreUI(null);
+ DlgBase<XSpriteShowView, XSpriteShowBehaviour>.singleton.ShowDetail(this.CachedLotteryResult[index].itemID, this.CachedLotteryPPT[index], true);
+ }
+
+ public bool isSpriteFoodEmpty()
+ {
+ ulong num = 0UL;
+ for (int i = 0; i < (int)this.FoodList.Count; i++)
+ {
+ num += XBagDocument.BagDoc.GetItemCount(this.FoodList[i, 0]);
+ }
+ return num == 0UL;
+ }
+
+ public bool isFightSpriteNeed2Feed(bool outView)
+ {
+ for (int i = 0; i < this._fightingList.Count; i++)
+ {
+ bool flag = this._fightingList[i] == 0UL;
+ if (!flag)
+ {
+ bool flag2 = this.isSpriteNeed2Feed(this._fightingList[i], outView);
+ if (flag2)
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public bool isSpriteNeed2Feed(ulong uid, bool outView)
+ {
+ int indexByUid = this.GetIndexByUid(uid);
+ bool result;
+ if (outView)
+ {
+ result = ((ulong)XSingleton<XAttributeMgr>.singleton.XPlayerData.Level >= (ulong)this._spriteList[indexByUid].Level + (ulong)((long)this.SpriteRedPointShowIntervel) && this.isSpriteCanLevelUp(indexByUid));
+ }
+ else
+ {
+ result = (XSingleton<XAttributeMgr>.singleton.XPlayerData.Level > this._spriteList[indexByUid].Level && this.isSpriteCanLevelUp(indexByUid));
+ }
+ return result;
+ }
+
+ private bool isSpriteCanLevelUp(int index)
+ {
+ int num = 0;
+ for (int i = 0; i < (int)this.FoodList.Count; i++)
+ {
+ num += (int)XBagDocument.BagDoc.GetItemCount(this.FoodList[i, 0]) * this.FoodList[i, 1];
+ }
+ return this._spriteList[index].Exp + (uint)num >= this.GetSpriteLevelUpExp(index);
+ }
+
+ public XFx CreateAndPlayFx(string path, Transform parent)
+ {
+ XFx xfx = XSingleton<XFxMgr>.singleton.CreateFx(path, null, true);
+ bool flag = xfx == null;
+ XFx result;
+ if (flag)
+ {
+ result = null;
+ }
+ else
+ {
+ xfx.Play(parent, Vector3.zero, Vector3.one, 1f, true, false);
+ result = xfx;
+ }
+ return result;
+ }
+
+ public void DestroyFx(XFx fx)
+ {
+ bool flag = fx == null;
+ if (!flag)
+ {
+ XSingleton<XFxMgr>.singleton.DestroyFx(fx, true);
+ }
+ }
+
+ public void ReqSpriteOperation(SpriteType type)
+ {
+ int currentClick = DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteMainFrame.CurrentClick;
+ bool flag = currentClick >= this.SpriteList.Count;
+ if (!flag)
+ {
+ RpcC2G_SpriteOperation rpcC2G_SpriteOperation = new RpcC2G_SpriteOperation();
+ rpcC2G_SpriteOperation.oArg.Type = type;
+ rpcC2G_SpriteOperation.oArg.uid = this.SpriteList[currentClick].uid;
+ XSingleton<XClientNetwork>.singleton.Send(rpcC2G_SpriteOperation);
+ }
+ }
+
+ public void OnSpriteOperation(SpriteOperationArg oArg, SpriteOperationRes oRes)
+ {
+ bool flag = oRes.ErrorCode > ErrorCode.ERR_SUCCESS;
+ if (flag)
+ {
+ XSingleton<UiUtility>.singleton.ShowSystemTip(oRes.ErrorCode, "fece00");
+ ErrorCode errorCode = oRes.ErrorCode;
+ if (errorCode == ErrorCode.ERR_SPRITE_EVOLUTION_LACKOFCOST)
+ {
+ bool flag2 = DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._StarUpWindow != null && DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._StarUpWindow.IsVisible();
+ if (flag2)
+ {
+ DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._StarUpWindow.SetVisible(false);
+ }
+ XSingleton<UiUtility>.singleton.ShowItemAccess(XSingleton<XGlobalConfig>.singleton.GetInt("SpriteStarUpItemID"), null);
+ }
+ }
+ else
+ {
+ switch (oArg.Type)
+ {
+ case SpriteType.Sprite_Feed:
+ {
+ for (int i = 0; i < this._spriteList.Count; i++)
+ {
+ bool flag3 = this._spriteList[i].uid == oArg.uid;
+ if (flag3)
+ {
+ this._spriteList[i].Exp = oRes.Exp;
+ break;
+ }
+ }
+ bool flag4 = DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteMainFrame != null;
+ if (flag4)
+ {
+ DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteMainFrame.OnServerReturn(oArg.uid);
+ }
+ XWelfareDocument specificDocument = XDocuments.GetSpecificDocument<XWelfareDocument>(XWelfareDocument.uuID);
+ for (int j = 0; j < (int)this.FoodList.Count; j++)
+ {
+ bool flag5 = this.FoodList[j, 0] == (int)oArg.FeedItemID;
+ if (flag5)
+ {
+ this._expTotal += (uint)this.FoodList[j, 1];
+ break;
+ }
+ }
+ XSingleton<XTimerMgr>.singleton.KillTimer(this._timerToken);
+ this._timerToken = XSingleton<XTimerMgr>.singleton.SetTimer((float)this._showExpTime, new XTimerMgr.ElapsedEventHandler(this.ShowGetExp), null);
+ break;
+ }
+ case SpriteType.Sprite_Evolution:
+ case SpriteType.Sprite_Train:
+ case SpriteType.Sprite_ResetTrain:
+ case SpriteType.Sprite_Rebirth:
+ {
+ bool flag6 = DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._StarUpWindow != null && DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._StarUpWindow.IsVisible();
+ if (flag6)
+ {
+ bool flag7 = oArg.Type == SpriteType.Sprite_Train;
+ if (flag7)
+ {
+ DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._StarUpWindow.LastAttrList.Clear();
+ DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._StarUpWindow.LastValueList.Clear();
+ for (int k = 0; k < oRes.LastTrainAttrID.Count; k++)
+ {
+ DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._StarUpWindow.LastAttrList.Add((int)oRes.LastTrainAttrID[k]);
+ DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._StarUpWindow.LastValueList.Add((int)oRes.LastTrainAttrValue[k]);
+ }
+ }
+ DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._StarUpWindow.OnServerReturn(oArg.Type);
+ }
+ break;
+ }
+ case SpriteType.Sprite_Awake:
+ {
+ bool flag8 = DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._AwakeWindow == null || !DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._AwakeWindow.IsVisible();
+ if (flag8)
+ {
+ DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton.OpenWindows(SpriteWindow.Awake);
+ }
+ bool flag9 = DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._AwakeWindow != null;
+ if (flag9)
+ {
+ DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._AwakeWindow.SetSpritesInfo(oRes.AwakeSpriteBefore, oRes.AwakeSprite);
+ }
+ bool flag10 = DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteMainFrame != null;
+ if (flag10)
+ {
+ DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteMainFrame.RefreshAwakeBtn();
+ }
+ break;
+ }
+ case SpriteType.Sprite_Awake_Retain:
+ case SpriteType.Sprite_Awake_Replace:
+ {
+ bool flag11 = DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._AwakeWindow != null;
+ if (flag11)
+ {
+ DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._AwakeWindow.SetVisible(false);
+ }
+ break;
+ }
+ case SpriteType.Sprite_InFight:
+ case SpriteType.Sprite_OutFight:
+ case SpriteType.Sprite_SwapLeader:
+ {
+ this.SetFightList(oRes.InFight);
+ this.CalNeed2FightSprite();
+ bool flag12 = DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteFightFrame != null && DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteFightFrame.IsVisible() && DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteFightFrame._SpriteSelectHandler != null;
+ if (flag12)
+ {
+ DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteFightFrame._SpriteSelectHandler.SetSpriteList(this._spriteList, false);
+ DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteFightFrame.RefreshFightList();
+ }
+ break;
+ }
+ case SpriteType.Sprite_Decompose:
+ {
+ bool flag13 = DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteResolveFrame != null && DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteResolveFrame.IsVisible();
+ if (flag13)
+ {
+ DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteResolveFrame.Clean();
+ }
+ break;
+ }
+ case SpriteType.Sprite_QueryEvolutionPPT:
+ {
+ bool flag14 = DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteMainFrame != null && DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton._SpriteMainFrame.IsVisible();
+ if (flag14)
+ {
+ DlgBase<SpriteSystemDlg, TabDlgBehaviour>.singleton.OpenWindows(SpriteWindow.StarUp);
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ public double GetSpriteLevelRatio(uint quality, uint level)
+ {
+ for (int i = 0; i < this._SpriteLevelTable.Table.Length; i++)
+ {
+ SpriteLevel.RowData rowData = this._SpriteLevelTable.Table[i];
+ bool flag = rowData.Quality == level && rowData.Level == level;
+ if (flag)
+ {
+ return rowData.Ratio;
+ }
+ }
+ return 0.0;
+ }
+
+ private void ShowGetExp(object o = null)
+ {
+ XWelfareDocument specificDocument = XDocuments.GetSpecificDocument<XWelfareDocument>(XWelfareDocument.uuID);
+ XSingleton<UiUtility>.singleton.ShowSystemTip(string.Format(XStringDefineProxy.GetString("SpriteExpTips"), this._expTotal), "fece00");
+ this._expTotal = 0u;
+ }
+
+ public void ShowGetSpriteWithAnimation(uint spriteID, uint ppt)
+ {
+ DlgBase<XSpriteShowView, XSpriteShowBehaviour>.singleton.ShowDetail(spriteID, ppt, false);
+ }
+
+ private bool _OnBuffChange(XEventArgs args)
+ {
+ XBuffChangeEventArgs xbuffChangeEventArgs = args as XBuffChangeEventArgs;
+ bool flag = xbuffChangeEventArgs.addBuff != null && xbuffChangeEventArgs.addBuff.buffInfo != null;
+ if (flag)
+ {
+ bool flag2 = XBuff.HasTag(xbuffChangeEventArgs.addBuff.buffInfo, XBuffTag.BT_SpriteEffect);
+ if (flag2)
+ {
+ XSpriteSystemDocument.SpriteSkillCast(xbuffChangeEventArgs.entity);
+ }
+ }
+ return true;
+ }
+
+ public static void SpriteSkillCast(XEntity entity)
+ {
+ bool isPlayer = entity.IsPlayer;
+ if (isPlayer)
+ {
+ uint leaderid = entity.Attributes.Outlook.sprite.leaderid;
+ SpriteTable.RowData bySpriteID = XSpriteSystemDocument._spriteTable.GetBySpriteID(leaderid);
+ bool flag = bySpriteID != null;
+ if (flag)
+ {
+ XSpriteSystemDocument specificDocument = XDocuments.GetSpecificDocument<XSpriteSystemDocument>(XSpriteSystemDocument.uuID);
+ SpriteSkill.RowData mySpriteInitiativeSkill = specificDocument.GetMySpriteInitiativeSkill();
+ bool flag2 = mySpriteInitiativeSkill != null;
+ if (flag2)
+ {
+ bool flag3 = !XSingleton<XGame>.singleton.SyncMode && mySpriteInitiativeSkill.ShowNotice[0] != 0;
+ if (flag3)
+ {
+ XInvitationDocument specificDocument2 = XDocuments.GetSpecificDocument<XInvitationDocument>(XInvitationDocument.uuID);
+ NoticeTable.RowData noticeData = specificDocument2.GetNoticeData(NoticeType.NT_SPRITE_SKILLCAST);
+ bool flag4 = noticeData == null;
+ if (flag4)
+ {
+ return;
+ }
+ StringBuilder stringBuilder = new StringBuilder(noticeData.info);
+ stringBuilder.Replace("$R", XStringDefineProxy.GetString("YOU"));
+ int num = XSpriteSystemDocument._Find(stringBuilder, "$C");
+ bool flag5 = num != -1;
+ if (flag5)
+ {
+ stringBuilder.Replace("$C", bySpriteID.SpriteName, num, 2);
+ }
+ num = XSpriteSystemDocument._Find(stringBuilder, "$C");
+ bool flag6 = num != -1;
+ if (flag6)
+ {
+ stringBuilder.Replace("$C", mySpriteInitiativeSkill.SkillName, num, 2);
+ }
+ num = XSpriteSystemDocument._Find(stringBuilder, "$C");
+ bool flag7 = num != -1;
+ if (flag7)
+ {
+ stringBuilder.Replace("$C", mySpriteInitiativeSkill.NoticeDetail, num, 2);
+ }
+ KKSG.ChatInfo chatInfo = new KKSG.ChatInfo();
+ chatInfo.info = stringBuilder.ToString();
+ chatInfo.channel = (uint)noticeData.channel;
+ XChatDocument specificDocument3 = XDocuments.GetSpecificDocument<XChatDocument>(XChatDocument.uuID);
+ specificDocument3.HandlerReceiveChatInfo(chatInfo);
+ }
+ bool flag8 = mySpriteInitiativeSkill.ShowNotice[1] != 0;
+ if (flag8)
+ {
+ XAffiliate xaffiliate = null;
+ bool flag9 = !entity.IsTransform && entity.Equipment != null;
+ if (flag9)
+ {
+ xaffiliate = entity.Equipment.Sprite;
+ }
+ bool flag10 = xaffiliate != null;
+ if (flag10)
+ {
+ XBubbleComponent xbubbleComponent = xaffiliate.GetXComponent(XBubbleComponent.uuID) as XBubbleComponent;
+ bool flag11 = xbubbleComponent == null;
+ if (flag11)
+ {
+ XSingleton<XComponentMgr>.singleton.CreateComponent(xaffiliate, XBubbleComponent.uuID);
+ }
+ XBubbleEventArgs @event = XEventPool<XBubbleEventArgs>.GetEvent();
+ @event.bubbletext = mySpriteInitiativeSkill.SkillName;
+ @event.existtime = 3f;
+ @event.Firer = xaffiliate;
+ @event.speaker = string.Empty;
+ XSingleton<XEventMgr>.singleton.FireEvent(@event);
+ }
+ }
+ bool flag12 = !string.IsNullOrEmpty(mySpriteInitiativeSkill.Audio);
+ if (flag12)
+ {
+ XSingleton<XAudioMgr>.singleton.PlaySound(entity, AudioChannel.Action, mySpriteInitiativeSkill.Audio);
+ }
+ }
+ }
+ }
+ }
+
+ private static int _Find(StringBuilder sb, string s)
+ {
+ int num = sb.Length - s.Length + 1;
+ for (int i = 0; i < num; i++)
+ {
+ bool flag = true;
+ int num2 = i;
+ int num3 = 0;
+ while (num2 < num && num3 < s.Length)
+ {
+ bool flag2 = sb[num2] != s[num3];
+ if (flag2)
+ {
+ flag = false;
+ break;
+ }
+ num2++;
+ num3++;
+ }
+ bool flag3 = flag;
+ if (flag3)
+ {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ private bool OnPlayerLevelChange(XEventArgs arg)
+ {
+ this.DealWithPositionLevelCondition();
+ return true;
+ }
+ }
+}