lvjincheng 4 éve
szülő
commit
2bda99b05b

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 1610 - 227
Assets/BowArrow/Resources/Prefabs/Views/FriendView.prefab


+ 63 - 1
Assets/BowArrow/Scripts/View/FriendView.cs

@@ -10,6 +10,7 @@ public class FriendView : MonoBehaviour
 {
 {
     [SerializeField] GameObject myFriendBox;
     [SerializeField] GameObject myFriendBox;
     [SerializeField] GameObject friendRequestBox;
     [SerializeField] GameObject friendRequestBox;
+    [SerializeField] GameObject friendRecommendBox;
     [SerializeField] GameObject searchPlayerBox;
     [SerializeField] GameObject searchPlayerBox;
 
 
     void Awake()
     void Awake()
@@ -17,6 +18,7 @@ public class FriendView : MonoBehaviour
         InitBtnTabs();
         InitBtnTabs();
         InitMyFriendBox();
         InitMyFriendBox();
         InitFriendRequestBox();
         InitFriendRequestBox();
+        InitFriendRecommendBox();
         InitSearchPlayerBox();
         InitSearchPlayerBox();
     }
     }
 
 
@@ -160,6 +162,62 @@ public class FriendView : MonoBehaviour
         }
         }
     #endregion
     #endregion
 
 
+    #region friendRecommend
+        void InitFriendRecommendBox() {
+            friendRecommendBox.SetActive(false);
+            GetFriendRecommendItemPrefab().SetActive(false);
+        }
+        Transform GetFriendRecommendItemParent() {
+            return friendRecommendBox.transform.Find("ScrollView/Viewport/Content");
+        }
+        GameObject GetFriendRecommendItemPrefab() {
+            return GetFriendRecommendItemParent().Find("Item").gameObject;
+        }
+        void EnterFriendRecommendBox() {
+            friendRecommendBox.SetActive(true);
+            for (int i = 1; i < GetFriendRecommendItemParent().childCount; i++) {
+                Destroy(GetFriendRecommendItemParent().GetChild(i).gameObject);
+            }
+            Action<JArray> cb = delegate(JArray list) {
+                for (int i = 1; i < GetFriendRecommendItemParent().childCount; i++) {
+                    Destroy(GetFriendRecommendItemParent().GetChild(i).gameObject);
+                }
+                if (list.Count > 0) {
+                    foreach (var itemInfo in list) {
+                        int userID = itemInfo.Value<int>("id");
+                        int avatarID = itemInfo.Value<int>("avatarID");
+                        string nickname = itemInfo.Value<string>("nickname");
+                        bool online = itemInfo.Value<bool>("online");
+                        long offlineTime = itemInfo.Value<long>("offlineTime");
+                        int playCount = itemInfo.Value<int>("playCount");
+                        GameObject o = GameObject.Instantiate(GetFriendRecommendItemPrefab(), GetFriendRecommendItemParent());
+                        o.SetActive(true);
+                        o.name = userID.ToString();
+                        o.transform.Find("Avatar/Sprite").GetComponent<Image>().sprite = RoleMgr.GetAvatar(avatarID);
+                        o.transform.Find("Name").GetComponent<Text>().text = nickname;
+                        o.transform.Find("PlayCount").GetComponent<Text>().text = $"最近一起进行过 {playCount} 场对战";
+                        o.transform.Find("BG0").gameObject.SetActive(!online);
+                        o.transform.Find("BG1").gameObject.SetActive(online);
+                        Text onlineTip = o.transform.Find("OnlineTip").GetComponent<Text>();
+                        onlineTip.text = TimeUtil.GetOfflineTimeStr(offlineTime, online);
+                        onlineTip.color = online ? Color.green : Color.gray;
+                        Button btnYes = o.transform.Find("BtnAdd").GetComponent<Button>();
+                        btnYes.onClick.RemoveAllListeners();
+                        btnYes.onClick.AddListener(delegate() {
+                            AudioMgr.ins.PlayBtn();
+                            UserPlayer.ins.call("friendComp.requestAddFriend", userID);
+                            btnYes.interactable = false;
+                        });
+                    }
+                } else {
+                    PopupMgr.ins.ShowTip("没有可推荐的好友");
+                }
+            };
+            UserPlayer.ins.call("friendComp.getFriendRecommendList", null, cb);
+            PopupMgr.ins.ClearAllTip();
+        }
+    #endregion
+
     #region searchPlayer
     #region searchPlayer
         void InitSearchPlayerBox() {
         void InitSearchPlayerBox() {
             searchPlayerBox.SetActive(false);
             searchPlayerBox.SetActive(false);
@@ -228,6 +286,7 @@ public class FriendView : MonoBehaviour
     void HideAllBox() {
     void HideAllBox() {
         myFriendBox.SetActive(false);
         myFriendBox.SetActive(false);
         friendRequestBox.SetActive(false);
         friendRequestBox.SetActive(false);
+        friendRecommendBox.SetActive(false);
         searchPlayerBox.SetActive(false);
         searchPlayerBox.SetActive(false);
     }
     }
 
 
@@ -239,11 +298,12 @@ public class FriendView : MonoBehaviour
 
 
     #region 左栏条目切换
     #region 左栏条目切换
         [SerializeField] Sprite[] btnTabTextures;
         [SerializeField] Sprite[] btnTabTextures;
-        Button[] btnTabs = {null, null, null};
+        Button[] btnTabs = {null, null, null, null};
         void InitBtnTabs() {
         void InitBtnTabs() {
             btnTabs[0] = this.transform.Find("LineV/BtnTab0").GetComponent<Button>();
             btnTabs[0] = this.transform.Find("LineV/BtnTab0").GetComponent<Button>();
             btnTabs[1] =this.transform.Find("LineV/BtnTab1").GetComponent<Button>();
             btnTabs[1] =this.transform.Find("LineV/BtnTab1").GetComponent<Button>();
             btnTabs[2] =this.transform.Find("LineV/BtnTab2").GetComponent<Button>();
             btnTabs[2] =this.transform.Find("LineV/BtnTab2").GetComponent<Button>();
+            btnTabs[3] =this.transform.Find("LineV/BtnTab3").GetComponent<Button>();
             for (int i = 0; i < btnTabs.Length; i++) {
             for (int i = 0; i < btnTabs.Length; i++) {
                 Button btnTab = btnTabs[i];
                 Button btnTab = btnTabs[i];
                 int btnTabIndex = i;
                 int btnTabIndex = i;
@@ -275,6 +335,8 @@ public class FriendView : MonoBehaviour
             } else if (btnIndex == 1) {
             } else if (btnIndex == 1) {
                 EnterFriendRequestBox();
                 EnterFriendRequestBox();
             } else if (btnIndex == 2) {
             } else if (btnIndex == 2) {
+                EnterFriendRecommendBox();   
+            } else if (btnIndex == 3) {
                 EnterSearchPlayerBox();
                 EnterSearchPlayerBox();
             }
             }
         }
         }

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott