using Snxxz.UI;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using TableConfig;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI
|
{
|
public class ComposeEquipWin : Window
|
{
|
[SerializeField]
|
ScrollerController cellCtrl;
|
|
[SerializeField]
|
ScrollerController equipTypeLineCellCtrl;
|
|
[SerializeField] GameObject increaseRateItem;
|
[SerializeField] GameObject increaseGridCell;
|
[SerializeField] Text increaseText;
|
[SerializeField] PushSwitchBtn switchBtn;
|
|
[SerializeField]
|
List<GameObject> sourceItemlist = new List<GameObject>();
|
|
[SerializeField]
|
List<GameObject> previewItemlist = new List<GameObject>();
|
|
[SerializeField]
|
Text successRateText;
|
|
[SerializeField] Text dismantleText;
|
|
[SerializeField]
|
Button helpBtn;
|
|
[SerializeField]
|
Button composeBtn;
|
|
[SerializeField]
|
Button onekeyPutBtn;
|
|
[SerializeField]
|
GameObject notChooseBG;
|
|
[SerializeField]
|
GameObject chooseComposeEquip;
|
|
[SerializeField]
|
GameObject composeEquip;
|
[SerializeField] UIEffect composeEffect;
|
[SerializeField] UIEffect successEffect;
|
[SerializeField] UIEffect failEffect;
|
|
ComposeWinModel _composeWinModel;
|
ComposeWinModel composeWinModel
|
{
|
get { return _composeWinModel ?? (_composeWinModel = ModelCenter.Instance.GetModel<ComposeWinModel>()); }
|
}
|
|
ItemTipsModel _itemTipsModel;
|
ItemTipsModel itemTipsModel
|
{
|
get
|
{
|
return _itemTipsModel ?? (_itemTipsModel = ModelCenter.Instance.GetModel<ItemTipsModel>());
|
}
|
}
|
|
PlayerPackModel _playerPack;
|
PlayerPackModel playerPack
|
{
|
get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PlayerPackModel>()); }
|
}
|
|
GetItemPathModel ItemPathModel
|
{
|
get { return ModelCenter.Instance.GetModel<GetItemPathModel>(); }
|
}
|
ComposeWinModel.ComposeFirstTypeData firstTypeData;
|
ComposeWinModel.ComposeSecondTypeData secondTypeData;
|
ComposeWinModel.ComposeThirdTypeData thirdTypeData;
|
Dictionary<int, List<int>> fixedItemIndexDict = new Dictionary<int, List<int>>();
|
|
private int curSecondType = 0;
|
private int curThirdType = 0;
|
private int preSecondType = 0;
|
private int preThirdType = 0;
|
[SerializeField] int initSuccessRate = 0;
|
private int curComposeEquipIndex = -1;
|
ItemCompoundConfig compoundModel = null;
|
bool isIncreaseRate = false;
|
int successRate = 0;
|
SelectEquipModel _selectModel;
|
SelectEquipModel selectModel
|
{
|
get { return _selectModel ?? (_selectModel = ModelCenter.Instance.GetModel<SelectEquipModel>()); }
|
}
|
protected override void BindController()
|
{
|
cellCtrl.OnRefreshCell += RefreshTypeCell;
|
cellCtrl.vertical = true;
|
cellCtrl.lockType = EnhanceLockType.KeepVertical;
|
equipTypeLineCellCtrl.OnRefreshCell += RefreshEquipTypeLineCell;
|
composeWinModel.ResetModelEvent += ResetModel;
|
}
|
|
protected override void AddListeners()
|
{
|
composeBtn.AddListener(OnClickComposeBtn);
|
onekeyPutBtn.AddListener(OnClickOnekeyPutBtn);
|
}
|
|
protected override void OnPreOpen()
|
{
|
|
composeWinModel.UpdateSecondTypeEvent += UpdateSecondType;
|
composeWinModel.UpdateThirdTypeEvent += UpdateThirdType;
|
selectModel.selectEquipEvent += RefreshSelectItem;
|
DTCA814_tagMCMakeItemAnswer.MakeItemAnswerEvent += OnComposeAnswer;
|
UIEventTrigger.Get(helpBtn.gameObject).OnDown = OnClickHelpBtn;
|
UIEventTrigger.Get(helpBtn.gameObject).OnUp = OnDownUp;
|
Display();
|
}
|
|
protected override void OnAfterOpen()
|
{
|
this.transform.SetAsLastSibling();
|
}
|
|
protected override void OnPreClose()
|
{
|
selectModel.selectEquipEvent -= RefreshSelectItem;
|
DTCA814_tagMCMakeItemAnswer.MakeItemAnswerEvent -= OnComposeAnswer;
|
composeWinModel.UpdateSecondTypeEvent -= UpdateSecondType;
|
composeWinModel.UpdateThirdTypeEvent -= UpdateThirdType;
|
}
|
|
protected override void OnAfterClose()
|
{
|
|
}
|
#region 新的逻辑
|
private void Display()
|
{
|
composeWinModel.TryGetFirstTypeData((int)ComposeFuncType.Equip,out firstTypeData);
|
if (firstTypeData == null ) return;
|
|
isIncreaseRate = false;
|
successRate = 0;
|
DefaultSelect();
|
CreateTypeCell();
|
|
}
|
|
private void DefaultSelect()
|
{
|
bool isJumpTo = false;
|
if (composeWinModel.secondType != 0)
|
{
|
isJumpTo = true;
|
curSecondType = composeWinModel.secondType;
|
curThirdType = composeWinModel.thirdType;
|
composeWinModel.ResetJumpToModel();
|
}
|
|
//CreateCell();
|
if (compoundModel != null)
|
{
|
RefreshUI(compoundModel);
|
if (isJumpTo)
|
{
|
isJumpTo = false;
|
if (!composeWinModel.IsEnoughFixedMat(compoundModel) || !composeWinModel.IsEnoughUnfixedMat(compoundModel))
|
{
|
MessageWin.Inst.ShowFixedTip(Language.Get("Compose101"));
|
}
|
else if (!composeWinModel.IsEnoughMoney(compoundModel))
|
{
|
MessageWin.Inst.ShowFixedTip(Language.Get("Z1011"));
|
}
|
}
|
}
|
else
|
{
|
RefreshUI(null);
|
}
|
}
|
|
private void CreateTypeCell()
|
{
|
if (firstTypeData == null) return;
|
|
cellCtrl.Refresh();
|
foreach(var second in firstTypeData.secondTypeDict.Keys)
|
{
|
cellCtrl.AddCell(ScrollerDataType.Header,second);
|
if(second == curSecondType)
|
{
|
var thirdTypeDict = firstTypeData.secondTypeDict[second].thirdTypeDict;
|
foreach(var third in thirdTypeDict.Keys)
|
{
|
if (third != 0)
|
{
|
cellCtrl.AddCell(ScrollerDataType.Normal,third);
|
}
|
}
|
}
|
}
|
cellCtrl.Restart();
|
JumpIndex();
|
|
if (curThirdType != 0)
|
{
|
composeWinModel.TryGetThirdTypeData((int)ComposeFuncType.Equip, curSecondType, curThirdType, out thirdTypeData);
|
ChangeUIState(false, true, false);
|
if(thirdTypeData != null)
|
{
|
ItemConfig itemConfig = Config.Instance.Get<ItemConfig>(thirdTypeData.itemCompound.makeID[0]);
|
if (itemConfig != null && itemConfig.ItemColor == 6)
|
{
|
dismantleText.gameObject.SetActive(true);
|
}
|
else
|
{
|
dismantleText.gameObject.SetActive(false);
|
}
|
}
|
}
|
else
|
{
|
RefreshUI(null);
|
dismantleText.gameObject.SetActive(false);
|
ChangeUIState(true, false, false);
|
}
|
}
|
|
private void RefreshTypeCell(ScrollerDataType type, CellView cell)
|
{
|
switch (type)
|
{
|
case ScrollerDataType.Header:
|
ComposeWinModel.ComposeSecondTypeData _secondTypeData = null;
|
ComposeFirstTypeCell firstTypeCell = cell.GetComponent<ComposeFirstTypeCell>();
|
composeWinModel.TryGetSecondTypeData((int)ComposeFuncType.Equip, cell.index, out _secondTypeData);
|
if (_secondTypeData != null)
|
{
|
var thirdTypeDict = _secondTypeData.thirdTypeDict;
|
foreach (var third in thirdTypeDict.Keys)
|
{
|
ComposeWinModel.ComposeThirdTypeData thirdTypeData = null;
|
composeWinModel.TryGetThirdTypeData((int)ComposeFuncType.Equip, cell.index, third, out thirdTypeData);
|
firstTypeCell.SetDisplay((int)ComposeFuncType.Equip, cell.index, third, curSecondType);
|
break;
|
}
|
}
|
break;
|
case ScrollerDataType.Normal:
|
ComposeSecondTypeCell secondTypeCell = cell.GetComponent<ComposeSecondTypeCell>();
|
secondTypeCell.SetDisplay((int)ComposeFuncType.Equip, curSecondType, cell.index, curThirdType);
|
if(curThirdType == cell.index)
|
{
|
CreateEquipTypeLineCell();
|
}
|
break;
|
}
|
}
|
|
private void JumpIndex()
|
{
|
if (firstTypeData == null) return;
|
|
var secondTypeDict = firstTypeData.secondTypeDict;
|
if (secondTypeDict.Count >= 1 && curSecondType != 0
|
&& curThirdType >= 1)
|
{
|
cellCtrl.JumpIndex(GetCurIndex(curSecondType));
|
}
|
}
|
|
private int GetCurIndex(int secondType)
|
{
|
if (firstTypeData == null) return 0;
|
int curIndex = 0;
|
var secondTypeDict = firstTypeData.secondTypeDict;
|
List<int> secondlist = secondTypeDict.Keys.ToList();
|
for (int i = 0; i < secondlist.Count; i++)
|
{
|
if (secondType == secondlist[i])
|
{
|
curIndex = i;
|
break;
|
}
|
}
|
return curIndex;
|
}
|
|
private void UpdateSecondType(int secondType)
|
{
|
curThirdType = 0;
|
curSecondType = secondType;
|
composeWinModel.TryGetSecondTypeData((int)ComposeFuncType.Equip,secondType,out secondTypeData);
|
OnClickSecondType();
|
CreateTypeCell();
|
}
|
|
private void OnClickSecondType()
|
{
|
if (secondTypeData == null) return;
|
|
var thirdTypeDict = secondTypeData.thirdTypeDict;
|
if (curThirdType == 0)
|
{
|
foreach (var thirdType in thirdTypeDict.Keys)
|
{
|
if (thirdType != 0)
|
{
|
if (preSecondType == curSecondType)
|
{
|
curSecondType = 0;
|
preSecondType = 0;
|
}
|
else
|
{
|
curThirdType = thirdType;
|
}
|
}
|
break;
|
}
|
}
|
|
if (preSecondType != curSecondType)
|
{
|
preSecondType = curSecondType;
|
curComposeEquipIndex = -1;
|
selectModel.ClearSelectModel();
|
}
|
}
|
|
private void UpdateThirdType(int thirdType)
|
{
|
composeWinModel.TryGetThirdTypeData((int)ComposeFuncType.Equip, curSecondType,thirdType, out thirdTypeData);
|
if(thirdTypeData != null)
|
{
|
bool isTrailer = composeWinModel.IsTrailerByLevel(thirdTypeData.itemCompound);
|
if (isTrailer)
|
{
|
MessageWin.Inst.ShowFixedTip(Language.Get("FuncOpenLv", thirdTypeData.itemCompound.levelNeed));
|
return;
|
}
|
}
|
curThirdType = thirdType;
|
OnClickThirdType();
|
CreateTypeCell();
|
}
|
|
private void OnClickThirdType()
|
{
|
if (thirdTypeData == null) return;
|
|
if (preThirdType != curThirdType)
|
{
|
preThirdType = curThirdType;
|
}
|
curComposeEquipIndex = -1;
|
selectModel.ClearSelectModel();
|
}
|
|
private void CreateEquipTypeLineCell()
|
{
|
List<ComposeWinModel.ComposeThirdTypeData> thirdTypeDatas = null;
|
bool isthird = composeWinModel.TryGetThirdTypeData((int)ComposeFuncType.Equip, curSecondType, curThirdType, out thirdTypeDatas);
|
if (!isthird) return;
|
|
if (thirdTypeDatas.Count > 1)
|
{
|
ChangeUIState(false, true, false);
|
equipTypeLineCellCtrl.Refresh();
|
int line = thirdTypeDatas.Count / 3;
|
if (thirdTypeDatas.Count % 3 > 0)
|
{
|
line += 1;
|
}
|
int i = 0;
|
for (i = 0; i < line; i++)
|
{
|
equipTypeLineCellCtrl.AddCell(ScrollerDataType.Header, i);
|
}
|
equipTypeLineCellCtrl.Restart();
|
}
|
else
|
{
|
if (thirdTypeDatas.Count > 0)
|
{
|
ItemCompoundConfig tagItemCompound = thirdTypeDatas[0].itemCompound;
|
ClickEquipTypeCell(tagItemCompound, 0);
|
RefreshUI(tagItemCompound);
|
}
|
}
|
if (curComposeEquipIndex != -1)
|
{
|
ItemCompoundConfig tagItemCompound = thirdTypeDatas[curComposeEquipIndex].itemCompound;
|
ClickEquipTypeCell(tagItemCompound, curComposeEquipIndex);
|
}
|
|
}
|
|
private void ChangeUIState(params bool[] isShows)
|
{
|
notChooseBG.SetActive(isShows[0]);
|
chooseComposeEquip.SetActive(isShows[1]);
|
composeEquip.SetActive(isShows[2]);
|
}
|
|
#endregion
|
|
private void ResetModel()
|
{
|
curSecondType = 0;
|
curThirdType = 0;
|
preSecondType = 0;
|
preThirdType = 0;
|
curComposeEquipIndex = -1;
|
compoundModel = null;
|
}
|
|
private void RefreshEquipTypeLineCell(ScrollerDataType type, CellView cell)
|
{
|
List<ComposeWinModel.ComposeThirdTypeData> thirdTypeDatas = null;
|
composeWinModel.TryGetThirdTypeData((int)ComposeFuncType.Equip, curSecondType, curThirdType, out thirdTypeDatas);
|
|
int i = 0;
|
for(i = 0; i < cell.transform.childCount; i++)
|
{
|
GameObject typeCell = cell.transform.GetChild(i).gameObject;
|
int index = (cell.transform.childCount) * cell.index + i;
|
if(index < thirdTypeDatas.Count)
|
{
|
typeCell.SetActive(true);
|
ItemCompoundConfig tagItemCompound = thirdTypeDatas[index].itemCompound;
|
ItemConfig tagChinItem = Config.Instance.Get<ItemConfig>(tagItemCompound.makeID[0]);
|
Image icon = typeCell.transform.Find("EquipIcon").GetComponent<Image>();
|
Image bgIcon = typeCell.transform.Find("EquipBG").GetComponent<Image>();
|
Text nameText = typeCell.transform.Find("BtnText").GetComponent<Text>();
|
Button cellBtn = typeCell.GetComponent<Button>();
|
icon.SetSprite(tagChinItem.IconKey);
|
bgIcon.SetItemBackGround(tagChinItem.ItemColor);
|
nameText.text = GeneralDefine.equipPlaceNameDict[tagChinItem.EquipPlace];
|
cellBtn.RemoveAllListeners();
|
cellBtn.AddListener(()=> {
|
ClickEquipTypeCell(tagItemCompound,index);
|
RefreshUI(tagItemCompound);
|
});
|
}
|
else
|
{
|
typeCell.SetActive(false);
|
}
|
|
}
|
|
}
|
|
private void ClickEquipTypeCell(ItemCompoundConfig tagItemCompound,int index)
|
{
|
curComposeEquipIndex = index;
|
ChangeUIState(false, false, true);
|
RefreshComposeSuccessRate();
|
}
|
|
|
private void RefreshUI(ItemCompoundConfig compoundModel)
|
{
|
this.compoundModel = compoundModel;
|
|
if (compoundModel == null)
|
{
|
|
int i = 0;
|
for (i = 0; i < previewItemlist.Count; i++)
|
{
|
GameObject gridCell = previewItemlist[i].transform.Find("GridCell").gameObject;
|
gridCell.SetActive(false);
|
}
|
|
for (i = 0; i < sourceItemlist.Count; i++)
|
{
|
GameObject gridCell = sourceItemlist[i].transform.Find("GridCell").gameObject;
|
Text putInText = sourceItemlist[i].transform.Find("PutInText").GetComponent<Text>();
|
Button posBtn = sourceItemlist[i].GetComponent<Button>();
|
posBtn.RemoveAllListeners();
|
putInText.gameObject.SetActive(false);
|
RefreshGridCellUI(gridCell, true);
|
}
|
composeBtn.gameObject.SetActive(false);
|
onekeyPutBtn.gameObject.SetActive(false);
|
|
}
|
else
|
{
|
composeWinModel.SetCurComposeModel(compoundModel);
|
composeBtn.gameObject.SetActive(true);
|
onekeyPutBtn.gameObject.SetActive(true);
|
ControllerRightUI();
|
}
|
|
RefreshComposeSuccessRate();
|
}
|
|
private void ControllerRightUI()
|
{
|
|
int i = 0;
|
#region 合成物品UI
|
for (i = 0; i < previewItemlist.Count; i++)
|
{
|
int[] makeIds = ItemCompoundConfig.GetDisplayArrayByType(compoundModel.id, DisplayItemArray.MakeIds);
|
GameObject gridCell = previewItemlist[i].transform.Find("GridCell").gameObject;
|
if (i < makeIds.Length)
|
{
|
RefreshGridCellUI(gridCell, false, makeIds[i],0,NeedMatType.MakeItem);
|
}
|
else
|
{
|
RefreshGridCellUI(gridCell,true);
|
}
|
}
|
#endregion
|
|
#region 固定道具和不固定道具UI
|
int[] fixedDisplay = ItemCompoundConfig.GetDisplayArrayByType(compoundModel.id, DisplayItemArray.FixedDisplay);
|
int[] fixedIds = ItemCompoundConfig.GetDisplayArrayByType(compoundModel.id, DisplayItemArray.FixedIds);
|
int[] fixedCounts = ItemCompoundConfig.GetDisplayArrayByType(compoundModel.id, DisplayItemArray.FixedCounts);
|
int[] unfixedIds = ItemCompoundConfig.GetDisplayArrayByType(compoundModel.id, DisplayItemArray.UnfixedIds);
|
int[] unfixedDisplay = ItemCompoundConfig.GetDisplayArrayByType(compoundModel.id, DisplayItemArray.UnfixedDisplay);
|
for (i = 0;i < sourceItemlist.Count; i++)
|
{
|
GameObject gridCell = sourceItemlist[i].transform.Find("GridCell").gameObject;
|
Text putInText = sourceItemlist[i].transform.Find("PutInText").GetComponent<Text>();
|
Button posBtn = sourceItemlist[i].GetComponent<Button>();
|
putInText.gameObject.SetActive(false);
|
RefreshGridCellUI(gridCell, true);
|
posBtn.RemoveAllListeners();
|
}
|
fixedItemIndexDict.Clear();
|
for (i = 0; i < fixedDisplay.Length; i++)
|
{
|
if (fixedDisplay[i] != 0)
|
{
|
GameObject matPos = sourceItemlist[fixedDisplay[i] - 1];
|
GameObject gridCell = matPos.transform.Find("GridCell").gameObject;
|
Text putInText = matPos.transform.Find("PutInText").GetComponent<Text>();
|
putInText.gameObject.SetActive(false);
|
RefreshGridCellUI(gridCell,false,fixedIds[i],fixedCounts[i],NeedMatType.fixedItem);
|
|
List<int> itemIndexlist = null;
|
SinglePackModel singlePack = playerPack.GetSinglePackModel(PackType.rptItem);
|
if (singlePack != null)
|
{
|
itemIndexlist = singlePack.ItemIndexlist(fixedIds[i],fixedCounts[i]);
|
}
|
if (itemIndexlist != null)
|
{
|
fixedItemIndexDict.Add(fixedIds[i], itemIndexlist);
|
}
|
}
|
}
|
|
for (i = 0; i < unfixedDisplay.Length; i++)
|
{
|
if (unfixedDisplay[i] != 0)
|
{
|
GameObject matPos = sourceItemlist[unfixedDisplay[i] - 1];
|
GameObject gridCell = matPos.transform.Find("GridCell").gameObject;
|
Text putInText = matPos.transform.Find("PutInText").GetComponent<Text>();
|
Button posBtn = matPos.GetComponent<Button>();
|
putInText.gameObject.SetActive(true);
|
RefreshGridCellUI(gridCell, false);
|
posBtn.RemoveAllListeners();
|
posBtn.AddListener(()=> {
|
selectModel.SetAddParent(matPos);
|
selectModel.selectItem = SelectItemType.unfixed;
|
WindowCenter.Instance.Open<SelectItemWin>();
|
});
|
}
|
}
|
#endregion
|
|
#region 提升合成成功率
|
int[] increases = compoundModel.successRateIncrease;
|
if(increases == null || increases.Length < 2)
|
{
|
isIncreaseRate = false;
|
increaseRateItem.SetActive(isIncreaseRate);
|
}
|
else
|
{
|
int increaseId = increases[0];
|
int increaseNeedNum = increases[1];
|
int increaseRate = increases[2] / 100;
|
increaseRateItem.SetActive(true);
|
RefreshGridCellUI(increaseGridCell, false,increaseId,increaseNeedNum);
|
increaseText.text = Language.Get("Compose109", StringUtility.Contact(increaseRate, "%"));
|
int haveIncreaseNum = playerPack.GetItemCountByID(PackType.rptItem, increaseId);
|
ItemConfig itemConfig = Config.Instance.Get<ItemConfig>(increaseId);
|
isIncreaseRate = haveIncreaseNum >= increaseNeedNum ? isIncreaseRate : false;
|
switchBtn.RefreshSwitchUI(isIncreaseRate);
|
switchBtn.switchBtn.RemoveAllListeners();
|
switchBtn.switchBtn.AddListener(()=>
|
{
|
if (switchBtn.onObj.activeInHierarchy)
|
{
|
isIncreaseRate = false;
|
switchBtn.RefreshSwitchUI(false);
|
}
|
else
|
{
|
if(haveIncreaseNum >= increaseNeedNum)
|
{
|
isIncreaseRate = true;
|
switchBtn.RefreshSwitchUI(true);
|
}
|
else
|
{
|
isIncreaseRate = false;
|
MessageWin.Inst.ShowFixedTip(Language.Get("Compose110", increaseNeedNum, itemConfig.ItemName));
|
}
|
}
|
RefreshComposeSuccessRate();
|
});
|
}
|
#endregion
|
|
}
|
|
private void RefreshGridCellUI(GameObject gridCell, bool islock, int itemId = -1,int needCount = 0,NeedMatType matType = NeedMatType.Nothing,int itemPlace = -1)
|
{
|
gridCell.SetActive(true);
|
ItemCell itemCell = gridCell.transform.Find("ItemCell").GetComponent<ItemCell>();
|
if (itemCell == null)
|
itemCell = gridCell.transform.Find("ItemCell").gameObject.AddComponent<ItemCell>();
|
|
GameObject gridlock = gridCell.transform.Find("GridLock").gameObject;
|
itemCell.cellBtn.onClick.RemoveAllListeners();
|
if (islock)
|
{
|
gridlock.gameObject.SetActive(true);
|
itemCell.gameObject.SetActive(false);
|
}
|
else
|
{
|
gridlock.gameObject.SetActive(false);
|
itemCell.gameObject.SetActive(true);
|
ItemModel itemModel = playerPack.GetItemModelByIndex(PackType.rptItem,itemPlace);
|
ItemConfig itemConfig = Config.Instance.Get<ItemConfig>(itemId);
|
if (itemModel == null)
|
{
|
if(itemId != -1)
|
{
|
ItemCellModel cellModel = new ItemCellModel(itemId);
|
itemCell.Init(cellModel);
|
itemCell.cellBtn.onClick.AddListener(() =>
|
{
|
if (matType == NeedMatType.fixedItem)
|
{
|
if (itemConfig.GetWay != null && itemConfig.GetWay.Length > 0)
|
{
|
ItemPathModel.SetChinItemModel(itemId);
|
}
|
else
|
{
|
ItemAttrData attrData = new ItemAttrData(itemId, true);
|
itemTipsModel.SetItemTipsModel(attrData);
|
}
|
}
|
else
|
{
|
ItemAttrData attrData = new ItemAttrData(itemId, true);
|
itemTipsModel.SetItemTipsModel(attrData);
|
}
|
}
|
);
|
}
|
else
|
{
|
itemCell.gameObject.SetActive(false);
|
}
|
|
}
|
else
|
{
|
itemCell.Init(itemModel);
|
itemCell.cellBtn.onClick.AddListener(() =>
|
{
|
if (matType == NeedMatType.fixedItem)
|
{
|
if (itemConfig.GetWay != null && itemConfig.GetWay.Length > 0)
|
{
|
ItemPathModel.SetChinItemModel(itemId);
|
}
|
else
|
{
|
itemTipsModel.SetItemTipsModel(PackType.rptItem, itemModel.itemInfo.ItemGUID);
|
}
|
}
|
else
|
{
|
itemTipsModel.SetItemTipsModel(PackType.rptItem, itemModel.itemInfo.ItemGUID);
|
}
|
});
|
}
|
|
if(needCount > 0)
|
{
|
itemCell.countText.gameObject.SetActive(true);
|
int haveCount = playerPack.GetItemCountByID(PackType.rptItem, itemId);
|
if (haveCount >= needCount)
|
{
|
itemCell.countText.text = StringUtility.Contact(UIHelper.GetTextColorByItemColor(TextColType.Green, haveCount.ToString()),
|
"/", needCount);
|
}
|
else
|
{
|
itemCell.countText.text = StringUtility.Contact(UIHelper.GetTextColorByItemColor(TextColType.Red, haveCount.ToString()),
|
"/", needCount);
|
}
|
}
|
else
|
{
|
itemCell.countText.gameObject.SetActive(false);
|
}
|
}
|
}
|
|
private void RefreshSelectItem(ItemModel model, GameObject go, SelectItemType selectType)
|
{
|
GameObject gridCell = go.transform.Find("GridCell").gameObject;
|
ItemCell itemCell = gridCell.transform.Find("ItemCell").GetComponent<ItemCell>();
|
Text putInText = null;
|
switch (selectType)
|
{
|
case SelectItemType.unfixed:
|
putInText = go.transform.Find("PutInText").GetComponent<Text>();
|
RefreshGridCellUI(gridCell, false, model.itemInfo.ItemID,0 ,NeedMatType.unfixedItem, model.itemInfo.ItemPlace);
|
break;
|
case SelectItemType.addons:
|
putInText = go.transform.Find("AddRateText").GetComponent<Text>();
|
RefreshGridCellUI(gridCell, false, model.itemInfo.ItemID, 0,NeedMatType.addItem, model.itemInfo.ItemPlace);
|
break;
|
}
|
|
itemCell.reducebtn.gameObject.SetActive(true);
|
itemCell.reducebtn.RemoveAllListeners();
|
|
itemCell.reducebtn.AddListener(() => { OnClickReduceBtn(gridCell, putInText,model.itemInfo.ItemPlace, selectType); });
|
putInText.gameObject.SetActive(false);
|
}
|
|
private void OnClickReduceBtn(GameObject gridCell,Text posDes,int itemPlace,SelectItemType selectItem)
|
{
|
switch (selectItem)
|
{
|
case SelectItemType.unfixed:
|
selectModel.RemoveHaveUnfixedSelectItem(itemPlace);
|
break;
|
case SelectItemType.addons:
|
selectModel.RemoveHaveAddSelectItem(itemPlace);
|
break;
|
}
|
|
posDes.gameObject.SetActive(true);
|
RefreshGridCellUI(gridCell,false,-1,0,NeedMatType.unfixedItem);
|
}
|
|
public void RefreshComposeSuccessRate()
|
{
|
successRate = 0;
|
int increaseRate = 0;
|
if (compoundModel != null)
|
{
|
successRate = compoundModel.successRate;
|
}
|
if(isIncreaseRate)
|
{
|
int[] increases = compoundModel.successRateIncrease;
|
if(increases != null && increases.Length > 1)
|
{
|
increaseRate = increases[2] / 100;
|
}
|
}
|
|
if(increaseRate > 0)
|
{
|
string extraAddRate = UIHelper.GetTextColorByItemColor(TextColType.Green,StringUtility.Contact("+", increaseRate, "%"),true);
|
successRateText.text = Language.Get("HallowsWin_Success", StringUtility.Contact(successRate / 100, "%", extraAddRate));
|
}
|
else
|
{
|
successRateText.text = Language.Get("HallowsWin_Success", StringUtility.Contact(successRate / 100, "%"));
|
}
|
|
}
|
|
private void OnClickOnekeyPutBtn()
|
{
|
if (compoundModel == null)
|
return;
|
|
Dictionary<int,ItemModel> unfixedSelectItemDict = selectModel.GetUnfixedItemModel();
|
int i = 0;
|
for (i = 0; i <sourceItemlist.Count; i++)
|
{
|
GameObject gridCell = sourceItemlist[i].transform.Find("GridCell").gameObject;
|
ItemCell itemCell = gridCell.transform.Find("ItemCell").GetComponent<ItemCell>();
|
GameObject gridlock = gridCell.transform.Find("GridLock").gameObject;
|
foreach (int key in unfixedSelectItemDict.Keys)
|
{
|
if(gridCell.activeInHierarchy && !gridlock.activeInHierarchy
|
&& !itemCell.gameObject.activeInHierarchy)
|
{
|
|
if (!selectModel.GetHaveUnfixedSelectItem().ContainsKey(key))
|
{
|
selectModel.AddHaveUnfixedSelectItem(key);
|
RefreshSelectItem(unfixedSelectItemDict[key], sourceItemlist[i],SelectItemType.unfixed);
|
break;
|
}
|
}
|
|
}
|
|
}
|
}
|
|
private void OnClickComposeBtn()
|
{
|
composeWinModel.SendComposeRequest(compoundModel,fixedItemIndexDict,composeEffect,1,10000,isIncreaseRate);
|
}
|
|
private void OnComposeAnswer(HA814_tagMCMakeItemAnswer answer)
|
{
|
if (answer.MakeType != (int)MakeType.Def_mitItemCompound)
|
return;
|
|
if (answer.Result == 1)
|
{
|
successEffect.Play();
|
}
|
else
|
{
|
failEffect.Play();
|
}
|
|
RefreshUI(compoundModel);
|
selectModel.ClearSelectModel();
|
}
|
|
private void OnDownUp(GameObject go)
|
{
|
WindowCenter.Instance.Close<ComposeHelpWin>();
|
}
|
|
private void OnClickHelpBtn(GameObject go)
|
{
|
if (compoundModel != null)
|
{
|
WindowCenter.Instance.Open<ComposeHelpWin>();
|
}
|
}
|
|
}
|
}
|