Ejemplo n.º 1
0
        private void DrawTestAttributes(SpriteBatch spriteBatch, SpriteFont spriteFont)
        {
            if (mCharacter == null)
            {
                return;
            }

            if (healthBarHP == null)
            {
                healthBarHP     = DrawHelper.Rect2Texture(CurrentAnimation.CurrentRect.Width, 4, 2, Color.Red);
                healthBarSP     = DrawHelper.Rect2Texture(CurrentAnimation.CurrentRect.Width, 4, 2, Color.Blue);
                healthBarBorder = DrawHelper.Rect2Texture(CurrentAnimation.CurrentRect.Width + 2, 6, 1, Color.Black);
            }

            Vector2 barPos  = mPosition + new Vector2(0f, CurrentAnimation.CurrentRect.Height + 1f);                                                                // start 1px below Bottom Bound (mostly feets)
            Vector2 namePos = new Vector2(mPosition.X + (CurrentAnimation.CurrentRect.Width / 2) - (spriteFont.MeasureString(mCharacter.Name).X / 2), mPosition.Y); // BottomLeft Corner + half Width (=Bottom Center) - NameLength / 2 (=Bottom Center)

            namePos.Y -= spriteFont.MeasureString(mCharacter.Name).Y;

            // fixxing ugly swimming Names by forcing integer
            namePos.X = Math.Max(0, (int)namePos.X);
            namePos.Y = Math.Max(0, (int)namePos.Y);

            spriteBatch.DrawStringShadowed(spriteFont, mCharacter.Name, namePos, Color.DarkBlue, Color.White);

            int hpPct = (int)(((float)mCharacter.Status.Hp / (float)mCharacter.Status.MaxHp) * healthBarHP.Width);
            int SpPct = (int)(((float)mCharacter.Status.Mp / (float)mCharacter.Status.MaxMp) * healthBarSP.Width);

            spriteBatch.Draw(healthBarBorder, new Rectangle((int)barPos.X, (int)barPos.Y, healthBarBorder.Width, healthBarBorder.Height), Color.White);
            spriteBatch.Draw(healthBarHP, new Rectangle((int)barPos.X + 1, (int)barPos.Y + 1, hpPct, healthBarHP.Height), Color.White);
            spriteBatch.Draw(healthBarBorder, new Rectangle((int)barPos.X, (int)barPos.Y + healthBarBorder.Height + 1, healthBarBorder.Width, healthBarBorder.Height), Color.White);
            spriteBatch.Draw(healthBarSP, new Rectangle((int)barPos.X + 1, (int)barPos.Y + healthBarBorder.Height + 1 + 1, SpPct, healthBarSP.Height), Color.White);
        }
Ejemplo n.º 2
0
        public Vector2 GetFootPosition()
        {
            Point2D cell = DrawHelper.Vector2ToEngineCell(mPosition);

            cell.Y++;
            return(DrawHelper.EngineCellToVector(cell));
        }
Ejemplo n.º 3
0
        public Point2D GetFootCell()
        {
            Point2D cell = DrawHelper.Vector2ToEngineCell(mPosition);

            cell.Y++;
            return(cell);
        }
Ejemplo n.º 4
0
        private void RenderDisplayAnimation_OnInitialize(object sender, EventArgs e)
        {
            EngineCore.Initialize("Content", GraphicsDevice, RenderDisplayAnimation.Services);

            mSpriteBatch = new SpriteBatch(GraphicsDevice);
            mLineTexture = DrawHelper.Rect2Texture(1, 1, 0, Color.White);

            mSpriteFont = EngineCore.ContentLoader.Load <SpriteFont>(@"Fonts\Arial");
        }
Ejemplo n.º 5
0
        private void TryMove(EDirection MoveDir, TileMap TileMap)
        {
            Point2D newCell = DrawHelper.Vector2ToEngineCell(mPosition) + MoveDir.ToPoint2D();

            mCurrentDirection = MoveDir;
            if (EngineCore.InputHelper.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift) == true)
            {
                return;                 // no move, only Dir Change
            }
            if (CanMove(newCell, TileMap) == false)
            {
                return;
            }

            if (Character != null)
            {
                Character.Move(newCell);
            }
            mFinalPosition = DrawHelper.EngineCellToVector(newCell);
        }
Ejemplo n.º 6
0
        private void SplitAnmationTileset()
        {
            pnlTilesetThumbs.Controls.Clear();
            // Taken from the old code - row was 125px, animation height 96px
            tableLayoutPanel1.RowStyles[4].Height = Constants.AnimationHeight + 29;

            var imgParts     = new Point(mAnimationTileset.Width / Constants.AnimationTilesetWidth, mAnimationTileset.Height / Constants.AnimationTilesetHeight);
            var animationBmp = DrawHelper.Texture2Image(mAnimationTileset);

            mAnimationParts    = new List <System.Drawing.Bitmap>();
            mSelectedAnimation = -1;

            int padding = 2, indexTag = 0;

            for (var y = 0; y < imgParts.Y; y++)
            {
                var modY = y * (imgParts.X * Constants.AnimationWidth);
                for (var x = 0; x < imgParts.X; x++, padding += 2)
                {
                    var imgBox = new PictureBox {
                        Location = new System.Drawing.Point(padding + modY + (x * Constants.AnimationWidth), 2),
                        Image    = GetAnimationPart(animationBmp, x, y)
                    };

                    imgBox.Size      = new System.Drawing.Size(imgBox.Image.Width, imgBox.Image.Height);
                    imgBox.Tag       = (indexTag++);               // Allows to quickly detect the selection in an array
                    imgBox.Name      = string.Format("{0}_{1}_{2}", cmbTilesets.SelectedIndex, x, y);
                    imgBox.Click    += PanelTilesetImage_Click;
                    imgBox.BackColor = System.Drawing.Color.Black;

                    mAnimationParts.Add(imgBox.Image.Clone() as System.Drawing.Bitmap);
                    pnlTilesetThumbs.Controls.Add(imgBox);
                }
            }

            animationBmp.Dispose();
        }
Ejemplo n.º 7
0
        private Vector2 ClampToCell(Vector2 pos)
        {
            Point2D cellPoint = DrawHelper.Vector2ToEngineCell(pos);

            return(DrawHelper.EngineCellToVector(cellPoint));
        }