//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Thursday, May 09, 2019
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace vnxbqy.UI
|
{
|
|
public class RealmRecommandEquipWin : Window
|
{
|
[SerializeField] ItemCell[] m_Items;
|
[SerializeField] Button m_Goto;
|
[SerializeField] Button m_GetWays;
|
[SerializeField] Button m_Close;
|
[SerializeField] ScrollRect m_Scroller;
|
[SerializeField] HorizontalLayoutGroup m_Layout;
|
[SerializeField] Text m_InfoText;
|
[SerializeField] Text m_WayText;
|
|
RealmModel model { get { return ModelCenter.Instance.GetModel<RealmModel>(); } }
|
PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
|
EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
|
EquipStarModel equipStarModel { get { return ModelCenter.Instance.GetModel<EquipStarModel>(); } }
|
|
#region Built-in
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
m_Goto.AddListener(Goto);
|
m_GetWays.AddListener(OnGetWay);
|
m_Close.AddListener(CloseClick);
|
}
|
|
protected override void OnPreOpen()
|
{
|
}
|
|
protected override void OnActived()
|
{
|
base.OnActived();
|
Display();
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
model.realmUpgrateNoEnoughReason = 0;
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
#endregion
|
|
void Display()
|
{
|
m_InfoText.text = Language.Get(model.realmUpgrateNoEnoughReason == 2 ? "realmEquipNotEnouth2" : "realmEquipNotEnouth1");
|
m_WayText.text = Language.Get(model.realmUpgrateNoEnoughReason == 2 ? "gotoEquipStar" : "GetItem_1");
|
|
var realmLevel = PlayerDatas.Instance.baseData.realmLevel;
|
List<int> notSatisfyPlaces;
|
int[] recommandEquips;
|
if (!model.SatisfyEquipCondition(realmLevel, out notSatisfyPlaces)
|
&& model.TryGetRecommandEquips(realmLevel, PlayerDatas.Instance.baseData.Job, out recommandEquips))
|
{
|
for (int i = 0; i < m_Items.Length; i++)
|
{
|
if (i < notSatisfyPlaces.Count && notSatisfyPlaces[i] <= recommandEquips.Length)
|
{
|
m_Items[i].SetActive(true);
|
|
var place = notSatisfyPlaces[i];
|
|
var itemData = new ItemCellModel(recommandEquips[place - 1], true, 1);
|
m_Items[i].Init(itemData);
|
m_Items[i].button.SetListener(() =>
|
{
|
ItemTipUtility.Show(recommandEquips[place - 1]);
|
});
|
}
|
else
|
{
|
m_Items[i].SetActive(false);
|
}
|
}
|
}
|
|
m_Scroller.horizontalNormalizedPosition = 0f;
|
m_Scroller.enabled = notSatisfyPlaces.Count > 4;
|
m_Layout.childAlignment = notSatisfyPlaces.Count > 4 ? TextAnchor.MiddleLeft : TextAnchor.MiddleCenter;
|
if (notSatisfyPlaces.Count < 4)
|
{
|
m_Layout.transform.localPosition = m_Layout.transform.localPosition.SetX(0);
|
}
|
|
if (model.realmUpgrateNoEnoughReason != 2)
|
{
|
var existBetterEquip = false;
|
RealmLevelUpEquipCondition equipCondition;
|
model.TryGetRealmEquipCondition(realmLevel, out equipCondition);
|
for (int i = 0; i < notSatisfyPlaces.Count; i++)
|
{
|
var place = notSatisfyPlaces[i];
|
var items = packModel.GetItems(PackType.Item, new SinglePack.FilterParams()
|
{
|
levels = new List<int>() { equipCondition.level },
|
equipTypes = new List<int>() { place },
|
jobs = new List<int>() { PlayerDatas.Instance.baseData.Job },
|
});
|
if (items != null)
|
{
|
foreach (var item in items)
|
{
|
if (equipCondition.isSuit && item.config.SuiteiD > 0)
|
{
|
existBetterEquip = true;
|
break;
|
}
|
if (!equipCondition.isSuit && item.config.ItemColor >= equipCondition.itemColor)
|
{
|
existBetterEquip = true;
|
break;
|
}
|
}
|
}
|
if (existBetterEquip)
|
{
|
break;
|
}
|
}
|
|
m_Goto.SetActive(existBetterEquip);
|
m_GetWays.SetActive(!existBetterEquip);
|
}
|
else
|
{
|
m_Goto.SetActive(true); //装备升星
|
m_GetWays.SetActive(false);
|
}
|
}
|
|
private void OnGetWay()
|
{
|
var realmLevel = PlayerDatas.Instance.baseData.realmLevel;
|
RealmLevelUpEquipCondition equipCondition;
|
model.TryGetRealmEquipCondition(realmLevel, out equipCondition);
|
List<int> notSatisfyPlaces;
|
model.SatisfyEquipCondition(realmLevel, out notSatisfyPlaces);
|
var config = EquipControlConfig.Get(equipCondition.level, notSatisfyPlaces[0]);
|
RealmRecommandEquipGetWayWin.equipGetWays.Clear();
|
RealmRecommandEquipGetWayWin.equipGetWays.AddRange(config.getWays);
|
WindowCenter.Instance.Open<RealmRecommandEquipGetWayWin>();
|
}
|
|
private void Goto()
|
{
|
var realmLevel = PlayerDatas.Instance.baseData.realmLevel;
|
RealmLevelUpEquipCondition equipCondition;
|
model.TryGetRealmEquipCondition(realmLevel, out equipCondition);
|
if (model.realmUpgrateNoEnoughReason != 2)
|
{
|
equipModel.SelectSet(equipCondition.level);
|
WindowCenter.Instance.Open<KnapSackWin>(false, 0);
|
}
|
else
|
{
|
|
equipStarModel.jumpEquipPos = new Int2(equipCondition.level, 1);
|
WindowCenter.Instance.Open<EquipFrameWin>(false, 1);
|
}
|
CloseImmediately();
|
WindowCenter.Instance.Close<RealmWin>();
|
}
|
}
|
|
}
|
|
|
|
|