using System.Collections.Generic; using UnityEngine; namespace Wizard; public class LoadingDownLoadStoryView : MonoBehaviour { [SerializeField] private UITexture _stillTexture; [SerializeField] private UILabel _storyTitleLabel; [SerializeField] private UILabel _storyValueLabel; [SerializeField] private UIToggle _indicatorBase; private List _indicatorList = new List(); private List _loadSceneStoryDatas = new List(); private const string FORMAT_STORY_NUMBER = "LoadStory_Number_1"; private int _currentIndex; public void Initialize() { _ = Data.SystemText; int result = 0; int.TryParse(Data.SystemText.Get("LoadStory_Number_1"), out result); GameObject gameObject = _indicatorBase.transform.parent.gameObject; for (int i = 1; i <= result; i++) { _loadSceneStoryDatas.Add(new LoadSceneStoryData(i)); _indicatorList.Add(NGUITools.AddChild(gameObject, _indicatorBase.gameObject).GetComponent()); } _indicatorBase.gameObject.SetActive(value: false); gameObject.GetComponent().Reposition(); SetStoryInfo(_currentIndex); } private void SetStoryInfo(int index) { LoadSceneStoryData loadSceneStoryData = _loadSceneStoryDatas[index]; _storyTitleLabel.text = loadSceneStoryData.StoryTitle; _storyValueLabel.text = loadSceneStoryData.StoryValue; _stillTexture.mainTexture = Resources.Load(loadSceneStoryData.StillImageName); UpdateIndicator(index); } public void ChangeStoryImage(bool isRight) { if (isRight) { UpdateIndexToNext(); } else { UpdateIndexToPrev(); } } private void UpdateIndexToNext() { _currentIndex = (_currentIndex + 1) % _loadSceneStoryDatas.Count; SetStoryInfo(_currentIndex); } private void UpdateIndexToPrev() { if (_currentIndex > 0) { _currentIndex--; } else { _currentIndex = _loadSceneStoryDatas.Count - 1; } SetStoryInfo(_currentIndex); } private void UpdateIndicator(int index) { if (_indicatorList.Count > 1) { _indicatorList[index].value = true; } } }