using Snxxz.UI;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using TableConfig;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI
|
{
|
public class ComposeWingsWin : Window
|
{
|
[SerializeField]
|
GameObject composeUIShowObj;
|
[SerializeField]
|
GameObject noneComposeObj;
|
|
[SerializeField]
|
ScrollerController cellCtrl;
|
|
[SerializeField]
|
List<GameObject> sourceItemlist = new List<GameObject>();
|
|
[SerializeField]
|
List<GameObject> previewItemlist = new List<GameObject>();
|
|
[SerializeField]
|
List<GameObject> addItemlist = new List<GameObject>();
|
|
[SerializeField]
|
Text successRateText;
|
|
[SerializeField]
|
Button helpBtn;
|
|
[SerializeField]
|
Button composeBtn;
|
|
[SerializeField]
|
Button onekeyPutBtn;
|
|
[SerializeField] UIEffect oneMatEffect;
|
[SerializeField] UIEffect twoMatEffect;
|
[SerializeField] UIEffect threeMatEffect;
|
[SerializeField] UIEffect successEffect;
|
[SerializeField] UIEffect failMatEffect;
|
|
ComposeWinModel _composeWinModel;
|
ComposeWinModel composeWinModel
|
{
|
get { return _composeWinModel ?? (_composeWinModel = ModelCenter.Instance.GetModel<ComposeWinModel>()); }
|
}
|
|
ItemTipsModel _itemTipsModel;
|
ItemTipsModel itemTipsModel
|
{
|
get
|
{
|
return _itemTipsModel ?? (_itemTipsModel = ModelCenter.Instance.GetModel<ItemTipsModel>());
|
}
|
}
|
|
GetItemPathModel ItemPathModel
|
{
|
get { return ModelCenter.Instance.GetModel<GetItemPathModel>(); }
|
}
|
|
private Dictionary<int, Dictionary<int, List<ItemCompoundConfig>>> firstTypeDict = null;
|
private Dictionary<int, List<ItemCompoundConfig>> secondTypeDict = null;
|
private List<ItemCompoundConfig> thirdTypelist = null;
|
|
Dictionary<int, List<int>> fixedItemIndexDict = new Dictionary<int, List<int>>();
|
|
private int curSecondType = 0;
|
private int curThirdType = 0;
|
private int preSecondType = 0;
|
private int successRate = 0;
|
[SerializeField] int initSuccessRate = 2000;
|
ItemCompoundConfig compoundModel = null;
|
|
SelectEquipModel _selectModel;
|
SelectEquipModel selectModel
|
{
|
get { return _selectModel ?? (_selectModel = ModelCenter.Instance.GetModel<SelectEquipModel>()); }
|
}
|
|
PlayerPackModel _playerPack;
|
PlayerPackModel playerPack
|
{
|
get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PlayerPackModel>()); }
|
}
|
|
AchievementGuideEffect guidEffect = null;
|
private bool IsComposeBind = false;
|
|
protected override void BindController()
|
{
|
cellCtrl.OnRefreshCell += RefreshCell;
|
|
cellCtrl.lockType = EnhanceLockType.KeepVertical;
|
composeWinModel.ResetModelEvent += ResetModel;
|
|
}
|
|
protected override void AddListeners()
|
{
|
composeBtn.AddListener(OnClickComposeBtn);
|
onekeyPutBtn.AddListener(OnClickOnekeyPutBtn);
|
}
|
|
protected override void OnPreOpen()
|
{
|
selectModel.selectEquipEvent += RefreshSelectItem;
|
DTCA814_tagMCMakeItemAnswer.MakeItemAnswerEvent += OnComposeAnswer;
|
UIEventTrigger.Get(helpBtn.gameObject).OnDown = OnClickHelpBtn;
|
UIEventTrigger.Get(helpBtn.gameObject).OnUp = OnDownUp;
|
|
firstTypeDict = composeWinModel.GetFirstTypeModel((int)ComposeFuncType.Wings);
|
bool isJumpTo = false;
|
SuccessConfig successConfig = Config.Instance.Get<SuccessConfig>(AchievementGoto.guideAchievementId);
|
if (successConfig != null && successConfig.Type == 69)
|
{
|
isJumpTo = true;
|
curSecondType = composeWinModel.secondType;
|
curThirdType = composeWinModel.thirdType;
|
secondTypeDict = composeWinModel.GetSecondTypeModel((int)ComposeFuncType.Wings,composeWinModel.secondType);
|
ClickSecondTypeUICtrl();
|
composeWinModel.ResetJumpToModel();
|
}
|
else
|
{
|
if (composeWinModel.secondType != 0)
|
{
|
isJumpTo = true;
|
curSecondType = composeWinModel.secondType;
|
curThirdType = composeWinModel.thirdType;
|
secondTypeDict = composeWinModel.GetSecondTypeModel((int)ComposeFuncType.Wings, composeWinModel.secondType);
|
ClickSecondTypeUICtrl();
|
composeWinModel.ResetJumpToModel();
|
}
|
}
|
|
CreateCell();
|
IsComposeBind = false;
|
if (curSecondType == 0)
|
{
|
RefreshUI(null);
|
}
|
|
if(compoundModel != null)
|
{
|
selectModel.ClearSelectModel();
|
RefreshUI(compoundModel);
|
if(isJumpTo)
|
{
|
isJumpTo = false;
|
bool isCanCompose = true;
|
if(!composeWinModel.IsEnoughFixedMat(compoundModel) || !composeWinModel.IsEnoughUnfixedMat(compoundModel))
|
{
|
MessageWin.Inst.ShowFixedTip(Language.Get("Compose101"));
|
isCanCompose = false;
|
}
|
else if(!composeWinModel.IsEnoughMoney(compoundModel))
|
{
|
MessageWin.Inst.ShowFixedTip(Language.Get("Z1011"));
|
isCanCompose = false;
|
}
|
|
if(isCanCompose)
|
{
|
guidEffect = AchievementGuideEffectPool.Require(1);
|
guidEffect.transform.SetParentEx(composeBtn.transform, Vector3.zero, Quaternion.identity, Vector3.one);
|
}
|
}
|
}
|
}
|
|
protected override void OnAfterOpen()
|
{
|
cellCtrl.vertical = true;
|
this.transform.SetAsLastSibling();
|
}
|
|
protected override void OnPreClose()
|
{
|
selectModel.selectEquipEvent -= RefreshSelectItem;
|
DTCA814_tagMCMakeItemAnswer.MakeItemAnswerEvent -= OnComposeAnswer;
|
}
|
|
protected override void OnAfterClose()
|
{
|
|
}
|
|
private void ResetModel()
|
{
|
curSecondType = 0;
|
curThirdType = 0;
|
preSecondType = 0;
|
successRate = 0;
|
compoundModel = null;
|
}
|
|
private void CreateCell()
|
{
|
cellCtrl.Refresh();
|
if(firstTypeDict != null)
|
{
|
foreach (int secondType in firstTypeDict.Keys)
|
{
|
cellCtrl.AddCell(ScrollerDataType.Header,secondType);
|
if(secondType == curSecondType)
|
{
|
foreach (int thirdType in secondTypeDict.Keys)
|
{
|
if (thirdType != 0)
|
{
|
cellCtrl.AddCell(ScrollerDataType.Normal, thirdType);
|
}
|
}
|
}
|
}
|
}
|
cellCtrl.Restart();
|
|
if(secondTypeDict != null)
|
{
|
if (secondTypeDict.Count >= 1 && curSecondType != 0)
|
{
|
cellCtrl.JumpIndex(GetCurIndex(curSecondType));
|
}
|
}
|
}
|
|
private int GetCurIndex(int secondType)
|
{
|
int curIndex = 0;
|
List<int> secondlist = firstTypeDict.Keys.ToList();
|
for (int i = 0; i < secondlist.Count; i++)
|
{
|
if (secondType == secondlist[i])
|
{
|
curIndex = i;
|
break;
|
}
|
}
|
return curIndex;
|
}
|
|
private void RefreshCell(ScrollerDataType type, CellView cell)
|
{
|
Image icon = cell.transform.Find("BtnIcon").GetComponent<Image>();
|
Text name = cell.transform.Find("BtnText").GetComponent<Text>();
|
Button cellBtn = cell.GetComponent<Button>();
|
cellBtn.RemoveAllListeners();
|
ItemCompoundConfig compoundModel = null;
|
switch (type)
|
{
|
case ScrollerDataType.Header:
|
GameObject arrowIcon = cell.transform.Find("SecondBtn").gameObject;
|
foreach (int thirdType in firstTypeDict[cell.index].Keys)
|
{
|
if (thirdType != 0)
|
{
|
arrowIcon.SetActive(true);
|
}
|
else
|
{
|
arrowIcon.SetActive(false);
|
}
|
compoundModel = firstTypeDict[cell.index][thirdType][0];
|
name.text = compoundModel.secondTypeName;
|
if (curSecondType == cell.index)
|
{
|
preSecondType = curSecondType;
|
icon.SetSprite("ComposeFirstClassChoosebtn");
|
arrowIcon.transform.localRotation = Quaternion.Euler(0,0,-90);
|
secondTypeDict = composeWinModel.GetSecondTypeModel((int)ComposeFuncType.Wings, curSecondType);
|
//ClickSecondTypeUICtrl();
|
}
|
else
|
{
|
arrowIcon.transform.localRotation = Quaternion.Euler(0,0,0);
|
icon.SetSprite("ComposeFirstClassNormalbtn");
|
}
|
break;
|
}
|
cellBtn.AddListener(()=> { OnClickSecondType(cell.index); });
|
break;
|
case ScrollerDataType.Normal:
|
compoundModel = secondTypeDict[cell.index][0];
|
name.text = compoundModel.thirdTypeName;
|
if (curThirdType == cell.index)
|
{
|
icon.SetSprite("ChildListBtn_Select");
|
thirdTypelist = composeWinModel.GetThirdTypeModellist(compoundModel.firstType, compoundModel.secondType, cell.index);
|
RefreshUI(compoundModel);
|
}
|
else
|
{
|
icon.SetSprite("ChildListBtn_UnSelect");
|
}
|
cellBtn.AddListener(() => { OnClickThirdType(cell.index); });
|
break;
|
}
|
}
|
|
private void OnClickSecondType(int secondType)
|
{
|
curSecondType = secondType;
|
secondTypeDict = composeWinModel.GetSecondTypeModel((int)ComposeFuncType.Wings, curSecondType);
|
foreach(var thirdType in secondTypeDict.Keys)
|
{
|
if(thirdType != 0)
|
{
|
|
if (preSecondType == curSecondType)
|
{
|
curSecondType = 0;
|
preSecondType = 0;
|
}
|
}
|
curThirdType = 0;
|
break;
|
}
|
|
if (preSecondType != curSecondType)
|
{
|
preSecondType = curSecondType;
|
selectModel.ClearSelectModel();
|
if (guidEffect != null)
|
{
|
AchievementGuideEffectPool.Recycle(guidEffect);
|
guidEffect = null;
|
}
|
}
|
|
ClickSecondTypeUICtrl();
|
CreateCell();
|
}
|
|
private void ClickSecondTypeUICtrl()
|
{
|
if (secondTypeDict.Count > 1)
|
{
|
RefreshUI(null);
|
}
|
else
|
{
|
if(curThirdType == 0)
|
{
|
if(secondTypeDict.ContainsKey(curThirdType))
|
{
|
RefreshUI(secondTypeDict[curThirdType][0]);
|
}
|
}
|
}
|
|
}
|
|
private void OnClickThirdType(int thirdType)
|
{
|
curThirdType = thirdType;
|
cellCtrl.m_Scorller.RefreshActiveCellViews();
|
selectModel.ClearSelectModel();
|
}
|
|
private void RefreshUI(ItemCompoundConfig compoundModel)
|
{
|
this.compoundModel = compoundModel;
|
if (compoundModel == null)
|
{
|
noneComposeObj.SetActive(true);
|
composeUIShowObj.SetActive(false);
|
}
|
else
|
{
|
noneComposeObj.SetActive(false);
|
composeUIShowObj.SetActive(true);
|
successRate = compoundModel.successRate;
|
successRateText.text = Language.Get("HallowsWin_Success",StringUtility.Contact(compoundModel.successRate / 100, "%"));
|
composeWinModel.SetCurComposeModel(compoundModel);
|
ControllerRightUI();
|
}
|
}
|
|
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],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>();
|
posBtn.RemoveAllListeners();
|
putInText.gameObject.SetActive(false);
|
RefreshGridCellUI(gridCell,true);
|
}
|
|
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],NeedMatType.fixedItem);
|
}
|
}
|
|
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 增加成功率UI
|
for (i = 0; i < addItemlist.Count; i++)
|
{
|
GameObject matPos = addItemlist[i];
|
GameObject gridCell = matPos.transform.Find("GridCell").gameObject;
|
Text putInText = matPos.transform.Find("AddRateText").GetComponent<Text>();
|
Button posBtn = matPos.GetComponent<Button>();
|
if (i < compoundModel.addonsCountMax)
|
{
|
putInText.gameObject.SetActive(true);
|
RefreshGridCellUI(gridCell, false);
|
posBtn.RemoveAllListeners();
|
posBtn.AddListener(() => {
|
selectModel.SetAddParent(matPos);
|
selectModel.selectItem = SelectItemType.addons;
|
WindowCenter.Instance.Open<SelectItemWin>();
|
});
|
}
|
else
|
{
|
putInText.gameObject.SetActive(false);
|
RefreshGridCellUI(gridCell, true);
|
posBtn.RemoveAllListeners();
|
}
|
}
|
|
#endregion
|
|
|
}
|
|
private void RefreshGridCellUI(GameObject gridCell, bool islock, int itemId = -1,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 (matType == NeedMatType.fixedItem)
|
{
|
int[] fixedIds = ItemCompoundConfig.GetDisplayArrayByType(compoundModel.id, DisplayItemArray.FixedIds);
|
int[] fixedCounts = ItemCompoundConfig.GetDisplayArrayByType(compoundModel.id, DisplayItemArray.FixedCounts);
|
itemCell.countText.gameObject.SetActive(true);
|
int haveCount = playerPack.GetItemCountByID(PackType.rptItem,itemId);
|
int i = 0;
|
for(i = 0; i < fixedIds.Length; i++)
|
{
|
if(fixedIds[i] == itemId)
|
{
|
if (haveCount >= fixedCounts[i])
|
{
|
itemCell.countText.text = StringUtility.Contact(UIHelper.GetTextColorByItemColor(TextColType.Green,haveCount.ToString()),
|
"/",fixedCounts[i].ToString());
|
}
|
else
|
{
|
itemCell.countText.text = StringUtility.Contact(UIHelper.GetTextColorByItemColor(TextColType.Red, haveCount.ToString()),
|
"/", fixedCounts[i].ToString());
|
}
|
break;
|
}
|
}
|
|
}
|
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, NeedMatType.unfixedItem, model.itemInfo.ItemPlace);
|
IsComposeBind = ChangeFixedMatUI();
|
break;
|
case SelectItemType.addons:
|
putInText = go.transform.Find("AddRateText").GetComponent<Text>();
|
RefreshGridCellUI(gridCell, false, model.itemInfo.ItemID, NeedMatType.addItem, model.itemInfo.ItemPlace);
|
successRateText.text = Language.Get("HallowsWin_Success", StringUtility.Contact(RefreshComposeSuccessRate(initSuccessRate) / 100, "%"));
|
if (successRate >= compoundModel.successUpper)
|
{
|
SysNotifyMgr.Instance.ShowTip("ComposeFullToAdd");
|
}
|
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)
|
{
|
ItemModel itemModel = playerPack.GetItemModelByIndex(PackType.rptItem,itemPlace);
|
switch (selectItem)
|
{
|
case SelectItemType.unfixed:
|
selectModel.RemoveHaveUnfixedSelectItem(itemPlace);
|
IsComposeBind = ChangeFixedMatUI();
|
break;
|
case SelectItemType.addons:
|
selectModel.RemoveHaveAddSelectItem(itemPlace);
|
successRateText.text = Language.Get("HallowsWin_Success", StringUtility.Contact(RefreshComposeSuccessRate(initSuccessRate) / 100, "%"));
|
break;
|
}
|
|
posDes.gameObject.SetActive(true);
|
RefreshGridCellUI(gridCell,false);
|
}
|
|
private bool ChangeFixedMatUI()
|
{
|
SinglePackModel singlePack = playerPack.GetSinglePackModel(PackType.rptItem);
|
if (singlePack == null || compoundModel == null) return false;
|
|
bool isBind = false;
|
Dictionary<int,ItemModel> unfixedMatDict = selectModel.GetHaveUnfixedSelectItem();
|
foreach(var model in unfixedMatDict.Values)
|
{
|
if(model.itemInfo.IsBind == 1)
|
{
|
isBind = true;
|
break;
|
}
|
}
|
int[] fixedIds = ItemCompoundConfig.GetDisplayArrayByType(compoundModel.id, DisplayItemArray.FixedIds);
|
int[] fixedCounts = ItemCompoundConfig.GetDisplayArrayByType(compoundModel.id, DisplayItemArray.FixedCounts);
|
int[] fixedDisplay = ItemCompoundConfig.GetDisplayArrayByType(compoundModel.id, DisplayItemArray.FixedDisplay);
|
for (int i = 0; i < fixedDisplay.Length; i++)
|
{
|
if (fixedDisplay[i] != 0)
|
{
|
GameObject matPos = sourceItemlist[fixedDisplay[i] - 1];
|
ItemCell itemCell = matPos.transform.Find("GridCell/ItemCell").GetComponent<ItemCell>();
|
int fixedId = fixedIds[i];
|
itemCell.bindIcon.gameObject.SetActive(false);
|
if (isBind)
|
{
|
List<ItemModel> list = null;
|
singlePack.GetItemCountByID(fixedId, out list);
|
if (list != null)
|
{
|
for (int j = 0; j < list.Count; j++)
|
{
|
if (list[j].itemInfo.IsBind == 1)
|
{
|
itemCell.bindIcon.gameObject.SetActive(true);
|
break;
|
}
|
}
|
}
|
}
|
|
}
|
}
|
|
return isBind;
|
}
|
|
public int RefreshComposeSuccessRate(int initRate)
|
{
|
Dictionary<int, ItemModel> addSelectItemDict = selectModel.GetHaveAddSelectItem();
|
|
if (addSelectItemDict == null) return initRate;
|
|
successRate = initRate;
|
|
foreach (var index in addSelectItemDict.Keys)
|
{
|
successRate = composeWinModel.GetComposeSuccessRate(compoundModel,addSelectItemDict[index],successRate);
|
}
|
return successRate;
|
}
|
|
private void OnClickOnekeyPutBtn()
|
{
|
if (compoundModel == null)
|
return;
|
|
if (successRate >= compoundModel.successUpper)
|
{
|
SysNotifyMgr.Instance.ShowTip("ComposeFullToAdd");
|
return;
|
}
|
|
List<ItemModel> onekeyPutlist = selectModel.GetOneKeyPutModel();
|
if(onekeyPutlist.Count < 1)
|
{
|
SysNotifyMgr.Instance.ShowTip("ComposeNothingToAdd");
|
return;
|
}
|
for (int i = 0; i <addItemlist.Count; i++)
|
{
|
GameObject gridCell = addItemlist[i].transform.Find("GridCell").gameObject;
|
ItemCell itemCell = gridCell.transform.Find("ItemCell").GetComponent<ItemCell>();
|
GameObject gridlock = gridCell.transform.Find("GridLock").gameObject;
|
if (gridCell.activeInHierarchy
|
&& !gridlock.activeInHierarchy
|
&& !itemCell.gameObject.activeInHierarchy)
|
{
|
for(int j = 0; j < onekeyPutlist.Count; j++)
|
{
|
if (!selectModel.GetHaveAddSelectItem().ContainsKey(onekeyPutlist[j].itemInfo.ItemPlace))
|
{
|
if(successRate < compoundModel.successUpper)
|
{
|
selectModel.AddHaveAddSelectItem(onekeyPutlist[j].itemInfo.ItemPlace);
|
RefreshSelectItem(onekeyPutlist[j], addItemlist[i], SelectItemType.addons);
|
break;
|
}
|
else
|
{
|
return;
|
}
|
}
|
}
|
}
|
}
|
|
}
|
|
private void OnClickComposeBtn()
|
{
|
SetFixedMatIndex();
|
composeWinModel.SendComposeRequest(compoundModel, fixedItemIndexDict, GetPlayMatEffect(), 1, successRate);
|
}
|
|
private void SetFixedMatIndex()
|
{
|
fixedItemIndexDict.Clear();
|
SinglePackModel singlePack = playerPack.GetSinglePackModel(PackType.rptItem);
|
if (singlePack == null || compoundModel == null) return;
|
int isBind = 0;
|
|
if(IsComposeBind)
|
{
|
isBind = 1;
|
}
|
else
|
{
|
isBind = 0;
|
}
|
int[] fixedIds = ItemCompoundConfig.GetDisplayArrayByType(compoundModel.id, DisplayItemArray.FixedIds);
|
int[] fixedCounts = ItemCompoundConfig.GetDisplayArrayByType(compoundModel.id, DisplayItemArray.FixedCounts);
|
for (int i = 0; i < fixedIds.Length; i++)
|
{
|
List<int> itemIndexlist = singlePack.ItemIndexlistByIsBind(fixedIds[i], fixedCounts[i],isBind);
|
if (itemIndexlist != null)
|
{
|
fixedItemIndexDict.Add(fixedIds[i], itemIndexlist);
|
}
|
|
}
|
}
|
|
private UIEffect GetPlayMatEffect()
|
{
|
if(compoundModel == null) return null;
|
|
int[] fixedIds = ItemCompoundConfig.GetDisplayArrayByType(compoundModel.id,DisplayItemArray.FixedIds);
|
int matTypeCnt = compoundModel.unfixedItemCount + fixedIds.Length;
|
switch (matTypeCnt)
|
{
|
case 1:
|
return oneMatEffect;
|
case 2:
|
return twoMatEffect;
|
case 3:
|
return threeMatEffect;
|
}
|
return null;
|
}
|
|
private void OnComposeAnswer(HA814_tagMCMakeItemAnswer answer)
|
{
|
if (answer.MakeType != (int)MakeType.Def_mitItemCompound)
|
return;
|
|
if (answer.Result == 1)
|
{
|
successEffect.Play();
|
int[] makeIds = ItemCompoundConfig.GetDisplayArrayByType(compoundModel.id,DisplayItemArray.MakeIds);
|
for (int i = 0; i < previewItemlist.Count; i++)
|
{
|
UIEffect targetEffect = previewItemlist[i].transform.Find("GridCell/TargetEffect").GetComponent<UIEffect>();
|
if (i < makeIds.Length)
|
{
|
if(makeIds[i] == answer.MakeItemID)
|
{
|
targetEffect.Play();
|
break;
|
}
|
}
|
}
|
}
|
else
|
{
|
failMatEffect.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>();
|
}
|
}
|
|
}
|
}
|