Exemple #1
0
 public void Update(float delta)
 {
     if (completed)
     {
         game.SetCurrentState(game.ReadState);
     }
 }
Exemple #2
0
        public void Update(float delta)
        {
            timer -= delta;

            if (timer < 0)
            {
                game.SetCurrentState(game.QuestionState);
            }
        }
Exemple #3
0
        IEnumerator DoEndAnimation(bool correct, CircleButton correctButton)
        {
            box.Active = false;
            if (correct)
            {
                correctButton.SetColor(UnityEngine.Color.green);
            }
            else
            {
                correctButton.SetColor(UnityEngine.Color.red);
            }
            yield return(new UnityEngine.WaitForSeconds(1.0f));

            if (!correct && game.RemoveLife())
            {
                yield break;
            }

            game.circleBox.GetComponent <CircleButtonBox>().Clear(() => {
                game.SetCurrentState(game.QuestionState);
            }, 0.5f);
        }
Exemple #4
0
        IEnumerator DoEndAnimation(bool correct, CircleButton correctButton, CircleButton clickedButton = null)
        {
            Finished   = true;
            box.Active = false;
            game.StartCoroutine(game.gameLettersHandler.CleanupCO(correct));
            if (countdownCo != null)
            {
                game.StopCoroutine(countdownCo);
            }

            if (ReadingGameConfiguration.Instance.CurrentGameType == ReadingGameConfiguration.GameType.ReadAndListen)
            {
                if (!TutorialMode)
                {
                    if (correct)
                    {
                        game.AddScore(1);
                    }
                }
            }

            if (ReadingGameConfiguration.Instance.CurrentGameType != ReadingGameConfiguration.GameType.SimonSong)
            {
                yield return(new WaitForSeconds(1.0f));
            }

            if (ReadingGameConfiguration.Instance.CurrentGameType != ReadingGameConfiguration.GameType.ReadAndListen)
            {
                if (!correct && game.RemoveLife())
                {
                    yield break;
                }
            }

            if (ReadingGameConfiguration.Instance.CurrentGameType == ReadingGameConfiguration.GameType.SimonSong)
            {
                // Time up
                if (!correct && !clickedButton)
                {
                    game.circleBox.GetComponent <CircleButtonBox>().ClearButtonsApartFrom(correctButton);
                }
                else
                {
                    if (correct)
                    {
                        game.AddScore(1);
                    }
                    else
                    {
                        clickedButton?.SetColor(Color.red);
                        yield return(new WaitForSeconds(0.5f));
                    }
                    correctButton.SetColor(Color.green);
                    game.circleBox.GetComponent <CircleButtonBox>().Clear(startDelay: 0.5f);
                }

                game.Context.GetAudioManager().PlayVocabularyData(correctButton.Answer);
                game.ChangeLoopingSong(game.CurrentSongBPM.intro);
                Debug.Log("POST ANSWER INTRO LOOP");
                game.onSongLoop += () =>
                {
                    KeeperManager.I.CloseSubtitles();
                    Debug.Log("END - POST ANSWER INTRO LOOP");
                    game.StopLoopingSong();
                    game.SetCurrentState(game.QuestionState);
                };
            }
            else if (ReadingGameConfiguration.Instance.CurrentGameType == ReadingGameConfiguration.GameType.SimonSong)
            {
                game.circleBox.GetComponent <CircleButtonBox>().ClearButtonsApartFrom(correctButton);
                game.circleBox.GetComponent <CircleButtonBox>().Clear(() => {
                    game.SetCurrentState(game.QuestionState);
                }, 0.5f);
            }
            else
            {
                //if (!correct) clickedButton?.SetColor(Color.red);
                correctButton.SetColor(Color.green);
                game.circleBox.GetComponent <CircleButtonBox>().Clear(() => {
                    game.SetCurrentState(game.QuestionState);
                }, 0.5f);
            }
        }
