using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
|
/// <summary>
|
/// 武将觉醒选择天赋界面
|
/// </summary>
|
public class HeroAwakeSelectGiftWin : UIBase
|
{
|
[SerializeField] GameObject[] slectGos;
|
[SerializeField] Button[] giftBtns;
|
[SerializeField] GiftBaseCell[] giftCells;
|
[SerializeField] Text[] skillText;
|
[SerializeField] Button okBtn;
|
|
int selectIndex = 0;
|
protected override void InitComponent()
|
{
|
okBtn.AddListener(SelectGift);
|
for (int i = 0; i < giftBtns.Length; i++)
|
{
|
int index = i;
|
giftBtns[i].AddListener(() =>
|
{
|
selectIndex = index;
|
Display();
|
});
|
}
|
}
|
|
protected override void OnPreOpen()
|
{
|
selectIndex = 0;
|
Display();
|
}
|
|
|
public void Display()
|
{
|
var hero = HeroManager.Instance.GetHero(HeroUIManager.Instance.selectAwakeHeroGuid);
|
if (hero == null)
|
{
|
return;
|
}
|
|
for (int i = 0; i < giftBtns.Length; i++)
|
{
|
slectGos[i].SetActive(i == selectIndex);
|
if (i < hero.talentAwakeRandomIDList.Count)
|
{
|
giftCells[i].Init(hero.talentAwakeRandomIDList[i], 1);
|
var giftConfig = HeroTalentConfig.Get(hero.talentAwakeRandomIDList[i]);
|
skillText[i].text = PlayerPropertyConfig.GetFullDescription(giftConfig.AttrID, giftConfig.AttrValue);
|
}
|
}
|
|
}
|
|
|
void SelectGift()
|
{
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("HeroAwake7"), (bool isOK) =>
|
{
|
if (isOK)
|
{
|
var hero = HeroManager.Instance.GetHero(HeroUIManager.Instance.selectAwakeHeroGuid);
|
if (hero == null)
|
{
|
return;
|
}
|
|
HeroUIManager.Instance.heroBeforeAwakeGiftIDList = new List<int>(hero.talentIDList);
|
HeroUIManager.Instance.heroBeforeAwakeGiftLevelList = new List<int>(hero.talentLvList);
|
|
HeroUIManager.Instance.waitResponse = new WaitHeroFuncResponse()
|
{
|
guid = HeroUIManager.Instance.selectAwakeHeroGuid,
|
type = HeroFuncType.Awake,
|
time = Time.time
|
};
|
var pack = new CB234_tagCSHeroAwakeSelectTalent();
|
pack.ItemIndex = (ushort)hero.itemHero.gridIndex;
|
pack.SelectIndex = (byte)selectIndex;
|
GameNetSystem.Instance.SendInfo(pack);
|
CloseWindow();
|
}
|
});
|
}
|
}
|