예제 #1
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);
        }
예제 #3
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);
        }
예제 #4
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);
        }
예제 #5
0
        // --------------------------------------------------------------------------------------------
        protected override SharpUIBase BuildMainPanel()
        {
            _background       = new SharpUIImage("UIStartMenuView", null);
            _background.Color = FadeInStartColor;
            _background.SetFillSize();

            _canvasGroup = new SharpUICanvasGroup("CanvasGroup");
            _canvasGroup.SetFillSize();
            _canvasGroup.Alpha = 0f;
            _background.AddChild(_canvasGroup);

            SharpUITextMeshPro title = new SharpUITextMeshPro("Title", "GridStrategy\n<size=15%>by Tofunaut</size>");

            title.Font          = AppManager.AssetManager.Get <TMPro.TMP_FontAsset>(AssetPaths.Fonts.GravityUltraLight);
            title.Color         = Color.white;
            title.TextAlignment = TMPro.TextAlignmentOptions.Center;
            title.SetFillSize(EAxis.X, 0.5f);
            title.SetFixedSize(EAxis.Y, 500);
            title.AutoSizeFont();
            title.alignment = EAlignment.TopCenter;
            _canvasGroup.AddChild(title);

            SharpUITextMeshPro versionLabel = new SharpUITextMeshPro("VersionLabel", AppManager.AppVersion);

            versionLabel.Font          = AppManager.AssetManager.Get <TMPro.TMP_FontAsset>(AssetPaths.Fonts.GravityRegular);
            versionLabel.Color         = new Color(1f, 1f, 1f, 0.5f);
            versionLabel.TextAlignment = TMPro.TextAlignmentOptions.Center;
            versionLabel.SetFixedSize(50, 25);
            versionLabel.AutoSizeFont();
            versionLabel.alignment = EAlignment.BottomRight;
            versionLabel.margin    = new RectOffset(0, 20, 0, 20);
            _canvasGroup.AddChild(versionLabel);

            _buttonLayout = BuildButtonLayout();
            _canvasGroup.AddChild(_buttonLayout);

            if (!AppManager.IsClientValid)
            {
                SharpUITextMeshPro clientValidationErrorMessage = new SharpUITextMeshPro("ClientValidationErrorMessage", string.Empty);
                clientValidationErrorMessage.Font  = AppManager.AssetManager.Get <TMPro.TMP_FontAsset>(AssetPaths.Fonts.GravityRegular);
                clientValidationErrorMessage.Color = Color.red;
                clientValidationErrorMessage.SetFixedSize(200, 25);
                clientValidationErrorMessage.SetFontSize(28);
                clientValidationErrorMessage.alignment     = EAlignment.TopLeft;
                clientValidationErrorMessage.margin        = new RectOffset(20, 0, 20, 0);
                clientValidationErrorMessage.TextAlignment = TMPro.TextAlignmentOptions.TopLeft;
                _canvasGroup.AddChild(clientValidationErrorMessage);

                switch (AppManager.ClientState)
                {
                case AppManager.EClientState.ForceOffline:
                    clientValidationErrorMessage.Text = "Force offline";
                    break;

                case AppManager.EClientState.ValidationError:
                    clientValidationErrorMessage.Text = "Client failed to validate correctly";
                    break;

                case AppManager.EClientState.Offline:
                    clientValidationErrorMessage.Text = "Client is offline";
                    break;

                case AppManager.EClientState.NeedsUpdate:
                    clientValidationErrorMessage.Text = "Client must update";
                    break;
                }
            }

            return(_background);
        }