//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Tuesday, March 12, 2019
|
//--------------------------------------------------------
|
using UnityEngine;
|
using System.Collections;
|
using UnityEngine.UI;
|
using UnityEngine.Events;
|
|
namespace Snxxz.UI
|
{
|
|
public class TipSuitPropertyWidget : MonoBehaviour
|
{
|
[SerializeField] Text m_SuitName;
|
[SerializeField] RectTransform m_StarsContainer;
|
[SerializeField] StarToggle[] m_StarToggles;
|
[SerializeField] Text[] m_SuitEquipNames;
|
|
[SerializeField] EquipSuitPropertyBar m_TwoSuit;
|
[SerializeField] EquipSuitPropertyBar m_FiveSuit;
|
[SerializeField] Text m_EightSuitTitle;
|
[SerializeField] Text m_EightSuitDescription;
|
|
ItemTipUtility.SuitInfo suitInfo;
|
public void Display(ItemTipUtility.SuitInfo suitInfo)
|
{
|
this.suitInfo = suitInfo;
|
|
m_SuitName.text = suitInfo.name;
|
|
var highestEightSuitLevel = 0;
|
foreach (var item in suitInfo.eightSuits)
|
{
|
if (item.Value && item.Key > highestEightSuitLevel)
|
{
|
highestEightSuitLevel = item.Key;
|
}
|
}
|
|
var maxLevel = suitInfo.maxSuitLevel;
|
m_StarsContainer.gameObject.SetActive(maxLevel >= 0);
|
if (maxLevel >= 0)
|
{
|
m_StarToggles[0].SetActive(true, DisplaySuitInfo);
|
m_StarToggles[1].SetActive(maxLevel >= 3, DisplaySuitInfo);
|
m_StarToggles[2].SetActive(maxLevel >= 6, DisplaySuitInfo);
|
m_StarToggles[3].SetActive(maxLevel >= 9, DisplaySuitInfo);
|
|
for (int i = 0; i < m_StarToggles.Length; i++)
|
{
|
m_StarToggles[i].toggle.isOn = i == highestEightSuitLevel / 3;
|
}
|
}
|
|
DisplaySuitInfo(highestEightSuitLevel);
|
}
|
|
void DisplaySuitInfo(int star)
|
{
|
DisplayCollectInfo(star);
|
DisplaySuitProperty(star);
|
}
|
|
void DisplayCollectInfo(int star)
|
{
|
var setName = EquipModel.GetSuitName(suitInfo.level);
|
for (int i = 0; i < m_SuitEquipNames.Length; i++)
|
{
|
var place = i + 1;
|
m_SuitEquipNames[i].text = setName + EquipSuitNameConfig.GetSuitName(suitInfo.level, place, suitInfo.job);
|
var hasSuit = suitInfo.places.Contains(place)
|
&& suitInfo.placeStars.ContainsKey(place) && suitInfo.placeStars[place] >= star;
|
m_SuitEquipNames[i].color = UIHelper.GetUIColor(hasSuit ? TextColType.Green : TextColType.White, true);
|
}
|
}
|
|
void DisplaySuitProperty(int star)
|
{
|
m_TwoSuit.Display(suitInfo.twoSuitProperties[star]);
|
m_FiveSuit.Display(suitInfo.fiveSuitProperties[star]);
|
m_EightSuitDescription.text = GetEightSuitDescription(suitInfo.job, suitInfo.level, star);
|
var eightSuitActive = suitInfo.eightSuits[star];
|
var color = UIHelper.GetUIColor(eightSuitActive ? TextColType.Green : TextColType.White, true);
|
m_EightSuitTitle.color = color;
|
m_EightSuitDescription.color = color;
|
}
|
|
public void Dispose()
|
{
|
|
}
|
|
private string GetEightSuitDescription(int job, int level, int star)
|
{
|
var configs = EquipSuitConfig.GetConfigs(job, level, EquipSuitType.EightSuit);
|
for (int i = 0; i < configs.Count; i++)
|
{
|
var config = configs[i];
|
if (config.star == star)
|
{
|
var description = string.Empty;
|
if (config.skillID > 0)
|
{
|
description = config.description;
|
}
|
else
|
{
|
var propertyConfig = PlayerPropertyConfig.Get(config.attr[0].x);
|
var propertyDescription = PlayerPropertyConfig.GetValueDescription(config.attr[0].x, config.attr[0].y);
|
description = StringUtility.Contact(propertyConfig.Name, " +", propertyDescription);
|
}
|
|
return description;
|
}
|
}
|
|
return string.Empty;
|
}
|
|
[System.Serializable]
|
public class StarToggle
|
{
|
public RectTransform root;
|
public int star;
|
public Text title;
|
public Toggle toggle;
|
|
UnityAction<int> action;
|
|
public void SetActive(bool active, UnityAction<int> action)
|
{
|
root.gameObject.SetActive(active);
|
toggle.isOn = false;
|
toggle.interactable = active;
|
this.action = action;
|
|
if (active)
|
{
|
toggle.SetListener(OnValueChange);
|
}
|
else
|
{
|
toggle.RemoveAllListeners();
|
}
|
}
|
|
private void OnValueChange(bool value)
|
{
|
if (value)
|
{
|
if (action != null)
|
{
|
action(star);
|
}
|
}
|
}
|
|
}
|
|
|
}
|
|
}
|