Beispiel #1
0
        public override void OnDraw(IRenderTarget target, Vector2 drawPosition)
        {
            drawPosition.X += Size.X / 2f;
            for (int i = 0; i < Options.Count; i++)
            {
                if (new Rectangle(drawPosition - new Vector2(Sizes[i].X / 2f, 0f), Sizes[i]).Contains(Mouse.Location))
                {
                    Font.DrawString(target, "<" + Options[i] + ">", Font.RenderSize, Program.Background * Opacity, drawPosition, HAlign.Center, VAlign.Top);
                }
                else
                {
                    Font.DrawString(target, Options[i], Font.RenderSize, Program.Background * Opacity, drawPosition, HAlign.Center, VAlign.Top);
                }
                drawPosition.Y += Font.RenderLineHeight * 1.5f;
            }

            base.OnDraw(target, drawPosition);
        }
Beispiel #2
0
            }   // end of UpdateBottomBarTexture()

            /// <summary>
            /// A helper function to make it easier to render the text on the bottom bar while
            /// highlighting sections of it.
            /// </summary>
            /// <returns>The width of the string just rendered.</returns>
            private int DrawText(String str, int x, int y, Color color)
            {
                BitmapFont font = BokuGame.fontBerlinSansFBDemiBold20;

                if (bottomBar.UseDropShadow)
                {
                    TextHelper.DrawStringWithShadow(font, x, y, str, color, bottomBar.DropShadowColor, bottomBar.InvertDropShadow);
                }
                else
                {
                    font.DrawString(x, y, color, str);
                }

                return(font.MeasureString(str));
            }   // end of DrawText()
Beispiel #3
0
 public override void Render(Game game, SpriteBatch batch)
 {
     font.DrawString(batch, text, (int)drawX, (int)drawY, Color4.White);
 }
Beispiel #4
0
        public override void OnDraw(IRenderTarget target, Vector2 drawPosition)
        {
            Font.DrawString(target, Text, Font.RenderSize, Program.Background * Opacity, drawPosition, hAlign, vAlign);

            base.OnDraw(target, drawPosition);
        }
Beispiel #5
0
        void ICmpRenderer.Draw(IDrawDevice device)
        {
            Canvas c = new Canvas(device, canvasBuffer);

            Vector2 size             = device.TargetSize;
            int     charOffset       = 0;
            int     charOffsetShadow = 0;

            DrawDebugStrings(device);

            // Health & Lives
            string currentPlayer;

            if (playerType == PlayerType.Spaz)
            {
                currentPlayer = "UI_CHARACTER_ICON_SPAZ";
            }
            else if (playerType == PlayerType.Lori)
            {
                currentPlayer = "UI_CHARACTER_ICON_LORI";
            }
            else
            {
                currentPlayer = "UI_CHARACTER_ICON_JAZZ";
            }

            DrawMaterial(c, currentPlayer, 36, size.Y, Alignment.BottomRight);

            string healthString = new string('|', currentHealth);

            fontSmall.DrawString(device, ref charOffsetShadow, healthString, 36 - 3 - 0.5f, size.Y - 16 + 0.5f, Alignment.BottomLeft, new ColorRgba(0f, 0f, 0f, 0.42f), 0.7f, charSpacing: 1.1f);
            fontSmall.DrawString(device, ref charOffsetShadow, healthString, 36 - 3 + 0.5f, size.Y - 16 - 0.5f, Alignment.BottomLeft, new ColorRgba(0f, 0f, 0f, 0.42f), 0.7f, charSpacing: 1.1f);
            fontSmall.DrawString(device, ref charOffset, healthString, 36 - 3, size.Y - 16, Alignment.BottomLeft, null, 0.7f, charSpacing: 1.1f);

            fontSmall.DrawString(device, ref charOffset, "x1", 36 - 4, size.Y, Alignment.BottomLeft, ColorRgba.TransparentBlack);

            // Weapon
            DrawMaterial(c, currentWeapon, size.X - 40, size.Y, Alignment.BottomRight);
            fontSmall.DrawString(device, ref charOffset, "x\x7f", size.X - 40, size.Y, Alignment.BottomLeft, ColorRgba.TransparentBlack);

            // Level Text
            if (levelText != null)
            {
                const float StillTime      = 350f;
                const float TransitionTime = 100f;
                const float TotalTime      = StillTime + TransitionTime * 2f;

                float offset;
                if (levelTextTime < TransitionTime)
                {
                    offset = MathF.Pow((TransitionTime - levelTextTime) / 12f, 3);
                }
                else if (levelTextTime > TransitionTime + StillTime)
                {
                    offset = -MathF.Pow((levelTextTime - TransitionTime - StillTime) / 12f, 3);
                }
                else
                {
                    offset = 0;
                }

                charOffsetShadow = charOffset;
                fontSmall.DrawString(device, ref charOffsetShadow, levelText, size.X * 0.5f + offset, 14f + 2.5f,
                                     Alignment.Top, new ColorRgba(0f, 0f, 0f, 0.3f), 1f, 0.72f, 0.8f, 0.8f);

                fontSmall.DrawString(device, ref charOffset, levelText, size.X * 0.5f + offset, 14f,
                                     Alignment.Top, ColorRgba.TransparentBlack, 1f, 0.72f, 0.8f, 0.8f);

                levelTextTime += Time.TimeMult;
                if (levelTextTime > TotalTime)
                {
                    levelText = null;
                }
            }
        }
