using UnityEngine; using UnityEngine.UI; using System.Collections; using Games.Item; using System.Collections.Generic; using GCGame.Table; using Games.GlobeDefine; using GCGame; using Module.Log; public class CommunityPlayerInfo { public ulong GUID; public string Name; public string ImageUrl; public int Profession; public int Level; public string Title; public string Locate; public string Guild; public string Desc; } public class CommunityLogic : UIControllerBase { #region public static void ShowMyCommunityRoot() { var weiboTab = TableManager.GetWeiboByID(0, 0); if (weiboTab.OpenLvl > GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level) { GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{41303}")); return; } Hashtable hash = new Hashtable(); CommunityPlayerInfo playerInfo = new CommunityPlayerInfo(); playerInfo.GUID = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid; playerInfo.Name = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.RoleName; playerInfo.Profession = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Profession; playerInfo.Level = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level; playerInfo.Title = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.TitlenName; playerInfo.ImageUrl = Community.Instance.HeadPicDownUrl; playerInfo.Desc = ""; hash.Add("CommunityPlayerInfo", playerInfo); CommunityLogic.CommunityPlayerInfo = playerInfo; UIManager.ShowUI(UIInfo.CommunityRoot, ShowCommunityOver, hash); } public static void ShowPlayerCommunityRoot(ulong guid, int level, string name) { var weiboTab = TableManager.GetWeiboByID(0, 0); if (weiboTab.OpenLvl > GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level) { GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{41303}")); return; } Hashtable hash = new Hashtable(); CommunityPlayerInfo playerInfo = new CommunityPlayerInfo(); playerInfo.GUID = guid; playerInfo.Name = name; CommunityLogic.CommunityPlayerInfo = playerInfo; hash.Add("CommunityPlayerInfo", playerInfo); if (CommunityLogic.Instance()) { CommunityLogic.Instance().InitTag(); CommunityLogic.Instance()._DefaultFirstPage.InitPage(); } UIManager.ShowUI(UIInfo.CommunityRoot, ShowCommunityOver, hash); } private static void ShowCommunityOver(bool isSucced, object param) { if (!isSucced) return; Hashtable hash = param as Hashtable; if (hash == null) return; CommunityPlayerInfo communityPlayerInfo = (CommunityPlayerInfo)hash["CommunityPlayerInfo"]; CommunityLogic.Instance().Show(communityPlayerInfo); } #endregion void OnEnable () { SetInstance(this); InitTag(); InitTips(); } void OnDisable() { SetInstance(null); } public void CloseWindow() { UIManager.CloseUI(UIInfo.CommunityRoot); } public UITagPanel _TagPanel; public GameObject _HotPageGO; public void InitTag() { _TagPanel.ShowPage(0); } public void OnTagShowPage(int page) { CommunityLogic.Instance()._EmptyTip.text = ""; if (page == 1) { Community.Instance.ResetLeaveWordTip(); } } #region playerInfo public static int _DescLength = 80; public NetImage _Icon; public Image _ProIcon; public Text _Name; public Text _Level; public Text _Title; public Text _Locate; public Button _LocateInput; public Text _Guild; public InputField _Desc; public Text _EmptyTip; public CommunityBlogPageLogic _DefaultFirstPage; public static CommunityPlayerInfo CommunityPlayerInfo; public bool IsShowingMyBlog() { if (CommunityPlayerInfo == null) return false; return CommunityPlayerInfo.GUID == GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid; } public void ShowMyBlog() { ShowMyCommunityRoot(); InitTag(); _DefaultFirstPage.InitPage(); } public void Show(CommunityPlayerInfo communityPlayerInfo) { CommunityPlayerInfo = communityPlayerInfo; //SetBaseInfo(); ReqBaseInfo(); } public void ReqBaseInfo() { CG_REQ_MENGDAO_INFO packet = (CG_REQ_MENGDAO_INFO)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_MENGDAO_INFO); packet.Roleguid = CommunityPlayerInfo.GUID; packet.SendPacket(); Debug.Log("ReqBaseInfo:" + packet.Roleguid); } public void SetBaseInfo(GC_RET_MENGDAO_INFO packet) { if (!string.IsNullOrEmpty(packet.Headpic)) { _Icon.SetNetImage(Community.Instance.GetHeadIconDownUrl(packet.Headpic), CommunityPlayerInfo.GUID); } else { _Icon.NetImageUrl = ""; _Icon.ClearNetImage(); LoadAssetBundle.Instance.SetImageSprite(_Icon._Image, Utils.GetProfessionSpriteName(packet.Job)); } Debug.Log("SetBaseInfo:" + packet.Roleguid); Debug.Log("SetBaseInfo:" + packet.Name); Debug.Log("SetBaseInfo:" + packet.Headpic); LoadAssetBundle.Instance.SetImageSprite(_ProIcon, GCGame.Utils.GetProfessionIconName((CharacterDefine.PROFESSION)packet.Job)); _Name.text = packet.Name; _Level.text = "Lv." + packet.Level; //Tab_TitleData titleData = TableManager.GetTitleDataByID(packet.Titleid, 0); //if (titleData != null) { _Title.GetComponent().SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, 170); _Title.text = packet.Titlename; } if (string.IsNullOrEmpty(packet.Localpos)) { _Locate.text = StrDictionary.GetClientDictionaryString("#{39021}"); } else { _Locate.text = packet.Localpos; } if (string.IsNullOrEmpty(packet.Guildname)) { _Guild.text = StrDictionary.GetClientDictionaryString("#{1793}"); } else { _Guild.text = packet.Guildname; } _Desc.text = packet.Mood; if (CommunityPlayerInfo.GUID == GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid) { _LocateInput.gameObject.SetActive(true); _HotPageGO.gameObject.SetActive(true); _Desc.interactable = true; } else { _LocateInput.gameObject.SetActive(false); _HotPageGO.gameObject.SetActive(false); _Desc.interactable = false; } } public void SetBaseInfo() { if (!string.IsNullOrEmpty(CommunityPlayerInfo.ImageUrl)) { _Icon.SetNetImage(Community.Instance.GetHeadIconDownUrl(CommunityPlayerInfo.ImageUrl), CommunityPlayerInfo.GUID); } else { _Icon._ImageChecking.gameObject.SetActive(false); LoadAssetBundle.Instance.SetImageSprite(_ProIcon, GCGame.Utils.GetProfessionSpriteName(CommunityPlayerInfo.Profession)); } _Name.text = CommunityPlayerInfo.Name; _Level.text = "Lv." + CommunityPlayerInfo.Level.ToString(); _Title.text = CommunityPlayerInfo.Title; if (string.IsNullOrEmpty(CommunityPlayerInfo.Locate)) { _Locate.text = StrDictionary.GetClientDictionaryString("#{39021}"); } else { _Locate.text = CommunityPlayerInfo.Locate; } _Guild.text = CommunityPlayerInfo.Guild; _Desc.text = CommunityPlayerInfo.Desc; _Locate.text = CommunityPlayerInfo.Locate; if (CommunityPlayerInfo.GUID == GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid) { _LocateInput.gameObject.SetActive(true); _HotPageGO.gameObject.SetActive(true); _Desc.interactable = true; } else { _LocateInput.gameObject.SetActive(false); _HotPageGO.gameObject.SetActive(false); _Desc.interactable = false; } } public void BtnLocateInput() { if (!IsShowingMyBlog()) return; _LocateInputPanel.gameObject.SetActive(true); } public void SetLocate(string input) { //_Locate.text = input; CG_REQ_SAVE_MENGDAO_STATE packet = (CG_REQ_SAVE_MENGDAO_STATE)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_SAVE_MENGDAO_STATE); packet.Mood = _Desc.text; packet.Localpos = input; packet.SendPacket(); } public void DescInput(string inputDesc) { if (!IsShowingMyBlog()) return; string desc = inputDesc; if (desc.Length > _DescLength) { desc = desc.Substring(0, _DescLength); } //_Desc.text = desc; CG_REQ_SAVE_MENGDAO_STATE packet = (CG_REQ_SAVE_MENGDAO_STATE)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_SAVE_MENGDAO_STATE); packet.Mood = desc; packet.Localpos = _Locate.text; packet.SendPacket(); } public void UpdateBaseInfo(GC_RET_SAVE_MENGDAO_STATE packet) { _Desc.text = packet.Mood; _Locate.text = packet.Localpos; } #endregion #region public CommunityWriteMsgLogic _WriteMsgPanel; public CommunitySettingLogic _SettingPanel; public CommunityPresentLogic _PresentPanel; public CommunityFwordingLogic _FwordingPanel; public CommunityBlogItem _BlogDetail; public CommunityGiveFlowerLogic _GiveFlowerPanel; public CommunityLocateInputLogic _LocateInputPanel; public GameObject _BlogDetailGO; public CommunityBlogInfo _BlogDetailInfo; public CommunityLargeImages _ShowLargeImages; public void ShowFwording(CommunityBlogInfo blogGuid, NetImage texture) { _FwordingPanel.ShowFwordingWin(blogGuid, texture); } public void ShowBlogDetail(CommunityBlogInfo blogInfo) { _BlogDetailGO.SetActive(true); _TagPanel.gameObject.SetActive(false); _BlogDetailInfo = blogInfo; ReqBlogDetail(_BlogDetailInfo); //test //Hashtable hash = new Hashtable(); //hash.Add("IsShowPlayerInfo", true); //hash.Add("IsFixedCommentHeight", true); //hash.Add("IsShowDeleteBtn", false); //hash.Add("InitObj", blogInfo); //_BlogDetail.Show(hash); //_BlogDetail.LoadMoreComment(); } private void ReqBlogDetail(CommunityBlogInfo blogInfo) { CG_REQ_VIEW_BLOG_INFO packet = (CG_REQ_VIEW_BLOG_INFO)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_VIEW_BLOG_INFO); packet.Blogguid = blogInfo.GUID; packet.SendPacket(); } public void RetBlogDetail(GC_RET_VIEW_BLOG_INFO packet) { _BlogDetailInfo.GUID = packet.Blogguid; _BlogDetailInfo.Contex = packet.Context; _BlogDetailInfo.HeadIconUrl = packet.Headpic; _BlogDetailInfo.Profession = packet.Job; _BlogDetailInfo.Level = packet.Rolelevel; _BlogDetailInfo.Name = packet.Rolename; _BlogDetailInfo.ForwardingCnt = packet.Reprinttimes; _BlogDetailInfo.LikeCnt = packet.Liketimes; _BlogDetailInfo.CommentCnt = packet.Commenttimes; _BlogDetailInfo.LikeRoles = new List(); for (int j = 0; j < packet.Likedroles.infolistCount; ++j) { _BlogDetailInfo.LikeRoles.Add(packet.Likedroles.GetInfolist(j)); } _BlogDetailInfo.Comments = new List(); for (int j = 0; j < packet.Commentlist.commentlistCount; ++j) { _BlogDetailInfo.Comments.Add(packet.Commentlist.GetCommentlist(j)); } _BlogDetailInfo.Time = packet.Recordtime; _BlogDetailInfo.ForwardingBlog = null; if (GlobeVar.IsGUIDValid(packet.Reprintroleguid)) { _BlogDetailInfo.ForwardingBlog = new CommunityBlogInfo(); _BlogDetailInfo.ForwardingBlog.RoleGuid = packet.Reprintroleguid; _BlogDetailInfo.ForwardingBlog.Name = packet.Reprintrolename; _BlogDetailInfo.ForwardingBlog.HeadIconUrl = packet.Reprintroleheadpic; _BlogDetailInfo.Contex = packet.Reprintcomment; _BlogDetailInfo.ForwardingBlog.Contex = packet.Context; _BlogDetailInfo.ForwardingBlog.Profession = packet.Reprintrolejob; _BlogDetailInfo.ForwardingBlog.Level = packet.Reprintrolelevel; _BlogDetailInfo.ForwardingBlog.ContexImageUrls = new List(); for (int j = 0; j < packet.picnamelistList.Count; ++j) { _BlogDetailInfo.ForwardingBlog.ContexImageUrls.Add(packet.GetPicnamelist(j)); } } else { _BlogDetailInfo.ContexImageUrls = new List(); for (int j = 0; j < packet.picnamelistList.Count; ++j) { _BlogDetailInfo.ContexImageUrls.Add(packet.GetPicnamelist(j)); } } Hashtable hash = new Hashtable(); hash.Add("IsShowPlayerInfo", true); hash.Add("IsFixedCommentHeight", true); hash.Add("IsShowDeleteBtn", false); hash.Add("InitObj", _BlogDetailInfo); _BlogDetail.Show(hash); } public void HideBlogDetail() { _BlogDetailGO.SetActive(false); _TagPanel.gameObject.SetActive(true); } public void ShowLargeImages(NetDoubleImage[] images, int selectedIdx) { if (images[selectedIdx]._ImageChecking.IsActive()) return; _ShowLargeImages.gameObject.SetActive(true); _ShowLargeImages.ShowLargeImages(images, selectedIdx); } #endregion #region self photo public ImageSelectPanel _ImageTool; //public RawImage _TestRawImage; public void OnBtnPhoto() { if (!IsShowingMyBlog()) return; _ImageTool.SetImageCallBack(CuttedImg, StrDictionary.GetClientDictionaryString("#{39027}")); } private void CuttedImg(Texture2D cuttedImg) { _Icon.SetNetImage(cuttedImg, IMAGE_CHECK_STATE.PASS); _Icon.UploadImage(UploadSucess, UploadFail); } private void UploadSucess(List uploadFileName) { CG_REQ_SAVE_HEAD_PIC_FILE_NAME packet = (CG_REQ_SAVE_HEAD_PIC_FILE_NAME)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_SAVE_HEAD_PIC_FILE_NAME); packet.Headpicname = uploadFileName[0]; packet.SendPacket(); LogModule.DebugLog("UploadSucess"); } private void UploadFail(List uploadFileName) { LogModule.DebugLog("UploadFail"); } //private IEnumerator FileUpload(Texture2D uploadImg) //{ // byte[] bytes = uploadImg.EncodeToPNG(); // WWWForm form = new WWWForm(); // form.AddBinaryData("FileUpLoad", bytes, "201708151918.png", "image/png"); // // Upload to a cgi script // WWW w = new WWW(_ImageUpLoadUrl, form); // yield return w; // if (!string.IsNullOrEmpty(w.error)) // { // print(w.error); // } // else // { // print("Finished Uploading Screenshot"); // } //} //private void InitTestDownImage() //{ // StartCoroutine(GetWWWImage()); //} //private IEnumerator GetWWWImage() //{ // WWW w = new WWW(_ImageDownUrl); // yield return w; // if (!string.IsNullOrEmpty(w.error)) // { // print(w.error); // } // else // { // _TestDownImage.texture = w.texture; // } //} #endregion #region tips public GameObject _LeaveWordTips; public GameObject _NewMsgTips; public void InitTips() { Community.Instance.SetTips(); } #endregion }