//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Thursday, March 14, 2019
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace vnxbqy.UI
|
{
|
|
public class EquipEvolutionWin : Window
|
{
|
// 强化大师界面
|
[SerializeField] Button m_EvolutionBtn;
|
[SerializeField] Text m_BtnText;
|
[SerializeField] Button m_CloseButton;
|
[SerializeField] RectTransform m_equipList;
|
[SerializeField] ScrollerController m_MasterAttrCtrl;
|
[SerializeField] RawImage m_RawRole;
|
[SerializeField] Text m_NewEeffectTip;
|
|
#region Built-in
|
EquipStrengthModel strengthModel { get { return ModelCenter.Instance.GetModel<EquipStrengthModel>(); } }
|
PackModel playerPack { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
|
EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
|
|
int activeMasterPlusLV = 0;
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
m_CloseButton.AddListener(() => { CloseImmediately(); });
|
m_EvolutionBtn.AddListener(OnClickEvolutionBtn);
|
}
|
|
bool isNewEffect = false;
|
|
protected override void OnPreOpen()
|
{
|
m_MasterAttrCtrl.OnRefreshCell += OnRefreshCell;
|
strengthModel.StrengthMasterFresh += Show;
|
//Text addText = m_AttributesText1.transform.Find("Number").GetComponent<Text>();
|
isNewEffect = false;
|
Show();
|
|
}
|
|
|
protected override void OnAfterOpen()
|
{
|
|
}
|
|
protected override void OnPreClose()
|
{
|
m_MasterAttrCtrl.OnRefreshCell -= OnRefreshCell;
|
strengthModel.StrengthMasterFresh -= Show;
|
}
|
|
|
|
protected override void OnAfterClose()
|
{
|
UI3DModelExhibition.Instance.StopShow();
|
}
|
#endregion
|
|
|
private void OnClickEvolutionBtn()
|
{
|
if (activeMasterPlusLV > 0)
|
SendActiveMaster();
|
else
|
CloseImmediately();
|
}
|
|
void DisplayPlayer()
|
{
|
m_NewEeffectTip.SetActive(isNewEffect);
|
m_RawRole.SetActive(true);
|
|
var appearance = equipModel.GetAppearance(strengthModel.SelectLevel);
|
UI3DModelExhibition.Instance.ShowPlayer(m_RawRole, new UI3DPlayerExhibitionData()
|
{
|
job = PlayerDatas.Instance.baseData.Job,
|
clothesId = appearance.clothes,
|
weaponId = appearance.weapon,
|
secondaryId = appearance.secondary,
|
keepRotation = false,
|
reikiRootEffectId = strengthModel.GetMasterLV(strengthModel.SelectLevel),
|
suitLevel = appearance.isSuit ? 1 : 0,
|
equipLevel = strengthModel.SelectLevel,
|
});
|
|
isNewEffect = true;
|
}
|
private void Show()
|
{
|
var masterInfo = ItemPlusMasterConfig.TryGetNextMaster(strengthModel.SelectLevel, strengthModel.GetMasterLV(strengthModel.SelectLevel));
|
int masterPlusLV = (masterInfo != null) ? masterInfo.MasterPlusLV : 0;
|
|
for (int i = 1; i <= 8; i++)
|
{
|
var plusLV = strengthModel.GetStrengthLevelByColor(strengthModel.SelectLevel, i);
|
//m_equipList
|
Text plusLvText = m_equipList.transform.Find("Img_Icon" + i).Find("Text").GetComponent<Text>();
|
plusLvText.text = UIHelper.AppendColor(plusLV >= masterPlusLV ? TextColType.DarkGreen:TextColType.Gray, "+" + plusLV, true);
|
Image light = m_equipList.transform.Find("Img_Icon" + i).Find("Img_Icon").GetComponent<Image>();
|
light.SetActive(plusLV >= masterPlusLV ? true: false);
|
}
|
CreateScroll();
|
RefreshButton();
|
|
DisplayPlayer();
|
}
|
|
private void CreateScroll()
|
{
|
int i = 0;
|
m_MasterAttrCtrl.Refresh();
|
var curMasterLV = strengthModel.GetMasterLV(strengthModel.SelectLevel);
|
int jumpIndex = -1;
|
foreach (var items in ItemPlusMasterConfig.GetMasters(strengthModel.SelectLevel))
|
{
|
CellInfo info = new CellInfo();
|
info.infoInt1 = items.Key;
|
m_MasterAttrCtrl.AddCell(ScrollerDataType.Header, i, info);
|
if (jumpIndex == -1 && curMasterLV < items.Key)
|
{
|
jumpIndex = Math.Max(i - 2, 0);
|
}
|
i++;
|
}
|
m_MasterAttrCtrl.Restart();
|
m_MasterAttrCtrl.JumpIndex(jumpIndex);
|
}
|
|
private void OnRefreshCell(ScrollerDataType type, CellView cell)
|
{
|
if (type == ScrollerDataType.Header)
|
{
|
var masterCell = cell as EquipStrengthMasterCell;
|
int plusLV = masterCell.info.Value.infoInt1;
|
masterCell.ShowMasterAttr(strengthModel.SelectLevel, plusLV);
|
}
|
|
}
|
|
private void RefreshButton()
|
{
|
//activeMasterPlusLV
|
|
var curMasterLV = strengthModel.GetMasterLV(strengthModel.SelectLevel);
|
var masterInfo = ItemPlusMasterConfig.TryGetNextMaster(strengthModel.SelectLevel, curMasterLV);
|
|
bool canBright = false;
|
if (masterInfo != null && (strengthModel.GetStrengthMinLV(strengthModel.SelectLevel) >= masterInfo.MasterPlusLV))
|
canBright = true;
|
|
if (canBright)
|
activeMasterPlusLV = masterInfo.MasterPlusLV;
|
else
|
activeMasterPlusLV = 0;
|
m_BtnText.text = canBright ? Language.Get("Z2004"): Language.Get("RuneTowerSweepText12");
|
}
|
|
public void SendActiveMaster()
|
{
|
CA5C7_tagCMActivateMasterPlusLV CA5C7 = new CA5C7_tagCMActivateMasterPlusLV();
|
CA5C7.ClassLV = (byte)strengthModel.SelectLevel;
|
CA5C7.MasterPlusLV = (ushort)activeMasterPlusLV;
|
|
GameNetSystem.Instance.SendInfo(CA5C7);
|
}
|
}
|
|
|
}
|
|
|
|
|