- Home /
 
 
               Question by 
               craftercis · Jan 23, 2018 at 10:56 AM · 
                c#howhow to  
              
 
              Display clue?
Hey Unity users?
How can i with this script display the clue?
You have to guess the word within the time and I want the answer to appear already for testing. How do I do this?

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 
 public class GameSetup : MonoBehaviour {
 
     public string[] words;
     public string[] clues;
 
     char[] chosenWord;
     char[] chosenClue;
 
     bool left = false;
 
     public Text[] textBoxes;
 
     char[] shuffleString;
 
     GameManager manager;
 
     public bool playing = false;
 
     public char[] guessedWord = new char[8];
     public int guessIndex = 0;
     public Text GuessText;
     public Text timeText;
     public Text clearText;
     public Text clue;
 
     //time
     int mins;
     float secs;
 
     int clears;
 
     private void Awake()
     {
         manager = GameObject.Find("_GameManager").GetComponent<GameManager>();
         StartTimer();
         playing = true;
     }
     private void Start()
     {
         
         int r = (int)Random.Range(0, 2);
         if (r == 0)
         {
             left = true;
         }
         else
         {
             left = false;
         }
         chosenWord = words[Random.Range(0, words.Length)].ToCharArray();
         //chosenClue = clues[Random.Range(0, clues.Length)].ToCharArray();
         shuffleString = new char[chosenWord.Length];
         //shuffleString = new char[chosenClue.Length];
 
         clue.text = clues.ToString();
 
         int index = Random.Range(0, 8);
 
         for (int i = 0; i < chosenWord.Length; i++)
         {
             if (!left) {
                 for (int j = 0; j < 3; j++)
                 {
                     if (index == 7)
                     {
                         index = 0;
                     }
                     else
                     {
                         index++;
                     }
                 }
             }
             else
             {
                 for (int j = 3; j > 0; j--)
                 {
                     if (index == 0)
                     {
                         index = 7;
                     }
                     else
                     {
                         index--;
                     }
                 }
             }
             shuffleString[i] = chosenWord[index];
         }
         for (int i = 0; i < shuffleString.Length; i++)
         {
             textBoxes[i].text = shuffleString[i].ToString();
             textBoxes[i].gameObject.transform.parent.gameObject.GetComponent<ButtonObj>().letter = shuffleString[i];
             textBoxes[i].gameObject.transform.parent.gameObject.GetComponent<ButtonObj>().clicked = false;
         }
         
     }
     private void Update()
     {
         if (playing)
         {
             if (guessIndex == 8)
             {
                 for (int i = 0; i < chosenWord.Length; i++)
                 {
                     if (chosenWord[i] == guessedWord[i])
                     {
                         guessIndex--;
                     }
                 }
                 if (guessIndex == 0)
                 {
                     Start();
                     GuessText.text = "";
                     clears++;
                     clearText.text = clears.ToString();
                 }
             }
             //time
             if (mins <= 0 && secs <= 0)
             {
                 print("game over");
                 playing = false;
                 manager.score = clears;
             }
             else if (secs <= 0)
             {
                 mins--;
                 secs = 60;
             }
             else
             {
                 secs -= Time.deltaTime;
             }
 
             int dispSecs = (int)secs;
 
             string secondString = dispSecs.ToString();
             string minuteString = mins.ToString();
 
             if (secs < 10)
             {
                 secondString = "0" + dispSecs.ToString();
             }
 
             timeText.text = minuteString + ":" + secondString;
         }
     }
     public void ResetGame()
     {
         guessIndex = 0;
         guessedWord = new char[8];
         GuessText.text = "";
         for (int i = 0; i < shuffleString.Length; i++)
         {
             textBoxes[i].gameObject.transform.parent.gameObject.GetComponent<ButtonObj>().clicked = false;
         }
     }
     public void StartTimer()
     {
         mins = manager.startMins;
         secs = manager.startSeconds;
     }
 }
 
 
               
                 
                18bb594b1c6c4a0b595a0b66448c68e3.png 
                (34.9 kB) 
               
 
              
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Illuminating a 3D object's edges OnMouseOver (script in c#)? 1 Answer
Animation editing help? 0 Answers