Example #1
0
        private IEnumerator RoundsCoroutine(KoreCallback gameEndedCallback)
        {
            int anturaGagRound = Random.Range(1, Configuration.NumberOfRounds);

            for (int round = 0; round < Configuration.NumberOfRounds; round++)
            {
                // Show antura only on the elected round.
                if (anturaGagRound == round)
                {
                    yield return(Koroutine.Nested(AnturaGag()));
                }
                InitRound();

                yield return(Koroutine.Nested(RoundBegin()));

                yield return(Koroutine.Nested(PlaceAnswers()));

                LogicInjector.EnableDragOnly();

                if (round == 0)
                {
                    executingRound0 = true;
                    Koroutine.Run(DescriptionAudio());
                }

                yield return(Koroutine.Nested(GamePlay()));

                executingRound0 = false;
                yield return(Koroutine.Nested(ClearRound()));
            }

            gameEndedCallback();
        }
Example #2
0
        private IEnumerator PlaceCoroutine()
        {
            var   positions = new List <Vector3>();
            float xMin      = placerOptions.LeftX + placerOptions.AnswerSize / 2f + 2.0f;
            float xMax      = placerOptions.RightX - placerOptions.AnswerSize / 2f - 1.0f;
            float yMin      = placerOptions.BottomY + 1.7f;
            float z         = placerOptions.DefaultZ;


            for (float x = xMin; x < xMax; x += placerOptions.AnswerSize + 0.2f)
            {
                int times = 0;
                for (float y = yMin; times < 3; y += 3.1f, times++)
                {
                    float dx  = Random.Range(-0.1f, 0.1f);
                    var   vec = new Vector3(x + dx, y, z);
                    positions.Add(vec);
                }
            }

            positions.Shuffle();

            playbackAnswers = new List <Answer>();
            foreach (var a in allAnswers)
            {
                yield return(Koroutine.Nested(PlaceAnswer(a, positions)));
            }
            yield return(Koroutine.Nested(PlayBackCorrectAnswers()));

            yield return(Wait.For(0.65f));

            isAnimating = false;
        }
Example #3
0
        public void Place(Answer[] answer)
        {
            Answer[] original = new Answer[answer.Length];
            placeholders = new List <StillLetterBox>();

            for (int i = 0; i < answer.Length; i++)
            {
                original[i] = answer[i];
            }

            for (int i = 0; i < answer.Length; i++)
            {
                answer[i].AddTicket(i);
            }

            answer.Shuffle();

            // Avoid the case where all letters are already in correct order (automatic win)
            // In case we see there would be an automatic win, we just swap the first 2
            // different letters. This may introduce some bias on shorter words.. but that's
            // ok. This is not a gamblin game.
            ForceRandom(answer, original);

            allAnswers  = answer;
            isAnimating = true;
            Koroutine.Run(PlaceCoroutine());
        }
Example #4
0
        IEnumerator RemoveCoroutine()
        {
            foreach (var q in allQuestions)
            {
                foreach (var p in q.GetPlaceholders())
                {
                    yield return(Koroutine.Nested(FadeOutPlaceholder(p)));
                }
                foreach (var img in images)
                {
                    yield return(Koroutine.Nested(FadeOutImage(img)));
                }
                yield return(Koroutine.Nested(FadeOutQuestion(q)));
            }

            foreach (var box in boxesList)
            {
                box.Hide();
            }

            // give time to finish animating elements
            yield return(Wait.For(0.45f));

            isAnimating = false;
        }
Example #5
0
 public WaitCoroutine(IEnumerator enumerator)
 {
     if (enumerator == null)
     {
         throw new ArgumentNullException();
     }
     Koroutine.Run(ParallelCoroutine(enumerator));
 }
Example #6
0
 // Update is called once per frame
 IEnumerator TestCoroutine(int i)
 {
     if (i > 0)
     {
         Koroutine.Run(Parallel(2 * i));
         yield return(Koroutine.Nested(TestCoroutine(i - 1)));
     }
 }
