Example #1
0
        public void Initialize()
        {
            ClearChildren();

            GridLayout panelLayout = new GridLayout(GUI, this, 10, 10);
            GroupBox   employeeBox = new GroupBox(GUI, panelLayout, "Employees");
            GridLayout boxLayout   = new GridLayout(GUI, employeeBox, 8, 4);
            ScrollView scrollView  = new ScrollView(GUI, boxLayout);

            EmployeeSelector = new ListSelector(GUI, scrollView)
            {
                Label         = "",
                DrawPanel     = false,
                Mode          = ListItem.SelectionMode.Selector,
                LocalBounds   = new Rectangle(0, 0, 256, Faction.Minions.Count * 24),
                WidthSizeMode = SizeMode.Fit
            };

            boxLayout.SetComponentPosition(scrollView, 0, 1, 3, 6);
            panelLayout.SetComponentPosition(employeeBox, 0, 0, 3, 10);

            foreach (CreatureAI creature in Faction.Minions)
            {
                EmployeeSelector.AddItem(creature.Stats.FullName);
            }


            EmployeeSelector.OnItemSelected += EmployeeSelector_OnItemSelected;

            Button hireButton = new Button(GUI, boxLayout, "Hire new", GUI.DefaultFont, Button.ButtonMode.ToolButton,
                                           GUI.Skin.GetSpecialFrame(GUISkin.Tile.ZoomIn))
            {
                ToolTip = "Hire new employees"
            };

            boxLayout.SetComponentPosition(hireButton, 0, 7, 2, 1);

            hireButton.OnClicked += hireButton_OnClicked;

            CurrentMinionBox = new GroupBox(GUI, panelLayout, "");

            GridLayout minionLayout = new GridLayout(GUI, CurrentMinionBox, 10, 10);

            CurrentMinionPanel       = new MinionPanel(GUI, minionLayout, Faction.Minions.FirstOrDefault());
            CurrentMinionPanel.Fire += CurrentMinionPanel_Fire;
            minionLayout.EdgePadding = 0;
            minionLayout.SetComponentPosition(CurrentMinionPanel, 0, 1, 10, 9);

            panelLayout.SetComponentPosition(CurrentMinionBox, 3, 0, 4, 10);

            if (Faction.Minions.Count > 0)
            {
                OnMinionSelected(Faction.Minions[0]);
            }
        }
Example #2
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);
        }
Example #3
0
        public override void Initialize(Dialog.ButtonType buttons, string title, string message)
        {
            WasSomeoneHired = false;
            GenerateApplicants(Company);
            IsModal    = true;
            OnClicked += HireDialog_OnClicked;
            OnClosed  += HireDialog_OnClosed;

            int w    = LocalBounds.Width;
            int h    = LocalBounds.Height;
            int rows = h / 64;
            int cols = 8;

            GridLayout layout = new GridLayout(GUI, this, rows, cols);

            Title = new Label(GUI, layout, title, GUI.TitleFont);
            layout.SetComponentPosition(Title, 0, 0, 2, 1);


            GroupBox applicantSelectorBox = new GroupBox(GUI, layout, "");

            layout.SetComponentPosition(applicantSelectorBox, 0, 1, rows / 2 - 1, cols - 1);

            GridLayout selectorLayout = new GridLayout(GUI, applicantSelectorBox, 1, 1);
            ScrollView view           = new ScrollView(GUI, selectorLayout);

            ApplicantSelector = new ListSelector(GUI, view)
            {
                Label = "-Applicants-"
            };

            selectorLayout.SetComponentPosition(view, 0, 0, 1, 1);

            foreach (Applicant applicant in Applicants)
            {
                ApplicantSelector.AddItem(applicant.Level.Name + " - " + applicant.Name);
            }

            ApplicantSelector.DrawPanel   = false;
            ApplicantSelector.LocalBounds = new Rectangle(0, 0, 128, Applicants.Count * 24);

            ApplicantSelector.OnItemSelected += ApplicantSelector_OnItemSelected;

            CurrentApplicant = Applicants[0];

            GroupBox applicantPanel = new GroupBox(GUI, layout, "");

            layout.SetComponentPosition(applicantPanel, rows / 2 - 1, 1, rows / 2 - 1, cols - 1);

            GridLayout applicantLayout = new GridLayout(GUI, applicantPanel, 1, 1);

            ApplicantPanel = new ApplicationPanel(applicantLayout);
            applicantLayout.SetComponentPosition(ApplicantPanel, 0, 0, 1, 1);
            ApplicantPanel.SetApplicant(CurrentApplicant);

            bool createOK     = false;
            bool createCancel = false;

            switch (buttons)
            {
            case ButtonType.None:
                break;

            case ButtonType.OkAndCancel:
                createOK     = true;
                createCancel = true;
                break;

            case ButtonType.OK:
                createOK = true;
                break;

            case ButtonType.Cancel:
                createCancel = true;
                break;
            }

            if (createOK)
            {
                Button okButton = new Button(GUI, layout, "OK", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.Check));
                layout.SetComponentPosition(okButton, cols - 2, rows - 1, 2, 1);
                okButton.OnClicked += okButton_OnClicked;
            }

            if (createCancel)
            {
                Button cancelButton = new Button(GUI, layout, "Cancel", GUI.DefaultFont, Button.ButtonMode.PushButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.Ex));
                layout.SetComponentPosition(cancelButton, cols - 4, rows - 1, 2, 1);
                cancelButton.OnClicked += cancelButton_OnClicked;
            }

            HireButton = new Button(GUI, layout, "Hire", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.ZoomIn));
            layout.SetComponentPosition(HireButton, cols - 1, rows - 2, 1, 1);

            HireButton.OnClicked += HireButton_OnClicked;
        }
