/// <summary> /// 点击列表,显示操作按钮 /// </summary> void OnClickFriendItem(GameObject go) { if (page < 5) { OthersItemUi friend = (OthersItemUi)UIEventListener.Get(go).parameter; UIToggle tog = friend.GetComponent <UIToggle>(); if (tog != null) { friend.sp.gameObject.SetActive(tog.value); } GameCenter.friendsMng.curFriend = GameCenter.friendsMng.GetFriendsInfoById(friend.FriendsData.configId); if (operateWindow.Count > page) { curOperateUi = operateWindow[page]; } curOperateUi.gameObject.SetActive(true); curOperateUi.transform.localPosition = friend.transform.position - new Vector3(0, 100); if (page == 3) { curOperateUi.isTransfer = true; } else { curOperateUi.isTransfer = false; } if (curOperateUi != null) { curOperateUi.show(); } } }
/// <summary> /// 创建列表 /// </summary> void CreateFriendItem() { GameCenter.friendsMng.isAddInAdvice = false; findFriendUi.gameObject.SetActive(false); manage.SetActive(false); nofriend.SetActive(false); nobody.SetActive(false); noTuiSong.gameObject.SetActive(false); if (curOperateUi != null) { curOperateUi.gameObject.SetActive(false); } switch ((FriendType)page) { case FriendType.FRIEND: GameCenter.friendsMng.findFriend = null; if (list.Count <= 0) { nofriend.SetActive(true); return; } break; case FriendType.NEARBY: GameCenter.friendsMng.findFriend = null; GameCenter.friendsMng.GetNearbyPlayer(); if (list.Count <= 0) { nobody.SetActive(true); return; } break; case FriendType.BLACKLIST: case FriendType.ENEMY: GameCenter.friendsMng.findFriend = null; if (list.Count <= 0) { return; } break; case FriendType.COMMEND: { GameCenter.friendsMng.isAddInAdvice = true; findFriendUi.gameObject.SetActive(true); findFriendUi.ShowTuiSong(); if (GameCenter.friendsMng.findFriend != null) //如果有查找的右边显示查找的 { findFriendUi.FriendsData = GameCenter.friendsMng.findFriend; } else { if (findFriendUi.FriendsData != null) { findFriendUi.FriendsData = null; } else { findFriendUi.ShowFindInfo(); } } if (list.Count <= 0) { GameCenter.friendsMng.isAddInAdvice = false; noTuiSong.gameObject.SetActive(true); return; } } break; case FriendType.MANAGEFRIEND: ChoosedList.Clear(); GameCenter.friendsMng.findFriend = null; manage.SetActive(true); if (list.Count <= 0) { return; } break; default: break; } OthersItemUi itemUi = null; for (int i = 0, max = list.Count; i < max; i++) { if (!friendItemUiList.ContainsKey(list[i].configId)) { GameObject go = null; go = (GameObject)GameObject.Instantiate(friendItems.gameObject); itemUi = go.GetComponent <OthersItemUi>(); if (page == (int)FriendType.COMMEND) { go.transform.parent = ComendScro.transform; go.transform.localPosition = new Vector3(30, i * itemHeiht - 36); } else if (page == (int)FriendType.MANAGEFRIEND) { go.transform.parent = friendItems.transform.parent; if (itemUi != null) { itemUi.transform.localPosition = new Vector3(i % 2 * itemWidth + 30, i / 2 * itemHeiht); } } else { go.transform.parent = friendItems.transform.parent; go.transform.localPosition = new Vector3(i % 2 * itemWidth + 30, i / 2 * itemHeiht); } if (itemUi != null) { if (itemUi.sendFlowerBtn != null) { itemUi.sendFlowerBtn.SetActive(page == 0); } if (itemUi.intimacyLab != null) { itemUi.intimacyLab.SetActive(page == 0 || page == 4); } if (itemUi.sameScrDes != null) { itemUi.sameScrDes.SetActive(page == 1); } if (itemUi.placeLab != null) { itemUi.placeLab.gameObject.SetActive(page == 3 && list[i].IsOnline); } if (itemUi.chooseTol != null) { itemUi.chooseTol.gameObject.SetActive(page == 5); } itemUi.FriendsData = list[i]; friendItemUiList[list[i].configId] = itemUi; UIEventListener.Get(itemUi.gameObject).onClick -= OnClickFriendItem; UIEventListener.Get(itemUi.gameObject).onClick += OnClickFriendItem; UIEventListener.Get(itemUi.gameObject).parameter = itemUi; } go.transform.localScale = Vector3.one; go.SetActive(true); } else { itemUi = friendItemUiList[list[i].configId] as OthersItemUi; if (itemUi != null) { if (page == (int)FriendType.COMMEND) { itemUi.transform.parent = ComendScro.transform; itemUi.transform.localPosition = new Vector3(30, i * itemHeiht - 36); } else if (page == (int)FriendType.MANAGEFRIEND) { itemUi.transform.parent = friendItems.transform.parent; itemUi.transform.localPosition = new Vector3(i % 2 * itemWidth + 30, i / 2 * itemHeiht); } else { itemUi.transform.parent = friendItems.transform.parent; itemUi.transform.localPosition = new Vector3(i % 2 * itemWidth + 30, i / 2 * itemHeiht); } if (itemUi.sendFlowerBtn != null) { itemUi.sendFlowerBtn.SetActive(page == 0); } if (itemUi.intimacyLab != null) { itemUi.intimacyLab.SetActive(page == 0 || page == 4); } if (itemUi.sameScrDes != null) { itemUi.sameScrDes.SetActive(page == 1); } if (itemUi.placeLab != null) { itemUi.placeLab.gameObject.SetActive(page == 3 && list[i].IsOnline); } if (itemUi.chooseTol != null) { itemUi.chooseTol.gameObject.SetActive(page == 5); } itemUi.gameObject.SetActive(true); itemUi.FriendsData = list[i]; friendItemUiList[list[i].configId] = itemUi; UIEventListener.Get(itemUi.gameObject).onClick -= OnClickFriendItem; UIEventListener.Get(itemUi.gameObject).onClick += OnClickFriendItem; UIEventListener.Get(itemUi.gameObject).parameter = itemUi; itemUi.transform.localScale = Vector3.one; } } } if (manage != null && manage.activeSelf) { if (deleteNochoose != null) { UIEventListener.Get(deleteNochoose.gameObject).onClick = OnClickDeleteNoChoose; } if (deleteChoose != null) { UIEventListener.Get(deleteChoose.gameObject).onClick = delegate { if (ChoosedList.Count > 0) { MessageST mst = new MessageST(); mst.messID = 383; mst.delYes = delegate { GameCenter.friendsMng.C2S_ReqOperateFriend(FriendOperation.DELETEFRIEND, ChoosedList); }; GameCenter.messageMng.AddClientMsg(mst); } } } ; if (deleteAll != null) { UIEventListener.Get(deleteAll.gameObject).onClick = OnClickDeleteAll; } if (addChooseToBlack != null) { UIEventListener.Get(addChooseToBlack.gameObject).onClick = delegate { GameCenter.friendsMng.C2S_ReqOperateFriend(FriendOperation.ADDBALCKLIST, ChoosedList); } } ; if (cancelAll != null) { UIEventListener.Get(cancelAll.gameObject).onClick = OnClickCancleAll; } } } /// <summary> /// 刷新列表 /// </summary> void OnFriendListUpdate() { foreach (OthersItemUi ui in friendItemUiList.Values) { ui.gameObject.SetActive(false); ui.sp.gameObject.SetActive(false); } if (operateWindow.Count > page) { curOperateUi = operateWindow[page]; } isCreateItems = true; }