Exemplo n.º 1
0
        private void SetupCreepHealthBar()
        {
            var drawArea = CalculateHealthBarDrawArea();

            HealthBar = new PercentageBar(drawArea, PercentileColors,
                                          PercentageBar.HorizontalAlignment.Center);
            HealthBar.RenderLayer = 10;
        }
Exemplo n.º 2
0
        private void Draw_TopLeftUI(SpriteBatch spriteBatch)
        {
            //Draw the win progress bar
            Vector2 barPos = characterDrawPos + new Vector2(uiScale * turnPlayer.CharacterSprite.Width / 2, 0f);

            PercentageBar.Draw(spriteBatch, emptyRect, barPos, winBarDimensions, turnPlayer.Colour, Color.Gray, turnPlayer.WinThreshold, turnPlayer.WinProgress);
            string text = $"{turnPlayer.WinProgress}/{turnPlayer.WinThreshold} Wins";

            spriteBatch.DrawString(bebasSmall, text, barPos + (winBarDimensions - 0.6f * bebasSmall.MeasureString(text)) / 2, Color.White, 0f, Vector2.Zero, 0.6f, SpriteEffects.None, 0f);

            //Draw the unit cap bar.
            Vector2 unitBarPos = barPos + new Vector2(0, winBarDimensions.Y);
            int     unitCount  = grid.CountPlayerUnitsOnGrid(turnPlayer.Id);

            PercentageBar.Draw(spriteBatch, emptyRect, unitBarPos, unitBarDimensions, Color.DarkRed, Color.YellowGreen, turnPlayer.UnitCap, unitCount);
            text = $"{unitCount}/{turnPlayer.UnitCap} Units";
            spriteBatch.DrawString(bebasSmall, text, unitBarPos + (unitBarDimensions - 0.5f * bebasSmall.MeasureString(text)) / 2, Color.White, 0f, Vector2.Zero, 0.5f, SpriteEffects.None, 0f);

            //Draw the players money amount.
            moneyBox.Draw(spriteBatch);
            string  moneyText = $"{turnPlayer.Money}";
            Vector2 textSize  = bebasSmall.MeasureString(moneyText);
            Vector2 basePos   = moneyBox.GetPos() + moneyBoxDimensions / 2;

            spriteBatch.DrawString(bebasSmall, moneyText, basePos - new Vector2(0, textSize.Y / 2), Color.White);
            spriteBatch.Draw(moneyIcon,
                             position: basePos + new Vector2(textSize.X + moneyBoxDimensions.X / 35, 0) - uiScale / 2 * new Vector2(0, moneyIcon.Height),
                             scale: uiScaleVector
                             );

            //Draw the player's character.
            spriteBatch.Draw(texture: characterBoundary, position: characterDrawPos - new Vector2(3 * uiScale, 0), scale: uiScaleVector, color: turnPlayer.Colour);
            spriteBatch.Draw(texture: turnPlayer.CharacterSprite, position: characterDrawPos, scale: uiScaleVector);

            //draw end turn button
            if (endTurnButton.IsHovered)
            {
                spriteBatch.Draw(texture: endTurnButton.HoverTexture, position: endTurnButton.Position, scale: uiScaleVector);
            }
            else
            {
                spriteBatch.Draw(texture: endTurnButton.ButtonTexture, position: endTurnButton.Position, scale: uiScaleVector);
            }
            spriteBatch.DrawString(bebasSmall, "End Turn", endTurnButton.MidPoint - 0.6f * bebasSmall.MeasureString("End Turn") / 2 + new Vector2(0, 1), Color.White, 0f, Vector2.Zero, 0.6f, SpriteEffects.None, 0);

            //draw the level up unit cap button.
            levelUnitCapButton.Draw(spriteBatch, turnPlayer, moneyIcon, WindowTools.GetUpscaledValue(2f), bebasSmall, 0.6f);

            //and the ability button
            useAbilityButton.Draw(spriteBatch, turnPlayer, bebasSmall, 0.6f);

            divisorLine.Draw(spriteBatch);

            stageInfo.Draw(spriteBatch, vsAiIcon, vsPlayerIcon);

            //help button
            helpButton.Draw(spriteBatch, bebasSmall, 1f);
        }
