Exemplo n.º 1
0
        private void CreateMenuItem <TView>(string text) where TView : UIView
        {
            var button = _slider.Button(new UIButtonSettings
            {
                ButtonSpriteStates = { Default = Game.GetSprite("mp_bar_text") }
            });

            button.SortingOrder(1);
            button.Click += _ =>
            {
                Hide();
                mUI.BaseView.ChildView <TView>(new UIViewSettings
                {
                    SortingOrder = 1
                });
            };

            button.Label(new UILabelSettings
            {
                Text          = text,
                Size          = 32,
                TextAlignment = TextAlignment.Center,
                TextAnchor    = TextAnchor.MiddleCenter,
                Color         = new UIColor("#4F4F4F")
            }).SortingOrder(1);
        }
Exemplo n.º 2
0
        private void CreateItemMenu <T>(string text) where T : BaseExampleView
        {
            var button = _scrollView.Button(new UIButtonSettings
            {
                Sprite = Game.GetSprite("mp_bar_text"),
            });

            button.Label(new UILabelSettings
            {
                Text      = text,
                Color     = Color.black,
                Font      = "Arial",
                TextStyle =
                {
                    FontStyle     = FontStyle.Bold,
                    TextAlignment = TextAlignment.Center,
                    Size          = 40
                }
            }).SortingOrder(1);

            button.OnClick += sender =>
            {
                Hide();
                ParentView.View <T>().BeforeDestroy += s =>
                {
                    Show();
                };
            };
        }
Exemplo n.º 3
0
        private UIBaseScrollBar CreateScrollBar(bool vertical, float step)
        {
            Func <bool, UIScrollBarSettings, UIBaseScrollBar> createFunc = (isVertical, settings) =>
            {
                if (isVertical)
                {
                    return(this.VerticalScrollBar(settings));
                }
                return(this.HorizontalScrollBar(settings));
            };

            return((UIBaseScrollBar)createFunc(vertical, new UIScrollBarSettings
            {
                Min = 100,
                Max = 200,
                Step = step,
                Default = 150,
                BarSprite = Game.GetSprite("level_info"),
                BarSpriteIsHorizontal = true,
                BarPointSettings =
                {
                    ButtonSpriteStates =
                    {
                        Default        = Game.GetSprite("x_bg"),
                        Highlighted    = Game.GetSprite("x_bg_pressed")
                    }
                },
                Padding = new Vector2(
                    vertical ? 0f : Game.GetSprite("x_bg").WorldSize().x / 2f * 1.39576f,
                    vertical ? Game.GetSprite("x_bg").WorldSize().y / 2f * 1.39576f : 0f
                    ),
                ScalePoint = new Vector2(1.39576f, 1.39576f)
            }).Scale(0.5f));
        }
Exemplo n.º 4
0
        private void CreateCharacter()
        {
            _characterContainer = this.Container(new UIContainerSettings());

            _body = _characterContainer.Sprite(new UISpriteSettings {
                Sprite = Game.GetSprite("mp_bar_buttons")
            });
            _body.SetColor(Color.black);

            _head = _characterContainer.Sprite(new UISpriteSettings {
                Sprite = Game.GetSprite("notif_cancel")
            });
            _head.SortingOrder(1);
            _head.Scale(3f);
            _head.Translate(0f, 2.22f);

            _leftHand = _characterContainer.Sprite(new UISpriteSettings {
                Sprite = Game.GetSprite("test_hand")
            });
            _leftHand.SortingOrder(2);
            _leftHand.Scale(0.2f, 0.32f);
            _leftHand.Translate(-0.87f, 0.36f);
            _leftHand.Flip(true, false);
            _leftHand.name = "Left Hand";
            _leftHand.SetColor(Color.black);

            _rightHand = _characterContainer.Sprite(new UISpriteSettings {
                Sprite = Game.GetSprite("test_hand")
            });
            _rightHand.SortingOrder(2);
            _rightHand.Scale(0.2f, 0.32f);
            _rightHand.Translate(0.87f, 0.36f);
            _rightHand.name = "Right Hand";
            _rightHand.SetColor(Color.black);

            _leftLeg = _characterContainer.Sprite(new UISpriteSettings {
                Sprite = Game.GetSprite("test_hand")
            });
            _leftLeg.SortingOrder(2);
            _leftLeg.Scale(0.2f, 0.32f);
            _leftLeg.Translate(-0.64f, -2.14f);
            _leftLeg.Rotate(-113.808f);
            _leftLeg.SetColor(Color.black);

            _rightLeg = _characterContainer.Sprite(new UISpriteSettings {
                Sprite = Game.GetSprite("test_hand")
            });
            _rightLeg.SortingOrder(2);
            _rightLeg.Scale(0.2f, 0.32f);
            _rightLeg.Translate(0.64f, -2.14f);
            _rightLeg.Rotate(113.808f);
            _rightLeg.SetColor(Color.black);
            _rightLeg.Flip(true, false);

            _characterContainer.Scale(0.5f);
        }
