//帮会历程界面 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 GuildBoss : MonoBehaviour { public Text FightTimes; public GameObject RewardOBj; public UIContainerSelect m_BossList; GC_RET_GUILDBOSS_INFO m_packet = null; void Awake() { Games.Events.EventDispatcher.Instance.Add(Games.Events.EventId.GuildBoss, FreshBossInfo); } private void OnDestroy() { Games.Events.EventDispatcher.Instance.Remove(Games.Events.EventId.GuildBoss, FreshBossInfo); } private void OnEnable() { if(GameManager.gameManager.PlayerDataPool.IsHaveGuild()==false) { Duty = true; return; } AskBossInfo(0); } bool Duty = false; private void Update() { if(Duty) { Duty = false; InitInifo(); } } void InitInifo() { int index = 0; int indexCall = -1; var hasCall = (m_packet != null && (m_packet.Fbstate == 1 || m_packet.Fbstate == 2)); var guildBosses = TableManager.GetGuildBossConfig().Values; var bossInfos = new List(); var i = 0; foreach (var guildBoss in guildBosses) { GuildBossInfo.BossInfo bossInfo = new GuildBossInfo.BossInfo(); var levelId = guildBoss.GetId(); bossInfo.index = i + 1; bossInfo.LevelId = levelId; bossInfo.CallState = hasCall ? 3 : 0; if (m_packet != null) { bossInfo.authority = m_packet.Authority; } if (m_packet != null && m_packet.Fbindex == levelId) { bossInfo.CallState = m_packet.Fbstate; if (bossInfo.CallState != 0) { indexCall = i; } } if (guildBoss.NeedGuildLevel <= GameManager.gameManager.PlayerDataPool.GuildInfo.GuildLevel) index = i; bossInfos.Add(bossInfo); i++; } if (indexCall >= 0) index = indexCall; List selects = new List(); if (bossInfos.Count > 0) { selects.Add(bossInfos[index]); bossInfos[index].index = 0; } m_BossList.InitSelectContent(bossInfos, selects, Select); } private void FreshBossInfo(object argc) { m_packet = (GC_RET_GUILDBOSS_INFO)argc; if (m_packet == null) return; FightTimes.text = m_packet.Leftcount.ToString(); Duty = true; } public void Select(object initInfo) { GuildBossInfo.BossInfo bossInfo = initInfo as GuildBossInfo.BossInfo; if (bossInfo == null) return; Tab_GuildBossConfig guildBoss = TableManager.GetGuildBossConfigByID(bossInfo.LevelId, 0); if (guildBoss == null) return; InitJoinReward(guildBoss.RewardShow1); } private void AskBossInfo(int type, int param = -1) { CG_REQ_GUILDBOSS_OPERATE send = (CG_REQ_GUILDBOSS_OPERATE)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_GUILDBOSS_OPERATE); send.Operate = type; send.Parm = param; send.SendPacket(); } List Rewards = new List(); public void InitJoinReward(string items) { for (int i = 0; i < Rewards.Count; i++) { Rewards[i].SetActive(false); } string[] itemIds = items.Split(':'); for (int i = 0; i < itemIds.Length; i++) { int itemID = -1; if (int.TryParse(itemIds[i], out itemID)) { if (Rewards.Count > i) { CloneRewardItem(itemID, Rewards[i]); continue; } GameObject newObj = CloneRewardItem(itemID, null); if (newObj != null) Rewards.Add(newObj); } } } public GameObject CloneRewardItem(int itemId, GameObject oldItemObj) { Tab_CommonItem commonItem = TableManager.GetCommonItemByID(itemId, 0); if (commonItem == null) return null; if (oldItemObj == null) { oldItemObj = GameObject.Instantiate(RewardOBj); oldItemObj.transform.SetParent(RewardOBj.transform.parent); oldItemObj.transform.localPosition = Vector3.zero; oldItemObj.transform.localScale = RewardOBj.transform.localScale; } if (oldItemObj == null) return null; oldItemObj.SetActive(true); Button btn = oldItemObj.GetComponentInChildren