//-------------------------------------------------------- // [Author]: 第二世界 // [ Date ]: Tuesday, March 12, 2019 //-------------------------------------------------------- using UnityEngine; using System.Collections; using UnityEngine.UI; namespace Snxxz.UI { public class EquipStrengthUpper : MonoBehaviour { [SerializeField] ItemCell m_ItemEquip; [SerializeField] Text m_StarLevel; [SerializeField] ItemCell m_ItemMoney; [SerializeField] Text NeedMoney; [SerializeField] Text m_AttributesText1; [SerializeField] Text m_AttributesText2; [SerializeField] Text m_AttributesText3; [SerializeField] Text m_TextNumber; [SerializeField] Text m_TextMaxLv; 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; public void SetEquipStrengthUpper(string equipGuid, int level, int equipPlace) { this.equipLevel = level; this.equipPlace = equipPlace; int equipIndex = EquipPlaceMapConfig.GetServerPlace(level, equipPlace); int equipLv = 0; EquipStrength equipStrength = new EquipStrength(); if (strengthModel.EquipStrengthDic.ContainsKey(equipIndex))//获取当前强化等级 { equipLv = strengthModel.EquipStrengthDic[equipIndex].StrengthLevel; equipStrength = strengthModel.EquipStrengthDic[equipIndex]; } var itemPlus = strengthModel.GetEquipConfig(level, equipPlace); if (itemPlus == null) { DebugEx.LogError("没有索引到对应的强化表数据"); return; } var item = packModel.GetItemByGuid(equipGuid); if (item != null) { m_ItemEquip.Init(item); m_ItemEquip.button.SetListener(() => { ItemTipUtility.Show(equipGuid); }); } m_TextNumber.text = "+" + (equipLv + 1); DisplayMoney(); int equipType = EquipStrengthModel.GetEquipStrengthType(equipPlace); var star = equipStarModel.GetEquipStarLevel(new Int2(level, equipPlace)); var maxStar = EquipStarModel.GetMaxStarLevel(item.config.ItemColor, level); star = Mathf.Min(star, maxStar); m_StarLevel.text = Language.Get("EquipStarLevel", star); m_StarLevel.gameObject.SetActive(star > 0); var equipMaxLv = strengthModel.GetEquipLevelMax(equipType, star); m_TextMaxLv.text = Language.Get("ZBQH_02", star, equipMaxLv); ItemCellModel cellModel = new ItemCellModel(2100, true, (ulong)1); m_ItemMoney.Init(cellModel); m_ItemMoney.button.SetListener(() => { ItemTipUtility.Show(2100); }); var equipLvNowList = strengthModel.GetEquipValueList(level, equipPlace); var equipAddLvList = strengthModel.GetEquipValueList(level, equipPlace, 1); m_AttributesText1.gameObject.SetActive(false); m_AttributesText2.gameObject.SetActive(false); m_AttributesText3.gameObject.SetActive(false); for (int i = 0; i < 3; i++) { if (i < equipLvNowList.Count) { int type = i; var _equipLv = equipLvNowList[type]; var _equipAddLv = equipAddLvList[type]; switch (type) { case 0: m_AttributesText1.gameObject.SetActive(true); Text addText = m_AttributesText1.transform.Find("Number").GetComponent(); m_AttributesText1.text = _equipLv.StrName + ":" + _equipLv.AttValue; addText.text = "+" + (_equipAddLv.AttValue - _equipLv.AttValue); break; case 1: m_AttributesText2.gameObject.SetActive(true); Text addText1 = m_AttributesText2.transform.Find("Number").GetComponent(); m_AttributesText2.text = _equipLv.StrName + ":" + _equipLv.AttValue; addText1.text = "+" + (_equipAddLv.AttValue - _equipLv.AttValue); break; case 2: m_AttributesText3.gameObject.SetActive(true); Text addText2 = m_AttributesText3.transform.Find("Number").GetComponent(); m_AttributesText3.text = _equipLv.StrName + ":" + _equipLv.AttValue; addText2.text = "+" + (_equipAddLv.AttValue - _equipLv.AttValue); break; } } } } public void DisplayMoney() { var config = strengthModel.GetEquipConfig(equipLevel, equipPlace); if (config == null) { return; } ulong money = UIHelper.GetMoneyCnt(3); ulong requireMoney = (ulong)config.costCount; string moneyLabel = ItemLogicUtility.Instance.OnChangeCoinsUnit(UIHelper.GetMoneyCnt(3)); moneyLabel = UIHelper.AppendColor(money >= requireMoney ? TextColType.Green : TextColType.Red, moneyLabel, true); string requireLabel = ItemLogicUtility.Instance.OnChangeCoinsUnit(requireMoney); NeedMoney.text = StringUtility.Contact(moneyLabel, "/", requireLabel); } } }