public static void WaitForTradeToFinish(DialogueContext Context) { if (Context.TradePanel.Result == Gui.Widgets.TradeDialogResult.Pending) { Context.Transition(WaitForTradeToFinish); } else { Context.Transition(ProcessTrade); } }
public override void OnEnter() { // Clear the input queue... cause other states aren't using it and it's been filling up. DwarfGame.GumInputMapper.GetInputQueue(); GuiRoot = new Gum.Root(new Point(640, 480), DwarfGame.GumSkin); GuiRoot.MousePointer = new Gum.MousePointer("mouse", 4, 0); var dialoguePanel = GuiRoot.RootItem.AddChild(new Gum.Widget { Font = "outline-font", TextColor = new Vector4(1, 1, 1, 1), MinimumSize = new Point(256, 0), MaximumSize = new Point(256, Int32.MaxValue), AutoLayout = Gum.AutoLayout.DockRight, Border = "border-fancy", InteriorMargin = new Gum.Margin(128, 0, 0, 0) }); GuiRoot.RootItem.Layout(); SpeakerAnimation = new Animation(DialogueContext.Envoy.OwnerFaction.Race.TalkAnimation); DialogueContext.SpeakerAnimation = SpeakerAnimation; DialogueContext.Panel = dialoguePanel; DialogueContext.Transition(DialogueTree.ConversationRoot); IsInitialized = true; base.OnEnter(); }
public static void ProcessTrade(DialogueContext Context) { if (Context.TradePanel.Result == NewGui.TradeDialogResult.Propose) { Context.TradePanel.Transaction.Apply(); } Context.Transition(ConversationRoot); }
public static void Trade(DialogueContext Context) { Context.TradePanel = Context.ChoicePanel.Root.ConstructWidget(new Gui.Widgets.TradePanel { Rect = Context.ChoicePanel.Root.RenderData.VirtualScreen, Envoy = new Trade.EnvoyTradeEntity(Context.Envoy), Player = new Trade.PlayerTradeEntity(Context.PlayerFaction) }) as Gui.Widgets.TradePanel; Context.TradePanel.Layout(); Context.ChoicePanel.Root.ShowDialog(Context.TradePanel); Context.Transition(WaitForTradeToFinish); }
public override void OnEnter() { // Clear the input queue... cause other states aren't using it and it's been filling up. DwarfGame.GumInputMapper.GetInputQueue(); GuiRoot = new Gui.Root(DwarfGame.GumSkin); GuiRoot.MousePointer = new Gui.MousePointer("mouse", 4, 0); GuiRoot.RootItem.Font = "font8"; int w = System.Math.Min(GuiRoot.RenderData.VirtualScreen.Width - 256, 550); int h = System.Math.Min(GuiRoot.RenderData.VirtualScreen.Height - 256, 300); int x = GuiRoot.RenderData.VirtualScreen.Width / 2 - w / 2; int y = System.Math.Max(GuiRoot.RenderData.VirtualScreen.Height / 2 - h / 2, 280); int bgx = x - 258; int bgy = y - 128; DialogueContext.SpeechBubble = GuiRoot.RootItem.AddChild(new Gui.Widget { Rect = new Rectangle(bgx + 258, bgy, w + 50, 128), Border = "speech-bubble-reverse", Font = "font16", TextColor = Color.Black.ToVector4() }); var bg = GuiRoot.RootItem.AddChild(new Widget() { Border = "border-dark", Rect = new Rectangle(bgx, bgy, 258, 258) }); DialogueContext.ChoicePanel = GuiRoot.RootItem.AddChild(new Gui.Widget { Rect = new Rectangle(x, y, w, h), Border = "border-fancy", AutoLayout = AutoLayout.DockFill }); SpeakerAnimation = AnimationLibrary.CreateAnimation(DialogueContext.Envoy.OwnerFaction.Race.TalkAnimation); SpeakerAnimationPlayer = new AnimationPlayer(SpeakerAnimation); DialogueContext.SpeakerAnimation = SpeakerAnimationPlayer; SpeakerWidget = bg.AddChild(new Widget() { Background = new TileReference(SpeakerAnimation.SpriteSheet.AssetName, 0), AutoLayout = AutoLayout.DockFill, MinimumSize = new Point(256, 256), Rect = new Rectangle(bgx, bgy - 5, 256, 256) }); DialogueContext.Politics = World.Diplomacy.GetPolitics( DialogueContext.PlayerFaction, DialogueContext.Envoy.OwnerFaction); DialogueContext.World = World; if (!DialogueContext.Politics.HasMet) { DialogueContext.Politics.HasMet = true; DialogueContext.Politics.RecentEvents.Add(new Diplomacy.PoliticalEvent() { Change = 0.0f, Description = "we just met", Duration = new TimeSpan(1, 0, 0, 0), Time = World.Time.CurrentDate }); } DialogueContext.EnvoyName = TextGenerator.GenerateRandom(Datastructures.SelectRandom(DialogueContext.Envoy.OwnerFaction.Race.NameTemplates).ToArray()); DialogueContext.Transition(DialogueTree.ConversationRoot); IsInitialized = true; base.OnEnter(); }
public static void ProcessTrade(DialogueContext Context) { if (Context.TradePanel.Result == Gui.Widgets.TradeDialogResult.Propose) { var containsHatedItem = Context.TradePanel.Transaction.PlayerItems .Select(item => ResourceLibrary.GetResourceByName(item.ResourceType)) .SelectMany(item => item.Tags) .Any(tag => Context.Envoy.OwnerFaction.Race.HatedResources.Contains(tag)); var containsLikedItem = Context.TradePanel.Transaction.PlayerItems .Select(item => ResourceLibrary.GetResourceByName(item.ResourceType)) .SelectMany(item => item.Tags) .Any(tag => Context.Envoy.OwnerFaction.Race.LikedResources.Contains(tag)); if (containsHatedItem) { Context.Envoy.OwnerFaction.Race.Speech.Language.SayBoo(); Context.NumOffensiveTrades++; var phrase = Datastructures.SelectRandom(Context.Envoy.OwnerFaction.Race.Speech.OffensiveTrades); var action = Context.NumOffensiveTrades >= 3 ? GoodbyeWithPrompt(phrase) : RootWithPrompt(phrase); Context.Transition(action); if (!Context.Politics.HasEvent("you tried to give us something offensive")) { Context.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 = Context.World.Time.CurrentDate }); } } else { if (containsLikedItem) { if (!Context.Politics.HasEvent("you gave us something we liked")) { Context.Politics.RecentEvents.Add(new Diplomacy.PoliticalEvent() { Change = 0.25f, Description = "you gave us something we liked", Duration = new TimeSpan(4, 0, 0, 0), Time = Context.World.Time.CurrentDate }); } } Context.TradePanel.Transaction.Apply(Context.World); Context.Transition(RootWithPrompt(Datastructures.SelectRandom(Context.Envoy.OwnerFaction.Race.Speech.GoodTrades))); Context.World.GoalManager.OnGameEvent(new Goals.Events.Trade { PlayerFaction = Context.PlayerFaction, PlayerGold = Context.TradePanel.Transaction.PlayerMoney, PlayerGoods = Context.TradePanel.Transaction.PlayerItems, OtherFaction = Context.Envoy.OwnerFaction, OtherGold = Context.TradePanel.Transaction.EnvoyMoney, OtherGoods = Context.TradePanel.Transaction.EnvoyItems }); if (!Context.Politics.HasEvent("we had profitable trade")) { Context.Politics.RecentEvents.Add(new Diplomacy.PoliticalEvent() { Change = 0.25f, Description = "we had profitable trade", Duration = new TimeSpan(2, 0, 0, 0), Time = Context.World.Time.CurrentDate }); } Context.Envoy.OwnerFaction.Race.Speech.Language.SayYay(); } } else if (Context.TradePanel.Result == Gui.Widgets.TradeDialogResult.RejectOffense || Context.TradePanel.Result == Gui.Widgets.TradeDialogResult.RejectProfit) { Context.Envoy.OwnerFaction.Race.Speech.Language.SayBoo(); Context.Transition(RootWithPrompt(Datastructures.SelectRandom(Context.Envoy.OwnerFaction.Race.Speech.BadTrades))); } else { Context.Transition(RootWithPrompt("Changed your mind?")); } }