Exemplo n.º 1
0
        public NewLevelBox(Location location, int startNumRows, int startNumColumns) : base(edgeThickness, null)
        {
            Dimensions = new WrapperDimensions(edgeThickness * 2 + padding, edgeThickness * 2 + padding, true, true);

            Location = CenteredLocation.All;

            edgeColor  = Utility.DrawingColorToXNAColor(DefaultUIValues.Default.BoxEdgeColor);
            innerColor = Utility.DrawingColorToXNAColor(DefaultUIValues.Default.BoxInnerColor);

            innerComponentsContainer = new UIComponent(CenteredLocation.All, WrapperDimensions.All);

            columnsEdit = new NumberInputBox(SimpleLocation.Zero, new CombinationDimensions(InheritDimensions.All, new MeasuredDimensions()), Strings.columns_edit_text, startNumColumns, 1, spritefont: DefaultUIValues.Default.DefaultEditorControlSpriteFont);
            rowsEdit    = new NumberInputBox(new RelativeToLocation(columnsEdit, 0, 10, true, false), new CombinationDimensions(InheritDimensions.All, new MeasuredDimensions(rowsEdit)), Strings.rows_edit_text, startNumRows, 1, spritefont: DefaultUIValues.Default.DefaultEditorControlSpriteFont);

            UIComponent centerSpanner = new UIComponent(new CombinationLocation(new CenteredLocation(horizontalCenter: true), new RelativeToLocation(rowsEdit, 0, 50, true, false)), WrapperDimensions.All);

            Button okButton = new SpriteSheetButton(SimpleLocation.Zero, null, Strings.begin, onClick: (UIComponent component) =>
            {
                Succes?.Invoke(this);
            });
            Button cancelButton = new SpriteSheetButton(new RelativeToLocation(okButton, 40, 0, false), null, Strings.cancel, onClick: (UIComponent component) =>
            {
                Visible = false;
            });

            centerSpanner.AddConstantComponent(okButton);
            centerSpanner.AddConstantComponent(cancelButton);

            innerComponentsContainer.AddConstantComponent(columnsEdit);
            innerComponentsContainer.AddConstantComponent(rowsEdit);
            innerComponentsContainer.AddConstantComponent(centerSpanner);

            AddConstantComponent(innerComponentsContainer);
        }
Exemplo n.º 2
0
        public TitleMenuState()
        {
            MenuContainer = new UIComponent(SimpleLocation.Zero, InheritDimensions.All);

            MenuContainer.AddChild(new Background(new SpriteSheet("mainMenuOverlay").Sprite));

            List <UIComponent> buttons = new List <UIComponent>();

            CombinationLocation buttonLocation = new CombinationLocation(new SharedLocation(buttons, -40, 0), new DirectionLocation(yOffset: 10, topToBottom: false));

            SpriteSheetButton begin = new SpriteSheetButton(buttonLocation, null, Strings.begin, (UIComponent o) =>
            {
                ((LoadMenuState)GameEnvironment.GameStateManager.GetGameState("LoadMenuState")).UpdateLevelExplorer();
                GameEnvironment.GameStateManager.SwitchTo("LoadMenuState");
            });

            SpriteSheetButton createLevel = new SpriteSheetButton(buttonLocation, null, Strings.map_editor, (UIComponent o) =>
            {
                GameEnvironment.GameStateManager.SwitchTo("LevelEditorState");
                //reset the gamestate to open blank;
                GameEnvironment.GameStateManager.CurrentGameState.Reset();
            });

            SpriteSheetButton settings = new SpriteSheetButton(buttonLocation, null, Strings.settings, (UIComponent o) =>
            {
                GameEnvironment.GameStateManager.PreviousGameState = GameEnvironment.GameStateManager.CurrentGameState.ToString();
                GameEnvironment.GameStateManager.SwitchTo("SettingsMenuState");
            });

            SpriteSheetButton quit = new SpriteSheetButton(buttonLocation, null, Strings.exit, (UIComponent o) =>
            {
                GameEnvironment.Instance.Exit();
            });

            buttons.Add(begin);
            buttons.Add(createLevel);
            buttons.Add(settings);
            buttons.Add(quit);


            //Level Editor button;
            MenuContainer.AddChild(begin);

            MenuContainer.AddChild(createLevel);

            MenuContainer.AddChild(settings);

            MenuContainer.AddChild(quit);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Fills the list of tiles
        /// </summary>
        private void FillTilesList()
        {
            //When we fill the list we want tiletypes to be empty
            tileTypeList = new List <TileType>();

            foreach (TileType tt in Enum.GetValues(typeof(TileType)))
            {
                tileTypeList.Add(tt);
                string[] tileBackgroundAndOverlays = Tile.GetAssetNamesFromTileType(tt);
                if (tileBackgroundAndOverlays != null)
                {
                    Button newButton = new SpriteSheetButton(new CenteredLocation(yOffset: BUTTON_DISTANCE_FROM_TOP, horizontalCenter: true), new SimpleDimensions(TILES_LIST_WIDTH - BUTTON_DISTANCE_FROM_TOP * 2 - 10, TILES_LIST_WIDTH - BUTTON_DISTANCE_FROM_TOP * 2 - 10), "", OnItemSelect, null, tileBackgroundAndOverlays, tiled: false);
                    tilesList.AddChild(newButton);
                }
            }
            ((Button)tilesList.Children[0]).Selected = true;
            PlayerMoved(level.Player);
        }