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.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 SpriteShowInIllustration { get { return XSpriteSystemDocument._spriteShowInIllustration; } } public Dictionary> _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 SpriteList { get { return this._spriteList; } } public List ResolveList { get { return this._resolveList; } } public List FightingList { get { return this._fightingList; } } public List BookList { get { return this._bookList; } } public uint MaxFightNum { get { return this._maxFightNum; } } public new static readonly uint uuID = XSingleton.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 _spriteList = new List(); private List _resolveList = new List(); private List _fightingList = new List(); private List _bookList = new List(); private HashSet _fightHash = new HashSet(); private HashSet _redPointSpriteHash = new HashSet(); private static Dictionary _levelUpExpDict = new Dictionary(); private static Dictionary> _spriteSkillDict = new Dictionary>(); private static Dictionary> _spriteEggIllustrationDict = new Dictionary>(); private static List _spriteShowInIllustration = new List(); public List PositionLevelCondition = new List(); private uint _maxFightNum; private static readonly uint K_LEVELUPQUALITY = 10000u; public static List MAXSTARLEVEL = new List { 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 FoodList; public SpriteHandlerTag CurrentTag; private uint GroupRatio; private int _starUpLimitLevel; public List CachedLotteryResult = new List(); public List CachedLotteryPPT = new List(); public List ResultShowList = new List(); 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 value; bool flag = !XSpriteSystemDocument._spriteSkillDict.TryGetValue(skillID, out value); if (flag) { value = new List(); 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 list; bool flag4 = !XSpriteSystemDocument._spriteEggIllustrationDict.TryGetValue(key, out list); if (flag4) { list = new List(); 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(this.Compare)); this.CalNeed2FightSprite(); this._resolveList.Sort(new Comparison(this.Compare)); } public SpriteSkill.RowData GetSpriteSkillData(short skillID, bool mainSkill, uint starLevel) { List 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.singleton.GetInt("SpriteRedPointShowIntervel"); for (int i = 0; i < 6; i++) { this.NAMECOLOR[i] = XSingleton.singleton.GetValue(string.Format("Quality{0}Color", i)); } for (int j = 0; j < 4; j++) { this._fightingList.Add(0UL); } this.GroupRatio = (uint)XSingleton.singleton.GetInt("SpriteGrowUpRatio"); this.NormalMaxCount = (uint)XSingleton.singleton.GetInt("SpriteGoldDrawFreeDayCount"); this._showExpTime = double.Parse(XSingleton.singleton.GetValue("SpriteExpShowTime")); this.FoodList = XSingleton.singleton.GetSequenceList("SpriteFoodExp", false); this._starUpLimitLevel = XSingleton.singleton.GetInt("SpriteEvolutionMinLevel"); XWelfareDocument specificDocument = XDocuments.GetSpecificDocument(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.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.singleton.GetUIntList("SpritePositionLevel"); bool flag = this.PositionLevelCondition.Count != 4; if (flag) { XSingleton.singleton.AddErrorLog("Error! get PositionLevelCondition's cout from globalconfig error! the cout isn't 4", null, null, null, null, null); } uint level = XSingleton.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.singleton._SpriteFightFrame != null; if (flag3) { DlgBase.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 hashSet = new HashSet(); 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(new bool[XSpriteSystemDocument._spriteTable.Table.Length]); XSingleton.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.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.singleton.XPlayerData.Outlook.SetSpriteData(this._spriteList[indexByUid].SpriteID); } bool flag4 = XSingleton.singleton.Player != null; if (flag4) { XEquipComponent xequipComponent = XSingleton.singleton.Player.GetXComponent(XEquipComponent.uuID) as XEquipComponent; uint presentID = xequipComponent.SpriteFromAttr(); XSingleton.singleton.OnSpriteChanged(XSingleton.singleton.Player, presentID); } } private void SetFightList(List 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.singleton.SetSysRedPointState(XSysDefine.XSys_SpriteSystem_Fight, this._redPointSpriteHash.Count != 0); XSingleton.singleton.RecalculateRedPointState(XSysDefine.XSys_SpriteSystem, true); this.CalSpriteMainRedPoint(); } public void CalSpriteMainRedPoint() { bool bState = !this.isSpriteFoodEmpty() && this.isFightSpriteNeed2Feed(true); XSingleton.singleton.SetSysRedPointState(XSysDefine.XSys_SpriteSystem_Main, bState); XSingleton.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.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.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.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.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.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 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 list) { Dictionary dictionary = new Dictionary(); 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 list) { List list2 = new List(); HashSet hashSet = new HashSet(); 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.singleton.ShowSystemTip(XStringDefineProxy.GetString("SpriteLevelUpTips"), "fece00"); bool flag = DlgBase.singleton._SpriteMainFrame != null && DlgBase.singleton._SpriteMainFrame.IsVisible(); if (flag) { DlgBase.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.singleton.ShowSystemTip(XStringDefineProxy.GetString("SpriteNull"), "fece00"); result = false; } else { bool flag2 = this.SpriteList[index].Level >= XSingleton.singleton.XPlayerData.Level; if (flag2) { XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("ERR_SPRITE_LEVELMAX"), "fece00"); result = false; } else { bool flag3 = XBagDocument.BagDoc.GetItemCount((int)feedItemID) <= 0UL; if (flag3) { XSingleton.singleton.ShowItemAccess((int)feedItemID, null); result = false; } else { XSingleton.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.singleton.Send(rpcC2G_SpriteOperation); result = true; } } } return result; } public void QueryTrain(int index, List 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.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.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.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.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.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.singleton.Send(rpcC2G_SpriteOperation); } public void QueryOpenStarUpWindow(ulong uid) { bool flag = (ulong)XSingleton.singleton.XPlayerData.Level < (ulong)((long)this._starUpLimitLevel); if (flag) { XSingleton.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.singleton.Send(rpcC2G_SpriteOperation); } } public void QueryResolveSprite(List 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.singleton.Send(rpcC2G_SpriteOperation); } public void CheckView() { bool flag = DlgBase.singleton._SpriteMainFrame != null && DlgBase.singleton._SpriteMainFrame.IsVisible(); if (flag) { DlgBase.singleton._SpriteMainFrame._SpriteSelectHandler.SetSpriteList(this._spriteList, false); } bool flag2 = DlgBase.singleton._SpriteResolveFrame != null && DlgBase.singleton._SpriteResolveFrame.IsVisible(); if (flag2) { DlgBase.singleton._SpriteResolveFrame._SpriteSelectHandler.SetSpriteList(this._resolveList, true); } bool flag3 = DlgBase.singleton._SpriteMainFrame != null && DlgBase.singleton._SpriteMainFrame.IsVisible(); if (flag3) { bool flag4 = DlgBase.singleton._SpriteMainFrame.CurrentClick < this.SpriteList.Count; if (flag4) { SpriteInfo spriteData = this.SpriteList[DlgBase.singleton._SpriteMainFrame.CurrentClick]; DlgBase.singleton._SpriteMainFrame._SpritePropertyHandler.SetSpriteAttributeInfo(spriteData, XSingleton.singleton.XPlayerData, null); DlgBase.singleton._SpriteMainFrame._SpriteAvatarHandler.SetSpriteInfo(spriteData, XSingleton.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.singleton.Send(rpcC2G_DrawLottery); } } public void SendBuySpriteEggRpc(uint lotteryType) { RpcC2G_BuySpriteEgg rpcC2G_BuySpriteEgg = new RpcC2G_BuySpriteEgg(); rpcC2G_BuySpriteEgg.oArg.type = lotteryType; XSingleton.singleton.Send(rpcC2G_BuySpriteEgg); } public void QueryBuyEggCD() { RpcC2G_QueryLotteryCD rpc = new RpcC2G_QueryLotteryCD(); XSingleton.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.singleton.SetSysRedPointState(XSysDefine.XSys_SpriteSystem_Shop, (this.NormalCoolDown == 0u && this.NormalFreeCount != this.NormalMaxCount) || this.SpecialCoolDown == 0u); XSingleton.singleton.RecalculateRedPointState(XSysDefine.XSys_SpriteSystem_Shop, true); bool flag = DlgBase.singleton._SpriteShopHandler == null; if (!flag) { bool flag2 = !DlgBase.singleton._SpriteShopHandler.IsVisible(); if (!flag2) { DlgBase.singleton._SpriteShopHandler.RefreshLotteryFrame(); } } } public void SetBuyEggItem(List item) { bool flag = !DlgBase.singleton.IsVisible(); if (!flag) { bool flag2 = DlgBase.singleton._SpriteShopHandler == null; if (!flag2) { bool flag3 = !DlgBase.singleton._SpriteShopHandler.IsVisible(); if (!flag3) { DlgBase.singleton._SpriteShopHandler.ShowResultFrame(item); DlgBase.singleton.CheckSpriteSummonRedpoint(); } } } } public void SetLotteryData(uint specialSafeCount) { this.SpecialSafeCount = specialSafeCount; this.RefreshSafeCountUI(); } private void RefreshSafeCountUI() { bool flag = !DlgBase.singleton.IsVisible(); if (!flag) { bool flag2 = DlgBase.singleton._SpriteLotteryHandler == null; if (!flag2) { bool flag3 = !DlgBase.singleton._SpriteLotteryHandler.IsVisible(); if (!flag3) { DlgBase.singleton._SpriteLotteryHandler.RefreshSafeCountUI(); } } } } public void SetLotteryResultData(List itemList, List 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.singleton.IsVisible(); if (!flag2) { bool flag3 = DlgBase.singleton._SpriteLotteryHandler == null; if (!flag3) { bool flag4 = !DlgBase.singleton._SpriteLotteryHandler.IsVisible(); if (!flag4) { DlgBase.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.singleton.SetTimer(XSingleton.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.singleton.SetTimer(XSingleton.singleton.Length - 0.05f, new XTimerMgr.ElapsedEventHandler(this.RestoreLotteryResultUI), id); } private void PlayLotteryCutscene(string path, bool bFadeAtBegin, bool bFadeAtEnd) { XSingleton.singleton.Start(path, bFadeAtBegin, bFadeAtEnd); XSingleton.singleton.GameCamera.UnityCamera.enabled = true; XSingleton.singleton.SetTimer(0.05f, new XTimerMgr.ElapsedEventHandler(this.HideAllUIWithOutCall), null); } private void RestoreUI(object o = null) { XSingleton.singleton.GameCamera.UnityCamera.enabled = false; XSingleton.singleton.RestoreAllUIWithOutCall(); } private void HideAllUIWithOutCall(object o) { XSingleton.singleton.HideAllUIWithOutCall(); } private void SendWorldNotice(uint itemid) { PtcC2G_OpenSpriteEggNtf ptcC2G_OpenSpriteEggNtf = new PtcC2G_OpenSpriteEggNtf(); ptcC2G_OpenSpriteEggNtf.Data.itemid = itemid; XSingleton.singleton.Send(ptcC2G_OpenSpriteEggNtf); } private void RestoreLotteryUI(object o) { this.RestoreUI(null); DlgBase.singleton._SpriteLotteryHandler.ShowResultFrame(); } private void RestoreLotteryResultUI(object o) { int index = (int)o; this.SendWorldNotice(this.CachedLotteryResult[index].itemID); this.RestoreUI(null); DlgBase.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.singleton.XPlayerData.Level >= (ulong)this._spriteList[indexByUid].Level + (ulong)((long)this.SpriteRedPointShowIntervel) && this.isSpriteCanLevelUp(indexByUid)); } else { result = (XSingleton.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.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.singleton.DestroyFx(fx, true); } } public void ReqSpriteOperation(SpriteType type) { int currentClick = DlgBase.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.singleton.Send(rpcC2G_SpriteOperation); } } public void OnSpriteOperation(SpriteOperationArg oArg, SpriteOperationRes oRes) { bool flag = oRes.ErrorCode > ErrorCode.ERR_SUCCESS; if (flag) { XSingleton.singleton.ShowSystemTip(oRes.ErrorCode, "fece00"); ErrorCode errorCode = oRes.ErrorCode; if (errorCode == ErrorCode.ERR_SPRITE_EVOLUTION_LACKOFCOST) { bool flag2 = DlgBase.singleton._StarUpWindow != null && DlgBase.singleton._StarUpWindow.IsVisible(); if (flag2) { DlgBase.singleton._StarUpWindow.SetVisible(false); } XSingleton.singleton.ShowItemAccess(XSingleton.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.singleton._SpriteMainFrame != null; if (flag4) { DlgBase.singleton._SpriteMainFrame.OnServerReturn(oArg.uid); } XWelfareDocument specificDocument = XDocuments.GetSpecificDocument(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.singleton.KillTimer(this._timerToken); this._timerToken = XSingleton.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.singleton._StarUpWindow != null && DlgBase.singleton._StarUpWindow.IsVisible(); if (flag6) { bool flag7 = oArg.Type == SpriteType.Sprite_Train; if (flag7) { DlgBase.singleton._StarUpWindow.LastAttrList.Clear(); DlgBase.singleton._StarUpWindow.LastValueList.Clear(); for (int k = 0; k < oRes.LastTrainAttrID.Count; k++) { DlgBase.singleton._StarUpWindow.LastAttrList.Add((int)oRes.LastTrainAttrID[k]); DlgBase.singleton._StarUpWindow.LastValueList.Add((int)oRes.LastTrainAttrValue[k]); } } DlgBase.singleton._StarUpWindow.OnServerReturn(oArg.Type); } break; } case SpriteType.Sprite_Awake: { bool flag8 = DlgBase.singleton._AwakeWindow == null || !DlgBase.singleton._AwakeWindow.IsVisible(); if (flag8) { DlgBase.singleton.OpenWindows(SpriteWindow.Awake); } bool flag9 = DlgBase.singleton._AwakeWindow != null; if (flag9) { DlgBase.singleton._AwakeWindow.SetSpritesInfo(oRes.AwakeSpriteBefore, oRes.AwakeSprite); } bool flag10 = DlgBase.singleton._SpriteMainFrame != null; if (flag10) { DlgBase.singleton._SpriteMainFrame.RefreshAwakeBtn(); } break; } case SpriteType.Sprite_Awake_Retain: case SpriteType.Sprite_Awake_Replace: { bool flag11 = DlgBase.singleton._AwakeWindow != null; if (flag11) { DlgBase.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.singleton._SpriteFightFrame != null && DlgBase.singleton._SpriteFightFrame.IsVisible() && DlgBase.singleton._SpriteFightFrame._SpriteSelectHandler != null; if (flag12) { DlgBase.singleton._SpriteFightFrame._SpriteSelectHandler.SetSpriteList(this._spriteList, false); DlgBase.singleton._SpriteFightFrame.RefreshFightList(); } break; } case SpriteType.Sprite_Decompose: { bool flag13 = DlgBase.singleton._SpriteResolveFrame != null && DlgBase.singleton._SpriteResolveFrame.IsVisible(); if (flag13) { DlgBase.singleton._SpriteResolveFrame.Clean(); } break; } case SpriteType.Sprite_QueryEvolutionPPT: { bool flag14 = DlgBase.singleton._SpriteMainFrame != null && DlgBase.singleton._SpriteMainFrame.IsVisible(); if (flag14) { DlgBase.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.uuID); XSingleton.singleton.ShowSystemTip(string.Format(XStringDefineProxy.GetString("SpriteExpTips"), this._expTotal), "fece00"); this._expTotal = 0u; } public void ShowGetSpriteWithAnimation(uint spriteID, uint ppt) { DlgBase.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.uuID); SpriteSkill.RowData mySpriteInitiativeSkill = specificDocument.GetMySpriteInitiativeSkill(); bool flag2 = mySpriteInitiativeSkill != null; if (flag2) { bool flag3 = !XSingleton.singleton.SyncMode && mySpriteInitiativeSkill.ShowNotice[0] != 0; if (flag3) { XInvitationDocument specificDocument2 = XDocuments.GetSpecificDocument(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.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.singleton.CreateComponent(xaffiliate, XBubbleComponent.uuID); } XBubbleEventArgs @event = XEventPool.GetEvent(); @event.bubbletext = mySpriteInitiativeSkill.SkillName; @event.existtime = 3f; @event.Firer = xaffiliate; @event.speaker = string.Empty; XSingleton.singleton.FireEvent(@event); } } bool flag12 = !string.IsNullOrEmpty(mySpriteInitiativeSkill.Audio); if (flag12) { XSingleton.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; } } }