Beispiel #6
0
        public static void Draw(SpriteBatch sB)
        {
            sB.Begin();

            //Draw layout
            if (uiTopBkg != null)
            {
                sB.Draw(uiTopBkg, uiTop, Color.White);
            }
            if (uiRightBkg != null)
            {
                sB.Draw(uiRightBkg, uiRight, Color.White);
            }
            if (uiRightBottomBkg != null)
            {
                sB.Draw(uiRightBottomBkg, uiRightBottom, Color.White);
            }
            if (uiRightTopBkg != null)
            {
                sB.Draw(uiRightTopBkg, uiRightTop, Color.White);
            }
            if (uiRightMiddleBkg != null)
            {
                sB.Draw(uiRightMiddleBkg, uiRightMiddle, Color.White);
            }
            if (uiHorizontalBkg != null)
            {
                sB.Draw(uiHorizontalBkg, uiHoriz1, Color.White);
                sB.Draw(uiHorizontalBkg, uiHoriz2, Color.White);
            }

            //Draw selection-specific commands
            if (SelectedObjectType == SelectedType.MultipleUnits || SelectedObjectType == SelectedType.Unit)
            {
                if (uiButtonDestroy != null)
                {
                    sB.Draw(uiButtonDestroy, uiCmd1, Color.White);
                }
                if (uiButtonStop != null)
                {
                    sB.Draw(uiButtonStop, uiCmd2, Color.White);
                }
                if (uiButtonMove != null)
                {
                    sB.Draw(uiButtonMove, uiCmd3, Color.White);
                }
                if (uiButtonAttack != null)
                {
                    sB.Draw(uiButtonAttack, uiCmd4, Color.White);
                }

                if (SelectedObject.name == "MCV")
                {
                    if (uiButtonDeploy != null)
                    {
                        sB.Draw(uiButtonDeploy, uiCmd4, Color.White);
                    }
                }
                if (SelectedObject.name == "Harvester")
                {
                    if (uiButtonHarvest != null)
                    {
                        sB.Draw(uiButtonHarvest, uiCmd4, Color.White);
                    }
                }

                if (SelectedObjectType == SelectedType.Unit)
                {
                    Texture2D pict = Textures.GetPictureReference(((Unit)SelectedObject).pictureName);
                    if (pict != null)
                    {
                        sB.Draw(pict, uiPicture, Color.White);
                    }
                }
            }
            else if (SelectedObjectType == SelectedType.Building || SelectedObjectType == SelectedType.MultipleUnits)
            {
                if (uiButtonDestroy != null)
                {
                    sB.Draw(uiButtonDestroy, uiCmd1, Color.White);
                }
                if (uiButtonRepair != null)
                {
                    sB.Draw(uiButtonRepair, uiCmd2, Color.White);
                }

                Texture2D pict = Textures.GetPictureReference(((Building)SelectedObject).pictureName);
                if (pict != null)
                {
                    sB.Draw(pict, uiPicture, Color.White);
                }

                //Available constructions
                if (SelectedObjectType == SelectedType.Building)
                {
                    Building b = (Building)SelectedObject;
                    if (b.IsBeingBuilt == false)
                    {
                        int c = 0;
                        //c can NOT exceed 8... if there are too many buildings in Dune.xml => exception is being thrown :D
                        //add xml validation someday...
                        for (int i = 0; i < b.canProduceBuildings.Count; i++)
                        {
                            sB.Draw(Textures.GetPictureReference(GlobalData.gameSettings.GetBuildingByName(b.canProduceBuildings[i]).pictureName),
                                    objectsToBuild[c], Color.White);
                            c++;
                        }
                        for (int i = 0; i < b.canProduceUnits.Count; i++)
                        {
                            sB.Draw(Textures.GetPictureReference(GlobalData.gameSettings.GetUnitByName(b.canProduceUnits[i]).pictureName),
                                    objectsToBuild[c], Color.White);
                            c++;
                        }
                    }
                }
            }

            if (SelectedObjectType == SelectedType.Building || SelectedObjectType == SelectedType.Unit)
            {
                float     ratio = SelectedObject.currentHealth / SelectedObject.maxHealth;
                Color     clr   = new Color((byte)(255 * (1 - ratio)), (byte)(255 * ratio), 0);
                Rectangle rc    = new Rectangle(uiHealth.X, uiHealth.Y, (int)(uiHealth.Width * ratio), uiHealth.Height);
                sB.Draw(Textures.GetPictureReference("MiniMap_Object"), uiHealth, Color.White);
                sB.Draw(Textures.GetPictureReference("MiniMap_Object"), rc, clr);
            }


            sB.End();

            bf.DrawString(exitButton.X, exitButton.Y, Color.Black, Properties.Resources.UI_Exit);
            string spice       = Properties.Resources.UI_Credits + Supplies.spice.ToString();
            string energy      = Properties.Resources.UI_Energy + Supplies.energy.ToString() + Properties.Resources.UI_EnergyCreditsSeparator;
            int    spiceStart  = uiTop.Right - bf.MeasureString(spice) - exitButton.X;
            int    energyStart = spiceStart - bf.MeasureString(energy);

            bf.DrawString(spiceStart, exitButton.Y, Color.Black, spice);

            bf.DrawString(energyStart, exitButton.Y, Color.Black, energy);
        }