Button decorate class
Inheritance: UIBase
Example #1
0
        protected override void CreateScene()
        {
            RenderManager.BackgroundColor = Color.Black;

            Entity background = new Entity()
                        .AddComponent(new Sprite("Content/mainScene.wpk"))
                        .AddComponent(new SpriteRenderer(DefaultLayers.Alpha))
                        .AddComponent(new Transform2D()
                        {
                            DrawOrder = 1
                        })
                        .AddComponent(new StretchBehavior());
            EntityManager.Add(background);

            Button button = new Button()
            {
                Text = string.Empty,
                IsBorder = false,
                Width = 600,
                Height = 200,
                BackgroundImage = "Content/button.wpk",
                PressedBackgroundImage = "Content/buttonPressed.wpk",
                Margin = new WaveEngine.Framework.UI.Thickness(76,800,0,0)
            };
            button.Click += (s, o) =>
            {
                WaveServices.ScreenContextManager.To(new ScreenContext(new MyScene()), new SpinningSquaresTransition(TimeSpan.FromSeconds(2.0f)));
            };
            EntityManager.Add(button);
        }
Example #2
0
        protected override void CreateScene()
        {
            RenderManager.BackgroundColor = Color.Black;

            // Adds record button.
            this.recordButton = new Button("recordButton")
            {
                Text = STARTTEXT,
                Margin = new WaveEngine.Framework.UI.Thickness(100),
                HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Left,
                VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Top
            };

            this.recordButton.Click += OnRecordButtonClicked;
            this.EntityManager.Add(this.recordButton);

            // Adds play button
            this.playButton = new Button("playButton")
            {
                Text = PLAYTEXT,
                Margin = new WaveEngine.Framework.UI.Thickness(100),
                HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Right,
                VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Top,
                IsVisible = false
            };
            this.playButton.Click += OnPlayButtonClicked;
            this.EntityManager.Add(this.playButton);

            // Shows error label if microphone is not available
            if (!WaveServices.Microphone.IsConnected)
            {
                TextBlock errorText = new TextBlock()
                {
                    Text = ERROREXT,
                    HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center,
                    VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Bottom,
                    Margin = new WaveEngine.Framework.UI.Thickness(50)
                };

                this.EntityManager.Add(errorText);
            }

            this.progressBar = new ProgressBar()
            {
                Maximum = 255,
                Minimum = 0,
                Value = 0,
                Width = 400,
                Height = 10,
                VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Center,
                HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center,
                IsVisible = false
            };

            this.EntityManager.Add(this.progressBar);

            //Register bank
            this.bank = new SoundBank(this.Assets);
            WaveServices.SoundPlayer.RegisterSoundBank(this.bank);
        }
Example #3
0
        private void CreateUI()
        {
            Button changeCameraBtn = new Button()
            {
                Text = "Change Camera",
                HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Left,
                VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Top,
                Margin = new WaveEngine.Framework.UI.Thickness(20),
                Width = 160,
                Height = 60
            };

            changeCameraBtn.Click += changeCameraBtn_Click;

            EntityManager.Add(changeCameraBtn);

            this.textBlock = new TextBlock()
            {
                Text = "",
                VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Top,
                HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Left,
                Margin = new WaveEngine.Framework.UI.Thickness(20, 100,0,0)
            };

            EntityManager.Add(this.textBlock);
        }
Example #4
0
        private void CreateUI()
        {
            var button = new Button()
            {
                Margin = new Thickness(0, 0, 0, 0
                ),
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                Text = string.Empty,
                IsBorder = false,
                BackgroundImage = WaveContent.Assets.PressStart_PNG,
                PressedBackgroundImage = WaveContent.Assets.PressStart_PNG
            };

            button.Entity.AddComponent(new AnimationUI());
            button.Entity.AddComponent(new OpacityApperComponent
            {
                From = 0.2f,
                DurationSeconds = 2
            });

            button.Click += this.OnStartButtonClicked;

            this.EntityManager.Add(button);
        }
Example #5
0
        protected override void CreateScene()
        {
            RenderManager.BackgroundColor = Color.FloralWhite;

            Button startGameButton = new Button()
            {
                HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center,
                VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Center,
                Text = string.Empty,
                IsBorder = false,
                BackgroundImage = Textures.PLAY_BUTTON,
                PressedBackgroundImage = Textures.PLAY_BUTTON_PRESSED
            };
            startGameButton.Click += (o, e) =>
            {
                TimeSpan timeSpan = new TimeSpan(0, 0, 0, 1, 500);
                CurtainsTransition transition = new CurtainsTransition(timeSpan);
                ScreenContext gameContext = new ScreenContext("GameScene", new GameScene())
                {
                    Behavior = ScreenContextBehaviors.DrawInBackground //Hacemos que se renderize cuando esté apilado en background (Paused)
                };
                WaveServices.ScreenContextManager.Push(gameContext, transition);
            };

            EntityManager.Add(startGameButton);
        }
        public ButtonOption(string option, Action action)
        {
            this.grid = new Grid();

            grid.HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center;
            grid.VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Center;
            grid.Width = 475;
            grid.Height = 139;

            grid.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Proportional) });

            grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Auto) });
            grid.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Proportional) });

            Button b_option = new Button()
            {
                Text = string.Empty,
                IsBorder = false,
                BackgroundImage = Directories.Textures + option + "_bt.png.wpk",
                PressedBackgroundImage = Directories.Textures + option + "_bt_pressed.png.wpk",
                VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Center,
                HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center,
            };
            b_option.Click += (s, o) => action();
            b_option.SetValue(GridControl.RowProperty, 0);
            b_option.SetValue(GridControl.ColumnProperty, 0);
            grid.Add(b_option);
           
            TextBlock t_option = new TextBlock()
            {
                Width = 322, 
                Height = 65,
                FontPath = WaveContent.Assets.Fonts.Gotham_Bold_16_ttf,
                Text = option.ToUpper(),
                VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Center,
                HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center,
                DrawOrder = 0.4f,
                Margin = new WaveEngine.Framework.UI.Thickness(0, 13, 0,0)
            };
            t_option.SetValue(GridControl.RowProperty, 0);
            t_option.SetValue(GridControl.ColumnProperty, 1);
            grid.Add(t_option);

            Image bg_option = new Image(WaveContent.Assets.Textures.bg_options_pause_PNG)
            {
                VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Center,
                HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center,
                Margin = new WaveEngine.Framework.UI.Thickness(-45,0,0,0),
                DrawOrder = 0.9f,
            };
            bg_option.SetValue(GridControl.RowProperty, 0);
            bg_option.SetValue(GridControl.ColumnProperty, 1);
            grid.Add(bg_option);

            this.entity = grid.Entity;
        }
