Beispiel #1
0
        public void SetScenario(
            Scenario Scenario, UnitConfigurationRenderer UnitRenderer, FactionRenderer FactionRenderer)
        {
            _ScenarioDisplay.Clear();
            foreach (ArmyConfiguration army in Scenario.ArmyConfigurations)
            {
                _ScenarioDisplay.Add(
                    new Button("scenario-army-header")
                {
                    DisplayedString = ObjectDescriber.Describe(army.Faction)
                });
                var      factionMount = new GuiContainer <GuiItem>("scenario-faction-mount");
                Vector2f size         = factionMount.Size - factionMount.LeftPadding * 2;
                var      faction      = new FactionView(army.Faction, FactionRenderer, Math.Min(size.X, size.Y));
                faction.Position = .5f * (factionMount.Size - faction.Size) - factionMount.LeftPadding;
                factionMount.Add(faction);
                _ScenarioDisplay.Add(factionMount);
                foreach (DeploymentConfiguration deployment in army.DeploymentConfigurations)
                {
                    _ScenarioDisplay.Add(new DeploymentRow(deployment, army.Faction, UnitRenderer));
                }
                foreach (ObjectiveSuccessTrigger trigger in army.VictoryCondition.Triggers)
                {
                    _ScenarioDisplay.Add(new VictoryConditionRow(trigger));
                }
            }

            _DetailDisplay.Clear();
            AddDetail("Environment", ObjectDescriber.Describe(Scenario.Environment));
            AddDetail("Turns", Scenario.TurnConfiguration.Turns.ToString());
            AddSequence("Deploy Order", Scenario.TurnConfiguration.DeploymentOrder, Scenario.ArmyConfigurations.ToArray());
            AddSequence("Turn Order", Scenario.TurnConfiguration.TurnOrder, Scenario.ArmyConfigurations.ToArray());
            AddDetail("Strength", Scenario.ArmyConfigurations.Select(i => DescribeStrength(i)).ToArray());
        }
        public VictoryConditionPane(Match Match, FactionRenderer FactionRenderer)
            : base("victory-condition-pane")
        {
            _CloseButton.Position = new Vector2f(Size.X - _CloseButton.Size.X - LeftPadding.X * 2, 0);
            _CloseButton.OnClick += HandleClose;

            _VictoryConditionDisplay.Position = new Vector2f(0, _CloseButton.Size.Y + 24);
            foreach (ArmyConfiguration army in Match.Scenario.ArmyConfigurations)
            {
                _VictoryConditionDisplay.Add(
                    new Button("scenario-army-header")
                {
                    DisplayedString = ObjectDescriber.Describe(army.Faction)
                });
                var      factionMount = new GuiContainer <GuiItem>("scenario-faction-mount");
                Vector2f size         = factionMount.Size - factionMount.LeftPadding * 2;
                var      faction      = new FactionView(army.Faction, FactionRenderer, Math.Min(size.X, size.Y));
                faction.Position = .5f * (factionMount.Size - faction.Size) - factionMount.LeftPadding;
                factionMount.Add(faction);
                _VictoryConditionDisplay.Add(factionMount);
                foreach (ObjectiveSuccessTrigger trigger in army.VictoryCondition.Triggers)
                {
                    _VictoryConditionDisplay.Add(new VictoryConditionRow(trigger));
                }
            }

            Add(_CloseButton);
            Add(_VictoryConditionDisplay);
        }
Beispiel #3
0
        public override Pod SetupState(ProgramContext ProgramContext, ProgramStateContext ProgramStateContext)
        {
            _Context = ProgramStateContext;

            var context         = (MatchContext)ProgramStateContext;
            var factionRenderer = new FactionRenderer(context.Match.Scenario, GameData.FactionRenderDetails, 512, 1024);
            var screen          = new MatchEndScreen(context.Match, ProgramContext.ScreenResolution, factionRenderer);

            screen.OnMainMenuButtonClicked += HandleBack;
            _Controller = new MatchEndController(screen, context);
            return(screen);
        }
