using System; using System.Collections.Generic; using KKSG; using XMainClient.UI; using XMainClient.UI.UICommon; using XUtliPoolLib; namespace XMainClient { internal class XGuildGrowthDocument : XDocComponent { public override uint ID { get { return XGuildGrowthDocument.uuID; } } public GuildZiCai GuildZiCaiTableReader { get { return XGuildGrowthDocument._guildZiCaiTable; } } public List BuffList { get { return XGuildGrowthDocument._buffList; } } public List RankList { get { return this._rankList; } } public List RecordList { get { return this._recordList; } } public XGuildGrowthDocument.GuildGrowthRankData MyData { get { return this._myData; } } public new static readonly uint uuID = XSingleton.singleton.XHash("XGuildGrowthDocument"); public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader(); private static GuildHall _guildHallTable = new GuildHall(); private static GuildZiCai _guildZiCaiTable = new GuildZiCai(); private static Dictionary _buffDict = new Dictionary(); private static readonly uint INTERVALNUM = 10000u; public bool LevelUpEnable = false; public bool AutoFindNpc = false; private static List _buffList = new List(); private List _rankList = new List(); private List _recordList = new List(); private XGuildGrowthDocument.GuildGrowthRankData _myData; public int MyRank; public uint WeekHallPoint; public uint WeekSchoolPoint; public uint WeekHuntTimes; public uint WeekDonateTimes; public uint ResourcesPoint; public uint TechnologyPoint; public uint ResDeltaPoint = 0u; public uint TecDeltaPoint = 0u; public class GuildGrowthBuffData { public uint BuffID; public uint BuffLevel; public uint BuffMaxLevel; public bool Enable; public GuildGrowthBuffData(uint id, uint level, uint maxLevel, bool enable) { this.BuffID = id; this.BuffLevel = level; this.BuffMaxLevel = maxLevel; this.Enable = enable; } } public class GuildGrowthRankData { public string Name; public ulong Uid; public uint HallPoint; public uint SchoolPoint; public GuildGrowthRankData(string name, ulong uid, uint hallPoint, uint schoolPoint) { this.Name = name; this.Uid = uid; this.HallPoint = hallPoint; this.SchoolPoint = schoolPoint; } } public class GuildCrowthRecordData { public string Name; public uint ItemID; public uint Time; public GuildCrowthRecordData(string name, uint itemID, uint time) { this.Name = name; this.ItemID = itemID; this.Time = time; } } public void SetPoint(uint resources, uint technology) { this.ResourcesPoint = resources; this.TechnologyPoint = technology; bool flag = DlgBase.singleton.IsVisible(); if (flag) { DlgBase.singleton.RefreshList(false); } bool flag2 = DlgBase.singleton.IsVisible(); if (flag2) { DlgBase.singleton.RefreshList(false); } } public void CheckShowItemGet(uint resDelta, uint tecDelta) { this.ResDeltaPoint += resDelta; this.TecDeltaPoint += tecDelta; this.ShowDeltaPointGet(); } public void ShowDeltaPointGet() { bool flag = XSingleton.singleton.CurrentStage.Stage != EXStage.Hall; if (!flag) { bool flag2 = this.ResDeltaPoint > 0u; if (flag2) { XSingleton.singleton.ShowSystemTip(string.Format(XStringDefineProxy.GetReplaceString("GuildGrowthResDelta", new object[0]), this.ResDeltaPoint), "fece00"); this.ResDeltaPoint = 0u; } bool flag3 = this.TecDeltaPoint > 0u; if (flag3) { XSingleton.singleton.ShowSystemTip(string.Format(XStringDefineProxy.GetReplaceString("GuildGrowthTecDelta", new object[0]), this.TecDeltaPoint), "fece00"); this.TecDeltaPoint = 0u; } } } protected override void OnReconnected(XReconnectedEventArgs arg) { } public override void OnEnterScene() { base.OnEnterScene(); } public override void OnEnterSceneFinally() { base.OnEnterSceneFinally(); bool autoFindNpc = this.AutoFindNpc; if (autoFindNpc) { this.AutoFindNpc = false; bool flag = XSingleton.singleton.SceneID == 4u; if (flag) { this.FindNpc(); } } this.ShowDeltaPointGet(); } public void FindNpc() { XNpc npc = XSingleton.singleton.GetNpc(19u); bool flag = npc == null; if (flag) { XSingleton.singleton.AddErrorLog("Can't find guild build npc.", null, null, null, null, null); } else { XSingleton.singleton.LastNpc = npc; } } public static void Execute(OnLoadedCallback callback = null) { XGuildGrowthDocument.AsyncLoader.AddTask("Table/GuildHall", XGuildGrowthDocument._guildHallTable, false); XGuildGrowthDocument.AsyncLoader.AddTask("Table/GuildZiCai", XGuildGrowthDocument._guildZiCaiTable, false); XGuildGrowthDocument.AsyncLoader.Execute(callback); } public static void OnTableLoaded() { uint num = 0u; for (int i = 0; i < XGuildGrowthDocument._guildHallTable.Table.Length; i++) { bool flag = XGuildGrowthDocument._guildHallTable.Table[i].skillid > num; if (flag) { num = XGuildGrowthDocument._guildHallTable.Table[i].skillid; } } XGuildGrowthDocument._buffList.Clear(); for (uint num2 = 0u; num2 <= num; num2 += 1u) { XGuildGrowthDocument._buffList.Add(new XGuildGrowthDocument.GuildGrowthBuffData(num2, 0u, 0u, false)); } XGuildGrowthDocument._buffDict.Clear(); for (int j = 0; j < XGuildGrowthDocument._guildHallTable.Table.Length; j++) { GuildHall.RowData rowData = XGuildGrowthDocument._guildHallTable.Table[j]; bool flag2 = rowData.level > XGuildGrowthDocument._buffList[(int)rowData.skillid].BuffMaxLevel; if (flag2) { XGuildGrowthDocument._buffList[(int)rowData.skillid].BuffMaxLevel = rowData.level; } XGuildGrowthDocument._buffDict.Add(rowData.skillid * XGuildGrowthDocument.INTERVALNUM + rowData.level, rowData); } } public GuildHall.RowData GetData(uint skillID, uint skillLevel) { uint key = skillID * XGuildGrowthDocument.INTERVALNUM + skillLevel; GuildHall.RowData result = null; bool flag = !XGuildGrowthDocument._buffDict.TryGetValue(key, out result); if (flag) { XSingleton.singleton.AddErrorLog("Can't find guild growth data for guildhall.txt, id = ", skillID.ToString() + " level = ", skillLevel.ToString(), null, null, null); } return result; } public void QueryBuffList() { RpcC2M_GuildHallGetBuffList rpc = new RpcC2M_GuildHallGetBuffList(); XSingleton.singleton.Send(rpc); } public void OnBuffListReply(GuildHallGetBuffList_M2C oRes) { this.LevelUpEnable = oRes.enableUpdate; for (int i = 0; i < XGuildGrowthDocument._buffList.Count; i++) { XGuildGrowthDocument._buffList[i].BuffLevel = 0u; XGuildGrowthDocument._buffList[i].Enable = false; } for (int j = 0; j < oRes.bufflist.Count; j++) { XGuildGrowthDocument._buffList[(int)oRes.bufflist[j].buffid].BuffLevel = oRes.bufflist[j].level; XGuildGrowthDocument._buffList[(int)oRes.bufflist[j].buffid].Enable = oRes.bufflist[j].isenable; } bool flag = DlgBase.singleton.IsVisible(); if (flag) { DlgBase.singleton.RefreshList(false); } bool flag2 = DlgBase.singleton.IsVisible(); if (flag2) { DlgBase.singleton.RefreshGrowthBuffList(); } } public void QueryGuildHallBuffLevelUp(uint buffid) { RpcC2M_GuildHallUpdateBuff rpcC2M_GuildHallUpdateBuff = new RpcC2M_GuildHallUpdateBuff(); rpcC2M_GuildHallUpdateBuff.oArg.buffid = buffid; XSingleton.singleton.Send(rpcC2M_GuildHallUpdateBuff); } public void OnBuffLevelUpSuccess(GuildHallBuffData data) { XGuildGrowthDocument._buffList[(int)data.buffid].BuffLevel = data.level; XGuildGrowthDocument._buffList[(int)data.buffid].Enable = data.isenable; bool flag = DlgBase.singleton.IsVisible(); if (flag) { DlgBase.singleton.ShowLevelUpFx = (int)data.buffid; DlgBase.singleton.RefreshList(true); } } public void QueryBuildRank() { RpcC2M_GuildSchoolHallGetRankList rpc = new RpcC2M_GuildSchoolHallGetRankList(); XSingleton.singleton.Send(rpc); } public void OnBuildRankGet(List list, uint hallPoint, uint schoolPoint, uint huntCount, uint donateCount) { this.WeekHallPoint = hallPoint; this.WeekSchoolPoint = schoolPoint; this.WeekHuntTimes = huntCount; this.WeekDonateTimes = donateCount; this._rankList.Clear(); this._myData = null; for (int i = 0; i < list.Count; i++) { this._rankList.Add(new XGuildGrowthDocument.GuildGrowthRankData(list[i].rolename, list[i].roleid, list[i].weeklyhallpoint, list[i].weeklyschoolpoint)); bool flag = list[i].roleid == XSingleton.singleton.XPlayerData.RoleID; if (flag) { this._myData = new XGuildGrowthDocument.GuildGrowthRankData(list[i].rolename, list[i].roleid, list[i].weeklyhallpoint, list[i].weeklyschoolpoint); } } bool flag2 = this._myData == null; if (flag2) { XSingleton.singleton.AddErrorLog("guild growth rank haven't my data.", null, null, null, null, null); } else { this._rankList.Sort(new Comparison(this.Compare)); for (int j = 0; j < this._rankList.Count; j++) { bool flag3 = this._rankList[j].Uid == XSingleton.singleton.XPlayerData.RoleID; if (flag3) { this.MyRank = j; break; } } bool flag4 = DlgBase.singleton.IsVisible(); if (flag4) { DlgBase.singleton.RefreshRank(); } bool flag5 = DlgBase.singleton.IsVisible(); if (flag5) { DlgBase.singleton.RefreshGrowthDonateTimes(); } } } private int Compare(XGuildGrowthDocument.GuildGrowthRankData x, XGuildGrowthDocument.GuildGrowthRankData y) { bool flag = x.Uid == y.Uid; int result; if (flag) { result = 0; } else { result = (int)(y.HallPoint + y.SchoolPoint - x.HallPoint - x.SchoolPoint); } return result; } public void QueryGuildGrowthDonate(uint itemid) { RpcC2M_GuildZiCaiDonate rpcC2M_GuildZiCaiDonate = new RpcC2M_GuildZiCaiDonate(); rpcC2M_GuildZiCaiDonate.oArg.itemid = itemid; XSingleton.singleton.Send(rpcC2M_GuildZiCaiDonate); } public void QueryGrowthRecordList() { RpcC2M_GuildZiCaiDonateHistory rpc = new RpcC2M_GuildZiCaiDonateHistory(); XSingleton.singleton.Send(rpc); } public void OnGrowthRecordListGet(List list) { this._recordList.Clear(); for (int i = 0; i < list.Count; i++) { this._recordList.Add(new XGuildGrowthDocument.GuildCrowthRecordData(list[i].rolename, list[i].itemid, list[i].time)); } bool flag = DlgBase.singleton.IsVisible(); if (flag) { DlgBase.singleton.CheckRecordRefresh(); } } } }