ArenaDressInfoView.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using FairyGUI;
  5. using UI.Arena;
  6. // using UI.DressUp;
  7. using UnityEngine;
  8. namespace GFGGame
  9. {
  10. public class ArenaDressInfoView : BaseWindow
  11. {
  12. private UI_ArenaDressInfoUI _ui;
  13. private GameObject _scenePrefab;
  14. private GameObject _sceneObject;
  15. private DressUpObj _dressUpObj;
  16. private List<LongPressGesture> _listLongPress = new List<LongPressGesture>();
  17. private List<FightData> _roleDatas;//可能是自己的搭配,也可能是对方玩家的搭配
  18. // private List<FightRobotData> _robotDatas;//对方机器人搭配
  19. private int _themeIndex = 0;
  20. private List<int> _itemList;
  21. private string[] _tags;
  22. private int _roleType = 0;//FightRoleType
  23. public override void Dispose()
  24. {
  25. if (_sceneObject != null)
  26. {
  27. GameObject.Destroy(_sceneObject);
  28. _sceneObject = null;
  29. }
  30. _dressUpObj.Dispose();
  31. for (int i = 0; i < _listLongPress.Count; i++)
  32. {
  33. _listLongPress[i].Dispose();
  34. }
  35. _listLongPress.Clear();
  36. if (_ui != null)
  37. {
  38. _ui.Dispose();
  39. _ui = null;
  40. }
  41. base.Dispose();
  42. }
  43. protected override void OnInit()
  44. {
  45. base.OnInit();
  46. packageName = UI_ArenaUI.PACKAGE_NAME;
  47. _ui = UI_ArenaDressInfoUI.Create();
  48. this.viewCom = _ui.target;
  49. isfullScreen = true;
  50. _ui.m_c2.onChanged.Add(OnThemeChange);
  51. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  52. _ui.m_btnDress.onClick.Add(OnBtnDressClick);
  53. _ui.m_btnRecommend.onClick.Add(OnBtnRecommendClick);
  54. _ui.m_list.itemRenderer = RenderListItem;
  55. _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneArenaDressUp"));
  56. // _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("gzs_bjbj");
  57. }
  58. protected override void AddEventListener()
  59. {
  60. base.AddEventListener();
  61. }
  62. protected override void OnShown()
  63. {
  64. base.OnShown();
  65. _roleType = (int)(this.viewData as object[])[0];
  66. _themeIndex = (int)(this.viewData as object[])[1];
  67. _roleDatas = (this.viewData as object[])[2] as List<FightData>;
  68. // _robotDatas = (this.viewData as object[])[3] as List<FightRobotData>;
  69. _ui.m_c1.selectedIndex = _roleType;
  70. if (_sceneObject == null)
  71. {
  72. _sceneObject = GameObject.Instantiate(_scenePrefab);
  73. MyDressUpHelper.dressUpObj.setSceneObj(_sceneObject, false, false);
  74. GameObject sceneCopyObject = _sceneObject.transform.Find("CopyRole").gameObject;
  75. _dressUpObj = new DressUpObj();
  76. _dressUpObj.setSceneObj(sceneCopyObject, false, false);
  77. }
  78. UpdateView();
  79. }
  80. protected override void OnHide()
  81. {
  82. base.OnHide();
  83. if (_sceneObject != null)
  84. {
  85. GameObject.Destroy(_sceneObject);
  86. _sceneObject = null;
  87. }
  88. }
  89. protected override void RemoveEventListener()
  90. {
  91. base.RemoveEventListener();
  92. }
  93. private void OnClickBtnBack()
  94. {
  95. ViewManager.GoBackFrom(typeof(ArenaDressInfoView).FullName);
  96. }
  97. private void OnThemeChange()
  98. {
  99. _themeIndex = _ui.m_c2.selectedIndex;
  100. if (_roleType == FightRoleType.MINE)
  101. {
  102. ArenaDataManager.Instance.SelectThemeIndex = _themeIndex;
  103. }
  104. UpdateView();
  105. }
  106. private void OnBtnDressClick()
  107. {
  108. ViewManager.Show<ArenaDressUpFightView>(null, new object[] { typeof(ArenaDressInfoView).FullName, new object[] { _roleType, _themeIndex, _roleDatas, null } }, true);
  109. }
  110. private void OnBtnRecommendClick()
  111. {
  112. for (int i = 0; i < ArenaDataManager.Instance.ThemeList.Count; i++)
  113. {
  114. int scoreType = ArenaDataManager.Instance.ThemeList[i];
  115. FightData roleData = ArenaDataManager.Instance.DressupList[i];
  116. roleData.scoreType = scoreType;
  117. roleData.itemList = ArenaDataManager.Instance.GetRecommentItemList(scoreType, roleData.tags);
  118. roleData.cardId = ArenaDataManager.Instance.GetRecommentCardId(scoreType, roleData.itemList);
  119. roleData.cardScore = ItemDataManager.GetItemAdditionScore(roleData.cardId, roleData.scoreType, roleData.tags);
  120. roleData.skillLvs = SkillDataManager.Instance.GetSkillLvs(roleData.cardId);
  121. FightDataManager.Instance.SetItemScoreList(roleData);
  122. ScoreSystemData.Instance.SetEquipScoresWithPartId(roleData);
  123. _roleDatas = ArenaDataManager.Instance.DressupList;
  124. ArenaSproxy.ReqChangeArenaDressup(i, roleData.cardId, roleData.itemList).Coroutine();
  125. Timers.inst.StartCoroutine(ScreenShotTex(i));
  126. }
  127. UpdateView();
  128. }
  129. private IEnumerator ScreenShotTex(int index)
  130. {
  131. _dressUpObj.TakeOffAll();
  132. _dressUpObj.PutOnItemList(_roleDatas[index].itemList);
  133. GameObject gameObject = _sceneObject.transform.Find("FightCamera").gameObject;
  134. Camera camera = gameObject.GetComponent<Camera>();
  135. ArenaDataManager.Instance.TextureDic[index] = FightDataManager.Instance.GetPrintscreenNTexture(camera);
  136. yield return new WaitForEndOfFrame();
  137. }
  138. private void UpdateView()
  139. {
  140. _itemList = _roleDatas[_themeIndex].itemList;
  141. _tags = _roleDatas[_themeIndex].tags;
  142. // UpdateValueInfo();
  143. UpdateCardInfo(_roleDatas[_themeIndex].cardId);
  144. ArenaViewManager.Instance.UpdateValue(_ui.m_comValueInfo.target, _themeIndex, _roleDatas);
  145. MyDressUpHelper.dressUpObj.PutOnItemList(_itemList);
  146. _ui.m_list.numItems = _itemList.Count;
  147. }
  148. private void UpdateCardInfo(int cardId)
  149. {
  150. if (cardId == 0)
  151. {
  152. _ui.m_comCard.m_c1.selectedIndex = 0;
  153. return;
  154. }
  155. _ui.m_comCard.m_c1.selectedIndex = 1;
  156. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(cardId);
  157. _ui.m_comCard.m_txtCardName.text = itemCfg.name;
  158. _ui.m_comCard.m_comCard.m_loaCard.url = ResPathUtil.GetCardSmallPath(itemCfg.res);
  159. _ui.m_comCard.m_loaScore.url = ResPathUtil.GetScorePath(ArenaDataManager.Instance.ThemeList[_themeIndex]);
  160. RarityIconController.UpdateRarityIcon(_ui.m_comCard.m_loaRarity, cardId, false);
  161. }
  162. private void RenderListItem(int index, GObject obj)
  163. {
  164. UI_ListPartsItem item = UI_ListPartsItem.Proxy(obj);
  165. // item.m_comAxtionSelect.target.visible = false;
  166. // item.m_imgNeed.visible = false;
  167. // item.m_imgNew.visible = false;
  168. item.m_iconSelected.visible = true;
  169. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_itemList[index]);
  170. item.m_txtTitle.text = itemCfg.name;
  171. item.m_ScoreType.url = ResPathUtil.GetScorePath(ArenaDataManager.Instance.ThemeList[_themeIndex]);
  172. item.m_icon.url = ResPathUtil.GetIconPath(itemCfg.res, "png");
  173. item.m_txtScore.text = _roleDatas[_themeIndex].itemScoreList[index].ToString();
  174. RarityIconController.UpdateRarityIcon(item.m_rarity, _itemList[index], false);
  175. if (item.target.data == null)
  176. {
  177. LongPressGesture longPressGesture = new LongPressGesture(item.target);
  178. longPressGesture.once = true;
  179. longPressGesture.onAction.Add(OnLongPress);
  180. _listLongPress.Add(longPressGesture);
  181. }
  182. item.target.data = _itemList[index];
  183. UI_ListPartsItem.ProxyEnd();
  184. }
  185. private void OnLongPress(EventContext context)
  186. {
  187. LongPressGesture gesture = (LongPressGesture)context.sender;
  188. int itemId = (int)gesture.host.data;
  189. GoodsItemTipsController.ShowItemTips(itemId);
  190. }
  191. }
  192. }