Exemplo n.º 1
0
        public void UpdateDialog(int selected = 0)
        {
            var dialogList = new List <IMenuItem>();

            if (CurrentDialog == null)
            {
                return;
            }
            var dialogs = CurrentDialog.Current.Responses.Where(r => r.ConditionsMet).ToList();

            for (int i = 0; i < dialogs.Count; i++)
            {
                var item = dialogs[i];
                dialogList.Add(new MenuButton((item.Text)));
            }

            foreach (var i in dialogList)
            {
                i.Parent = DialogMenu;
            }

            if (DialogMenu == null)
            {
                DialogMenu = new RPGDialogMenu(CurrentNpc.Name + ": " + CurrentDialog.Current.NpcText, SelectDialog, dialogList.ToArray());
                DialogMenu.ExtendWindowHeight = false;
            }
            else
            {
                DialogMenu.Caption = CurrentNpc.Name + ": " + CurrentDialog.Current.NpcText;
                DialogMenu.Items.Clear();
                DialogMenu.Items.AddRange(dialogList);
                DialogMenu.Initialize();
            }

            DialogMenu.Caption = CurrentNpc.Name + ": " + CurrentDialog.Current.NpcText;
            RPGUI.FormatMenu(DialogMenu);
            DialogMenu.HeaderHeight = 25;
            if (DialogMenu != null && IsOpen(DialogMenu))
            {
                DialogMenu.SelectedIndex = selected;
            }
        }
Exemplo n.º 2
0
        private void SelectDialog(RPGDialogMenu obj)
        {
            var dialogs  = CurrentDialog.Current.Responses.Where(r => r.ConditionsMet).ToList();
            var selected = obj.SelectedIndex;

            var selectedItem = dialogs[selected];

            if (selectedItem.Action != ResponseAction.None)
            {
                switch (selectedItem.Action)
                {
                case ResponseAction.Vendor:
                    DialogEnd();
                    OpenShop();
                    break;

                case ResponseAction.Return_To_Start:
                    CurrentDialog.Current = CurrentDialog.StartingDialog;
                    break;

                case ResponseAction.Craft:
                    DialogEnd();
                    OpenCrafting();
                    break;

                case ResponseAction.Contract:
                    DialogEnd();
                    GetRandomContract();
                    break;

                case ResponseAction.Start_Quest:
                    var quest = RPG.PlayerData.Quests.First(q => q.Name == selectedItem.Paramater);
                    if (!quest.InProgress && !quest.Done)
                    {
                        quest.Start();
                    }
                    DialogEnd();
                    break;

                case ResponseAction.Finish_Quest:

                    var qu = RPG.PlayerData.Quests.First(q => q.Name == selectedItem.Paramater);
                    DialogEnd();
                    if (qu.ConditionsComplete)
                    {
                        qu.Complete();
                    }
                    break;

                case ResponseAction.Custom_End:
                    selectedItem.CustomAction.Invoke();
                    DialogEnd();
                    break;

                case ResponseAction.End:
                    DialogEnd();
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            else
            {
                CurrentDialog.Current = CurrentDialog.Dialogs.First(d => d.Id == selectedItem.DialogId);
            }

            UpdateDialog();
        }