| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 | using System.Text.RegularExpressions;using ET;using FairyGUI;using UI.League;using UnityEngine;namespace GFGGame{    //修改联盟名称、徽章    public class LeagueChangeNameView : BaseWindow    {        private UI_LeagueChangeNameUI _ui;        public override void Dispose()        {            if (_ui != null)            {                _ui.Dispose();                _ui = null;            }            base.Dispose();        }        protected override void OnInit()        {            base.OnInit();            packageName = UI_LeagueChangeNameUI.PACKAGE_NAME;            _ui = UI_LeagueChangeNameUI.Create();            this.viewCom = _ui.target;            this.viewCom.Center();            this.modal = true;            viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;            // _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("gzs_bjbj");            _ui.m_btnClose.onClick.Add(Hide);            _ui.m_c1.onChanged.Add(UpdateView);            _ui.m_btnChange.onClick.Add(OnBtnChangeClick);            _ui.m_listIcon.itemRenderer = RenderListItem;        }        protected override void AddEventListener()        {            base.AddEventListener();        }        protected override void OnShown()        {            base.OnShown();            _ui.m_c1.selectedIndex = 0;            _ui.m_listIcon.numItems = GlobalCfgArray.globalCfg.badgeResArr.Length;            UpdateView();        }        protected override void OnHide()        {            base.OnHide();        }        protected override void RemoveEventListener()        {            base.RemoveEventListener();        }        private void UpdateView()        {            _ui.m_txtName.text = "";            if (_ui.m_listIcon.numItems > 0)            {                _ui.m_listIcon.selectedIndex = 0;                _ui.m_listIcon.ScrollToView(0);            }            if (_ui.m_c1.selectedIndex == 0)            {                ItemUtil.UpdateItemNeedNum(_ui.m_comCost, GlobalCfgArray.globalCfg.consumeChangeBadgeArr[0][0], GlobalCfgArray.globalCfg.consumeChangeBadgeArr[0][1]);            }            else            {                ItemUtil.UpdateItemNeedNum(_ui.m_comCost, GlobalCfgArray.globalCfg.consumeChangeNameArr[0][0], GlobalCfgArray.globalCfg.consumeChangeNameArr[0][1]);            }        }        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();        }        private void OnBtnChangeClick()        {            if (LeagueDataManager.Instance.LeagueData.LeagueMemberDatas[RoleDataManager.roleId].Pos != LeaguePos.Owner)            {                PromptController.Instance.ShowFloatTextPrompt("权限不足");                return;            }            if (_ui.m_c1.selectedIndex == 0)//改徽章            {                int costId = GlobalCfgArray.globalCfg.consumeChangeBadgeArr[0][1];                long needCount = ItemDataManager.GetItemNum(GlobalCfgArray.globalCfg.consumeChangeBadgeArr[0][1]);                if (!ItemUtil.CheckItemEnough(costId, needCount))                {                    long has = ItemDataManager.GetItemNum(costId);                    ItemUtil.BuyCurrency(costId, needCount - has);                    return;                }                LeagueSproxy.ReqChangeLeagueNameOrIcon(2, GlobalCfgArray.globalCfg.badgeResArr[_ui.m_listIcon.selectedIndex]).Coroutine();            }            else//改联盟名称            {                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;                }                //判断是否和旧的名字一样                if (leagueName == LeagueDataManager.Instance.LeagueData.Name)                {                    PromptController.Instance.ShowFloatTextPrompt("雅集名字不可重名");                    return;                }                int costId = GlobalCfgArray.globalCfg.consumeChangeNameArr[0][0];                int needCount = GlobalCfgArray.globalCfg.consumeChangeNameArr[0][1];                if (!ItemUtil.CheckItemEnough(costId, needCount))                {                    long has = ItemDataManager.GetItemNum(costId);                    ItemUtil.BuyCurrency(costId, needCount - has);                    return;                }                LeagueSproxy.ReqChangeLeagueNameOrIcon(1, leagueName).Coroutine();            }        }    }}
 |