//Huvudmetod för utritning av spelets grafiska/visuella komponenter internal void DrawAndUpdate(float a_elapsedTime) { //Hämtar spelarObjekt Model.Player player = m_gameModel.m_playerSystem.m_player; //Uppdaterar kamera m_camera.UpdateCamera(); //Påbörjar utritning m_spriteBatch.Begin(); #region Draw //Ritar bakgrund m_gameModel.m_currentMap.DrawLayer(m_spriteBatch, m_gameModel.m_level.IndexBackgroundLayerOne, m_camera.GetScreenRectangle, 0f); m_gameModel.m_currentMap.DrawLayer(m_spriteBatch, m_gameModel.m_level.IndexBackgroundLayerTwo, m_camera.GetScreenRectangle, 0f); m_gameModel.m_currentMap.DrawLayer(m_spriteBatch, m_gameModel.m_level.IndexBackgroundLayerThree, m_camera.GetScreenRectangle, 0f); m_inputHandler.MouseIsOverLoot = false; //Ritar Items DrawItems(a_elapsedTime); //Ritar spelare, enemies, NPCs m_unitView.DrawAndUpdateUnits(a_elapsedTime); //Ritar spells DrawSpells(m_gameModel.m_playerSystem.m_spellSystem.ActiveSpells, a_elapsedTime); DrawSpells(m_gameModel.m_enemySystem.m_enemySpellSystem.ActiveSpells, a_elapsedTime); //Ritar förgrund if (m_gameModel.m_level.foregroundVisible) { m_gameModel.m_currentMap.DrawLayer(m_spriteBatch, m_gameModel.m_level.IndexForeground, m_camera.GetScreenRectangle, 0f); } #region Dialogrutor //Triggar utritning av quest meddelanden if (player.Target != null) { if (player.Target.GetType() == Model.GameModel.FRIENDLY_NPC) { Model.Friend npc = player.Target as Model.Friend; if (m_inputHandler.DidGetTargetedByLeftClick(m_camera.VisualizeRectangle(npc.ThisUnit.Bounds)) && npc.ThisUnit.Bounds.Intersects(player.CollisionArea) && npc.CanInterract) { m_conversation.DrawDialog = true; } else if (!npc.ThisUnit.Bounds.Intersects(player.CollisionArea)) { m_conversation.DrawDialog = false; } bool isQuestNpc = false; if (npc.UnitId == m_gameModel.m_questSystem.ActiveNpc) { isQuestNpc = true; } if (m_conversation.DrawDialog) { m_conversation.DrawNPCText(player.Target, isQuestNpc); } } } #endregion //Ritar UserInterface m_UIView.DrawAndUpdate(a_elapsedTime); //Uppdaterar och ritar zonetexter DrawZoneText(); #region Utritning av objektlager (DEBUG) //if (m_inputHandler.PressedAndReleased('V')) //{ // m_showDebug = !m_showDebug; //} //if (m_showDebug) //{ // m_gameModel.m_currentMap.DrawObjectLayer(m_spriteBatch, m_gameModel.m_level.IndexCollision, m_camera.GetScreenRectangle, 0f); // m_gameModel.m_currentMap.DrawObjectLayer(m_spriteBatch, m_gameModel.m_level.IndexInteraction, m_camera.GetScreenRectangle, 0f); // m_gameModel.m_currentMap.DrawObjectLayer(m_spriteBatch, m_gameModel.m_level.IndexFriendlyNPC, m_camera.GetScreenRectangle, 0f); // m_gameModel.m_currentMap.DrawObjectLayer(m_spriteBatch, m_gameModel.m_level.IndexEnemyNPC, m_camera.GetScreenRectangle, 0f); // m_gameModel.m_currentMap.DrawObjectLayer(m_spriteBatch, m_gameModel.m_level.IndexItems, m_camera.GetScreenRectangle, 0f); // m_gameModel.m_currentMap.DrawObjectLayer(m_spriteBatch, m_gameModel.m_level.IndexPlayer, m_camera.GetScreenRectangle, 0f); // m_gameModel.m_currentMap.DrawObjectLayer(m_spriteBatch, m_gameModel.m_level.IndexEnemyZone, m_camera.GetScreenRectangle, 0f); // m_gameModel.m_currentMap.DrawObjectLayer(m_spriteBatch, m_gameModel.m_level.IndexGraveyard, m_camera.GetScreenRectangle, 0f); //} #endregion #endregion m_spriteBatch.End(); //Repeterar uppdatering av kamera (Buggfix) m_camera.UpdateCamera(); //Uppdaterar och spelar spelmusik UpdateMusic(); }
/// <summary> /// Main drawing method. /// Draws all in game content. /// </summary> /// <param name="elapsedTime">Elapsed time in milleseconds</param> internal void DrawAndUpdate(float elapsedTime) { _inputHandler.MouseIsOverLoot = false; //Get player object Model.Player player = _gameModel.PlayerSystem.Player; //Updating player camera _camera.UpdateCamera(); _spriteBatch.Begin(); //Drawing background layers _gameModel.CurrentMap.DrawLayer(_spriteBatch, _gameModel.Level.IndexBackgroundLayerOne, _camera.GetScreenRectangle, 0f); _gameModel.CurrentMap.DrawLayer(_spriteBatch, _gameModel.Level.IndexBackgroundLayerTwo, _camera.GetScreenRectangle, 0f); _gameModel.CurrentMap.DrawLayer(_spriteBatch, _gameModel.Level.IndexBackgroundLayerThree, _camera.GetScreenRectangle, 0f); //Drawing items, units and spells DrawItems(elapsedTime, player); _unitView.DrawAndUpdateUnits(elapsedTime); DrawSpells(_gameModel.PlayerSystem.SpellSystem.ActiveSpells, elapsedTime); DrawSpells(_gameModel.EnemySystem._enemySpellSystem.ActiveSpells, elapsedTime); //Drawing foreground layers if (_gameModel.Level.ForegroundVisible) { _gameModel.CurrentMap.DrawLayer(_spriteBatch, _gameModel.Level.IndexForeground, _camera.GetScreenRectangle, 0f); } //Drawing dialog boxes, user interface and zone texts DrawDialogBoxes(player); _UIView.DrawAndUpdate(elapsedTime); DrawZoneText(); #region DEBUG - Show objectlayers if (_inputHandler.PressedAndReleased(InputHandler.Input.DEBUG_MODE)) { _showDebug = !_showDebug; } if (_showDebug) { _gameModel.CurrentMap.DrawObjectLayer(_spriteBatch, _gameModel.Level.IndexCollision, _camera.GetScreenRectangle, 0f); _gameModel.CurrentMap.DrawObjectLayer(_spriteBatch, _gameModel.Level.IndexInteraction, _camera.GetScreenRectangle, 0f); _gameModel.CurrentMap.DrawObjectLayer(_spriteBatch, _gameModel.Level.IndexFriendlyNPC, _camera.GetScreenRectangle, 0f); _gameModel.CurrentMap.DrawObjectLayer(_spriteBatch, _gameModel.Level.IndexEnemyNPC, _camera.GetScreenRectangle, 0f); _gameModel.CurrentMap.DrawObjectLayer(_spriteBatch, _gameModel.Level.IndexItems, _camera.GetScreenRectangle, 0f); _gameModel.CurrentMap.DrawObjectLayer(_spriteBatch, _gameModel.Level.IndexPlayer, _camera.GetScreenRectangle, 0f); _gameModel.CurrentMap.DrawObjectLayer(_spriteBatch, _gameModel.Level.IndexEnemyZone, _camera.GetScreenRectangle, 0f); _gameModel.CurrentMap.DrawObjectLayer(_spriteBatch, _gameModel.Level.IndexGraveyard, _camera.GetScreenRectangle, 0f); } #endregion _spriteBatch.End(); //Repeat the camera uodate (fix) _camera.UpdateCamera(); UpdateMusic(); }