| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 | using System.Text.RegularExpressions;using ET;using FairyGUI;using UI.League;using UnityEngine;namespace GFGGame{    //创建联盟    public class LeagueCreatView : BaseWindow    {        private UI_LeagueCreatUI _ui;        public override void Dispose()        {            if (_ui != null)            {                _ui.Dispose();                _ui = null;            }            base.Dispose();        }        protected override void OnInit()        {            base.OnInit();            packageName = UI_LeagueCreatUI.PACKAGE_NAME;            _ui = UI_LeagueCreatUI.Create();            this.viewCom = _ui.target;            this.viewCom.Center();            this.modal = true;            isReturnWindow = true;            viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;            _ui.m_btnClose.onClick.Add(Hide);            _ui.m_btnCreat.onClick.Add(OnBtnCreatClick);            _ui.m_listIcon.itemRenderer = RenderListItem;        }        protected override void AddEventListener()        {            base.AddEventListener();        }        protected override void OnShown()        {            base.OnShown();            _ui.m_listIcon.numItems = GlobalCfgArray.globalCfg.badgeResArr.Length;            _ui.m_listIcon.selectedIndex = 0;            _ui.m_txtName.text = "";            ItemUtil.UpdateItemNeedNum(_ui.m_comCost, GlobalCfgArray.globalCfg.consumeCreateArr[0][0], GlobalCfgArray.globalCfg.consumeCreateArr[0][1]);        }        protected override void OnHide()        {            base.OnHide();        }        protected override void RemoveEventListener()        {            base.RemoveEventListener();        }        private async void OnBtnCreatClick()        {            string leagueName = _ui.m_txtName.text;            if (string.IsNullOrEmpty(leagueName))            {                PromptController.Instance.ShowFloatTextPrompt("雅集名字不能为空");                return;            }            if (leagueName.Length > GFGGame.GlobalConst.MaxNameLen)            {                PromptController.Instance.ShowFloatTextPrompt("雅集名字最多七个字");                return;            }            if (!Regex.IsMatch(leagueName, @"^[\u4e00-\u9fa5_0-9]+$"))//角色起名仅允许汉字、数字、底划线            {                PromptController.Instance.ShowFloatTextPrompt("雅集名字仅允许汉字、数字、下划线");                return;            }            long hasCount = ItemDataManager.GetItemNum(GlobalCfgArray.globalCfg.consumeCreateArr[0][0]);            long needCount = GlobalCfgArray.globalCfg.consumeCreateArr[0][1];            if (hasCount < needCount)            {                ItemUtil.BuyCurrency(GlobalCfgArray.globalCfg.consumeCreateArr[0][0], needCount - hasCount);                return;            }            bool result = await LeagueSproxy.ReqCreateLeague(leagueName, GlobalCfgArray.globalCfg.badgeResArr[_ui.m_listIcon.selectedIndex]);            if (result)            {                this.Hide();                ViewManager.DeleteViewStackCountDown(null,1);                ViewManager.Show<LeagueView>(null, true);            }        }        private void RenderListItem(int index, GObject obj)        {            UI_ListIconItem item = UI_ListIconItem.Proxy(obj);            item.m_loaIcon.url = ResPathUtil.GetLeagueIconPath(GlobalCfgArray.globalCfg.badgeResArr[index]);            UI_ListIconItem.ProxyEnd();        }    }}
 |