using Snxxz.UI; using System; using System.Collections.Generic; using TableConfig; using UnityEngine; using UnityEngine.UI; namespace Snxxz.UI { public class ComposeEquipWin : Window { [SerializeField] ScrollerController cellCtrl; [SerializeField] ScrollerController equipTypeLineCellCtrl; [SerializeField] List sourceItemlist = new List(); [SerializeField] List previewItemlist = new List(); [SerializeField] Text successRateText; [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()); } } ItemTipsModel _itemTipsModel; ItemTipsModel itemTipsModel { get { return _itemTipsModel ?? (_itemTipsModel = ModelCenter.Instance.GetModel()); } } PlayerPackModel _playerPack; PlayerPackModel playerPack { get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel()); } } GetItemPathModel ItemPathModel { get { return ModelCenter.Instance.GetModel(); } } private Dictionary>> firstTypeDict = null; private Dictionary> secondTypeDict = null; private List thirdTypelist = null; Dictionary> fixedItemIndexDict = new Dictionary>(); 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; int successRate = 0; SelectEquipModel _selectModel; SelectEquipModel selectModel { get { return _selectModel ?? (_selectModel = ModelCenter.Instance.GetModel()); } } protected override void BindController() { cellCtrl.OnRefreshCell += RefreshCell; 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() { selectModel.selectEquipEvent += RefreshSelectItem; DTCA814_tagMCMakeItemAnswer.MakeItemAnswerEvent += OnComposeAnswer; UIEventTrigger.Get(helpBtn.gameObject).OnDown = OnClickHelpBtn; UIEventTrigger.Get(helpBtn.gameObject).OnUp = OnDownUp; successRate = 0; firstTypeDict = composeWinModel.GetFirstTypeModel((int)ComposeFuncType.Equip); CreateCell(); if(curSecondType == 0) { RefreshUI(null); } if (compoundModel != null) { RefreshUI(compoundModel); } } protected override void OnAfterOpen() { 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; preThirdType = 0; curComposeEquipIndex = -1; compoundModel = null; } private void CreateCell() { cellCtrl.Refresh(); if(curSecondType == 0) { ChangeUIState(true, false,false); } if(firstTypeDict != null) { foreach (int secondType in firstTypeDict.Keys) { cellCtrl.AddCell(ScrollerDataType.Header,secondType); if(secondType == curSecondType) { foreach (int thirdType in firstTypeDict[secondType].Keys) { if (thirdType != 0) { cellCtrl.AddCell(ScrollerDataType.Normal, thirdType); } } } } } cellCtrl.Restart(); if (secondTypeDict != null) { if (secondTypeDict.Count >= 1 && curSecondType != 0 && curThirdType == 1) { int remain = curSecondType - firstTypeDict.Count; if(remain > 0) { cellCtrl.JumpIndex(curSecondType- remain); } else { cellCtrl.JumpIndex(curSecondType - 1); } } } } private void RefreshCell(ScrollerDataType type, CellView cell) { Image icon = cell.transform.Find("BtnIcon").GetComponent(); Text name = cell.transform.Find("BtnText").GetComponent(); Button cellBtn = cell.GetComponent