Example #7
0
        protected override void CreateScene()
        {
            FixedCamera2D camera2d = new FixedCamera2D("camera")
            {
                BackgroundColor = Color.Black,
                ClearFlags = ClearFlags.DepthAndStencil,
            };
            camera2d.BackgroundColor = Color.Black;
            EntityManager.Add(camera2d);

            Entity logo = new Entity()
            .AddComponent(new Transform2D() { X = WaveServices.ViewportManager.VirtualWidth / 2, Y = 227, Origin = Vector2.Center, DrawOrder = 0.1f })
            .AddComponent(new Sprite("Content/DeepSpace_logo.wpk"))
            .AddComponent(new AnimationUI())
            .AddComponent(new SpriteRenderer(DefaultLayers.Alpha));

            this.labelAnimation = logo.FindComponent<AnimationUI>();

            this.EntityManager.Add(logo);
           
            var button = new Button()
            {
                Margin = new Thickness(0, 657, 0, 0),
                HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center,
                VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Top,
                Text = string.Empty,
                IsBorder = false,
                BackgroundImage = "Content/PressStart.wpk",
                PressedBackgroundImage = "Content/PressStart.wpk"

            };

            button.Click += (o, e) =>
            {
                var gameScene = WaveServices.ScreenContextManager.FindContextByName("GamePlayContext").FindScene<GamePlayScene>();

                gameScene.State = GameState.Game;

                WaveServices.ScreenContextManager.Pop(new CrossFadeTransition(TimeSpan.FromSeconds(0.5f)));
                ////WaveServices.ScreenContextManager.Push(gameContext, new CrossFadeTransition(TimeSpan.FromSeconds(1.5f)));
            };

            button.Entity.AddComponent(new AnimationUI());
            this.playAnimation = button.Entity.FindComponent<AnimationUI>();

            this.EntityManager.Add(button);


            this.playScaleAppear = new SingleAnimation(0.2f, 1f, TimeSpan.FromSeconds(2), EasingFunctions.Back);
            this.playOpacityAppear = new SingleAnimation(0, 1, TimeSpan.FromSeconds(1), EasingFunctions.Cubic);
        }
Example #8
0
        protected override void CreateScene()
        {
            FixedCamera2D camera2d = new FixedCamera2D("camera");
            camera2d.BackgroundColor = Color.Gray;
            EntityManager.Add(camera2d);

            // Panel
            stackPanel = new StackPanel()
            {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                Width = 400,
                Height = 400,
            };
            EntityManager.Add(stackPanel.Entity);

            // Elements
            Button button;
            for (int i = 0; i < 4; i++)
            {
                button = new Button()
                {
                    Text = i.ToString(),
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment = VerticalAlignment.Center,
                    Width = 100,
                    Height = 100,
                    Foreground = Color.Yellow,
                    BackgroundColor = Color.Red,
                };
                stackPanel.Add(button);
            }

            // Set Orientation
            Button button1 = new Button()
            {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Bottom,
                Text = "Change Orientation",
                Width = 200,
                Margin = new Thickness(20),
                Foreground = Color.LightPink,
                BackgroundColor = Color.Purple,
                BorderColor = Color.LightPink,
            };
            button1.Click += b_Click;
            EntityManager.Add(button1.Entity);

            // Debug
            this.CreateDebugMode();
        }
        private void CreateUI()
        {
            // Play Button
            Button play = new Button("Play")
            {
                Text = string.Empty,
                IsBorder = false,
                BackgroundImage = WaveContent.Assets.Textures.play_png,
                PressedBackgroundImage = WaveContent.Assets.Textures.playPressed_png,
                Margin = new Thickness(244, 580, 0, 0),
            };

            play.Click += (s, o) =>
            {

                var gameContext = new ScreenContext("GamePlay", new GamePlayScene())
                {
                    Behavior = ScreenContextBehaviors.DrawInBackground
                };

                WaveServices.ScreenContextManager.Pop();
                WaveServices.ScreenContextManager.Push(gameContext, new CrossFadeTransition(TimeSpan.FromSeconds(1.5f)));
            };

            play.Entity.FindChild("ImageEntity").FindComponent<Transform2D>().Origin = Vector2.Center;
            play.Entity.AddComponent(new AnimationUI());
            EntityManager.Add(play);

            // Best Scores
            TextBlock bestScores = new TextBlock("BestScores")
            {
                FontPath = WaveContent.Assets.Fonts.Bulky_Pixels_16_TTF,
                Text = "your best score:",
                Foreground = new Color(223 / 255f, 244 / 255f, 255 / 255f),
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Bottom,
                Margin = new Thickness(161, 0, 0, 30),
            };
            EntityManager.Add(bestScores);

            // Scores
            TextBlock scores = new TextBlock()
            {
                FontPath = WaveContent.Assets.Fonts.Bulky_Pixels_26_TTF,
                Text = this.gameStorage.BestScore.ToString(),
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Bottom,
                Margin = new Thickness(440, 0, 0, 40),
            };
            EntityManager.Add(scores);
        }