Example #7
0
 public void Check(List <PlaceholderBehaviour> placeholders,
                   List <IQuestion> questions,
                   IDragManager dragManager)
 {
     isAnimating    = true;
     coroutineEnded = false;
     allCorrect     = false;
     Koroutine.Run(CheckCoroutine(placeholders, questions, dragManager));
 }
Example #8
0
        private void Start()
        {
            var startPos = ItemFactory.Instance.AnturaStart;

            transform.localPosition = startPos.localPosition;
            transform.localRotation = startPos.localRotation;

            Koroutine.Run(Entering);
        }
Example #9
0
 public void Place(IQuestion[] question, bool playSound)
 {
     allQuestions   = question;
     isAnimating    = true;
     images         = new List <StillLetterBox>();
     questionSounds = new List <IEnumerator>();
     boxesList      = new List <QuestionBox>();
     Koroutine.Run(PlaceCoroutine(playSound));
 }
Example #10
0
        IEnumerator ReadQuestionAndReplyEvent()
        {
            yield return(Koroutine.Nested(
                             dialogues.PlayLetterDataCoroutine(cacheQuestionToRead)));

            yield return(Wait.For(0.3f));

            yield return(Koroutine.Nested(dialogues.PlayLetterDataCoroutine(cacheAnswerToRead)));
        }
Example #11
0
        private IEnumerator RemoveCoroutine()
        {
            foreach (var a in allAnswers)
            {
                yield return(Koroutine.Nested(RemoveAnswer(a.gameObject)));
            }
            yield return(Wait.For(0.65f));

            isAnimating = false;
        }
Example #12
0
        private IEnumerator PlayBackCorrectAnswers()
        {
            playbackAnswers.Shuffle();
            foreach (var a in playbackAnswers)
            {
                yield return(Koroutine.Nested(a.PlayLetter()));

                yield return(Wait.For(0.3f));
            }
            playbackAnswers = null;
        }
Example #13
0
        IEnumerator A, B; //States

        // Use this for initialization
        void Start()
        {
            // Cache enumerators, Garbage generate only when creating a IEnumerator
            // so as long as we keep and reuse the same reference, we stop generating garbage.
            A = StateA();
            B = StateB();
            Koroutine.Run(A);  //Start State Machine

            // This coroutine is just for detecting a key pressed.
            Koroutine.Run(InputDetection());
        }
Example #14
0
        IEnumerator Nested()
        {
            Debug.Log("Nested");
            yield return(null);

            Debug.Log("Nested");
            yield return(Koroutine.Nested(Nested2()));;
            Debug.Log("Nested");
            yield return(null);

            Debug.Log("Nested");
        }
Example #15
0
        public void EnterState()
        {
            AssessmentConfiguration.Instance.Context.GetLogManager().OnGameEnded(3);
            LogManager.I.LogPlaySessionScore(AppManager.I.JourneyHelper.GetCurrentPlaySessionData().Id, 3);

            var audioManager = assessmentGame.Context.GetAudioManager();

            audioManager.PlayMusic(Music.Relax);
            audioManager.PlaySound(Sfx.TickAndWin);

            Koroutine.Run(QuitAfterYieldable(dialogueManager.PlayAssessmentCompleteSound()));
        }
Example #16
0
        IEnumerator Test1()
        {
            Debug.Log("A");
            yield return(null);

            Debug.Log("B");
            yield return(Koroutine.Nested(Nested()));

            Debug.Log("C");
            yield return(null);

            Debug.Log("D");
        }
        public IEnumerator AllAnsweredEvent()
        {
            if (events.OnAllQuestionsAnsweredPlacer != null)
            {
                Koroutine.Run(events.OnAllQuestionsAnsweredPlacer());
            }

            if (events.OnAllQuestionsAnswered != null)
            {
                return(events.OnAllQuestionsAnswered());
            }
            return(events.NoEvent());
        }