Beispiel #4
0
        public MatchScreen(
            Vector2f WindowSize,
            Match Match,
            IEnumerable <Army> FollowedArmies,
            TileRenderer TileRenderer,
            UnitConfigurationRenderer UnitRenderer,
            FactionRenderer FactionRenderer)
            : base(WindowSize, Match.Map, TileRenderer)
        {
            Match.OnStartPhase   += _EventBuffer.Hook <StartTurnComponentEventArgs>(HandleNewTurn).Invoke;
            Match.OnExecuteOrder += _EventBuffer.Hook <ExecuteOrderEventArgs>(HandleOrderExecuted).Invoke;

            this.UnitRenderer    = UnitRenderer;
            this.FactionRenderer = FactionRenderer;

            _FollowedArmies  = new HashSet <Army>(FollowedArmies);
            _FogOfWar        = Match.Scenario.Rules.FogOfWar;
            _FogOfWarHandler = _EventBuffer.Hook <SightUpdatedEventArgs>(HandleSightUpdated);

            EventHandler <NewUnitEventArgs> addUnitHandler = _EventBuffer.Hook <NewUnitEventArgs>(AddUnit).Invoke;

            foreach (Army a in Match.Armies)
            {
                a.OnUnitAdded += addUnitHandler;
                foreach (Unit u in a.Units)
                {
                    AddUnit(u);
                }
            }

            for (int i = 0; i < Match.Scenario.TurnConfiguration.Turns; ++i)
            {
                _TurnCounter.Add(new Checkbox("overlay-turn-counter-box")
                {
                    Enabled = false
                });
            }

            _FinishButton.Position            = Size - _FinishButton.Size - new Vector2f(32, 32);
            _FinishButton.OnClick            += HandleFinishClicked;
            _InfoDisplay.Position             = _FinishButton.Position - new Vector2f(0, _InfoDisplay.Size.Y + 16);
            _VictoryConditionDisplay.Position =
                _InfoDisplay.Position - new Vector2f(0, _VictoryConditionDisplay.Size.Y + 16);
            _ActionDisplay.Position = new Vector2f(WindowSize.X - _ActionDisplay.Size.X - 16, 16);

            _TransformedItems.Add(_StackLayer);

            _Items.Add(_FinishButton);
            _Items.Add(_InfoDisplay);
            _Items.Add(_VictoryConditionDisplay);
            _Items.Add(_TurnCounter);
            _Items.Add(_ActionDisplay);
        }
        public MatchEndScreen(Match Match, Vector2f WindowSize, FactionRenderer FactionRenderer)
            : base(WindowSize)
        {
            _Table.Position = .5f * (WindowSize - _Table.Size);
            foreach (Army a in Match.Armies)
            {
                _Table.Add(new MatchEndArmyRow(a, FactionRenderer));
            }

            _SaveButton.Position = new Vector2f(_Table.Size.X - _SaveButton.Size.X, 0);
            _SaveButton.OnClick += HandleSaveClicked;
            _Table.Add(_SaveButton);

            _Items.Add(_Table);
        }
        public FactionView(Faction Faction, FactionRenderer Renderer, float Scale)
        {
            this.Faction = Faction;
            this.Scale   = Scale;

            var renderInfo = Renderer.GetRenderInfo(Faction);

            _Texture  = renderInfo.Item1;
            _Vertices = new Vertex[]
            {
                new Vertex(new Vector2f(0, 0), Color.White, renderInfo.Item2[0]),
                new Vertex(new Vector2f(1, 0), Color.White, renderInfo.Item2[1]),
                new Vertex(new Vector2f(1, 1), Color.White, renderInfo.Item2[2]),
                new Vertex(new Vector2f(0, 1), Color.White, renderInfo.Item2[3])
            };
        }
 public MatchEndArmyRow(Army Army, FactionRenderer FactionRenderer)
     : base("match-end-army-row")
 {
     _FactionView = new FactionView(Army.Configuration.Faction, FactionRenderer, 128)
     {
         Position = LeftPadding
     };
     Add(new Button("match-end-army-header")
     {
         DisplayedString = ObjectDescriber.Describe(Army.Configuration.Faction)
     });
     Add(new Button("match-end-army-success")
     {
         DisplayedString = ObjectDescriber.Describe(Army.GetObjectiveSuccessLevel())
     });
 }
        public override Pod SetupState(ProgramContext ProgramContext, ProgramStateContext ProgramStateContext)
        {
            _Context        = (MatchContext)ProgramStateContext;
            _MatchEndBuffer = new EventBuffer <EventArgs>();

            var renderer = new UnitConfigurationRenderer(
                _Context.Match.Scenario,
                GameData.UnitRenderDetails,
                128,
                1024,
                ClassLibrary.Instance.GetFont("compacta"));
            var factionRenderer =
                new FactionRenderer(_Context.Match.Scenario, GameData.FactionRenderDetails, 512, 1024);
            var armies = new HashSet <Army>(_Context.GetPlayerControlledArmies());

            var screen = new MatchScreen(
                ProgramContext.ScreenResolution,
                _Context.Match,
                armies,
                GameData.TileRenderers[_Context.Match.Scenario.Environment.UniqueKey],
                renderer,
                factionRenderer);
            var controller =
                new HumanMatchPlayerController(
                    _Context.MakeMatchAdapter(), armies, renderer, screen, ProgramContext.KeyController);

            var playerControllers = new Dictionary <Army, MatchPlayerController>();

            foreach (Army a in _Context.Match.Armies)
            {
                // var controller = new AIMatchPlayerController(_Context.MakeMatchAdapter(), a);
                var overrideController = _Context.GetOverridePlayerController(a);
                playerControllers.Add(a, overrideController ?? controller);
            }
            _MatchController             = new MatchController(_Context.Match, playerControllers);
            screen.OnPulse              += HandlePulse;
            _Context.Match.OnMatchEnded += _MatchEndBuffer.Hook <EventArgs>(HandleMatchEnd).Invoke;
            _Context.Match.Start();

            return(screen);
        }
        public ScenarioSelectScreen(Vector2f WindowSize, IEnumerable <Scenario> Scenarios)
            : base(WindowSize)
        {
            _Renderer =
                new UnitConfigurationRenderer(
                    Scenarios.SelectMany(i => i.UnitConfigurations).Distinct(),
                    GameData.UnitRenderDetails,
                    128,
                    1024,
                    ClassLibrary.Instance.GetFont("compacta"));
            _FactionRenderer =
                new FactionRenderer(
                    Scenarios.SelectMany(i => i.ArmyConfigurations.Select(j => j.Faction)).Distinct(),
                    GameData.FactionRenderDetails,
                    512,
                    1024);
            foreach (Scenario s in Scenarios)
            {
                var option = new SelectionOption <Scenario>("scenario-selection-option")
                {
                    DisplayedString = s.Name,
                    Value           = s
                };
                _ScenarioSelect.Add(option);
            }
            _ScenarioSelect.OnChange += HandleSelect;
            _ScenarioView.Position    = new Vector2f(_ScenarioSelect.Size.X + 16, 0);

            _StartButton.OnClick += HandleStart;
            _StartButton.Position = new Vector2f(0, _Display.Size.Y - _StartButton.Size.Y - 32);

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

            _Display.Add(_ScenarioSelect);
            _Display.Add(_ScenarioView);
            _Display.Add(_StartButton);
            _Items.Add(_Display);
        }
Beispiel #10
0
 public ScenarioView(Scenario Scenario, UnitConfigurationRenderer UnitRenderer, FactionRenderer FactionRenderer)
     : this()
 {
     SetScenario(Scenario, UnitRenderer, FactionRenderer);
 }