Esempio n. 1
0
        private IEnumerable <SpeechNode> CommonGoods()
        {
            string goods = "We already have a lot of ";

            List <string> goodList = Faction.Race.CommonResources.Select(tags => tags.ToString()).ToList();

            goods += TextGenerator.GetListString(goodList);
            goods += " things";

            goods   += ". We don't have many ";
            goodList = Faction.Race.RareResources.Select(tags => tags.ToString()).ToList();
            goods   += TextGenerator.GetListString(goodList);
            goods   += " goods";
            goods   += ".";

            yield return(new SpeechNode()
            {
                Text = goods,
                Actions = new List <SpeechNode.SpeechAction>()
                {
                    new SpeechNode.SpeechAction()
                    {
                        Text = "OK",
                        Action = () => SpeechNode.Echo(DialougeTree)
                    }
                }
            });
        }
Esempio n. 2
0
        private IEnumerable <SpeechNode> WhatDoYouThink()
        {
            Diplomacy.Politics p            = World.ComponentManager.Diplomacy.GetPolitics(Faction, PlayerFation);
            Relationship       r            = p.GetCurrentRelationship();
            string             relationship = "So far, our relationship has been " + r;

            if (p.RecentEvents.Count > 0)
            {
                relationship += ", because ";
                List <string> events = p.RecentEvents.Select(e => e.Description).ToList();
                relationship += TextGenerator.GetListString(events);
            }

            relationship += ".";
            yield return(new SpeechNode()
            {
                Text = relationship,
                Actions = new List <SpeechNode.SpeechAction>()
                {
                    new SpeechNode.SpeechAction()
                    {
                        Text = "Interesting",
                        Action = () => SpeechNode.Echo(DialougeTree)
                    }
                }
            });
        }
Esempio n. 3
0
 private IEnumerable <SpeechNode> AskAQuestion()
 {
     yield return(new SpeechNode()
     {
         Text = "Ask...",
         Actions = new List <SpeechNode.SpeechAction>()
         {
             new SpeechNode.SpeechAction()
             {
                 Text = "What do you think of us?",
                 Action = WhatDoYouThink
             },
             new SpeechNode.SpeechAction()
             {
                 Text = "What's the news?",
                 Action = WhatsTheNews
             },
             new SpeechNode.SpeechAction()
             {
                 Text = "What goods do you want?",
                 Action = WhatGoods
             },
             new SpeechNode.SpeechAction()
             {
                 Text = "Nevermind",
                 Action = () => SpeechNode.Echo(DialougeTree)
             }
         }
     });
 }
Esempio n. 4
0
        private IEnumerable <SpeechNode> WhatGoods()
        {
            string goods = "We desire ";

            List <string> goodList = Faction.Race.LikedResources.Select(tags => tags.ToString()).ToList();

            goods += TextGenerator.GetListString(goodList);
            goods += " items";

            if (Faction.Race.HatedResources.Any())
            {
                goods   += ". But we find ";
                goodList = Faction.Race.HatedResources.Select(tags => tags.ToString()).ToList();
                goods   += TextGenerator.GetListString(goodList);
                goods   += " items offensive";
            }
            goods += ".";

            yield return(new SpeechNode()
            {
                Text = goods,
                Actions = new List <SpeechNode.SpeechAction>()
                {
                    new SpeechNode.SpeechAction()
                    {
                        Text = "Interesting",
                        Action = () => SpeechNode.Echo(DialougeTree)
                    }
                }
            });
        }
Esempio n. 5
0
 private IEnumerable <SpeechNode> WhatsTheNews()
 {
     yield return(new SpeechNode()
     {
         Text = "The world is the same as ever.",
         Actions = new List <SpeechNode.SpeechAction>()
         {
             new SpeechNode.SpeechAction()
             {
                 Text = "Interesting",
                 Action = () => SpeechNode.Echo(DialougeTree)
             }
         }
     });
 }
