Esempio n. 1
0
        private void OnDifficultySelected(int index)
        {
            Services.Instance.SoundService.PlayClip(clipOnSelected, QuestionsGame.Sound.AudioType.SOUND_FX);
            var coccurrentRoutine = new Unity.Utils.CocurrentRoutineHandler(Disable, true,
                                                                            new System.Func <IEnumerator>(() => Utils.ButtonFlash(difficultySelectButtons[index], difficultySelectButtons[index].colors, flashColor, flashDelay, flashRepeats)));

            Services.Instance.EventAggregator.Invoke(this, new DifficultySelectedEventArgs(definitions[index], coccurrentRoutine));
            coccurrentRoutine.Start();
        }
        private void OnAnswerPicked(bool isRight, int buttonIndex)
        {
            var color = isRight ? rightAnswerColor : wrongAnswerColor;

            Services.Instance.SoundService.PlayClip(isRight ? isRightClip : isWrongClip, QuestionsGame.Sound.AudioType.SOUND_FX);

            var coccurentHandler =
                new Unity.Utils.CocurrentRoutineHandler(OnExit, true,
                                                        new System.Func <IEnumerator>(() => Utils.ButtonFlash(answersButtons[buttonIndex], defaultColorBlock, color, flashDelay, flashRepeats)));

            Services.Instance.EventAggregator.Invoke(this, new AnswerPickedCoccurentEventArgs(isRight, coccurentHandler));
            coccurentHandler.Start();
        }
Esempio n. 3
0
        private IEnumerator SpinRoutine(List <float> percentages, List <Color> colors)
        {
            Services.Instance.SoundService.PlayClip(wheelSpinningClip, QuestionsGame.Sound.AudioType.SOUND_FX, true);

            var angle        = 0f;
            var spinSpeed    = this.spinSpeed;
            int currentIndex = 0;

            while (spinSpeed >= 0.1f)
            {
                if (stop)
                {
                    spinSpeed -= spinDeccelaration;
                }

                angle += spinSpeed * Time.deltaTime;
                wheel.transform.eulerAngles += new Vector3(0, 0, 1) * spinSpeed * Time.deltaTime;

                var minAngle = 0f;
                var maxAngle = 0f;

                for (int i = 0; i < percentages.Count; i++)
                {
                    minAngle  = maxAngle;
                    maxAngle += percentages[i] * 360;
                    if (minAngle < angle && angle < maxAngle)
                    {
                        mat.SetColor(TARGET_COLOR, colors[i]);
                        currentIndex = i;
                        break;
                    }
                }
                angle %= 360;
                yield return(null);
            }

            Services.Instance.SoundService.PlayClip(wheelStopClip, QuestionsGame.Sound.AudioType.SOUND_FX, false);

            yield return(new WaitForSeconds(exitDelay));

            var cocurrentRoutine = new Unity.Utils.CocurrentRoutineHandler();

            cocurrentRoutine.AddOnFinishCallback(OnExit);

            Services.Instance.EventAggregator.Invoke(this, new WheelStopSpinEventArgs(categories[currentIndex], cocurrentRoutine));
            cocurrentRoutine.Start();
        }
Esempio n. 4
0
 public DifficultySelectedEventArgs(DifficultyDefinition definition, Unity.Utils.CocurrentRoutineHandler coccurentRoutine)
 {
     DifficultyDefinition = definition;
     CoccurentRoutine     = coccurentRoutine;
 }
Esempio n. 5
0
 public WheelStopSpinEventArgs(Questions.QuestionCategory questionCategory, Unity.Utils.CocurrentRoutineHandler cocurrentRoutine)
 {
     QuestionCategory = questionCategory;
     CocurrentRoutine = cocurrentRoutine;
 }