Ejemplo n.º 1
0
        //Called on start, used to initialize stuff
        void Start()
        {
            //Create objects and background
            LoadLevel(ProgressManager.currentLevel);

            //Set up kid
            GameObject kid = GameObject.FindGameObjectWithTag("Kid");

            kid.GetComponent <SpriteRenderer> ().sprite = Resources.Load <Sprite> ("Graphics/" + ProgressManager.chosenKid);

            //Play Grow Animation for kid
            GrowKid();

            //Load audio for kid
            kid.AddComponent <AudioSource> ().clip = Resources.Load("Audio/KidSpeaking/" + ProgressManager.currentLevel) as AudioClip;
            //Check if audio clip is attached
            if (kid.audio.clip != null)
            {
                kid.audio.priority = 255;
                //Play audio clip attached to kid if there is one
                kid.audio.Play();
            }

            //Find ChooseObjectDirector gameObject
            GameObject dir = GameObject.Find("ChooseObjectDirector");

            //Load background music for scene onto ChooseObjectDirector
            dir.AddComponent <AudioSource> ().clip = Resources.Load("Audio/BackgroundMusic/" + ProgressManager.currentLevel) as AudioClip;
            //Check if audio clip is attached
            if (dir.audio.clip != null)
            {
                dir.audio.volume = .7f;
                //Start playing background music if attached
                dir.audio.Play();
            }

            //Subscribe buttons to touch gestures
            GameObject button = GameObject.FindGameObjectWithTag("Button");

            button.AddComponent <GestureManager> ().AddAndSubscribeToGestures(button);

            //Find word objects
            GameObject[] gos = GameObject.FindGameObjectsWithTag("WordObject");
            foreach (GameObject go in gos)
            {
                //Start pulsing for each object
                Debug.Log("Started pulsing for " + go.name);
                go.GetComponent <PulseBehavior> ().StartPulsing(go);

                //Check if word has been completed by user

                //If word not completed, darken and fade out object
                if (!ProgressManager.IsWordCompleted(go.name))
                {
                    SetColorAndTransparency(go, Color.grey, .9f);
                }
                //If word completed, brighten and fill in object
                if (ProgressManager.IsWordCompleted(go.name))
                {
                    Debug.Log("Word Completed: " + go.name);
                    SetColorAndTransparency(go, Color.white, 1f);
                }
            }

            //Check if this level has been completed, i.e. if all words in the level have been completed
            if (CheckCompletedLevel())
            {
                //If level completed, add to completedLevels list and unlock the next level
                ProgressManager.AddCompletedLevel(ProgressManager.currentLevel);
                ProgressManager.UnlockNextLevel(ProgressManager.currentLevel);
            }
        }