Example #4
0
        public void Initialize()
        {
            ClearChildren();

            GridLayout panelLayout = new GridLayout(GUI, this, 10, 10);
            GroupBox employeeBox = new GroupBox(GUI, panelLayout, "Employees");
            GridLayout boxLayout = new GridLayout(GUI, employeeBox, 8, 4);
            ScrollView scrollView = new ScrollView(GUI, boxLayout);
            EmployeeSelector = new ListSelector(GUI, scrollView)
            {
                Label = "",
                DrawPanel = false,
                Mode = ListItem.SelectionMode.Selector,
                LocalBounds = new Rectangle(0, 0, 256, Faction.Minions.Count * 24),
                WidthSizeMode = SizeMode.Fit
            };

            boxLayout.SetComponentPosition(scrollView, 0, 1, 3, 6);
            panelLayout.SetComponentPosition(employeeBox, 0, 0, 3, 10);

            foreach (CreatureAI creature in Faction.Minions)
            {
                EmployeeSelector.AddItem(creature.Stats.FullName);
            }

            EmployeeSelector.OnItemSelected += EmployeeSelector_OnItemSelected;

            Button hireButton = new Button(GUI, boxLayout, "Hire new", GUI.DefaultFont, Button.ButtonMode.ToolButton,
                GUI.Skin.GetSpecialFrame(GUISkin.Tile.ZoomIn))
            {
                ToolTip = "Hire new employees"
            };

            boxLayout.SetComponentPosition(hireButton, 0, 7, 2, 1);

            hireButton.OnClicked += hireButton_OnClicked;

            CurrentMinionBox = new GroupBox(GUI, panelLayout, "");

            GridLayout minionLayout = new GridLayout(GUI, CurrentMinionBox, 10, 10);
            CurrentMinionPanel = new MinionPanel(GUI, minionLayout, Faction.Minions.FirstOrDefault());
            CurrentMinionPanel.Fire += CurrentMinionPanel_Fire;
            minionLayout.EdgePadding = 0;
            minionLayout.SetComponentPosition(CurrentMinionPanel, 0, 1, 10, 9);

            panelLayout.SetComponentPosition(CurrentMinionBox, 3, 0, 4, 10);

            if (Faction.Minions.Count > 0)
            {
                OnMinionSelected(Faction.Minions[0]);
            }
        }
