123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- using UnityEngine;
- using FairyGUI;
- using UI.Friend;
- namespace GFGGame
- {
- public class FriendView : BaseView
- {
- private UI_FriendUI _ui;
- private GameObject _scenePrefab;
- private GameObject _sceneObject;
- public override void Dispose()
- {
- if (_sceneObject != null)
- {
- GameObject.Destroy(_sceneObject);
- _sceneObject = null;
- }
- if (_ui != null)
- {
- _ui.Dispose();
- _ui = null;
- }
- base.Dispose();
- }
- protected override void Init()
- {
- base.Init();
- packageName = UI_FriendUI.PACKAGE_NAME;
- _ui = UI_FriendUI.Create();
- viewCom = _ui.target;
- isfullScreen = true;
- _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneFriend"));
- _ui.m_list.SetVirtual();
- _ui.m_list.itemRenderer = RenderListItem;
- _ui.m_list.onClickItem.Add(OnListItemClick);
- _ui.m_btnSolgan.onClick.Add(OnBtnSloganClick);
- _ui.m_btnDelete.onClick.Add(OnBtnDeleteClick);
- _ui.m_btnAdd.onClick.Add(OnBtnAddClick);
- }
- protected override void OnInit()
- {
- base.OnInit();
- _ui.m_btnBack.onClick.Add(OnHide);
- }
- protected override void AddEventListener()
- {
- base.AddEventListener();
- }
- protected override void OnShown()
- {
- base.OnShown();
- _ui.m_grpSlogan.visible = false;
- UpdateList();
- CustomSuitData suitSavedData = CustomSuitDataManager.GetCurrentSuitList();
- // if (_ui.m_list.numItems > 0)
- // {
- // _ui.m_list.selectedIndex = 0;
- // suitSavedData = _ui.m_list.GetChildAt(0).asCom.data as CustomSuitData;
- // }
- UpdateScene(suitSavedData);
- }
- protected override void OnHide()
- {
- if (_sceneObject != null)
- {
- GameObject.Destroy(_sceneObject);
- _sceneObject = null;
- }
- ViewManager.GoBackFrom(typeof(FriendView).FullName);
- }
- protected override void RemoveEventListener()
- {
- base.RemoveEventListener();
- }
- private void UpdateList()
- {
- _ui.m_list.numItems = 20;
- }
- private void RenderListItem(int index, GObject obj)
- {
- UI_ListItem item = UI_ListItem.Proxy(obj);
- UI_ListItem.ProxyEnd();
- }
- private void OnListItemClick(EventContext context)
- {
- GObject item = context.data as GObject;
- CustomSuitData suitSavedData = item.data as CustomSuitData;
- UpdateScene(suitSavedData);
- }
- private void UpdateScene(CustomSuitData suitSavedData)
- {
- if (_sceneObject == null)
- {
- _sceneObject = GameObject.Instantiate(_scenePrefab);
- EquipDataCache.cacher.setSceneObj(_sceneObject);
- }
- EquipDataCache.cacher.PutOnSuitMemory(suitSavedData);
- }
- private void OnBtnSloganClick()
- {
- _ui.m_grpSlogan.visible = !_ui.m_grpSlogan.visible;
- }
- private void OnBtnDeleteClick()
- {
- AlertUI.Show("是否删除好友?").SetLeftButton(true).SetRightButton(true, "确定", (object data) =>
- {
- });
- }
- private void OnBtnAddClick()
- {
- ViewManager.Show<FriendAddView>();
- }
- }
- }
|