示例#1
0
        //Metod för utritning av konversations-text
        public void DrawNPCText(Model.Unit a_friend, bool a_isQuestDialog)
        {
            //TextRektangel
            m_textRect = m_camera.VisualizeRectangle(new Rectangle(a_friend.ThisUnit.Bounds.X, a_friend.ThisUnit.Bounds.Y, 300, 50));

            //Visualiserar mapobjektets rektangel
            m_speakerRect = m_camera.VisualizeRectangle(new Rectangle(a_friend.ThisUnit.Bounds.X, a_friend.ThisUnit.Bounds.Y, a_friend.ThisUnit.Bounds.Width, a_friend.ThisUnit.Bounds.Height));

            //Hämtar meddelande
            string message = null;
            int    state   = 0;

            //Om det är en QuestDialog
            if (a_isQuestDialog)
            {
                message = GetQuestMessage(m_textRect);
            }
            //Annars en vanlig dialog
            else
            {
                //Om spelet passerat q3 befinner sig dialogstaten i state 1, annars 0
                if (m_questSystem.CurrentQuest.Id > 2)
                {
                    state = 1;
                }
                message = GetMessage(a_friend.UnitId, state);
            }

            //Om textrektangeln överlappar med talaren flyttas den i yled
            if (m_textRect.Intersects(m_speakerRect))
            {
                int overlap = m_textRect.Bottom - m_speakerRect.Top;
                m_textRect.Y -= overlap;
            }

            //Ritar textruta + text
            if (m_drawDialog)
            {
                m_spriteBatch.Draw(m_dialogueWindow, m_textRect, null, Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0f);
                m_spriteBatch.DrawString(m_spriteFont, message, new Vector2(m_textRect.X + 12, m_textRect.Y + 12), Color.White);

                if (a_isQuestDialog)
                {
                    DrawQuestButtons();
                }
            }
        }
示例#2
0
        /// <summary>
        /// Method for rendering of conversation text
        /// </summary>
        /// <param name="targetNpc">The source npc unit</param>
        /// <param name="isQuestDialog">Type of converation</param>
        public void DrawNPCText(Model.Unit targetNpc, bool isQuestDialog)
        {
            //Text rectangle
            _textRect = _camera.VisualizeRectangle(new Rectangle(targetNpc.ThisUnit.Bounds.X, targetNpc.ThisUnit.Bounds.Y, 300, 50));

            //Vizualizing the map-objects rectangle
            _speakerRect = _camera.VisualizeRectangle(new Rectangle(targetNpc.ThisUnit.Bounds.X, targetNpc.ThisUnit.Bounds.Y, targetNpc.ThisUnit.Bounds.Width, targetNpc.ThisUnit.Bounds.Height));

            string message = null;
            int    state   = 0;

            //Quest dialog
            if (isQuestDialog)
            {
                message = GetQuestMessage(_textRect);
            }
            //Standard dialog
            else
            {
                //If the game have passed the 3rd quest the dialog-state is 1, else 0
                if (_questSystem.CurrentQuest.Id > 2)
                {
                    state = 1;
                }

                message = GetMessage(targetNpc.UnitId, state);
            }

            //Moving the text box verticaly if it overlaps the speaker
            if (_textRect.Intersects(_speakerRect))
            {
                int overlap = _textRect.Bottom - _speakerRect.Top;
                _textRect.Y -= overlap;
            }

            //Drawing textbox and text
            if (_drawDialog)
            {
                _spriteBatch.Draw(_dialogueWindow, _textRect, null, Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0f);
                _spriteBatch.DrawString(_spriteFont, message, new Vector2(_textRect.X + 12, _textRect.Y + 12), Color.White);

                if (isQuestDialog)
                {
                    DrawQuestButtons();
                }
            }
        }