Exemple #5
0
        public void EnterState()
        {
            game.antura.AllowSitting = true;
            game.isTimesUp           = false;

            // Reset game timer
            gameTime.Reset(game.TimeToAnswer);

            switch (ReadingGameConfiguration.Instance.CurrentGameType)
            {
            case ReadingGameConfiguration.GameType.FollowReading:

                if (!TutorialMode)
                {
                    gameTime.Start();
                }
                else
                {
                    game.PlayTutorial();
                    drawTutorialLineTimer = 0;
                }

                break;

            case ReadingGameConfiguration.GameType.ReadAndListen:
                break;

            case ReadingGameConfiguration.GameType.FollowSong:
                break;

            case ReadingGameConfiguration.GameType.SimonSong:
                game.PlayTutorialConditional(TutorialMode, StartSimonQuestionLoop);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            var inputManager = game.Context.GetInputManager();

            inputManager.onPointerDown += OnPointerDown;
            inputManager.onPointerUp   += OnPointerUp;

            game.blurredText.SetActive(true);

            switch (ReadingGameConfiguration.Instance.CurrentGameType)
            {
            case ReadingGameConfiguration.GameType.FollowReading:

                break;

            case ReadingGameConfiguration.GameType.ReadAndListen:

                // Read it
                // Play the question word and go to the answer
                game.PlayTutorialConditional(TutorialMode,
                                             () =>
                                             game.Context.GetAudioManager().PlayVocabularyData(game.CurrentQuestion.GetQuestion(),
                                                                                               keeperMode: KeeperMode.LearningAndSubtitles, autoClose: false, callback:
                                                                                               () => {
                    // Setup timer for the new state
                    game.AnswerState.ReadTime     = gameTime.Time;
                    game.AnswerState.MaxTime      = gameTime.Duration;
                    game.AnswerState.TutorialMode = TutorialMode;
                    game.SetCurrentState(game.AnswerState);
                })
                                             );

                break;

            case ReadingGameConfiguration.GameType.FollowSong:
                AudioClip songAudio = null;
                switch (ReadingGameConfiguration.Instance.Variation)
                {
                case ReadingGameVariation.SongAlphabet:
                    songAudio = game.alphabetSongAudio;
                    break;

                case ReadingGameVariation.SongDiacritics:
                    songAudio = game.diacriticSongAudio;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                game.barSet.PlaySong(game.Context.GetAudioManager().PlaySound(songAudio), OnSongEnded);
                break;

            case ReadingGameConfiguration.GameType.SimonSong:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            completedDragging = false;

            if (firstRealRun)
            {
                bool showClock = ReadingGameConfiguration.Instance.ShowTimer;
                bool showLives = ReadingGameConfiguration.Instance.CurrentGameType == ReadingGameConfiguration.GameType.FollowReading;

                if (!TutorialMode)
                {
                    // Configure overlay
                    var overlay = game.Context.GetOverlayWidget();
                    overlay.Initialize(true, showClock, showLives);
                    overlay.SetMaxLives(game.Lives);
                    overlay.SetLives(game.Lives);
                    overlay.SetClockDuration(gameTime.Duration);
                    overlay.SetClockTime(gameTime.Time);
                    overlay.SetStarsThresholds(game.GetStarsThreshold(1), game.GetStarsThreshold(2), game.GetStarsThreshold(3));
                    firstRealRun = false;
                }
            }

            switch (ReadingGameConfiguration.Instance.CurrentGameType)
            {
            case ReadingGameConfiguration.GameType.FollowReading:
                game.barSet.SwitchToNextBar();
                game.barSet.active = true;
                break;

            case ReadingGameConfiguration.GameType.FollowSong:
                game.barSet.active = true;
                break;

            case ReadingGameConfiguration.GameType.ReadAndListen:
            case ReadingGameConfiguration.GameType.SimonSong:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
        public void Update(float delta)
        {
            if (!TutorialMode)
            {
                game.Context.GetOverlayWidget().SetClockTime(gameTime.Time);
            }
            else if (dragging == null)
            {
                drawTutorialLineTimer -= delta;

                if (drawTutorialLineTimer < 0)
                {
                    var activeBar = game.barSet.GetActiveBar();

                    if (activeBar != null)
                    {
                        drawTutorialLineTimer = 5;

                        var handleOffset = activeBar.glass.handleOffset.position - activeBar.glass.transform.position;
                        TutorialUI.DrawLine(activeBar.start.transform.position + handleOffset, activeBar.endCompleted.transform.position + handleOffset, TutorialUI.DrawLineMode.FingerAndArrow, false, true);
                    }
                }
            }

            gameTime.Update(delta);

            if (dragging != null)
            {
                var inputManager = game.Context.GetInputManager();
                completedDragging = dragging.SetGlassScreenPosition(inputManager.LastPointerPosition + draggingOffset,
                                                                    ReadingGameConfiguration.Instance.Variation == ReadingGameVariation.ReadAndAnswer);
            }
            else
            {
                if (ReadingGameConfiguration.Instance.Variation == ReadingGameVariation.ReadAndAnswer)
                {
                    if (completedDragging)
                    {
                        var completedAllBars = game.barSet.SwitchToNextBar();

                        if (completedAllBars)
                        {
                            // go to Buttons State
                            game.AnswerState.ReadTime     = gameTime.Time;
                            game.AnswerState.MaxTime      = gameTime.Duration;
                            game.AnswerState.TutorialMode = TutorialMode;
                            game.SetCurrentState(game.AnswerState);
                            return;
                        }
                    }

                    completedDragging = false;
                }
            }


            if (ReadingGameConfiguration.Instance.Variation == ReadingGameVariation.ReadAndAnswer)
            {
                float perc = gameTime.Time / gameTime.Duration;

                if (perc < 0.05f)
                {
                    game.antura.Mood = ReadingGameAntura.AnturaMood.SAD;
                }
                else if (perc < 0.5f)
                {
                    game.antura.Mood = ReadingGameAntura.AnturaMood.ANGRY;
                }
                else
                {
                    game.antura.Mood = ReadingGameAntura.AnturaMood.HAPPY;
                }
            }
            else   // Alphabet Song
            {
                float distance;
                if (game.barSet.GetFollowingDistance(out distance))
                {
                    distance = Math.Abs(distance);

                    if (distance > 100)
                    {
                        timeFarFromTarget += delta;
                    }
                    else
                    {
                        timeFarFromTarget = 0;
                        //if (distance < 50) {
                        scoreAccumulator += 1.2f * delta;
                        //} else {
                        //    scoreAccumulator += 1 * delta;
                        // }
                        if (scoreAccumulator >= 1)
                        {
                            game.AddScore((int)scoreAccumulator);
                            scoreAccumulator = scoreAccumulator - (int)scoreAccumulator;
                        }
                    }

                    if (timeFarFromTarget > 1.0f)
                    {
                        game.antura.Mood = ReadingGameAntura.AnturaMood.ANGRY;
                    }
                    else
                    {
                        game.antura.Mood = ReadingGameAntura.AnturaMood.HAPPY;
                    }
                }
            }
        }