using System.Collections;
|
using System.Collections.Generic;
|
using Cysharp.Threading.Tasks;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
/// <summary>
|
/// 招募结果展示
|
/// </summary>
|
public class HeroCallResultWin : UIBase
|
{
|
[SerializeField] GameObject moneyObj; //立绘时候隐藏
|
[SerializeField] OwnItemCell ownItemCell;
|
[SerializeField] OwnMoneyCell ownMoneyCell;
|
|
[SerializeField] GameObject result1Obj; //单抽展示
|
[SerializeField] HeroCallResultCell result1Cell;
|
|
[SerializeField] GameObject result10Obj; //十连展示
|
[SerializeField] HeroCallResultCell[] result10Cells;
|
|
[SerializeField] GameObject result10LihuiObj; //十连立绘展示
|
[SerializeField] UIHeroController roleLHModel;
|
[SerializeField] Image qualityImg;
|
[SerializeField] HeroCallResultCell showLHResultCell;
|
[SerializeField] Image newMarkLHImg;
|
[SerializeField] Button showNextlhOrCloseBtn;
|
|
[SerializeField] GameObject heroInfoObj; //武将信息,单抽和立绘时候显示
|
[SerializeField] Text heroNameText;
|
[SerializeField] Image heroCountryImg;
|
[SerializeField] Image heroJobImg;
|
[SerializeField] Text jobPosNameText;
|
|
//按钮区
|
[SerializeField] GameObject btnsObj;
|
[SerializeField] Button call1Btn;
|
[SerializeField] Image call1ItemIcon;
|
[SerializeField] Text call1Text;
|
[SerializeField] Button call10Btn;
|
[SerializeField] Image call10ItemIcon;
|
[SerializeField] Text call10Text;
|
[SerializeField] Button okBtn;
|
|
|
int resultState = 0; //0单抽展示 1十连展示 2 十连开始展示 3 十连立绘展示
|
|
bool isSkip = false;
|
List<int> showLHHeroIDList = new List<int>();
|
|
protected override void InitComponent()
|
{
|
okBtn.AddListener(CloseWindow);
|
|
call1Btn.AddListener(SendHeroCall);
|
call10Btn.AddListener(() =>
|
{
|
HeroUIManager.Instance.selectCallIndex = 1;
|
HappyXBModel.Instance.SendXBManyQuest((int)HeroUIManager.Instance.selectCallType);
|
});
|
showNextlhOrCloseBtn.AddListener(RefreshLihui);
|
}
|
|
|
protected override void OnPreOpen()
|
{
|
isSkip = LocalSave.GetBool(HeroUIManager.skipKey, false);
|
UIManager.Instance.CloseWindow<ScrollTipWin>();
|
HappyXBModel.Instance.RefreshXBResultAct += UpdateState;
|
HappyXBModel.Instance.RefreshXBTypeInfoAct += RefreshBtn;
|
InitMoney();
|
UpdateState();
|
RefreshBtn();
|
}
|
|
protected override void OnPreClose()
|
{
|
HappyXBModel.Instance.RefreshXBResultAct -= UpdateState;
|
HappyXBModel.Instance.RefreshXBTypeInfoAct -= RefreshBtn;
|
}
|
|
void UpdateState()
|
{
|
if (HeroUIManager.Instance.selectCallIndex == 0)
|
{
|
resultState = 0;
|
}
|
else if (isSkip)
|
{
|
resultState = 1;
|
}
|
else
|
{
|
resultState = 2;
|
MoveToNextState().Forget();
|
}
|
RefreshState();
|
}
|
|
async UniTask MoveToNextState()
|
{
|
await UniTask.Delay(1500);
|
|
showLHHeroIDList.Clear();
|
for (int i = 0; i < HappyXBModel.Instance.xbResultDict.Count; i++)
|
{
|
var heroID = HappyXBModel.Instance.xbResultDict[i].itemId;
|
if (HeroConfig.Get(heroID).Quality >= 4)
|
showLHHeroIDList.Add(HappyXBModel.Instance.xbResultDict[i].itemId);
|
}
|
|
resultState = 3;
|
try
|
{
|
RefreshState();
|
}
|
catch (System.Exception e)
|
{
|
Debug.LogWarning(e);
|
}
|
}
|
|
void RefreshState()
|
{
|
if (resultState == 0)
|
{
|
btnsObj.SetActive(true);
|
call1Btn.SetActive(HeroUIManager.Instance.selectCallType != HappXBTitle.HeroCallScore ? true : false);
|
call10Btn.SetActive(false);
|
|
result1Obj.SetActive(true);
|
result10Obj.SetActive(false);
|
result10LihuiObj.SetActive(false);
|
ShowMoney(true);
|
heroInfoObj.SetActive(true);
|
|
result1Cell.Display(HappyXBModel.Instance.xbResultDict[0].itemId, 0);
|
RefreshHeroInfo(HappyXBModel.Instance.xbResultDict[0].itemId);
|
}
|
else if (resultState == 1)
|
{
|
btnsObj.SetActive(true);
|
call1Btn.SetActive(false);
|
call10Btn.SetActive(true);
|
|
result1Obj.SetActive(false);
|
result10Obj.SetActive(true);
|
result10LihuiObj.SetActive(false);
|
ShowMoney(true);
|
heroInfoObj.SetActive(false);
|
if (isSkip)
|
Refresh10Result();
|
}
|
else if (resultState == 2)
|
{
|
btnsObj.SetActive(false);
|
|
result1Obj.SetActive(false);
|
result10Obj.SetActive(true);
|
result10LihuiObj.SetActive(false);
|
ShowMoney(false);
|
heroInfoObj.SetActive(false);
|
Refresh10Result();
|
}
|
else if (resultState == 3)
|
{
|
btnsObj.SetActive(false);
|
|
result1Obj.SetActive(false);
|
result10Obj.SetActive(false);
|
result10LihuiObj.SetActive(true);
|
ShowMoney(false);
|
heroInfoObj.SetActive(true);
|
RefreshLihui();
|
}
|
}
|
|
public void RefreshBtn()
|
{
|
var funcSet = TreasureSetConfig.Get((int)HeroUIManager.Instance.selectCallType);
|
if (funcSet.CostItemID == 0)
|
{
|
call1ItemIcon.SetActive(false);
|
call1Text.SetActive(false);
|
call10ItemIcon.SetActive(false);
|
call10Text.SetActive(false);
|
return;
|
}
|
|
call1ItemIcon.SetActive(true);
|
call1Text.SetActive(true);
|
call10ItemIcon.SetActive(true);
|
call10Text.SetActive(true);
|
|
var item = ItemConfig.Get(funcSet.CostItemID);
|
var IconKey = item.IconKey;
|
call1ItemIcon.SetOrgSprite(IconKey);
|
|
|
if (HappyXBModel.Instance.IsHaveFreeXB((int)HeroUIManager.Instance.selectCallType))
|
{
|
call1Text.text = Language.Get("L1127");
|
}
|
else
|
{
|
call1Text.text = Language.Get("L1100", item.ItemName, funcSet.CostItemCountList[0]);
|
}
|
|
|
call10ItemIcon.SetOrgSprite(IconKey);
|
call10Text.text = Language.Get("L1100", item.ItemName, funcSet.CostItemCountList[1]);
|
}
|
|
void ShowMoney(bool show)
|
{
|
if (HeroUIManager.Instance.selectCallType == HappXBTitle.HeroCallScore)
|
{
|
moneyObj.SetActive(false);
|
return;
|
}
|
moneyObj.SetActive(show);
|
}
|
|
void Refresh10Result()
|
{
|
for (int i = 0; i < result10Cells.Length; i++)
|
{
|
result10Cells[i].Display(HappyXBModel.Instance.xbResultDict[i].itemId, i + 1);
|
}
|
}
|
|
void InitMoney()
|
{
|
ownItemCell.itemID = TreasureSetConfig.Get((int)HeroUIManager.Instance.selectCallType).CostItemID;
|
ownMoneyCell.moneyType = TreasureSetConfig.Get((int)HeroUIManager.Instance.selectCallType).CostMoneyType;
|
}
|
|
void SendHeroCall()
|
{
|
heroInfoObj.SetActive(false);
|
HeroUIManager.Instance.selectCallIndex = 0;
|
if (HappyXBModel.Instance.IsHaveFreeXB((int)HeroUIManager.Instance.selectCallType))
|
{
|
HappyXBModel.Instance.SendXBQuest((int)HeroUIManager.Instance.selectCallType, 0, 1);
|
}
|
else
|
{
|
HappyXBModel.Instance.SendOneXBQuest((int)HeroUIManager.Instance.selectCallType);
|
}
|
}
|
|
void RefreshLihui()
|
{
|
//汇总品质传说及以上的立绘
|
int heroID = 0;
|
if (showLHHeroIDList.Count > 0)
|
{
|
heroID = showLHHeroIDList[0];
|
showLHHeroIDList.RemoveAt(0);
|
}
|
else
|
{
|
resultState = 1;
|
RefreshState();
|
return;
|
}
|
var hero = HeroConfig.Get(heroID);
|
roleLHModel.Create(hero.SkinIDList[0], HeroUIManager.lihuiScale, motionName: "", isLh: true);
|
qualityImg.SetSprite("HeroCallQuality" + hero.Quality);
|
newMarkLHImg.SetActive(HeroUIManager.Instance.IsNewHero(heroID));
|
showLHResultCell.Display(heroID, 0, true);
|
RefreshHeroInfo(heroID);
|
}
|
|
void RefreshHeroInfo(int heroID)
|
{
|
var heroConfig = HeroConfig.Get(heroID);
|
|
heroNameText.text = heroConfig.Name;
|
heroNameText.color = UIHelper.GetUIColorByFunc(heroConfig.Quality);
|
heroCountryImg.SetSprite(HeroUIManager.Instance.GetCountryIconName(heroConfig.Country));
|
heroJobImg.SetSprite(HeroUIManager.Instance.GetJobIconName(heroConfig.Class));
|
jobPosNameText.text = HeroUIManager.Instance.GetJobName(heroConfig.Class) + " " + heroConfig.Desc;
|
}
|
}
|