Exemple #1
0
    //gets a word from the file, parameter is #of lettered word 4 or 5
    public string getStringFromFile(int x)
    {
        //textString holds the string data from the file which will be split by delimeter
        List <string> textString = new List <string>();
        //retString is the string we will return to Start() function
        string retString = "";
        //create Resource functor
        PuzzleResourceClass pr = new PuzzleResourceClass();

        if (x == 5)
        {
            //get 5 letter word list
            textString = new List <string>(pr.GetFive());
        }
        else
        {
            //get 4 letter word list
            textString = new List <string>(pr.GetFour());
        }
        //get a random integer between 0 and thelength(exclusively) of the string
        int r = (int)(Random.Range(0, (float)textString.Count));

        //Get the random tan coordinate from the string array
        retString = textString [(int)r];
        return(retString);
    }
Exemple #2
0
    //This function gets a random tangram string with coordinates from a file.
    string getStringFromFile()
    {
        //textString holds the string data from the file which will be split by delimeter
        //retString is the string we will return to Start() function
        string textString = "", retString;
        //create Resource functor
        PuzzleResourceClass pr = new PuzzleResourceClass();

        //Opens a stream reader

        //check the difficulty of the puzzle
        switch (this.difficulty)
        {
        case 1:
            //load an easy puzzle
            textString = pr.GetTanEasy();
            break;

        case 2:
            //load med puzzle
            textString = pr.GetTanMed();
            break;

        case 3:
            //load hard puzzle
            textString = pr.GetTanDiff();
            break;

        default:
            //Debug.Log ("No Difficulty Assigned");
            return("");
        }
        //clone the split string by ';' delim
        string[] parsedString = (string[])(textString.Split(';')).Clone();
        //get a random integer between 0 and thelength(exclusively) of the string
        int r = (int)(Random.Range(0, (float)parsedString.Length));

        //Get the random tan coordinate from the string array
        retString = parsedString [(int)r];
#if DEBUG
        Debug.Log(string.Format("Tangram Puzzle: Difficulty: {0}, Index: {1}", this.difficulty, r));
#endif
        return(retString);
    }