using UnityEngine; using UnityEngine.UI; using System.Collections; using System.Collections.Generic; using GCGame.Table; using GCGame; using Games.GlobeDefine; public class WorldBossRank : MonoBehaviour { public Text m_LastKillerName; public Image m_LastKillerHeadIcon; public Text BossName; public Text FubenName; public Text Level; public Text SelfContribute; public Toggle ProfessionToggle; public UIContainerBase m_RewardList; public UIContainerBase m_ContainerBase; private void Awake() { Games.Events.EventDispatcher.Instance.Add(Games.Events.EventId.WorldBossRank, Init); CloneProfessionToggle(); } private void OnDestroy() { Games.Events.EventDispatcher.Instance.Remove(Games.Events.EventId.WorldBossRank, Init); } void CloneProfessionToggle() { if (ProfessionToggle == null) return; for (int i = -1; i < (int)CharacterDefine.PROFESSION.MAX; i++) { int profession = i; GameObject newOBj = GameObject.Instantiate(ProfessionToggle.gameObject); if (newOBj == null) continue; newOBj.SetActive(true); newOBj.transform.SetParent(ProfessionToggle.transform.parent); newOBj.transform.localPosition = Vector3.zero; newOBj.transform.localScale = ProfessionToggle.transform.localScale; Toggle toggle = newOBj.GetComponent(); if (profession != -1) { Text[] toggleNames = newOBj.GetComponentsInChildren(); string name = StrDictionary.GetClientDictionaryString("#{" + CharacterDefine.PROFESSION_DICNUM[i] + "}"); for (int num = 0; num < toggleNames.Length; num++) { toggleNames[num].text = name; } } if (toggle != null) { toggle.isOn = (profession == -1 ? true : false); toggle.onValueChanged.AddListener(delegate (bool isOn) { if (isOn) { ToggleProfession_Click(profession); } }); } } ToggleProfession_Click(-1); } int m_CurrentSelProfession = -1; public void ToggleProfession_Click(int profession) { m_CurrentSelProfession = profession; m_ContainerBase.Hide (); WorldBossData.Instance.SendAskRankData(profession); } public void OnEnable() { Tab_WorldBossConfig boss = TableManager.GetWorldBossConfigByID(WorldBossData.Instance.m_CurrentShowBossId, 0); if (boss == null) return; Level.text = StrDictionary.GetClientDictionaryString("#{1166}", boss.Level); Tab_RoleBaseAttr roleBase = TableManager.GetRoleBaseAttrByID(WorldBossData.Instance.m_CurrentShowBossId, 0); if (roleBase == null) return; BossName.text = roleBase.Name; Tab_Fuben fuben = TableManager.GetFubenByID(boss.FubenID, 0); if (fuben != null) FubenName.text = fuben.Name; WorldBossData.Instance.SendAskRankData(-1); } public void Init(object par) { AskWorldBossLastRankInfoRet rankInfo = par as AskWorldBossLastRankInfoRet; if (rankInfo == null) return; if (m_CurrentSelProfession != rankInfo.professionId) return; m_LastKillerName.gameObject.SetActive(false); m_LastKillerHeadIcon.gameObject.SetActive(false); if (rankInfo.lastKiller!=null && rankInfo.lastKiller.playerGuid!=-1 && rankInfo.lastKiller.professionId!=-1) { m_LastKillerName.gameObject.SetActive(true); m_LastKillerHeadIcon.gameObject.SetActive(true); m_LastKillerName.text = rankInfo.lastKiller.name; LoadAssetBundle.Instance.SetImageSprite(m_LastKillerHeadIcon, Utils.GetProfessionSpriteName(rankInfo.lastKiller.professionId)); } SelfContribute.text = rankInfo.selfScore.ToString(); List showList = new List(); for(int i=0;i SelfAwardItems = new List(); string[] itemIds = rankInfo.selfReward.Split(':'); for(int i=0;i