SHARE
TWEET

Untitled

a guest Oct 16th, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. public class SetParagraphText : MonoBehaviour
  7. {
  8.     public int ChapterStatus;
  9.     public int PreviousChapterStatus;
  10.     public string ChapterStatusString;
  11.     public string PreviousChapterStatusString;
  12.     private GameObject StoryButton1;
  13.     private GameObject StoryButton2;
  14.     private GameObject StoryButton3;
  15.     private GameObject StoryButton4;
  16.     private GameObject StoryButton5;
  17.     private GameObject SoundManager;
  18.     SoundManagerScript SoundManagerClass;
  19.    
  20.     // Start is called before the first frame update
  21.     void Start()
  22.     {
  23. //          int ChapterStatus = 1; 
  24.             SoundManager = GameObject.Find("SoundManager");
  25.             SoundManagerClass = SoundManager.GetComponent <SoundManagerScript> ();
  26.     }
  27.  
  28.    
  29.     public void FindStoryButtons()
  30.     {
  31. //          Debug.Log("Finding Story Buttons");
  32.             StoryButton1 = GameObject.Find("StoryButton1");
  33.             StoryButton2 = GameObject.Find("StoryButton2");
  34.             StoryButton3 = GameObject.Find("StoryButton3");
  35.             StoryButton4 = GameObject.Find("StoryButton4");
  36.             StoryButton5 = GameObject.Find("StoryButton5");
  37. //          Debug.Log("Story buttons found!");
  38.     }
  39.    
  40.     public void ChangeStoryByString(string numberinput)
  41.     {
  42.        
  43.         PreviousChapterStatus = ChapterStatus;     
  44.         int.TryParse(numberinput, out int realnumberinput);    
  45.         ChapterStatus = realnumberinput;
  46.         GetComponent<Text>().text = LoadStoryData.storylist[realnumberinput].storytext;
  47.  
  48.         string TextToChangeButton1To = LoadStoryData.storylist[ChapterStatus].button1;
  49.         if(TextToChangeButton1To == "blank") {
  50.             StoryButton2.SetActive(false);
  51.         }
  52.         else {
  53.             StoryButton1.SetActive(true);  
  54.             StoryButton1.GetComponent <SetButton1Text> ().ChangeButton1(); 
  55.         }
  56.  
  57.         string TextToChangeButton2To = LoadStoryData.storylist[ChapterStatus].button2;
  58.         if(TextToChangeButton2To == "blank") {
  59.             StoryButton2.SetActive(false);
  60.         }
  61.         else {
  62.             StoryButton2.SetActive(true);  
  63.             StoryButton2.GetComponent <SetButton2Text> ().ChangeButton2(); 
  64.         }      
  65.        
  66.         string TextToChangeButton3To = LoadStoryData.storylist[ChapterStatus].button3;
  67.         if(TextToChangeButton3To == "blank") {
  68.             StoryButton3.SetActive(false);
  69.         }
  70.         else {
  71.             StoryButton3.SetActive(true);  
  72.             StoryButton3.GetComponent <SetButton3Text> ().ChangeButton3(); 
  73.         }          
  74.        
  75.         string TextToChangeButton4To = LoadStoryData.storylist[ChapterStatus].button4;
  76.         if(TextToChangeButton4To == "blank") {
  77.             StoryButton4.SetActive(false);
  78.         }
  79.         else {
  80.             StoryButton4.SetActive(true);  
  81.             StoryButton4.GetComponent <SetButton4Text> ().ChangeButton4(); 
  82.         }          
  83.        
  84.         string TextToChangeButton5To = LoadStoryData.storylist[ChapterStatus].button5;
  85.         if(TextToChangeButton5To == "blank") {
  86.             StoryButton5.SetActive(false);
  87.         }
  88.         else {
  89.             StoryButton5.SetActive(true);  
  90.             StoryButton5.GetComponent <SetButton5Text> ().ChangeButton5(); 
  91.         }          
  92.        
  93.         SoundManagerClass.PlaySound ("VOpart"+ChapterStatus);
  94.         PlayerPrefs.SetInt("chapter", ChapterStatus);
  95.         PlayerPrefs.Save ();
  96.         Debug.Log("Chapter Status is "+ChapterStatus+" and Previous Chapter is "+PreviousChapterStatus);   
  97.     }
  98.                
  99.  
  100.     public void ChangeStoryByVariableButton(int ButtonID) {
  101.         PreviousChapterStatus = ChapterStatus;
  102.  
  103.         switch (ButtonID) {
  104.             case 1:
  105.                 ChapterStatus = LoadStoryData.storylist[PreviousChapterStatus].button1link;
  106.                 break;
  107.             case 2:
  108.                 ChapterStatus = LoadStoryData.storylist[PreviousChapterStatus].button2link;
  109.                 break;             
  110.             case 3:
  111.                 ChapterStatus = LoadStoryData.storylist[PreviousChapterStatus].button3link;
  112.                 break;             
  113.             case 4:
  114.                 ChapterStatus = LoadStoryData.storylist[PreviousChapterStatus].button4link;
  115.                 break;
  116.             case 5:
  117.                 ChapterStatus = LoadStoryData.storylist[PreviousChapterStatus].button5link;
  118.                 break;
  119.             default:
  120.                 ChapterStatus = 0;
  121.                 break;
  122.         }
  123.        
  124.         GetComponent<Text>().text = LoadStoryData.storylist[ChapterStatus].storytext;
  125.  
  126.         string TextToChangeButton1To = LoadStoryData.storylist[ChapterStatus].button1;
  127.         if(TextToChangeButton1To == "blank") {
  128.             StoryButton1.SetActive(false);
  129.         }
  130.         else {
  131.             StoryButton1.SetActive(true);  
  132.             StoryButton1.GetComponent <SetButton1Text> ().ChangeButton1(); 
  133.         }  
  134.  
  135.         string TextToChangeButton2To = LoadStoryData.storylist[ChapterStatus].button2;
  136.         if(TextToChangeButton2To == "blank") {
  137.             StoryButton2.SetActive(false);
  138.         }
  139.         else {
  140.             StoryButton2.SetActive(true);  
  141.             StoryButton2.GetComponent <SetButton2Text> ().ChangeButton2(); 
  142.         }      
  143.        
  144.         string TextToChangeButton3To = LoadStoryData.storylist[ChapterStatus].button3;
  145.         if(TextToChangeButton3To == "blank") {
  146.             StoryButton3.SetActive(false);
  147.         }
  148.         else {
  149.             StoryButton3.SetActive(true);  
  150.             StoryButton3.GetComponent <SetButton3Text> ().ChangeButton3(); 
  151.         }          
  152.        
  153.         string TextToChangeButton4To = LoadStoryData.storylist[ChapterStatus].button4;
  154.         if(TextToChangeButton4To == "blank") {
  155.             StoryButton4.SetActive(false);
  156.         }
  157.         else {
  158.             StoryButton4.SetActive(true);  
  159.             StoryButton4.GetComponent <SetButton4Text> ().ChangeButton4(); 
  160.         }          
  161.        
  162.         string TextToChangeButton5To = LoadStoryData.storylist[ChapterStatus].button5;
  163.         if(TextToChangeButton5To == "blank") {
  164.             StoryButton5.SetActive(false);
  165.         }
  166.         else {
  167.             StoryButton5.SetActive(true);  
  168.             StoryButton5.GetComponent <SetButton5Text> ().ChangeButton5(); 
  169.         }          
  170.        
  171.         SoundManagerClass.PlaySound ("VOpart"+ChapterStatus);
  172.         PlayerPrefs.SetInt("chapter", ChapterStatus);
  173.         PlayerPrefs.Save ();
  174.         Debug.Log("Chapter Status is "+ChapterStatus+" and Previous Chapter is "+PreviousChapterStatus);   
  175.     }  
  176.  
  177.  
  178. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top