Example #10
0
        protected override void CreateScene()
        {
            RenderManager.BackgroundColor = Color.Gray;

            // Panel
            wrapPanel = new WrapPanel()
            {
                Width = 400,
                Height = 220,
                Orientation = Orientation.Horizontal,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
            };
            EntityManager.Add(wrapPanel.Entity);

            // Elements
            Button button;
            for (int i = 0; i < 5; i++)
            {
                button = new Button()
                {
                    Text = i.ToString(),
                    Width = 100,
                    Height = 100,
                    Foreground = Color.Yellow,
                    BackgroundColor = Color.Red,
                };
                wrapPanel.Add(button);
            }

            // Set Orientation
            Button button1 = new Button()
            {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Bottom,
                Text = "Change Orientation",
                Width = 200,
                Margin = new Thickness(20),
                Foreground = Color.LightPink,
                BackgroundColor = Color.Purple,
                BorderColor = Color.LightPink,
            };
            button1.Click += b_Click;
            EntityManager.Add(button1.Entity);

            // Debug
            this.CreateDebugMode();
        }
Example #11
0
        protected override void CreateScene()
        {
            RenderManager.BackgroundColor = Color.Gray;

            // Panel
            gridPanel = new Grid()
            {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                Width = 400,
                Height = 400,
            };
            EntityManager.Add(gridPanel.Entity);

            gridPanel.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Proportional) });
            gridPanel.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Proportional) });
            gridPanel.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Proportional) });

            gridPanel.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Proportional) });
            gridPanel.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Proportional) });

            // Elements
            Button button;
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    button = new Button()
                    {
                        Text = "[" + i + "," + j + "]",
                        HorizontalAlignment = HorizontalAlignment.Center,
                        VerticalAlignment = VerticalAlignment.Center,
                        Width = 100,
                        Height = 100,
                        Foreground = Color.Yellow,
                        BackgroundColor = Color.Red,
                    };
                    button.SetValue(GridControl.RowProperty, i);
                    button.SetValue(GridControl.ColumnProperty, j);
                    gridPanel.Add(button);
                }
            }

            // Debug
            this.CreateDebugMode();
        }
        protected override void CreateScene()
        {
            RenderManager.BackgroundColor = Color.Black;
            /*Entity title = new Entity("Title")
                   .AddComponent(new Sprite("Content/TitlePong.wpk"))
                   .AddComponent(new SpriteRenderer(DefaultLayers.Alpha))
                   .AddComponent(new Transform2D()
                   {
                       Y = WaveServices.Platform.ScreenHeight / 2,
                       X = WaveServices.Platform.ScreenWidth / 2
                   });

            EntityManager.Add(title);*/
            TextBlock scoreEnd = new TextBlock("scoreEndTextBlock")
            {
                Text = "Score\n" + this.score.ToString(),
                VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Top,
                HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center,
                DrawOrder = 3f,
            };

            EntityManager.Add(scoreEnd);

            Button button = new Button()
                {
                    Text = "Restart?",
                    IsBorder = false,
                    Width = 700,
                    Height = 500,
                    HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Right,
                    VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Center,
                    //BackgroundImage = "Content/button.wpk",
                    //PressedBackgroundImage = "Content/buttonPressed.wpk",
                    Margin = new WaveEngine.Framework.UI.Thickness(100, 400, 0, 0)
                };
            button.Click += (s, o) =>
            {
                WaveServices.ScreenContextManager.To(new ScreenContext(new MyScene()), new SpinningSquaresTransition(TimeSpan.FromSeconds(2.0f)));
            };
            EntityManager.Add(button);
        }
Example #13
0
        private void CreateUI()
        {
            // Play Button
            Button play = new Button("Play")
            {
                Text = string.Empty,
                IsBorder = false,
                BackgroundImage = WaveContent.Assets.Textures.play_png,
                PressedBackgroundImage = WaveContent.Assets.Textures.playPressed_png,
                Margin = new Thickness(244, 580, 0, 0),
            };

            play.Click += this.Play_Click;

            play.Entity.FindChild("ImageEntity").FindComponent<Transform2D>().Origin = Vector2.Center;
            play.Entity.AddComponent(new AnimationUI());
            EntityManager.Add(play);

            // Best Scores
            TextBlock bestScores = new TextBlock("BestScores")
            {
                FontPath = WaveContent.Assets.Fonts.Bulky_Pixels_16_TTF,
                Text = "your best score:",
                Foreground = new Color(223 / 255f, 244 / 255f, 255 / 255f),
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Bottom,
                Margin = new Thickness(161, 0, 0, 30),
            };
            EntityManager.Add(bestScores);

            // Scores
            TextBlock scores = new TextBlock()
            {
                FontPath = WaveContent.Assets.Fonts.Bulky_Pixels_26_TTF,
                Text = this.gameStorage.BestScore.ToString(),
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Bottom,
                Margin = new Thickness(440, 0, 0, 40),
            };
            EntityManager.Add(scores);
        }
