Example #1
0
        /// <summary>
        /// Fade stars Coroutine.
        /// </summary>
        /// <returns>The stars.</returns>
        public IEnumerator FadeStars()
        {
            if (visible)
            {
                starsNumber = timer.progress.starsNumber;
                float delayBetweenStars = 0.5f;
                if (starsNumber == ShapesManager.Shape.StarsNumber.ONE)                  //Fade with One Star
                {
                    if (effectsAudioSource != null)
                    {
                        CommonUtil.PlayOneShotClipAt(starSoundEffect, Vector3.zero, effectsAudioSource.volume);
                    }
                    firstStarFading.SetTrigger("Running");
                }
                else if (starsNumber == ShapesManager.Shape.StarsNumber.TWO)                    //Fade with Two Stars
                {
                    if (effectsAudioSource != null)
                    {
                        CommonUtil.PlayOneShotClipAt(starSoundEffect, Vector3.zero, effectsAudioSource.volume);
                    }
                    firstStarFading.SetTrigger("Running");
                    yield return(new WaitForSeconds(delayBetweenStars));

                    if (effectsAudioSource != null)
                    {
                        CommonUtil.PlayOneShotClipAt(starSoundEffect, Vector3.zero, effectsAudioSource.volume);
                    }
                    secondStarFading.SetTrigger("Running");
                }
                else if (starsNumber == ShapesManager.Shape.StarsNumber.THREE)                    //Fade with Three Stars
                {
                    if (effectsAudioSource != null)
                    {
                        CommonUtil.PlayOneShotClipAt(starSoundEffect, Vector3.zero, effectsAudioSource.volume);
                    }
                    firstStarFading.SetTrigger("Running");
                    yield return(new WaitForSeconds(delayBetweenStars));

                    if (effectsAudioSource != null)
                    {
                        CommonUtil.PlayOneShotClipAt(starSoundEffect, Vector3.zero, effectsAudioSource.volume);
                    }
                    secondStarFading.SetTrigger("Running");
                    yield return(new WaitForSeconds(delayBetweenStars));

                    if (effectsAudioSource != null)
                    {
                        CommonUtil.PlayOneShotClipAt(starSoundEffect, Vector3.zero, effectsAudioSource.volume);
                    }
                    thirdStarFading.SetTrigger("Running");
                }
            }
            yield return(0);
        }
        /// <summary>
        /// Get the shape stars.
        /// </summary>
        /// <returns>The shape stars.</returns>
        /// <param name="ID">The ID of the shape.</param>
        public static ShapesManager.Shape.StarsNumber GetShapeStars(int ID)
        {
            ShapesManager.Shape.StarsNumber stars = ShapesManager.Shape.StarsNumber.ZERO;
            string key = GetStarsStrKey(ID);

            if (PlayerPrefs.HasKey(key))
            {
                stars = CommonUtil.IntNumberToShapeStarsNumberEnum(PlayerPrefs.GetInt(key));
            }
            return(stars);
        }
