123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- 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 DressUpObj _dressUpObj;
- private List<LongPressGesture> _listLongPress = new List<LongPressGesture>();
- private List<FightData> _roleDatas;//可能是自己的搭配,也可能是对方玩家的搭配
- // private List<FightRobotData> _robotDatas;//对方机器人搭配
- private int _themeIndex = 0;
- private List<int> _itemList;
- 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_list.itemRenderer = RenderListItem;
- _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneArenaDressUp"));
- // _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("gzs_bjbj");
- }
- 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>;
- // _robotDatas = (this.viewData as object[])[3] as List<FightRobotData>;
- _ui.m_c1.selectedIndex = _roleType;
- if (_sceneObject == null)
- {
- _sceneObject = GameObject.Instantiate(_scenePrefab);
- MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject, false, false);
- GameObject sceneCopyObject = _sceneObject.transform.Find("CopyRole").gameObject;
- _dressUpObj = new DressUpObj();
- _dressUpObj.setSceneObj(sceneCopyObject, false, false);
- }
- UpdateView();
- }
- protected override void OnHide()
- {
- base.OnHide();
- if (_sceneObject != null)
- {
- GameObject.Destroy(_sceneObject);
- _sceneObject = null;
- }
- }
- protected override void RemoveEventListener()
- {
- base.RemoveEventListener();
- }
- private void OnClickBtnBack()
- {
- ViewManager.GoBackFrom(typeof(ArenaDressInfoView).FullName);
- }
- private void OnThemeChange()
- {
- _themeIndex = _ui.m_c2.selectedIndex;
- if (_roleType == FightRoleType.MINE)
- {
- ArenaDataManager.Instance.SelectThemeIndex = _themeIndex;
- }
- UpdateView();
- }
- private void OnBtnDressClick()
- {
- ViewManager.Show<ArenaDressUpFightView>(null, new object[] { typeof(ArenaDressInfoView).FullName, new object[] { _roleType, _themeIndex, _roleDatas, null } }, true);
- }
- private 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);
- roleData.cardScore = ItemDataManager.GetItemAdditionScore(roleData.cardId, roleData.scoreType, roleData.tags);
- roleData.skillLvs = SkillDataManager.Instance.GetSkillLvs(roleData.cardId);
- FightDataManager.Instance.SetItemScoreList(roleData);
- ScoreSystemData.Instance.SetEquipScoresWithPartId(roleData);
- _roleDatas = ArenaDataManager.Instance.DressupList;
- ArenaSproxy.ReqChangeArenaDressup(i, roleData.cardId, roleData.itemList).Coroutine();
- Timers.inst.StartCoroutine(ScreenShotTex(i));
- }
- UpdateView();
- }
- private IEnumerator ScreenShotTex(int index)
- {
- _dressUpObj.TakeOffAll();
- _dressUpObj.PutOnItemList(_roleDatas[index].itemList);
- GameObject gameObject = _sceneObject.transform.Find("FightCamera").gameObject;
- Camera camera = gameObject.GetComponent<Camera>();
- ArenaDataManager.Instance.TextureDic[index] = FightDataManager.Instance.GetPrintscreenNTexture(camera);
- yield return new WaitForEndOfFrame();
- }
- private void UpdateView()
- {
- _itemList = _roleDatas[_themeIndex].itemList;
- _tags = _roleDatas[_themeIndex].tags;
- // UpdateValueInfo();
- UpdateCardInfo(_roleDatas[_themeIndex].cardId);
- ArenaViewManager.Instance.UpdateValue(_ui.m_comValueInfo.target, _themeIndex, _roleDatas);
- MyDressUpHelper.dressUpObj.PutOnItemList(_itemList);
- _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_comAxtionSelect.target.visible = false;
- // item.m_imgNeed.visible = false;
- // item.m_imgNew.visible = false;
- 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].itemScoreList[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);
- }
- }
- }
|