//-------------------------------------------------------- // [Author]: 第二世界 // [ Date ]: Monday, March 11, 2019 //-------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace Snxxz.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; EquipGemModel model { get { return ModelCenter.Instance.GetModel(); } } EquipModel equipModel { get { return ModelCenter.Instance.GetModel(); } } PackModel packModel { get { return ModelCenter.Instance.GetModel(); } } EquipStrengthModel strengthModel { get { return ModelCenter.Instance.GetModel(); } } EquipStarModel equipStarModel { get { return ModelCenter.Instance.GetModel(); } } 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.gameObject.SetActive(equiped); m_ContainerUnEquip.gameObject.SetActive(!equiped); m_Select.SetListener(() => { strengthModel.SelectEquipPlace = equipPlace; }); if (equiped) { DisplayBase(); EquipGemRedpoint equipGemRedpoint; m_Redpoint.redpointId = 0; } else { m_Redpoint.redpointId = 0; DisplayUnEquip(); } m_ContainerSelect.gameObject.SetActive(strengthModel.SelectEquipPlace == equipPlace); } void DisplayBase() { int itemIndex = EquipPlaceMapConfig.GetServerPlace(equipLevel, equipPlace); var strengthLv = 0; if (strengthModel.EquipStrengthDic.ContainsKey(itemIndex)) { strengthLv = strengthModel.EquipStrengthDic[itemIndex].StrengthLevel; } var item = packModel.GetItemByGuid(equipGuid); if (item != null) { m_Item.Init(item); 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.gameObject.SetActive(starLevel>0); } } void DisplayUnEquip() { if (GeneralDefine.equipPlaceNameDict.ContainsKey(equipPlace)) { m_EquipPlaceName.text = Language.Get("L1076", GeneralDefine.equipPlaceNameDict[equipPlace]); } } } }