123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274 |
- 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 _sceneObject;
- private List<LongPressGesture> _listLongPress = new List<LongPressGesture>();
- private List<FightData> _roleDatas; //可能是自己的搭配,也可能是对方玩家的搭配
- private int _themeIndex = 0;
- private string _openViewName = "";
- private List<int> _itemList = new List<int>();
- 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;
- }
- 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<FightData>;
- _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 = PrefabManager.Instance.InstantiateSync(ResPathUtil.GetPrefabPath("SceneArenaDressUp"));
- 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<ArenaDressUpFightView>(null,
- new object[]
- { typeof(ArenaDressInfoView).FullName, new object[] { _roleType, _themeIndex, _roleDatas, "" } },
- true);
- }
- private async void OnBtnRecommendClick()
- {
- //标记,本次推荐已经穿戴过的词牌,防止重复。
- var wearCardIds = new List<int>();
- 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, wearCardIds);
- 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;
- }
- }
- wearCardIds.Clear();
- 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.GetCardIconPath(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);
- }
- }
- }
|