Example #14
0
        protected override void CreateScene()
        {
            this.Load(WaveContent.Scenes.GameOverScene);

            var button = new Button()
            {
                Margin = new Thickness(0, 0, 0, 0),
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                Text = string.Empty,
                IsBorder = false,
                BackgroundImage = WaveContent.Assets.restart_png,
                PressedBackgroundImage = WaveContent.Assets.restart_png
            };

            button.Entity.AddComponent(new AnimationUI());
            button.Entity.AddComponent(new OpacityApperComponent
            {
                From = 0.2f,
                DurationSeconds = 2
            });

            button.Click += this.OnResetButtonClicked;

            this.EntityManager.Add(button);

            var gameStorage = Catalog.GetItem<GameStorage>();
            this.scoreText = new TextBlock()
            {
                Text = gameStorage.BestScore.ToString(),
                FontPath = WaveContent.Fonts.Space_Age_TTF,
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment = VerticalAlignment.Bottom,
                Margin = new Thickness(0, 0, -10, 26),
                Foreground = new Color(117, 243, 237, 255)
            };

            this.EntityManager.Add(scoreText);
        }
        private void CreateUI()
        {
            // Restart Button
            Button restart = new Button("RestartButton")
            {
                Text = string.Empty,
                IsBorder = false,
                BackgroundImage = WaveContent.Assets.Textures.restartRelease_png,
                PressedBackgroundImage = WaveContent.Assets.Textures.restartPressed_png,
                Margin = new Thickness(10, WaveServices.ViewportManager.BottomEdge - 120, 0, 0)
            };
            EntityManager.Add(restart);

            // Score Panel            
            var scorePanel = new ScorePanel("ScorePanel")
            {
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment = VerticalAlignment.Top,
            };

            EntityManager.Add(scorePanel);
        }
 private void CreateUI()
 {
     titleText = new TextBlock()
     {
         Text = "Pongify",
         VerticalAlignment = VerticalAlignment.Center,
         HorizontalAlignment = HorizontalAlignment.Center,
         Margin = new Thickness(15, 0, 0, 60)
     };
     startButton = new Button()
     {
         Text = "Start",
         VerticalAlignment = VerticalAlignment.Center,
         HorizontalAlignment = HorizontalAlignment.Center,
         Margin = new Thickness(0, 90, 0, 0)
     };
     startButton.Click += (s, o) =>
     {
         toMainMenu();
     };
     EntityManager.Add(titleText);
     EntityManager.Add(startButton);
 }
        private void CreateUi()
        {
            var serverButton = new Button
            {
                Text = "Create Server",
                Width = 200,
                Height = 50,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Top,
                Margin = new Thickness(10)
            };
            serverButton.Click += this.OnCreateServerClicked;
            this.EntityManager.Add(serverButton);

            var discoveryButton = new Button
            {
                Text = "Find Servers",
                Width = 200,
                Height = 50,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Top,
                Margin = new Thickness(10, 10 + 70, 10, 10)
            };
            discoveryButton.Click += this.OnDiscoverHostsClicked;
            this.EntityManager.Add(discoveryButton);

            this.errorMessage = new TextBlock
            {
                Width = 600,
                Height = 50,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Bottom,
                Margin = new Thickness(10, 0, 10, 10),
                IsVisible = false
            };
            this.EntityManager.Add(this.errorMessage);
        }
Example #18
0
        private void CreateLeaderBoardByCodePanel()
        {
            var leaderboardlabel = new TextBlock()
            {
                Text = "Enter leaderboard code:",
                Width = 200,
            };
            var leaderboardCodeText = new TextBox()
            {
                Text = string.Empty,
                Height = 60,
                Width = _buttonWidth,
                Margin = new Thickness(_spaceControl, 0, 0, 0)
            };

            // Show leaderboard by code
            var leaderboardCodeButton = new Button()
            {
                Width = _buttonWidth,
                Height = _buttonHeight,
                Text = "Show leaderboard by code",
                Foreground = _foregroundButton,
                BackgroundColor = _backgroundColor,
                Margin = new Thickness(_spaceControl, 0, 0, 0)
            };
            leaderboardCodeButton.Click += (s, e) =>
            {
                var code = leaderboardCodeText.Text;
                _socialService.ShowLeaderboard(code);
            };

            var sp4 = new StackPanel
            {
                Orientation = Orientation.Horizontal,
                Margin = new Thickness(100, _topMargin + 5, 0, 0),
            };
            sp4.Add(leaderboardlabel);
            sp4.Add(leaderboardCodeText);
            sp4.Add(leaderboardCodeButton);

            EntityManager.Add(sp4);
        }
