//帮会历程界面 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; public class GuildBuildWnd : MonoBehaviour { public GameObject welfareObj; public GameObject xiulianObj; public GameObject upLevelNeedObj; public GameObject upLevelTimeObj; public GameObject buildNeedObj; public GameObject buildTimeObj; public Button buildBtn; public Button buildBtn1; public GameObject levelUpBtn; public GameObject IconGuild; public GameObject IconLibrary; public GameObject IconCoin; public GameObject IconHouse; public Text welfare; //福利 public Text xiulian; //修炼 public Text upLevelNeed; //升级需求 public TimeDownText upLevelTime; //升级时间 public Text upLevelCost; //升级消耗 public Text buildNeed; //建设需求 public TimeDownText buildTime; //建设时间 public Text shuoming; //说明 public Text title; //标题 public Text needMoney; public Slider needMoneySlider; private Guild.BuildType openIndex = Guild.BuildType.None; Dictionary m_strDictionTitles = new Dictionary() { {Guild.BuildType.guildInfo,"#{25073}" }, {Guild.BuildType.house,"#{25074}" }, {Guild.BuildType.coin,"#{25075}" }, {Guild.BuildType.library,"#{25076}" }, }; void Awake() { Hashtable add = new Hashtable(); add["name"] = "buildInfo"; Games.Events.MessageEventCallBack call = BuildInfo; add["callFun"] = call; Games.Events.EventDispatcher.Instance.AddMessageEvent(Games.Events.EventId.BuildInfo, add); openIndex = Guild.BuildType.guildInfo; } void OnDestroy() { Games.Events.EventDispatcher.Instance.RemoveMessage(Games.Events.EventId.BuildInfo, "buildInfo"); } public void BuildInfo(Hashtable add, Hashtable send) { InitBuildInfo(IsLevelOnMax(openIndex)); } public void AskBuildInfo(Hashtable table = null) { CG_GUILD_REQ_INFO send = (CG_GUILD_REQ_INFO)PacketDistributed.CreatePacket(MessageID.PACKET_CG_GUILD_REQ_INFO); send.SetReqType((int)CG_GUILD_REQ_INFO.REQ_TYPE.REQ_TYPE_BUILDING); send.SendPacket(); } public void SetTextActive(int state,bool levelOnMax) { welfareObj.SetActive((state & 1) == 1); xiulianObj.SetActive((state & 2) == 2); upLevelNeedObj.SetActive((state & 4) == 4); upLevelTimeObj.SetActive((state & 8) == 8); buildNeedObj.SetActive((state & 16) == 16); buildTimeObj.SetActive((state & 32) == 32); levelUpBtn.SetActive(((state & 64) == 64)); buildBtn1.gameObject.SetActive(((state & 128) == 128)); buildBtn.gameObject.SetActive((state & 256) == 256); IconGuild.SetActive(openIndex == Guild.BuildType.guildInfo); IconLibrary.SetActive(openIndex == Guild.BuildType.library); IconCoin.SetActive(openIndex == Guild.BuildType.coin); IconHouse.SetActive(openIndex == Guild.BuildType.house); } private void SetTextInfoOnLevelMax() { upLevelNeed.text = StrDictionary.GetClientDictionaryString("#{25125}"); buildNeed.text = StrDictionary.GetClientDictionaryString("#{25125}"); upLevelCost.text = StrDictionary.GetClientDictionaryString("#{25125}"); needMoney.text = StrDictionary.GetClientDictionaryString("#{25125}"); needMoney.text = StrDictionary.GetClientDictionaryString("#{25125}"); needMoneySlider.value = 1; upLevelTime.Init (StrDictionary.GetClientDictionaryString ("#{25125}")); buildTime.Init (StrDictionary.GetClientDictionaryString ("#{25125}")); } string isEnough = ""; bool IsGuildMoneyEnough = true; private void SetTextInfo(Guild.BuildType type, bool levelOnMax) { int index = GameManager.gameManager.PlayerDataPool.GuildInfo.GetBuildLevel(type); if (index == -1) return; Tab_GuildBuilding buildInfo = TableManager.GetGuildBuildingByID((int)type, index); if (buildInfo == null) return; welfare.text = buildInfo.Describe; xiulian.text = buildInfo.Describe; if(levelOnMax) { SetTextInfoOnLevelMax(); return; } isEnough = ""; IsGuildMoneyEnough = true; if (GameManager.gameManager.PlayerDataPool.GuildInfo.GuildLevel < buildInfo.NeedGuildLevel) { buildNeed.text = GCGame.Table.StrDictionary.GetClientDictionaryString("#{25077}", "", buildInfo.NeedGuildLevel); isEnough = GCGame.Table.StrDictionary.GetClientDictionaryString("#{25244}", buildInfo.NeedGuildLevel); } else { buildNeed.text = GCGame.Table.StrDictionary.GetClientDictionaryString("#{25077}", "", buildInfo.NeedGuildLevel); } if (GameManager.gameManager.PlayerDataPool.GuildInfo.GuildMoney < buildInfo.ConsumeWealth) { isEnough = GCGame.Table.StrDictionary.GetClientDictionaryString("#{25214}"); IsGuildMoneyEnough = false; upLevelCost.text = GCGame.Table.StrDictionary.GetClientDictionaryString("#{25079}", "", buildInfo.ConsumeWealth); } else upLevelCost.text = GCGame.Table.StrDictionary.GetClientDictionaryString("#{25079}", "", buildInfo.ConsumeWealth); needMoney.text = string.Format("{0}/{1}", GameManager.gameManager.PlayerDataPool.GuildInfo.GuildMoney, buildInfo.NeedWealth); needMoneySlider.value = GameManager.gameManager.PlayerDataPool.GuildInfo.GuildMoney * 1.0f / buildInfo.NeedWealth; if(GameManager.gameManager.PlayerDataPool.GuildInfo.GuildMoney < buildInfo.NeedWealth) IsGuildMoneyEnough = false; int needTime = GameManager.gameManager.PlayerDataPool.GuildInfo.GetBuildCoolDown(type); upLevelTime.Init(""); if (needTime == 0 || needTime - Time.realtimeSinceStartup <= 0) { buildTime.Init (GCGame.Table.StrDictionary.GetClientDictionaryString("#{25078}", GCGame.Utils.GetTimeStr(buildInfo.NeedTime))); } else { buildTime.Init("", needTime, needTime - Time.realtimeSinceStartup, 25085, AskBuildInfo,EventDown:2); } } private void SetGuildInfoTextInfo(bool levelOnMax) { Tab_GuildLevelUp buildInfo = TableManager.GetGuildLevelUpByID(GameManager.gameManager.PlayerDataPool.GuildInfo.GuildLevel,0); if (buildInfo == null) return; welfare.text = buildInfo.Describe; if (levelOnMax) { SetTextInfoOnLevelMax(); return; } int canBuild = 0; if (GameManager.gameManager.PlayerDataPool.GuildInfo.GetBuildLevel(Guild.BuildType.library) >= buildInfo.NeedTwoBuild) canBuild++; if (GameManager.gameManager.PlayerDataPool.GuildInfo.GetBuildLevel(Guild.BuildType.coin) >= buildInfo.NeedTwoBuild) canBuild++; if (GameManager.gameManager.PlayerDataPool.GuildInfo.GetBuildLevel(Guild.BuildType.house) >= buildInfo.NeedTwoBuild) canBuild++; isEnough = ""; IsGuildMoneyEnough = true; if (canBuild>=2) { upLevelNeed.text = GCGame.Table.StrDictionary.GetClientDictionaryString("#{25080}", "", buildInfo.NeedTwoBuild); } else { upLevelNeed.text = GCGame.Table.StrDictionary.GetClientDictionaryString("#{25080}", "", buildInfo.NeedTwoBuild); isEnough = GCGame.Table.StrDictionary.GetClientDictionaryString("#{25245}", buildInfo.NeedTwoBuild); } if (GameManager.gameManager.PlayerDataPool.GuildInfo.GuildMoney < buildInfo.ConsumeWealth) { isEnough = GCGame.Table.StrDictionary.GetClientDictionaryString("#{25214}"); IsGuildMoneyEnough = false; upLevelCost.text = GCGame.Table.StrDictionary.GetClientDictionaryString("#{25079}", "", buildInfo.ConsumeWealth); } else upLevelCost.text = GCGame.Table.StrDictionary.GetClientDictionaryString("#{25079}", "", buildInfo.ConsumeWealth); needMoney.text = string.Format("{0}/{1}", GameManager.gameManager.PlayerDataPool.GuildInfo.GuildMoney, buildInfo.NeedWealth); needMoneySlider.value = GameManager.gameManager.PlayerDataPool.GuildInfo.GuildMoney * 1.0f / buildInfo.NeedWealth; if(GameManager.gameManager.PlayerDataPool.GuildInfo.GuildMoney < buildInfo.NeedWealth) IsGuildMoneyEnough = false; buildTime.Init(""); if (GameManager.gameManager.PlayerDataPool.GuildInfo.GuildLevelCoolDown <= Time.realtimeSinceStartup) { upLevelTime.Init(GCGame.Table.StrDictionary.GetClientDictionaryString("#{25078}", GCGame.Utils.GetTimeStr(buildInfo.NeedTime))); } else { upLevelTime.Init("", GameManager.gameManager.PlayerDataPool.GuildInfo.GuildLevelCoolDown, GameManager.gameManager.PlayerDataPool.GuildInfo.GuildLevelCoolDown - Time.realtimeSinceStartup, 25085, AskBuildInfo,EventDown: 2); } } public void OpenGuild(bool isOn) { if (!isOn) return; openIndex = Guild.BuildType.guildInfo; InitBuildInfo(IsLevelOnMax(openIndex)); AskBuildInfo(); } public void OpenLibrary(bool isOn) { if (!isOn) return; openIndex = Guild.BuildType.library; //InitBuildInfo(IsLevelOnMax(openIndex)); AskBuildInfo(); } public void OpenCoin(bool isOn) { if (!isOn) return; openIndex = Guild.BuildType.coin; //InitBuildInfo(IsLevelOnMax(openIndex)); AskBuildInfo(); } public void OpenHouse(bool isOn) { if (!isOn) return; openIndex = Guild.BuildType.house; //InitBuildInfo(IsLevelOnMax(openIndex)); AskBuildInfo(); } bool IsLevelOnMax(Guild.BuildType type) { if(type == Guild.BuildType.guildInfo) return (GameManager.gameManager.PlayerDataPool.GuildInfo.GuildLevel + 1 >= TableManager.GetGuildLevelUp().Count); int buildlevel = GameManager.gameManager.PlayerDataPool.GuildInfo.GetBuildLevel(openIndex); List buildInfos = TableManager.GetGuildBuildingByID((int)type); return buildlevel >= buildInfos.Count - 1; } public void InitBuildInfo(bool levelMax) { title.text = ""; int level = 0; if (openIndex == Guild.BuildType.guildInfo) { shuoming.text = GCGame.Table.StrDictionary.GetClientDictionaryString("#{25069}"); SetTextActive(77, levelMax); } if (openIndex == Guild.BuildType.library) { shuoming.text = GCGame.Table.StrDictionary.GetClientDictionaryString("#{25072}"); SetTextActive(305, levelMax); } if (openIndex == Guild.BuildType.coin) { shuoming.text = GCGame.Table.StrDictionary.GetClientDictionaryString("#{25071}"); SetTextActive(305, levelMax); } if (openIndex == Guild.BuildType.house) { shuoming.text = GCGame.Table.StrDictionary.GetClientDictionaryString("#{25070}"); SetTextActive(305, levelMax); } if (GameManager.gameManager.PlayerDataPool.IsHaveGuild()) level = GameManager.gameManager.PlayerDataPool.GuildInfo.GetBuildLevel(openIndex); if (level == -1) level = 0; Tab_GuildLevelUp buildInfo = TableManager.GetGuildLevelUpByID(GameManager.gameManager.PlayerDataPool.GuildInfo.GuildLevel, 0); if (buildInfo != null && m_strDictionTitles.ContainsKey(openIndex)) { if (openIndex == Guild.BuildType.guildInfo) { title.text = GCGame.Table.StrDictionary.GetClientDictionaryString(m_strDictionTitles[openIndex], GameManager.gameManager.PlayerDataPool.GuildInfo.GuildLevel); SetGuildInfoTextInfo(levelMax); } else { title.text = GCGame.Table.StrDictionary.GetClientDictionaryString(m_strDictionTitles[openIndex], string.Format("{0}/{1}", level, buildInfo.GetBuildMaxbyIndex((int)openIndex))); SetTextInfo(openIndex, levelMax); } } buildBtn.interactable = !levelMax; buildBtn1.interactable = !levelMax; } public void Click_StartBuild() { if (GameManager.gameManager.m_RunningScene == 658) { GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{79512}")); return; } if (IsGuildMoneyEnough==false) { MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{25247}"), "", delegate () { YuanBaoShopLogic.OpenShopForItem(828); }); return; } if(string.IsNullOrEmpty(isEnough) == false) { GUIData.AddNotifyData(isEnough); return; } if(Singleton.Instance.MainPlayer != null) { Singleton.Instance.MainPlayer.ReqGuildLevelUp(openIndex); } } }