Example #1
0
 /// <summary>
 /// Called at the start of a conversation between the player and an npc
 /// </summary>
 /// <param name="subject">The subject npc of the interaction</param>
 public void Start(ActiveNpc subject)
 {
     Subject = subject;
     State = NpcInteractionState.Intro;
     CurrentText = subject.Type.Dialog.Get(State).Line;
     SkipFrame = true;
 }
Example #2
0
        public void Update(Camera camera, Control control, SpriteFont font)
        {
            #region Setup Dialog Area

            if (State == NpcInteractionState.Intro || State == NpcInteractionState.Gossip)
            {
                // Calculate dialog area
                CurrentLines = TextHelper.SplitWrap(CurrentText, 330, font, 0.75f).Length;
                CurrentBody = camera.FromRectangle(new Rectangle(Subject.Movement.Area.Center.X - Width / 2, Subject.Movement.Area.Top - Height - 20, Width, Height));
                CurrentHeader = camera.FromRectangle(new Rectangle(Subject.Movement.Area.Center.X - Width / 2, Subject.Movement.Area.Top - Height - 52, Width, 32));
                Height = 30 + (int)(font.MeasureString("S").Y - 4) * (CurrentLines + 1);

                if (control.MousePos.Intersects(CurrentBody))
                    control.MouseLock = true;
            }

            #endregion

            #region Intro

            if (State == NpcInteractionState.Intro)
            {

                // Actions
                Vector2 footer_offset = new Vector2(CurrentBody.X + 10, CurrentBody.Y + Height - 25);
                CurrentSelection = "";
                Vector2 current_font;

                // if shop
                current_font = font.MeasureString("Shop") * ScaleActions;
                if (control.MousePos.Intersects(new Rectangle((int)footer_offset.X, (int)footer_offset.Y, (int)current_font.X, (int)current_font.Y)))
                {
                    CurrentSelection = "Shop";
                    if (control.Click()) { State = NpcInteractionState.Shop; }
                }
                footer_offset.X += (int)(font.MeasureString("Shop").X * 0.7f) + 10;

                // if gossip
                current_font = font.MeasureString("Gossip") * ScaleActions;
                if (control.MousePos.Intersects(new Rectangle((int)footer_offset.X, (int)footer_offset.Y, (int)current_font.X, (int)current_font.Y)))
                {
                    CurrentSelection = "Gossip";
                    if (control.Click()) { State = NpcInteractionState.Gossip; CurrentText = Subject.Type.Dialog.Get(State).Line; }
                }
                footer_offset.X += (int)(font.MeasureString("Gossip").X * 0.7f) + 10;

                // if follow
                current_font = font.MeasureString("Follow Me") * ScaleActions;
                if (control.MousePos.Intersects(new Rectangle((int)footer_offset.X, (int)footer_offset.Y, (int)current_font.X, (int)current_font.Y)))
                {
                    CurrentSelection = "Follow Me";
                    if (control.Click()) { State = NpcInteractionState.None; }
                }
                footer_offset.X += (int)(font.MeasureString("Follow Me").X * 0.7f) + 10;

            }

            #endregion
        }
Example #3
0
 /// <summary>
 /// End the conversation
 /// </summary>
 public void End()
 {
     Subject = null;
     State = NpcInteractionState.None;
 }