158 lines
5.7 KiB
C#
158 lines
5.7 KiB
C#
|
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<Toggle>();
|
|||
|
|
|||
|
if (profession != -1)
|
|||
|
{
|
|||
|
Text[] toggleNames = newOBj.GetComponentsInChildren<Text>();
|
|||
|
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<WorldBossRankItem.RankInfo> showList = new List<WorldBossRankItem.RankInfo>();
|
|||
|
for(int i=0;i<rankInfo.rankInfo.Count;i++)
|
|||
|
{
|
|||
|
if (rankInfo.rankInfo[i].playerGuid == -1 || rankInfo.rankInfo[i].professionId == -1)
|
|||
|
continue;
|
|||
|
WorldBossRankItem.RankInfo info = new WorldBossRankItem.RankInfo();
|
|||
|
info.rank = i + 1;
|
|||
|
info.name = string.Format("{0}({1})",rankInfo.rankInfo[i].name,rankInfo.rankInfo[i].servername);
|
|||
|
info.score = rankInfo.rankInfo[i].AddScore;
|
|||
|
showList.Add(info);
|
|||
|
}
|
|||
|
m_ContainerBase.Show ();
|
|||
|
m_ContainerBase.InitContentItem(showList);
|
|||
|
|
|||
|
List<CommonItemContainerItem.ItemInfo> SelfAwardItems = new List<CommonItemContainerItem.ItemInfo>();
|
|||
|
string[] itemIds = rankInfo.selfReward.Split(':');
|
|||
|
for(int i=0;i<itemIds.Length;i++)
|
|||
|
{
|
|||
|
int itemId = 0;
|
|||
|
if(int.TryParse(itemIds[i],out itemId))
|
|||
|
{
|
|||
|
Tab_CommonItem commonItem = TableManager.GetCommonItemByID(itemId, 0);
|
|||
|
if(commonItem!=null)
|
|||
|
{
|
|||
|
CommonItemContainerItem.ItemInfo itemInfo = new CommonItemContainerItem.ItemInfo();
|
|||
|
itemInfo.itemID = itemId;
|
|||
|
itemInfo.itemNum = 1;
|
|||
|
itemInfo.itemQuality = Utils.GetItemQualityFrame(commonItem);
|
|||
|
itemInfo.itemSprite = commonItem.Icon;
|
|||
|
SelfAwardItems.Add(itemInfo);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
m_RewardList.InitContentItem(SelfAwardItems);
|
|||
|
}
|
|||
|
|
|||
|
public void Close()
|
|||
|
{
|
|||
|
UIManager.CloseUI(UIInfo.WorldBossRank);
|
|||
|
}
|
|||
|
|
|||
|
}
|