Exemplo n.º 3
0
    void Start()
    {
        s_units.Add(this);
        m_mesh = GetComponent <MeshFilter>().mesh;
        Init();
        m_health = m_maximumHealth;
        m_mana   = m_maximumMana;

        m_healthbar = gameObject.AddComponent <PercentageBar>();
        m_healthbar.Init(m_maximumHealth, m_health, drawAbove: false, offset: new Vector2(0, 0));
        m_manabar = gameObject.AddComponent <PercentageBar>();
        m_manabar.Init(m_healthbar, m_maximumMana, m_mana, drawAbove: false, emptyColor: Color.gray, filledColor: Color.blue, offset: new Vector2(0, 1));
        SetOwnership(null);
    }
Exemplo n.º 4
0
        private void Draw_UI(SpriteBatch spriteBatch)
        {
            helpButton.Draw(spriteBatch, bebasSmall, 1f);

            //draw the players character and money if vs an AI.
            if (useAiOpponent)
            {
                moneyUiBox.Draw(spriteBatch);
                string  moneyText = $"{playerToCheckWinCondition.Money}";
                Vector2 textSize  = bebasSmall.MeasureString(moneyText);
                Vector2 basePos   = moneyUiBox.GetPos() + new Vector2(moneyBoxDimensions.X / 2f, moneyBoxDimensions.Y / 2);
                spriteBatch.DrawString(bebasSmall, moneyText, basePos - new Vector2(0, textSize.Y / 2), Color.White);
                spriteBatch.Draw(moneyIcon,
                                 position: basePos + new Vector2(textSize.X + moneyBoxDimensions.X / 35, 0) - uiScale / 2 * new Vector2(0, moneyIcon.Height),
                                 scale: uiScaleVector
                                 );

                //Draw the player's character.
                spriteBatch.Draw(texture: characterBoundary, position: characterPos[0] - new Vector2(3 * uiScale, 0), scale: uiScaleVector, color: playerToCheckWinCondition.Colour);
                spriteBatch.Draw(texture: playerToCheckWinCondition.CharacterSprite, position: characterPos[0], scale: uiScaleVector);
            }
            //otherwise, draw each players character and their win progress.
            else
            {
                //Draw each players win % bars.
                Vector2 barPos = characterPos[0] + new Vector2(uiScale * otherPlayer.CharacterSprite.Width / 2, 0f);
                PercentageBar.Draw(spriteBatch, emptyRect, barPos, winBarDimensions, otherPlayer.Colour, Color.Gray, otherPlayer.WinThreshold, otherPlayer.WinProgress);
                string text = $"{otherPlayer.WinProgress}/{otherPlayer.WinThreshold} Wins";
                spriteBatch.DrawString(bebasSmall, text, barPos + (winBarDimensions - 0.6f * bebasSmall.MeasureString(text)) / 2, Color.White, 0f, Vector2.Zero, 0.6f, SpriteEffects.None, 0f);

                Vector2 lowerBarPos = characterPos[1] + new Vector2(uiScale * playerToCheckWinCondition.CharacterSprite.Width / 2, -winBarDimensions.Y);
                PercentageBar.Draw(spriteBatch, emptyRect, lowerBarPos, winBarDimensions, playerToCheckWinCondition.Colour, Color.Gray, playerToCheckWinCondition.WinThreshold, playerToCheckWinCondition.WinProgress);
                text = $"{playerToCheckWinCondition.WinProgress}/{playerToCheckWinCondition.WinThreshold} Wins";
                spriteBatch.DrawString(bebasSmall, text, lowerBarPos + (winBarDimensions - 0.6f * bebasSmall.MeasureString(text)) / 2, Color.White, 0f, Vector2.Zero, 0.6f, SpriteEffects.None, 0f);

                //Draw each players character with their boundary (their respective colour)
                spriteBatch.Draw(texture: characterBoundary, position: characterPos[0] - new Vector2(3 * uiScale, 0), scale: uiScaleVector, color: otherPlayer.Colour);
                spriteBatch.Draw(texture: otherPlayer.CharacterSprite, position: characterPos[0], scale: uiScaleVector);

                Vector2 lowerDrawPos = characterPos[1] - new Vector2(0, playerToCheckWinCondition.CharacterSprite.Height * uiScale);
                spriteBatch.Draw(texture: characterBoundary, position: lowerDrawPos - new Vector2(3 * uiScale, 0), scale: uiScaleVector, color: playerToCheckWinCondition.Colour);
                spriteBatch.Draw(texture: playerToCheckWinCondition.CharacterSprite, position: lowerDrawPos, scale: uiScaleVector);
            }

            logDisplay.Draw(spriteBatch, actionLog.GetActionsInOrder(), players, actionLogTextures);
        }
