//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Tuesday, March 12, 2019
|
//--------------------------------------------------------
|
using UnityEngine;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI
|
{
|
|
public class TipGemInfoWidget : MonoBehaviour
|
{
|
[SerializeField] GemBehaviour[] m_GemBehaviours;
|
|
public void Display(ItemTipUtility.GemInfo gemInfo)
|
{
|
for (int i = 0; i < m_GemBehaviours.Length; i++)
|
{
|
var behaviour = m_GemBehaviours[i];
|
var active = gemInfo.activeStates.ContainsKey(i) ? gemInfo.activeStates[i] : false;
|
var gem = (gemInfo.gems != null && gemInfo.gems.ContainsKey(i)) ? gemInfo.gems[i] : 0;
|
behaviour.Display(active, gem);
|
}
|
}
|
|
[System.Serializable]
|
public class GemBehaviour
|
{
|
public Image gemIcon;
|
public Image locked;
|
public Text gemName;
|
public Text propertyBehaviour;
|
public RectTransform unLockContainer;
|
|
public void Display(bool active, int gem)
|
{
|
if (active)
|
{
|
if (gem > 0)
|
{
|
var config = ItemConfig.Get(gem);
|
gemIcon.gameObject.SetActive(true);
|
gemIcon.SetSprite(StringUtility.Contact("GemTypeMini_", config.EffectValueA1));
|
gemName.text = config.ItemName;
|
|
var properties = new List<Int2>();
|
if (config.Effect2 > 0)
|
{
|
properties.Add(new Int2(config.Effect2, config.EffectValueA2));
|
}
|
|
if (config.Effect3 > 0)
|
{
|
properties.Add(new Int2(config.Effect3, config.EffectValueA3));
|
}
|
|
if (config.Effect4 > 0)
|
{
|
properties.Add(new Int2(config.Effect4, config.EffectValueA4));
|
}
|
|
if (config.Effect5 > 0)
|
{
|
properties.Add(new Int2(config.Effect5, config.EffectValueA5));
|
}
|
|
var lines = new string[properties.Count];
|
for (int i = 0; i < properties.Count; i++)
|
{
|
var property = properties[i];
|
lines[i] = PlayerPropertyConfig.GetFullDescription(property.x, property.y);
|
}
|
|
propertyBehaviour.text = string.Join("\r\n", lines);
|
propertyBehaviour.gameObject.SetActive(true);
|
}
|
else
|
{
|
gemIcon.gameObject.SetActive(false);
|
gemName.text = "未镶嵌";
|
propertyBehaviour.gameObject.SetActive(false);
|
}
|
|
locked.gameObject.SetActive(false);
|
unLockContainer.gameObject.SetActive(false);
|
}
|
else
|
{
|
locked.gameObject.SetActive(true);
|
gemIcon.gameObject.SetActive(false);
|
gemName.text = "未解锁";
|
propertyBehaviour.gameObject.SetActive(false);
|
unLockContainer.gameObject.SetActive(true);
|
}
|
}
|
|
}
|
|
|
}
|
|
}
|