Пример #1
0
        /// <summary>
        /// Method for drawing dialog boxes
        /// </summary>
        /// <param name="player">Player object</param>
        private void DrawDialogBoxes(Model.Player player)
        {
            //Trigger the drawing dialog boxes
            if (player.Target != null)
            {
                if (player.Target.GetType() == Model.GameModel.FRIENDLY_NPC)
                {
                    Model.NonPlayerCharacter npc = player.Target as Model.NonPlayerCharacter;

                    if (_inputHandler.DidGetTargetedByLeftClick(_camera.VisualizeRectangle(npc.ThisUnit.Bounds)) &&
                        npc.ThisUnit.Bounds.Intersects(player.CollisionArea) && npc.CanInterract)
                    {
                        _conversation.DrawDialog = true;
                    }
                    else if (!npc.ThisUnit.Bounds.Intersects(player.CollisionArea))
                    {
                        _conversation.DrawDialog = false;
                    }

                    bool isQuestNpc = false;

                    if (npc.UnitId == _gameModel.QuestSystem.ActiveNpc)
                    {
                        isQuestNpc = true;
                    }

                    if (_conversation.DrawDialog)
                    {
                        _conversation.DrawNPCText(player.Target, isQuestNpc);
                    }
                }
            }
        }
        //Metod för utritning av QuestLog
        private void DrawQuestLog()
        {
            List <Objective> progress   = m_questSystem.ObjectiveList;
            List <Objective> quest      = m_questSystem.CurrentQuest.Objectives;
            Vector2          position   = new Vector2(405, 150);
            Rectangle        textRect   = m_camera.VisualizeRectangle(new Rectangle((int)position.X + 8, (int)position.Y + 53, 225, 350));
            Rectangle        closeCross = GetCloseButton(position.X, position.Y, QLOG);

            m_spriteBatch.Draw(m_textures[QLOG], position, Color.White);

            if (m_questSystem.CurrentQuest.Status != Model.QuestSystem.PRE)
            {
                m_spriteBatch.DrawString(m_spriteFontSegoeSmall, m_conversation.GetLogMessage(textRect), m_camera.LogicalizeCordinates(textRect.X, textRect.Y), Color.White);

                int changeRow = 150;
                for (int i = 0; i < progress.Count; i++)
                {
                    m_spriteBatch.DrawString(m_spriteFontSegoeSmall, progress[i].Amount + "/" + quest[i].Amount + " - " + quest[i].Name, m_camera.LogicalizeCordinates(textRect.X, textRect.Y + changeRow), Color.White);
                    changeRow += 18;
                }
            }

            if (m_inputHandler.MouseIsOver(new Rectangle((int)position.X, (int)position.Y, m_textures[QLOG].Bounds.Width, m_textures[QLOG].Bounds.Height)))
            {
                m_inputHandler.MouseIsOverInterface = true;
            }
            if (m_inputHandler.DidGetTargetedByLeftClick(closeCross))
            {
                m_questSystem.IsWatchingQuestLog = false;
            }
        }
Пример #3
0
        //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();
        }