Пример #1
0
        // Create word objects. Takes in the current level (category of words) and a list of objects (words).
        public static void CreateWordObjects(string level, string[] objects)
        {
            Vector3[] position = new Vector3[objects.Length];      // stores the desired position for each object
            float[]   scale    = new float[objects.Length];        // stores the appropriate scale for each object

            // Set x-position for each object
            if (objects.Length == 5)
            {
                float x1 = 6;
                float x2 = 3;
                float y1 = 2.5f;

                position = new Vector3[5] {
                    new Vector3(-x1, 0, 0),
                    new Vector3(0, y1, 0),
                    new Vector3(x1, 0, 0),
                    new Vector3(x2, -y1, 0),
                    new Vector3(-x2, -y1, 0)
                };
            }

            for (int i = 0; i < objects.Length; i++)
            {
                // Get appropriate scale for the object (info stored in WordProperties script)
                scale[i] = WordProperties.GetWordProperties(objects[i]).ObjScale();

                // Instantiate word object, according to the given input
                ObjectProperties obj = ObjectProperties.CreateInstance(objects [i], "WordObject", position [i], new Vector3(scale [i], scale [i], 1), level + "/" + objects [i], "Words/" + objects [i]);
                ObjectProperties.InstantiateObject(obj);
            }
        }
Пример #2
0
        // make a ghost letter appear in an uncompleted blank
        // as a hint to the user
        public static void ShowLetterHint()
        {
            List <GameObject> unoccupiedTargets = UnoccupiedTargets("TargetBlank");
            int    i          = 0;
            string letterName = unoccupiedTargets [i].name;             // get letter that we want to create a hint for

            // create a letter if not already created
            if (GameObject.Find("Hint" + letterName) == null)
            {
                ObjectProperties letter = ObjectProperties.CreateInstance("Hint" + letterName, "Hint", unoccupiedTargets [i].transform.position, new Vector3(WordCreation.letterScale, WordCreation.letterScale, 1), "Letters/" + letterName, null);
                ObjectProperties.InstantiateObject(letter);
            }

            // find the letter just created / already created
            GameObject hint = GameObject.Find("Hint" + letterName);

            // move letter to center of corresponding blank
            hint.transform.position = unoccupiedTargets [i].transform.position;

            // play phoneme sound of the letter
            unoccupiedTargets [i].audio.Play();

            // move letter in front of the background (to z = -3) to make visible
            LeanTween.moveZ(hint, -3, .01f).setDelay(0f);

            // change color of letter to purple and then back to black
            LeanTween.color(hint, Color.magenta, 1f).setDelay(0f);
            LeanTween.color(hint, Color.black, 1f).setDelay(1f);

            // move letter behind the background (to z = 3) to make invisible
            LeanTween.moveZ(hint, 3f, .01f).setDelay(2f);
        }
Пример #3
0
        //<summary>
        // create word object
        //</summary>
        void CreateWordImage(string word, float scale)
        {
            float y = 3;             // y-position of object
            // instantiate object
            ObjectProperties Obj = ObjectProperties.CreateInstance(word, "WordObject", new Vector3(0, y, 0),
                                                                   new Vector3(scale, scale, 1), ProgressManager.currentLevel + "/" + word, "Words/" + word);

            ObjectProperties.InstantiateObject(Obj);
        }
