142 lines
4.6 KiB
C#
142 lines
4.6 KiB
C#
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using System.Collections;
|
|||
|
using Games.Item;
|
|||
|
using GCGame.Table;
|
|||
|
|
|||
|
public class QianghuaLvInfo
|
|||
|
{
|
|||
|
public int Level;
|
|||
|
public GameItem EquipItem;
|
|||
|
public int CurPerfect;
|
|||
|
public int MinPerfect;
|
|||
|
public int MaxPerfect;
|
|||
|
public int PlayerLevel;
|
|||
|
public bool IsCanSelect = true;
|
|||
|
public bool IsAuto;
|
|||
|
}
|
|||
|
|
|||
|
public class EquipQianghuaLevelItem : UIItemSelect
|
|||
|
{
|
|||
|
|
|||
|
public Text _LevelName;
|
|||
|
public Slider _PerfectPro;
|
|||
|
public Text _ProDisable;
|
|||
|
public Text _CurPro;
|
|||
|
public Text _MaxPro;
|
|||
|
public GameObject _CanSelectGO;
|
|||
|
public ParticleSystem _EffectPrefab;
|
|||
|
public float beginPercentage = 0.1f; // 百分比显示的初始长度:当处于等级的最底完美度,也需要显示一定长度。
|
|||
|
|
|||
|
private ParticleSystem _Effect;
|
|||
|
public bool CanSelect;
|
|||
|
|
|||
|
private QianghuaLvInfo _QianghuaInfo;
|
|||
|
|
|||
|
void OnEnable()
|
|||
|
{
|
|||
|
if (_Effect != null)
|
|||
|
{
|
|||
|
_Effect.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public override void Show(Hashtable hash)
|
|||
|
{
|
|||
|
base.Show();
|
|||
|
|
|||
|
_QianghuaInfo = (QianghuaLvInfo)hash["InitObj"];
|
|||
|
InitQianghua();
|
|||
|
//var image = _Effect.GetComponent<Image>();
|
|||
|
//image.color = new Color(image.color.r, image.color.g, image.color.b, 0);
|
|||
|
//_Effect.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
|
|||
|
public void PlayEffect()
|
|||
|
{
|
|||
|
if (_Effect == null)
|
|||
|
{
|
|||
|
_Effect = GameObject.Instantiate<ParticleSystem>(_EffectPrefab);
|
|||
|
_Effect.transform.SetParent(transform);
|
|||
|
_Effect.transform.localPosition = Vector2.zero;
|
|||
|
_Effect.transform.localRotation = Quaternion.Euler( Vector2.zero);
|
|||
|
_Effect.transform.localScale = Vector3.one;
|
|||
|
|
|||
|
_Effect.gameObject.AddComponent<UIParticleSystem>();
|
|||
|
}
|
|||
|
_Effect.gameObject.SetActive(true);
|
|||
|
//_Effect.Stop();
|
|||
|
_Effect.Play();
|
|||
|
//_Effect.CrossFade("dengjiqianghua", 0);
|
|||
|
}
|
|||
|
|
|||
|
public override void Refresh()
|
|||
|
{
|
|||
|
base.Refresh();
|
|||
|
|
|||
|
var qianghua = _QianghuaInfo.EquipItem.GetEquipStarRate(_QianghuaInfo.Level);
|
|||
|
_QianghuaInfo.CurPerfect = (int)qianghua.x;
|
|||
|
_QianghuaInfo.MinPerfect = (int)qianghua.y;
|
|||
|
_QianghuaInfo.MaxPerfect = (int)qianghua.z;
|
|||
|
InitQianghua();
|
|||
|
}
|
|||
|
|
|||
|
private void InitQianghua()
|
|||
|
{
|
|||
|
_LevelName.text = StrDictionary.GetClientDictionaryString("#{2162}", _QianghuaInfo.Level);
|
|||
|
//if (!_QianghuaInfo.IsAuto)
|
|||
|
{
|
|||
|
if (_QianghuaInfo.CurPerfect >= _QianghuaInfo.MaxPerfect || !_QianghuaInfo.IsCanSelect)
|
|||
|
{
|
|||
|
_CanSelectGO.SetActive(false);
|
|||
|
CanSelect = false;
|
|||
|
_ProDisable.text = StrDictionary.GetClientDictionaryString("#{5432}");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_CanSelectGO.SetActive(true);
|
|||
|
CanSelect = true;
|
|||
|
_ProDisable.text = "";
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
_CurPro.text = _QianghuaInfo.CurPerfect + "%";
|
|||
|
_MaxPro.text = StrDictionary.GetClientDictionaryString("#{5392}", _QianghuaInfo.MinPerfect, _QianghuaInfo.MaxPerfect);
|
|||
|
|
|||
|
Tab_EquipEnchanceRandRate tab = TableManager.GetEquipEnchanceRandRateByID(_QianghuaInfo.Level, 0);
|
|||
|
if(GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level >= tab.PlayerLevel)
|
|||
|
{
|
|||
|
if (_QianghuaInfo.CurPerfect > 0 || _QianghuaInfo.IsCanSelect)
|
|||
|
{
|
|||
|
_PerfectPro.gameObject.SetActive(true);
|
|||
|
_ProDisable.gameObject.SetActive(false);
|
|||
|
|
|||
|
//if (_QianghuaInfo.CurPerfect == _QianghuaInfo.MinPerfect)
|
|||
|
//{
|
|||
|
// _PerfectPro.value = beginPercentage;
|
|||
|
//}
|
|||
|
//else
|
|||
|
{
|
|||
|
|
|||
|
float deltaPro = ((float)(_QianghuaInfo.CurPerfect - _QianghuaInfo.MinPerfect + 1)) / (_QianghuaInfo.MaxPerfect - _QianghuaInfo.MinPerfect + 1);
|
|||
|
_PerfectPro.value = deltaPro;
|
|||
|
}
|
|||
|
//_AttrDesc.text = StrDictionary.GetClientDictionaryString("#{5300}", _QianghuaInfo.CurPerfect, _QianghuaInfo.MaxPerfect);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_PerfectPro.gameObject.SetActive(false);
|
|||
|
_ProDisable.gameObject.SetActive(true);
|
|||
|
//_AttrDesc.text = StrDictionary.GetClientDictionaryString("#{5301}", _QianghuaInfo.MinPerfect, _QianghuaInfo.MaxPerfect);
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
_PerfectPro.gameObject.SetActive(false);
|
|||
|
_ProDisable.text = StrDictionary.GetClientDictionaryString("#{5401}", tab.PlayerLevel);
|
|||
|
_ProDisable.gameObject.SetActive(true);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|