| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316 | 
							- using UnityEngine;
 
- using FairyGUI;
 
- using UI.Friend;
 
- using UI.CommonGame;
 
- namespace GFGGame
 
- {
 
-     public class FriendView : BaseView
 
-     {
 
-         private UI_FriendUI _ui;
 
-         private GameObject _sceneObject;
 
-         private DressUpObj _dressUpObj;
 
-         private long _friendRoleId;
 
-         public override void Dispose()
 
-         {
 
-             if (_sceneObject != null)
 
-             {
 
-                 PrefabManager.Instance.Restore(_sceneObject);
 
-                 _sceneObject = null;
 
-             }
 
-             _dressUpObj = null;
 
-             if (_ui != null)
 
-             {
 
-                 _ui.Dispose();
 
-                 _ui = null;
 
-             }
 
-             base.Dispose();
 
-         }
 
-         protected override void Init()
 
-         {
 
-             base.Init();
 
-         }
 
-         protected override void OnInit()
 
-         {
 
-             base.OnInit();
 
-             packageName = UI_FriendUI.PACKAGE_NAME;
 
-             _ui = UI_FriendUI.Create();
 
-             viewCom = _ui.target;
 
-             isfullScreen = true;
 
-             _dressUpObj = new DressUpObj();
 
-             _ui.m_list.SetVirtual();
 
-             _ui.m_list.itemRenderer = RenderListItem;
 
-             _ui.m_list.onClickItem.Add(OnListItemClick);
 
-             _ui.m_btnInfo.onClick.Add(OnBtnInfoClick);
 
-             _ui.m_btnDelete.onClick.Add(OnBtnDeleteClick);
 
-             _ui.m_btnAdd.onClick.Add(OnBtnAddClick);
 
-             _ui.m_btnSendAll.onClick.Add(OnBtnSendAllClick);
 
-             _ui.m_btnBack.onClick.Add(GoBackFrom);
 
-         }
 
-         protected override void AddEventListener()
 
-         {
 
-             base.AddEventListener();
 
-             EventAgent.AddEventListener(ConstMessage.FRIEND_REFRESH, RefreshView);
 
-             EventAgent.AddEventListener(ConstMessage.FRIEND_REMOVE, RefreshRemoveFriend);
 
-             EventAgent.AddEventListener(ConstMessage.FRIEND_ADD, RefreshAddFriend);
 
-             EventAgent.AddEventListener(ConstMessage.RED_CHANGE, UpdateRedDot);
 
-         }
 
-         protected override void OnShown()
 
-         {
 
-             base.OnShown();
 
-             _friendRoleId = this.viewData == null ? 0 : (long)this.viewData;
 
-             if (_sceneObject == null)
 
-             {
 
-                 CustomSuitData customSuit = CustomSuitDataManager.GetSuitList(CustomSuitDataManager.currentIndex);
 
-                 _sceneObject = PrefabManager.Instance.InstantiateSync(ResPathUtil.GetPrefabPath("SceneFriend"));
 
-                 _dressUpObj.setSceneObj(_sceneObject);
 
-                 _dressUpObj.AddOrRemove(customSuit.dressUpData.bgId, true);
 
-             }
 
-             FriendDataManager.Instance.UpdateFriendList(true);
 
-             _ui.m_list.numItems = FriendDataManager.Instance.FriendDatas.Count;
 
-             if (_ui.m_list.numItems > 0)
 
-             {
 
-                 if (_friendRoleId > 0)
 
-                 {
 
-                     for (int i = 0; i < FriendDataManager.Instance.FriendDatas.Count; i++)
 
-                     {
 
-                         if (_friendRoleId == FriendDataManager.Instance.FriendDatas[i])
 
-                         {
 
-                             _ui.m_list.selectedIndex = i;
 
-                             _ui.m_list.ScrollToView(i);
 
-                             ReqFriendDetialInfo(i);
 
-                         }
 
-                     }
 
-                 }
 
-                 else
 
-                 {
 
-                     _ui.m_list.selectedIndex = 0;
 
-                     ReqFriendDetialInfo(0);
 
-                 }
 
-             }
 
-             else
 
-             {
 
-                 ReqFriendDetialInfo(-1);
 
-             }
 
-             RefreshView();
 
-             UpdateRedDot();
 
-         }
 
-         protected override void OnHide()
 
-         {
 
-             base.OnHide();
 
-             if (_sceneObject != null)
 
-             {
 
-                 PrefabManager.Instance.Restore(_sceneObject);
 
-                 _sceneObject = null;
 
-             }
 
-             _ui.m_list.numItems = 0;
 
-         }
 
-         private void GoBackFrom()
 
-         {
 
-             ViewManager.GoBackFrom(typeof(FriendView).FullName);
 
-         }
 
-         protected override void RemoveEventListener()
 
-         {
 
-             base.RemoveEventListener();
 
-             EventAgent.RemoveEventListener(ConstMessage.FRIEND_REFRESH, RefreshView);
 
-             EventAgent.RemoveEventListener(ConstMessage.FRIEND_REMOVE, RefreshRemoveFriend);
 
-             EventAgent.RemoveEventListener(ConstMessage.FRIEND_ADD, RefreshAddFriend);
 
-             EventAgent.RemoveEventListener(ConstMessage.RED_CHANGE, UpdateRedDot);
 
-         }
 
-         private void RefreshView()
 
-         {
 
-             _ui.m_list.RefreshVirtualList();
 
-             _ui.m_txtCount.text = string.Format("好友数:{0}/{1}", _ui.m_list.numItems, GlobalCfgArray.globalCfg.maxFriendCount);
 
-             _ui.m_btnSendAll.text = RedDotDataManager.Instance.GetFriendGiftRed() ? "一键领取并赠送" : "一键赠送";
 
-             _ui.m_txtPowerCount.SetVar("value", FriendDataManager.Instance.Count.ToString()).FlushVars();
 
-             _ui.m_txtPowerCount.SetVar("maxValue", FriendDataManager.Instance.maxGetPowerCount.ToString()).FlushVars();
 
-         }
 
-         private void RenderListItem(int index, GObject obj)
 
-         {
 
-             long roleId = FriendDataManager.Instance.FriendDatas[index];
 
-             FriendInfoData friendInfo = FriendDataManager.Instance.GetFriendDataById(roleId);
 
-             UI_ListItem item = UI_ListItem.Proxy(obj);
 
-             RoleInfoManager.Instance.UpdateHead(item.m_comHead, friendInfo.roleInfo.headId, friendInfo.roleInfo.headBorderId);
 
-             item.m_txtName.text = friendInfo.roleInfo.roleName;
 
-             item.m_txtLvl.text = friendInfo.roleInfo.roleLv.ToString();
 
-             item.m_c2.selectedIndex = friendInfo.roleInfo.offlineTimeSec == 0 ? 0 : 1;
 
-             item.m_c1.selectedIndex = FriendDataManager.Instance.GetGiftState(friendInfo.roleInfo.roleId);
 
-             if (item.m_btnSend.data == null)
 
-             {
 
-                 item.m_btnSend.onClick.Add(OnClickBtnSend);
 
-             }
 
-             item.m_btnSend.data = roleId;
 
-             item.target.data = index;
 
-             UI_ListItem.ProxyEnd();
 
-         }
 
-         private void OnClickBtnSend(EventContext context)
 
-         {
 
-             GObject item = context.sender as GObject;
 
-             FriendInfoData friendInfo = FriendDataManager.Instance.GetFriendDataById((long)item.data);
 
-             if (friendInfo.takeGiftState == ConstBonusStatus.CAN_GET)
 
-             {
 
-                 // if (FriendDataManager.Instance.Count >= GlobalCfgArray.globalCfg.maxGetPowerCount)
 
-                 // {
 
-                 //     PromptController.Instance.ShowFloatTextPrompt("今日体力已全部领取");
 
-                 //     return;
 
-                 // }
 
-                 FriendSProxy.ReqTakeGiftFromFriend(friendInfo.roleInfo.roleId).Coroutine();
 
-             }
 
-             else if (friendInfo.giveGiftState == (int)ConstGiveGiftStatus.CanGave)
 
-             {
 
-                 FriendSProxy.ReqGiveGiftToFriend(friendInfo.roleInfo.roleId).Coroutine();
 
-             }
 
-         }
 
-         private void OnListItemClick(EventContext context)
 
-         {
 
-             GObject item = context.data as GObject;
 
-             int index = (int)item.data;
 
-             ReqFriendDetialInfo(index);
 
-         }
 
-         private void OnBtnSendAllClick()
 
-         {
 
-             if (RedDotDataManager.Instance.GetFriendGiftRed() && FriendDataManager.Instance.Count < FriendDataManager.Instance.maxGetPowerCount)
 
-             {
 
-                 FriendSProxy.ReqTakeGiftFromAllFriend().Coroutine();
 
-             }
 
-             else
 
-             {
 
-                 FriendSProxy.ReqGiveGiftToAllFriend().Coroutine();
 
-             }
 
-         }
 
-         private void OnBtnDeleteClick()
 
-         {
 
-             if (_ui.m_list.numItems == 0)
 
-             {
 
-                 PromptController.Instance.ShowFloatTextPrompt("暂无好友可删除");
 
-                 return;
 
-             }
 
-             AlertUI.Show("是否删除好友?").SetLeftButton(true).SetRightButton(true, "确定", (object data) =>
 
-             {
 
-                 int index = _ui.m_list.selectedIndex;
 
-                 long roleId = FriendDataManager.Instance.FriendDatas[index];
 
-                 FriendSProxy.ReqDeleteFriend(roleId).Coroutine();
 
-             });
 
-         }
 
-         private void RefreshRemoveFriend()
 
-         {
 
-             int index = _ui.m_list.selectedIndex;
 
-             _ui.m_list.numItems = FriendDataManager.Instance.FriendDatas.Count;
 
-             if (FriendDataManager.Instance.FriendDatas.Count > 0)
 
-             {
 
-                 if (index >= FriendDataManager.Instance.FriendDatas.Count)
 
-                 {
 
-                     index = FriendDataManager.Instance.FriendDatas.Count - 1;//选中最后一个
 
-                 }
 
-                 _ui.m_list.selectedIndex = index;
 
-             }
 
-             else
 
-             {
 
-                 index = -1;//无好友
 
-             }
 
-             ReqFriendDetialInfo(index);
 
-             _ui.m_txtCount.text = string.Format("好友数:{0}/{1}", _ui.m_list.numItems, GlobalCfgArray.globalCfg.maxFriendCount);
 
-         }
 
-         private void RefreshAddFriend()
 
-         {
 
-             int selectedIndex = 0;
 
-             if (_ui.m_list.numItems > 0)
 
-             {
 
-                 int childIndex = _ui.m_list.ItemIndexToChildIndex(_ui.m_list.selectedIndex);
 
-                 if (childIndex < 0) return;
 
-                 GButton item = _ui.m_list.GetChildAt(childIndex).asButton.GetChild("btnSend").asButton;
 
-                 long roleId = (long)item.data;
 
-                 selectedIndex = FriendDataManager.Instance.FriendDatas.IndexOf(roleId);
 
-             }
 
-             _ui.m_list.numItems = FriendDataManager.Instance.FriendDatas.Count;
 
-             _ui.m_list.selectedIndex = selectedIndex;
 
-             ReqFriendDetialInfo(selectedIndex);
 
-             _ui.m_txtCount.text = string.Format("好友数:{0}/{1}", _ui.m_list.numItems, GlobalCfgArray.globalCfg.maxFriendCount);
 
-         }
 
-         private async void ReqFriendDetialInfo(int index)
 
-         {
 
-             if (index >= 0)
 
-             {
 
-                 _friendRoleId = FriendDataManager.Instance.FriendDatas[index];
 
-                 OtherRoleInfoDetailData roleInfoDetail = await RoleInfoSProxy.ReqOtherRoleDetailInfo(_friendRoleId);
 
-                 if (roleInfoDetail != null)
 
-                 {
 
-                     UpdateScene(roleInfoDetail.customSuitData);
 
-                 }
 
-             }
 
-             else
 
-             {
 
-                 CustomSuitData customSuit = CustomSuitDataManager.GetSuitList(CustomSuitDataManager.currentIndex);
 
-                 UpdateScene(customSuit);
 
-             }
 
-         }
 
-         private void UpdateScene(CustomSuitData suitSavedData)
 
-         {
 
-             if (suitSavedData != null)
 
-             {
 
-                 _dressUpObj.PutOnDressUpData(suitSavedData.dressUpData);
 
-             }
 
-             else
 
-             {
 
-                 _dressUpObj.PutOnDefaultDressUpData();
 
-             }
 
-             Transform transform = _sceneObject.transform.Find("Role");
 
-             transform.localPosition = new Vector3(-2, transform.localPosition.y, 0);
 
-         }
 
-         private void OnBtnInfoClick()
 
-         {
 
-             if (_friendRoleId == 0)
 
-             {
 
-                 ViewManager.Show<RoleInfoView>(null, new object[] { typeof(FriendView).FullName, _friendRoleId });
 
-             }
 
-             else
 
-             {
 
-                 FriendInfoData friendInfoData = FriendDataManager.Instance.GetFriendDataById(_friendRoleId);
 
-                 ViewManager.Show<OtherRoleInfoView>(new object[] { friendInfoData.roleInfo, friendInfoData.roleDetailInfo }, new object[] { typeof(FriendView).FullName, _friendRoleId });
 
-             }
 
-         }
 
-         private void OnBtnAddClick()
 
-         {
 
-             ViewManager.Show<FriendAddView>();
 
-         }
 
-         private void UpdateRedDot()
 
-         {
 
-             RedDotController.Instance.SetComRedDot(_ui.m_btnAdd, RedDotDataManager.Instance.GetFriendApplyRed());
 
-             RedDotController.Instance.SetComRedDot(_ui.m_btnSendAll, RedDotDataManager.Instance.GetFriendGiftRed());
 
-             // RefreshView();
 
-         }
 
-     }
 
- }
 
 
  |