using TableConfig; using UnityEngine; using UnityEngine.UI; using System.Collections.Generic; using System; using System.Collections; using System.Text; namespace Snxxz.UI { public class WashMasterWin : Window { [SerializeField] Text titleText; [SerializeField] Text areaText; [SerializeField] GameObject activeMasterObj; [SerializeField] GameObject currentPro; [SerializeField] Text targetNowText; [SerializeField] Text attr1NowText; [SerializeField] GameObject nextPro; [SerializeField] Text targetNextText; [SerializeField] Text attr1NextText; [SerializeField] GameObject unActiveMasterObj; [SerializeField] Text unEffectText; [SerializeField] Text unTargetText; [SerializeField] Text unAttrText; [SerializeField] Button closeBtn; [SerializeField] PositionTween leftPosTween; [SerializeField] UIEffect leftEffect; [Header("武器洗练大师")] [SerializeField] GameObject weaponObj; [SerializeField] List weaponCelllist = new List(); [Header("防具洗练大师")] [SerializeField] GameObject defenceObj; [SerializeField] List defenceCelllist = new List(); [Header("仙器洗练大师")] [SerializeField] GameObject fairyObj; [SerializeField] List fairyCelllist = new List(); [SerializeField] UIAlphaTween alphaTween; [SerializeField] PositionTween posTween; [SerializeField] CanvasGroup canvas; [SerializeField] Text washMasterCondText; protected List p_washSpeclist = null; private EquipWashSpecConfig p_currentSpecModel = null; private EquipWashSpecConfig p_nextSpecModel = null; private int p_preIndex = -1; private int p_nextIndex = -1; EquipWashModel _equipWashModel; EquipWashModel equipWashModel { get { return _equipWashModel ?? (_equipWashModel = ModelCenter.Instance.GetModel()); } } protected override void BindController() { } protected override void AddListeners() { closeBtn.AddListener(CloseWin); } protected override void OnPreOpen() { canvas.alpha = 0; p_washSpeclist = null; p_currentSpecModel = null; p_nextSpecModel = null; Init(); } protected override void OnAfterOpen() { //SetLeftUI(); // StartCoroutine(ShowCurPro()); } protected override void OnPreClose() { } protected override void OnAfterClose() { } private void SetLeftUI() { leftPosTween.gameObject.SetActive(true); leftEffect.Play(); leftPosTween.Play(); } IEnumerator ShowCurPro() { yield return null; if (p_currentSpecModel != null) { currentPro.SetActive(true); } StartCoroutine(ShowNextPro()); } IEnumerator ShowNextPro() { yield return null; if(p_nextSpecModel != null) { nextPro.SetActive(true); } StartCoroutine(ShowBottomPart()); } IEnumerator ShowBottomPart() { yield return null; alphaTween.Play(); posTween.Play(); } private void Init() { p_washSpeclist = EquipWashSpecConfig.GetWashSpecModel(equipWashModel.washType); GetTwoAdjacentNumber(0, p_washSpeclist.Count - 1,equipWashModel.washLv); if (p_preIndex != -1) { p_currentSpecModel = p_washSpeclist[p_preIndex]; } if (p_nextIndex != -1) { p_nextSpecModel = p_washSpeclist[p_nextIndex]; } ReFreshUI(); } private void ReFreshUI() { GetEquipWashGroup(); if(p_currentSpecModel == null || p_nextSpecModel == null) { unActiveMasterObj.SetActive(true); activeMasterObj.SetActive(false); if(p_currentSpecModel != null) { unEffectText.text = Language.Get("EquipWashMaster_4"); GetOpenHaveOneWashEffect(p_currentSpecModel); } else if(p_nextSpecModel != null) { unEffectText.text = Language.Get("EquipWashMaster_5"); GetOpenHaveOneWashEffect(p_nextSpecModel); } } else { unActiveMasterObj.SetActive(false); activeMasterObj.SetActive(true); GetOpenWashPro("current", p_currentSpecModel); GetOpenWashPro("next", p_nextSpecModel); } } private void GetOpenWashPro(string needShowPro, EquipWashSpecConfig model) { int[] openPro = ConfigParse.GetMultipleStr(model.attByLevel); int[] openProValue = ConfigParse.GetMultipleStr(model.attByLevelValue); List proModellist = new List(); List proValuelist = new List(); for (int i = 0; i < openPro.Length; i++) { PlayerPropertyConfig proModel = ConfigManager.Instance.GetTemplate(openPro[i]); proModellist.Add(proModel); if (proModel.ISPercentage == 1) { string str = (float)Math.Round((float)openProValue[i] / 100, 1) + "%"; proValuelist.Add(str); } else if (proModel.ISPercentage == 2) { string str = ((float)Math.Round((float)openProValue[i] / 100, 1)).ToString(); proValuelist.Add(str); } else { proValuelist.Add(openProValue[i].ToString()); } } if (needShowPro == "current") { switch (equipWashModel.washType) { case 1: targetNowText.text = Language.Get("EquipWash112", this.p_washSpeclist[p_preIndex].levelNeed.ToString()); break; case 2: targetNowText.text = Language.Get("EquipWashMaster_2", this.p_washSpeclist[p_preIndex].levelNeed.ToString()); break; case 3: targetNowText.text = Language.Get("EquipWashMaster_3", this.p_washSpeclist[p_preIndex].levelNeed.ToString()); break; } StringBuilder attrDes = new StringBuilder(); for(int i = 0; i < proModellist.Count; i++) { string s = proModellist[i].Name + "+" + proValuelist[i]; if(i < proModellist.Count - 1) { attrDes.Append(s +"\n"); } else { attrDes.Append(s); } } attr1NowText.text = attrDes.ToString(); } else if (needShowPro == "next") { switch (equipWashModel.washType) { case 1: targetNextText.text = Language.Get("EquipWash112", this.p_washSpeclist[p_nextIndex].levelNeed.ToString()); break; case 2: targetNextText.text = Language.Get("EquipWashMaster_2", this.p_washSpeclist[p_nextIndex].levelNeed.ToString()); break; case 3: targetNextText.text = Language.Get("EquipWashMaster_3", this.p_washSpeclist[p_nextIndex].levelNeed.ToString()); break; } StringBuilder attrDes = new StringBuilder(); for (int i = 0; i < proModellist.Count; i++) { string s = proModellist[i].Name + "+" + proValuelist[i]; if (i < proModellist.Count - 1) { attrDes.Append(s + "\n"); } else { attrDes.Append(s); } } attr1NextText.text = attrDes.ToString(); } } private void GetOpenHaveOneWashEffect(EquipWashSpecConfig model) { int[] openPro = ConfigParse.GetMultipleStr(model.attByLevel); int[] openProValue = ConfigParse.GetMultipleStr(model.attByLevelValue); List proModellist = new List(); List proValuelist = new List(); for (int i = 0; i < openPro.Length; i++) { PlayerPropertyConfig proModel = ConfigManager.Instance.GetTemplate(openPro[i]); proModellist.Add(proModel); if (proModel.ISPercentage == 1) { string str = (float)Math.Round((float)openProValue[i] / 100, 1) + "%"; proValuelist.Add(str); } else if (proModel.ISPercentage == 2) { string str = ((float)Math.Round((float)openProValue[i] / 100, 1)).ToString(); proValuelist.Add(str); } else { proValuelist.Add(openProValue[i].ToString()); } } int index = p_preIndex == -1 ? p_nextIndex : p_preIndex; switch (equipWashModel.washType) { case 1: unTargetText.text = Language.Get("EquipWash112", this.p_washSpeclist[index].levelNeed.ToString()); break; case 2: unTargetText.text = Language.Get("EquipWashMaster_2", this.p_washSpeclist[index].levelNeed.ToString()); break; case 3: unTargetText.text = Language.Get("EquipWashMaster_3", this.p_washSpeclist[index].levelNeed.ToString()); break; } StringBuilder attrDes = new StringBuilder(); for (int i = 0; i < proModellist.Count; i++) { string s = proModellist[i].Name + "+" + proValuelist[i]; if (i < proModellist.Count - 1) { attrDes.Append(s + "\n"); } else { attrDes.Append(s); } } unAttrText.text = attrDes.ToString(); } private void GetEquipWashGroup() { weaponObj.SetActive(false); defenceObj.SetActive(false); fairyObj.SetActive(false); int curMasterCnt = 0; switch (equipWashModel.washType) { case 1: weaponObj.SetActive(true); GetWashGroupIncludeName("EquipWashGroup1"); titleText.text = Language.Get("EquipWash116"); if(p_nextIndex != -1) { for(int i = 0; i < equipWashModel.washGroup1.Count; i++) { if(equipWashModel.washGroup1[i].XLAttrLV >= p_nextSpecModel.levelNeed) { curMasterCnt += 1; } } if (curMasterCnt >= 2) { washMasterCondText.text = StringUtility.Contact(Language.Get("EquipWash112", p_nextSpecModel.levelNeed), ":", UIHelper.GetTextColorByItemColor(TextColType.Green, curMasterCnt.ToString()), "/", 2); } else { washMasterCondText.text = StringUtility.Contact(Language.Get("EquipWash112", p_nextSpecModel.levelNeed), ":", UIHelper.GetTextColorByItemColor(TextColType.Red, curMasterCnt.ToString()), "/", 2); } } else { washMasterCondText.text = Language.Get("WashTips_SpecWashFull_1"); } for(int i = 0; i < weaponCelllist.Count; i++) { if (p_nextSpecModel != null) { weaponCelllist[i].SetModel(p_nextSpecModel.levelNeed); } else { weaponCelllist[i].SetModel(-1); } } break; case 2: defenceObj.SetActive(true); GetWashGroupIncludeName("EquipWashGroup2"); titleText.text = Language.Get("EquipWash117"); if (p_nextIndex != -1) { for (int i = 0; i < equipWashModel.washGroup2.Count; i++) { if (equipWashModel.washGroup2[i].XLAttrLV >= p_nextSpecModel.levelNeed) { curMasterCnt += 1; } } if (curMasterCnt >= 5) { washMasterCondText.text = StringUtility.Contact(Language.Get("EquipWash112", p_nextSpecModel.levelNeed), ":", UIHelper.GetTextColorByItemColor(TextColType.Green, curMasterCnt.ToString()), "/", 5); } else { washMasterCondText.text = StringUtility.Contact(Language.Get("EquipWash112", p_nextSpecModel.levelNeed), ":", UIHelper.GetTextColorByItemColor(TextColType.Red, curMasterCnt.ToString()), "/", 5); } } else { washMasterCondText.text = Language.Get("WashTips_SpecWashFull_2"); } for (int i = 0; i < defenceCelllist.Count; i++) { if (p_nextSpecModel != null) { defenceCelllist[i].SetModel(p_nextSpecModel.levelNeed); } else { defenceCelllist[i].SetModel(-1); } } break; case 3: fairyObj.SetActive(true); GetWashGroupIncludeName("EquipWashGroup3"); titleText.text = Language.Get("EquipWash118"); if (p_nextIndex != -1) { for (int i = 0; i < equipWashModel.washGroup3.Count; i++) { if (equipWashModel.washGroup3[i].XLAttrLV >= p_nextSpecModel.levelNeed) { curMasterCnt += 1; } } if(curMasterCnt >= 3) { washMasterCondText.text = StringUtility.Contact(Language.Get("EquipWash112", p_nextSpecModel.levelNeed), ":", UIHelper.GetTextColorByItemColor(TextColType.Green,curMasterCnt.ToString()), "/", 3); } else { washMasterCondText.text = StringUtility.Contact(Language.Get("EquipWash112", p_nextSpecModel.levelNeed), ":", UIHelper.GetTextColorByItemColor(TextColType.Red, curMasterCnt.ToString()), "/", 3); } } else { washMasterCondText.text = Language.Get("WashTips_SpecWashFull_3"); } for (int i = 0; i < fairyCelllist.Count; i++) { if(p_nextSpecModel != null) { fairyCelllist[i].SetModel(p_nextSpecModel.levelNeed); } else { fairyCelllist[i].SetModel(-1); } } break; default: DesignDebug.LogError("不存在此洗练群组" + equipWashModel.washType); break; } } private void GetWashGroupIncludeName(string key) { FuncConfigConfig washGroupMode = ConfigManager.Instance.GetTemplate(key); int[] grouplist = ConfigParse.GetMultipleStr(washGroupMode.Numerical1); areaText.text = Language.Get("EquipWash111"); if (grouplist.Length > 0) { for (int i = 0; i < grouplist.Length; i++) { if (i < grouplist.Length - 1) { areaText.text = areaText.text + UIHelper.GetEquipAreaName(grouplist[i]) + "、"; } else { areaText.text = areaText.text + UIHelper.GetEquipAreaName(grouplist[i]); } } } } //得到相邻的两个数 private void GetTwoAdjacentNumber(int minIndex, int maxIndex, int currentLevel) { p_preIndex = -1; p_nextIndex = -1; int minWashLevel = p_washSpeclist[minIndex].levelNeed; int maxWashLevel = p_washSpeclist[maxIndex].levelNeed; int sum = minWashLevel + maxWashLevel; int adjacentIndex = 0; if (sum != 0) { adjacentIndex = (int)((float)currentLevel / (minWashLevel + maxWashLevel) * p_washSpeclist.Count); } if (adjacentIndex < p_washSpeclist.Count) { for (int i = adjacentIndex; i > -1; i--) { if (p_washSpeclist[i].levelNeed <= currentLevel) { p_preIndex = i; break; } else { p_nextIndex = i; } } if (p_nextIndex == -1) { for (int i = adjacentIndex; i < p_washSpeclist.Count; i++) { if (p_washSpeclist[i].levelNeed >= currentLevel) { if (adjacentIndex != p_washSpeclist.Count - 1) { p_nextIndex = i; } break; } else { p_preIndex = i; } } } if (p_preIndex != -1 && p_nextIndex != -1) { if (p_preIndex == p_nextIndex) { p_nextIndex += 1; } } } else { p_preIndex = p_washSpeclist.Count - 1; p_nextIndex = -1; } } private void CloseWin() { CloseImmediately(); } } }