using Snxxz.UI; using System; using System.Collections.Generic; 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 sourceItemlist = new List(); [SerializeField] List previewItemlist = new List(); [SerializeField] List addItemlist = new List(); [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()); } } ItemTipsModel _itemTipsModel; ItemTipsModel itemTipsModel { get { return _itemTipsModel ?? (_itemTipsModel = 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 successRate = 0; [SerializeField] int initSuccessRate = 2000; ItemCompoundConfig compoundModel = null; SelectEquipModel _selectModel; SelectEquipModel selectModel { get { return _selectModel ?? (_selectModel = ModelCenter.Instance.GetModel()); } } PlayerPackModel _playerPack; PlayerPackModel playerPack { get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel()); } } 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(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) { 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