using System; using System.Collections; using System.Collections.Generic; using Cute; using UnityEngine; namespace Wizard; public class FirstTips : MonoBehaviour { public enum TipsType { Deck = 0, CardCreate = 1, ChallengeTwoPick = 2, SoroPlay = 3, Battle = 4, Card = 5, VideoSharing = 6, VideoRecordingIosJpn = 7, VideoRecordingIosEng = 8, VideoRecordingAndroidEng = 9, ShopCardPack = 10, CardDestruct = 11, Convention = 12, BattleBeforeFormatUser = 13, DeckBeforeFormatUser = 14, DeckAfterFormatUser = 15, Colosseum = 16, ColosseumInfo = 17, Challenge = 18, Sealed = 19, GuildNotJoining = 20, GuildJoining = 21, SoroPlayOnlydAssist = 22, SpotCardExchange = 23, GachaPointExchange = 24, Quest = 25, AdditionalPuzzle = 26, Competition = 27, Crossover = 28, Bingo = 29, NeutralPopularityVote = 30, LeaderPopularityVote = 31, CompetitionVer2 = 32, MyRotationDeck = 33, BossRush = 34, CompetitionTwoPick = 35, RedEtherCampaign = 36, SoroPlay2 = 37, ResurgentCard = 38, ColosseumWindFall = 39, HeroesFreeMatch = 40, HeroesGrandPrix = 41, TimeslipResurgentCard = 42, Colosseum2PickChaos = 43, ChallengeTwoPickCube = 44, ChallengeTwoPickChaos = 45, Max = 46, MyPage = 1001, BattlePathSeason = 1002 } protected enum Csv { TipsType, TextId, Mask, PrefabName, ImageName } public const float TWEEN_ALPHA_TIME = 0.5f; [SerializeField] private UITexture m_ImageTex; [SerializeField] private UILabel m_WindowLabel; [SerializeField] private GameObject m_NextTextMarkObject; [SerializeField] private GameObject m_MaskObject; [SerializeField] private TweenAlpha m_TweenAlpha; [SerializeField] private UIPanel _panel; private ArrayList m_Csv; private List m_TipsData; private IEnumerable _tipsTypes; private int m_PageNo; private int m_PageMaxNo; private GameObject m_TipsPrefab; private bool m_DestoryFlg; private bool _isResourceLoadFinish; private int _startPage; private List m_AssetFileList = new List(); private ResourcesManager.AssetLoadPathType m_AssetType = ResourcesManager.AssetLoadPathType.FirstTips; private bool _isEnableBackKeyChange = true; private Action _onFinish; private int _seasonId; private const string TIPS_CSV_NAME = "firsttips"; public bool IsEnableBackKeyChange { get { return _isEnableBackKeyChange; } set { _isEnableBackKeyChange = value; } } public void CreateTips(TipsType in_TipsType, Action onFinish) { CreateTips(new TipsType[1] { in_TipsType }, onFinish); } public void CreateTips(IEnumerable tipsTypes, Action onFinish, int startPage = 0, int seasonId = 0) { _startPage = startPage; _onFinish = onFinish; _panel.alpha = 0f; GameMgr.GetIns().GetInputMgr().isBackKeyEnable = false; m_TweenAlpha.enabled = false; m_AssetFileList.Clear(); _tipsTypes = tipsTypes; _seasonId = seasonId; List list = new List(); string assetTypePath = Toolbox.ResourcesManager.GetAssetTypePath("firsttips", ResourcesManager.AssetLoadPathType.Master); list.Add(assetTypePath); m_AssetFileList.Add(assetTypePath); UIManager.GetInstance().StartCoroutine(Toolbox.ResourcesManager.LoadAssetGroupAsync(list, _CsvLoadEnd)); } protected void _CsvLoadEnd() { string assetTypePath = Toolbox.ResourcesManager.GetAssetTypePath("etc/firsttips", ResourcesManager.AssetLoadPathType.Master, isfetch: true); TextAsset textAsset = Toolbox.ResourcesManager.LoadObject(assetTypePath); m_Csv = Utility.ConvertCSV(textAsset.text); m_TipsData = new List(); foreach (TipsType tipsType in _tipsTypes) { foreach (ArrayList item in m_Csv) { string[] array = (string[])item.ToArray(typeof(string)); if (int.Parse(array[0]) == (int)tipsType) { m_TipsData.Add(array); } } } m_PageMaxNo = m_TipsData.Count; List list = new List(); foreach (string[] tipsDatum in m_TipsData) { if (tipsDatum[4] != "") { string assetTypePath2 = Toolbox.ResourcesManager.GetAssetTypePath(tipsDatum[4], m_AssetType); assetTypePath2 = ConvertSeasonImageFileName((TipsType)int.Parse(tipsDatum[0]), assetTypePath2); if (!list.Contains(assetTypePath2)) { list.Add(assetTypePath2); m_AssetFileList.Add(assetTypePath2); } } if (tipsDatum[3] != "") { string assetTypePath2 = Toolbox.ResourcesManager.GetAssetTypePath(tipsDatum[3], m_AssetType); if (!list.Contains(assetTypePath2)) { list.Add(assetTypePath2); m_AssetFileList.Add(assetTypePath2); } } } UIManager.GetInstance().StartCoroutine(Toolbox.ResourcesManager.LoadAssetGroupAsync(list, _ResourceLoadEnd)); } protected void _ResourceLoadEnd() { _isResourceLoadFinish = true; m_TweenAlpha.enabled = true; _PageSet(_startPage); } public void TipsClickCallBack() { if (_isResourceLoadFinish && !m_DestoryFlg) { m_PageNo++; if (m_PageMaxNo > m_PageNo) { GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_FEED_TEXT); _PageSet(m_PageNo); } else if (m_PageNo == m_PageMaxNo) { GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_CANCEL); m_TweenAlpha.PlayReverse(); m_DestoryFlg = true; StartCoroutine(Destroy()); } } } protected void _PageSet(int in_PageNo) { m_PageNo = in_PageNo; SystemText systemText = Data.SystemText; m_WindowLabel.SetWrapText(systemText.Get(m_TipsData[m_PageNo][1])); if (m_PageMaxNo != 1) { m_NextTextMarkObject.SetActive(value: true); } else { m_NextTextMarkObject.SetActive(value: false); } if ("1" == m_TipsData[m_PageNo][2]) { m_MaskObject.SetActive(value: true); } else { m_MaskObject.SetActive(value: false); } string text = m_TipsData[m_PageNo][4]; if (text != "") { string assetTypePath = Toolbox.ResourcesManager.GetAssetTypePath(text, m_AssetType, isfetch: true); assetTypePath = ConvertSeasonImageFileName((TipsType)int.Parse(m_TipsData[m_PageNo][0]), assetTypePath); Texture mainTexture = Toolbox.ResourcesManager.LoadObject(assetTypePath); m_ImageTex.mainTexture = mainTexture; } string path = m_TipsData[m_PageNo][3]; if (m_TipsData[m_PageNo][3] != "") { string assetTypePath2 = Toolbox.ResourcesManager.GetAssetTypePath(path, m_AssetType, isfetch: true); m_TipsPrefab = Toolbox.ResourcesManager.LoadObject(assetTypePath2); m_TipsPrefab = UnityEngine.Object.Instantiate(m_TipsPrefab); m_TipsPrefab.transform.parent = m_ImageTex.gameObject.transform; m_TipsPrefab.transform.localPosition = Vector3.zero; m_TipsPrefab.transform.localScale = Vector3.one; } else if (m_TipsPrefab != null) { UnityEngine.Object.Destroy(m_TipsPrefab); m_TipsPrefab = null; } } private static bool IsAllwaysDispaly(TipsType in_TipsType) { if (in_TipsType > TipsType.Max) { return true; } return false; } private string ConvertSeasonImageFileName(TipsType tipsType, string imagePath) { if (tipsType == TipsType.BattlePathSeason || tipsType == TipsType.Colosseum2PickChaos || tipsType == TipsType.ChallengeTwoPickChaos) { return string.Format(imagePath, _seasonId); } return imagePath; } public static bool IsFirstTipsOpen(TipsType in_TipsType) { if (IsAllwaysDispaly(in_TipsType)) { return true; } if (in_TipsType == TipsType.ColosseumInfo) { return true; } if ((Fix(long.Parse(PlayerPrefsWrapper.GetValue(PlayerPrefsWrapper.FIRST_TIPS))) & (1L << (int)in_TipsType)) != 0L) { return false; } return true; } private IEnumerator Destroy() { float time = 0f; while (time < 0.5f) { time += Time.deltaTime; yield return null; } foreach (TipsType tipsType in _tipsTypes) { SaveFinishFirstTips(tipsType); } _onFinish.Call(); UnityEngine.Object.Destroy(base.gameObject); } public static void ClearTipsFlag() { PlayerPrefsWrapper.SetValue(PlayerPrefsWrapper.FIRST_TIPS, 0.ToString()); } public static void SaveFinishFirstTips(TipsType tips) { if (!IsAllwaysDispaly(tips)) { long value = long.Parse(PlayerPrefsWrapper.GetValue(PlayerPrefsWrapper.FIRST_TIPS)); value = Fix(value); PlayerPrefsWrapper.SetValue(PlayerPrefsWrapper.FIRST_TIPS, (value | (1L << (int)tips)).ToString()); } } protected void OnDestroy() { if (m_AssetFileList.Count != 0) { Toolbox.ResourcesManager.RemoveAssetGroup(m_AssetFileList); } if (IsEnableBackKeyChange) { GameMgr.GetIns().GetInputMgr().isBackKeyEnable = true; } } public static long Fix(long value) { if (value < 0) { long num = Convert.ToInt64("0x00000000ffffffff", 16); value &= num; PlayerPrefsWrapper.SetValue(PlayerPrefsWrapper.FIRST_TIPS, value.ToString()); } return value; } }