Example #19
0
        private void AddNewScorePanel()
        {
            var addNewScorelabel1 = new TextBlock()
            {
                Text = "Enter leaderboard code:",
                Width = 200,
            };
            var addNewScoreCodeText1 = new TextBox()
            {
                Text = string.Empty,
                Height = 60,
                Width = _buttonWidth,
                Margin = new Thickness(_spaceControl, 0, 0, 0)
            };

            var addNewScorelabel2 = new TextBlock()
            {
                Text = "Enter new score:",
                Width = 200,
            };
            var addNewScoreCodeText2 = new TextBox()
            {
                Text = string.Empty,
                Height = 60,
                Width = _buttonWidth,
                Margin = new Thickness(_spaceControl, 0, 0, 0)
            };

            var sp5 = new StackPanel
            {
                Orientation = Orientation.Horizontal,
                Margin = new Thickness(100, _topMargin + 5, 0, 0),
            };
            sp5.Add(addNewScorelabel1);
            sp5.Add(addNewScoreCodeText1);

            _topMargin += 70;

            var sp6 = new StackPanel
            {
                Orientation = Orientation.Horizontal,
                Margin = new Thickness(100, _topMargin + 5, 0, 0),
            };
            sp6.Add(addNewScorelabel2);
            sp6.Add(addNewScoreCodeText2);

            EntityManager.Add(sp5);
            EntityManager.Add(sp6);

            // Add new score
            var addNewScoreCodeButton = new Button()
            {
                Width = _buttonWidth,
                Height = _buttonHeight,
                Text = "Add new Score",
                Foreground = _foregroundButton,
                BackgroundColor = _backgroundColor,
                Margin = new Thickness(_topMargin + _spaceControl + 15, 580, 0, 0)
            };
            addNewScoreCodeButton.Click += (s, e) =>
            {
                var code = addNewScoreCodeText1.Text;
                var score = addNewScoreCodeText2.Text;

                if (string.IsNullOrEmpty(code) || string.IsNullOrEmpty(score))
                {
                    return;
                }

                var longScore = long.Parse(score);

                _socialService.AddNewScore(code, longScore);
            };

            EntityManager.Add(addNewScoreCodeButton);
        }
Example #20
0
        protected override void CreateScene()
        {
            RenderManager.BackgroundColor = Color.Gray;
            //RenderManager.DebugLines = true;

            // Slider 1
            int slider1Top = 60;
            slider1 = new Slider()
            {
                Margin = new Thickness(20, slider1Top, 0, 0),
                Width = 360,
                Value = 50,
            };
            EntityManager.Add(slider1.Entity);

            // Slider 2
            int slider2Top = 130;
            slider2 = new Slider()
            {
                Margin = new Thickness(20, slider2Top, 0, 0),
                Width = 360,
                Minimum = -20,
                Maximum = 500,
                Value = 10,
                Foreground = Color.Purple,
                Background = Color.LightPink,
                TextColor = Color.Purple,
            };
            EntityManager.Add(slider2.Entity);

            // Slider 3
            int slider3Top = 220;
            int spacing = 60;
            slider3 = new Slider()
            {
                Margin = new Thickness(60, slider3Top, 0, 0),
                Orientation = Orientation.Vertical,
                Height = 360,
                Width = 20,
                Minimum = 40,
                Maximum = 500,
                Value = 80,
                Foreground = Color.Yellow,
                Background = Color.Red,
                TextColor = Color.LightGreen
            };
            slider3.ValueChanged += slider3_ValueChanged;
            EntityManager.Add(slider3.Entity);

            textblock1 = new TextBlock()
            {
                Margin = new Thickness(100, slider3Top, 0, 0),
                Text = "Range: [40, 500] InitValue: 80",
                Width = 300,
                Height = 40,
            };
            EntityManager.Add(textblock1.Entity);

            button1 = new Button()
            {
                Margin = new Thickness(100, slider3Top + spacing, 0, 0),
                Width = 160,
                Text = "Set Value 250",
                Foreground = Color.Gray,
                BackgroundColor = Color.LightBlue,
                BorderColor = Color.LightBlue,
            };
            button1.Click += button1_Click;
            EntityManager.Add(button1.Entity);

            textblock2 = new TextBlock()
            {
                Margin = new Thickness(100, slider3Top + spacing * 2, 0, 0),
                Text = "<Info>",
                Width = 300,
                Height = 40,
                Foreground = Color.Yellow
            };
            EntityManager.Add(textblock2.Entity);

            // Image Check
            AddCheckImage("Content/SliderSample.wpk");
        }
Example #21
0
        protected override void CreateScene()
        {
            RenderManager.BackgroundColor = Color.Gray;
            //RenderManager.DebugLines = true;

            // TextBox Single
            textBoxSingle = new TextBox()
            {
                Margin = new Thickness(20, 20, 0, 0),
                Width = 360,
                Height = 30,
                IsBorder = true,
                BorderColor = Color.White,
                Text = "Haz click para escribir"
            };
            EntityManager.Add(textBoxSingle.Entity);

            // TextBox Multiple 1
            textBoxMultiple1 = new TextBox()
            {
                Margin = new Thickness(20, 100, 0, 0),
                Width = 360,
                Height = 200,
                AcceptsReturn = true,
                IsBorder = true,
                BorderColor = Color.Yellow,
                Background = Color.LightGreen,
                Text = "Un mago nunca llega tarde. Ni pronto. Llega justo cuando se le necesita. by Gandalf",
                TextAlignment = TextAlignment.Right,
                TextWrapping = true,
                Foreground = Color.Green
            };
            EntityManager.Add(textBoxMultiple1.Entity);

            // Button
            button = new Button()
            {
                Margin = new Thickness(20, 320, 0, 0),
                Text = "Clear",
                Foreground = Color.Gray,
                BackgroundColor = Color.LightBlue,
                BorderColor = Color.LightBlue,
            };
            button.Click += button_Click;
            EntityManager.Add(button.Entity);

            // TextBox Multiple 2
            textBoxMultiple2 = new TextBox()
            {
                Margin = new Thickness(20, 380, 0, 0),
                Width = 360,
                Height = 200,
                IsBorder = true,
                BorderColor = Color.Brown,
                AcceptsReturn = true,
                Text = "Un mago nunca llega tarde. Ni pronto. Llega justo cuando se le necesita. by Gandalf",
                TextAlignment = TextAlignment.Center,
                TextWrapping = true,
                Foreground = Color.Brown,
                Background = Color.LightSalmon
            };
            EntityManager.Add(textBoxMultiple2.Entity);

            AddCheckImage("Content/TextBoxSample.wpk");
        }
