using Snxxz.UI; using System; using System.Collections.Generic; using TableConfig; using UnityEngine; using UnityEngine.UI; namespace Snxxz.UI { public class ComposeTicketWin : Window { [SerializeField] GameObject composeUIShowObj; [SerializeField] GameObject noneComposeObj; [SerializeField] ScrollerController cellCtrl; [SerializeField] List sourceItemlist = new List(); [SerializeField] List previewItemlist = new List(); [SerializeField] Text successRateText; [SerializeField] Text _moneyCountText; [SerializeField] GameObject costMoneyObj; [SerializeField] Button composeBtn; [SerializeField] Button allComposeBtn; [SerializeField] UIEffect composeEffect; 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()); } } PackModelInterface _modelInterface; PackModelInterface modelInterface { get { return _modelInterface ?? (_modelInterface = ModelCenter.Instance.GetModel()); } } GetItemPathModel ItemPathModel { get { return ModelCenter.Instance.GetModel(); } } private Dictionary>> firstTypeDict = null; private Dictionary> secondTypeDict = null; private List thirdTypelist = null; private int curSecondType = 0; private int curThirdType = 0; private int preSecondType = 0; [SerializeField] int initSuccessRate = 10000; ItemCompoundConfig compoundModel = null; SelectEquipModel _selectModel; private Dictionary> fixedItemIndexDict = new Dictionary>(); SelectEquipModel selectModel { get { return _selectModel ?? (_selectModel = ModelCenter.Instance.GetModel()); } } AchievementGuideEffect guidEffect = null; protected override void BindController() { cellCtrl.OnRefreshCell += RefreshCell; cellCtrl.vertical = true; cellCtrl.lockType = EnhanceLockType.KeepVertical; composeWinModel.ResetModelEvent += ResetModel; } protected override void AddListeners() { composeBtn.AddListener(OnClickComposeBtn); allComposeBtn.AddListener(ClickAllComposeBtn); } protected override void OnPreOpen() { DTCA814_tagMCMakeItemAnswer.MakeItemAnswerEvent += OnComposeAnswer; firstTypeDict = composeWinModel.GetFirstTypeModel((int)ComposeFuncType.Ticket); bool isJumpTo = false; if (AchievementGoto.guideAchievementId != 0) { SuccessConfig successConfig = Config.Instance.Get(AchievementGoto.guideAchievementId); if (successConfig.Type == 69) { isJumpTo = true; curSecondType = composeWinModel.secondType; curThirdType = composeWinModel.thirdType; secondTypeDict = composeWinModel.GetSecondTypeModel((int)ComposeFuncType.Ticket, composeWinModel.secondType); ClickSecondTypeUICtrl(); composeWinModel.ResetJumpToModel(); } } else { if(composeWinModel.secondType != 0) { isJumpTo = true; curSecondType = composeWinModel.secondType; curThirdType = composeWinModel.thirdType; secondTypeDict = composeWinModel.GetSecondTypeModel((int)ComposeFuncType.Ticket,composeWinModel.secondType); ClickSecondTypeUICtrl(); composeWinModel.ResetJumpToModel(); } } CreateCell(); if (curSecondType == 0) { RefreshUI(null); } if (compoundModel != null) { 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() { DTCA814_tagMCMakeItemAnswer.MakeItemAnswerEvent -= OnComposeAnswer; } protected override void OnAfterClose() { } private void ResetModel() { curSecondType = 0; curThirdType = 0; preSecondType = 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 firstTypeDict[secondType].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