using System; using System.Collections; using System.Collections.Generic; using FairyGUI; using UI.Arena; // using UI.DressUp; using UnityEngine; namespace GFGGame { public class ArenaDressInfoView : BaseWindow { private UI_ArenaDressInfoUI _ui; private GameObject _scenePrefab; private GameObject _sceneObject; private List _listLongPress = new List(); private List _roleDatas;//可能是自己的搭配,也可能是对方玩家的搭配 private int _themeIndex = 0; private string _openViewName = ""; private List _itemList = new List(); private string[] _tags; private int _roleType = 0;//FightRoleType public override void Dispose() { if (_sceneObject != null) { GameObject.Destroy(_sceneObject); _sceneObject = null; } // _dressUpObj.Dispose(); for (int i = 0; i < _listLongPress.Count; i++) { _listLongPress[i].Dispose(); } _listLongPress.Clear(); if (_ui != null) { _ui.Dispose(); _ui = null; } base.Dispose(); } protected override void OnInit() { base.OnInit(); packageName = UI_ArenaUI.PACKAGE_NAME; _ui = UI_ArenaDressInfoUI.Create(); this.viewCom = _ui.target; isfullScreen = true; _ui.m_c2.onChanged.Add(OnThemeChange); _ui.m_btnBack.onClick.Add(OnClickBtnBack); _ui.m_btnDress.onClick.Add(OnBtnDressClick); _ui.m_btnRecommend.onClick.Add(OnBtnRecommendClick); _ui.m_comValueInfo.m_btnFightScoreRule.onClick.Add(OnBtnFightScoreRule); _ui.m_grhCloseComFightScore.onClick.Add(OnCloseComFightScore); _ui.m_list.itemRenderer = RenderListItem; _scenePrefab = GFGAsset.Load(ResPathUtil.GetPrefabPath("SceneArenaDressUp")); } protected override void AddEventListener() { base.AddEventListener(); } protected override void OnShown() { base.OnShown(); _roleType = (int)(this.viewData as object[])[0]; _themeIndex = (int)(this.viewData as object[])[1]; _roleDatas = (this.viewData as object[])[2] as List; _openViewName = (this.viewData as object[])[3].ToString(); _ui.m_grhCloseComFightScore.visible = false; _ui.m_c1.selectedIndex = _roleType; _ui.m_c2.selectedIndex = _themeIndex; if (_sceneObject == null) { _sceneObject = GameObject.Instantiate(_scenePrefab); MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject, false, false); } UpdateView(); Timers.inst.AddUpdate(CheckGuide); } protected override void OnHide() { base.OnHide(); if (_sceneObject != null) { GameObject.Destroy(_sceneObject); _sceneObject = null; } _ui.m_grhCloseComFightScore.visible = false; _ui.m_comValueInfo.m_c2.selectedIndex = 0; Timers.inst.Remove(CheckGuide); } protected override void RemoveEventListener() { base.RemoveEventListener(); } private void OnClickBtnBack() { ViewManager.GoBackFrom(typeof(ArenaDressInfoView).FullName);//返回竞技场主界面 if (!string.IsNullOrEmpty(_openViewName)) { ViewManager.Show(_openViewName);//打开来源界面:如历史记录、排行榜 } } private void OnThemeChange() { _themeIndex = _ui.m_c2.selectedIndex; if (_roleType == FightRoleType.MINE) { ArenaDataManager.Instance.SelectThemeIndex = _themeIndex; } UpdateView(); } private void OnBtnFightScoreRule() { _ui.m_grhCloseComFightScore.visible = true; } private void OnCloseComFightScore() { _ui.m_comValueInfo.m_c2.selectedIndex = 0; _ui.m_grhCloseComFightScore.visible = false; } private void OnBtnDressClick() { ViewManager.Show(null, new object[] { typeof(ArenaDressInfoView).FullName, new object[] { _roleType, _themeIndex, _roleDatas, "" } }, true); } private async void OnBtnRecommendClick() { for (int i = 0; i < ArenaDataManager.Instance.ThemeList.Count; i++) { int scoreType = ArenaDataManager.Instance.ThemeList[i]; FightData roleData = ArenaDataManager.Instance.DressupList[i]; roleData.scoreType = scoreType; roleData.itemList = ArenaDataManager.Instance.GetRecommentItemList(scoreType, roleData.tags); roleData.cardId = ArenaDataManager.Instance.GetRecommentCardId(scoreType, roleData.itemList); ArenaDataManager.Instance.SetMineFightAttr(roleData, scoreType); ScoreSystemData.Instance.SetEquipScoresWithPartId(roleData); _roleDatas = ArenaDataManager.Instance.DressupList; bool result = await ArenaSproxy.ReqChangeArenaDressup(i, roleData.cardId, roleData.itemList); if (!result) { PromptController.Instance.ShowFloatTextPrompt("保存失败"); return; } } PromptController.Instance.ShowFloatTextPrompt("保存成功"); UpdateView(); } private void UpdateView() { // _itemList = _roleDatas[_themeIndex].itemList; _tags = _roleDatas[_themeIndex].tags; UpdateCardInfo(_roleDatas[_themeIndex].cardId); ArenaViewManager.Instance.UpdateValue(_ui.m_comValueInfo.target, _themeIndex, _roleDatas); MyDressUpHelper.dressUpObj.PutOnItemList(_roleDatas[_themeIndex].itemList); _itemList.Clear(); for (int i = 0; i < _roleDatas[_themeIndex].itemList.Count; i++) { int itemId = _roleDatas[_themeIndex].itemList[i]; if (itemId == ConstItemID.DEFULT_FA_XING || itemId == ConstItemID.DEFULT_LIAN_YI_QUN || itemId == ConstItemID.DEFULT_NEI_DA || itemId == ConstItemID.DEFULT_XIA_ZHUANG) continue; _itemList.Add(itemId); } _ui.m_list.numItems = _itemList.Count; } private void UpdateCardInfo(int cardId) { if (cardId == 0) { _ui.m_comCard.m_c1.selectedIndex = 0; return; } _ui.m_comCard.m_c1.selectedIndex = 1; ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(cardId); _ui.m_comCard.m_txtCardName.text = itemCfg.name; _ui.m_comCard.m_comCard.m_loaCard.url = ResPathUtil.GetCardSmallPath(itemCfg.res); _ui.m_comCard.m_loaScore.url = ResPathUtil.GetScorePath(ArenaDataManager.Instance.ThemeList[_themeIndex]); RarityIconController.UpdateRarityIcon(_ui.m_comCard.m_loaRarity, cardId, false); } private void RenderListItem(int index, GObject obj) { UI_ListPartsItem item = UI_ListPartsItem.Proxy(obj); item.m_iconSelected.visible = true; ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_itemList[index]); item.m_txtTitle.text = itemCfg.name; item.m_ScoreType.url = ResPathUtil.GetScorePath(ArenaDataManager.Instance.ThemeList[_themeIndex]); item.m_icon.url = ResPathUtil.GetIconPath(itemCfg.res, "png"); item.m_txtScore.text = _roleDatas[_themeIndex].itemScoreDic[_itemList[index]].ToString(); RarityIconController.UpdateRarityIcon(item.m_rarity, _itemList[index], false); if (item.target.data == null) { LongPressGesture longPressGesture = new LongPressGesture(item.target); longPressGesture.once = true; longPressGesture.onAction.Add(OnLongPress); _listLongPress.Add(longPressGesture); } item.target.data = _itemList[index]; UI_ListPartsItem.ProxyEnd(); } private void OnLongPress(EventContext context) { LongPressGesture gesture = (LongPressGesture)context.sender; int itemId = (int)gesture.host.data; GoodsItemTipsController.ShowItemTips(itemId); } private void CheckGuide(object param) { if (GuideDataManager.IsGuideFinish(ConstGuideId.ARENA_OPEN) <= 0) { UpdateToCheckGuide(null); } else { Timers.inst.Remove(CheckGuide); } } protected override void UpdateToCheckGuide(object param) { if (!ViewManager.CheckIsTopView(this.viewCom)) return; GuideController.TryGuide(_ui.m_btnRecommend, ConstGuideId.ARENA_OPEN, 6, ""); GuideController.TryGuide(_ui.m_btnBack, ConstGuideId.ARENA_OPEN, 7, "搭配好啦,挑个对手比拼吧~"); } protected override void TryCompleteGuide() { base.TryCompleteGuide(); GuideController.TryCompleteGuideIndex(ConstGuideId.ARENA_OPEN, 7); } } }