// --------------------------------------------------------------------------------------------
            public UIStartMenuButton(string caption, Action onClicked) : base($"{caption}_Button")
            {
                SetFixedSize(Size);
                alignment = EAlignment.MiddleCenter;

                _onClicked = onClicked;

                _background = new SharpUIImage($"{Name}_Background", null);
                _background.SetFillSize(EAxis.X);
                _background.SetFixedSize(EAxis.Y, 0);
                _background.alignment = EAlignment.MiddleCenter;
                _background.Color     = DefaultBackgroundColor;
                AddChild(_background);

                _captionLabel               = new SharpUITextMeshPro($"{caption}_Label", caption);
                _captionLabel.Font          = AppManager.AssetManager.Get <TMPro.TMP_FontAsset>(AssetPaths.Fonts.GravityBook);
                _captionLabel.Color         = DefaultColor;
                _captionLabel.TextAlignment = TMPro.TextAlignmentOptions.Center;
                _captionLabel.SetFillSize();
                _captionLabel.AutoSizeFont();
                _captionLabel.alignment = EAlignment.MiddleCenter;
                AddChild(_captionLabel);

                SubscribeToEvent(EEventType.PointerEnter, OnPointerEnter);
                SubscribeToEvent(EEventType.PointerExit, OnPointerExit);
                SubscribeToEvent(EEventType.PointerDown, OnPointerDown);
                SubscribeToEvent(EEventType.PointerUp, OnPointerUp);
                SubscribeToEvent(EEventType.PointerClick, OnClicked);
            }
Example #2
0
        protected override SharpUIBase BuildMainPanel()
        {
            _bannerBackground = new SharpUIImage("UIBeginTurnBanner", null);
            _bannerBackground.SetFillSize(EAxis.X, 1f);
            _bannerBackground.SetFixedSize(EAxis.Y, BannerHeight);
            _bannerBackground.Color     = new Color(1f, 1f, 1f, 0.3f);
            _bannerBackground.alignment = EAlignment.MiddleCenter;

            _bannerLabel      = new SharpUITextMeshPro($"{_bannerBackground.Name}_Label", _playerName);
            _bannerLabel.Font = AppManager.AssetManager.Get <TMPro.TMP_FontAsset>(AssetPaths.Fonts.GravityLightItalic);
            _bannerLabel.SetFillSize();
            _bannerLabel.TextAlignment = TMPro.TextAlignmentOptions.Center;
            _bannerLabel.AutoSizeFont();
            _bannerLabel.Color     = Color.black;
            _bannerLabel.alignment = EAlignment.MiddleCenter;
            _bannerBackground.AddChild(_bannerLabel);

            return(_bannerBackground);
        }
        protected override SharpUIBase BuildMainPanel()
        {
            // use non drawing graphic to block input
            SharpUINonDrawingGraphic toReturn = new SharpUINonDrawingGraphic("UIConfirmationDialog");

            toReturn.SetFillSize();

            toReturn.SubscribeToEvent(EEventType.PointerClick, (object sender, EventSystemEventArgs e) =>
            {
                OnCancelClicked?.Invoke();
            });

            _background = new SharpUIImage($"{toReturn.Name}_bg", null);
            _background.SetFixedSize(Size);
            _background.alignment = EAlignment.MiddleCenter;
            _background.Color     = new Color(0f, 0f, 0f, 0.5f);
            toReturn.AddChild(_background);

            SharpUIHorizontalLayout buttonLayout = new SharpUIHorizontalLayout($"{toReturn.Name}_button_layout");

            buttonLayout.SetFitSize();
            buttonLayout.spacing   = 40;
            buttonLayout.alignment = EAlignment.BottomCenter;
            buttonLayout.margin    = new RectOffset(0, 0, 0, 20);
            _background.AddChild(buttonLayout);

            ChoiceButton okButton = new ChoiceButton(() => { OnOKClicked?.Invoke(); }, $"{toReturn.Name}_ok_button", "OK");

            buttonLayout.AddChild(okButton);

            ChoiceButton cancelButton = new ChoiceButton(() => { OnCancelClicked?.Invoke(); }, $"{toReturn.Name}_cancel_button", "Cancel");

            buttonLayout.AddChild(cancelButton);

            return(toReturn);
        }
