//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Wednesday, February 27, 2019
|
//--------------------------------------------------------
|
using UnityEngine;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI
|
{
|
|
public class EquipSuitPropertyWidget : MonoBehaviour
|
{
|
[SerializeField] Text m_SuitName;
|
[SerializeField] StarToggle[] m_StarToggles;
|
[SerializeField] Text[] m_SuitEquipNames;
|
|
[SerializeField] EquipSuitPropertyBar m_TwoSuit;
|
[SerializeField] EquipSuitPropertyBar m_FiveSuit;
|
[SerializeField] Text m_EightSuitTitle;
|
[SerializeField] Text m_EightSuitDescription;
|
|
EquipModel model { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
|
EquipStarModel starModel { get { return ModelCenter.Instance.GetModel<EquipStarModel>(); } }
|
PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
|
|
public void Init(int level)
|
{
|
var maxLevel = starModel.GetMaxStarLevel(level);
|
m_StarToggles[0].SetActive(true);
|
m_StarToggles[1].SetActive(maxLevel >= 3);
|
m_StarToggles[2].SetActive(maxLevel >= 6);
|
m_StarToggles[3].SetActive(maxLevel >= 9);
|
}
|
|
public void Display(int level, int star)
|
{
|
m_SuitName.text = EquipSuitConfig.GetConfigs(PlayerDatas.Instance.baseData.Job, level, EquipSuitType.TwoSuit)[0].name;
|
for (int i = 1; i <= 8; i++)
|
{
|
var equip = packModel.GetItemByGuid(model.GetEquip(level, i));
|
var hasSuit = equip != null && equip.config.SuiteiD > 0;
|
m_SuitEquipNames[i - 1].color = UIHelper.GetUIColor(hasSuit ? TextColType.Green : TextColType.Gray);
|
}
|
|
m_TwoSuit.Display(model.GetEquipSuitEntry(level, star, EquipSuitType.TwoSuit));
|
m_FiveSuit.Display(model.GetEquipSuitEntry(level, star, EquipSuitType.FiveSuit));
|
m_EightSuitDescription.text = GetEightSuitDescription(level, star);
|
var eightSuitLevel = starModel.GetSuitLevel(level, EquipSuitType.EightSuit);
|
var color = UIHelper.GetUIColor(eightSuitLevel >= star ? TextColType.Green : TextColType.Gray, true);
|
m_EightSuitTitle.color = color;
|
m_EightSuitDescription.color = color;
|
}
|
|
public void Dispose()
|
{
|
|
}
|
|
private string GetEightSuitDescription(int level, int star)
|
{
|
var configs = EquipSuitConfig.GetConfigs(PlayerDatas.Instance.baseData.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.GetPropertyDescription(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 int star;
|
public Text title;
|
public Toggle toggle;
|
|
EquipModel model { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
|
|
public void SetActive(bool active)
|
{
|
title.gameObject.SetActive(active);
|
if (active)
|
{
|
toggle.SetListener(OnValueChange);
|
}
|
else
|
{
|
toggle.RemoveAllListeners();
|
}
|
}
|
|
private void OnValueChange(bool value)
|
{
|
if (value)
|
{
|
model.selectedStarLevel.value = star;
|
}
|
}
|
|
}
|
|
}
|
|
}
|