|
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<WashMasterCell> weaponCelllist = new List<WashMasterCell>();
|
[Header("防具洗练大师")]
|
[SerializeField] GameObject defenceObj;
|
[SerializeField] List<WashMasterCell> defenceCelllist = new List<WashMasterCell>();
|
[Header("仙器洗练大师")]
|
[SerializeField] GameObject fairyObj;
|
[SerializeField] List<WashMasterCell> fairyCelllist = new List<WashMasterCell>();
|
|
[SerializeField] UIAlphaTween alphaTween;
|
[SerializeField] PositionTween posTween;
|
[SerializeField] CanvasGroup canvas;
|
[SerializeField] Text washMasterCondText;
|
|
protected List<EquipWashSpecConfig.EquipWashSpecData> p_washSpeclist = null;
|
private EquipWashSpecConfig.EquipWashSpecData p_currentSpecModel = null;
|
private EquipWashSpecConfig.EquipWashSpecData p_nextSpecModel = null;
|
private int p_preIndex = -1;
|
private int p_nextIndex = -1;
|
|
EquipWashModel _equipWashModel;
|
EquipWashModel equipWashModel
|
{
|
get
|
{
|
return _equipWashModel ?? (_equipWashModel = ModelCenter.Instance.GetModel<EquipWashModel>());
|
}
|
}
|
|
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.EquipWashSpecData model)
|
{
|
|
int[] openPro = model.activeIds;
|
int[] openProValue = model.activeValues;
|
List<PlayerPropertyConfig> proModellist = new List<PlayerPropertyConfig>();
|
List<string> proValuelist = new List<string>();
|
for (int i = 0; i < openPro.Length; i++)
|
{
|
PlayerPropertyConfig proModel = PlayerPropertyConfig.Get(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")
|
{
|
var preWashSpec = this.p_washSpeclist[p_preIndex].specConfig;
|
switch (equipWashModel.washType)
|
{
|
case 1:
|
targetNowText.text = Language.Get("EquipWash112", preWashSpec.levelNeed.ToString());
|
break;
|
case 2:
|
targetNowText.text = Language.Get("EquipWashMaster_2", preWashSpec.levelNeed.ToString());
|
break;
|
case 3:
|
targetNowText.text = Language.Get("EquipWashMaster_3", preWashSpec.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")
|
{
|
var nextWashSpec = this.p_washSpeclist[p_nextIndex].specConfig;
|
switch (equipWashModel.washType)
|
{
|
case 1:
|
targetNextText.text = Language.Get("EquipWash112", nextWashSpec.levelNeed.ToString());
|
break;
|
case 2:
|
targetNextText.text = Language.Get("EquipWashMaster_2", nextWashSpec.levelNeed.ToString());
|
break;
|
case 3:
|
targetNextText.text = Language.Get("EquipWashMaster_3", nextWashSpec.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.EquipWashSpecData model)
|
{
|
|
int[] openPro = model.activeIds;
|
int[] openProValue = model.activeValues;
|
List<PlayerPropertyConfig> proModellist = new List<PlayerPropertyConfig>();
|
List<string> proValuelist = new List<string>();
|
for (int i = 0; i < openPro.Length; i++)
|
{
|
PlayerPropertyConfig proModel = PlayerPropertyConfig.Get(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;
|
var washSpecData = this.p_washSpeclist[index];
|
switch (equipWashModel.washType)
|
{
|
case 1:
|
unTargetText.text = Language.Get("EquipWash112", washSpecData.specConfig.levelNeed.ToString());
|
break;
|
case 2:
|
unTargetText.text = Language.Get("EquipWashMaster_2", washSpecData.specConfig.levelNeed.ToString());
|
break;
|
case 3:
|
unTargetText.text = Language.Get("EquipWashMaster_3", washSpecData.specConfig.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(equipWashModel.washGroups1);
|
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.specConfig.levelNeed)
|
{
|
curMasterCnt += 1;
|
}
|
}
|
if (curMasterCnt >= 2)
|
{
|
washMasterCondText.text = StringUtility.Contact(Language.Get("EquipWash112", p_nextSpecModel.specConfig.levelNeed), ":", UIHelper.AppendStringColor(TextColType.Green, curMasterCnt.ToString()), "/", 2);
|
}
|
else
|
{
|
washMasterCondText.text = StringUtility.Contact(Language.Get("EquipWash112", p_nextSpecModel.specConfig.levelNeed), ":", UIHelper.AppendStringColor(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.specConfig.levelNeed);
|
}
|
else
|
{
|
weaponCelllist[i].SetModel(-1);
|
}
|
}
|
|
break;
|
case 2:
|
defenceObj.SetActive(true);
|
GetWashGroupIncludeName(equipWashModel.washGroups2);
|
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.specConfig.levelNeed)
|
{
|
curMasterCnt += 1;
|
}
|
}
|
if (curMasterCnt >= 5)
|
{
|
washMasterCondText.text = StringUtility.Contact(Language.Get("EquipWash112", p_nextSpecModel.specConfig.levelNeed), ":", UIHelper.AppendStringColor(TextColType.Green, curMasterCnt.ToString()), "/", 5);
|
}
|
else
|
{
|
washMasterCondText.text = StringUtility.Contact(Language.Get("EquipWash112", p_nextSpecModel.specConfig.levelNeed), ":", UIHelper.AppendStringColor(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.specConfig.levelNeed);
|
}
|
else
|
{
|
defenceCelllist[i].SetModel(-1);
|
}
|
|
}
|
break;
|
case 3:
|
fairyObj.SetActive(true);
|
GetWashGroupIncludeName(equipWashModel.washGroups3);
|
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.specConfig.levelNeed)
|
{
|
curMasterCnt += 1;
|
}
|
}
|
if(curMasterCnt >= 3)
|
{
|
washMasterCondText.text = StringUtility.Contact(Language.Get("EquipWash112", p_nextSpecModel.specConfig.levelNeed), ":", UIHelper.AppendStringColor(TextColType.Green,curMasterCnt.ToString()), "/", 3);
|
}
|
else
|
{
|
washMasterCondText.text = StringUtility.Contact(Language.Get("EquipWash112", p_nextSpecModel.specConfig.levelNeed), ":", UIHelper.AppendStringColor(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.specConfig.levelNeed);
|
}
|
else
|
{
|
fairyCelllist[i].SetModel(-1);
|
}
|
|
}
|
break;
|
default:
|
DebugEx.LogError("不存在此洗练群组" + equipWashModel.washType);
|
break;
|
}
|
}
|
|
private void GetWashGroupIncludeName(int[] groups)
|
{
|
if (groups == null) return;
|
|
areaText.text = Language.Get("EquipWash111");
|
if (groups.Length > 0)
|
{
|
for (int i = 0; i < groups.Length; i++)
|
{
|
if (i < groups.Length - 1)
|
{
|
areaText.text = areaText.text + UIHelper.GetEquipPlaceName(groups[i]) + "、";
|
}
|
else
|
{
|
areaText.text = areaText.text + UIHelper.GetEquipPlaceName(groups[i]);
|
}
|
|
}
|
}
|
|
}
|
|
//得到相邻的两个数
|
private void GetTwoAdjacentNumber(int minIndex, int maxIndex, int currentLevel)
|
{
|
p_preIndex = -1;
|
p_nextIndex = -1;
|
int minWashLevel = p_washSpeclist[minIndex].specConfig.levelNeed;
|
int maxWashLevel = p_washSpeclist[maxIndex].specConfig.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].specConfig.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].specConfig.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();
|
}
|
}
|
}
|