// --------------------------------------------------------------------------------------------
            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);
            }
示例#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);
        }
示例#3
0
        // --------------------------------------------------------------------------------------------
        public UIEndTurnButton(Action onClick) : base("UIEndTurnButton", null)
        {
            Color = new Color(0.5f, 0.5f, 0.5f, 1f);
            SetFixedSize(Size);
            alignment = EAlignment.BottomRight;

            SharpUITextMeshPro label = new SharpUITextMeshPro($"{Name}_label", "End Turn");

            label.SetFillSize();
            label.AutoSizeFont();
            label.Font          = AppManager.AssetManager.Get <TMPro.TMP_FontAsset>(AssetPaths.Fonts.GravityBold);
            label.TextAlignment = TMPro.TextAlignmentOptions.Center;
            AddChild(label);

            SubscribeToEvent(EEventType.PointerClick, (object sender, EventSystemEventArgs e) =>
            {
                onClick?.Invoke();
            });
        }
示例#4
0
        // --------------------------------------------------------------------------------------------
        protected override SharpUIBase BuildMainPanel()
        {
            _background = new SharpUINonDrawingGraphic($"{_player.name}_Panel");
            _background.RaycastTarget = false;
            _background.SetFixedSize(Size);
            _background.alignment = EAlignment.BottomLeft;
            _background.margin    = new RectOffset(20, 0, 0, 20);

            _heroHealthBar = new SharpUIProgressBar("HeroHealthBar", null, null);
            _heroHealthBar.BackgroundColor = new Color(0f, 0f, 0f, 0.5f);
            _heroHealthBar.FillColor       = Color.green;
            _heroHealthBar.Percent         = 1f;
            _heroHealthBar.SetFixedSize(340, 40);
            _heroHealthBar.alignment = EAlignment.TopRight;
            _heroHealthBar.margin    = new RectOffset(0, 0, 20, 0);
            _background.AddChild(_heroHealthBar);

            _headBackground = new SharpUIMask("HeadBackground", AppManager.AssetManager.Get <Sprite>(AssetPaths.Sprites.CircleWhite2048));
            _headBackground.ShowMaskGraphic = true;
            _headBackground.SetFixedSize((int)Size.y, (int)Size.y);
            _background.AddChild(_headBackground);

            _headSprite = new SharpUIImage("HeadSprite", AppManager.AssetManager.Get <Sprite>(_player.PlayerData.headSpritePath));
            _headSprite.SetFillSize();
            _headBackground.AddChild(_headSprite);

            _sourceLabel = new SharpUITextMeshPro("SourceLabel", _player.Source.ToString());
            _sourceLabel.SetFixedSize(50, 50);
            _sourceLabel.Font = AppManager.AssetManager.Get <TMPro.TMP_FontAsset>(AssetPaths.Fonts.GravityBoldItalic);
            _sourceLabel.AutoSizeFont();
            _sourceLabel.alignment     = EAlignment.BottomLeft;
            _sourceLabel.TextAlignment = TMPro.TextAlignmentOptions.Center;
            _background.AddChild(_sourceLabel);

            _energyMeter = new UIEnergyMeter($"{_player.name}_energy_meter");
            _energyMeter.SetEnergy(_player.Energy, _player.EnergyCap);
            _energyMeter.alignment = EAlignment.TopLeft;
            _energyMeter.margin    = new RectOffset((int)Size.y + 10, 0, 70, 0);
            _background.AddChild(_energyMeter);

            return(_background);
        }
示例#5
0
            public ChoiceButton(string name, string caption, Action onClick) : base(name, null)
            {
                SetFixedSize(Size);
                Color = new Color(0.25f, 0.25f, 0.25f, 1f);

                SharpUITextMeshPro label = new SharpUITextMeshPro($"{name}_label", caption);

                label.SetFillSize();
                label.AutoSizeFont();
                label.Font          = AppManager.AssetManager.Get <TMPro.TMP_FontAsset>(AssetPaths.Fonts.GravityBook);
                label.Color         = Color.black;
                label.TextAlignment = TMPro.TextAlignmentOptions.Center;
                label.Color         = Color.white;
                AddChild(label);

                SubscribeToEvent(EEventType.PointerClick, (object sender, EventSystemEventArgs e) =>
                {
                    onClick?.Invoke();
                });
            }
示例#6
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);
        }
示例#7
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);
        }
        // --------------------------------------------------------------------------------------------
        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);
        }