Example #5
0
        public override void Initialize(Dialog.ButtonType buttons, string title, string message)
        {
            WasSomeoneHired = false;
            GenerateApplicants();
            IsModal = true;
            OnClicked += HireDialog_OnClicked;
            OnClosed += HireDialog_OnClosed;

            int w = LocalBounds.Width;
            int h = LocalBounds.Height;
            int rows = h / 64;
            int cols = 8;

            GridLayout layout = new GridLayout(GUI, this, rows, cols);
            Title = new Label(GUI, layout, title, GUI.TitleFont);
            layout.SetComponentPosition(Title, 0, 0, 2, 1);

            GroupBox applicantSelectorBox = new GroupBox(GUI, layout, "");
            layout.SetComponentPosition(applicantSelectorBox, 0, 1, rows / 2 - 1, cols - 1);

            GridLayout selectorLayout = new GridLayout(GUI, applicantSelectorBox, 1, 1);
            ScrollView view = new ScrollView(GUI, selectorLayout);
            ApplicantSelector = new ListSelector(GUI, view)
            {
                Label = "-Applicants-"
            };

            selectorLayout.SetComponentPosition(view, 0, 0, 1, 1);

            foreach (Applicant applicant in Applicants)
            {
                ApplicantSelector.AddItem(applicant.Level.Name + " - " + applicant.Name);
            }

            ApplicantSelector.DrawPanel = false;
            ApplicantSelector.LocalBounds = new Rectangle(0, 0, 128, Applicants.Count * 24);

            ApplicantSelector.OnItemSelected += ApplicantSelector_OnItemSelected;

            CurrentApplicant = Applicants[0];

            GroupBox applicantPanel = new GroupBox(GUI, layout, "");
            layout.SetComponentPosition(applicantPanel, rows / 2 - 1, 1, rows / 2 - 1, cols - 1);

            GridLayout applicantLayout = new GridLayout(GUI, applicantPanel, 1, 1);

            ApplicantPanel = new ApplicationPanel(applicantLayout);
            applicantLayout.SetComponentPosition(ApplicantPanel, 0, 0, 1, 1);
            ApplicantPanel.SetApplicant(CurrentApplicant);

            bool createOK = false;
            bool createCancel = false;

            switch (buttons)
            {
                case ButtonType.None:
                    break;
                case ButtonType.OkAndCancel:
                    createOK = true;
                    createCancel = true;
                    break;
                case ButtonType.OK:
                    createOK = true;
                    break;
                case ButtonType.Cancel:
                    createCancel = true;
                    break;
            }

            if (createOK)
            {
                Button okButton = new Button(GUI, layout, "OK", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.Check));
                layout.SetComponentPosition(okButton, cols - 2, rows - 1 , 2, 1);
                okButton.OnClicked += okButton_OnClicked;
            }

            if (createCancel)
            {
                Button cancelButton = new Button(GUI, layout, "Cancel", GUI.DefaultFont, Button.ButtonMode.PushButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.Ex));
                layout.SetComponentPosition(cancelButton, cols - 4, rows - 1, 2, 1);
                cancelButton.OnClicked += cancelButton_OnClicked;
            }

            HireButton = new Button(GUI, layout, "Hire", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.ZoomIn));
            layout.SetComponentPosition(HireButton, cols - 1, rows - 2, 1, 1);

            HireButton.OnClicked += HireButton_OnClicked;
        }
Example #6
0
        void Initialize()
        {
            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;
            Drawer = new Drawer2D(Game.Content, Game.GraphicsDevice);
            MainWindow = new Panel(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,
                DrawPanel = false,
                Label = ""
            };
            DialougeSelector.OnItemSelected += DialougeSelector_OnItemSelected;
            Layout.SetComponentPosition(DialougeSelector, 2, 2, 2, 10);

            Button back = new Button(GUI, Layout, "Back", GUI.DefaultFont, Button.ButtonMode.ToolButton, GUI.Skin.GetSpecialFrame(GUISkin.Tile.LeftArrow));
            Layout.SetComponentPosition(back, 0, 10, 1, 1);
            back.OnClicked += back_OnClicked;

            DialougeTree = new SpeechNode()
            {
                Text = GetGreeting(),
                Actions = new List<SpeechNode.SpeechAction>()
                {
                    new SpeechNode.SpeechAction()
                    {
                        Text = "Let's trade.",
                        Action = WaitForTrade
                    },
                    new SpeechNode.SpeechAction()
                    {
                        Text = "Goodbye.",
                        Action = () => SpeechNode.Echo(new SpeechNode()
                        {
                            Text = GetFarewell(),
                            Actions = new List<SpeechNode.SpeechAction>()
                        })
                    }
                }
            };

            Transition(DialougeTree);
            Politics.HasMet = true;

            PlayerFation.AddResources(new ResourceAmount(ResourceLibrary.ResourceType.Mana, 64));
        }