Example #4
0
        // --------------------------------------------------------------------------------------------
        public UICard(CardData cardData) : base($"UICard: {cardData.id}")
        {
            _cardData = cardData;

            SetFixedSize(Size);

            _border = new SharpUIImage("CardBorder", null);
            _border.SetFillSize();
            _border.Color = BorderColor;
            AddChild(_border);

            _cardBackground = new SharpUIImage("CardBackground", null);
            _cardBackground.SetFixedSize(CardBackgroundSize);
            _cardBackground.margin = new RectOffset(BorderSize, BorderSize, BorderSize, BorderSize);
            _cardBackground.Color  = BackgroundColor;
            AddChild(_cardBackground);

            _prefabViewportBackground       = new SharpUIImage("PrefabViewportBackground", null);
            _prefabViewportBackground.Color = Color.green; // placeholder
            _prefabViewportBackground.SetFixedSize(ViewportSize);
            _prefabViewportBackground.margin = new RectOffset(BorderSize, 0, BorderSize + (int)TitleBarSize.y, 0);
            _cardBackground.AddChild(_prefabViewportBackground);

            if (!string.IsNullOrEmpty(cardData.illustrationPrefabPath))
            {
                _prefabViewport = new SharpUIPrefabToRenderTexture("PrefabViewport", AppManager.AssetManager.Get <GameObject>(cardData.illustrationPrefabPath), ViewportSize, true);
                _prefabViewport.SetFillSize();
                _prefabViewport.SetCameraDistanceAndAngle(new Vector3(0f, 0.5f, 0f), 2f, Quaternion.Euler(0f, 30f, 10f));
                _prefabViewportBackground.AddChild(_prefabViewport);
            }

            _descriptionBackground = new SharpUIImage("DescriptionBackground", null);
            _descriptionBackground.SetFixedSize(DescriptionSize);
            _descriptionBackground.margin    = DescriptionOffset;
            _descriptionBackground.Color     = DescriptionBoxColor;
            _descriptionBackground.alignment = EAlignment.TopCenter;
            _cardBackground.AddChild(_descriptionBackground);

            _titleBackground       = new SharpUIImage("TitleBackground", null);
            _titleBackground.Color = TitleColor;
            _titleBackground.SetFixedSize(TitleBarSize);
            _titleBackground.alignment = EAlignment.TopCenter;
            _titleBackground.margin    = TitleOffset;
            _cardBackground.AddChild(_titleBackground);

            SharpUITextMeshPro titleBackgroundLabel = new SharpUITextMeshPro("TitleLabel", cardData.id);

            titleBackgroundLabel.SetFillSize();
            titleBackgroundLabel.AutoSizeFont();
            titleBackgroundLabel.TextAlignment = TMPro.TextAlignmentOptions.Left;
            titleBackgroundLabel.Font          = AppManager.AssetManager.Get <TMPro.TMP_FontAsset>(AssetPaths.Fonts.GravityRegular);
            titleBackgroundLabel.alignment     = EAlignment.MiddleLeft;
            titleBackgroundLabel.margin        = new RectOffset(20, 0, 0, 0);
            titleBackgroundLabel.Color         = Color.black;
            _titleBackground.AddChild(titleBackgroundLabel);

            _infoBarBackground       = new SharpUIImage("InfoBarBackground", null);
            _infoBarBackground.Color = TitleColor;
            _infoBarBackground.SetFixedSize(TitleBarSize);
            _infoBarBackground.alignment = EAlignment.TopCenter;
            _infoBarBackground.margin    = InfoBarOffset;
            _cardBackground.AddChild(_infoBarBackground);
        }
Example #5
0
        protected override SharpUIBase BuildMainPanel()
        {
            SharpUINonDrawingGraphic toReturn = new SharpUINonDrawingGraphic("UIGameOverView");

            toReturn.SetFillSize();

            SharpUIImage background = new SharpUIImage($"{toReturn.Name}_bg", null);

            background.Color = new Color(0f, 0f, 0f, 0.5f);
            background.SetFixedSize(Size);
            background.alignment = EAlignment.MiddleCenter;
            toReturn.AddChild(background);

            SharpUITextMeshPro gameOverLabel = new SharpUITextMeshPro("GameOverLabel", "Game Over");

            gameOverLabel.SetFillSize(EAxis.X, 0.8f);
            gameOverLabel.SetFixedSize(EAxis.Y, 200);
            gameOverLabel.alignment = EAlignment.TopCenter;
            gameOverLabel.AutoSizeFont();
            gameOverLabel.Font          = AppManager.AssetManager.Get <TMPro.TMP_FontAsset>(AssetPaths.Fonts.GravityBook);
            gameOverLabel.Color         = Color.black;
            gameOverLabel.TextAlignment = TMPro.TextAlignmentOptions.Center;
            gameOverLabel.Color         = Color.white;
            background.AddChild(gameOverLabel);

            List <Player> players = _game.GetWinners();
            StringBuilder sb      = new StringBuilder();

            if (players.Count > 0)
            {
                sb.Append("Winner: ");
            }
            foreach (Player player in players)
            {
                sb.Append(player.name + ", ");
            }

            SharpUITextMeshPro winnerLabel = new SharpUITextMeshPro("WinnerLabel", sb.ToString());

            winnerLabel.SetFillSize(EAxis.X, 0.6f);
            winnerLabel.SetFixedSize(EAxis.Y, 100);
            winnerLabel.margin    = new RectOffset(0, 0, 200, 0);
            winnerLabel.alignment = EAlignment.TopCenter;
            winnerLabel.AutoSizeFont();
            winnerLabel.Font          = AppManager.AssetManager.Get <TMPro.TMP_FontAsset>(AssetPaths.Fonts.GravityItalic);
            winnerLabel.Color         = Color.black;
            winnerLabel.TextAlignment = TMPro.TextAlignmentOptions.Center;
            winnerLabel.Color         = Color.white;
            background.AddChild(winnerLabel);

            SharpUIHorizontalLayout buttonLayout = new SharpUIHorizontalLayout($"{toReturn.Name}_button_layout");

            buttonLayout.SetFillSize(EAxis.X);
            buttonLayout.SetFixedSize(EAxis.Y, (int)ChoiceButton.Size.y);
            buttonLayout.alignment      = EAlignment.BottomCenter;
            buttonLayout.margin         = new RectOffset(0, 0, 0, 20);
            buttonLayout.childAlignment = EAlignment.MiddleCenter;
            background.AddChild(buttonLayout);

            buttonLayout.AddChild(new ChoiceButton("ReturnToStartButton", "Return to Start", () =>
            {
                _listener.OnReturnToStartClicked();
            }));

            return(toReturn);
        }