From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../XMainClient/UI/XSpriteAttributePHandler.cs | 169 +++++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/UI/XSpriteAttributePHandler.cs (limited to 'Client/Assets/Scripts/XMainClient/UI/XSpriteAttributePHandler.cs') diff --git a/Client/Assets/Scripts/XMainClient/UI/XSpriteAttributePHandler.cs b/Client/Assets/Scripts/XMainClient/UI/XSpriteAttributePHandler.cs new file mode 100644 index 00000000..5084b1f9 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/UI/XSpriteAttributePHandler.cs @@ -0,0 +1,169 @@ +using System; +using System.Collections.Generic; +using KKSG; +using UILib; +using UnityEngine; +using XUtliPoolLib; + +namespace XMainClient.UI +{ + internal class XSpriteAttributePHandler : DlgHandlerBase + { + protected override string FileName + { + get + { + return "GameSystem/SpriteSystem/SpriteAttribute"; + } + } + + private XUIPool m_AttributePool = new XUIPool(XSingleton.singleton.m_uiTool); + + private IXUIList m_AttributeList; + + private Dictionary attrCompareData = new Dictionary(); + + private Dictionary aptitudeCompareData = new Dictionary(); + + protected override void Init() + { + base.Init(); + this.m_AttributeList = (base.PanelObject.transform.Find("Grid").GetComponent("XUIList") as IXUIList); + Transform transform = base.PanelObject.transform.Find("Grid/Tpl"); + this.m_AttributePool.SetupPool(transform.parent.gameObject, transform.gameObject, 6u, false); + } + + private void PreProcessComparedData(SpriteInfo compareData) + { + this.attrCompareData.Clear(); + bool flag = compareData != null; + if (flag) + { + for (int i = 0; i < compareData.AttrID.Count; i++) + { + bool flag2 = i < compareData.AttrValue.Count; + if (flag2) + { + this.attrCompareData[compareData.AttrID[i]] = compareData.AttrValue[i]; + } + else + { + XSingleton.singleton.AddErrorLog("Cannot Find Aptitude ID", null, null, null, null, null); + } + } + } + } + + private void CreateSpriteAttr(List attrID, List attrValue, List evoAttrID, List evoAttrValue) + { + this.m_AttributePool.FakeReturnAll(); + for (int i = 0; i < attrID.Count; i++) + { + bool flag = attrID[i] == 0u; + if (!flag) + { + GameObject obj = this.m_AttributePool.FetchGameObject(false); + bool flag2 = i < attrValue.Count; + if (flag2) + { + double evoValue = 0.0; + bool flag3 = evoAttrID != null && evoAttrValue != null; + if (flag3) + { + for (int j = 0; j < evoAttrID.Count; j++) + { + bool flag4 = attrID[i] == evoAttrID[j] && j < evoAttrValue.Count; + if (flag4) + { + evoValue = evoAttrValue[j]; + break; + } + } + } + this.SetAttributeInfo(obj, attrID[i], (uint)attrValue[i], evoValue); + } + else + { + XSingleton.singleton.AddErrorLog("Cannot Find Attr Value", null, null, null, null, null); + } + } + } + this.m_AttributeList.Refresh(); + this.m_AttributePool.ActualReturnAll(false); + } + + public void SetSpriteAttributeInfo(SpriteInfo spriteData, SpriteInfo compareData = null) + { + bool flag = spriteData == null; + if (flag) + { + this.m_AttributePool.ReturnAll(false); + } + else + { + this.PreProcessComparedData(compareData); + this.CreateSpriteAttr(spriteData.AttrID, spriteData.AttrValue, spriteData.EvoAttrID, spriteData.EvoAttrValue); + } + } + + public void SetSpriteAttributeInfo(uint spriteID) + { + this.attrCompareData.Clear(); + XSpriteSystemDocument specificDocument = XDocuments.GetSpecificDocument(XSpriteSystemDocument.uuID); + SpriteTable.RowData bySpriteID = specificDocument._SpriteTable.GetBySpriteID(spriteID); + bool flag = bySpriteID == null; + if (!flag) + { + List attrID = new List(); + List attrValue = new List(); + List list = new List(); + XSpriteAttributeHandler.GetLevelOneSpriteAttr(bySpriteID, out attrID, out attrValue, out list); + this.CreateSpriteAttr(attrID, attrValue, null, null); + } + } + + private void SetAttributeInfo(GameObject obj, uint attrID, uint attrValue, double evoValue) + { + IXUILabel ixuilabel = obj.transform.Find("Name").GetComponent("XUILabel") as IXUILabel; + IXUILabel ixuilabel2 = obj.transform.Find("Value").GetComponent("XUILabel") as IXUILabel; + IXUILabel ixuilabel3 = obj.transform.Find("Addon").GetComponent("XUILabel") as IXUILabel; + string format = "Sprite_{0}"; + XAttributeDefine xattributeDefine = (XAttributeDefine)attrID; + string key = string.Format(format, xattributeDefine.ToString()); + ixuilabel.SetText(XStringDefineProxy.GetString(key)); + ixuilabel2.SetText(attrValue.ToString()); + ixuilabel3.SetVisible(evoValue != 0.0); + ixuilabel3.SetText(string.Format("+{0}", evoValue)); + bool flag = this.attrCompareData.Count > 0; + if (flag) + { + double num = 0.0; + bool flag2 = this.attrCompareData.TryGetValue(attrID, out num); + if (flag2) + { + bool flag3 = attrValue > (uint)num; + if (flag3) + { + ixuilabel2.SetText("[00ff00]+" + attrValue.ToString() + "[-]"); + } + else + { + bool flag4 = attrValue < (uint)num; + if (flag4) + { + ixuilabel2.SetText("[ff0000]+" + attrValue.ToString() + "[-]"); + } + else + { + ixuilabel2.SetText("+" + attrValue.ToString()); + } + } + } + else + { + ixuilabel2.SetText("[00ff00]+" + attrValue.ToString() + "[-]"); + } + } + } + } +} -- cgit v1.1-26-g67d0