Example #18
0
        private IEnumerator PlaceCoroutine()
        {
            // Text justification "algorithm"
            float spaceIncrement = 0.5f + letterSize;
            float occupiedSpace  = allAnswers.Length * spaceIncrement - 3.5f;

            var     flow = AssessmentOptions.Instance.LocaleTextDirection;
            float   sign;
            Vector3 currentPos = Vector3.zero;

            currentPos.y = -1;
            currentPos.z = 5;

            if (flow == TextDirection.RightToLeft)
            {
                currentPos.x = occupiedSpace / 2f;
                sign         = -1;
            }
            else
            {
                currentPos.x = -occupiedSpace / 2f;
                sign         = 1;
            }

            currentPos.y -= 1.5f;

            // Move answer so we can wrap them in bg.
            foreach (var a in allAnswers)
            {
                MoveAnswer(a, currentPos);
                currentPos.x += spaceIncrement * sign;
            }

            // Spawn BG
            SpawnLettersBG();

            // Spawn Answers.
            playbackAnswers = new List <Answer>();
            foreach (var a in allAnswers)
            {
                yield return(Koroutine.Nested(PlaceAnswer(a)));
            }

            yield return(Koroutine.Nested(PlayBackCorrectAnswers()));

            yield return(Wait.For(0.65f));

            isAnimating = false;
        }
Example #19
0
        public bool AllAnswered()
        {
            if (dragOnly || objectFlying || returnedAllAnswered)
            {
                return(false); // When antura is animating we should not complete the assessment
            }
            if (sortables == null)
            {
                return(false);
            }

            Answer[] answer       = new Answer[answers.Count];
            Answer[] answerSorted = new Answer[answers.Count];

            //Answers like are actually sorted
            var sorted = sortables.OrderByDescending(x => x.transform.position.x).ToArray();

            if (!LanguageSwitcher.LearningRTL)
            {
                sorted = sorted.Reverse().ToArray();
            }

            int index = 0;

            foreach (var a in answers)
            {
                answerSorted[index] = sorted[index].gameObject.GetComponent <Answer>();
                index++;
            }

            // Answers sorted by ticket
            answer = answerSorted.OrderBy(a => a.GetTicket()).ToArray();

            for (int i = 0; i < answer.Length; i++)
            {
                //If sorted version has letter forms in wrong positions we know we didn't find solution
                if (answer[i].Equals(answerSorted[i]) == false)
                {
                    return(false);
                }
            }

            //Debug.Log("Return TRUE");
            // two words identical!
            returnedAllAnswered = true;
            Koroutine.Run(AllCorrectCoroutine());
            return(true);
        }
Example #20
0
        private IEnumerator ClearRound()
        {
            LogicInjector.RemoveDraggables();

            yield return(Koroutine.Nested(LogicInjector.AllAnsweredEvent()));

            QuestionPlacer.RemoveQuestions();
            AnswerPlacer.RemoveAnswers();

            while (QuestionPlacer.IsAnimating() || AnswerPlacer.IsAnimating())
            {
                yield return(null);
            }

            LogicInjector.ResetRound();
        }
Example #21
0
        private IEnumerator RemoveCoroutine()
        {
            foreach (var a in allAnswers)
            {
                yield return(Koroutine.Nested(RemoveAnswer(a.gameObject)));
            }

            yield return(Wait.For(0.2f));

            bgBox.Hide();

            foreach (var p in placeholders)
            {
                RemovePlaceholder(p);
            }

            audioManager.PlayPoofSound();
            yield return(Wait.For(0.3f));

            isAnimating = false;
        }