Esempio n. 6
0
        void Initialize()
        {
            Envoy.TradeMoney = Faction.TradeMoney + MathFunctions.Rand(-100.0f, 100.0f);
            Envoy.TradeMoney = Math.Max(Envoy.TradeMoney, 0.0f);
            TalkerName       = TextGenerator.GenerateRandom(Datastructures.SelectRandom(Faction.Race.NameTemplates).ToArray());
            Tabs             = new Dictionary <string, GUIComponent>();
            GUI = new DwarfGUI(Game, Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Default),
                               Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Title),
                               Game.Content.Load <SpriteFont>(ContentPaths.Fonts.Small), Input)
            {
                DebugDraw = false
            };
            IsInitialized = true;
            MainWindow    = new GUIComponent(GUI, GUI.RootComponent)
            {
                LocalBounds = new Rectangle(EdgePadding, EdgePadding, Game.GraphicsDevice.Viewport.Width - EdgePadding * 2, Game.GraphicsDevice.Viewport.Height - EdgePadding * 2)
            };

            Layout = new GridLayout(GUI, MainWindow, 11, 4);
            Layout.UpdateSizes();

            Talker = new SpeakerComponent(GUI, Layout, new Animation(Faction.Race.TalkAnimation));
            Layout.SetComponentPosition(Talker, 0, 0, 4, 4);

            DialougeSelector = new ListSelector(GUI, Layout)
            {
                Mode        = ListItem.SelectionMode.ButtonList,
                DrawButtons = true,
                DrawPanel   = false,
                Label       = "",
                ItemHeight  = 35,
                Padding     = 5
            };
            DialougeSelector.OnItemSelected += DialougeSelector_OnItemSelected;
            Layout.SetComponentPosition(DialougeSelector, 2, 3, 1, 8);

            BackButton = new Button(GUI, Layout, "Back", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.LeftArrow));
            Layout.SetComponentPosition(BackButton, 2, 10, 1, 1);
            BackButton.OnClicked += back_OnClicked;
            BackButton.IsVisible  = false;
            DialougeTree          = new SpeechNode()
            {
                Text    = GetGreeting(),
                Actions = new List <SpeechNode.SpeechAction>()
                {
                    new SpeechNode.SpeechAction()
                    {
                        Text   = "Trade...",
                        Action = WaitForTrade
                    },
                    new SpeechNode.SpeechAction()
                    {
                        Text   = "Ask a question...",
                        Action = AskAQuestion
                    },
                    new SpeechNode.SpeechAction()
                    {
                        Text   = "Declare war!",
                        Action = DeclareWar
                    },
                    new SpeechNode.SpeechAction()
                    {
                        Text   = "Leave",
                        Action = () =>
                        {
                            BackButton.IsVisible = true;
                            if (Envoy != null)
                            {
                                Diplomacy.RecallEnvoy(Envoy);
                            }
                            return(SpeechNode.Echo(new SpeechNode()
                            {
                                Text = GetFarewell(),
                                Actions = new List <SpeechNode.SpeechAction>()
                            }));
                        }
                    }
                }
            };


            if (Politics.WasAtWar)
            {
                PreeTree = new SpeechNode()
                {
                    Text    = Datastructures.SelectRandom(Faction.Race.Speech.PeaceDeclarations),
                    Actions = new List <SpeechNode.SpeechAction>()
                    {
                        new SpeechNode.SpeechAction()
                        {
                            Text   = "Make peace with " + Faction.Name,
                            Action = () =>
                            {
                                if (!Politics.HasEvent("you made peace with us"))
                                {
                                    Politics.RecentEvents.Add(new Diplomacy.PoliticalEvent()
                                    {
                                        Change      = 0.4f,
                                        Description = "you made peace with us",
                                        Duration    = new TimeSpan(4, 0, 0, 0),
                                        Time        = World.Time.CurrentDate
                                    });
                                }
                                return(SpeechNode.Echo(DialougeTree));
                            }
                        },
                        new SpeechNode.SpeechAction()
                        {
                            Text   = "Continue the war with " + Faction.Name,
                            Action = DeclareWar
                        }
                    }
                };
                Transition(PreeTree);
                Politics.WasAtWar = false;
            }
            else
            {
                Transition(DialougeTree);
            }


            if (!Politics.HasMet)
            {
                Politics.HasMet = true;

                Politics.RecentEvents.Add(new Diplomacy.PoliticalEvent()
                {
                    Change      = 0.0f,
                    Description = "we just met",
                    Duration    = new TimeSpan(1, 0, 0, 0),
                    Time        = World.Time.CurrentDate
                });
            }

            Layout.UpdateSizes();
            Talker.TweenIn(Drawer2D.Alignment.Top, 0.25f);
            DialougeSelector.TweenIn(Drawer2D.Alignment.Right, 0.25f);
        }
Esempio n. 7
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;
        }