Example #22
0
        protected override void CreateScene()
        {
            FixedCamera2D camera2d = new FixedCamera2D("camera");
            camera2d.ClearFlags = ClearFlags.DepthAndStencil;
            EntityManager.Add(camera2d);
            
            Entity logo = new Entity()
            .AddComponent(new Transform2D() { X = WaveServices.ViewportManager.VirtualWidth / 2, Y = 300, Origin = new Vector2(0.5f, 0), DrawOrder = 0.1f })
            .AddComponent(new Sprite("Content/GameOver.wpk"))
            .AddComponent(new AnimationUI())
            .AddComponent(new SpriteRenderer(DefaultLayers.Alpha));

            this.gameStorage = Catalog.GetItem<GameStorage>();

            this.EntityManager.Add(logo);

            this.labelAnimation = logo.FindComponent<AnimationUI>();

            this.playScaleAppear = new SingleAnimation(0.2f, 1f, TimeSpan.FromSeconds(2), EasingFunctions.Back);
            this.playOpacityAppear = new SingleAnimation(0, 1, TimeSpan.FromSeconds(1), EasingFunctions.Cubic);

            var button = new Button()
            {
                Margin = new Thickness(0, 657, 0, 0),
                HorizontalAlignment = WaveEngine.Framework.UI.HorizontalAlignment.Center,
                VerticalAlignment = WaveEngine.Framework.UI.VerticalAlignment.Top,
                Text = string.Empty,
                IsBorder = false,
                BackgroundImage = "Content/restart.wpk",
                PressedBackgroundImage = "Content/restart.wpk"

            };

            button.Click += (o, e) =>
            {
                GamePlayScene scene = WaveServices.ScreenContextManager.FindContextByName("GamePlayContext").FindScene<GamePlayScene>();

                scene.State = Behaviors.GameState.Game;

                scene.Reset();

                WaveServices.ScreenContextManager.Pop(new CrossFadeTransition(TimeSpan.FromSeconds(0.5f)));
            };

            button.Entity.AddComponent(new AnimationUI());
            this.playAnimation = button.Entity.FindComponent<AnimationUI>();

            this.EntityManager.Add(button);

            var stackPanel = new StackPanel()
            {
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment = VerticalAlignment.Bottom,
                Orientation = Orientation.Horizontal,
                Margin = new Thickness(0, 0, (WaveServices.ViewportManager.VirtualWidth - WaveServices.ViewportManager.RightEdge), 20)// (WaveServices.ViewportManager.VirtualWidth - WaveServices.ViewportManager.RightEdge), 20)
            };

            var bestScoreLabel = new Image("Content/BestScore.wpk")
            {
                VerticalAlignment = VerticalAlignment.Center
            };

            stackPanel.Add(bestScoreLabel);

            var bestScoreText = new TextBlock()
            {
                Text = this.gameStorage.BestScore.ToString(),
                FontPath = "Content/Space Age.wpk",
                VerticalAlignment = VerticalAlignment.Center,
                Margin = new Thickness(5,0,0,10)
            };
            stackPanel.Add(bestScoreText);

            this.EntityManager.Add(stackPanel);
        }
Example #23
0
 /// <summary>
 /// Creates the button.
 /// </summary>
 /// <param name="button">The button.</param>
 /// <param name="text">The text.</param>
 /// <param name="clickHandler">The click handler.</param>
 private void CreateButton(out Button button, string text, EventHandler clickHandler)
 {
     button = new Button();
     button.Text = text;
     button.Width = this.BUTTONWIDTH;
     button.Height = this.BUTTONHEIGHT;
     button.IsBorder = false;
     button.Click += clickHandler;
 }
Example #24
0
        /// <summary>
        /// Creates the UI.
        /// </summary>
        private void CreateUI()
        {
            Button changeSkyButton = new Button("changeSky")
            {
                Text = "Change environment",
                Margin = new WaveEngine.Framework.UI.Thickness(10),
                Width = 200
            };
            EntityManager.Add(changeSkyButton);

            changeSkyButton.Click += (o, e) => { this.ChangeEnvironment(); };
        }
Example #25
0
        private void CreateLeaderBoardsAndAchievementsPanel()
        {
            // Show Leaderboards
            var leaderboards = new Button()
            {
                Width = _buttonWidth,
                Height = _buttonHeight,
                Text = "Show all leaderboards",
                Foreground = _foregroundButton,
                BackgroundColor = _backgroundColor,
            };
            leaderboards.Click += (s, e) => { _socialService.ShowAllLeaderboards(); };

            // Show Achievements
            var achievements = new Button()
            {
                Width = _buttonWidth,
                Height = _buttonHeight,
                Text = "Show all achievements",
                Foreground = _foregroundButton,
                BackgroundColor = _backgroundColor,
                Margin = new Thickness(_spaceControl, 0, 0, 0)
            };
            achievements.Click += (s, e) => { _socialService.ShowAchievements(); };

            var sp2 = new StackPanel
            {
                Orientation = Orientation.Horizontal,
                Margin = new Thickness(_leftMargin, _topMargin, 0, 0),
            };
            sp2.Add(leaderboards);
            sp2.Add(achievements);

            EntityManager.Add(sp2);
        }
