using System;
|
using System.Collections.Generic;
|
using TableConfig;
|
using UnityEngine;
|
using UnityEngine.UI;
|
using DG.Tweening;
|
using System.Collections;
|
|
namespace Snxxz.UI
|
{
|
public class WashMasterActiveWin : Window
|
{
|
[SerializeField] Image titleImg;
|
[SerializeField] UIAlphaTween titleAlphaTween;
|
[SerializeField] ScaleTween titleScaleTween;
|
[SerializeField] PositionTween leftPosTween;
|
[SerializeField] UIEffect leftEffect;
|
[SerializeField] WindowInfo windowInfo;
|
|
[Header("武器洗练大师")]
|
[SerializeField] GameObject weaponObj;
|
[Header("防具洗练大师")]
|
[SerializeField] GameObject defenceObj;
|
[Header("仙器洗练大师")]
|
[SerializeField] GameObject fairyObj;
|
|
[Header("洗练大师激活")]
|
[SerializeField] Transform activeParent;
|
[SerializeField] GameObject activeAttrObj;
|
[SerializeField] Text fightNumText;
|
[SerializeField] GameObject activeAttrCell;
|
[SerializeField] CalculateLayout activeLayout;
|
[Header("洗练大师升阶")]
|
[SerializeField] Transform raiseParent;
|
[SerializeField] GameObject raiseLvAttrObj;
|
[SerializeField] Text preLvText;
|
[SerializeField] Text curLvText;
|
[SerializeField] GameObject raiseAttrCell;
|
[SerializeField] CalculateLayout raiseLayout;
|
|
private List<EquipWashSpecConfig> washSpeclist = null;
|
List<GameObject> tempCelllist = new List<GameObject>();
|
EquipWashModel equipWashModel { get{ return ModelCenter.Instance.GetModel<EquipWashModel>();}}
|
|
Dictionary<int, int> curAttrDict = new Dictionary<int, int>();
|
Dictionary<int, int> preAttrDict = new Dictionary<int, int>();
|
int curFightNum = 0;
|
int preFightNum = 0;
|
|
protected override void BindController()
|
{
|
|
}
|
protected override void AddListeners()
|
{
|
|
}
|
|
protected override void OnPreOpen()
|
{
|
curFightNum = 0;
|
preFightNum = 0;
|
washSpeclist = null;
|
tempCelllist.Clear();
|
}
|
|
protected override void OnActived()
|
{
|
base.OnActived();
|
SetTitleUI();
|
}
|
protected override void OnAfterOpen()
|
{
|
StartCoroutine(CloseRayTarget());
|
}
|
|
protected override void OnPreClose()
|
{
|
for(int i = 0; i < tempCelllist.Count; i++)
|
{
|
DestroyObject(tempCelllist[i]);
|
}
|
}
|
|
protected override void OnAfterClose()
|
{
|
|
}
|
|
IEnumerator CloseRayTarget()
|
{
|
yield return null;
|
windowInfo.raycastTarget = false;
|
}
|
|
private void SetTitleUI()
|
{
|
activeAttrObj.SetActive(false);
|
raiseLvAttrObj.SetActive(false);
|
leftPosTween.gameObject.SetActive(false);
|
if (equipWashModel.MasterWashState == 1)
|
{
|
titleImg.SetSprite("UI_JH_10");
|
}
|
else if (equipWashModel.MasterWashState == 2)
|
{
|
titleImg.SetSprite("UI_JH_9");
|
}
|
|
titleAlphaTween.Play();
|
titleScaleTween.Play(SetLeftUI);
|
}
|
|
private void SetLeftUI()
|
{
|
GetEquipWashGroup();
|
leftPosTween.gameObject.SetActive(true);
|
leftEffect.Play();
|
leftPosTween.Play(SetRightUI);
|
}
|
|
private void SetRightUI()
|
{
|
washSpeclist = EquipWashSpecConfig.GetWashSpecModel(equipWashModel.washType);
|
curAttrDict.Clear();
|
preAttrDict.Clear();
|
for (int i = 0; i < washSpeclist.Count; i++)
|
{
|
if (washSpeclist[i].levelNeed == equipWashModel.washLv)
|
{
|
EquipWashSpecConfig curSpecConfig = washSpeclist[i];
|
int[] attrIds = ConfigParse.GetMultipleStr<int>(curSpecConfig.attByLevel);
|
int[] curAttrValues = ConfigParse.GetMultipleStr<int>(curSpecConfig.attByLevelValue);
|
for (int j = 0; j < attrIds.Length; j++)
|
{
|
curAttrDict.Add(attrIds[j], curAttrValues[j]);
|
}
|
curFightNum = UIHelper.GetFightPower(curAttrDict);
|
|
if (equipWashModel.MasterWashState == 1)
|
{
|
activeAttrObj.SetActive(true);
|
raiseLvAttrObj.SetActive(false);
|
fightNumText.text = curFightNum.ToString();
|
CreateActiveCell(washSpeclist[i]);
|
}
|
else if (equipWashModel.MasterWashState == 2)
|
{
|
activeAttrObj.SetActive(false);
|
raiseLvAttrObj.SetActive(true);
|
EquipWashSpecConfig preSpecConfig = washSpeclist[i - 1];
|
int[] preAttrValues = ConfigParse.GetMultipleStr<int>(preSpecConfig.attByLevelValue);
|
for (int j = 0; j < attrIds.Length; j++)
|
{
|
preAttrDict.Add(attrIds[j], preAttrValues[j]);
|
}
|
preFightNum = UIHelper.GetFightPower(preAttrDict);
|
preLvText.text = preSpecConfig.MasterLV.ToString();
|
curLvText.text = washSpeclist[i].MasterLV.ToString();
|
CreateRaiseCell(preSpecConfig, washSpeclist[i]);
|
}
|
break;
|
}
|
}
|
|
windowInfo.raycastTarget = true;
|
}
|
|
private void GetEquipWashGroup()
|
{
|
weaponObj.SetActive(false);
|
defenceObj.SetActive(false);
|
fairyObj.SetActive(false);
|
|
switch (equipWashModel.washType)
|
{
|
case 1:
|
weaponObj.SetActive(true);
|
break;
|
case 2:
|
defenceObj.SetActive(true);
|
break;
|
case 3:
|
fairyObj.SetActive(true);
|
break;
|
default:
|
DebugEx.LogError("不存在此洗练群组" + equipWashModel.washType);
|
break;
|
}
|
}
|
|
private void CreateActiveCell(EquipWashSpecConfig specConfig)
|
{
|
int[] attrIds = ConfigParse.GetMultipleStr<int>(specConfig.attByLevel);
|
int[] attrValues = ConfigParse.GetMultipleStr<int>(specConfig.attByLevelValue);
|
activeAttrCell.SetActive(false);
|
for (int i = 0; i < attrIds.Length; i++)
|
{
|
PlayerPropertyConfig propertyConfig = Config.Instance.Get<PlayerPropertyConfig>(attrIds[i]);
|
GameObject activeGo = Instantiate(activeAttrCell);
|
activeGo.SetActive(true);
|
activeGo.transform.SetParent(activeParent);
|
activeGo.transform.localScale = Vector3.one;
|
ActiveAttrCell activeCell = activeGo.GetComponent<ActiveAttrCell>();
|
activeCell.SetModel(attrIds[i], attrValues[i]);
|
tempCelllist.Add(activeGo);
|
}
|
activeLayout.Init(tempCelllist,true);
|
}
|
|
private void CreateRaiseCell(EquipWashSpecConfig preSpecConfig, EquipWashSpecConfig curSpecConfig)
|
{
|
int[] preAttrIds = ConfigParse.GetMultipleStr<int>(preSpecConfig.attByLevel);
|
int[] preAttrValues = ConfigParse.GetMultipleStr<int>(preSpecConfig.attByLevelValue);
|
int[] curAttrIds = ConfigParse.GetMultipleStr<int>(curSpecConfig.attByLevel);
|
int[] curAttrValues = ConfigParse.GetMultipleStr<int>(curSpecConfig.attByLevelValue);
|
raiseAttrCell.SetActive(false);
|
|
tempCelllist.Add(GetRaiseGo(Language.Get("MainInterfacePanel_HeadPortraitTip_ZL"),preFightNum.ToString(),(curFightNum-preFightNum).ToString()));
|
|
for (int i = 0; i < preAttrIds.Length; i++)
|
{
|
PlayerPropertyConfig propertyConfig = Config.Instance.Get<PlayerPropertyConfig>(preAttrIds[i]);
|
tempCelllist.Add(GetRaiseGo(propertyConfig.Name, GetProValueTypeStr(propertyConfig, preAttrValues[i]),GetProValueTypeStr(propertyConfig, curAttrValues[i]-preAttrValues[i])));
|
}
|
raiseLayout.Init(tempCelllist,true);
|
}
|
|
private GameObject GetRaiseGo(string nameStr,string preValue,string curValue)
|
{
|
GameObject raiseGo = Instantiate(raiseAttrCell);
|
raiseGo.SetActive(true);
|
raiseGo.transform.SetParent(raiseParent);
|
raiseGo.transform.localScale = Vector3.one;
|
RaiseAttrCell raisecell = raiseGo.GetComponent<RaiseAttrCell>();
|
raisecell.SetModel(nameStr,preValue,curValue);
|
return raiseGo;
|
}
|
|
public string GetProValueTypeStr(PlayerPropertyConfig playerproModel, int value)
|
{
|
string s = "";
|
if (playerproModel.ISPercentage == 0)
|
{
|
s = value.ToString();
|
}
|
else if (playerproModel.ISPercentage == 1)
|
{
|
s = (float)Math.Round(value / 100f, 1) + "%";
|
}
|
else if (playerproModel.ISPercentage == 2)
|
{
|
s = ((float)Math.Round(value / 100f, 1)).ToString();
|
}
|
return s;
|
}
|
}
|
}
|