Exemplo n.º 5
0
        protected override void CreateInterface(object[] @params)
        {
            var joystick1 = CreateJoystick(0f, 0f);

            joystick1.PosY(this.RelativeY(1f) - joystick1.GetHeight() / 2);

            var joystick2 = CreateJoystick(Game.GetSprite("GreenCircle100px").WorldSize().x / 2, 0.5f);

            joystick2.PosY(this.RelativeY(0f) + joystick2.GetHeight() / 2);

            base.CreateInterface(@params);
        }
Exemplo n.º 6
0
        protected override void CreateInterface(object[] @params)
        {
            _sprite = this.Sprite(new UISpriteSettings {
                Sprite = Game.GetSprite("mp_gui_finish")
            });
            Debug.Log($"size = {_sprite.Renderer.size}");
            Debug.Log($"pivot = {_sprite.Renderer.sprite.pivot}");
            Debug.Log($"bounds.center = {_sprite.Renderer.sprite.bounds.center}");
            Debug.Log($"bounds.size = {_sprite.Renderer.sprite.bounds.size}");

            _pos = _sprite.Pos() - new Vector2(_sprite.GetWidth() / 2, _sprite.GetHeight() / 2);
            base.CreateInterface(@params);
        }
Exemplo n.º 7
0
        private UIToggle CreateToggle(UIRadioGroup group)
        {
            var toggle = group.Toggle(new UIToggleSettings
            {
                ButtonSpriteStates =
                {
                    Default     = Game.GetSprite("notif_agree"),
                    Selected    = Game.GetSprite("notif_cancel_closed"),
                    Highlighted = Game.GetSprite("notif_agree_closed")
                },
            });

            return(toggle);
        }
Exemplo n.º 8
0
        protected override void CreateInterface(object[] @params)
        {
            var button = this.Button(new UIButtonSettings
            {
                SpriteStates = new SpriteStates
                {
                    Default     = Game.GetSprite("notif_cancel"),
                    Highlighted = Game.GetSprite("notif_cancel_closed")
                },
            });

            button.Position(this.Position(UIAnchor.LowerRight), UIAnchor.LowerRight);

            button.OnClick += s => Destroy();
        }
Exemplo n.º 9
0
        protected override void CreateInterface(object[] @params)
        {
            var backButton = this.Button(new UIButtonSettings
            {
                ButtonSpriteStates =
                {
                    Default     = Game.GetSprite("notif_cancel"),
                    Highlighted = Game.GetSprite("notif_cancel_closed")
                }
            });

            backButton.Pos(
                this.RelativeX(1f) - backButton.GetWidth() / 2,
                this.RelativeY(0f) + backButton.GetHeight() / 2
                );
            backButton.Click += Close;
        }
Exemplo n.º 10
0
        protected override void CreateInterface(object[] @params)
        {
            var toggle = this.Toggle(new UIToggleSettings
            {
                ButtonSpriteStates =
                {
                    Default     = Game.GetSprite("notif_agree"),
                    Selected    = Game.GetSprite("notif_cancel_closed"),
                    Highlighted = Game.GetSprite("notif_agree_closed")
                }
            });

            toggle.Selected   += _ => Debug.Log("Toggle selected");
            toggle.Deselected += _ => Debug.Log("Toggle deselected");

            base.CreateInterface(@params);
        }
