using UnityEngine; using UnityEngine.UI; using System.Collections; using System.Collections.Generic; using GCGame.Table; public class GuildBossCopy : MonoBehaviour { public struct BossState { public int dataid; public int state; public float PosX; public float PosZ; } public GameObject BossInfoObj; private void Awake() { Games.Events.EventDispatcher.Instance.Add(Games.Events.EventId.GuildFBBoss, FreshBossInfo); } private void OnDestroy() { Games.Events.EventDispatcher.Instance.Remove(Games.Events.EventId.GuildFBBoss, FreshBossInfo); } void OnEnable() { //if (MissionDialogAndLeftTabsLogic.Instance() != null) // MissionDialogAndLeftTabsLogic.Instance().HideMissionDialog(false); //MissionDialogAndLeftTabsLogic.SetSwitch(UIInfo.GuildBossCopy); Tab_Fuben fuben = TableManager.GetFubenByID(GameManager.gameManager.PlayerDataPool.EnterSceneCache.EnterCopySceneID, 0); if (fuben == null) { UIManager.CloseUI(UIInfo.GuildBossCopy); return; } int job = GameManager.gameManager.PlayerDataPool.GuildInfo.GetMemberJob(GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Guid); if (job != (int)Games.GlobeDefine.GameDefine_Globe.GUILD_JOB.CHIEF && job != (int)Games.GlobeDefine.GameDefine_Globe.GUILD_JOB.VICE_CHIEF) { ApplyMemberWnd.SetActive(false); } OnBtnShow(); } public void FreshBossInfo(object argc) { List Caches = new List(); int index = 0; SynGuildBossFBInfo binaryMsg = (SynGuildBossFBInfo)argc; if (binaryMsg == null) return; for (int i = 0; i < BossItemOBjs.Count; i++) BossItemOBjs[i].SetActive(false); Tab_GuildBossConfig guildBoss = null; var guildBosss = TableManager.GetGuildBossConfig().Values; foreach (var boss in guildBosss) { if (boss.FunbenID == GameManager.gameManager.PlayerDataPool.EnterSceneCache.EnterCopySceneID) guildBoss = boss; } if(guildBoss==null) { UIManager.CloseUI(UIInfo.GuildBossCopy); return; } m_CurrBossLevelId = guildBoss.Id; int stateIndex = -1; for (int i = 0; i < binaryMsg.info.Count; i++) { GuildBossFBInfo info = binaryMsg.info[i]; if (info.state == 2) { stateIndex = i; } } SendMsg(100, MovieEventSend.EventType.HideGameObj); stateIndex++; for (; index < guildBoss.getBossInfoCount(); index++) { string bossStr = guildBoss.GetBossInfobyIndex(index); if (bossStr.Contains(":") == false) continue; string[] bossInfos = bossStr.Split(':'); if (bossInfos.Length < 3) continue; BossState boss; int.TryParse(bossInfos[0], out boss.dataid); float.TryParse(bossInfos[1], out boss.PosX); float.TryParse(bossInfos[2], out boss.PosZ); if (boss.dataid == 0) continue; boss.state = 0; if (index < stateIndex) boss.state = 2; if(index == stateIndex) boss.state = 1; if(index > stateIndex) boss.state = 0; if (BossItemOBjs.Count > index) CreateOneBOSS(BossItemOBjs[index], boss); else { GameObject newObj = CreateOneBOSS(null, boss); if (newObj != null) BossItemOBjs.Add(newObj); } } for (; index < BossItemOBjs.Count; index++) { BossItemOBjs[index].SetActive(false); } if(stateIndex <= 0) { SendMsg(101, MovieEventSend.EventType.AddMesh); } if(stateIndex <= 1) { SendMsg(102, MovieEventSend.EventType.AddMesh); } } private void SendMsg(int envenID,MovieEventSend.EventType eventType) { EventSenderInfo info = new EventSenderInfo(); info._SendID = gameObject.GetInstanceID(); info._State = true; MovieEventSend.EventInfo even = new MovieEventSend.EventInfo(); even.EveneID = envenID; even.EventType = eventType; info.Events.Add(even); Games.Events.EventDispatcher.Instance.Dispatch(Games.Events.EventId.MovieEvent, info); } List BossItemOBjs = new List(); public GameObject CreateOneBOSS(GameObject cloneObj, BossState info) { GameObject BossItem = cloneObj; if(BossItem==null) BossItem = GameObject.Instantiate(BossInfoObj); if (BossItem == null) return null; BossItem.transform.SetParent(BossInfoObj.transform.parent); BossItem.transform.localPosition = Vector3.zero; BossItem.transform.localScale = Vector3.one; BossItem.SetActive(true); Transform killed = BossItem.transform.Find("Killed"); if(killed!=null) { killed.gameObject.SetActive(info.state == 2); } Transform Tip = BossItem.transform.Find("Tip"); if (Tip != null) { Tip.gameObject.SetActive(info.state == 0); Text TipText = Tip.GetComponent(); if (TipText != null) { TipText.text = StrDictionary.GetClientDictionaryString("#{24985}"); } } Transform Name = BossItem.transform.Find("Name"); if (Name != null) { Text NameText = Name.GetComponent(); if(NameText!=null) { string numStr = string.Format(" {0}/1", (info.state == 2 ? 1 : 0)); Tab_RoleBaseAttr role = TableManager.GetRoleBaseAttrByID(info.dataid, 0); if (role != null) NameText.text = role.Name + numStr; } } Button btn = BossItem.GetComponentInChildren