//--------------------------------------------------------
|
// [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] Text m_InfoText;
|
[SerializeField] RichText[] m_EquipTexts;
|
[SerializeField] Button[] m_EquipGetWay;
|
[SerializeField] Button m_Close;
|
|
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>(); } }
|
|
RealmLevelUpEquipCondition equipCondition;
|
List<int> notSatisfyPlaces = new List<int>();
|
|
#region Built-in
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
m_Close.AddListener(CloseClick);
|
for (int i = 0; i < m_EquipGetWay.Length; i++)
|
{
|
m_EquipGetWay[i].AddListener(OnGetWay);
|
}
|
}
|
|
protected override void OnPreOpen()
|
{
|
Display();
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
#endregion
|
|
void Display()
|
{
|
var config = RealmLVUPTaskConfig.Get(functionOrder);
|
|
equipCondition = new RealmLevelUpEquipCondition()
|
{
|
level = config.NeedValueList[0],
|
starLevel = config.NeedValueList[1],
|
isSuit = config.NeedValueList[2] == 1,
|
itemColor = config.NeedValueList[3],
|
};
|
var equipSet = equipModel.GetEquipSet(equipCondition.level);
|
var realmConfig = RealmConfig.Get(equipSet.realm);
|
|
notSatisfyPlaces = new List<int>();
|
model.SatisfyEquipCondition(model.equipNeedConfig, out notSatisfyPlaces);
|
|
int count;
|
string countStr = "";
|
if (config.NeedValueList.Length == 5)
|
{
|
count = config.NeedValueList[4];
|
if (count == 8)
|
{
|
countStr = StringUtility.Contact(countStr, count);
|
}
|
else
|
{
|
countStr = StringUtility.Contact(countStr, Language.Get("L2031"), count);
|
}
|
}
|
else
|
{
|
count = 8;
|
countStr = StringUtility.Contact(countStr, count);
|
}
|
|
|
if (!equipCondition.isSuit)
|
{
|
var colorName = UIHelper.GetColorNameByItemColor(equipCondition.itemColor);
|
m_InfoText.text = Language.Get("RealmNeedEquipCondition_1", realmConfig.NameEx, colorName, equipCondition.starLevel, countStr)
|
+ " (" + Language.Get("BlessedLand036", Math.Min(count, 8 - notSatisfyPlaces.Count), count) + ")";
|
}
|
else
|
{
|
m_InfoText.text = Language.Get("RealmNeedEquipCondition_2", realmConfig.NameEx, equipCondition.starLevel, countStr)
|
+ " (" + Language.Get("BlessedLand036", Math.Min(count, 8 - notSatisfyPlaces.Count), count) + ")";
|
}
|
|
|
|
int[] recommandEquips;
|
model.TryGetRecommandEquips(equipCondition.level, PlayerDatas.Instance.baseData.Job, model.equipNeedConfig.NeedValueList[3], out recommandEquips);
|
for (int i = 0; i < m_EquipTexts.Length; i++)
|
{
|
int place = i + 1;
|
int equipState = 0; // 0 完成 1. 没有装备引导获得途径 2. 背包中有更好的装备引导穿戴 3.引导升星
|
int curStarLevel = 0;
|
int targetStarLevel = equipCondition.starLevel;
|
|
var equipGuid = equipModel.GetEquip(new Int2(equipCondition.level, place));
|
var itemModel = packModel.GetItemByGuid(equipGuid);
|
if (itemModel != null)
|
{
|
curStarLevel = equipStarModel.GetEquipStarLevel(new Int2(equipCondition.level, place));
|
|
if (curStarLevel < targetStarLevel)
|
{
|
equipState = 3;
|
}
|
|
if (equipCondition.isSuit)
|
{
|
if (itemModel.config.SuiteiD == 0)
|
{
|
equipState = 1;
|
}
|
}
|
else if (itemModel.config.ItemColor < equipCondition.itemColor)
|
{
|
equipState = 1;
|
}
|
|
}
|
else
|
{
|
equipState = 1;
|
}
|
|
//查找背包中是否有更好的装备
|
if (equipState == 1)
|
{
|
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) ||
|
(!equipCondition.isSuit && item.config.ItemColor >= equipCondition.itemColor))
|
{
|
equipState = 2;
|
break;
|
}
|
}
|
}
|
}
|
|
var itemConfig = ItemConfig.Get(recommandEquips[i]);
|
string suffix = string.Empty;
|
if (equipState == 0)
|
{
|
suffix = StringUtility.Contact("(", Language.Get("TaskWin_Btn_Finish"), ")");
|
m_EquipGetWay[i].RemoveAllListeners();
|
}
|
else if (equipState == 1)
|
{
|
suffix = StringUtility.Contact("<color=#ff0000><a>", Language.Get("HolidayXianXiaMJLotterynWin__1"), "</a></color>");
|
m_EquipGetWay[i].AddListener(OnGetWay);
|
}
|
else if (equipState == 2)
|
{
|
suffix = StringUtility.Contact("<color=#ff0000><a>", Language.Get("RealmRecommandEquipWin__2"), "</a></color>");
|
m_EquipGetWay[i].AddListener(() => {
|
Goto(2);
|
});
|
}
|
else if (equipState == 3)
|
{
|
suffix = StringUtility.Contact("<color=#ff0000><a>", Language.Get("gotoEquipStar"), "</a></color>");
|
m_EquipGetWay[i].AddListener(() => {
|
Goto(1);
|
});
|
}
|
string equipName = StringUtility.Contact(itemConfig.ItemName, " ",
|
Language.Get("EquipStarLevel", Language.Get("BlessedLand036", curStarLevel, targetStarLevel)), " ", suffix);
|
m_EquipTexts[i].text = UIHelper.AppendColor(notSatisfyPlaces.Contains(place) ? TextColType.Gray : TextColType.Green, equipName, true);
|
}
|
|
}
|
|
private void OnGetWay()
|
{
|
var config = EquipControlConfig.Get(equipCondition.level, notSatisfyPlaces[0]);
|
RealmRecommandEquipGetWayWin.equipGetWays.Clear();
|
RealmRecommandEquipGetWayWin.equipGetWays.AddRange(config.getWays);
|
WindowCenter.Instance.Open<RealmRecommandEquipGetWayWin>();
|
}
|
|
private void Goto(int state)
|
{
|
if (state == 2)
|
{
|
equipModel.SelectSet(equipCondition.level);
|
WindowCenter.Instance.Open<KnapSackWin>(false, 0);
|
}
|
else
|
{
|
|
equipStarModel.jumpEquipPos = new Int2(equipCondition.level, notSatisfyPlaces[0]);
|
WindowCenter.Instance.Open<EquipFrameWin>(false, 1);
|
}
|
CloseImmediately();
|
WindowCenter.Instance.Close<RealmWin>();
|
}
|
|
|
}
|
|
}
|
|
|
|
|