Exemplo n.º 1
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);
        }
        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);
        }
Exemplo n.º 3
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);
        }