using UnityEngine; using UnityEngine.UI; using System.Collections; using GCGame.Table; using Games.Item; using Games.GlobeDefine; using GCGame; using System.Collections.Generic; using Module.Log; using Games.UserCommonData; public enum TooltipType { NORMAL, CHAT_MSG } public class PlayerTooltipsLogic : MonoBehaviour { public RectTransform _Anchor; public Image _Icon; public Text _Level; public Text _Name; public Text _Team; public Text _Xiuwei; public UISubScollMenu _PopMenu; private int _TeamID = -1; private string _IconName; private int _LevelValue; private ulong _Guid; private string _PlayerName; private string _Content; private static PlayerTooltipsLogic m_Instance; public static PlayerTooltipsLogic Instance() { return m_Instance; } public static GC_RET_OTHER_ROLE_BASE_INFO _PlayerRetInfo; public static void ShowPlayerTooltip(ulong guid, string name, string icon, int level, int teamID, int xiuwei, Vector3 pos, int type = 0, string content = "") { if (guid == GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid) return; Hashtable hash = new Hashtable(); hash.Add("GUID", guid); hash.Add("Icon", icon); hash.Add("Name", name); hash.Add("Level", level); hash.Add("TeamID", teamID); hash.Add("Xiuwei", xiuwei); hash.Add("Pos", pos); hash.Add("Type", type); hash.Add("Content", content); UIManager.ShowUI(UIInfo.PlayerTooltipsRoot, OnShowPlayerTip, hash); } public static void ShowPlayerTooltip(ulong guid, string name, Vector3 pos, string content = "", int profession = -1, int level = -1) { if (guid == GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid) return; Hashtable hash = new Hashtable(); hash.Add("Name", name); hash.Add("Pos", pos); hash.Add("GUID", guid); hash.Add("Content", content); if(profession != -1) { var iconName = GCGame.Utils.GetProfessionSpriteName(profession); hash.Add("Icon", iconName); } if(level != -1) { hash.Add("Level", level); } UIManager.ShowUI(UIInfo.PlayerTooltipsRoot, OnShowPlayerTip, hash); } private static void OnShowPlayerTip(bool bSuccess, object param) { if (!bSuccess) { LogModule.ErrorLog("load playertooltip error"); return; } Hashtable hash = param as Hashtable; Vector3 pos = (Vector3)hash["Pos"]; PlayerTooltipsLogic.Instance()._Anchor.anchoredPosition = new Vector2(pos.x, pos.y); string content = ""; if(hash.ContainsKey("Content")) { content = (string)hash["Content"]; } ulong guid = 0; if (hash.ContainsKey("GUID")) { guid = (ulong)hash["GUID"]; } string icon = ""; if (hash.ContainsKey("Icon")) { icon = (string)hash["Icon"]; } string name = ""; if (hash.ContainsKey("Name")) { name = (string)hash["Name"]; } int level = 0; if (hash.ContainsKey("Level")) { level = (int)hash["Level"]; if (_PlayerRetInfo != null && _PlayerRetInfo.Guid == guid) level = _PlayerRetInfo.Lvl; } int teamID = -1; if (hash.ContainsKey("TeamID")) { teamID = (int)hash["TeamID"]; if (_PlayerRetInfo != null && _PlayerRetInfo.Guid == guid) teamID = _PlayerRetInfo.Teamid; } int xiuwei = -1; if (hash.ContainsKey("Xiuwei")) { xiuwei = (int)hash["Xiuwei"]; if (_PlayerRetInfo != null && _PlayerRetInfo.Guid == guid) xiuwei = _PlayerRetInfo.Abilitylvl; } int type = -1; if (hash.ContainsKey("Type")) { type = (int)hash["Type"]; } int teamMemCnt = 0; if (_PlayerRetInfo != null && _PlayerRetInfo.Guid == guid) teamMemCnt = _PlayerRetInfo.Teammembernum; PlayerTooltipsLogic.Instance().ShowTooltips(guid, icon, name, level, teamID, teamMemCnt, xiuwei, type, content); } void Awake() { m_Instance = this; } void Start() { if (_PlayerRetInfo != null) { UpdatePlayerBaseInfo(_PlayerRetInfo); } } void OnDestroy() { m_Instance = null; } public void UpdatePlayerBaseInfo(GC_RET_OTHER_ROLE_BASE_INFO packet) { _PlayerRetInfo = packet; UpdateToolTips(packet.Guid, Utils.GetProfessionSpriteName(packet.Prof), packet.Rolename, packet.Lvl, packet.Teamid, packet.Teammembernum, packet.Abilitylvl); } private void ShowTooltips(ulong guid, string icon, string name, int level, int teamID, int teamMemCnt, int xiuwei, int type = 0, string content = "") { _Guid = guid; _PlayerName = name; LoadAssetBundle.Instance.SetImageSprite(_Icon, icon); _IconName = icon; _LevelValue = level; _Level.text = level.ToString(); _Name.text = name; _Content = content; if (teamMemCnt > 0) { _Team.text = teamMemCnt + "/" + GlobeVar.MAX_TEAM_MEMBER.ToString(); } else { _Team.text = "-/-"; } _Xiuwei.text = xiuwei.ToString(); _TeamID = teamID; _PopMenu.Clear(); bool sameTeam = false; bool Friend = false; if (GameManager.gameManager.PlayerDataPool.IsHaveTeam() && GameManager.gameManager.PlayerDataPool.IsTeamMem(_Guid)) sameTeam = true; if (GameManager.gameManager.PlayerDataPool.FriendList.RelationDataList.ContainsKey(_Guid)) Friend = true; _PopMenu.PushMenu(StrDictionary.GetClientDictionaryString("#{4904}"));//发送消息 _PopMenu.PushMenu(StrDictionary.GetClientDictionaryString("#{4355}"));//查看消息 _PopMenu.PushMenu(StrDictionary.GetClientDictionaryString("#{4354}"));//邀请入队 _PopMenu.PushMenu(StrDictionary.GetClientDictionaryString("#{4352}"));//申请入队 if (Friend) { _PopMenu.PushMenu(StrDictionary.GetClientDictionaryString("#{5206}"));//删除好友 } else { if (!GameManager.gameManager.PlayerDataPool.BlackList.RelationDataList.ContainsKey(guid)) { _PopMenu.PushMenu(StrDictionary.GetClientDictionaryString("#{4363}"));//添加好友 } } if (type == (int)TooltipType.CHAT_MSG) { _PopMenu.PushMenu(StrDictionary.GetClientDictionaryString("#{5212}"));//好友聊天:移除列表 } if (GameManager.gameManager.PlayerDataPool.BlackList.RelationDataList.ContainsKey(guid)) { _PopMenu.PushMenu(StrDictionary.GetClientDictionaryString("#{5205}"));//删除黑名单 } else { _PopMenu.PushMenu(StrDictionary.GetClientDictionaryString("#{5204}"));//加入黑名单 } //_PopMenu.PushMenu(StrDictionary.GetClientDictionaryString("#{4353}"));//举报玩家 _PopMenu.PushMenu(StrDictionary.GetClientDictionaryString("#{4905}"));//梦岛 _PopMenu.PushMenu(StrDictionary.GetClientDictionaryString("#{4943}"));//赠送鲜花 //_PopMenu.PushMenu(StrDictionary.GetClientDictionaryString("#{4906}"));//查看家谱 _PopMenu.PushMenu(StrDictionary.GetClientDictionaryString("#{1657}"));//切磋 _PopMenu.PushMenu(StrDictionary.GetClientDictionaryString("#{4353}"));//举报 //gameObject.SetActive(true); //UIManager.ShowUI(UIInfo.ItemTooltipsRoot); CG_REQ_OTHER_ROLE_BASE_INFO askPak = (CG_REQ_OTHER_ROLE_BASE_INFO)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_OTHER_ROLE_BASE_INFO); askPak.SetGuid(guid); askPak.SendPacket(); } private void UpdateToolTips(ulong guid, string icon, string name, int level, int teamID, int teamMemCnt, int xiuwei) { _Guid = guid; _PlayerName = name; LoadAssetBundle.Instance.SetImageSprite(_Icon, icon); _IconName = icon; _LevelValue = level; _Level.text = level.ToString(); _Name.text = name; if (teamMemCnt > 0) { _Team.text = teamMemCnt + "/" + GlobeVar.MAX_TEAM_MEMBER.ToString(); } else { _Team.text = "-/-"; } _Xiuwei.text = xiuwei.ToString(); _TeamID = teamID; } public void CloseWindow() { //m_Item = null; //gameObject.SetActive(false); UIManager.CloseUI(UIInfo.PlayerTooltipsRoot); } public void OnBtnPopMenu(object menuObj) { string menuStr = menuObj as string; if (menuStr == StrDictionary.GetClientDictionaryString("#{4904}")) { OnSendMessage(); } else if (menuStr == StrDictionary.GetClientDictionaryString("#{4355}")) { OnViewPlayer(); } else if (menuStr == StrDictionary.GetClientDictionaryString("#{4354}")) { OnInviteTeam(); } else if (menuStr == StrDictionary.GetClientDictionaryString("#{4352}")) { OnJoinTeam(); } else if (menuStr == StrDictionary.GetClientDictionaryString("#{4363}")) { OnAddFriend(); } else if (menuStr == StrDictionary.GetClientDictionaryString("#{5204}")) { OnAddBlack(); } else if (menuStr == StrDictionary.GetClientDictionaryString("#{5206}")) { OnDelFriend(); } else if (menuStr == StrDictionary.GetClientDictionaryString("#{5205}")) { OnDelBlack(); } else if (menuStr == StrDictionary.GetClientDictionaryString("#{4353}")) { OnReport(); } else if (menuStr == StrDictionary.GetClientDictionaryString("#{4905}")) { OnViewRolePhoto(); } else if (menuStr == StrDictionary.GetClientDictionaryString("#{4906}")) { OnViewRelation(); } else if (menuStr == StrDictionary.GetClientDictionaryString("#{5212}")) { OnRemoveTell(); } else if (menuStr == StrDictionary.GetClientDictionaryString("#{1657}")) { OnMenuDuel(); } else if (menuStr == StrDictionary.GetClientDictionaryString("#{4943}")) { OnSendFlower(); } CloseWindow(); } void OnSendMessage() { //如果非玩家,则无效 if (GlobeVar.INVALID_GUID == _Guid) { return; } //如果目标是自己 if (GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid == _Guid) { return; } GameManager.gameManager.PlayerDataPool.ChatHistory.AddFriendChat(_Guid, _Name.text, _IconName, _LevelValue, _Guid, 0, 0, null); //未打开过则创建 FriendAndMailRoot.ShowFriendChat(_Guid, _Name.text); } void OnViewPlayer() { //如果非玩家,则无效 if (GlobeVar.INVALID_GUID == _Guid) { return; } if (null == Singleton.GetInstance().MainPlayer) { return; } //如果目标是自己也不发送 if (GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid == _Guid) { return; } Singleton.GetInstance().MainPlayer.ReqViewOtherPlayer(_Guid, OtherRoleViewLogic.OPEN_TYPE.OPEN_TYPE_POPMENU); } void OnInviteTeam() { //如果非玩家,则无效 if (GlobeVar.INVALID_GUID == _Guid) { return; } //如果目标是自己也不发送加好友 if (GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid == _Guid) { return; } if (null == Singleton.GetInstance().MainPlayer) { return; } //如果有队伍,则判断下队伍是否已满 if (GlobeVar.INVALID_ID != GameManager.gameManager.PlayerDataPool.TeamInfo.TeamID) { if (GameManager.gameManager.PlayerDataPool.TeamInfo.IsFull()) { return; } } Singleton.GetInstance().MainPlayer.ReqInviteTeam(_Guid); } void OnJoinTeam() { //如果非玩家,则则无效 if (GlobeVar.INVALID_GUID == _Guid) { return; } //如果目标是自己也不发送加好友 if (GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid == _Guid) { return; } if (null == Singleton.GetInstance().MainPlayer) { return; } /*ReqJoinTeam会检查 if (GlobeVar.INVALID_ID != GameManager.gameManager.PlayerDataPool.TeamInfo.TeamID) { return; }*/ Singleton.GetInstance().MainPlayer.ReqJoinTeam(_TeamID); } void OnAddFriend() { //如果非玩家,则不显示 if (GlobeVar.INVALID_GUID == _Guid) { return; } Singleton.Instance.MainPlayer.ReqAddFriend(_Guid); } void OnDelFriend() { MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{5211}", _PlayerName), "", OnDelFriendOK); } void OnDelFriendOK() { Singleton.Instance.MainPlayer.ReqDelFriend(_Guid); } void OnAddBlack() { MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{5219}", _PlayerName), "", OnAddBlackOk); } void OnAddBlackOk() { //如果非玩家,则无效 if (GlobeVar.INVALID_GUID == _Guid) { return; } if (null == Singleton.GetInstance().MainPlayer) { return; } //如果目标是自己也不发送 if (GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid == _Guid) { return; } Singleton.GetInstance().MainPlayer.ReqAddBlack(_Guid); } void OnDelBlack() { //如果非玩家,则无效 if (GlobeVar.INVALID_GUID == _Guid) { return; } if (null == Singleton.GetInstance().MainPlayer) { return; } //如果目标是自己也不发送 if (GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid == _Guid) { return; } Singleton.GetInstance().MainPlayer.ReqDelBlack(_Guid); } void OnComplaint() { } void OnViewRolePhoto() { if (_Guid == GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid) { CommunityLogic.ShowMyCommunityRoot(); } else { CommunityLogic.ShowPlayerCommunityRoot(_Guid, _LevelValue, _PlayerName); } } void OnSendFlower() { //var weiboTab = TableManager.GetWeiboByID(0, 0); //if (weiboTab.OpenLvl > GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level) //{ // GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{41303}")); // return; //} //if (_Guid == GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid) //{ // CommunityLogic.ShowMyCommunityRoot(); //} //else //{ // CommunityLogic.ShowPlayerCommunityRoot(_Guid, _LevelValue, _PlayerName); //} //GameManager.gameManager.StartCoroutine(ShowFlowerLater()); CommunityGiveFlowerLogic.GiveFlower(_Guid, _PlayerName); } //private static IEnumerator ShowFlowerLater() //{ // while (CommunityLogic.Instance() == null) // { // yield return new WaitForSeconds(0.5f); // } // CommunityLogic.Instance()._TagPanel.ShowPage(1); // CommunityLogic.Instance()._GiveFlowerPanel.ShowWindow(); //} void OnViewRelation() { } void OnReport() { UIManager.ShowUI(UIInfo.ChatReportPanel, delegate(bool bSucess, object param) { if(bSucess) { ChatReportPanelCtr.Instance.InitReport(_PlayerName, _Content, _Guid); } }); } void OnMenuDuel() { //如果非玩家,则无效 if (GlobeVar.INVALID_GUID == _Guid) { return; } //如果目标是自己也不发送 if (GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid == _Guid) { return; } if (null == Singleton.GetInstance().MainPlayer) { return; } Singleton.GetInstance().MainPlayer.ReqDuelOption(CG_COMPETITION_OPTION.COMPETITION_TYPE.INVITE, _Guid, 0); } void OnRemoveTell() { var chat = GameManager.gameManager.PlayerDataPool.ChatHistory.GetFriendChat(_Guid); if (chat == null) return; GameManager.gameManager.PlayerDataPool.ChatHistory.FriendChatList.Remove(chat); if (FriendAndMailRoot.Instance() != null) { FriendAndMailRoot.Instance()._FriendRootLogic.UpdateTell(); } } #region 双人坐骑相关 //骑乘邀请按钮 public Button BtnMenuItem; private int _PlayerState; public void GetMountData(GC_MOUNT_DATA packet) { _PlayerState = packet.State; Debug.LogError("_PlayerState === "+ packet.State); } /// /// 双骑邀请 /// public void OnClickInviteBtn() { //在紫禁之巅中无效 //if (GameManager.gameManager.m_RunningScene == 658) //{ // GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{79512}")); // return; //} //如果非玩家,则无效 if (GlobeVar.INVALID_GUID == _Guid) { return; } //如果目标是自己也不发送 if (GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid == _Guid) { return; } int nowMountID = GameManager.gameManager.PlayerDataPool.m_objMountParam.AdvanceMountId; Tab_AdvanceFashion m_advanceFashion = TableManager.GetAdvanceFashionByID(nowMountID, 0); if (m_advanceFashion == null) { //48211 您没有乘坐双人坐骑,无法邀请 GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{48211}")); CloseWindow(); return; } Tab_MountBase mountBases = TableManager.GetMountBaseByID(m_advanceFashion.ModelId, 0); if (mountBases ==null) { //48211 您没有乘坐双人坐骑,无法邀请 GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{48211}")); CloseWindow(); return; } if (mountBases.DoubleRiding != 1) { //48211 您没有乘坐双人坐骑,无法邀请 GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{48211}")); CloseWindow(); return; } //发送请求 CG_DOUBLEMOUNT_INVITE packet = (CG_DOUBLEMOUNT_INVITE)PacketDistributed.CreatePacket(MessageID.PACKET_CG_DOUBLEMOUNT_INVITE); packet.BeInvitedId = _Guid; packet.SendPacket(); //关闭交互界面 CloseWindow(); } #endregion }