Example #26
0
        private void AchievementsByCodePanel()
        {
            var unlockAchievementlabel = new TextBlock()
            {
                Text = "Enter achievement code:",
                Width = 200,
            };
            var unlockAchievementText = new TextBox()
            {
                Text = string.Empty,
                Height = 60,
                Width = _buttonWidth,
                Margin = new Thickness(_spaceControl, 0, 0, 0)
            };

            // Unlock achievement by code
            var unlockAchievementCodeButton = new Button()
            {
                Width = _buttonWidth,
                Height = _buttonHeight,
                Text = "Unlock achievement by code",
                Foreground = _foregroundButton,
                BackgroundColor = _backgroundColor,
                Margin = new Thickness(_spaceControl, 0, 0, 0)
            };
            unlockAchievementCodeButton.Click += async (s, e) =>
            {
                var code = unlockAchievementText.Text;
                await _socialService.UnlockAchievement(code);
            };

            var sp3 = new StackPanel
            {
                Orientation = Orientation.Horizontal,
                Margin = new Thickness(100, _topMargin + 5, 0, 0),
            };
            sp3.Add(unlockAchievementlabel);
            sp3.Add(unlockAchievementText);
            sp3.Add(unlockAchievementCodeButton);

            EntityManager.Add(sp3);
        }
Example #27
0
        private void CreateLoginPanel()
        {
            // Login
            var login = new Button()
            {
                Width = _buttonWidth,
                Height = _buttonHeight,
                Text = "Login into service",
                Foreground = _foregroundButton,
                BackgroundColor = _backgroundColor,
            };
            login.Click += async (s, e) =>
            {
                var loggedIn = await _socialService.Login();
                if (!loggedIn)
                {
                    await WaveServices.Platform.ShowMessageBoxAsync("Error", "Not logged in");
                }
            };

            // Logout
            var logout = new Button()
            {
                Width = _buttonWidth,
                Height = _buttonHeight,
                Text = "Logout",
                Foreground = _foregroundButton,
                BackgroundColor = _backgroundColor,
                Margin = new Thickness(_spaceControl, 0, 0, 0)
            };
            logout.Click += async (s, e) => { await _socialService.Logout(); };

            var sp1 = new StackPanel
            {
                Orientation = Orientation.Horizontal,
                Margin = new Thickness(_leftMargin, _topMargin, 0, 0),
            };
            sp1.Add(login);
            sp1.Add(logout);

            EntityManager.Add(sp1);
        }
Example #28
0
        /// <summary>
        /// Creates the scene.
        /// </summary>
        /// <remarks>
        /// This method is called before all <see cref="T:WaveEngine.Framework.Entity" /> instances in this instance are initialized.
        /// </remarks>
        protected override void CreateScene()
        {
            RenderManager.BackgroundColor = Color.Black;

            //Background
            Entity background = new Entity()
                            .AddComponent(new Transform2D()
                            {
                                DrawOrder = 1,
                            })
                            .AddComponent(new StretchBehavior())
                            .AddComponent(new Sprite(Directories.TexturePath + "background.wpk"))
                            .AddComponent(new SpriteRenderer(DefaultLayers.Opaque));
            EntityManager.Add(background);

            // Logo
            Entity logo = new Entity()
                           .AddComponent(new Transform2D()
                           {
                               X = 15,
                               Y = WaveServices.ViewportManager.TopEdge,
                               DrawOrder = 0.9f,
                           })
                           .AddComponent(new SpriteAtlas(Directories.TexturePath + "game.wpk", "smallLogo"))
                           .AddComponent(new SpriteAtlasRenderer(DefaultLayers.Opaque));
            EntityManager.Add(logo);

            // Gravity
            Entity gravity = new Entity()
                            .AddComponent(new Transform2D()
                            {
                                Origin = Vector2.Center,
                                X = WaveServices.ViewportManager.VirtualWidth / 2,
                                Y = 605,
                                DrawOrder = 0.9f,
                            })
                            .AddComponent(new SpriteAtlas(Directories.TexturePath + "game.wpk", "gravity"))
                            .AddComponent(new SpriteAtlasRenderer(DefaultLayers.Opaque));
            EntityManager.Add(gravity);

            // Moon back
            Entity moonBack = new Entity()
                            .AddComponent(new Transform2D()
                            {
                                Origin = Vector2.Center,
                                X = WaveServices.ViewportManager.VirtualWidth / 2,
                                Y = 605,
                                DrawOrder = 0.8f,
                            })
                            .AddComponent(new SpriteAtlas(Directories.TexturePath + "game.wpk", "moonBack"))
                            .AddComponent(new SpriteAtlasRenderer(DefaultLayers.Opaque));
            EntityManager.Add(moonBack);

            // Rabbits
            this.rabbitEmiter = new RabbitEmiter();
            EntityManager.Add(this.rabbitEmiter);

            // Tap hand
            this.tapHand = new Entity()
                            .AddComponent(new Transform2D()
                            {
                                X = 305,
                                Y = 598,
                                DrawOrder = 0.4f,
                            })
                            .AddComponent(new SpriteAtlas(Directories.TexturePath + "game.wpk", "tapHand"))
                            .AddComponent(new SpriteAtlasRenderer(DefaultLayers.Opaque));
            EntityManager.Add(this.tapHand);

            // Touch Panel
            Entity touchPanel = new Entity()
                                .AddComponent(new Transform2D()
                                {
                                    DrawOrder = 0.1f,
                                    Rectangle = new RectangleF(WaveServices.ViewportManager.LeftEdge,
                                                               WaveServices.ViewportManager.TopEdge,
                                                               WaveServices.ViewportManager.RightEdge - WaveServices.ViewportManager.LeftEdge,
                                                               WaveServices.ViewportManager.BottomEdge - WaveServices.ViewportManager.TopEdge),
                                })
                                .AddComponent(new RectangleCollider())
                                .AddComponent(new TouchGestures());
            var touch = touchPanel.FindComponent<TouchGestures>();
            touch.TouchPressed += (s, o) =>
            {
                switch (this.currentState)
                {
                    case States.Paused:
                        this.SetNewState(States.Play);
                        break;
                    case States.Play:

                        this.rabbitEmiter.ApplyImpuseToLast();

                        break;
                }
            };
            EntityManager.Add(touchPanel);

            // Restart Button
            Button restart = new Button()
            {
                Text = string.Empty,
                IsBorder = false,
                BackgroundImage = Directories.TexturePath + "restartRelease.wpk",
                PressedBackgroundImage = Directories.TexturePath + "restartPressed.wpk",
                Margin = new Thickness(10, WaveServices.ViewportManager.BottomEdge - 120, 0 ,0)
            };
            restart.Click += (s, o) =>
            {
                this.SetNewState(States.Paused);
                SoundsManager.Instance.PlaySound(SoundsManager.SOUNDS.Click);
            };
            EntityManager.Add(restart);

            // Score Panel
            this.scorePanel = new ScorePanel()
            {
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment = VerticalAlignment.Top,
            };
            EntityManager.Add(this.scorePanel);

            this.rabbitEmiter.ScoreChanged += rabbitEmiter_scoreChanged;

            // Add scene behaviors
            this.AddSceneBehavior(new DebugSceneBehavior(), SceneBehavior.Order.PostUpdate);
        }
