internal void Update() { InputState inputState = input.GetState(); if (GameScreen.gameState == RPG.GameState.Event) { if (model.HasAction()) { updateDialogue(inputState, InputButton.A); updateDialogue(inputState, InputButton.LEFT); updateDialogue(inputState, InputButton.RIGHT); updateDialogue(inputState, InputButton.DOWN); updateDialogue(inputState, InputButton.UP); } else { pressedMap[InputButton.A] = false; pressedMap[InputButton.LEFT] = false; pressedMap[InputButton.RIGHT] = false; pressedMap[InputButton.DOWN] = false; pressedMap[InputButton.UP] = false; } } lastState = inputState; }
/// <summary> /// Called every frame to drive the game logic /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Tick() { // Push the last update to the screen if (!buffers[0].Equals(buffers[1]) || textRegionDirty) { textRegionDirty = false; Render(); } // Update the controllers characterController.Update(); levelController.Update(); dialogueController.Update(); // Do the rendering/sound stuff. TODO: Clean this up with views buffers[bufferIndex].Clear(); buffers[bufferIndex].X = (levelModel.Avatar.X + levelModel.Avatar.Width / 2) - buffers[bufferIndex].Width / 2; buffers[bufferIndex].Y = (levelModel.Avatar.Y + levelModel.Avatar.Height / 2) - buffers[bufferIndex].Height / 2; foreach (WorldObject obj in levelModel.level.Objects) { if (!obj.isHidden) { buffers[bufferIndex].Draw(obj); } } buffers[bufferIndex].Draw(levelModel.Avatar); mainRegion.SetMatrix(buffers[bufferIndex].Data); bufferIndex = (bufferIndex + 1) % 2; if (gameState == GameState.Event && gameDialogue.HasAction()) { if (detailRegion.GetText() != gameDialogue.GetCurrent()) { detailRegion.SetText(gameDialogue.GetCurrent()); textRegionDirty = true; Audio.AbortCurrentSound(); Audio.PlaySound(gameDialogue.GetCurrent()); } if (!detailRegion.IsVisible()) { detailRegion.SetVisibility(true); textRegionDirty = true; } } else { Audio.AbortCurrentSound(); detailRegion.SetText(string.Empty); if (detailRegion.IsVisible()) { textRegionDirty = true; detailRegion.SetVisibility(false); } } }