Exemplo n.º 5
0
    public void Init(PercentageBar attachTo, float max = 0, float current = 0, bool drawAbove = true, Color emptyColor = new Color(), Color filledColor = new Color(), Vector2 offset = new Vector2(), Vector2 forceDimensions = new Vector2())
    {
        m_maximum       = max;
        m_value         = current;
        m_emptyColor    = emptyColor;
        m_filledColor   = filledColor;
        m_barAttachedTo = attachTo;
        m_drawAbove     = drawAbove;
        m_offset        = offset;

        if (forceDimensions != Vector2.zero)
        {
            m_forcedWidth  = (int)forceDimensions.x;
            m_forcedHeight = (int)forceDimensions.y;
        }

        Setup();
    }
Exemplo n.º 6
0
 private void Draw_UnitUI(SpriteBatch spriteBatch)
 {
     //need a seperate loop here to prevent units from being drawn over bars.
     foreach (Unit unit in grid.Units)
     {
         //draw health bars
         Vector2   tileCoordinate = CoordConverter.CubeToOffset(unit.CubeCoordinate);
         Texture2D unitTexture    = unitSprites[unit.GetType()];
         Vector2   pos            = grid.Tiles[(int)tileCoordinate.X, (int)tileCoordinate.Y].GetCentrePixelCoordinate(boardScale) - new Vector2(boardScale * (unitTexture.Width / 2), unitTexture.Height * boardScale);
         Color     barColor       = (players.Where(player => player.Id == unit.OwnerId).ToArray().Length == 0) ? Color.Gray : players.Where(player => player.Id == unit.OwnerId).First().Colour;
         PercentageBar.Draw(spriteBatch, emptyRect, pos - new Vector2(0, 15) * WindowTools.GetUpscaleRatio(), healthBarDimensions, barColor, Color.OrangeRed, unit.Stats.MaxHp.Value, unit.Hp);
         //draw an icon to show the unit has augmented stats if it does.
         // (these units are strong!)
         if (unit.Augmented)
         {
             spriteBatch.Draw(augmentIcon,
                              position: pos - new Vector2(0, 15) - uiScale / 2 * new Vector2(augmentIcon.Width, augmentIcon.Height / 2),
                              scale: uiScaleVector / 2);
         }
     }
 }
        //ArmourTypePowerValLabel

        /*
         * public static void UpdateArmourTypePowerVal(int val)
         * {
         *  ArmourTypePowerVal = val;
         *  ArmourTypePowerValLabel.textItem = ArmourTypePowerVal + " %";
         *  ArmourTypePowerValLabel.draw();
         * }*/

        public static void Init()
        {
            PanelWidth  = (ScreenManager.screenWidth - ScreenManager.RoomMapWindowsWidth) / 2 - 1 - 1;
            PanelHeight = ScreenManager.MapWidowHeight;

            BorderLine            = new Rectangle();
            BorderLine.BorderType = Shapes.BORDER_TYPE.Single;
            BorderLine.Create(
                new Point(0, ScreenManager.HUDHeight + 2),
                new Size((ScreenManager.screenWidth - ScreenManager.RoomMapWindowsWidth) / 2 - 1 - 1,
                         ScreenManager.MapWidowHeight),
                BorderColor, ConsoleColor.Black);

            UIPosCol = 0;
            UIPosRow = ScreenManager.HUDHeight + 2;

            //Top Title
            TitleLabel = new TextBox();
            TitleLabel.Create(
                new Point(UIPosCol + 2, UIPosRow + 1),
                new Size(PanelWidth - 4, 1),
                ConsoleColor.Yellow,
                ConsoleColor.Black);
            TitleLabel.alighnment = TextBox.ALIGN_ENUM.Left_Justify;
            TitleLabel.textItem   = "Inventory";

            //GoldItemLabel
            GoldItemLabel = new TextBox();
            GoldItemLabel.Create(
                new Point(UIPosCol + 2, UIPosRow + 3),
                new Size(PanelWidth - 4, 1),
                ConsoleColor.White, ConsoleColor.Black);
            GoldItemLabel.textItem = GoldItemStr + GoldItemVal;

            //SilverItemLabel
            SilverItemLabel = new TextBox();
            SilverItemLabel.Create(
                new Point(UIPosCol + 2, UIPosRow + 4),
                new Size(PanelWidth - 4, 1),
                ConsoleColor.White, ConsoleColor.Black);
            SilverItemLabel.textItem = SilverItemStr + SilverItemVal;

            //KeyItemLabel
            KeyItemLabel = new TextBox();
            KeyItemLabel.Create(
                new Point(UIPosCol + 2, UIPosRow + 5),
                new Size(PanelWidth - 4, 1),
                ConsoleColor.White, ConsoleColor.Black);
            KeyItemLabel.textItem = KeyItemStr + KeyItemVal;

            //ArmourItemLabel
            ArmourItemLabel = new TextBox();
            ArmourItemLabel.Create(
                new Point(UIPosCol + 2, UIPosRow + 6),
                new Size(PanelWidth - 4, 1),
                ConsoleColor.White, ConsoleColor.Black);
            ArmourItemLabel.textItem = ArmourItemStr + ArmourItemVal;

            //SwordItemLabel
            SwordItemLabel = new TextBox();
            SwordItemLabel.Create(
                new Point(UIPosCol + 2, UIPosRow + 7),
                new Size(PanelWidth - 4, 1),
                ConsoleColor.White, ConsoleColor.Black);
            SwordItemLabel.textItem = SwordItemStr + SwordItemVal;

            //HealthPortionLabel
            HealthPotionLabel = new TextBox();
            HealthPotionLabel.Create(
                new Point(UIPosCol + 2, UIPosRow + 8),
                new Size(PanelWidth - 4, 1),
                ConsoleColor.White, ConsoleColor.Black);
            HealthPotionLabel.textItem = HealthPotionLabelStr + HealthPotionLabelVal;

            //TotalItemLabel
            TotalItemLabel = new TextBox();
            TotalItemLabel.Create(
                new Point(UIPosCol + 2, UIPosRow + 9),
                new Size(PanelWidth - 4, 1),
                ConsoleColor.White, ConsoleColor.Black);
            TotalItemLabel.textItem = TotalItemStr + TotalItemVal;

            //TotalEnemyLabel
            TotalEnemyLabel = new TextBox();
            TotalEnemyLabel.Create(
                new Point(UIPosCol + 2, UIPosRow + 11),
                new Size(PanelWidth - 4, 1),
                ConsoleColor.White, ConsoleColor.Black);
            TotalEnemyLabel.textItem = TotalEnemyStr + TotalEnemyVal;

            //TotalMonsterWLabel
            TotalMonsterWLabel = new TextBox();
            TotalMonsterWLabel.Create(
                new Point(UIPosCol + 2, UIPosRow + 12),
                new Size(PanelWidth - 4, 1),
                ConsoleColor.White, ConsoleColor.Black);
            TotalMonsterWLabel.textItem = TotalMonsterWStr + TotalMonsterWVal;


            //TotalArmourWLabel
            TotalGlobinWLabel = new TextBox();
            TotalGlobinWLabel.Create(
                new Point(UIPosCol + 2, UIPosRow + 13),
                new Size(PanelWidth - 4, 1),
                ConsoleColor.White, ConsoleColor.Black);
            TotalGlobinWLabel.textItem = TotalGlobinWStr + TotalGlobinWVal;

            //WeaponTypeLabel

            /*
             * WeaponTypeLabel = new TextBox();
             * WeaponTypeLabel.Create(
             *  new Point(UIPosCol + 2, UIPosRow + 11),
             *  new Size(PanelWidth - 4, 1),
             *  ConsoleColor.Yellow, ConsoleColor.Black);
             * WeaponTypeLabel.textItem = WeaponTypeStr;
             */

            //WeaponTypeLabel
            WeaponTypeLabel = new TextBox();
            WeaponTypeLabel.Create(
                new Point(UIPosCol + 2, UIPosRow + 15),
                new Size(PanelWidth - 4, 1),
                ConsoleColor.Yellow, ConsoleColor.Black);
            WeaponTypeLabel.textItem = WeaponTypeStr;

            //WeaponTypeValLabel
            WeaponTypeValLabel = new TextBox();
            WeaponTypeValLabel.Create(
                new Point(UIPosCol + 2, UIPosRow + 16),
                new Size(PanelWidth - 4, 1),
                ConsoleColor.White, ConsoleColor.Black);
            WeaponTypeValLabel.alighnment = TextBox.ALIGN_ENUM.Centre_Justify;
            WeaponTypeValLabel.textItem   = WeaponTypeValStr;

            //WeaponTypePowerValLabel

            /*
             * WeaponTypePowerValLabel = new TextBox();
             * WeaponTypePowerValLabel.Create(
             *  new Point(UIPosCol + 2, UIPosRow + 14),
             *  new Size(PanelWidth - 4, 1),
             *  ConsoleColor.White, ConsoleColor.Black);
             * WeaponTypePowerValLabel.alighnment = TextBox.ALIGN_ENUM.Centre_Justify;
             * WeaponTypePowerValLabel.textItem = WeaponTypePowerVal + " %";
             */

            //WeaponTypeLabel
            ArmourTypeLabel = new TextBox();
            ArmourTypeLabel.Create(
                new Point(UIPosCol + 2, UIPosRow + 20),
                new Size(PanelWidth - 4, 1),
                ConsoleColor.Yellow, ConsoleColor.Black);
            ArmourTypeLabel.textItem = ArmourTypeStr;

            //ArmourTypeValLabel
            ArmourTypeValLabel = new TextBox();
            ArmourTypeValLabel.Create(
                new Point(UIPosCol + 2, UIPosRow + 21),
                new Size(PanelWidth - 4, 1),
                ConsoleColor.White, ConsoleColor.Black);
            ArmourTypeValLabel.alighnment = TextBox.ALIGN_ENUM.Centre_Justify;
            ArmourTypeValLabel.textItem   = ArmourTypeValStr;

            //ArmourTypePowerValLabel

            /*
             * ArmourTypePowerValLabel = new TextBox();
             * ArmourTypePowerValLabel.Create(
             *  new Point(UIPosCol + 2, UIPosRow + 20),
             *  new Size(PanelWidth - 4, 1),
             *  ConsoleColor.White, ConsoleColor.Black);
             * ArmourTypePowerValLabel.alighnment = TextBox.ALIGN_ENUM.Centre_Justify;
             * ArmourTypePowerValLabel.textItem = ArmourTypePowerVal + " %";
             */

            WeaponBar = new PercentageBar();
            WeaponBar.Create(
                new Point(UIPosCol + 2, UIPosRow + 18),
                new Size(PanelWidth - 4, 1),
                ConsoleColor.White,
                ConsoleColor.Black);
            WeaponBar.BarWidth = 20;
            WeaponBar.Percent  = 100;

            ArmourBar = new PercentageBar();
            ArmourBar.Create(
                new Point(UIPosCol + 2, UIPosRow + 23),
                new Size(PanelWidth - 4, 1),
                ConsoleColor.White,
                ConsoleColor.Black);
            ArmourBar.BarWidth = 20;
            ArmourBar.Percent  = 100;
        }
