using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
using System.Collections;
|
using System.Linq;
|
using System.Text;
|
using Snxxz.UI;
|
using System;
|
using Snxxz;
|
|
public class EquipSuitTips : MonoBehaviour
|
{
|
#region 属性
|
|
[SerializeField] private Transform _suitCellParent;
|
[SerializeField] private Button _equipMaker; //装备锻造
|
[SerializeField] private Button splitBtn; //拆解套装
|
[SerializeField] private Transform _equipParent;
|
[SerializeField] private Transform _material1Parent;
|
[SerializeField] private Transform _material2Parent;
|
[SerializeField] private Transform _material3Parent;
|
[SerializeField] private Text _makerSuitName;
|
[SerializeField] private Text _makerSuitNumber;
|
[SerializeField] private Text _needConditionText;
|
[SerializeField] private GameObject _armorSuitGo;
|
[SerializeField] private GameObject _equipSuitGo;
|
|
[SerializeField] private Button _previewBtn;
|
[SerializeField] private ScrollerController _equipSuitCtrl;
|
[SerializeField] private ScrollRect _suitCellRect;
|
[SerializeField] private ScrollerController _suitProCtrl;
|
[SerializeField] UIEffect oneMatEffect;
|
[SerializeField] UIEffect twoMatEffect;
|
[SerializeField] UIEffect threeMatEffect;
|
[SerializeField] UIEffect makeSuccessEffect;
|
[SerializeField] UIEffect makerEquipEffect;
|
[SerializeField] SuitTypeSwitchBtn swichBtn;
|
[SerializeField] GameObject maxSuitLvObj;
|
[SerializeField] GameObject makerMatlistObj;
|
[SerializeField] Text upgradeLvText;
|
#endregion
|
|
#region 数据
|
private List<int> equipPartlist;
|
private EquipSuitAttrConfig _equipSuitProModel;
|
private EquipSuitCompoundConfig _equipSuitMatModel;
|
private List<Transform> _materialPoslist = new List<Transform>();
|
|
HowToPlayModel _toPlayModel;
|
HowToPlayModel toPlayModel
|
{
|
get { return _toPlayModel ?? (_toPlayModel = ModelCenter.Instance.GetModel<HowToPlayModel>()); }
|
}
|
|
PlayerSuitModel _suitModel;
|
PlayerSuitModel SuitModel
|
{
|
get { return _suitModel ?? (_suitModel = ModelCenter.Instance.GetModel<PlayerSuitModel>()); }
|
}
|
|
|
GetItemPathModel _itemPathModel;
|
GetItemPathModel itemPathModel
|
{
|
get { return _itemPathModel ?? (_itemPathModel = ModelCenter.Instance.GetModel<GetItemPathModel>()); }
|
}
|
|
|
ItemTipsModel _itemTipsModel;
|
ItemTipsModel itemTipsModel
|
{
|
get
|
{
|
return _itemTipsModel ?? (_itemTipsModel = ModelCenter.Instance.GetModel<ItemTipsModel>());
|
}
|
}
|
|
PackModel _playerPack;
|
PackModel playerPack
|
{
|
get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PackModel>()); }
|
}
|
|
private int presentIndex; //用于记录当前选项
|
private string suitId;
|
public static SuitType E_SuitType = SuitType.LowSuit;
|
public int equipPlace = 0;
|
public int curSuitLv = 0;
|
private bool firstOpen = true;
|
[SerializeField] float offest = 50;
|
#endregion
|
|
private int redEquipPlace = 0;
|
AchievementGuideEffect guideEffect = null;
|
|
private void OnEnable()
|
{
|
guideEffect = null;
|
swichBtn.switchBtn.AddListener(OnClickSwitchBtn);
|
_previewBtn.onClick.AddListener(OnClickPreViewBtn);
|
_equipSuitCtrl.OnRefreshCell += RefreshEquipSuitCell;
|
_suitProCtrl.OnRefreshCell += RefreshSuitProCell;
|
DTC0721_tagMakeItemAnswer.MakeItemAnswerEvent += GetMakeResult;
|
//_equipSuitCtrl.lockType = EnhanceLockType.KeepVertical;
|
SuitModel.RefreshSuitModelAct += CreateEquipSuitCell;
|
_materialPoslist.Clear();
|
_materialPoslist.Add(_material1Parent);
|
_materialPoslist.Add(_material2Parent);
|
_materialPoslist.Add(_material3Parent);
|
firstOpen = true;
|
CheckJumpToModel();
|
}
|
|
private void OnDisable()
|
{
|
swichBtn.switchBtn.RemoveAllListeners();
|
_previewBtn.onClick.RemoveAllListeners();
|
_equipSuitCtrl.OnRefreshCell -= RefreshEquipSuitCell;
|
_suitProCtrl.OnRefreshCell -= RefreshSuitProCell;
|
DTC0721_tagMakeItemAnswer.MakeItemAnswerEvent -= GetMakeResult;
|
SuitModel.RefreshSuitModelAct -= CreateEquipSuitCell;
|
SuitModel.ClearJumpModel();
|
E_SuitType = SuitType.LowSuit;
|
int equipPlace = 0;
|
SuitModel.CheckRedPointCondition(out equipPlace);
|
SuitModel.CheckTypeBtnRedPointCondition();
|
AchievementGoto.guideAchievementId = 0;
|
}
|
|
private void CheckJumpToModel()
|
{
|
SuccessConfig successConfig = SuccessConfig.Get(AchievementGoto.guideAchievementId);
|
if (successConfig != null && successConfig.Type == 92)
|
{
|
AchievementGoto.guideAchievementId = 0;
|
E_SuitType = SuitModel.jumpToSuitType;
|
}
|
else
|
{
|
if(!WindowJumpMgr.Instance.IsJumpState)
|
{
|
E_SuitType = SuitType.LowSuit;
|
bool isSwitch = true;
|
foreach (var red in SuitModel.suitCellRedPointDict.Values)
|
{
|
if (red.state == RedPointState.Simple)
|
{
|
isSwitch = false;
|
break;
|
}
|
}
|
if (SuitModel.typeBtnRedPoint.state == RedPointState.Simple && isSwitch)
|
{
|
E_SuitType = SuitType.HighSuit;
|
}
|
}
|
}
|
equipPartlist = SuitModel.GetEquipOrderlist(E_SuitType);
|
CreateEquipSuitCell();
|
StartCoroutine(SetOffestPos());
|
}
|
|
private void CreateEquipSuitCell()
|
{
|
int equipPlace = 0;
|
SuitModel.CheckRedPointCondition(out equipPlace);
|
if (_equipSuitCtrl.GetNumberOfCells(_equipSuitCtrl.m_Scorller) > 0)
|
{
|
_equipSuitCtrl.m_Scorller.RefreshActiveCellViews();
|
}
|
else
|
{
|
_equipSuitCtrl.Refresh();
|
for (int i = 0; i < equipPartlist.Count; i++)
|
{
|
_equipSuitCtrl.AddCell(ScrollerDataType.Header, i);
|
}
|
_equipSuitCtrl.Restart();
|
}
|
ChooseSuitCell();
|
SuitModel.CheckTypeBtnRedPointCondition();
|
}
|
|
private IEnumerator SetOffestPos()
|
{
|
yield return null;
|
redEquipPlace = 0;
|
int equipPlace = 0;
|
SuitModel.CheckRedPointCondition(out equipPlace);
|
int index = 0;
|
for (int i = 0; i < equipPartlist.Count; i++)
|
{
|
if (equipPlace == equipPartlist[i])
|
{
|
redEquipPlace = equipPlace;
|
index = i;
|
if(SuitModel.jumpToGroupType != 0)
|
{
|
guideEffect = AchievementGuideEffectPool.Require(1);
|
guideEffect.transform.SetParentEx(_equipMaker.transform, Vector3.zero, Quaternion.identity, Vector3.one);
|
}
|
break;
|
}
|
}
|
presentIndex = index;
|
_equipSuitCtrl.JumpIndex(index);
|
_equipSuitCtrl.m_Scorller.RefreshActiveCellViews();
|
ChooseSuitCell();
|
yield return null;
|
if (presentIndex != 0)
|
{
|
_equipSuitCtrl.JumpIndex(-offest, 0, EnhancedUI.EnhancedScroller.EnhancedScroller.TweenType.immediate);
|
}
|
}
|
|
private void ChooseSuitCell()
|
{
|
int realSuitLv = 0;
|
ItemModel itemModel = playerPack.GetItemByIndex(PackType.Equip, equipPartlist[presentIndex]);
|
int suitLv = SuitModel.GetServerSuitLv(equipPartlist[presentIndex], (int)E_SuitType);
|
if (itemModel != null)
|
{
|
bool isMaker = SuitModel.IsMakerSuit(E_SuitType, itemModel.config.ItemColor, itemModel.config.StarLevel);
|
realSuitLv = suitLv;
|
switch (E_SuitType)
|
{
|
case SuitType.LowSuit:
|
if (!isMaker)
|
{
|
realSuitLv = 0;
|
}
|
else
|
{
|
if (suitLv != 0)
|
{
|
if (suitLv > itemModel.config.LV)
|
{
|
realSuitLv = itemModel.config.LV;
|
}
|
}
|
}
|
break;
|
case SuitType.HighSuit:
|
int lowSuitLv = SuitModel.GetServerSuitLv(equipPartlist[presentIndex], (int)SuitType.LowSuit);
|
if (!isMaker)
|
{
|
realSuitLv = 0;
|
}
|
else
|
{
|
if (suitLv != 0)
|
{
|
if (suitLv > itemModel.config.LV)
|
{
|
realSuitLv = itemModel.config.LV;
|
}
|
}
|
}
|
break;
|
}
|
}
|
|
OnClickSuitCell(realSuitLv,presentIndex);
|
|
}
|
|
private void RefreshEquipSuitCell(ScrollerDataType type, CellView cell)
|
{
|
EquipSuitCell suitCell = cell.GetComponent<EquipSuitCell>();
|
int equipPlace = equipPartlist[cell.index];
|
int suitLv = SuitModel.GetServerSuitLv(equipPlace, (int)E_SuitType);
|
if (suitCell != null)
|
{
|
suitCell.SetDisplayModel(SuitModel.suitCellRedPointDict[equipPlace].id,equipPlace,E_SuitType,presentIndex);
|
}
|
|
suitCell.suitCellToggle.RemoveAllListeners();
|
suitCell.suitCellToggle.AddListener(()=>{
|
OnClickSuitCell(suitLv, cell.index);
|
});
|
}
|
|
private void OnClickSuitCell(int realSuitLv,int index)
|
{
|
presentIndex = index;
|
curSuitLv = realSuitLv;
|
equipPlace = equipPartlist[index];
|
ControllerShowMidUI(equipPlace, realSuitLv);
|
ControllerShowRightUI(equipPlace,realSuitLv);
|
ItemModel itemModel = playerPack.GetItemByIndex(PackType.Equip, equipPlace);
|
|
if(equipPlace != redEquipPlace)
|
{
|
if(guideEffect != null)
|
{
|
AchievementGuideEffectPool.Recycle(guideEffect);
|
guideEffect = null;
|
SuitModel.ClearJumpModel();
|
}
|
}
|
|
if(itemModel == null)
|
{
|
ChangeMakerBtnState(false, Language.Get("EquipSuit_Cannot"));
|
}
|
else
|
{
|
bool isMaker = SuitModel.IsMakerSuit(E_SuitType, itemModel.config.ItemColor, itemModel.config.StarLevel);
|
if(!isMaker)
|
{
|
ChangeMakerBtnState(false, Language.Get("EquipSuit_Cannot"));
|
}
|
else
|
{
|
if(SuitModel.IsUpgradSuitLv(equipPartlist[index],(int)E_SuitType,realSuitLv))
|
{
|
switch (E_SuitType)
|
{
|
case SuitType.LowSuit:
|
ChangeMakerBtnState(true, Language.Get("EquipSuitPanel_SmithTxt_1"));
|
break;
|
case SuitType.HighSuit:
|
ChangeMakerBtnState(true, Language.Get("EquipSuitPanel_SmithTxt_2"));
|
break;
|
}
|
}
|
else
|
{
|
switch (E_SuitType)
|
{
|
case SuitType.LowSuit:
|
ChangeMakerBtnState(false, Language.Get("EquipSuit_Finished"));
|
break;
|
case SuitType.HighSuit:
|
bool isReachMax = SuitModel.IsReachMax(equipPartlist[index],(int)SuitType.HighSuit,realSuitLv);
|
if(!isReachMax
|
&& SuitModel.GetServerSuitLv(equipPartlist[index], (int)SuitType.LowSuit) <= SuitModel.GetServerSuitLv(equipPartlist[index], (int)SuitType.HighSuit))
|
{
|
ChangeMakerBtnState(false, Language.Get("EquipSuit_Cannot"));
|
}
|
else
|
{
|
ChangeMakerBtnState(false, Language.Get("EquipSuit_Finished"));
|
}
|
break;
|
}
|
|
}
|
}
|
}
|
|
int serverSuitLv = SuitModel.GetServerSuitLv(equipPlace,(int)E_SuitType);
|
if(serverSuitLv > 0)
|
{
|
splitBtn.gameObject.SetActive(true);
|
splitBtn.RemoveAllListeners();
|
splitBtn.AddListener(()=>
|
{
|
switch (E_SuitType)
|
{
|
case SuitType.LowSuit:
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("EquipSuitSplit101", UIHelper.GetEquipPlaceName(equipPlace)),
|
(bool isOk) =>
|
{
|
if (isOk)
|
{
|
SuitModel.SendSplitSuit(equipPlace,E_SuitType);
|
}
|
});
|
break;
|
case SuitType.HighSuit:
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("EquipSuitSplit102", UIHelper.GetEquipPlaceName(equipPlace)),
|
(bool isOk) =>
|
{
|
if (isOk)
|
{
|
SuitModel.SendSplitSuit(equipPlace, E_SuitType);
|
}
|
});
|
break;
|
}
|
|
});
|
}
|
else
|
{
|
splitBtn.gameObject.SetActive(false);
|
}
|
|
_equipSuitCtrl.m_Scorller.RefreshActiveCellViews();
|
}
|
|
public void ChangeMakerBtnState(bool isClick, string btnDes)
|
{
|
Text btnText = _equipMaker.transform.Find("SmithTxt").GetComponent<Text>();
|
Image btnIcon = _equipMaker.GetComponent<Image>();
|
btnText.text = btnDes;
|
_equipMaker.RemoveAllListeners();
|
if (isClick)
|
{
|
_equipMaker.interactable = true;
|
_equipMaker.onClick.AddListener(OnClickEquipMaker);
|
btnIcon.SetSprite("CanUseBtn");
|
}
|
else
|
{
|
_equipMaker.interactable = false;
|
btnIcon.SetSprite("BlackBtn_a");
|
}
|
}
|
|
public void IsLockGridCell(bool islock, GameObject go)
|
{
|
|
GameObject itemCell = go.transform.Find("ItemCell").gameObject;
|
GameObject gridLock = go.transform.Find("GridLock").gameObject;
|
GameObject lockBg = go.transform.Find("ItemBG").gameObject;
|
if (islock)
|
{
|
itemCell.SetActive(false);
|
gridLock.SetActive(true);
|
lockBg.SetActive(true);
|
}
|
else
|
{
|
itemCell.SetActive(true);
|
gridLock.SetActive(false);
|
lockBg.SetActive(false);
|
}
|
|
}
|
|
public void ControllerShowMidUI(int equipPlace,int realSuitLv)
|
{
|
swichBtn.SetInit(E_SuitType);
|
GameObject equipGridCell = _equipParent.transform.Find("GridCell").gameObject;
|
GameObject mater1GridCell = _material1Parent.transform.Find("GridCell").gameObject;
|
GameObject mater2GridCell = _material2Parent.transform.Find("GridCell").gameObject;
|
GameObject mater3GridCell = _material3Parent.transform.Find("GridCell").gameObject;
|
maxSuitLvObj.SetActive(false);
|
makerMatlistObj.SetActive(true);
|
|
if (makerEquipEffect.IsPlaying)
|
{
|
makerEquipEffect.StopImediatly();
|
}
|
ItemModel itemModel = playerPack.GetItemByIndex(PackType.Equip,equipPlace);
|
|
if (itemModel == null)
|
{
|
IsLockGridCell(true, equipGridCell);
|
IsLockGridCell(true, mater1GridCell);
|
IsLockGridCell(true, mater2GridCell);
|
IsLockGridCell(true, mater3GridCell);
|
}
|
else
|
{
|
IsLockGridCell(false, equipGridCell);
|
ItemCell itemCell = equipGridCell.transform.Find("ItemCell").GetComponent<ItemCell>();
|
//pdr ToDo
|
itemCell.Init(itemModel);
|
itemCell.cellBtn.RemoveAllListeners();
|
itemCell.cellBtn.AddListener(() =>
|
{
|
itemTipsModel.SetItemTipsModel(PackType.Equip,itemModel.guid);
|
});
|
bool isMaker = SuitModel.IsMakerSuit(E_SuitType,itemModel.config.ItemColor,itemModel.config.StarLevel);
|
if(E_SuitType == SuitType.HighSuit)
|
{
|
if (isMaker)
|
{
|
if (!makerEquipEffect.IsPlaying)
|
{
|
makerEquipEffect.Play();
|
}
|
}
|
}
|
|
if(SuitModel.IsNeedUpgradEquipLv(equipPlace,(int)E_SuitType))
|
{
|
maxSuitLvObj.SetActive(true);
|
makerMatlistObj.SetActive(false);
|
upgradeLvText.text = Language.Get("EquipSuitUpgradLv",itemModel.config.LV + 1);
|
}
|
else
|
{
|
int suitLv = SuitModel.GetServerSuitLv(equipPlace,(int)E_SuitType);
|
if (SuitModel.IsReachMax(equipPlace, (int)E_SuitType,suitLv))
|
{
|
maxSuitLvObj.SetActive(true);
|
makerMatlistObj.SetActive(false);
|
upgradeLvText.text = Language.Get("NewEquipSuitFull");
|
}
|
}
|
|
#region 材料UI的显示
|
_equipSuitMatModel = EquipSuitCompoundConfig.GetMakerEquipSuitMatModel((int)E_SuitType, equipPlace,SuitModel.GetServerSuitLv(equipPlace,(int)E_SuitType) + 1, SuitModel.GetEquipJob(itemModel.itemId));
|
if (_equipSuitMatModel == null || !SuitModel.IsUpgradSuitLv(equipPlace,(int)E_SuitType,curSuitLv))
|
{
|
IsLockGridCell(true, mater1GridCell);
|
IsLockGridCell(true, mater2GridCell);
|
IsLockGridCell(true, mater3GridCell);
|
return;
|
}
|
|
int materIndex = 0;
|
for (materIndex = 0; materIndex < _materialPoslist.Count; materIndex++)
|
{
|
GameObject matGridCell = _materialPoslist[materIndex].transform.Find("GridCell").gameObject;
|
ItemCell materItemCell = _materialPoslist[materIndex].transform.Find("GridCell/ItemCell").GetComponent<ItemCell>();
|
Text materCount = materItemCell.transform.Find("CountText").GetComponent<Text>();
|
if(isMaker)
|
{
|
if (materIndex < _equipSuitMatModel.CostItemID.Length)
|
{
|
IsLockGridCell(false, matGridCell);
|
int itemid = _equipSuitMatModel.CostItemID[materIndex];
|
ItemCellModel cellModel = new ItemCellModel(itemid);
|
materItemCell.Init(cellModel);
|
materItemCell.cellBtn.RemoveAllListeners();
|
materItemCell.cellBtn.AddListener(() =>
|
{
|
itemPathModel.SetChinItemModel(itemid);
|
});
|
|
materCount.gameObject.SetActive(true);
|
int haveCount = playerPack.GetItemCountByID(PackType.Item, _equipSuitMatModel.CostItemID[materIndex]);
|
if (haveCount >= _equipSuitMatModel.CostItemCnt[materIndex])
|
{
|
materCount.text = StringUtility.Contact(UIHelper.AppendStringColor(TextColType.Green, haveCount.ToString(), true), "/", _equipSuitMatModel.CostItemCnt[materIndex]);
|
}
|
else
|
{
|
materCount.text = StringUtility.Contact(UIHelper.AppendStringColor(TextColType.Red, haveCount.ToString()), "/", _equipSuitMatModel.CostItemCnt[materIndex]);
|
}
|
}
|
else
|
{
|
IsLockGridCell(true, matGridCell);
|
}
|
}
|
else
|
{
|
IsLockGridCell(true, matGridCell);
|
}
|
}
|
#endregion
|
|
}
|
|
}
|
|
public void ControllerShowRightUI(int equipPlace, int realSuitLv)
|
{
|
_needConditionText.gameObject.SetActive(true);
|
ItemModel itemModel = playerPack.GetItemByIndex(PackType.Equip,equipPlace);
|
switch (E_SuitType)
|
{
|
case SuitType.LowSuit:
|
_needConditionText.text = Language.Get("SuitPanel_FourStage");
|
break;
|
case SuitType.HighSuit:
|
_needConditionText.text = Language.Get("EquipSuit_Honghuang");
|
break;
|
}
|
if (itemModel != null)
|
{
|
bool isMaker = SuitModel.IsMakerSuit(E_SuitType, itemModel.config.ItemColor, itemModel.config.StarLevel);
|
if (isMaker)
|
{
|
_equipSuitGo.gameObject.SetActive(true);
|
_armorSuitGo.gameObject.SetActive(true);
|
List<int> equipPlacelist = null;
|
int previewSuitLv = realSuitLv;
|
if (realSuitLv <= 0)
|
{
|
previewSuitLv += 1;
|
}
|
curSuitNum = SuitModel.GetSameSuitCnt(E_SuitType, equipPlace, previewSuitLv, out equipPlacelist);
|
var suitAttrData = EquipSuitAttrConfig.GetSuitAttrData(SuitModel.GetGroupType(equipPlace)
|
, (int)E_SuitType, previewSuitLv, SuitModel.GetEquipJob(itemModel.itemId));
|
EquipSuitAttrConfig attrConfig = suitAttrData == null ? null : suitAttrData.attrConfig;
|
|
if(attrConfig != null)
|
{
|
_makerSuitName.text = StringUtility.Contact(Language.Get("KnapS143"),":");
|
_makerSuitNumber.text = StringUtility.Contact(curSuitNum, "/", attrConfig.count3);
|
}
|
|
OnGetSuitProValue(attrConfig);
|
_needConditionText.gameObject.SetActive(false);
|
}
|
else
|
{
|
_equipSuitGo.gameObject.SetActive(false);
|
_armorSuitGo.gameObject.SetActive(false);
|
}
|
}
|
else
|
{
|
_equipSuitGo.gameObject.SetActive(false);
|
_armorSuitGo.gameObject.SetActive(false);
|
}
|
}
|
|
private int[] firstProlist = null;
|
private int[] firstProValuelist = null;
|
private int[] secondProlist = null;
|
private int[] secondProValuelist = null;
|
private int[] thirdProlist = null;
|
private int[] thirdProValuelist = null;
|
|
public void OnGetSuitProValue(EquipSuitAttrConfig attrConfig)
|
{
|
if (attrConfig == null)
|
return;
|
|
_equipSuitProModel = attrConfig;
|
string key = StringUtility.Contact(attrConfig.groupType, attrConfig.suiteType, attrConfig.suiteLV,attrConfig.job);
|
var attrData = EquipSuitAttrConfig.GetSuitAttrDataBySuitID(key);
|
firstProlist = attrData.attr1Ids;
|
firstProValuelist = attrData.attr1Values;
|
secondProlist = attrData.attr2Ids;
|
secondProValuelist = attrData.attr2Values;
|
thirdProlist = attrData.attr3Ids;
|
thirdProValuelist = attrData.attr3Values;
|
CreateSuitProCell();
|
}
|
|
private int length1 = 0;
|
private int length2 = 0;
|
private int length3 = 0;
|
private int curSuitNum = 0;
|
|
private void CreateSuitProCell()
|
{
|
_suitProCtrl.Refresh();
|
int i = 0;
|
length1 = firstProlist.Length;
|
for (i = 0; i < length1; i++)
|
{
|
_suitProCtrl.AddCell(ScrollerDataType.Header, i);
|
}
|
_suitProCtrl.AddCell(ScrollerDataType.Normal, length1);
|
length2 = length1 + secondProlist.Length + 1;
|
for (i = length1 + 1; i < length2; i++)
|
{
|
_suitProCtrl.AddCell(ScrollerDataType.Header, i);
|
}
|
_suitProCtrl.AddCell(ScrollerDataType.Normal, length2);
|
length3 = length2 + thirdProlist.Length + 1;
|
for (i = length2 + 1; i < length3; i++)
|
{
|
_suitProCtrl.AddCell(ScrollerDataType.Header, i);
|
}
|
_suitProCtrl.Restart();
|
}
|
|
private void RefreshSuitProCell(ScrollerDataType type, CellView cell)
|
{
|
if (type != ScrollerDataType.Header) return;
|
|
Text curNum = cell.transform.Find("FirstSuitATT").GetComponent<Text>();
|
Text curPro = cell.transform.Find("ATTNum").GetComponent<Text>();
|
Text curProName = cell.transform.Find("ATTTxt").GetComponent<Text>();
|
|
if (cell.index == 0)
|
{
|
curNum.text = Language.Get("EquipSuit111", _equipSuitProModel.count1.ToString());
|
curNum.gameObject.SetActive(true);
|
}
|
else if (cell.index == length1 + 1)
|
{
|
curNum.text = Language.Get("EquipSuit111", _equipSuitProModel.count2.ToString());
|
curNum.gameObject.SetActive(true);
|
}
|
else if (cell.index == length2 + 1)
|
{
|
curNum.text = Language.Get("EquipSuit111", _equipSuitProModel.count3.ToString());
|
curNum.gameObject.SetActive(true);
|
}
|
else
|
{
|
curNum.gameObject.SetActive(false);
|
}
|
|
PlayerPropertyConfig playerproModel = null;
|
if (cell.index < length1)
|
{
|
playerproModel = PlayerPropertyConfig.Get(firstProlist[cell.index]);
|
if (playerproModel != null)
|
{
|
curProName.text = playerproModel.Name;
|
curPro.text = StringUtility.Contact("+", GetProValueTypeStr(playerproModel, firstProValuelist[cell.index]));
|
}
|
|
ChangeSuitProTextColor(curNum, curPro, curProName, _equipSuitProModel.count1);
|
}
|
|
else if (cell.index >= length1 + 1 && cell.index < length2)
|
{
|
|
playerproModel = PlayerPropertyConfig.Get(secondProlist[cell.index - length1 -1]);
|
if (playerproModel != null)
|
{
|
curProName.text = playerproModel.Name;
|
curPro.text = StringUtility.Contact("+", GetProValueTypeStr(playerproModel, secondProValuelist[cell.index - length1 - 1]));
|
}
|
ChangeSuitProTextColor(curNum, curPro, curProName, _equipSuitProModel.count2);
|
}
|
|
else if (cell.index >= length2 + 1 && cell.index < length3)
|
{
|
playerproModel = PlayerPropertyConfig.Get(thirdProlist[cell.index - length2 - 1]);
|
if (playerproModel != null)
|
{
|
curProName.text = playerproModel.Name;
|
curPro.text = StringUtility.Contact("+", GetProValueTypeStr(playerproModel, thirdProValuelist[cell.index - length2 - 1]));
|
}
|
ChangeSuitProTextColor(curNum, curPro, curProName, _equipSuitProModel.count3);
|
}
|
}
|
|
private void ChangeSuitProTextColor(Text num, Text pro, Text proName, int needSuitNum)
|
{
|
string nameStr = GetSuitNameByName(proName.text);
|
if (curSuitNum >= needSuitNum)
|
{
|
num.text = StringUtility.Contact("<color=#109D06FF>", num.text, "</color>");
|
pro.text = StringUtility.Contact("<color=#109D06FF> ", pro.text, "</color>");
|
proName.text = StringUtility.Contact("<color=#109D06FF>", nameStr, "</color>");
|
|
}
|
else
|
{
|
num.text = StringUtility.Contact("<color=#686868FF>", num.text, "</color>");
|
pro.text = StringUtility.Contact("<color=#686868FF>", pro.text, "</color>");
|
proName.text = StringUtility.Contact("<color=#686868FF>", nameStr, "</color>");
|
}
|
}
|
public string GetSuitNameByName(string attrName)
|
{
|
string suitStr = "";
|
for (int i = 0; i < attrName.Length; i++)
|
{
|
if (i != attrName.Length - 1)
|
{
|
if (attrName.Length == 2)
|
{
|
suitStr = StringUtility.Contact(suitStr, attrName[i], " ");
|
}
|
else
|
{
|
suitStr = StringUtility.Contact(suitStr, attrName[i]);
|
}
|
}
|
else
|
{
|
suitStr = StringUtility.Contact(suitStr, attrName[i]);
|
}
|
}
|
return suitStr;
|
|
}
|
|
/// <summary>
|
/// 套装属性值的UI展示
|
/// </summary>
|
/// <param name="playerproModel"></param>
|
/// <param name="value"></param>
|
/// <returns></returns>
|
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;
|
}
|
|
#region 按钮监听
|
private void OnClickSwitchBtn()
|
{
|
int curSelect = equipPartlist[presentIndex];
|
E_SuitType = E_SuitType == SuitType.LowSuit ? SuitType.HighSuit : SuitType.LowSuit;
|
equipPartlist = SuitModel.GetEquipOrderlist(E_SuitType);
|
for (int i = 0; i < equipPartlist.Count; i++)
|
{
|
if (equipPartlist[i] == curSelect)
|
{
|
presentIndex = i;
|
break;
|
}
|
}
|
if (guideEffect != null)
|
{
|
AchievementGuideEffectPool.Recycle(guideEffect);
|
guideEffect = null;
|
SuitModel.ClearJumpModel();
|
}
|
CreateEquipSuitCell();
|
}
|
|
private void OnClickHowToPlayerBtn()
|
{
|
}
|
|
private void OnClickPreViewBtn()
|
{
|
WindowCenter.Instance.Open<EquipSuitPreviewWin>();
|
}
|
|
private void OnClickEquipMaker()
|
{
|
ItemModel itemModel = playerPack.GetItemByIndex(PackType.Equip, equipPlace);
|
if (itemModel == null) return;
|
|
bool canMaker = true;
|
if (SuitModel.IsUpgradSuitLv(equipPlace, (int)E_SuitType, curSuitLv))
|
{
|
for (int i = _equipSuitMatModel.CostItemID.Length - 1; i > -1; i--)
|
{
|
int haveCnt = playerPack.GetItemCountByID(PackType.Item, _equipSuitMatModel.CostItemID[i]);
|
if (haveCnt < _equipSuitMatModel.CostItemCnt[i])
|
{
|
itemPathModel.SetChinItemModel(_equipSuitMatModel.CostItemID[i]);
|
canMaker = false;
|
break;
|
}
|
}
|
}
|
else
|
{
|
canMaker = false;
|
}
|
|
if (canMaker)
|
{
|
if(SuitModel.IsFirstEquipMaker())
|
{
|
ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("EquipSuit112"),(bool isOk)=>
|
{
|
if(isOk)
|
{
|
switch (_equipSuitMatModel.CostItemID.Length)
|
{
|
case 1:
|
oneMatEffect.Play();
|
break;
|
case 2:
|
twoMatEffect.Play();
|
break;
|
case 3:
|
threeMatEffect.Play();
|
break;
|
}
|
SuitModel.SendMakeSuit((int)E_SuitType, equipPlace);
|
}
|
}
|
);
|
}
|
else
|
{
|
switch (_equipSuitMatModel.CostItemID.Length)
|
{
|
case 1:
|
oneMatEffect.Play();
|
break;
|
case 2:
|
twoMatEffect.Play();
|
break;
|
case 3:
|
threeMatEffect.Play();
|
break;
|
}
|
SuitModel.SendMakeSuit((int)E_SuitType, equipPlace);
|
}
|
|
}
|
}
|
|
#endregion
|
private void GetMakeResult(H0721_tagMakeItemAnswer result)
|
{
|
if (result.MakeType != (int)MakeType.Def_mitSuiteCompound)
|
return;
|
|
if (result.Result == 1)
|
{
|
CreateEquipSuitCell();
|
makeSuccessEffect.Play();
|
}
|
|
}
|
}
|