Exemple #1
0
        public override void Render(Canvas2D canvas)
        {
            base.Render(canvas);


            if (CurrentSpriteSheet != null)
            {
                using (canvas <= Camera.Transformation)
                {
                    Rect boundingRect = Rect.FromBox(CurrentSpriteSheet.BoundingRect.LeftTop.Floored,
                                                     new Vector2(CurrentSpriteSheet.BoundingRect.Width,
                                                                 CurrentSpriteSheet.BoundingRect.Height));
                    canvas.DrawRect(boundingRect, new LineStyle(2f, LineStroke.Solid), ColorU.Red);

                    canvas.DrawSprite(Vector2.Zero, 0f, CurrentSpriteSheet.Texture.ToSprite(), ColorU.White);


                    foreach (SpriteSheetFrame frame in CurrentSpriteSheet.Frames)
                    {
                        ColorU color;


                        if (frame.Highlighted && !frame.Selected)
                        {
                            color = Configuration.HoverFrameRectColor;
                        }
                        else if (frame.Selected)
                        {
                            color = Configuration.SelectedFrameRectColor;
                        }
                        else
                        {
                            color = Configuration.FrameRectColor;
                        }

                        Rect frameBoundingRect = frame.RelativeBoundingRect;
                        canvas.DrawRect(frameBoundingRect, new LineStyle(2f, LineStroke.Solid), color);
                    }

                    _stateHandler.Draw(canvas);


                    //if (GridEnabled && Camera.Zoom > 4f)
                    //{
                    //    Point start = Camera.ScreenToWorld(Vector2.Zero).ToPoint();

                    //    for (int i = start.X; i < RenderRegion.Width; i++)
                    //    {
                    //        canvas.DrawLine(i, start.Y, i, RenderRegion.Height, ColorU.Gray.MultiplyAlpha(0.5f));
                    //    }
                    //    for (int i = start.Y; i < RenderRegion.Height; i++)
                    //    {
                    //        canvas.DrawLine(start.X, i, RenderRegion.Width, i, ColorU.Gray.MultiplyAlpha(0.5f));
                    //    }
                    //}
                }
            }

            guiManager.DrawControls(canvas);
        }
Exemple #2
0
        public void Draw(Canvas2D canvas)
        {
            if (Frames.Count == 0)
            {
                return;
            }


            if (EnableOnionSkin)
            {
                if (_currentFrameIndex > 0)
                {
                    canvas.DrawSprite(Frames[_currentFrameIndex - 1].OffSet,
                                      Frames[_currentFrameIndex - 1].SpriteFrame.Sprite,
                                      ColorU.White.MultiplyAlpha(0.5f));
                }
            }

            Frame frame = Frames[_currentFrameIndex];

            canvas.DrawSprite(frame.OffSet, frame.SpriteFrame.Sprite, ColorU.White);
        }
Exemple #3
0
 public override void Render(Canvas2D canvas, VisualEnemyUnit unit)
 {
     if (unit.EnemyUnit.State == EnemyUnit.EnemyState.Dead)
     {
         _unitExplosion.MoveTo(unit.EnemyUnit.Location * TileSize);
         _unitExplosion.Emit(BulletExplosionParticlesCount);
         return;
     }
     Vector pos = unit.EnemyUnit.Location * TileSize;
     float directionAngle = unit.EnemyUnit.Direction.Angle;
     canvas.DrawSprite(pos, directionAngle,
         unit.MovementAnimation.ToSprite(), ColorU.White);
 }
Exemple #4
0
        public void Render(Canvas2D canvas, RenderTarget target)
        {
            Vector offset = Vector.Zero;
            if (ShakeLength > 0)
            {
                offset.X = (float)(m_random.NextDouble() - 0.5) * ShakeLength;
                offset.Y = (float)(m_random.NextDouble() - 0.5) * ShakeLength;
            }

            float progress = 1;
            canvas.DrawSprite(canvas.Region + offset, target.ToSprite(),
                ColorU.White.SemiTransparent(progress));
        }
Exemple #5
0
        public override void Draw(Canvas2D canvas)
        {
            canvas.DrawFrame(AbsoluteBoundingRect, Frames[State], FrameBorder,
                             true, Color);

            if (_drawOverlay)
            {
                canvas.DrawSprite(AbsoluteBoundingRect, Overlay, ColorU.White);
            }

            var textSize = Canvas2D.MeasureText(Font, Text);

            Vector2 textDrawPos = new Vector2(AbsoluteBoundingRect.CenterX - textSize.X / 2,
                                              AbsoluteBoundingRect.CenterY - textSize.Y / 2);

            canvas.DrawText(Font, textDrawPos.Floored, Text, TextColor);


            base.Draw(canvas);
        }
