public override void ExitState() { if (!exit) { base.ExitState(); DisableButtons(); } else { if (goToState == StatesIdList.RUNNER) { RunnerState rs = (RunnerState)parent.getState((int)goToState); rs.CharName = selected.ToString().ToLower(); rs.Level = chosenLevel; rs.Subjects = chosenSubjects; rs.GoBackTo = StatesIdList.EMPTY_STATE; } bgm.Stop(Microsoft.Xna.Framework.Audio.AudioStopOptions.AsAuthored); parent.ExitState(ID, (int)goToState); goToState = StatesIdList.EMPTY_STATE; ToggleButtonsOff(); } }
private void Reset() { if (monitoredState.MistakesMade < monitoredState.AllowedMistakes) { _continue.Visible = true; _continue.Enable(); tryAgain.Visible = false; tryAgain.Disable(); } else { _continue.Visible = false; _continue.Disable(); tryAgain.Visible = true; tryAgain.Enable(); } EnableButtons(); gotoState = StatesIdList.EMPTY_STATE; string txt = ""; if (monitoredState.AnswersGot == monitoredState.NumberOfAnswers) { if (monitoredState.MistakesMade == 0) { txt = "PERFEITO!\n(Você acertou tudo de primeira, merece o dobro de pontos!)\n\n"; } int instanceScore = monitoredState.Score * monitoredState.PerfectSscoreMultiplier; txt += "Pontuação obtida: " + monitoredState.Score + " x " + monitoredState.PerfectSscoreMultiplier + " = " + instanceScore; txt += "\n"; txt += "Pontuação acumulada: " + monitoredState.AccumulatedScore; txt += "\n"; txt += "Pontuação total: " + instanceScore + " + " + monitoredState.AccumulatedScore + " = " + (instanceScore + monitoredState.AccumulatedScore); } else { txt = "Hmmm, dessa vez não deu. Que tal tentar de novo?\n\n"; txt += "Respostas corretas obtidas: " + monitoredState.AnswersGot + " / " + monitoredState.NumberOfAnswers + "\n"; txt += "Erros cometidos: " + monitoredState.MistakesMade; } results.Text = txt; }
/// <summary> /// Sai de um estado e imediatamente entra em outro. /// </summary> /// <param name="id">ID do estado do qual o jogo sairá.</param> /// <param name="id2">ID do estado no qual o jogo entrará.</param> public void ExitState(int id, int id2) { if (StateAlreadyOnStack(id2)) { ExitState(id); querriedState = (StatesIdList)id2; } else { if (statesStack[statesStack.Count - 1].ID == id) { statesStack.RemoveAt(statesStack.Count - 1); EnterState(id2); } } }
/// <summary> /// Atualiza os estados na pilha, de cima para baixo. /// </summary> /// <param name="gameTime">O tempo de jogo.</param> private void UpdateStates(GameTime gameTime) { for (int stateIndex = statesStack.Count - 1; stateIndex >= 0; stateIndex--) { GameState state = statesStack[stateIndex]; if (querriedState != StatesIdList.EMPTY_STATE) { if (state.ID == (int)querriedState) { querriedState = StatesIdList.EMPTY_STATE; } else if (!state.ExitingState) { state.ExitState(); } } state.Update(gameTime); if (state.FreezeUpdatesBelow) { break; } } }
protected override void Initialize() { base.Initialize(); enterTransitionDuration = 500; exitTransitionDuration = 100; goToState = StatesIdList.EMPTY_STATE; Rectangle screen = parent.GraphicsDevice.Viewport.Bounds; char separator = Path.AltDirectorySeparatorChar; string basePath = "Menu" + separator + "Char_Selection" + separator; bg = new Scalable2DGameObject(goManager.R2D); bg.Width = screen.Width; bg.Height = screen.Height; bg.FilePath = basePath; bg.BaseFileName = "char_select_bg"; difficultyLbl = new TextBox(goManager.R2D); difficultyLbl.Width = 300; difficultyLbl.Height = 40; difficultyLbl.X = 5; difficultyLbl.Y = 5; difficultyLbl.FontSize = 40; difficultyLbl.TextColor = Color.Beige; difficultyLbl.ShadowColor = Color.Beige * 0.5f; difficultyLbl.DropShadow = true; difficultyLbl.ShadowOffset = new Vector2(-4, -4); difficultyLbl.Text = "DIFICULDADE:"; Rectangle bounds = new Rectangle((int)(difficultyLbl.Y + difficultyLbl.Height + 10), (int)(difficultyLbl.Y + difficultyLbl.Height), 163, 76); easy = new ToggleButton(goManager.R2D, bounds); easy.UseText = false; easy.BaseFileName = "easyBtn"; easy.FilePath = basePath + "difficulty" + separator; easy.mouseClicked += new Button.MouseClicked(difficultyBtn_mouseClicked); easy.LockToggleState = true; bounds.X += bounds.Width + 20; medium = new ToggleButton(goManager.R2D, bounds); medium.UseText = false; medium.BaseFileName = "mediumBtn"; medium.FilePath = easy.FilePath; medium.mouseClicked += new Button.MouseClicked(difficultyBtn_mouseClicked); medium.LockToggleState = true; bounds.X += bounds.Width + 20; hard = new ToggleButton(goManager.R2D, bounds); hard.UseText = false; hard.BaseFileName = "hardBtn"; hard.FilePath = easy.FilePath; hard.mouseClicked += new Button.MouseClicked(difficultyBtn_mouseClicked); hard.LockToggleState = true; subjectLbl = new TextBox(goManager.R2D); subjectLbl.Width = 180; subjectLbl.Height = 30; subjectLbl.X = 5; subjectLbl.Y = easy.Y + easy.Height + 40; subjectLbl.FontSize = 40; subjectLbl.TextColor = Color.Beige; subjectLbl.ShadowColor = Color.Beige * 0.5f; subjectLbl.DropShadow = true; subjectLbl.ShadowOffset = new Vector2(-4, -4); subjectLbl.Text = "MATÉRIA:"; bounds.X = 50; bounds.Y = (int)(subjectLbl.Y + subjectLbl.Height + 10); math = new ToggleButton(goManager.R2D, bounds); math.UseText = false; math.BaseFileName = "mathBtn"; math.FilePath = basePath + "subjects" + separator; math.mouseClicked += new Button.MouseClicked(subjectBtn_mouseClicked); math.LockToggleState = true; bounds.X += bounds.Width + 20; pt = new ToggleButton(goManager.R2D, bounds); pt.UseText = false; pt.BaseFileName = "ptBtn"; pt.FilePath = basePath + "subjects" + separator; pt.mouseClicked += new Button.MouseClicked(subjectBtn_mouseClicked); pt.LockToggleState = true; bounds.X += bounds.Width + 20; both = new ToggleButton(goManager.R2D, bounds); both.UseText = false; both.BaseFileName = "ptMathBtn"; both.FilePath = basePath + "subjects" + separator; both.mouseClicked += new Button.MouseClicked(subjectBtn_mouseClicked); both.LockToggleState = true; characterLbl = new TextBox(goManager.R2D); characterLbl.Width = 400; characterLbl.Height = 30; characterLbl.X = 5; characterLbl.Y = math.Y + math.Height + 40; characterLbl.FontSize = 40; characterLbl.TextColor = Color.Beige; characterLbl.ShadowColor = Color.Beige * 0.5f; characterLbl.DropShadow = true; characterLbl.ShadowOffset = new Vector2(-4, -4); characterLbl.Text = "ESCALE SEU ATACANTE:"; bounds = new Rectangle(screen.Width / 2 - 250, (int)(characterLbl.Y + characterLbl.Height + 10), 200, 250); cosme = new AnimatedButton(goManager.R2D, bounds, new int[] { 1, 1, 1, 1 }, new bool[] { false, false, false, false }); cosme.UseText = false; cosme.BaseFileName = "cosmeBtn"; cosme.FilePath = basePath; cosme.mouseClicked += new Button.MouseClicked(cosme_mouseClicked); cosme.LockToggleState = true; bounds = new Rectangle(screen.Width / 2 + 50, screen.Height / 2 - 25, 200, 250); maria = new AnimatedButton(goManager.R2D, bounds, new int[] { 1, 1, 1, 1 }, new bool[] { false, false, false, false }); maria.UseText = false; maria.BaseFileName = "mariaBtn"; maria.FilePath = cosme.FilePath; maria.mouseClicked += new Button.MouseClicked(maria_mouseClicked); maria.LockToggleState = true; bounds = new Rectangle(screen.Width / 2 - 235, (int)maria.Bounds.Y + (int)maria.Bounds.Height + 50, 210, 70); titleScreen = new Button(goManager.R2D, bounds); titleScreen.BaseFileName = "menuInicialBtn"; titleScreen.FilePath = "Menu" + separator + "Generic" + separator; titleScreen.UseText = false; titleScreen.mouseClicked += new Button.MouseClicked(titleScreen_mouseClicked); bounds = new Rectangle(screen.Width / 2 + 25, (int)titleScreen.Bounds.Y, 210, 70); play = new Button(goManager.R2D, bounds); play.BaseFileName = "playBtn"; play.FilePath = "Menu" + separator + "Char_Selection" + separator; play.mouseClicked += new Button.MouseClicked(play_mouseClicked); goManager.AddObject(bg); goManager.AddObject(difficultyLbl); goManager.AddObject(easy); goManager.AddObject(medium); goManager.AddObject(hard); goManager.AddObject(subjectLbl); goManager.AddObject(math); goManager.AddObject(pt); goManager.AddObject(both); goManager.AddObject(characterLbl); goManager.AddObject(cosme); goManager.AddObject(maria); goManager.AddObject(titleScreen); goManager.AddObject(play); DisableButtons(); }
void subjectBtn_mouseClicked(Button btn) { if (btn != math) { math.State = ButtonStates.NORMAL; } else { chosenSubjects = new QuestionSubject[] { QuestionSubject.MAT } }; if (btn != pt) { pt.State = ButtonStates.NORMAL; } else { chosenSubjects = new QuestionSubject[] { QuestionSubject.PT } }; if (btn != both) { both.State = ButtonStates.NORMAL; } else { chosenSubjects = new QuestionSubject[] { QuestionSubject.MAT, QuestionSubject.PT } }; } void difficultyBtn_mouseClicked(Button btn) { if (btn != easy) { easy.State = ButtonStates.NORMAL; } else { chosenLevel = RunnerLevel.EASY; } if (btn != medium) { medium.State = ButtonStates.NORMAL; } else { chosenLevel = RunnerLevel.MEDIUM; } if (btn != hard) { hard.State = ButtonStates.NORMAL; } else { chosenLevel = RunnerLevel.HARD; } } void play_mouseClicked(Button btn) { if (parent.IsActive) { goToState = StatesIdList.RUNNER; } } void maria_mouseClicked(Button btn) { if (parent.IsActive) { selected = SelectedCharacter.MARIA; cosme.State = ButtonStates.NORMAL; } } void cosme_mouseClicked(Button btn) { if (parent.IsActive) { selected = SelectedCharacter.COSME; maria.State = ButtonStates.NORMAL; } } void titleScreen_mouseClicked(Button btn) { if (parent.IsActive) { goToState = StatesIdList.MAIN_MENU; AudioManager.GetCue("cancel2").Play(); } }
void titleScreen_mouseClicked(Button btn) { gotoState = StatesIdList.MAIN_MENU; DisableButtons(); }
void playAgain_mouseClicked(Button btn) { monitoredState.ShouldReset = true; gotoState = StatesIdList.RUNNER; DisableButtons(); }
void _continue_mouseClicked(Button btn) { monitoredState.Continue(); gotoState = StatesIdList.RUNNER; DisableButtons(); }
protected override void Initialize() { if (!initialized) { base.Initialize(); level = RunnerLevel.EASY; subjects = new QuestionSubject[] { QuestionSubject.PT }; Score = 0; perfectScoreMultiplier = 2; enterTransitionDuration = 500; exitTransitionDuration = 1000; showTutorial = true; shouldWait = true; goBackTo = StatesIdList.EMPTY_STATE; questions = new List <QuestionGameObject>(); questionHeader = new TextBox(goManager.R2D); questionHeader.FontSize = 60; questionHeader.TextColor = new Color(245, 236, 222); questionHeader.Outline = true; questionHeader.OutlineColor = new Color(111, 129, 129); questionHeader.OutlineWeight = 2; questionHeader.Alignment = TextAlignment.CENTER; questionHeader.Width = 1024; questionHeader.Height = 100; questionHeader.Y = 5; string path = "Imagem" + Path.AltDirectorySeparatorChar + "ui" + Path.AltDirectorySeparatorChar + "bate_bola" + Path.AltDirectorySeparatorChar + "respostas_e_pontos" + Path.AltDirectorySeparatorChar; answersSupports = new Repeatable2DGameObject(goManager.R2D, path, "suporte", 2, -1); answersSupports.Y = 100; answersSupports.RepeatAmount = Vector2.Zero; answersSupports.AdaptToFrame = false; answersGotLbl = new List <TextBox>(); numberOfQuestions = 1; ball = new Ball(goManager.R3D, goManager.CollidableGameObjects); player = new Character(goManager.R3D, goManager.CollidableGameObjects, "cosme", ball); player.collidedWithAnswer += new Character.CollidedWithAnswer(player_collidedWithAnswer); cam = new Camera(new Vector3(0f, 3f, -4f), Vector3.Up, new Vector2(0.25f, 20f)); cam.lookAt(new Vector3(0f, 0.25f, 2f), true); cam.createProjection(MathHelper.PiOver4, parent.GraphicsDevice.Viewport.AspectRatio); goManager.R3D.Cam = cam; bg = new Background(goManager.R2D); field = new Field(goManager.R3D, rows, columns); progress = new ProgressBar(goManager.R2D); progress.Orientation = BarOrientation.VERTICAL; char separator = Path.AltDirectorySeparatorChar; string uiPath = "Imagem" + separator + "ui" + separator; progress.FilePath = uiPath + "progress_bar"; progress.FillOpacity = 0.75f; uiPath += "bate_bola" + separator; scoreLbl = new TextBox(goManager.R2D); scoreLbl.BaseFileName = "pontos"; scoreLbl.FilePath = uiPath + "respostas_e_pontos" + separator; scoreLbl.FontSize = 30; scoreLbl.Alignment = TextAlignment.CENTER; scoreLbl.Width = 219; scoreLbl.Height = 60; scoreLbl.X = parent.GraphicsDevice.Viewport.Width - scoreLbl.Width - 5; scoreLbl.Padding = new Vector4(0, scoreLbl.Height * 0.4f, 0, 0); mistakesLbl = new TextBox(goManager.R2D); mistakesLbl.BaseFileName = "erros"; mistakesLbl.FontSize = 30; mistakesLbl.Alignment = TextAlignment.CENTER; mistakesLbl.FilePath = uiPath + "respostas_e_pontos" + separator; mistakesLbl.Width = 219; mistakesLbl.Height = 60; mistakesLbl.X = scoreLbl.X; mistakesLbl.Padding = new Vector4(0, mistakesLbl.Height * 0.4f, 0, 0); bgmNames = new string[] { "wedo_midi", "vanilla", "relaxing_summer_bea", "quotsports_fanaticq" }; totalLoadingSteps = 6; currentLoadingStep = 0; goManager.AddObject(cam); goManager.AddObject(bg); goManager.AddObject(field); goManager.AddObject(ball); goManager.AddObject(player); goManager.AddObject(progress); goManager.AddObject(questionHeader); goManager.AddObject(answersSupports); goManager.AddObject(scoreLbl); goManager.AddObject(mistakesLbl); } }
protected override void Initialize() { base.Initialize(); IsMouseVisible = true; graphics.GraphicsDevice.BlendState = BlendState.AlphaBlend; spriteBatch = new SpriteBatch(graphics.GraphicsDevice); querriedState = StatesIdList.EMPTY_STATE; states = new Dictionary <int, GameState>(); statesStack = new List <GameState>(); Menu menu = new Menu((int)StatesIdList.MAIN_MENU, this); states.Add(menu.ID, menu); Episodio01 md = new Episodio01((int)StatesIdList.EPISODE_01, this); states.Add(md.ID, md); EncerramentoDoEpisodio1 ede1 = new EncerramentoDoEpisodio1((int)StatesIdList.EPISODE_01_END, this); states.Add(ede1.ID, ede1); RunnerState rs = new RunnerState((int)StatesIdList.RUNNER, this); states.Add(rs.ID, rs); RunnerWaitState rws = new RunnerWaitState((int)StatesIdList.RUNNER_WAIT, this); states.Add(rws.ID, rws); RunnerEndState res = new RunnerEndState((int)StatesIdList.RUNNER_END, this, rs); states.Add(res.ID, res); TutorialState ts = new TutorialState((int)StatesIdList.RUNNER_TUTORIAL, this); states.Add(ts.ID, ts); CadernoDeAtividades cda = new CadernoDeAtividades((int)StatesIdList.OPTIONS, this, md); states.Add(cda.ID, cda); PauseState ps = new PauseState((int)StatesIdList.PAUSE, this); states.Add(ps.ID, ps); CharSelectionState css = new CharSelectionState((int)StatesIdList.CHAR_SELECTION, this); states.Add(css.ID, css); LoadingState ls = new LoadingState((int)StatesIdList.LOADING, this); states.Add(ls.ID, ls); CreditsState cs = new CreditsState((int)StatesIdList.CREDITS, this); states.Add(cs.ID, cs); EnterState(menu.ID); }