From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Assets/Scripts/XMainClient/XFlowerSendView.cs | 321 +++++++++++++++++++++ 1 file changed, 321 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XFlowerSendView.cs (limited to 'Client/Assets/Scripts/XMainClient/XFlowerSendView.cs') diff --git a/Client/Assets/Scripts/XMainClient/XFlowerSendView.cs b/Client/Assets/Scripts/XMainClient/XFlowerSendView.cs new file mode 100644 index 00000000..f415aff0 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XFlowerSendView.cs @@ -0,0 +1,321 @@ +using System; +using System.Collections.Generic; +using KKSG; +using UILib; +using UnityEngine; +using XMainClient.UI; +using XMainClient.UI.UICommon; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XFlowerSendView : DlgBase + { + public override string fileName + { + get + { + return "GameSystem/FlowerSendDlg"; + } + } + + public override bool autoload + { + get + { + return true; + } + } + + private XFlowerSendDocument _doc = null; + + private static readonly int SEND_FLOWER_TYPE_COUNT = 3; + + private string[] sendCountType; + + private List ownCount = new List(); + + private List flowerTab = new List(); + + private List sendItem = new List(); + + private GameObject currSelectTab; + + private XFlowerSendView.SendFlowerType currSelectTabType; + + private ulong roleIDSendTo; + + private string roleNameSendTo; + + private uint sendFlowerId; + + private uint sendFlowerCount; + + private uint needCostID; + + private uint needCostCount; + + private enum SendFlowerType + { + RED_ROSE, + WHITE_ROSE, + BLUE_ENCHANTRESS + } + + protected override void Init() + { + base.Init(); + this._doc = XDocuments.GetSpecificDocument(XFlowerSendDocument.uuID); + this.InitFlowerBtnInfo(); + } + + public override void RegisterEvent() + { + base.RegisterEvent(); + base.uiBehaviour.m_Close.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnCloseClicked)); + } + + private void InitFlowerBtnInfo() + { + this.flowerTab.Clear(); + this.sendItem.Clear(); + this.ownCount.Clear(); + string[] array = new string[] + { + "icon-90", + "icon-91", + "icon-92" + }; + for (int i = 0; i < XFlowerSendView.SEND_FLOWER_TYPE_COUNT; i++) + { + GameObject gameObject = base.uiBehaviour.m_TabPool.FetchGameObject(false); + gameObject.transform.localPosition = gameObject.transform.localPosition + new Vector3(0f, (float)(-90 * i), 0f); + IXUISprite ixuisprite = gameObject.GetComponent("XUISprite") as IXUISprite; + IXUILabel ixuilabel = gameObject.transform.Find("T1").GetComponent("XUILabel") as IXUILabel; + IXUILabel item = gameObject.transform.Find("T2").GetComponent("XUILabel") as IXUILabel; + IXUISprite ixuisprite2 = gameObject.transform.Find("P2").GetComponent("XUISprite") as IXUISprite; + ixuisprite.ID = (ulong)((long)i); + ixuilabel.SetText(XStringDefineProxy.GetString(string.Format("FLOWER_SEND_TYPE_{0}", i))); + ixuisprite2.SetSprite(array[i]); + this.flowerTab.Add(gameObject); + this.ownCount.Add(item); + this.SetTabSelect(gameObject, false); + ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnSendRoseTypeClicked)); + } + this.sendCountType = XSingleton.singleton.GetAndSeparateValue("SendFlowerCount", XGlobalConfig.ListSeparator); + for (int j = 0; j < this.sendCountType.Length; j++) + { + GameObject gameObject2 = base.uiBehaviour.m_SendItemPool.FetchGameObject(false); + gameObject2.transform.parent = base.uiBehaviour.m_SendItemList.gameObject.transform; + IXUISprite ixuisprite3 = gameObject2.GetComponent("XUISprite") as IXUISprite; + IXUILabel ixuilabel2 = gameObject2.transform.Find("T1").GetComponent("XUILabel") as IXUILabel; + ixuilabel2.SetText(string.Format("{0}{1}", this.sendCountType[j], XStringDefineProxy.GetString("FLOWER_UNIT"))); + ixuisprite3.ID = (ulong)((long)j); + this.sendItem.Add(gameObject2); + ixuisprite3.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnSendItemClicked)); + } + base.uiBehaviour.m_SendItemList.Refresh(); + this.SelectTab(XFlowerSendView.SendFlowerType.RED_ROSE); + } + + private void SelectTab(XFlowerSendView.SendFlowerType type) + { + bool flag = this.currSelectTab != null; + if (flag) + { + this.SetTabSelect(this.currSelectTab, false); + } + this.currSelectTabType = type; + int num = XFastEnumIntEqualityComparer.ToInt(type); + this.currSelectTab = this.flowerTab[num]; + this.SetTabSelect(this.currSelectTab, true); + int num2 = XFastEnumIntEqualityComparer.ToInt(ItemEnum.FLOWER_RED_ROSE) + XFastEnumIntEqualityComparer.ToInt(this.currSelectTabType); + string[] andSeparateValue = XSingleton.singleton.GetAndSeparateValue("Flower2Charm", XGlobalConfig.AllSeparators); + int num3 = 0; + for (int i = 0; i < andSeparateValue.Length; i += 2) + { + bool flag2 = num2 == int.Parse(andSeparateValue[i]); + if (flag2) + { + num3 = int.Parse(andSeparateValue[i + 1]); + } + } + for (int j = 0; j < this.sendCountType.Length; j++) + { + GameObject gameObject = this.sendItem[j]; + IXUILabel ixuilabel = gameObject.transform.Find("T3").GetComponent("XUILabel") as IXUILabel; + int num4 = int.Parse(this.sendCountType[j]) * num3; + ixuilabel.SetText("+" + num4); + } + string text = string.Format(XStringDefineProxy.GetString("FLOWER_SEND_TIP"), XStringDefineProxy.GetString(string.Format("FLOWER_SEND_TYPE_{0}", num)), num3); + base.uiBehaviour.m_PointTip.SetText(text); + } + + private void OnSendRoseTypeClicked(IXUISprite sp) + { + this.SelectTab((XFlowerSendView.SendFlowerType)sp.ID); + } + + private void OnSendItemClicked(IXUISprite sp) + { + int num = (int)sp.ID; + bool flag = num >= this.sendCountType.Length; + if (!flag) + { + bool flag2 = XSingleton.singleton.SceneType != SceneType.SCENE_HALL && XSingleton.singleton.SceneType != SceneType.SCENE_GUILD_HALL && XSingleton.singleton.SceneType != SceneType.SCENE_FAMILYGARDEN && XSingleton.singleton.SceneType != SceneType.SCENE_LEISURE; + if (flag2) + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("FLOWER_SEND_SCENE_TIP"), "fece00"); + } + else + { + uint count = uint.Parse(this.sendCountType[num]); + uint sendItemID = (uint)(XFastEnumIntEqualityComparer.ToInt(ItemEnum.FLOWER_RED_ROSE) + XFastEnumIntEqualityComparer.ToInt(this.currSelectTabType)); + this._doc.SendFlower(this.roleIDSendTo, count, sendItemID); + } + } + } + + public void FlowerNotEnough(SendFlowerArg oArg) + { + this.sendFlowerCount = oArg.count; + this.sendFlowerId = oArg.sendItemID; + string[] andSeparateValue = XSingleton.singleton.GetAndSeparateValue("BuyFlowerCost", XGlobalConfig.ListSeparator); + int itemCount = XSingleton.singleton.GetItemCount((int)oArg.sendItemID); + for (int i = 0; i < andSeparateValue.Length; i++) + { + string[] array = andSeparateValue[i].Split(new char[] + { + '=' + }); + bool flag = array.Length == 3; + if (flag) + { + bool flag2 = uint.Parse(array[0]) == this.sendFlowerId; + if (flag2) + { + this.needCostID = uint.Parse(array[1]); + this.needCostCount = (this.sendFlowerCount - (uint)itemCount) * uint.Parse(array[2]); + ItemList.RowData itemConf = XBagDocument.GetItemConf((int)this.needCostID); + string label = string.Format(XStringDefineProxy.GetString("FLOWER_SEND_NOT_ENOUGH"), new object[] + { + this.roleNameSendTo, + this.sendFlowerCount, + (long)((ulong)this.sendFlowerCount - (ulong)((long)itemCount)), + this.needCostCount, + (itemConf != null) ? XSingleton.singleton.ChooseProfString(itemConf.ItemName, 0u) : "" + }); + string firstBtn = string.Format(XStringDefineProxy.GetString("FLOWER_SEND_NOT_ENOUGH_RIGHT"), (itemConf != null) ? XSingleton.singleton.ChooseProfString(itemConf.ItemName, 0u) : ""); + XSingleton.singleton.ShowModalDialog(label, firstBtn, new ButtonClickEventHandler(this.OnUseMoney), 50); + DlgBase.singleton.SetCloseButtonVisible(true); + break; + } + } + } + } + + private bool OnGotoBuy(IXUIButton button) + { + bool flag = !XSingleton.singleton.IsSystemOpened(XSysDefine.XSys_GameMall); + bool result; + if (flag) + { + XSingleton.singleton.ShowSystemTip(XSingleton.singleton.GetString("FLOWER_MALL_NOT_OPEN"), "fece00"); + result = false; + } + else + { + DlgBase.singleton.SetVisible(false, true); + this.SetVisibleWithAnimation(false, null); + DlgBase.singleton.SetVisible(false, true); + DlgBase.singleton.ShowWorkGameSystem(XSysDefine.XSys_GameMall_Diamond); + result = true; + } + return result; + } + + private bool OnUseMoney(IXUIButton button) + { + DlgBase.singleton.SetVisible(false, true); + this._doc.SendFlower(this.roleIDSendTo, this.sendFlowerCount, this.sendFlowerId, this.needCostID, this.needCostCount); + return true; + } + + public void ShowLackMoneyError() + { + ItemEnum itemEnum = (ItemEnum)this.needCostID; + if (itemEnum != ItemEnum.GOLD) + { + if (itemEnum != ItemEnum.DRAGON_COIN) + { + if (itemEnum == ItemEnum.DIAMOND) + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("ERR_TEAMBUY_DIAMOND_LESS"), "fece00"); + } + } + else + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("ERR_AUCT_DRAGONCOINLESS"), "fece00"); + } + } + else + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("ERR_AUCTGOLDLESS"), "fece00"); + } + } + + public void ShowGoToMallError(SendFlowerArg oArg) + { + ItemList.RowData itemConf = XBagDocument.GetItemConf((int)oArg.sendItemID); + string text = (itemConf != null) ? XSingleton.singleton.ChooseProfString(itemConf.ItemName, 0u) : ""; + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("FLOWER_SEND_GO_TO_MALL", new object[] + { + text + }), "fece00"); + } + + public void RefreshSendFlowerInfo() + { + this.RefreshRoseOwnCount(); + } + + public void OnSendFlowerError() + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("FLOWER_SEND_FAIL"), "fece00"); + } + + private void SetTabSelect(GameObject obj, bool select) + { + IXUISprite ixuisprite = obj.transform.Find("Select").GetComponent("XUISprite") as IXUISprite; + ixuisprite.SetAlpha((float)(select ? 1 : 0)); + } + + public void ShowBoard(ulong roleID, string roleName) + { + bool flag = !base.IsVisible(); + if (flag) + { + this.SetVisibleWithAnimation(true, null); + } + this.roleIDSendTo = roleID; + this.roleNameSendTo = roleName; + this.RefreshRoseOwnCount(); + } + + private void RefreshRoseOwnCount() + { + for (int i = 0; i < XFlowerSendView.SEND_FLOWER_TYPE_COUNT; i++) + { + int itemCount = XSingleton.singleton.GetItemCount(XFastEnumIntEqualityComparer.ToInt(ItemEnum.FLOWER_RED_ROSE) + i); + string text = string.Format(XStringDefineProxy.GetString("FLOWER_SEND_OWN_COUNT"), itemCount); + this.ownCount[i].SetText(text); + } + } + + private bool OnCloseClicked(IXUIButton button) + { + this.SetVisibleWithAnimation(false, null); + return true; + } + } +} -- cgit v1.1-26-g67d0