public void EnterState() { game.antura.AllowSitting = true; game.isTimesUp = false; int maxQuestions = ReadingGameGame.MAX_QUESTIONS; switch (ReadingGameConfiguration.Instance.CurrentGameType) { case ReadingGameConfiguration.GameType.SimonSong: maxQuestions = ReadingGameGame.MAX_QUESTIONS_SIMON_SONG; break; } if (game.CurrentQuestionNumber >= maxQuestions) { game.EndGame(game.CurrentStars, game.CurrentScore); return; } game.blurredText.SetActive(true); switch (ReadingGameConfiguration.Instance.CurrentGameType) { case ReadingGameConfiguration.GameType.FollowReading: { // Pick a question and show it var pack = ReadingGameConfiguration.Instance.Questions.GetNextQuestion(); game.CurrentQuestion = pack; if (pack != null) { // Show the bar game.barSet.SetData(pack.GetQuestion()); } else { game.EndGame(game.CurrentStars, game.CurrentScore); } break; } case ReadingGameConfiguration.GameType.ReadAndListen: { // Pick a question pack var pack = ReadingGameConfiguration.Instance.Questions.GetNextQuestion(); game.CurrentQuestion = pack; break; } case ReadingGameConfiguration.GameType.FollowSong: // Just follow the bars game.UpdateFollowDifficulty(); game.barSet.SetData(game.songToPlay); break; case ReadingGameConfiguration.GameType.SimonSong: { // Pick a question pack var pack = ReadingGameConfiguration.Instance.Questions.GetNextQuestion(); game.CurrentQuestion = pack; break; } default: throw new ArgumentOutOfRangeException(); } game.barSet.active = false; if (firstRun) { switch (ReadingGameConfiguration.Instance.CurrentGameType) { case ReadingGameConfiguration.GameType.FollowReading: case ReadingGameConfiguration.GameType.ReadAndListen: game.PlayIntro(() => { completed = true; }); game.ReadState.TutorialMode = game.TutorialEnabled; break; case ReadingGameConfiguration.GameType.SimonSong: game.PlayIntro(() => { completed = true; }); game.ReadState.TutorialMode = game.TutorialEnabled; break; case ReadingGameConfiguration.GameType.FollowSong: game.PlayIntro(() => { var firstBar = game.barSet.GetNextBar(); var handleOffset = firstBar.glass.handleOffset.position - firstBar.glass.transform.position; if (game.TutorialEnabled) { TutorialUI.DrawLine(firstBar.start.transform.position + handleOffset, firstBar.endCompleted.transform.position + handleOffset, TutorialUI.DrawLineMode.FingerAndArrow, false, true); } game.barSet.SwitchToNextBar(); if (game.TutorialEnabled) { UnityEngine.Debug.LogError("TUTORIAL ON"); game.Context.GetAudioManager() .PlayDialogue(ReadingGameConfiguration.Instance.TutorialLocalizationId, () => { completed = true; }); } else { completed = true; } }); break; default: throw new ArgumentOutOfRangeException(); } } else { ++game.CurrentQuestionNumber; completed = true; game.ReadState.TutorialMode = false; } if (ReadingGameConfiguration.Instance.ShowTimer && !game.ReadState.TutorialMode) { game.Context.GetOverlayWidget().SetClockDuration(game.TimeToAnswer); game.Context.GetOverlayWidget().SetClockTime(game.TimeToAnswer); } firstRun = false; }
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); // Drag & Read if (dragging != null) { var inputManager = game.Context.GetInputManager(); bool applyMagnet = ReadingGameConfiguration.Instance.CurrentGameType == ReadingGameConfiguration.GameType.FollowReading; completedDragging = dragging.SetGlassScreenPosition(inputManager.LastPointerPosition + draggingOffset, applyMagnet); } else { if (ReadingGameConfiguration.Instance.CurrentGameType == ReadingGameConfiguration.GameType.FollowReading) { 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; } } // Antura reactions switch (ReadingGameConfiguration.Instance.CurrentGameType) { case ReadingGameConfiguration.GameType.FollowReading: 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; } break; case ReadingGameConfiguration.GameType.FollowSong: 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; game.UpdateFollowDifficulty(); } } if (timeFarFromTarget > 1.0f) { game.antura.Mood = ReadingGameAntura.AnturaMood.ANGRY; } else { game.antura.Mood = ReadingGameAntura.AnturaMood.HAPPY; } } break; case ReadingGameConfiguration.GameType.ReadAndListen: break; case ReadingGameConfiguration.GameType.SimonSong: break; } }