Example #22
0
        IEnumerator Example()
        {
            var cube    = Instantiate(cubePrefab, transform.position, Quaternion.identity) as GameObject;
            var cubepos = cube.transform;

            for (int i = 0; i < 5; i++)
            {
                float   advancement = 0;
                Vector3 pos         = cubepos.position;

                while (advancement < 2)
                {
                    advancement     += Time.deltaTime * 2;
                    cubepos.position = new Vector3(pos.x + advancement, pos.y, pos.z);
                    yield return(null);
                }

                yield return(Koroutine.Nested(ShotBullet(cubepos)));
            }

            Destroy(cube);
            RestartAnimation();
        }
Example #23
0
        void Start()
        {
            cube = Instantiate(cubePrefab, transform.position, Quaternion.identity) as GameObject;

            Koroutine.Run(StateA());
        }
Example #24
0
 private void RestartAnimation()
 {
     Koroutine.Run(Example());
 }
Example #25
0
 // Use this for initialization
 void Start()
 {
     Koroutine.Run(TestCoroutine(300));
 }
Example #26
0
 private void RestartCoroutine()
 {
     Koroutine.Run(Example());
 }
Example #27
0
        public override IEnumerator GetPlaceCoroutine(bool playAudio)
        {
            ResetAnimationsQueue();

            if (playAudio)
            {
                // warn our heirs
                Debug.LogWarning("playAudio, parameter not used for Categorization questions");
            }

            // Count questions and answers
            int questionsNumber    = 0;
            int placeHoldersNumber = 0;

            foreach (var q in allQuestions)
            {
                questionsNumber++;
                placeHoldersNumber += q.PlaceholdersCount();
            }

            float occupiedSpace  = placeHoldersNumber * options.SlotSize;
            float blankSpace     = options.RightX - options.LeftX - occupiedSpace;
            float spaceIncrement = blankSpace / (questionsNumber + 1);

            var     flow = AssessmentOptions.Instance.LocaleTextDirection;
            float   sign;
            Vector3 currentPos = new Vector3(0, options.QuestionY - 3.5f, options.DefaultZ);

            if (flow == TextDirection.RightToLeft)
            {
                currentPos.x = options.RightX;
                sign         = -1;
            }
            else
            {
                currentPos.x = options.LeftX;
                sign         = 1;
            }

            int questionIndex = 0;

            for (int i = 0; i < questionsNumber; i++)
            {
                currentPos.x += spaceIncrement * sign;
                float min = 1000, max = -1000;

                foreach (var p in allQuestions[questionIndex].GetPlaceholders())
                {
                    currentPos.x += (options.SlotSize / 2) * sign;

                    if (currentPos.x > max)
                    {
                        max = currentPos.x;
                    }

                    if (currentPos.x < min)
                    {
                        min = currentPos.x;
                    }

                    PlacePlaceholder(p, currentPos);
                    currentPos.x += (options.SlotSize / 2) * sign;
                }

                var questionPos = currentPos;
                questionPos.y = options.QuestionY;
                questionPos.x = (max + min) / 2f;

                // Category questions never read the category
                PlaceQuestion(allQuestions[questionIndex], questionPos, false);

                WrapQuestionInABox(allQuestions[questionIndex]);
                foreach (var anim in AnimationsQueue)
                {
                    yield return(Koroutine.Nested(anim));
                }

                AnimationsQueue.Clear();

                questionIndex++;
            }

            // give time to finish animating elements
            yield return(Wait.For(0.65f));

            isAnimating = false;
        }
 public GameSubmissionScheduler(ISubmissionScheduler scheduler)
 {
     this.scheduler = scheduler;
     Koroutine.Run(scheduler.ScheduleTask(), Method.LateUpdate);  //be sure this is the last thing executed in a frame
 }
Example #29
0
 public void RemoveAnswers()
 {
     isAnimating = true;
     Koroutine.Run(RemoveCoroutine());
 }
Example #30
0
 public void Place(Answer[] answer)
 {
     allAnswers  = answer;
     isAnimating = true;
     Koroutine.Run(PlaceCoroutine());
 }