Пример #4
0
        // give user hint about what letter a particular sound is pronouncing
        public static void ShowSoundHint()
        {
            // find movable sound blanks
            GameObject[] mov = GameObject.FindGameObjectsWithTag("MovableBlank");

            // loop through sound blanks
            foreach (GameObject go in mov)
            {
                // choose first sound blank that is still draggable
                // i.e. hasn't been dragged onto a jar/letter yet
                if (go.GetComponent <PanGesture> ().enabled == true)
                {
                    // get position of sound blank
                    Vector3 posn = go.transform.position;

                    // sound blank rotates halfway around and fades out
                    LeanTween.rotateAround(go, Vector3.right, 180, 1f);
                    LeanTween.alpha(go, 0f, .5f).setDelay(.5f);

                    // create letter if one doesn't already exist
                    if (GameObject.Find("Hint" + go.name) == null)
                    {
                        ObjectProperties letter = ObjectProperties.CreateInstance("Hint" + go.name, "Hint", posn, new Vector3(WordCreation.letterScale * .9f, WordCreation.letterScale * .9f, 1), "Letters/" + go.name, null);
                        ObjectProperties.InstantiateObject(letter);
                    }

                    // find the letter just created / already created
                    GameObject hint = GameObject.Find("Hint" + go.name);

                    // move letter to center of corresponding sound blank
                    hint.transform.position = new Vector3(go.transform.position.x, go.transform.position.y, 3);

                    // play phoneme sound of letter
                    go.audio.PlayDelayed(1f);

                    // letter fades in and moves in front of background to z = -3
                    LeanTween.alpha(hint, 0f, .01f);
                    LeanTween.moveZ(hint, -3, .01f).setDelay(1f);
                    LeanTween.alpha(hint, 1f, .01f).setDelay(1f);

                    // letter changes color to green and then back to black
                    LeanTween.color(hint, Color.green, 1f).setDelay(1f);
                    LeanTween.color(hint, Color.black, 1f).setDelay(2f);

                    // letter fades out and moves behind background to z = 3
                    LeanTween.alpha(hint, 0f, .01f).setDelay(3f);
                    LeanTween.moveZ(hint, 3, .01f).setDelay(3f);

                    // sound blank rotates back around and fades in
                    LeanTween.alpha(go, 1f, .5f).setDelay(3f);
                    LeanTween.rotateAround(go, Vector3.left, 180, 1f).setDelay(3f);

                    // exit loop once a hint letter has been created
                    break;
                }
            }
        }
Пример #5
0
 //<summary>
 // create jars
 //</summary>
 void CreateJars()
 {
     // find letters
     GameObject[] gos = GameObject.FindGameObjectsWithTag(Constants.Tags.TAG_TARGET_LETTER);
     foreach (GameObject go in gos)
     {
         // get position of letter
         Vector3 letterPosn = new Vector3(go.transform.position.x, go.transform.position.y, 1.5f);
         // instantiate jar behind letter
         ObjectProperties jar = ObjectProperties.CreateInstance("Jar", "Jar", letterPosn,
                                                                new Vector3(.45f, .45f, 1), "Jar", null);
         ObjectProperties.InstantiateObject(jar);
     }
 }
Пример #6
0
        // Create word with letters. Takes in desired word, list of phonemes in word, tag for each letter (MovableLetter or TargetLetter),
        // and game mode that word will be created in (Learn, SpellingGame, or SoundGame).
        public static void CreateWord(string word, string[] sounds, string tag, string mode)
        {
            Vector3[] position = new Vector3[word.Length];          // contains desired position of each letter
            string[]  letters  = new string[word.Length];           // contains letters in word

            // want each letter as an uppercase string
            for (int i = 0; i < word.Length; i++)
            {
                char letter = System.Char.ToUpper(word [i]);
                letters[i] = System.Char.ToString(letter);
            }

            // set y-position for letters
            if (mode == "Learn")
            {
                y = -2;
            }
            if (mode == "SpellingGame")
            {
                y = 0;
            }
            if (mode == "SoundGame")
            {
                y = -3.5f;
            }

            // set z-position for letters
            if (tag == "MovableLetter")
            {
                z = -2;
            }
            if (tag == "TargetLetter")
            {
                z = 0;
            }

            // set x-position for each letter
            // word centered at x = 0, letters evenly spread out according to letterWidth
            if (word.Length == 3)
            {
                position = new Vector3[3] {
                    new Vector3(-1f * letterWidth, y, z),
                    new Vector3(0, y, z),
                    new Vector3(1f * letterWidth, y, z)
                };
            }
            if (word.Length == 4)
            {
                position = new Vector3[4] {
                    new Vector3(-1.5f * letterWidth, y, z),
                    new Vector3(-.5f * letterWidth, y, z),
                    new Vector3(.5f * letterWidth, y, z),
                    new Vector3(1.5f * letterWidth, y, z),
                };
            }
            if (word.Length == 5)
            {
                position = new Vector3[5] {
                    new Vector3(-2f * letterWidth, y, z),
                    new Vector3(-1f * letterWidth, y, z),
                    new Vector3(0, y, z),
                    new Vector3(1f * letterWidth, y, z),
                    new Vector3(2f * letterWidth, y, z)
                };
            }


            for (int i = 0; i < word.Length; i++)
            {
                // create letter with desired properties according to input given
                ObjectProperties letter = ObjectProperties.CreateInstance(letters [i], tag, position [i], new Vector3(letterScale, letterScale, 1), "Letters/" + letters [i], "Phonemes/" + sounds [i]);
                ObjectProperties.InstantiateObject(letter);
            }
        }
