private UIElement CreateMainSceneShipStatusPanel() { // Status star bars {Power, Life, Speed} var powerStatusDecorator = CreateMainSceneShipStatusStars("power", powerStatusStar, 0); var controlStatusDecorator = CreateMainSceneShipStatusStars("control", controlStatusStar, 1); var speedStatusDecorator = CreateMainSceneShipStatusStars("speed", speedStatusStar, 2); PowerStatus = shipList[activeShipIndex].Power; ControlStatus = shipList[activeShipIndex].Control; SpeedStatus = shipList[activeShipIndex].Speed; // Put the stats (Stars) in 3x1 uniform grid var statusPanel = new UniformGrid { Rows = 3 }; statusPanel.Children.Add(powerStatusDecorator); statusPanel.Children.Add(controlStatusDecorator); statusPanel.Children.Add(speedStatusDecorator); statusPanel.SetGridColumn(1); // SpaceShip Button currentShipImage = new ImageElement { Source = SpriteFromSheet.Create(MainSceneImages, shipList[activeShipIndex].Name) }; currentShipImage.SetGridRow(1); var shipImageSpacerGrid = new Grid { HorizontalAlignment = HorizontalAlignment.Center }; shipImageSpacerGrid.Children.Add(currentShipImage); shipImageSpacerGrid.RowDefinitions.Add(new StripDefinition(StripType.Star, 2)); shipImageSpacerGrid.RowDefinitions.Add(new StripDefinition(StripType.Star, 6)); shipImageSpacerGrid.RowDefinitions.Add(new StripDefinition(StripType.Star, 2)); shipImageSpacerGrid.ColumnDefinitions.Add(new StripDefinition()); shipImageSpacerGrid.LayerDefinitions.Add(new StripDefinition()); var shipButtonDesign = SpriteFromSheet.Create(MainSceneImages, "display_element"); var currentShipButton = new Button { NotPressedImage = shipButtonDesign, PressedImage = shipButtonDesign, MouseOverImage = shipButtonDesign, Content = shipImageSpacerGrid, Padding = new Thickness(45, 20, 10, 25), VerticalAlignment = VerticalAlignment.Center }; currentShipButton.Click += delegate { // Once click, update the SpaceShip status pop-up and show it. UpdateShipStatus(); ShowShipSelectionPopup(); }; currentShipButton.SetGridColumn(3); // Status upgrade buttons var powerUpgradeButton = CreateIncreaseStatusButton("P", 0, 0, 2, 0, () => PowerStatus, () => PowerStatus++); var controlUpgradeButton = CreateIncreaseStatusButton("C", 0, 1, 2, 0, () => ControlStatus, () => ControlStatus++); var speedUpgradeButton = CreateIncreaseStatusButton("S", 1, 0, 2, 0, () => SpeedStatus, () => SpeedStatus++); var lifeUpgradeButton = CreateIncreaseStatusButton("L", 1, 1, 1, 1, () => 0, () => LifeStatus++); // Arrange the status up buttons in a 2x2 Uniform grid. var statusUpgradeGridPanel = new UniformGrid { Rows = 2, Columns = 2, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center }; statusUpgradeGridPanel.Children.Add(powerUpgradeButton); statusUpgradeGridPanel.Children.Add(controlUpgradeButton); statusUpgradeGridPanel.Children.Add(speedUpgradeButton); statusUpgradeGridPanel.Children.Add(lifeUpgradeButton); statusUpgradeGridPanel.SetGridColumn(5); // Put together bottom region in horizontal Stack panel, arranging it from left to right var mainPanel = new Grid(); mainPanel.RowDefinitions.Add(new StripDefinition()); mainPanel.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, 10)); // space mainPanel.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 4)); mainPanel.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, 25)); // space mainPanel.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 4)); mainPanel.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, 25)); // space mainPanel.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 3)); mainPanel.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, 10)); // space mainPanel.LayerDefinitions.Add(new StripDefinition()); mainPanel.Children.Add(statusPanel); mainPanel.Children.Add(currentShipButton); mainPanel.Children.Add(statusUpgradeGridPanel); return(mainPanel); }
private UIElement CreateMainSceneShipStatusPanel() { // Status star bars {Power, Life, Speed} var powerStatusDecorator = CreateMainSceneShipStatusStars("power", powerStatusStar, 0); var controlStatusDecorator = CreateMainSceneShipStatusStars("control", controlStatusStar, 1); var speedStatusDecorator = CreateMainSceneShipStatusStars("speed", speedStatusStar, 2); PowerStatus = shipList[activeShipIndex].Power; ControlStatus = shipList[activeShipIndex].Control; SpeedStatus = shipList[activeShipIndex].Speed; // Put the stats (Stars) in 3x1 uniform grid var statusPanel = new UniformGrid { Rows = 3 }; statusPanel.Children.Add(powerStatusDecorator); statusPanel.Children.Add(controlStatusDecorator); statusPanel.Children.Add(speedStatusDecorator); statusPanel.SetGridColumn(1); // SpaceShip Button currentShipImage = new ImageElement { Source = mainScreneImages[shipList[activeShipIndex].Name], }; currentShipImage.SetGridRow(1); var shipImageSpacerGrid = new Grid { HorizontalAlignment = HorizontalAlignment.Center }; shipImageSpacerGrid.Children.Add(currentShipImage); shipImageSpacerGrid.RowDefinitions.Add(new StripDefinition(StripType.Star, 2)); shipImageSpacerGrid.RowDefinitions.Add(new StripDefinition(StripType.Star, 6)); shipImageSpacerGrid.RowDefinitions.Add(new StripDefinition(StripType.Star, 2)); shipImageSpacerGrid.ColumnDefinitions.Add(new StripDefinition()); shipImageSpacerGrid.LayerDefinitions.Add(new StripDefinition()); var shipButtonDesign = mainScreneImages["display_element"]; var currentShipButton = new Button { NotPressedImage = shipButtonDesign, PressedImage = shipButtonDesign, MouseOverImage = shipButtonDesign, Content = shipImageSpacerGrid, Padding = new Thickness(45, 20, 10, 25), VerticalAlignment = VerticalAlignment.Center }; currentShipButton.Click += delegate { // Once click, update the SpaceShip status pop-up and show it. UpdateShipStatus(); ShowShipSelectionPopup(); }; currentShipButton.SetGridColumn(3); // Status upgrade buttons var powerUpgradeButton = CreateIncreaseStatusButton("P", 0, 0, 2, 0, () => PowerStatus, () => PowerStatus++); var controlUpgradeButton = CreateIncreaseStatusButton("C", 0, 1, 2, 0, () => ControlStatus, () => ControlStatus++); var speedUpgradeButton = CreateIncreaseStatusButton("S", 1, 0, 2, 0, () => SpeedStatus, () => SpeedStatus++); var lifeUpgradeButton = CreateIncreaseStatusButton("L", 1, 1, 1, 1, () => 0, () => LifeStatus++); // Arrange the status up buttons in a 2x2 Uniform grid. var statusUpgradeGridPanel = new UniformGrid { Rows = 2, Columns = 2, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center }; statusUpgradeGridPanel.Children.Add(powerUpgradeButton); statusUpgradeGridPanel.Children.Add(controlUpgradeButton); statusUpgradeGridPanel.Children.Add(speedUpgradeButton); statusUpgradeGridPanel.Children.Add(lifeUpgradeButton); statusUpgradeGridPanel.SetGridColumn(5); // Put together bottom region in horizontal Stack panel, arranging it from left to right var mainPanel = new Grid(); mainPanel.RowDefinitions.Add(new StripDefinition()); mainPanel.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, 10)); // space mainPanel.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 4)); mainPanel.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, 25)); // space mainPanel.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 4)); mainPanel.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, 25)); // space mainPanel.ColumnDefinitions.Add(new StripDefinition(StripType.Star, 3)); mainPanel.ColumnDefinitions.Add(new StripDefinition(StripType.Fixed, 10)); // space mainPanel.LayerDefinitions.Add(new StripDefinition()); mainPanel.Children.Add(statusPanel); mainPanel.Children.Add(currentShipButton); mainPanel.Children.Add(statusUpgradeGridPanel); return mainPanel; }
private UniformGrid CreateShipButtonElement(SpaceShip spaceShip) { // Put the stat text block in a vertical uniform grid var statusTextGrid = new UniformGrid { Rows = 3, Margin = new Thickness(5f, -6f, 0, 0) }; statusTextGrid.Children.Add(CreateShipStatusTextBlock("Power", 0)); statusTextGrid.Children.Add(CreateShipStatusTextBlock("Control", 1)); statusTextGrid.Children.Add(CreateShipStatusTextBlock("Speed", 2)); // Put the stat stars in a vertical uniform grid spaceShip.PowerImageElement = CreateShipStatusStar(0); spaceShip.ControlImageElement = CreateShipStatusStar(1); spaceShip.SpeedImageElement = CreateShipStatusStar(2); var starGrid = new UniformGrid { Rows = 3 }; starGrid.Children.Add(spaceShip.PowerImageElement); starGrid.Children.Add(spaceShip.ControlImageElement); starGrid.Children.Add(spaceShip.SpeedImageElement); starGrid.SetGridColumn(2); // Ship image var shipSprite = SpriteFromSheet.Create(MainSceneImages, spaceShip.Name); var shipImageElement = new ImageElement { Source = shipSprite }; shipImageElement.SetGridColumn(4); // Create the horizontal grid with two blank stretchable columns and add the text blocks, the starts and the ship image var shipContent = new Grid(); shipContent.ColumnDefinitions.Add(new StripDefinition(StripType.Auto)); shipContent.ColumnDefinitions.Add(new StripDefinition(StripType.Star)); shipContent.ColumnDefinitions.Add(new StripDefinition(StripType.Auto)); shipContent.ColumnDefinitions.Add(new StripDefinition(StripType.Star)); shipContent.ColumnDefinitions.Add(new StripDefinition(StripType.Auto)); shipContent.RowDefinitions.Add(new StripDefinition()); shipContent.LayerDefinitions.Add(new StripDefinition()); shipContent.Children.Add(statusTextGrid); shipContent.Children.Add(starGrid); shipContent.Children.Add(shipImageElement); // var shipSelectFrameSprite = SpriteFromSheet.Create(MainSceneImages, "weapon_select_frame"); var shipButton = new Button { Name = spaceShip.Name, Content = shipContent, PressedImage = shipSelectFrameSprite, NotPressedImage = shipSelectFrameSprite, MouseOverImage = shipSelectFrameSprite, Padding = new Thickness(60, 20, 20, 20) }; shipButton.Click += delegate { currentShipImage.Source = shipSprite; activeShipIndex = shipList.FindIndex(w => w.Name == spaceShip.Name); PowerStatus = spaceShip.Power; ControlStatus = spaceShip.Control; SpeedStatus = spaceShip.Speed; CloseShipSelectPopup(); }; shipButton.IsEnabled = !spaceShip.IsLocked; shipButton.SetCanvasRelativeSize(new Vector3(1f, 1f, 1f)); var buttonGrid = new UniformGrid { MaximumHeight = 100 }; buttonGrid.Children.Add(shipButton); if (spaceShip.IsLocked) { var lockIconElement = new ImageElement { Source = SpriteFromSheet.Create(MainSceneImages, "lock_icon"), StretchType = StretchType.Fill, }; lockIconElement.SetPanelZIndex(1); buttonGrid.Children.Add(lockIconElement); } return(buttonGrid); }
private UniformGrid CreateShipButtonElement(SpaceShip spaceShip) { // Put the stat text block in a vertical uniform grid var statusTextGrid = new UniformGrid { Rows = 3, Margin = new Thickness(5f, -6f, 0, 0)}; statusTextGrid.Children.Add(CreateShipStatusTextBlock("Power", 0)); statusTextGrid.Children.Add(CreateShipStatusTextBlock("Control", 1)); statusTextGrid.Children.Add(CreateShipStatusTextBlock("Speed", 2)); // Put the stat stars in a vertical uniform grid spaceShip.PowerImageElement = CreateShipStatusStar(0); spaceShip.ControlImageElement = CreateShipStatusStar(1); spaceShip.SpeedImageElement = CreateShipStatusStar(2); var starGrid = new UniformGrid { Rows = 3 }; starGrid.Children.Add(spaceShip.PowerImageElement); starGrid.Children.Add(spaceShip.ControlImageElement); starGrid.Children.Add(spaceShip.SpeedImageElement); starGrid.SetGridColumn(2); // Ship image var shipSprite = mainScreneImages[spaceShip.Name]; var shipImageElement = new ImageElement { Source = shipSprite }; shipImageElement.SetGridColumn(4); // Create the horizontal grid with two blank stretchable columns and add the text blocks, the starts and the ship image var shipContent = new Grid(); shipContent.ColumnDefinitions.Add(new StripDefinition(StripType.Auto)); shipContent.ColumnDefinitions.Add(new StripDefinition(StripType.Star)); shipContent.ColumnDefinitions.Add(new StripDefinition(StripType.Auto)); shipContent.ColumnDefinitions.Add(new StripDefinition(StripType.Star)); shipContent.ColumnDefinitions.Add(new StripDefinition(StripType.Auto)); shipContent.RowDefinitions.Add(new StripDefinition()); shipContent.LayerDefinitions.Add(new StripDefinition()); shipContent.Children.Add(statusTextGrid); shipContent.Children.Add(starGrid); shipContent.Children.Add(shipImageElement); // var shipSelectFrameSprite = mainScreneImages["weapon_select_frame"]; var shipButton = new Button { Name = spaceShip.Name, Content = shipContent, PressedImage = shipSelectFrameSprite, NotPressedImage = shipSelectFrameSprite, MouseOverImage = shipSelectFrameSprite, Padding = new Thickness(60, 20, 20, 20) }; shipButton.Click += delegate { currentShipImage.Source = shipSprite; activeShipIndex = shipList.FindIndex(w => w.Name == spaceShip.Name); PowerStatus = spaceShip.Power; ControlStatus = spaceShip.Control; SpeedStatus = spaceShip.Speed; CloseShipSelectPopup(); }; shipButton.IsEnabled = !spaceShip.IsLocked; shipButton.SetCanvasRelativeSize(new Vector3(1f, 1f, 1f)); var buttonGrid = new UniformGrid { MaximumHeight = 100 }; buttonGrid.Children.Add(shipButton); if (spaceShip.IsLocked) { var lockIconImage = mainScreneImages["lock_icon"]; var lockIconElement = new ImageElement { Source = lockIconImage, StretchType = StretchType.Fill, }; lockIconElement.SetPanelZIndex(1); buttonGrid.Children.Add(lockIconElement); } return buttonGrid; }