using System; using System.Collections.Generic; using UnityEngine; namespace Wizard; public class BannerDialog : MonoBehaviour { [SerializeField] private UICenterOnChild _uiCenterOnChild; [SerializeField] private int _widthContentSize = 830; [SerializeField] private UITexture _bannerObj_1; [SerializeField] private UITexture _bannerObj_2; [SerializeField] private BoxCollider _leftButton; [SerializeField] private BoxCollider _rightButton; [SerializeField] private UIToggle indicatorBase; private UITexture _currentBannerObj; private int _currentTextureIndex; private List _listBannerTexture; private List _indicatorList = new List(); private bool _isAnimation; private List _bannerTitleList; private DialogBase _dialog; private bool _isCreateEnd; public void Init(List bannerTextureList, List bannerTitleList, DialogBase dialog) { _listBannerTexture = bannerTextureList; _currentTextureIndex = 0; _currentBannerObj = _bannerObj_1; _bannerTitleList = bannerTitleList; _dialog = dialog; _uiCenterOnChild.onFinished = _OnFinishedCenterChild; _bannerObj_1.transform.localPosition = Vector3.zero; _bannerObj_2.transform.localPosition = new Vector3(_widthContentSize, 0f, 0f); GameObject gameObject = indicatorBase.transform.parent.gameObject; if (_listBannerTexture.Count <= 1) { gameObject.SetActive(value: false); _rightButton.gameObject.SetActive(value: false); _leftButton.gameObject.SetActive(value: false); _bannerObj_2.gameObject.SetActive(value: false); } else { gameObject.SetActive(value: true); _rightButton.gameObject.SetActive(value: true); _leftButton.gameObject.SetActive(value: true); _indicatorList.Add(indicatorBase); for (int i = 1; i < _listBannerTexture.Count; i++) { _indicatorList.Add(NGUITools.AddChild(gameObject, indicatorBase.gameObject).GetComponent()); } gameObject.GetComponent().Reposition(); UpdateIndicator(_currentTextureIndex); } _bannerObj_1.mainTexture = _listBannerTexture[_currentTextureIndex]; UpdateDialogTitle(_currentTextureIndex); _isCreateEnd = true; } private void _OnFinishedCenterChild() { _isAnimation = false; } private void UpdateDialogTitle(int index) { if (_dialog != null && _bannerTitleList != null) { _dialog.SetTitleLabel(_bannerTitleList[index]); } } private void UpdateIndicator(int index) { if (_indicatorList.Count > 1) { _indicatorList[index].value = true; } } }