//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Monday, March 11, 2019
|
//--------------------------------------------------------
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace vnxbqy.UI {
|
|
public class EquipStrengthSelectBehaviour: CellView
|
{
|
[SerializeField] Transform m_ContainerEquip;
|
[SerializeField] Transform m_ContainerUnEquip;
|
[SerializeField] Text m_EquipPlaceName;
|
[SerializeField] Transform m_ContainerSelect;
|
[SerializeField] ItemCell m_Item;
|
[SerializeField] Text m_EquipStar;
|
[SerializeField] Text m_ItemName;
|
[SerializeField] Button m_Select;
|
[SerializeField] RedpointBehaviour m_Redpoint;
|
[SerializeField] UIEffect strengthEffect;
|
|
EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
|
PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
|
EquipStrengthModel strengthModel { get { return ModelCenter.Instance.GetModel<EquipStrengthModel>(); } }
|
EquipStarModel equipStarModel { get { return ModelCenter.Instance.GetModel<EquipStarModel>(); } }
|
|
int equipLevel = 0;
|
int equipPlace = 0;
|
string equipGuid = string.Empty;
|
|
public void Display(int level, int place)
|
{
|
this.equipLevel = level;
|
this.equipPlace = place;
|
|
var equipSet = equipModel.GetEquipSet(equipLevel);
|
equipGuid = equipSet.GetEquip(equipPlace);
|
|
var equiped = !string.IsNullOrEmpty(equipGuid);
|
m_ContainerEquip.SetActive(equiped);
|
m_ContainerUnEquip.SetActive(!equiped);
|
|
m_Select.SetListener(() => { strengthModel.SelectEquipPlace = equipPlace; });
|
|
if (equiped)
|
{
|
DisplayBase();
|
EquipStrengthModel.EquipStrengthRedpoint redpoint;
|
if (strengthModel.TryGetRedpoint(level, place, out redpoint))
|
{
|
m_Redpoint.redpointId = redpoint.redpoint.id;
|
}
|
}
|
else
|
{
|
m_Redpoint.redpointId = 0;
|
DisplayUnEquip();
|
}
|
|
m_ContainerSelect.SetActive(strengthModel.SelectEquipPlace == equipPlace);
|
}
|
|
int tmpLV = -2; //升级时显示特效
|
void DisplayBase()
|
{
|
int itemIndex = EquipPlaceMapConfig.GetServerPlace(equipLevel, equipPlace);
|
var strengthLv = 0;
|
if (strengthModel.EquipStrengthDic.ContainsKey(itemIndex))
|
{
|
strengthLv = strengthModel.EquipStrengthDic[itemIndex].StrengthLevel;
|
if (strengthLv - tmpLV == 1)
|
{
|
strengthEffect.Play();
|
}
|
tmpLV = strengthLv;
|
}
|
var item = packModel.GetItemByGuid(equipGuid);
|
if (item != null)
|
{
|
m_Item.Init(item);
|
m_Item.button.enabled = false;
|
m_ItemName.text = Language.Get("ZBQH_01", item.config.ItemName, strengthLv);
|
m_ItemName.color = UIHelper.GetUIColor(item.config.ItemColor, true);
|
|
var maxStar = EquipStarModel.GetMaxStarLevel(item.config.ItemColor, item.config.LV);
|
var starLevel = Mathf.Min(maxStar, equipStarModel.GetStarLevel(new Int2(equipLevel, equipPlace)));
|
m_EquipStar.text = Language.Get("EquipStarLevel", starLevel);
|
m_EquipStar.SetActive(starLevel>0);
|
}
|
}
|
|
void DisplayUnEquip()
|
{
|
if (GeneralDefine.equipPlaceNameDict.ContainsKey(equipPlace))
|
{
|
m_EquipPlaceName.text = Language.Get("L1076", GeneralDefine.equipPlaceNameDict[equipPlace]);
|
}
|
}
|
}
|
|
}
|
|
|
|