Пример #7
0
 //<summary>
 //Instantiate blanks. Takes in the desired word, phonemes in the word, shape of the blank (Rectangle or Circle),
 // tag of object (MovableBlank or TargetBlank), and type of game (SpellingGame or SoundGame).
 //</summary>
 public static void CreateBlanks(string word, string[] sounds, string shape, string tag, string mode)
 {
     //Set default scale, according to blank shape
     if (shape == "Rectangle")
     {
         xScale = .7f;
         yScale = 1.5f;
     }
     if (shape == "Circle")
     {
         xScale = .3f;
         yScale = .3f;
     }
     //Set y position, according to game mode
     if (mode == "SpellingGame")
     {
         y = -3;
     }
     if (mode == "SoundGame")
     {
         y = 0;
     }
     //Set z position
     if (tag == Constants.Tags.TAG_MOVABLE_BLANK)
     {
         // if draggable, set in front
         z = -2;
     }
     if (tag == Constants.Tags.TAG_TARGET_BLANK)
     {
         // if static, set in back
         z = 0;
     }
     //Want the word in the format of an array of uppercase letters instead of a string
     string[] letterArray = new string[word.Length];
     for (int i = 0; i < word.Length; i++)
     {
         char letter = System.Char.ToUpper(word[i]);
         letterArray[i] = System.Char.ToString(letter);
     }
     //Set x position of each blank, for each possible word length
     //Word is centered at x = 0, letters are evenly spaced out according to blankWidth
     Vector3[] position = new Vector3[word.Length];
     if (word.Length == 3)
     {
         position = new Vector3[3]
         {
             new Vector3(-1f * blankWidth, y, z),
             new Vector3(0, y, z),
             new Vector3(1f * blankWidth, y, z)
         };
     }
     if (word.Length == 4)
     {
         position = new Vector3[4]
         {
             new Vector3(-1.5f * blankWidth, y, z),
             new Vector3(-.5f * blankWidth, y, z),
             new Vector3(.5f * blankWidth, y, z),
             new Vector3(1.5f * blankWidth, y, z),
         };
     }
     if (word.Length == 5)
     {
         position = new Vector3[5]
         {
             new Vector3(-2f * blankWidth, y, z),
             new Vector3(-1f * blankWidth, y, z),
             new Vector3(0, y, z),
             new Vector3(1f * blankWidth, y, z),
             new Vector3(2f * blankWidth, y, z)
         };
     }
     //Assign properties for the blanks according to input given, then instantiate each blank
     for (int i = 0; i < word.Length; i++)
     {
         ObjectProperties blank = ObjectProperties.CreateInstance(letterArray[i], tag, position[i],
                                                                  new Vector3(xScale, yScale, 1), shape, "Phonemes/" + sounds[i]);
         ObjectProperties.InstantiateObject(blank);
     }
 }