Exemplo n.º 8
0
 public void SetUp()
 {
     bar = new PercentageBar(Center, PercentileColors);
 }
Exemplo n.º 9
0
        /*
         * public static void UpdateArmourLevel(int level)
         * {
         *  ArmourBar.Percent = level;
         *  ArmourBar.draw();
         * }
         */

        public static void Init()
        {
            PanelWidth  = (ScreenManager.screenWidth - ScreenManager.RoomMapWindowsWidth) / 2 - 1;
            PanelHeight = ScreenManager.MapWidowHeight;

            BorderLine            = new Rectangle();
            BorderLine.BorderType = Shapes.BORDER_TYPE.Single;
            BorderLine.Create(
                new Point(
                    ((ScreenManager.screenWidth - ScreenManager.RoomMapWindowsWidth) / 2) + ScreenManager.RoomMapWindowsWidth + 1,
                    ScreenManager.HUDHeight + 2),
                new Size(
                    (ScreenManager.screenWidth - ScreenManager.RoomMapWindowsWidth) / 2 - 1,
                    ScreenManager.MapWidowHeight),
                BorderColor, ConsoleColor.Black);

            UIPosCol = ((ScreenManager.screenWidth - ScreenManager.RoomMapWindowsWidth) / 2) + ScreenManager.RoomMapWindowsWidth + 1;
            UIPosRow = ScreenManager.HUDHeight + 2;

            //Top Title
            TitleLabel = new TextBox();
            TitleLabel.Create(
                new Point(UIPosCol + 2, UIPosRow + 1),
                new Size(PanelWidth - 4, 1),
                ConsoleColor.Yellow,
                ConsoleColor.Black);
            TitleLabel.alighnment = TextBox.ALIGN_ENUM.Left_Justify;
            TitleLabel.textItem   = "Legend";

            //HealthLevelTitleLabel
            HealthLevelTitleLabel = new TextBox();
            HealthLevelTitleLabel.Create(
                new Point(UIPosCol + 2, UIPosRow + 15),
                new Size(PanelWidth - 4, 1),
                ConsoleColor.Yellow,
                ConsoleColor.Black);
            HealthLevelTitleLabel.alighnment = TextBox.ALIGN_ENUM.Left_Justify;
            HealthLevelTitleLabel.textItem   = "Health Level";

            //HealthBar

            HealthBar = new PercentageBar();
            HealthBar.Create(
                new Point(UIPosCol + 2, UIPosRow + 17),
                new Size(PanelWidth - 4, 1),
                ConsoleColor.White,
                ConsoleColor.Black);
            HealthBar.BarWidth = 20;
            HealthBar.Percent  = 100;


            //EnemyTitleLabel

            EnemyTitleLabel = new TextBox();
            EnemyTitleLabel.Create(
                new Point(UIPosCol + 2, UIPosRow + 19),
                new Size(PanelWidth - 4, 1),
                ConsoleColor.Yellow,
                ConsoleColor.Black);
            EnemyTitleLabel.alighnment = TextBox.ALIGN_ENUM.Left_Justify;
            EnemyTitleLabel.textItem   = "";


            //EnemyHealthBar

            EnemyHealthBar = new PercentageBarEx1();
            EnemyHealthBar.Create(
                new Point(UIPosCol + 2, UIPosRow + 21),
                new Size(PanelWidth - 4, 1),
                ConsoleColor.White,
                ConsoleColor.Black);
            EnemyHealthBar.BarWidth = 20;
            EnemyHealthBar.Percent  = 0;


            /* Text Box for the Options Menu */
            menutxtBox = new MenuTextBox();
            menutxtBox.Create(
                new Point(UIPosCol + 2, UIPosRow + 3),
                new Size(PanelWidth - 4, 11),
                ConsoleColor.White, ConsoleColor.Black);
            menutxtBox.lineItem = menuOptions;
        }