From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Scripts/XMainClient/UI/XFpStrengthenView.cs | 469 +++++++++++++++++++++ 1 file changed, 469 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/UI/XFpStrengthenView.cs (limited to 'Client/Assets/Scripts/XMainClient/UI/XFpStrengthenView.cs') diff --git a/Client/Assets/Scripts/XMainClient/UI/XFpStrengthenView.cs b/Client/Assets/Scripts/XMainClient/UI/XFpStrengthenView.cs new file mode 100644 index 00000000..c0afae81 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/UI/XFpStrengthenView.cs @@ -0,0 +1,469 @@ +using System; +using System.Collections.Generic; +using UILib; +using UnityEngine; +using XMainClient.UI.UICommon; +using XUtliPoolLib; + +namespace XMainClient.UI +{ + internal class XFpStrengthenView : DlgBase + { + public override string fileName + { + get + { + return "GameSystem/FpStrengthenDlg"; + } + } + + public override int group + { + get + { + return 1; + } + } + + public override bool autoload + { + get + { + return true; + } + } + + public override bool hideMainMenu + { + get + { + return true; + } + } + + public override bool fullscreenui + { + get + { + return true; + } + } + + public override bool pushstack + { + get + { + return true; + } + } + + private XFPStrengthenDocument _doc = null; + + public XUIPool m_FpStrengthenPool = new XUIPool(XSingleton.singleton.m_uiTool); + + public XUIPool m_FpButtonPool = new XUIPool(XSingleton.singleton.m_uiTool); + + private Dictionary m_checkBoxDic = new Dictionary(); + + private Dictionary> m_tabReddot = new Dictionary>(); + + private FunctionDef _curFunctionEnum = FunctionDef.ZHANLI; + + private FunctionDef _defFunctionEnum = FunctionDef.END; + + private bool _isFirst = true; + + private bool _isFromShow = false; + + protected override void Init() + { + this._doc = XDocuments.GetSpecificDocument(XFPStrengthenDocument.uuID); + this._doc.StrengthenView = this; + this.m_FpStrengthenPool.SetupPool(base.uiBehaviour.m_tabParentGo, base.uiBehaviour.m_tabParentGo.transform.Find("template").gameObject, XFPStrengthenBehaviour.FUNCTION_NUM, false); + Transform transform = base.uiBehaviour.transform.Find("Bg/Content/Panel"); + this.m_FpButtonPool.SetupPool(transform.gameObject, transform.Find("template").gameObject, 20u, false); + } + + public override void RegisterEvent() + { + base.uiBehaviour.m_Close.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnCloseClicked)); + } + + protected override void OnShow() + { + base.OnShow(); + base.uiBehaviour.m_Scroll.SetPosition(0f); + this.InitLeftViews(); + this.FillTopContent(); + bool flag = !this.m_checkBoxDic.ContainsKey(this._curFunctionEnum); + if (flag) + { + this._curFunctionEnum = this._defFunctionEnum; + } + this._isFromShow = true; + this._doc.RequsetFightNum(); + this.m_checkBoxDic[this._curFunctionEnum].bChecked = true; + } + + protected override void OnHide() + { + base.OnHide(); + this.m_FpStrengthenPool.ReturnAll(false); + bool flag = this.m_checkBoxDic != null; + if (flag) + { + foreach (KeyValuePair keyValuePair in this.m_checkBoxDic) + { + bool flag2 = keyValuePair.Value != null; + if (flag2) + { + keyValuePair.Value.ForceSetFlag(false); + } + } + } + this.m_tabReddot.Clear(); + base.uiBehaviour.m_RateTex.SetTexturePath(""); + } + + protected override void OnUnload() + { + this.m_checkBoxDic.Clear(); + this._doc = null; + base.OnUnload(); + } + + public override void StackRefresh() + { + base.uiBehaviour.m_Scroll.SetPosition(0f); + this.FillTopContent(); + this._doc.RequsetFightNum(); + } + + public void ShowContent(FunctionDef fun = FunctionDef.ZHANLI) + { + bool flag = !XSingleton.singleton.IsSystemOpened(XSysDefine.XSys_Strong); + if (!flag) + { + this._curFunctionEnum = fun; + bool flag2 = !base.IsVisible(); + if (flag2) + { + this.SetVisible(true, true); + } + } + } + + public void RefreshUi(bool isFromMes) + { + bool flag = this._curFunctionEnum == FunctionDef.ZHANLI; + if (flag) + { + this.m_FpButtonPool.ReturnAll(false); + this.FillStrengthenContent(); + this.RefreshTabRedDot(); + bool flag2 = !this._isFromShow; + if (flag2) + { + this._doc.CancleNew(XFastEnumIntEqualityComparer.ToInt(this._curFunctionEnum)); + } + else + { + this._isFromShow = false; + if (isFromMes) + { + this._doc.CancleNew(XFastEnumIntEqualityComparer.ToInt(this._curFunctionEnum)); + } + } + } + } + + public void RefreshTabRedDot() + { + bool flag = this.m_tabReddot == null || this.m_tabReddot.Count == 0; + if (!flag) + { + foreach (KeyValuePair> keyValuePair in this.m_tabReddot) + { + bool flag2 = keyValuePair.Value != null; + if (flag2) + { + bool flag3 = keyValuePair.Key == FunctionDef.ZHANLI; + if (flag3) + { + bool tabNew = this._doc.GetTabNew(XFastEnumIntEqualityComparer.ToInt(keyValuePair.Key)); + bool flag4 = tabNew; + if (flag4) + { + keyValuePair.Value.Item1.SetActive(true); + keyValuePair.Value.Item2.SetActive(false); + } + else + { + keyValuePair.Value.Item1.SetActive(false); + keyValuePair.Value.Item2.SetActive(this._doc.NeedUp); + } + } + else + { + keyValuePair.Value.Item1.SetActive(this._doc.GetTabNew(XFastEnumIntEqualityComparer.ToInt(keyValuePair.Key))); + keyValuePair.Value.Item2.SetActive(false); + } + } + } + } + } + + private void InitLeftViews() + { + string @string = XStringDefineProxy.GetString("BQ_TITLE_STRING"); + string[] array = @string.Split(new char[] + { + '|' + }); + int num = 0; + this._defFunctionEnum = FunctionDef.END; + this.m_checkBoxDic.Clear(); + this.m_tabReddot.Clear(); + for (int i = 0; i < array.Length; i++) + { + bool flag = this.GetFuncNum(FunctionDef.ZHANLI + i) == 0; + if (!flag) + { + GameObject gameObject = this.m_FpStrengthenPool.FetchGameObject(false); + gameObject.transform.parent = base.uiBehaviour.m_tabParentGo.transform; + gameObject.transform.localScale = Vector3.one; + gameObject.transform.localPosition = new Vector3(this.m_FpStrengthenPool.TplPos.x, this.m_FpStrengthenPool.TplPos.y - (float)(num * this.m_FpStrengthenPool.TplHeight), this.m_FpStrengthenPool.TplPos.z); + this.InitTabInfo(gameObject.transform.Find("Bg"), array[i], i); + num++; + } + } + IXUIScrollView ixuiscrollView = base.uiBehaviour.m_tabParentGo.GetComponent("XUIScrollView") as IXUIScrollView; + ixuiscrollView.ResetPosition(); + } + + private void InitTabInfo(Transform tra, string name, int index) + { + bool flag = tra == null; + if (!flag) + { + IXUILabel ixuilabel = tra.Find("TextLabel").GetComponent("XUILabel") as IXUILabel; + ixuilabel.SetText(name); + ixuilabel = (tra.Find("SelectedTextLabel").GetComponent("XUILabel") as IXUILabel); + ixuilabel.SetText(name); + IXUICheckBox ixuicheckBox = tra.GetComponent("XUICheckBox") as IXUICheckBox; + ixuicheckBox.RegisterOnCheckEventHandler(new CheckBoxOnCheckEventHandler(this.SelectStrengthItem)); + ixuicheckBox.ID = (ulong)((long)(0 + index)); + this.m_checkBoxDic.Add((FunctionDef)ixuicheckBox.ID, ixuicheckBox); + GameObject gameObject = tra.Find("New").gameObject; + GameObject gameObject2 = tra.Find("Up").gameObject; + this.m_tabReddot.Add((FunctionDef)ixuicheckBox.ID, new XTuple(gameObject, gameObject2)); + bool flag2 = this._defFunctionEnum == FunctionDef.END; + if (flag2) + { + this._defFunctionEnum = (FunctionDef)ixuicheckBox.ID; + } + } + } + + private int GetFuncNum(FunctionDef def) + { + return this._doc.GetFuncNumByType(XFastEnumIntEqualityComparer.ToInt(def)); + } + + private void FillContentArea(FunctionDef def) + { + bool flag = def == FunctionDef.ZHANLI; + if (flag) + { + this.RefreshUi(false); + } + else + { + this.RefreshTabRedDot(); + this.m_FpButtonPool.ReturnAll(false); + this.FillOtherContent(def); + this._doc.CancleNew(XFastEnumIntEqualityComparer.ToInt(def)); + } + base.uiBehaviour.m_Scroll.ResetPosition(); + } + + private void FillTopContent() + { + uint num = (uint)XSingleton.singleton.XPlayerData.GetAttr(XAttributeDefine.XAttr_POWER_POINT_Basic); + RecommendFightNum.RowData recommendFightData = this._doc.GetRecommendFightData(XSysDefine.XSys_None, -1); + uint num2 = 1u; + bool flag = recommendFightData == null && XSingleton.singleton.XPlayerData != null; + if (flag) + { + XSingleton.singleton.AddErrorLog("the data is not find,level = " + XSingleton.singleton.XPlayerData.Level, null, null, null, null, null); + } + else + { + num2 = recommendFightData.Total; + } + base.uiBehaviour.m_MyFightLab.SetText(num.ToString()); + base.uiBehaviour.m_RecommendFightLab.SetText(num2.ToString()); + base.uiBehaviour.m_MyLevelLab.SetText(XSingleton.singleton.XPlayerData.Level.ToString()); + int fightPercent = (int)(num / num2 * 100.0); + string totalFightRateDes = this._doc.GetTotalFightRateDes(fightPercent); + base.uiBehaviour.m_RateTex.SetTexturePath("atlas/UI/GameSystem/Activity/" + totalFightRateDes); + } + + private void FillStrengthenContent() + { + int num = 0; + int num2 = 0; + for (int i = 0; i < this._doc.StrengthAuxDataList.Count; i++) + { + StrengthAuxData strengthAuxData = this._doc.StrengthAuxDataList[i]; + bool flag = strengthAuxData == null || !strengthAuxData.IsShow; + if (!flag) + { + GameObject gameObject = this.m_FpButtonPool.FetchGameObject(true); + gameObject.transform.Find("Other").gameObject.SetActive(false); + gameObject.transform.localPosition = new Vector3(this.m_FpButtonPool.TplPos.x, this.m_FpButtonPool.TplPos.y - (float)(num * this.m_FpButtonPool.TplHeight), this.m_FpButtonPool.TplPos.z); + num++; + IXUIButton ixuibutton = gameObject.transform.Find("go").GetComponent("XUIButton") as IXUIButton; + ixuibutton.RegisterClickEventHandler(new ButtonClickEventHandler(this.GoToStrengthSys)); + ixuibutton.ID = (ulong)((long)strengthAuxData.StrengthenData.BQSystem); + IXUISprite ixuisprite = gameObject.transform.Find("Sprite").GetComponent("XUISprite") as IXUISprite; + ixuisprite.SetSprite(strengthAuxData.StrengthenData.BQImageID); + bool tabNew = this._doc.GetTabNew(XFastEnumIntEqualityComparer.ToInt(this._curFunctionEnum)); + bool flag2 = tabNew; + if (flag2) + { + bool flag3 = strengthAuxData.StrengthenData != null; + if (flag3) + { + gameObject.transform.Find("New").gameObject.SetActive(this._doc.GetNewStatus(strengthAuxData.StrengthenData.BQID)); + } + else + { + gameObject.transform.Find("New").gameObject.SetActive(false); + } + gameObject.transform.Find("Up").gameObject.SetActive(false); + } + else + { + gameObject.transform.Find("New").gameObject.SetActive(false); + bool flag4 = strengthAuxData.FightPercent < (double)this._doc.ShowUpSprNum && num2 < 2; + if (flag4) + { + num2++; + gameObject.transform.Find("Up").gameObject.SetActive(true); + } + else + { + gameObject.transform.Find("Up").gameObject.SetActive(false); + } + } + gameObject = gameObject.transform.Find("Strengthen").gameObject; + gameObject.SetActive(true); + IXUILabel ixuilabel = gameObject.transform.Find("TittleLab").GetComponent("XUILabel") as IXUILabel; + ixuilabel.SetText(strengthAuxData.StrengthenData.BQTips); + double num3 = strengthAuxData.FightPercent; + ixuilabel = (gameObject.transform.Find("RateLab").GetComponent("XUILabel") as IXUILabel); + ixuilabel.SetText(this._doc.GetPartFightRateDes(num3)); + IXUISlider ixuislider = gameObject.transform.Find("Slider").GetComponent("XUISlider") as IXUISlider; + num3 = ((num3 > 100.0) ? 100.0 : num3); + num3 = ((num3 < 0.0) ? 0.0 : num3); + ixuislider.Value = (float)num3 / 100f; + } + } + } + + private void FillOtherContent(FunctionDef def) + { + List strengthByType = this._doc.GetStrengthByType(XFastEnumIntEqualityComparer.ToInt(def)); + for (int i = 0; i < strengthByType.Count; i++) + { + FpStrengthNew.RowData rowData = strengthByType[i]; + bool flag = rowData == null; + if (!flag) + { + GameObject gameObject = this.m_FpButtonPool.FetchGameObject(true); + gameObject.transform.Find("Strengthen").gameObject.SetActive(false); + gameObject.transform.localPosition = new Vector3(this.m_FpButtonPool.TplPos.x, this.m_FpButtonPool.TplPos.y - (float)(i * this.m_FpButtonPool.TplHeight), this.m_FpButtonPool.TplPos.z); + IXUIButton ixuibutton = gameObject.transform.Find("go").GetComponent("XUIButton") as IXUIButton; + ixuibutton.RegisterClickEventHandler(new ButtonClickEventHandler(this.GoToStrengthSys)); + ixuibutton.ID = (ulong)((long)rowData.BQSystem); + IXUISprite ixuisprite = gameObject.transform.Find("Sprite").GetComponent("XUISprite") as IXUISprite; + ixuisprite.SetSprite(rowData.BQImageID); + gameObject.transform.Find("New").gameObject.SetActive(this._doc.GetNewStatus(rowData.BQID)); + gameObject.transform.Find("Up").gameObject.SetActive(false); + gameObject = gameObject.transform.Find("Other").gameObject; + gameObject.SetActive(true); + IXUILabel ixuilabel = gameObject.transform.Find("Label").GetComponent("XUILabel") as IXUILabel; + ixuilabel.SetText(rowData.BQTips); + for (int j = 0; j < 5; j++) + { + gameObject.transform.Find(j.ToString()).gameObject.SetActive(j < rowData.StarNum); + } + } + } + } + + private bool OnCloseClicked(IXUIButton sp) + { + this.SetVisible(false, true); + return true; + } + + private bool SelectStrengthItem(IXUICheckBox iXUICheckBox) + { + FunctionDef functionDef = (FunctionDef)iXUICheckBox.ID; + bool bChecked = iXUICheckBox.bChecked; + if (bChecked) + { + bool flag = this._isFirst && functionDef == FunctionDef.ZHANLI; + if (flag) + { + this._isFirst = false; + return true; + } + this._curFunctionEnum = functionDef; + this.FillContentArea(functionDef); + } + return true; + } + + public bool GoToStrengthSys(IXUIButton sp) + { + XSysDefine xsysDefine = (XSysDefine)sp.ID; + XSysDefine xsysDefine2 = xsysDefine; + if (xsysDefine2 - XSysDefine.XSys_Level_Normal > 1) + { + if (xsysDefine2 - XSysDefine.XSys_Item_Enchant > 1) + { + if (xsysDefine2 != XSysDefine.XSys_GuildDailyTask) + { + XSingleton.singleton.OpenSystem(xsysDefine, 0UL); + } + else + { + XSingleton.singleton.CloseAllUI(); + XSingleton.singleton.OpenSystem(xsysDefine, 0UL); + } + } + else + { + XSingleton.singleton.OpenSystem(XSysDefine.XSys_Item_Equip, 0UL); + } + } + else + { + XLevelDocument specificDocument = XDocuments.GetSpecificDocument(XLevelDocument.uuID); + bool flag = xsysDefine == XSysDefine.XSys_Level_Normal; + if (flag) + { + specificDocument.AutoGoBattle(0, 0, 0u); + } + else + { + specificDocument.AutoGoBattle(0, 0, 1u); + } + } + return true; + } + } +} -- cgit v1.1-26-g67d0