using System;
|
using System.Collections.Generic;
|
|
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.EquipWashSpecData> 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++)
|
{
|
var washSpecData = washSpeclist[i];
|
if (washSpecData.specConfig.levelNeed == equipWashModel.washLv)
|
{
|
int[] attrIds = washSpecData.activeIds;
|
int[] curAttrValues = washSpecData.activeValues;
|
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);
|
var preWashSpecData = washSpeclist[i - 1];
|
int[] preAttrValues = preWashSpecData.activeValues;
|
for (int j = 0; j < attrIds.Length; j++)
|
{
|
preAttrDict.Add(attrIds[j], preAttrValues[j]);
|
}
|
preFightNum = UIHelper.GetFightPower(preAttrDict);
|
preLvText.text = preWashSpecData.specConfig.MasterLV.ToString();
|
curLvText.text = washSpecData.specConfig.MasterLV.ToString();
|
CreateRaiseCell(preWashSpecData,washSpecData);
|
}
|
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.EquipWashSpecData specConfig)
|
{
|
int[] attrIds = specConfig.activeIds;
|
int[] attrValues = specConfig.activeValues;
|
activeAttrCell.SetActive(false);
|
for (int i = 0; i < attrIds.Length; i++)
|
{
|
PlayerPropertyConfig propertyConfig = PlayerPropertyConfig.Get(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.EquipWashSpecData preSpecConfig, EquipWashSpecConfig.EquipWashSpecData curSpecConfig)
|
{
|
int[] preAttrIds = preSpecConfig.activeIds;
|
int[] preAttrValues = preSpecConfig.activeValues;
|
int[] curAttrIds = curSpecConfig.activeIds;
|
int[] curAttrValues = curSpecConfig.activeValues;
|
raiseAttrCell.SetActive(false);
|
|
tempCelllist.Add(GetRaiseGo(Language.Get("L1056"),preFightNum.ToString(),(curFightNum-preFightNum).ToString()));
|
|
for (int i = 0; i < preAttrIds.Length; i++)
|
{
|
PlayerPropertyConfig propertyConfig = PlayerPropertyConfig.Get(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;
|
}
|
}
|
}
|