//还未加入帮会打开时显示的界面 using Games.LogicObj; using UnityEngine; using UnityEngine.UI; using System.Collections; using GCGame; using Module.Log; using Games.GlobeDefine; using System.Collections.Generic; using System; using GCGame.Table; using Games.Events; public class NoHasGuildMainWnd : MonoBehaviour { public GameObject ApplyBtn; //申请加入一个帮会按钮 public GameObject RespondBtn; //申请响应帮会的按钮 public GameObject CancelRespondBtn; //取消响应帮会按钮 public GameObject ConnectMainBtn; //响应联系帮主 public GameObject AskEnsileBtn; //招兵买马 public UITagPanel _TagPanel; public GameObject CancleSearchBtn; public InputField m_SearchGuild; //搜索帮会输入框 //public InputField m_CreateGuildZhongzhi; //创建帮会界面的宗旨输入框 public Text GuildNotice; public InputField m_CreateGuildName; //创建帮会界面的帮会名称输入框 public Text m_CreateGuildtiaokuan; public Text m_JoinGuildZongzhi; public Text m_RespondZongzhi; public Text title; public UIContainerSelect m_JoinContainer; public UIContainerSelect m_ResponContainer; private GuildPreviewInfo m_currSelectJoinInfo; private GuildPreviewInfo m_currSelectRespondInfo; private ulong m_CurrSelectRespondId = GlobeVar.INVALID_GUID; //消耗 public Image iconPrice; public Image iconHas; public Text Price; public Text Has; void Awake() { Hashtable add = new Hashtable(); add["name"] = "InitGuildInfoContent"; Games.Events.MessageEventCallBack call = InitGuildInfoContent; add["callFun"] = call; Games.Events.EventDispatcher.Instance.AddMessageEvent(Games.Events.EventId.JoinGuildListInfo, add); if(GameManager.gameManager.PlayerDataPool.IsHaveGuild() == false) { Hashtable add1 = new Hashtable(); add1["name"] = "createGuildSucc"; Games.Events.MessageEventCallBack call1 = CreateGuildSuccess; add1["callFun"] = call1; Games.Events.EventDispatcher.Instance.AddMessageEvent(Games.Events.EventId.UpdateGuildInfo, add1); } Hashtable add2 = new Hashtable(); add2["name"] = "JoinRespond"; Games.Events.MessageEventCallBack call2 = UpdateBtns; add2["callFun"] = call2; Games.Events.EventDispatcher.Instance.AddMessageEvent(Games.Events.EventId.OperatorResult, add2); Hashtable calbackMoveparam3 = new Hashtable(); calbackMoveparam3["name"] = "NoHasGuild"; MessageEventCallBack fun3 = PayFresh; calbackMoveparam3.Add("callFun", fun3); EventDispatcher.Instance.AddMessageEvent(Games.Events.EventId.FRESHSAMEUSETIP, calbackMoveparam3); GuildNotice.text = StrDictionary.GetClientDictionaryString("#{25243}"); m_JoinGuildZongzhi.text = StrDictionary.GetClientDictionaryString("#{25243}"); } void OnDestroy() { Games.Events.EventDispatcher.Instance.RemoveMessage(Games.Events.EventId.JoinGuildListInfo, "InitGuildInfoContent"); Games.Events.EventDispatcher.Instance.RemoveMessage(Games.Events.EventId.UpdateGuildInfo, "createGuildSucc"); Games.Events.EventDispatcher.Instance.RemoveMessage(Games.Events.EventId.OperatorResult, "JoinRespond"); Games.Events.EventDispatcher.Instance.RemoveMessage(Games.Events.EventId.FRESHSAMEUSETIP, "NoHasGuild"); if (GameManager.gameManager.PlayerDataPool.guildList!=null && GameManager.gameManager.PlayerDataPool.guildList.GuildInfoList!=null) { GameManager.gameManager.PlayerDataPool.guildList.GuildInfoList.Clear(); } if(GameManager.gameManager.PlayerDataPool.guildList!=null && GameManager.gameManager.PlayerDataPool.guildList.RGuildInfoList!=null) { GameManager.gameManager.PlayerDataPool.guildList.RGuildInfoList.Clear(); } } public void PayFresh(Hashtable addparam, Hashtable sendparam) { Tab_GuildOther other = TableManager.GetGuildOtherByID(0, 0); if (other != null) { Has.text = GameManager.gameManager.PlayerDataPool.Money.GetMoneyByType((MONEYTYPE)other.CreateMoneyType).ToString(); } } void Start() { if (GameManager.gameManager.PlayerDataPool.guildList != null && GameManager.gameManager.PlayerDataPool.guildList.GuildInfoList != null) { GameManager.gameManager.PlayerDataPool.guildList.GuildInfoList.Clear(); } if (GameManager.gameManager.PlayerDataPool.guildList != null && GameManager.gameManager.PlayerDataPool.guildList.RGuildInfoList != null) { GameManager.gameManager.PlayerDataPool.guildList.RGuildInfoList.Clear(); } if(Singleton.Instance.MainPlayer!=null) { Singleton.Instance.MainPlayer.ReqGuildList(1); Singleton.Instance.MainPlayer.ReqGuildList(0); } Tab_GuildOther other = TableManager.GetGuildOtherByID(0, 0); if (other != null) { Has.text = GameManager.gameManager.PlayerDataPool.Money.GetMoneyByType((MONEYTYPE)other.CreateMoneyType).ToString(); Price.text = other.CreateNeedMoney.ToString(); LoadAssetBundle.Instance.SetImageSprite(iconPrice, UICurrencyItem.GetCurrencySprite((MONEYTYPE)other.CreateMoneyType)); LoadAssetBundle.Instance.SetImageSprite(iconHas, UICurrencyItem.GetCurrencySprite((MONEYTYPE)other.CreateMoneyType)); } SetRespondBtns(); } public void SetRespondBtns() { if (m_currSelectRespondInfo == null) return; bool hasGuild = GameManager.gameManager.PlayerDataPool.IsHaveGuild(); bool HadCreateGuild = GameManager.gameManager.PlayerDataPool.IsHadCreateGuild(); bool isGuildChief = (m_currSelectRespondInfo.GuildChiefGUID == Singleton.Instance.MainPlayer.GUID); bool HasRespond = GameManager.gameManager.PlayerDataPool.guildList.HadRespond != GlobeVar.INVALID_GUID; RespondBtn.SetActive(!(hasGuild || HasRespond || HadCreateGuild)); CancelRespondBtn.SetActive(false); if (GameManager.gameManager.PlayerDataPool.guildList.HadRespond == m_currSelectRespondInfo.GuildGuid) { CancelRespondBtn.SetActive(true); } ConnectMainBtn.SetActive(!isGuildChief); AskEnsileBtn.SetActive(isGuildChief); } public void BuyFast() { JudgeMoneyLogic.ShowSwitchMoneyPanel(MONEYTYPE.MONEYTYPE_YUANBAO, true); } public void TagShowPage(int page) { if (page == 0) { Click_OpenJoinWnd(); } else if (page == 1) { Click_OpenCreateWnd(); } else { Click_OpenRespondWnd(); } } public void OpenIndex(int index,ulong guildGuid = GlobeVar.INVALID_GUID) { if (_TagPanel == null) return; if (index == 2) m_CurrSelectRespondId = guildGuid; _TagPanel.ShowPage(index); } public void CreateGuildSuccess(Hashtable add, Hashtable send) { //m_CreateGuildZhongzhi.text = ""; m_CreateGuildName.text = ""; if (GameManager.gameManager.PlayerDataPool.IsHaveGuild()) { UIManager.CloseUI(UIInfo.GuildMainWnd); UIManager.ShowUI(UIInfo.GuildMainInfoWnd, null, null); } else { if (GameManager.gameManager.PlayerDataPool.GuildInfo!=null && GameManager.gameManager.PlayerDataPool.GuildInfo.GuildGuid!= GlobeVar.INVALID_GUID && GameManager.gameManager.PlayerDataPool.GuildInfo.GuildLevel == 0) { _TagPanel.ShowPage(2); } } } private int openIndex = 0; public void InitGuildInfoContent(Hashtable add, Hashtable send) { if (openIndex == 0) { InitGuildJoinInfoContent(); } if(openIndex==1) { return; } if(openIndex==2) { InitGuildRespondInfoContent(); } } #region 更新加入列表中的帮会信息 void InitGuildJoinInfoContent() { List selects = new List(); if(GameManager.gameManager.PlayerDataPool.guildList.GuildInfoList.Count>0) selects.Add(GameManager.gameManager.PlayerDataPool.guildList.GuildInfoList[0]); m_JoinContainer.InitSelectContent(GameManager.gameManager.PlayerDataPool.guildList.GuildInfoList, selects, GuildInfoItemClick); } private GameObject JoinSelect = null; public void GuildInfoItemClick(object initInfo) { GuildPreviewInfo info = initInfo as GuildPreviewInfo; if (info == null) { LogModule.DebugLog("GuildPreviewInfo is null"); return; } ApplyBtn.SetActive(info.IsEnemyGuild == false); //m_JoinGuildZongzhi.text = info.GuildNotice; m_currSelectJoinInfo = info; } #endregion #region 更新响应列表中的帮会信息 void InitGuildRespondInfoContent() { GuildPreviewInfo Selecte = null; GuildPreviewInfo self = null; List showList = new List(); for (int i = 0; i < GameManager.gameManager.PlayerDataPool.guildList.RGuildInfoList.Count; i++) { GuildPreviewInfo guildInfo = GameManager.gameManager.PlayerDataPool.guildList.RGuildInfoList[i]; if (guildInfo == null) continue; if (guildInfo.RespondOverTime - Time.realtimeSinceStartup <= 0) continue; if(m_CurrSelectRespondId!=GlobeVar.INVALID_GUID && guildInfo.GuildGuid == m_CurrSelectRespondId) { Selecte = guildInfo; } if (GameManager.gameManager.PlayerDataPool.GuildInfo != null && GameManager.gameManager.PlayerDataPool.GuildInfo.GuildGuid == guildInfo.GuildGuid) { self = guildInfo; } else showList.Add(guildInfo); } if (showList.Count <= 0 && self == null) return; List selects = new List(); if (self != null) showList.Insert(0, self); if (Selecte != null) selects.Add(Selecte); else { if (self != null) selects.Add(self); else selects.Add(showList[0]); } m_ResponContainer.InitSelectContent(showList, selects, GuildResInfoItemClick); } public void GuildResInfoItemClick(object initInfo) { GuildPreviewInfo info = initInfo as GuildPreviewInfo; if (info == null) { //LogModule.DebugLog("GuildPreviewInfo is null"); return; } m_RespondZongzhi.text = info.GuildNotice; m_currSelectRespondInfo = info; SetRespondBtns(); } #endregion public void UpdateBtns(Hashtable addParam,Hashtable sendParam) { if(openIndex==0) { if (m_currSelectJoinInfo == null) return; ApplyBtn.SetActive(m_currSelectJoinInfo.IsEnemyGuild == false); } if(openIndex == 2) { if (m_currSelectRespondInfo == null) return; SetRespondBtns(); m_ResponContainer.RefreshItems(); } } public void CancleSearch() { CancleSearchBtn.SetActive(false); InitGuildJoinInfoContent(); } public void OnInputFieldChange() { if(string.IsNullOrEmpty(m_SearchGuild.text)) { CancleSearchBtn.SetActive(true); return; } CancleSearchBtn.SetActive(false); } public void SearchGuild() { if (GameManager.gameManager.m_RunningScene == 658) { GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{79512}")); return; } if (string.IsNullOrEmpty(m_SearchGuild.text)) { GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{6710}")); return; } List searchs = new List(); for(int i=0;i< GameManager.gameManager.PlayerDataPool.guildList.GuildInfoList.Count;i++) { if(GameManager.gameManager.PlayerDataPool.guildList.GuildInfoList[i].GuildName.Contains(m_SearchGuild.text)) { searchs.Add(GameManager.gameManager.PlayerDataPool.guildList.GuildInfoList[i]); } } if(searchs.Count<=0) { GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{6710}")); return; } CancleSearchBtn.SetActive(true); List selects = new List(); selects.Add(searchs[0]); m_JoinContainer.InitSelectContent(searchs, selects, GuildInfoItemClick); } private float AskEnsileTimeLimit = 0; public void Click_AskEnsile() { if (GameManager.gameManager.m_RunningScene == 658) { GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{79512}")); return; } if (!ChatInputLogic.IsCanChat((int)CG_CHAT.CHATTYPE.CHAT_TYPE_WORLD,true,false)) return; if(Time.realtimeSinceStartup - AskEnsileTimeLimit <300) { GUIData.AddNotifyData("#{25212}"); return; } AskEnsileTimeLimit = Time.realtimeSinceStartup; Games.ChatHistory.ChatHistoryItem item = new Games.ChatHistory.ChatHistoryItem(); item.CleanUp(); item.EChannel = (GC_CHAT.CHATTYPE)((int)CG_CHAT.CHATTYPE.CHAT_TYPE_WORLD); string sendStr = StrDictionary.GetClientDictionaryString("#{3077}",GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.RoleName,GameManager.gameManager.PlayerDataPool.GuildInfo.GuildName,GameManager.gameManager.PlayerDataPool.GuildInfo.GuildGuid); item.ChatInfo = sendStr; Utils.SendCGChatPak(item.ChatInfo, item); } public void Click_OpenJoinWnd() { if (openIndex == 0) return; openIndex = 0; title.text = StrDictionary.GetClientDictionaryString("#{25001}"); Singleton.Instance.MainPlayer.ReqGuildList(0); //InitGuildJoinInfoContent(); } public void Click_OpenCreateWnd() { if (openIndex == 1) return; openIndex = 1; title.text = StrDictionary.GetClientDictionaryString("#{25002}"); } public void Click_OpenRespondWnd() { if (openIndex == 2) return; openIndex = 2; title.text = StrDictionary.GetClientDictionaryString("#{25003}"); //InitGuildRespondInfoContent(); Singleton.Instance.MainPlayer.ReqGuildList(1); } public void Click_OneKeyAskBtn() { if (GameManager.gameManager.m_RunningScene == 658) { GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{79512}")); return; } Obj_MainPlayer mainPlayer = Singleton.GetInstance().MainPlayer; if (mainPlayer == null) return; mainPlayer.ReqJoinGuild(GlobeVar.INVALID_GUID); } public void Click_AskJoinBtn() { if (GameManager.gameManager.m_RunningScene == 658) { GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{79512}")); return; } if(m_currSelectJoinInfo==null) { GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{25012}")); return; } if(m_currSelectJoinInfo.GuildCurMemberNum == m_currSelectJoinInfo.GuildMaxMemberNum) { GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{25013}")); return; } Obj_MainPlayer mainPlayer = Singleton.GetInstance().MainPlayer; if (mainPlayer == null) return; if (m_currSelectJoinInfo == null) return; mainPlayer.ReqJoinGuild(m_currSelectJoinInfo.GuildGuid); } public void Click_ConnectManagerBtn() { if (GameManager.gameManager.m_RunningScene == 658) { GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{79512}")); return; } if (m_currSelectJoinInfo == null) { GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{25206}")); return; } ConnectGuildMan(m_currSelectJoinInfo.GuildChiefGUID, m_currSelectJoinInfo.GuildChiefName); } public void ConnectGuildMan(ulong guildGuid,string name) { //如果非玩家,则无效 if (GlobeVar.INVALID_GUID == guildGuid) { return; } //如果目标是自己 if (GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid == guildGuid) { return; } //未打开过则创建 FriendAndMailRoot.ShowFriendChat(guildGuid, name); } public void Click_CreateGuildBtn() { if (GameManager.gameManager.m_RunningScene == 658) { GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{79512}")); return; } if (GameManager.gameManager.PlayerDataPool.IsHaveGuild()) { if (GameManager.gameManager.PlayerDataPool.GuildInfo.GuildChiefGuid == Singleton.Instance.MainPlayer.GUID) GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{25000}")); else GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{24999}")); return; } if(GameManager.gameManager.PlayerDataPool.GuildInfo.GuildGuid != GlobeVar.INVALID_GUID) { GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{25209}")); return; } int price = 100000; Tab_GuildOther other = TableManager.GetGuildOtherByID(0, 0); if (other != null) { price = other.CreateNeedMoney; } if (JudgeMoneyLogic.IsMoneyEnough(MONEYTYPE.MONEYTYPE_YUANBAO, price)) { MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{25023}", price, m_CreateGuildName.text), "", OnCreateGuild, null); } } void OnCreateGuild() { if (null == Singleton.GetInstance().MainPlayer) { return; } //判断帮会名称控件是否存在 if (null == m_CreateGuildName) { return; } Obj_MainPlayer mainPlayer = Singleton.GetInstance().MainPlayer; if (null == mainPlayer) { return; } //判断帮会名称是否合法 string szGuildName = m_CreateGuildName.text; //过短 if (szGuildName.Length <= 0) { mainPlayer.SendNoticMsg(false, "#{1761}"); //请输入帮会名称 return; } //玩家等级判断 if (mainPlayer.CreateLevelisOK(mainPlayer.BaseAttr.Level) == false) { mainPlayer.SendNoticMsg(false, "#{1771}"); //你的人物等级不足30级,无法创建帮会 return; } //有帮会无法申请 if (GameManager.gameManager.PlayerDataPool.GuildInfo.GuildGuid != GlobeVar.INVALID_GUID) { mainPlayer.SendNoticMsg(false, "#{1772}"); //你已属于一个帮会,不能创建帮会 return; } if (null != Utils.GetStrFilter(szGuildName, (int)GameDefine_Globe.STRFILTER_TYPE.STRFILTER_NAME)) { mainPlayer.SendNoticMsg(false, "#{1278}"); // 包含非法字符 return; } mainPlayer.ReqCreateGuild(szGuildName, "1"); } public void Click_RespondGuildBtn() { if (GameManager.gameManager.m_RunningScene == 658) { GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{79512}")); return; } if (m_currSelectRespondInfo == null) { GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{25015}")); return; } Obj_MainPlayer mainPlayer = Singleton.GetInstance().MainPlayer; if (mainPlayer == null) return; if (m_currSelectRespondInfo == null) return; mainPlayer.ReqRespondGuild(m_currSelectRespondInfo.GuildGuid, GCGame.Utils.GetTimeStr( (int)(m_currSelectRespondInfo.RespondOverTime - Time.realtimeSinceStartup)),m_currSelectRespondInfo.GuildName); } public void Click_ConnectGuildManBtn() { if (GameManager.gameManager.m_RunningScene == 658) { GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{79512}")); return; } if (m_currSelectRespondInfo == null) { GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{25203}")); return; } ConnectGuildMan(m_currSelectRespondInfo.GuildChiefGUID, m_currSelectRespondInfo.GuildChiefName); } public void Click_CancelRespondBtn() { if (GameManager.gameManager.m_RunningScene == 658) { GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{79512}")); return; } Obj_MainPlayer mainPlayer = Singleton.GetInstance().MainPlayer; if (mainPlayer == null) return; if (m_currSelectRespondInfo == null) return; mainPlayer.ReqRespondGuild(m_currSelectRespondInfo.GuildGuid,"",m_currSelectRespondInfo.GuildName,true); //响应的也发加入的协议,服务器自己会根据帮会等级处理 } public void Click_Close() { UIManager.CloseUI(UIInfo.GuildMainWnd); } }