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); }
IEnumerable <Act.Status> RecallEnvoyOnFail(TradeEnvoy envoy) { Diplomacy.RecallEnvoy(envoy); TradePort.Faction.World.MakeAnnouncement("Envoy from " + envoy.OwnerFaction.Name + " left. Trade port inaccessible."); yield return(Act.Status.Success); }