Example #29
0
        protected override void CreateScene()
        {
            FixedCamera2D camera2d = new FixedCamera2D("camera");
            camera2d.BackgroundColor = Color.Gray;
            EntityManager.Add(camera2d);

            int offsetTop = 20;
            int spacing = 80;

            // Checkbox 1
            checkbox1 = new CheckBox()
            {
                Margin = new Thickness(20, offsetTop, 0, 0),
            };
            EntityManager.Add(checkbox1.Entity);

            // Checkbox 2
            checkbox2 = new CheckBox()
            {
                Margin = new Thickness(20, offsetTop + spacing, 0, 0),
                Text = "Antialising",
                Foreground = Color.Red,
                IsChecked = true,
            };
            EntityManager.Add(checkbox2.Entity);

            // Checkbox 3
            checkbox3 = new CheckBox()
            {
                Margin = new Thickness(20, offsetTop + spacing * 2, 0, 0),
                Width = 250,
                Text = "SegoeBlack20",
                Foreground = Color.Blue,
                IsBorder = true,
            };
            EntityManager.Add(checkbox3.Entity);

            // Checkbox 4
            checkbox4 = new CheckBox()
            {
                Margin = new Thickness(20, offsetTop + spacing * 3, 0, 0),
                Width = 300,
                Text = "You can modify me",
                Foreground = Color.Yellow,
            };
            EntityManager.Add(checkbox4.Entity);

            button1 = new Button()
            {
                Margin = new Thickness(20, offsetTop + spacing * 4, 0, 0),
                Width = 150,
                Text = "Set Checked",
                Foreground = Color.LightPink,
                BackgroundColor = Color.Purple,
            };
            button1.Click += button1_Click;
            EntityManager.Add(button1.Entity);

            // CheckBox 5
            checkbox5 = new CheckBox()
            {
                Margin = new Thickness(20, offsetTop + spacing * 5, 0, 0),
                Text = "Physic",
                Foreground = Color.Orange,
            };
            checkbox5.Checked += checkbox5_Checked;
            EntityManager.Add(checkbox5.Entity);

            textblock1 = new TextBlock()
            {
                Margin = new Thickness(20, offsetTop + spacing * 5.5f, 0, 0),
                Text = "CheckedCount: " + checkedCounter,
                Foreground = Color.Orange,
            };
            EntityManager.Add(textblock1.Entity);

            textblock2 = new TextBlock()
            {
                Margin = new Thickness(20, offsetTop + spacing * 6, 0, 0),
                Text = "UncheckedCount: " + uncheckedCounter,
                Foreground = Color.Orange,
            };
            EntityManager.Add(textblock2.Entity);

            // Image Check
            AddCheckImage("Content/CheckBoxSample.wpk");
        }
Example #30
0
        /// <summary>
        /// Creates the UI Interface
        /// </summary>
        private void CreateUI()
        {
            Button changeSkyButton = new Button("changeSky")
            {
                Text = "Change environment",
                Margin = new WaveEngine.Framework.UI.Thickness(10),
                Width = 200
            };
            EntityManager.Add(changeSkyButton);

            CheckBox ambientCheckBox = new CheckBox("ambientCheckBox")
            {
                Text = "Ambient Occlusion",
                Margin = new WaveEngine.Framework.UI.Thickness(10, 70, 0, 0),
                IsChecked = this.isOcclusionEnabled
            };
            EntityManager.Add(ambientCheckBox);

            changeSkyButton.Click += (o, e) => { this.ChangeEnvironment(); };
            ambientCheckBox.Checked += (o, e) => { this.ChangeAmbientOcclusion(e.Value); };
        }