Exemple #6
0
            public void Draw(Canvas2D canvas, SpriteFont font)
            {
                var drawRect = new Rect(new PointF(X, Y), Size);

                ColorU color;

                if (Highlighted && !Selected)
                {
                    color = ColorU.Red;
                }
                else if (Selected)
                {
                    color = ColorU.Yellow;
                }
                else
                {
                    color = ColorU.WhiteSmoke;
                }

                //-------------------EXTERNAL-BORDER------------------------------------------------------------
                canvas.DrawRect(drawRect.Left - LineStyleExternalRect.Width,
                                drawRect.Top - LineStyleExternalRect.Width,
                                drawRect.Width + LineStyleExternalRect.Width * 2,
                                drawRect.Height + LineStyleExternalRect.Width * 2,
                                LineStyleExternalRect,
                                color);

                //------------------INTERNAL-BORDER-------------------------------------------------------------
                canvas.DrawRect(drawRect, LineStyleInternalRect, ColorU.Black);

                //------------------BACKGROUND------------------------------------------------------------------
                canvas.DrawFilledRect(drawRect, ColorU.Black.MultiplyAlpha(0.5f));


                var frameLabelRect = new Rect(new PointF(drawRect.Left,
                                                         drawRect.Top + drawRect.Height + LineStyleExternalRect.Width +
                                                         LineStyleInternalRect.Width), new SizeF(drawRect.Width, 20f));

                //------------------LABEL------------------------------------------------------------------------
                canvas.DrawFilledRect(frameLabelRect, ColorU.Black.MultiplyAlpha(0.5f));


                //------------------SPRITE-----------------------------------------------------------------------
                if (Frame != null)
                {
                    //using (canvas[0] <= new SamplerState(Configuration.TextureFilterMode, ColorU.White))
                    //{
                    canvas.DrawText(font, new Vector2(frameLabelRect.Left + 5f, frameLabelRect.Top),
                                    string.Format("{0}", Frame.Num), ColorU.AliceBlue);
                    canvas.DrawText(font, new Vector2(frameLabelRect.Left + 30f, frameLabelRect.Top),
                                    string.Format("FrameRate: {0}", 1f / Frame.FrameDuration), ColorU.Red);
                    if (!Dragged)
                    {
                        canvas.DrawSprite(drawRect.CenterX, drawRect.CenterY, Frame.SpriteFrame.Width * Scale.X,
                                          Frame.SpriteFrame.Height * Scale.Y, Frame.SpriteFrame.Sprite, ColorU.White);
                    }
                    else
                    {
                        canvas.DrawSprite(FrameDrawPos.X, FrameDrawPos.Y, Frame.SpriteFrame.Width * Scale.X,
                                          Frame.SpriteFrame.Height * Scale.Y, Frame.SpriteFrame.Sprite,
                                          ColorU.White);
                    }

                    //}
                }
            }
Exemple #7
0
 protected override void DrawSelf(Canvas2D canvas)
 {
     canvas.DrawSprite(canvas.Region, Gfx.Instance.GetMainMenuBackground(), ColorU.White);
     canvas.DrawString(Fonts.Instance.TanksAltFont, BattleGame.ResolutionX / 2 - 2, 190,
         "Powered by PS-51", ColorU.Lime);
 }
Exemple #8
0
 public override void Render(Canvas2D canvas, VisualWallUnit unit)
 {
     canvas.DrawSprite(unit.WallUnit.Location.X * TileSize, unit.WallUnit.Location.Y * TileSize,
         unit.Sprite, ColorU.White);
 }
Exemple #9
0
        public override void Render(Canvas2D canvas, VisualPlayerUnit unit)
        {
            if (unit.PlayerUnit.State == PlayerUnit.PlayerState.Dead &&
                !unit.PlayerUnit.World.WorldState.GameComplete)
            {
                _unitExplosion.MoveTo(unit.PlayerUnit.Location * TileSize);
                _unitExplosion.Emit(BulletExplosionParticlesCount);

                ActivateShackeEffect(ShakeStrength, ShakeMinimizingSpeed);

                return;
            }
            if (unit.PlayerUnit.State != PlayerUnit.PlayerState.Dead)
            {
                Vector pos = unit.PlayerUnit.Location * TileSize;
                float directionAngle = unit.PlayerUnit.Direction.Angle;
                canvas.DrawSprite(pos, directionAngle, unit.MovementAnimation.ToSprite(), ColorU.White);
            }
        }
Exemple #10
0
        public override void Render(Canvas2D canvas, VisualBulletUnit unit)
        {
            if (unit.BulletUnit.BulletState ==
                BattleCore.Units.BulletUnit.BulletUnitState.Dead)
            {
                var possiblePlayerUnit = unit.BulletUnit.DeadOn as PlayerUnit;
                if (possiblePlayerUnit != null)
                {
                    ActivateShackeEffect(ShakeStrength, ShakeMinimizingSpeed);
                }

                _bulletExplosion.MoveTo(unit.BulletUnit.Location * TileSize);
                _bulletExplosion.Emit(BulletExplosionParticlesCount);
            }
            else
            {
                Vector pos = unit.BulletUnit.Location * TileSize;
                float directionAngle = unit.BulletUnit.Direction.Angle;
                canvas.DrawSprite(pos, directionAngle, unit.FlightAnimation.ToSprite(), ColorU.White);
            }
        }
Exemple #11
0
 public override void Render(Canvas2D canvas, VisualBonus unit)
 {
     canvas.DrawSprite(unit.BonusUnit.Location.X * TileSize, unit.BonusUnit.Location.Y * TileSize,
         unit.BonusAnimation.ToSprite(), ColorU.White);
 }
Exemple #12
0
 private void DrawGround(Canvas2D canvas)
 {
     canvas.DrawSprite(canvas.Region, Gfx.Instance.GetGroundSprite(), ColorU.White);
 }