コード例 #1
0
        public ScenarioBuilderController(ScenarioBuilder ScenarioBuilder, ScenarioBuilderScreen Screen)
        {
            _ScenarioBuilder = ScenarioBuilder;
            _Screen          = Screen;

            _Screen.OnParametersChanged      = HandleParametersChanged;
            _Screen.OnArmyAdded             += HandleArmyAdded;
            _Screen.OnArmyParametersChanged += HandleArmyParametersChanged;
            _Screen.OnArmyRemoved           += HandleArmyRemoved;
            _Screen.OnFinished += HandleFinished;
        }
コード例 #2
0
        public override Pod SetupState(ProgramContext ProgramContext, ProgramStateContext ProgramStateContext)
        {
            var defaultParameters =
                new ScenarioParameters(
                    1939, GameData.MatchSettings.Values.First(), 8, new Coordinate(33, 33), false);

            _ScenarioBuilder = new ScenarioBuilder(defaultParameters);

            var screen = new ScenarioBuilderScreen(ProgramContext.ScreenResolution, _ScenarioBuilder);

            screen.OnMainMenuButtonClicked += HandleBack;

            _Controller             = new ScenarioBuilderController(_ScenarioBuilder, screen);
            _Controller.OnFinished += HandleFinished;

            return(screen);
        }
コード例 #3
0
        void HandleFinished(object Sender, EventArgs E)
        {
            ScenarioBuilder builder = ((ScenarioBuilderContext)_Context).ScenarioBuilder;
            ProgramStateTransitionEventArgs transition = null;

            if (builder.Armies.All(i => i.Validate()))
            {
                transition = new ProgramStateTransitionEventArgs(
                    ProgramState.MATCH,
                    new MatchContext(
                        new Match(builder.BuildScenario().MakeStatic(new Random()), new FullOrderAutomater())));
            }
            else
            {
                transition = new ProgramStateTransitionEventArgs(ProgramState.BUILD_ARMY, _Context);
            }
            OnProgramStateTransition(this, transition);
        }
コード例 #4
0
 public bool Apply(ScenarioBuilder ScenarioBuilder)
 {
     return(ScenarioBuilder.SetParameters(Parameters));
 }
コード例 #5
0
        public ScenarioBuilderScreen(Vector2f WindowSize, ScenarioBuilder ScenarioBuilder)
            : base(WindowSize, true)
        {
            this.ScenarioBuilder = ScenarioBuilder;

            var header = new Button("scenario-builder-header")
            {
                DisplayedString = "Custom Scenario"
            };

            _Pane.Add(header);
            _LeftDisplay.Position = new Vector2f(0, header.Size.Y);
            _ArmiesTable.Position = new Vector2f(_LeftDisplay.Size.X + 32, header.Size.Y);

            MakeSection("Year", _YearSelect, _LeftDisplay);
            _YearSelect.OnChange += HandleParametersChanged;
            for (uint i = 1939; i < 1946; ++i)
            {
                _YearSelect.Add(
                    new SelectionOption <uint>(
                        "scenario-builder-parameters-section-select-option")
                {
                    DisplayedString = i.ToString(),
                    Value           = i
                });
            }
            _YearSelect.SetValue(i => i.Value == ScenarioBuilder.Parameters.Year);

            MakeSection("Setting", _SettingSelect, _LeftDisplay);
            _SettingSelect.OnChange += HandleParametersChanged;
            foreach (MatchSetting setting in GameData.MatchSettings.Values)
            {
                _SettingSelect.Add(
                    new SelectionOption <MatchSetting>("scenario-builder-parameters-section-select-option")
                {
                    DisplayedString = ObjectDescriber.Describe(setting),
                    Value           = setting
                });
            }
            _SettingSelect.SetValue(i => i.Value == ScenarioBuilder.Parameters.Setting);

            MakeSection("Turns", _TurnsSelect, _LeftDisplay);
            _TurnsSelect.OnChange += HandleParametersChanged;
            for (byte i = 6; i <= 16; i += 2)
            {
                _TurnsSelect.Add(
                    new SelectionOption <byte>("scenario-builder-parameters-section-select-option")
                {
                    DisplayedString = i.ToString(),
                    Value           = i
                });
            }
            _TurnsSelect.SetValue(i => i.Value == ScenarioBuilder.Parameters.Turns);

            MakeSection("Fog of War", _FogOfWarCheckbox, _LeftDisplay);
            _FogOfWarCheckbox.OnChange += HandleParametersChanged;
            _FogOfWarCheckbox.Value     = ScenarioBuilder.Parameters.FogOfWar;

            MakeSection("Map Width", _MapWidthInput, _LeftDisplay);
            _MapWidthInput.OnChange += HandleParametersChanged;
            _MapWidthInput.Value     = ScenarioBuilder.Parameters.MapSize.X.ToString();

            MakeSection("Map Height", _MapHeightInput, _LeftDisplay);
            _MapHeightInput.OnChange += HandleParametersChanged;
            _MapHeightInput.Value     = ScenarioBuilder.Parameters.MapSize.Y.ToString();

            _Pane.Position = .5f * (WindowSize - _Pane.Size);

            var addArmyButton = new Button("scenario-builder-army-section-add-button")
            {
                DisplayedString = "+"
            };

            addArmyButton.OnClick += HandleArmyAdded;
            _ArmiesTable.Add(
                new TableRow("scenario-builder-army-section-header")
            {
                new Button("scenario-builder-army-section-faction-header")
                {
                    DisplayedString = "Faction"
                },
                new Button("scenario-builder-army-section-points-header")
                {
                    DisplayedString = "Points"
                },
                new Button("scenario-builder-army-section-team-header")
                {
                    DisplayedString = "Team"
                },
                addArmyButton
            });

            var finishedButton = new Button("large-button")
            {
                DisplayedString = "Finished"
            };

            finishedButton.Position = new Vector2f(0, _Pane.Size.Y - finishedButton.Size.Y - 32);
            finishedButton.OnClick += HandleFinished;

            _Pane.Add(finishedButton);
            _Pane.Add(_LeftDisplay);
            _Pane.Add(_ArmiesTable);
            _Items.Add(_Pane);
        }