using System.Collections; using System.Collections.Generic; using System.IO; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; public class IntroOutroInfo : MonoBehaviour { public GameObject introPanel; public GameObject outroPanel; private TextAsset introOutroTexts; private string currentIndexString; private int currentIndex; private void Awake() { currentIndex = SceneManager.GetActiveScene().buildIndex; if (currentIndex <= 9) currentIndexString = "0" + currentIndex; else currentIndexString = currentIndex.ToString(); introOutroTexts = Resources.Load<TextAsset>("IntroOutroTexts"); string inOutText = introOutroTexts.text; string currentLevelText = ""; for (int i = 0; i < inOutText.Length; i++) { if(inOutText[i] == ':') { string levelIndexText = ""; levelIndexText += inOutText[i - 2]; levelIndexText += inOutText[i - 1]; if(levelIndexText == currentIndexString) { i += 3; while (inOutText[i] != '*') { currentLevelText += inOutText[i]; i++; } break; } } } outroPanel.GetComponentInChildren<Text>().text = currentLevelText; if (currentIndex == 1) { currentLevelText = ""; int i = 23; while (inOutText[i] != '*') { currentLevelText += inOutText[i]; i++; } introPanel.GetComponentInChildren<Text>().text = currentLevelText; } } public GameObject GetIntroPanel() { return introPanel; } public GameObject GetOutroPanel() { return outroPanel; } public void SetGoodOrBadText() { currentIndex = SceneManager.GetActiveScene().buildIndex; currentIndexString = currentIndex.ToString(); introOutroTexts = Resources.Load<TextAsset>("IntroOutroTexts"); string inOutText = introOutroTexts.text; string currentLevelText = ""; for (int i = 0; i < inOutText.Length; i++) { if (inOutText[i] == ':') { string levelIndexText = ""; char gobIndicator; levelIndexText += inOutText[i - 3]; levelIndexText += inOutText[i - 2]; gobIndicator = inOutText[i - 1]; //good or bad indicator if (levelIndexText == currentIndexString && gobIndicator == 'a') { i += 3; while (inOutText[i] != '*') { currentLevelText += inOutText[i]; i++; } break; } } } outroPanel.GetComponentInChildren<Text>().text = currentLevelText; } }