Example #3
0
        /// <summary>
        /// On shape completed event.
        /// </summary>
        private void OnShapeComplete()
        {
            DisableHand();
            //brightEffect.GetComponent<ParticleEmitter> ().emit = false;

            Animator shapeAnimator = shape.GetComponent <Animator> ();

            shapeAnimator.SetBool(shape.name, false);
            shapeAnimator.SetTrigger("Completed");

            ShapesManager.Shape.StarsNumber collectedStars = Progress.instance.starsNumber;

            AlphabetDataManager.SaveShapeStars(ShapesManager.Shape.selectedShapeID, collectedStars);
            if (ShapesManager.Shape.selectedShapeID + 1 < ShapesManager.instance.shapes.Count)
            {
                AlphabetDataManager.SaveShapeLockedStatus(ShapesManager.Shape.selectedShapeID + 1, false);
            }

            List <Transform> paths = CommonUtil.FindChildrenByTag(shape.transform.Find("Paths"), "Path");
            int from, to;

            string [] slices;
            foreach (Transform p in paths)
            {
                slices = p.name.Split('-');
                from   = int.Parse(slices [1]);
                to     = int.Parse(slices [2]);
                AlphabetDataManager.SaveShapePathColor(ShapesManager.Shape.selectedShapeID, from, to, CommonUtil.FindChildByTag(p, "Fill").GetComponent <Image> ().color);
            }

            timer.Stop();
            Area.Show();
            winDialog.Show();
            GameObject.Find("NextButton").GetComponent <Animator> ().SetTrigger("Select");
            winEffect.gameObject.SetActive(true);

            if (correctSFX != null && effectsAudioSource != null)
            {
                CommonUtil.PlayOneShotClipAt(completedSFX, Vector3.zero, effectsAudioSource.volume);
            }
        }
        /// <summary>
        /// Converts from enum StarsNumber to int number value.
        /// </summary>
        /// <returns>The stars number as int.</returns>
        /// <param name="starsNumber">Stars number enum.</param>
        public static int ShapeStarsNumberEnumToIntNumber(ShapesManager.Shape.StarsNumber starsNumber)
        {
            if (starsNumber == ShapesManager.Shape.StarsNumber.ZERO)
            {
                return(0);
            }
            else if (starsNumber == ShapesManager.Shape.StarsNumber.ONE)
            {
                return(1);
            }
            else if (starsNumber == ShapesManager.Shape.StarsNumber.TWO)
            {
                return(2);
            }
            else if (starsNumber == ShapesManager.Shape.StarsNumber.THREE)
            {
                return(3);
            }

            return(-1);//undefined
        }
Example #5
0
        /// <summary>
        /// Set the value of the progress.
        /// </summary>
        /// <param name="currentTime">Current time.</param>
        public void SetProgress(float currentTime)
        {
            if (AlphabetGameManager.instance == null)
            {
                return;
            }

            if (AlphabetGameManager.instance.shape == null)
            {
                return;
            }

            if (progressImage != null)
            {
                progressImage.fillAmount = 1 - (currentTime / (ShapesManager.instance.GetCurrentShape().starsTimePeriod * 3));
            }

            if (currentTime >= 0 && currentTime <= ShapesManager.instance.GetCurrentShape().starsTimePeriod)
            {
                if (levelStars [0] != null)
                {
                    levelStars [0].sprite = starOn;
                }
                if (levelStars [1] != null)
                {
                    levelStars [1].sprite = starOn;
                }
                if (levelStars [2] != null)
                {
                    levelStars [2].sprite = starOn;
                }
                if (progressImage != null)
                {
                    progressImage.color = Colors.greenColor;
                }

                starsNumber = ShapesManager.Shape.StarsNumber.THREE;
            }
            else if (currentTime > ShapesManager.instance.GetCurrentShape().starsTimePeriod&& currentTime <= 2 * ShapesManager.instance.GetCurrentShape().starsTimePeriod)
            {
                if (levelStars [2] != null)
                {
                    levelStars [2].sprite = starOff;
                }
                if (progressImage != null)
                {
                    progressImage.color = Colors.yellowColor;
                }
                starsNumber = ShapesManager.Shape.StarsNumber.TWO;
            }
            else
            {
                if (levelStars [1] != null)
                {
                    levelStars [1].sprite = starOff;
                }
                if (levelStars [2] != null)
                {
                    levelStars [2].sprite = starOff;
                }
                if (progressImage != null)
                {
                    progressImage.color = Colors.redColor;
                }
                starsNumber = ShapesManager.Shape.StarsNumber.ONE;
            }
        }
 /// <summary>
 /// Save the shape stars.
 /// </summary>
 /// <param name="ID">The ID of the shape.</param>
 /// <param name="stars">Stars.</param>
 public static void SaveShapeStars(int ID, ShapesManager.Shape.StarsNumber stars)
 {
     PlayerPrefs.SetInt(GetStarsStrKey(ID), CommonUtil.ShapeStarsNumberEnumToIntNumber(stars));
     PlayerPrefs.Save();
 }