Exemplo n.º 11
0
        protected override void CreateInterface(object[] @params)
        {
            var slider = this.VerticalSlider(new UISliderSettings
            {
                Height = GetHeight() * 0.8f
            });

            var sp = Game.GetSprite("mp_chat_msg");

            for (var i = EasingType.linear; i <= EasingType.easeInOutBounce; i++)
            {
                var c = slider.Container(new UIContainerSettings
                {
                    Width  = GetWidth(),
                    Height = sp.WorldSize().y * 2
                }).SortingOrder(1);

                c.Label(new UILabelSettings
                {
                    TextAlignment = TextAlignment.Left,
                    TextAnchor    = TextAnchor.UpperLeft,
                    Text          = i.ToString(),
                    Size          = 20,
                }).Translate(-c.GetWidth() / 2, 0);

                var sprite = c.Sprite(new UISpriteSettings
                {
                    Sprite = sp
                });
                sprite.Translate(-sprite.Parent.GetWidth() / 2 + sprite.GetWidth() / 2, -sprite.GetHeight());
                sprite.LinearAnimation(new UILinearAnimationSettings
                {
                    StartPos = sprite.LocalPos(),
                    EndPos   = new Vector2(
                        sprite.Parent.GetWidth() / 2 - sprite.GetWidth() / 2,
                        sprite.LocalPos().y
                        ),
                    EasingType = i,
                    Duration   = 4f,
                    PlayType   = UIAnimationPlayType.END_RESET,
                    IsLocal    = true
                });
            }

            base.CreateInterface(@params);
        }
Exemplo n.º 12
0
        protected override void CreateInterface(object[] @params)
        {
            var button = this.Button(new UIButtonSettings
            {
                ButtonSpriteStates =
                {
                    Default     = Game.GetSprite("notif_agree"),
                    Highlighted = Game.GetSprite("notif_agree_closed")
                }
            });

            button.Click += _ =>
            {
                Debug.Log("Click");
            };

            SetupScaleAnimation(button);
            base.CreateInterface(@params);
        }
Exemplo n.º 13
0
        protected override void CreateInterface(object[] @params)
        {
            var pageSlider = this.HorizontalPageSlider(new UIPageSliderSettings
            {
                ElementsDirection     = LayoutElemsDirection.FORWARD,
                EasingCurrentPageType = EasingType.easeInOutCirc,
                EasingNextPageType    = EasingType.easeInOutCirc,
                Duration = 2f
            });

            for (int i = 0; i < 5; i++)
            {
                pageSlider.Sprite(new UISpriteSettings {
                    Sprite = Game.GetSprite("mp_bar_buttons")
                }).SortingOrder(1);
            }

            base.CreateInterface(@params);
        }
Exemplo n.º 14
0
        protected override void CreateInterface(object[] @params)
        {
            var slider1 = this.HorizontalSlider(new UISliderSettings
            {
                Height            = GetHeight() / 2.5f,
                Width             = GetWidth(),
                Offset            = 0.1f,
                ElementsDirection = LayoutElemsDirection.FORWARD,
            });

            slider1.PosY(this.RelativeY(1f) - slider1.GetHeight() / 2);

            for (int i = 0; i < 20; i++)
            {
                slider1.Sprite(new UISpriteSettings {
                    Sprite = Game.GetSprite("mp_chat_msg")
                }).SortingOrder(1);
            }

            var slider2 = this.HorizontalSlider(new UISliderSettings
            {
                Height            = GetHeight() / 2.5f,
                Width             = GetWidth(),
                ElementsDirection = LayoutElemsDirection.BACKWARD,
                Padding           = 0.5f,
                Offset            = 0.2f,
                TimeToStop        = 1f
            });

            slider2.PosY(this.RelativeY(0f) + slider2.GetHeight() / 2);

            for (int i = 0; i < 20; i++)
            {
                slider2.Sprite(new UISpriteSettings {
                    Sprite = Game.GetSprite("mp_chat_msg")
                }).SortingOrder(1);
            }
            base.CreateInterface(@params);
        }
Exemplo n.º 15
0
        private UIJoystick CreateJoystick(float paddingRadius, float friction)
        {
            var joystick = this.Joystick(new UIJoystickSettings
            {
                BackgroundSprite = Game.GetSprite("editor_drawcircle"),
                PointSprite      = Game.GetSprite("GreenCircle100px"),
                PaddingRadius    = paddingRadius,
                Friction         = friction
            });

            var label = joystick.Label(new UILabelSettings
            {
                Text          = $"pos={joystick.NormilizedPointPos}",
                Color         = UIColor.Black,
                TextAnchor    = TextAnchor.MiddleCenter,
                TextAlignment = TextAlignment.Center,
                Size          = 40,
            });

            label.SortingOrder(3);
            joystick.PointMoved += _ => label.SetText($"pos={joystick.NormilizedPointPos}");

            return(joystick);
        }