126 lines
3.3 KiB
C#
126 lines
3.3 KiB
C#
using cfg.CharacterCfg;
|
|
using Framework;
|
|
using Gameplay;
|
|
using Gameplay.Net;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class UIRaffleResultController : UIWindow
|
|
{
|
|
private ItemCounts mNowItems;
|
|
private Image Image_poster;
|
|
private TMP_Text Name;
|
|
private Button RaffleOne;
|
|
private Button RaffleTen;
|
|
private Button mHome_Btn;
|
|
private Button mBack_Btn;
|
|
public override void OnInit()
|
|
{
|
|
|
|
RaffleOne = GetComponent<Button>("RaffleOneBtn");
|
|
RaffleTen = GetComponent<Button>("RaffleTenBtn");
|
|
Image_poster = GetComponent<Image>("Single/Image_Poster00");
|
|
Name =FindObj("Single/Image_GroupLogo/Image_NameInfo/Text_CharacterName").GetComponent<TMP_Text>();
|
|
mBack_Btn = GetComponent<Button>("Button_Back");
|
|
mHome_Btn = GetComponent<Button>("Button_Home");
|
|
|
|
BindButton(RaffleOne, OnRaffleOne);
|
|
BindButton(RaffleTen, OnRaffleTen);
|
|
BindButton(mBack_Btn, OnBackOnClick);
|
|
}
|
|
private void OnBackOnClick()
|
|
{
|
|
CloseWindow();
|
|
|
|
}
|
|
|
|
|
|
private void OnRaffleTen()
|
|
{
|
|
}
|
|
|
|
private void OnRaffleOne()
|
|
{
|
|
|
|
}
|
|
|
|
protected override void OnShowWindow(object data = null)
|
|
{
|
|
mNowItems=data as ItemCounts;
|
|
RefreshAll(mNowItems);
|
|
|
|
// RefreshBtns();
|
|
|
|
}
|
|
|
|
public void RefreshAll(ItemCounts data)
|
|
{
|
|
RefreshAwards(data);
|
|
RefreshRemain();
|
|
}
|
|
private void RefreshRemain()
|
|
{
|
|
GetComponent<TMP_Text>("Remain/remain").text = "抽卡道具:" + Actor.Instance.Item.GetItemCount(2);
|
|
}
|
|
|
|
|
|
public void RefreshAwards(ItemCounts awards)
|
|
{
|
|
if (awards.Ids.Count == 1)
|
|
{
|
|
RefreshSingleAwards(awards);
|
|
}
|
|
else if(awards.Ids.Count>1)
|
|
{
|
|
RefreshMultiAwards(awards);
|
|
}
|
|
else
|
|
{
|
|
DebugUtil.LogError("奖励数据不对");
|
|
}
|
|
}
|
|
|
|
private void RefreshMultiAwards(ItemCounts awards)
|
|
{
|
|
FindObj("Single").SetActive(false);
|
|
FindObj("Multilple").SetActive(true);
|
|
for (int i = 1; i <= 10; i++)
|
|
{
|
|
GameObject obj = FindObj(string.Format("Multilple/1/{0}",i));
|
|
if (i <= awards.Ids.Count)
|
|
{
|
|
obj.SetActive(true);
|
|
RefreshSingleCharacter(obj,awards.Ids[i - 1], awards.Counts[i-1]);
|
|
}
|
|
else
|
|
{
|
|
obj.SetActive(false);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
private void RefreshSingleCharacter(GameObject obj,uint id ,uint count)
|
|
{
|
|
DebugUtil.LogError("抽取的角色Id为:" + id);
|
|
int uid = TableManager.Instance.Tables.Item.GetOrDefault((int)id).Param1;
|
|
CommonUtils.RefreshCharacter2DPic(CommonUtils.GetComponent<Image>(obj, "Image_Poster"), uid, CommonUtils.ECharacterPicPathType.SelectCharacter);
|
|
|
|
}
|
|
|
|
private void RefreshSingleAwards(ItemCounts awards)
|
|
{
|
|
FindObj("Single").SetActive(true);
|
|
FindObj("Multilple").SetActive(false);
|
|
|
|
int cId = TableManager.Instance.Tables.Item.GetOrDefault((int)awards.Ids[0]).Param1;
|
|
DataCharacterAttri cfg = TableManager.Instance.Tables.CharacterAttri.GetOrDefault(cId);
|
|
CommonUtils.RefreshCharacter2DPic(Image_poster, cfg.RoleID, CommonUtils.ECharacterPicPathType.Cultivate);
|
|
Name.text = CommonUtils.GetLocalizeText(cfg.Name);
|
|
|
|
}
|
|
|
|
}
|