示例#3
0
        /// <summary>
        /// Method for drawing NPCs
        /// </summary>
        /// <param name="elapsedTime">Elapsed time in milleseconds</param>
        private void DrawNPC(float elapsedTime)
        {
            foreach (Model.NonPlayerCharacter friend in _nonPlayerCharacters)
            {
                //Checks wheter the NPC occurs within the camera screen
                if (friend.ThisUnit.Bounds.Intersects(_camera.GetScreenRectangle))
                {
                    friend.CanAddToQuest = true;

                    //Setting the NPC as target on click
                    if (_inputHandler.DidGetTargetedByLeftClick(_camera.VisualizeRectangle(friend.ThisUnit.Bounds)) ||
                        _inputHandler.DidGetTargetedByRightClick(_camera.VisualizeRectangle(friend.ThisUnit.Bounds)))
                    {
                        _player.Target = friend;
                    }

                    Vector2 interactPosition = _camera.VisualizeCordinates(friend.ThisUnit.Bounds.X + 10, friend.ThisUnit.Bounds.Y - 24);
                    int     bubble           = -1;

                    //Drawing dialog box if the NPC ID excists in the XML file for Dialogs
                    if (_conversation.DialogueList.Exists(Message => Message.id == friend.UnitId))
                    {
                        friend.CanInterract = true;
                        bubble = Convert.ToInt32(Texture.INTERACT);
                    }
                    else if ((_questSystem.QuestList.Exists(Quest => _questSystem.ActiveNpc == friend.UnitId && Quest.Id == _questSystem.CurrentQuest.Id)))
                    {
                        friend.CanInterract = true;

                        if (_questSystem.CurrentQuest.Status == Model.QuestSystem.END)
                        {
                            bubble = Convert.ToInt32(Texture.INTERACT_Q_COMPLETE);
                        }
                        else if (_questSystem.CurrentQuest.Status == Model.QuestSystem.PRE)
                        {
                            bubble = Convert.ToInt32(Texture.INTERACT_Q);
                        }
                        else
                        {
                            bubble = Convert.ToInt32(Texture.INTERACT);
                        }
                    }
                    else
                    {
                        friend.CanInterract = false;
                    }

                    if (friend.CanInterract)
                    {
                        _spriteBatch.Draw(_textures[bubble], new Rectangle((int)interactPosition.X, (int)interactPosition.Y, 30, 30), Color.White);
                    }

                    //Drawing NPC
                    Vector2 npcPosition = _camera.VisualizeCordinates(friend.ThisUnit.Bounds.X + 8, friend.ThisUnit.Bounds.Y + 8);
                    AnimationSystem.Texture animation = 0;

                    if (friend.Type == Model.NonPlayerCharacter.OLD_MAN)
                    {
                        animation = AnimationSystem.Texture.OLD_MAN;
                    }
                    else
                    {
                        animation = AnimationSystem.Texture.CITY_GUARD;
                    }

                    //Drawing target circle
                    DrawTargetCircle(_player, friend);
                    _animationSystem.UpdateAndDraw(elapsedTime, Color.White, npcPosition, friend.UnitState, animation);
                }
                else
                {
                    friend.CanAddToQuest = false;
                }
            }
        }
示例#4
0
        //Metod för utritning av friendly NPCs
        private void DrawFriendlyNPC(float a_elapsedTime)
        {
            foreach (Model.Friend friend in m_friends)
            {
                //Kollar att npcn är med på skärmen
                if (friend.ThisUnit.Bounds.Intersects(m_camera.GetScreenRectangle))
                {
                    friend.CanAddToQuest = true;

                    //Om man klickar på FNPC sätts den till spelarens target
                    if (m_inputHandler.DidGetTargetedByLeftClick(m_camera.VisualizeRectangle(friend.ThisUnit.Bounds)) ||
                        m_inputHandler.DidGetTargetedByRightClick(m_camera.VisualizeRectangle(friend.ThisUnit.Bounds)))
                    {
                        m_player.Target = friend;
                    }

                    Vector2 interactPosition = m_camera.VisualizeCordinates(friend.ThisUnit.Bounds.X + 10, friend.ThisUnit.Bounds.Y - 24);
                    int     bubble           = -1;

                    //Ritar ut pratbubbla om NPCns ID ingår i XML filen för konversationer
                    if (m_conversation.m_dialogueList.Exists(Message => Message.id == friend.UnitId))
                    {
                        friend.CanInterract = true;
                        bubble = INTERACT;
                    }
                    else if ((m_questSystem.QuestList.Exists(Quest => m_questSystem.ActiveNpc == friend.UnitId && Quest.Id == m_questSystem.CurrentQuest.Id)))
                    {
                        friend.CanInterract = true;

                        if (m_questSystem.CurrentQuest.Status == Model.QuestSystem.END)
                        {
                            bubble = INTERACT_Q_COMPLETE;
                        }
                        else if (m_questSystem.CurrentQuest.Status == Model.QuestSystem.PRE)
                        {
                            bubble = INTERACT_Q;
                        }
                        else
                        {
                            bubble = INTERACT;
                        }
                    }
                    else
                    {
                        friend.CanInterract = false;
                    }

                    if (friend.CanInterract)
                    {
                        m_spriteBatch.Draw(m_textures[bubble], new Rectangle((int)interactPosition.X, (int)interactPosition.Y, 30, 30), Color.White);
                    }

                    //Ritar NPC
                    Vector2 npcPosition = m_camera.VisualizeCordinates(friend.ThisUnit.Bounds.X + 8, friend.ThisUnit.Bounds.Y + 8);
                    int     animation   = 0;

                    if (friend.Type == Model.Friend.OLD_MAN)
                    {
                        animation = AnimationSystem.NPC_OLD_MAN;
                    }
                    else
                    {
                        animation = AnimationSystem.CITY_GUARD;
                    }

                    //Ritar target ringen.
                    DrawTargetCircle(m_player, friend);
                    m_animationSystem.UpdateAndDraw(a_elapsedTime, Color.White, npcPosition, friend.UnitState, animation);
                }
                else
                {
                    friend.CanAddToQuest = false;
                }
            }
        }