private void OnClickNextButton(GameObject obj) { UIButton btn = obj.transform.GetComponent <UIButton>(); sg.GS2C_Task_Invite_List_Res.canInviteFriend friend = (sg.GS2C_Task_Invite_List_Res.canInviteFriend)btn.Data; StorageFriendInfo friendInfo = new StorageFriendInfo(); friendInfo.friendId = friend.friendId; friendInfo.friendType = friend.friendType; friendInfo.friendGender = friend.friendGender; friendInfo.friednAppearance = friend.friednAppearance; if (friend.friendType == (int)JobManager.InviteType.Pet) { friendInfo.friendCloth = Globals.Instance.MGameDataManager.MActorData.PetInfo.itemId.ToString(); } else { friendInfo.friendCloth = friend.friendCloth; } friendInfo.friendActing = friend.actSkill; Globals.Instance.MTaskManager.mTaskDailyData.FriendInfo = friendInfo; NPCConfig Config = Globals.Instance.MDataTableManager.GetConfig <NPCConfig>(); NPCConfig.NPCObject NpcObj = null; bool isHas = Config.GetNPCObject((int)friend.friendId, out NpcObj); if (!isHas) { NetSender.Instance.RequestTaskInviteReq(taskID, (int)friend.friendId, friend.friendType); return; } if (friend.friendType != (int)JobManager.InviteType.FRIEND && friend.friendType != (int)JobManager.InviteType.NEARBY) { if (NpcObj.Cost_Money != -1) { Globals.Instance.MGUIManager.CreateGUIDialog(delegate(GUIDialog gui){ gui.SetTextAnchor(ETextAnchor.MiddleLeft, false); gui.SetDialogType(EDialogType.CommonType, null); string flag = string.Format(Globals.Instance.MDataTableManager.GetWordText(4014), NpcObj.Cost_Money, Globals.Instance.MDataTableManager.GetWordText(4015)); gui.SetText(flag); }, EDialogStyle.DialogOkCancel, delegate() { NetSender.Instance.RequestTaskInviteReq(taskID, (int)friend.friendId, friend.friendType); }); } else if (NpcObj.Cost_Ingot != -1) { Globals.Instance.MGUIManager.CreateGUIDialog(delegate(GUIDialog gui){ gui.SetTextAnchor(ETextAnchor.MiddleLeft, false); gui.SetDialogType(EDialogType.CommonType, null); string flag = string.Format(Globals.Instance.MDataTableManager.GetWordText(4014), NpcObj.Cost_Ingot, Globals.Instance.MDataTableManager.GetWordText(4016)); gui.SetText(flag); }, EDialogStyle.DialogOkCancel, delegate() { NetSender.Instance.RequestTaskInviteReq(taskID, (int)friend.friendId, friend.friendType); }); } else { NetSender.Instance.RequestTaskInviteReq(taskID, (int)friend.friendId, friend.friendType); } } }
public void ShowFriendsList(sg.GS2C_Task_Invite_List_Res res) { mTaskInviteList = res; this.SetVisible(true); NGUITools.SetActive(MissionView, false); NGUITools.SetActive(FriendsView, true); taskID = res.taskId; UILabel MissionName = FriendsView.transform.Find("MissionName").gameObject.transform.Find("MissionNameLabel").GetComponent <UILabel>(); Task tk = Globals.Instance.MDataTableManager.GetConfig <Task>(); Task.TaskObject element = null; bool hasData = tk.GetTaskObject(res.taskId, out element); if (!hasData) { return; } MissionName.text = element.Name; HelpUtil.DelListInfo(FriendGrid.transform); foreach (sg.GS2C_Task_Invite_List_Res.canInviteFriend friend in res.friendLis) { GameObject obj = GameObject.Instantiate(FriendItem) as GameObject; obj.transform.parent = FriendGrid.transform; obj.transform.localScale = Vector3.one; obj.transform.localPosition = new Vector3(0, 0, -5); if (friend.friendType == (int)JobManager.InviteType.Pet) { obj.name = "AA" + friend.friendType; } else if (friend.friendType == (int)JobManager.InviteType.NPC) { obj.name = "BB" + friend.friendType; } else if (friend.friendType == (int)JobManager.InviteType.FRIEND) { obj.name = "CC" + friend.friendType; } else if (friend.friendType == (int)JobManager.InviteType.NEARBY) { obj.name = "DD" + friend.friendType; } GameObject AllLabel = obj.transform.Find("AllLabel").gameObject; GameObject Details = obj.transform.Find("Tween").transform.Find("GameObject").transform.Find("Details").gameObject; UITexture FriendIcon = AllLabel.transform.Find("FriendIcon").GetComponent <UITexture>(); UILabel NameLabel = AllLabel.transform.Find("NameLabel").GetComponent <UILabel>(); UIButton AddFriendButton = AllLabel.transform.Find("AddFriendButton").GetComponent <UIButton>(); UIButton CheckButton = AllLabel.transform.Find("CheckButton").GetComponent <UIButton>(); UISprite mFriendSign = AllLabel.transform.Find("Friendsign").GetComponent <UISprite>(); UILabel FriendshipLabel = AllLabel.transform.Find("FriendshipLabel").GetComponent <UILabel>(); UIEventListener.Get(AddFriendButton.gameObject).onClick += OnClickAddFriendButton; UIEventListener.Get(CheckButton.gameObject).onClick += OnClickCheckButton; UILabel ActingLabel = Details.transform.Find("ActingLabel").GetComponent <UILabel>(); UILabel FansLabel = Details.transform.Find("FansLabel").GetComponent <UILabel>(); if (friend.friendType == (int)JobManager.InviteType.Pet) { PetInfoMation PetInfo = Globals.Instance.MGameDataManager.MActorData.PetInfo; ActingLabel.text = (PetInfo.baseActing + PetInfo.incActing).ToString(); FansLabel.text = "0"; NameLabel.text = PetInfo.petName; NGUITools.SetActive(AddFriendButton.gameObject, false); NGUITools.SetActive(mFriendSign.gameObject, false); FriendshipLabel.text = "10"; AddFriendButton.Data = friend; CheckButton.Data = friend; FriendIcon.mainTexture = Resources.Load("Icon/AvatarIcon/Npc12001", typeof(Texture2D)) as Texture2D; } else { ActingLabel.text = friend.actSkill.ToString(); FansLabel.text = friend.fans.ToString(); NameLabel.text = friend.friendName; if (friend.friendType == (int)JobManager.InviteType.NEARBY) { NGUITools.SetActive(AddFriendButton.gameObject, true); NGUITools.SetActive(mFriendSign.gameObject, false); FriendshipLabel.text = "5"; } else { NGUITools.SetActive(AddFriendButton.gameObject, false); NGUITools.SetActive(mFriendSign.gameObject, true); FriendshipLabel.text = "10"; } AddFriendButton.Data = friend; CheckButton.Data = friend; if (friend.friendIcon != "") { FriendIcon.mainTexture = Resources.Load("Icon/AvatarIcon/" + friend.friendIcon, typeof(Texture2D)) as Texture2D; } } UIButton NextButton = obj.transform.Find("Tween").transform.Find("GameObject").transform.Find("NextButton").GetComponent <UIButton>(); NextButton.Data = friend; UIEventListener.Get(NextButton.gameObject).onClick += OnClickNextButton; NGUITools.SetActive(obj.transform.Find("Tween").gameObject, false); UISprite cost = NextButton.gameObject.transform.Find("Sprite").GetComponent <UISprite>(); UILabel label = NextButton.gameObject.transform.Find("Label").GetComponent <UILabel>(); if (friend.friendType != (int)JobManager.InviteType.FRIEND && friend.friendType != (int)JobManager.InviteType.NEARBY) { NPCConfig Config = Globals.Instance.MDataTableManager.GetConfig <NPCConfig>(); NPCConfig.NPCObject NpcObj = null; bool isHas = Config.GetNPCObject((int)friend.friendId, out NpcObj); if (!isHas) { NGUITools.SetActive(cost.gameObject, false); label.transform.localPosition = Vector3.zero; continue; } if (NpcObj.Cost_Money != -1) { cost.spriteName = "IconJinqian"; } else if (NpcObj.Cost_Ingot != -1) { cost.spriteName = "IconZuanshi"; } else { NGUITools.SetActive(cost.gameObject, false); label.transform.localPosition = Vector3.zero; } } } FriendGrid.repositionNow = true; }