using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
using System.Text;
|
using Snxxz.UI;
|
using System.Collections;
|
|
public class RoleEquipStrengthTips : MonoBehaviour
|
{
|
#region 成员变量
|
[SerializeField]
|
CanvasGroup tipAlpha;
|
private GameObject _curStrength;
|
private Text _curStrengthText;
|
private Text _curAttrValueText;
|
private Text _haveStrengthText;
|
private GameObject _nextStrength;
|
private Text _nextStrengthText;
|
private Text _nextAttrValueText;
|
private Text _noOpenText;
|
#endregion
|
|
private int _curStrengthLv;
|
private PlayerPropertyConfig _playerProModel;
|
private Dictionary<int, Dictionary<int, int>> _roleStrengthInfoDict;
|
private Dictionary<int, EquipmentInitialization> _haveStrengthInfoDict;
|
|
private void Awake()
|
{
|
_curStrength = transform.Find("CurrentStrength").gameObject;
|
_curStrengthText = transform.Find("CurrentStrength/TargetNowText").GetComponent<Text>();
|
_curAttrValueText = transform.Find("CurrentStrength/AttrValueText").GetComponent<Text>();
|
_haveStrengthText = transform.Find("CurrentStrength/CountNowText").GetComponent<Text>();
|
|
_nextStrength = transform.Find("NextStrength").gameObject;
|
_nextStrengthText = transform.Find("NextStrength/TargetNextText").GetComponent<Text>();
|
_nextAttrValueText = transform.Find("NextStrength/ActNextText").GetComponent<Text>();
|
_noOpenText = transform.Find("CurrentStrength/NoOpenText").GetComponent<Text>();
|
|
}
|
PlayerStrengthengDatas m_StrengthengModel;
|
PlayerStrengthengDatas strengthengmodel
|
{
|
get
|
{
|
return m_StrengthengModel ?? (m_StrengthengModel = ModelCenter.Instance.GetModel<PlayerStrengthengDatas>());
|
}
|
}
|
private void OnEnable()
|
{
|
_roleStrengthInfoDict = strengthengmodel.StrengtheningAll();
|
_haveStrengthInfoDict = strengthengmodel._EqInfo;
|
_nextStrength.SetActive(false);
|
_curStrength.SetActive(false);
|
RefreshUI();
|
tipAlpha.alpha = 0;
|
StartCoroutine(SetScrollSize());
|
}
|
|
private void RefreshUI()
|
{
|
if (_roleStrengthInfoDict.Count < 2)
|
return;
|
List<int> strengthLvs = _roleStrengthInfoDict.Keys.ToList();
|
_curStrengthText.text = Language.Get("KnapS121").Replace("{0}",strengthLvs[0].ToString());
|
StringBuilder curAttrStr = new StringBuilder();
|
RectTransform size = _haveStrengthText.GetComponent<RectTransform>();
|
foreach (int pro in _roleStrengthInfoDict[strengthLvs[0]].Keys)
|
{
|
curAttrStr.Append(SetIsPercentShow(pro, _roleStrengthInfoDict[strengthLvs[0]][pro]) + "\n");
|
}
|
|
if(curAttrStr.Length < 1)
|
{
|
_noOpenText.gameObject.SetActive(true);
|
_curStrengthText.gameObject.SetActive(false);
|
_curAttrValueText.gameObject.SetActive(false);
|
}
|
else
|
{
|
_noOpenText.gameObject.SetActive(false);
|
_curStrengthText.gameObject.SetActive(true);
|
_curAttrValueText.gameObject.SetActive(true);
|
}
|
_curAttrValueText.text = curAttrStr.ToString();
|
StringBuilder nextAttrStr = new StringBuilder();
|
foreach (int pro in _roleStrengthInfoDict[strengthLvs[1]].Keys)
|
{
|
nextAttrStr.Append(SetIsPercentShow(pro, _roleStrengthInfoDict[strengthLvs[1]][pro]) + "\n");
|
}
|
_nextStrengthText.text = Language.Get("KnapS121").Replace("{0}", _roleStrengthInfoDict.Keys.ToList()[1].ToString());
|
_nextAttrValueText.text = nextAttrStr.ToString();
|
|
_curStrengthLv = 0;
|
foreach(var value in _haveStrengthInfoDict.Values)
|
{
|
_curStrengthLv += value.EquipPartStarLV;
|
}
|
_haveStrengthText.text = Language.Get("KnapS122").Replace("{0}",_curStrengthLv.ToString());
|
|
}
|
|
IEnumerator SetScrollSize()
|
{
|
yield return null;
|
yield return null;
|
_curStrength.SetActive(true);
|
StartCoroutine(ShowBottomPart());
|
}
|
|
IEnumerator ShowBottomPart()
|
{
|
yield return null;
|
_nextStrength.SetActive(true);
|
StartCoroutine(SetPanelScale());
|
}
|
|
IEnumerator SetPanelScale()
|
{
|
yield return null;
|
tipAlpha.alpha = 1;
|
}
|
|
//判断属性是否百分比显示
|
public string SetIsPercentShow(int proId, int proValue)
|
{
|
_playerProModel = PlayerPropertyConfig.Get(proId);
|
string strPro = "";
|
if (_playerProModel == null)
|
{
|
DebugEx.LogError("不存在此属性" + proId);
|
return "";
|
}
|
|
if (!_playerProModel.Name.Contains("%s"))
|
{
|
if (_playerProModel.ISPercentage == 0)
|
{
|
strPro = _playerProModel.Name + "+" + proValue;
|
}
|
else if (_playerProModel.ISPercentage == 1)
|
{
|
strPro = _playerProModel.Name + "+" + (float)Math.Round(proValue / 100f, 1) + "%";
|
}
|
}
|
else
|
{
|
if (_playerProModel.ISPercentage == 0)
|
{
|
strPro = _playerProModel.Name.Replace("%s", proValue.ToString());
|
}
|
else if (_playerProModel.ISPercentage == 1)
|
{
|
strPro = _playerProModel.Name.Replace("%s", (float)Math.Round(proValue / 100f, 1) + "%");
|
}
|
}
|
|
return strPro;
|
}
|
|
}
|