Ejemplo n.º 1
0
        public static TradeDialog Popup(DwarfGUI gui, int w, int h, GUIComponent parent, int x, int y, WindowButtons buttons, Faction faction, List <ResourceAmount> resources)
        {
            TradeDialog d = new TradeDialog(gui, parent, faction, resources, buttons)
            {
                LocalBounds = new Rectangle(x, y, w, h),
                MinWidth    = w,
                MinHeight   = h,
                DrawOrder   = 100,
                IsModal     = true
            };

            return(d);
        }
Ejemplo n.º 2
0
        IEnumerable <SpeechNode> WaitForTrade()
        {
            TradeDialog dialog = TradeDialog.Popup(GUI, GUI.RootComponent, Faction, Resources);

            LastEvent        = null;
            dialog.OnTraded += dialog_OnClicked;



            while (LastEvent == null && dialog.IsVisible)
            {
                yield return(null);
            }

            if (LastEvent != null)
            {
                TradeEvent.Profit profit = LastEvent.GetProfit();

                if (LastEvent.IsHate() && !Politics.HasEvent("you tried to give us something offensive"))
                {
                    Politics.RecentEvents.Add(new Diplomacy.PoliticalEvent()
                    {
                        Change      = -0.25f,
                        Description = "you tried to give us something offensive",
                        Duration    = new TimeSpan(4, 0, 0, 0),
                        Time        = World.Time.CurrentDate
                    });
                }
                else if ((!LastEvent.IsHate() && LastEvent.IsLike()) && !Politics.HasEvent("you gave us something we liked"))
                {
                    Politics.RecentEvents.Add(new Diplomacy.PoliticalEvent()
                    {
                        Change      = 0.25f,
                        Description = "you gave us something we liked",
                        Duration    = new TimeSpan(4, 0, 0, 0),
                        Time        = World.Time.CurrentDate
                    });
                }

                if (profit.PercentProfit > 0.25f && !LastEvent.IsHate())
                {
                    DoTrade(LastEvent);

                    if (!Politics.HasEvent("we had profitable trade"))
                    {
                        Politics.RecentEvents.Add(new Diplomacy.PoliticalEvent()
                        {
                            Change      = 0.25f,
                            Description = "we had profitable trade",
                            Duration    = new TimeSpan(2, 0, 0, 0),
                            Time        = World.Time.CurrentDate
                        });
                    }

                    yield return(new SpeechNode()
                    {
                        Text = GetGoodTradeText(),
                        Actions = new List <SpeechNode.SpeechAction>()
                        {
                            new SpeechNode.SpeechAction()
                            {
                                Text = "Ok",
                                Action = () => SpeechNode.Echo(DialougeTree)
                            }
                        }
                    });
                }
                else
                {
                    yield return(new SpeechNode()
                    {
                        Text = GetBadTradeText(),
                        Actions = new List <SpeechNode.SpeechAction>()
                        {
                            new SpeechNode.SpeechAction()
                            {
                                Text = "Sorry.",
                                Action = () => SpeechNode.Echo(DialougeTree)
                            }
                        }
                    });
                }
                yield break;
            }
            else
            {
                yield return(DialougeTree);
            }
            yield break;
        }
Ejemplo n.º 3
0
        public static TradeDialog Popup(DwarfGUI gui, int w, int h, GUIComponent parent, int x, int y, WindowButtons buttons, Faction faction)
        {
            TradeDialog d = new TradeDialog(gui, parent, faction, buttons)
            {
                LocalBounds =
                    new Rectangle(x, y, w, h),
                MinWidth = w - 150,
                MinHeight = h - 150,
                DrawOrder = 100,
                IsModal = true
            };

            return d;
        }