コード例 #1
0
ファイル: Program.cs プロジェクト: teamstor/aod
        public static void BlackBorders(SpriteBatch batch)
        {
            double scale = Math.Min((double)batch.Device.Viewport.Width / (1920 / 4), (double)batch.Device.Viewport.Height / (1080 / 4));

            if (scale > 1)
            {
                scale = Math.Floor(scale);
            }

            Point     size      = new Point((int)((1920 / 4) * scale), (int)((1080 / 4) * scale));
            Rectangle rectangle = new Rectangle(batch.Device.Viewport.Width / 2 - size.X / 2, batch.Device.Viewport.Height / 2 - size.Y / 2, size.X, size.Y);

            batch.Scissor   = null;
            batch.Transform = Matrix.Identity;

            batch.Rectangle(new Rectangle(0, 0, batch.Device.Viewport.Width, rectangle.Y), Color.Black);
            batch.Rectangle(new Rectangle(0, rectangle.Y + rectangle.Height, batch.Device.Viewport.Width, batch.Device.Viewport.Height), Color.Black);
            batch.Rectangle(new Rectangle(0, 0, rectangle.X, batch.Device.Viewport.Height), Color.Black);
            batch.Rectangle(new Rectangle(rectangle.X + rectangle.Width, 0, batch.Device.Viewport.Width, batch.Device.Viewport.Height), Color.Black);
        }
コード例 #2
0
        public override void Draw(SpriteBatch batch, Vector2 screenSize)
        {
            batch.Transform    = BaseState.Camera.Transform;
            batch.SamplerState = SamplerState.PointClamp;

            Rectangle rect = new Rectangle(SelectedTile.X * 16 - 480 / 2, SelectedTile.Y * 16 - 270 / 2, 480, 270);

            batch.Outline(rect, Color.Blue * 0.8f);
            batch.Rectangle(rect, Color.Blue * 0.2f);

            batch.Texture(new Vector2(SelectedTile.X * 16, SelectedTile.Y * 16 - 16), Assets.Get <Texture2D>("player/front0.png"), Color.White * 0.6f);

            batch.Reset();
        }
コード例 #3
0
ファイル: MenuUI.cs プロジェクト: teamstor/aod
        /// <summary>
        /// Draws this MenuUI at the specified position.
        /// </summary>
        /// <param name="position">The position of the top-left corner of the menu.</param>
        /// <param name="batch">The sprite batch to draw with.</param>
        /// <param name="screenSize">The size of the screen.</param>
        public void Draw(Vector2 position, SpriteBatch batch, Vector2 screenSize)
        {
            position = new Vector2((int)position.X, (int)position.Y);

            if (DrawBackground)
            {
                batch.Texture(position, Parent.Assets.Get <Texture2D>("ui/menu_corner.png"), Color.White * _alpha, null, null, 0, null, SpriteEffects.None);
                batch.Texture(position + new Vector2((int)Area.Value.X - 7, 0), Parent.Assets.Get <Texture2D>("ui/menu_corner.png"), Color.White * _alpha, null, null, 0, null, SpriteEffects.FlipHorizontally);
                batch.Texture(position + new Vector2(0, (int)Area.Value.Y - 7), Parent.Assets.Get <Texture2D>("ui/menu_corner.png"), Color.White * _alpha, null, null, 0, null, SpriteEffects.FlipVertically);
                batch.Texture(position + new Vector2((int)Area.Value.X - 7, (int)Area.Value.Y - 7), Parent.Assets.Get <Texture2D>("ui/menu_corner.png"), Color.White * _alpha, null, null, 0, null, SpriteEffects.FlipHorizontally | SpriteEffects.FlipVertically);
            }

            Vector2 fillArea = Area.Value - new Vector2(7 * 2, 7 * 2);

            if (DrawBackground)
            {
                batch.Rectangle(new Rectangle((int)position.X + 7, (int)position.Y + 7, (int)fillArea.X, (int)fillArea.Y), new Color(68, 68, 242) * _alpha);
            }

            batch.SamplerState = SamplerState.PointWrap;

            if (DrawBackground)
            {
                batch.Texture(new Rectangle((int)position.X + 7, (int)position.Y, (int)fillArea.X, 7), Parent.Assets.Get <Texture2D>("ui/menu_top.png"), Color.White * _alpha);
                batch.Texture(new Rectangle((int)position.X + 7, (int)position.Y + (int)Area.Value.Y - 7, (int)fillArea.X, 7), Parent.Assets.Get <Texture2D>("ui/menu_top.png"), Color.White * _alpha, null, 0, null, SpriteEffects.FlipVertically);

                batch.Texture(new Rectangle((int)position.X, (int)position.Y + 7, 7, (int)fillArea.Y), Parent.Assets.Get <Texture2D>("ui/menu_side.png"), Color.White * _alpha);
                batch.Texture(new Rectangle((int)position.X + (int)Area.Value.X - 7, (int)position.Y + 7, 7, (int)fillArea.Y), Parent.Assets.Get <Texture2D>("ui/menu_side.png"), Color.White * _alpha, null, 0, null, SpriteEffects.FlipHorizontally);
            }

            batch.Scissor = new Rectangle((int)position.X + 7, (int)position.Y + 7, (int)fillArea.X, (int)fillArea.Y);
            Vector2 transformLT = Vector2.Transform(batch.Scissor.Value.Location.ToVector2(), batch.Transform);
            Vector2 transformRB = Vector2.Transform(new Vector2(batch.Scissor.Value.Right, batch.Scissor.Value.Bottom), batch.Transform);

            batch.Scissor = new Rectangle(
                (int)transformLT.X,
                (int)transformLT.Y,
                (int)(transformRB.X - transformLT.X),
                (int)(transformRB.Y - transformLT.Y));
            if (Area.Value == Area.TargetValue && _alpha.Value == 1)
            {
                SelectedPage.DrawInsideArea(batch,
                                            new Rectangle((int)position.X + 7, (int)position.Y + 7, (int)fillArea.X, (int)fillArea.Y));
            }

            batch.Scissor = null;
        }
コード例 #4
0
ファイル: OpenMapState.cs プロジェクト: teamstor/aod
        public override void Draw(SpriteBatch batch, Vector2 screenSize)
        {
            _lastState.Draw(batch, screenSize);
            batch.Rectangle(new Rectangle(0, 0, (int)screenSize.X, (int)screenSize.Y), Color.Black * 0.85f);

            Vector2 measure = Game.DefaultFonts.MonoBold.Measure(24, _targetMap + "|");

            batch.Text(SpriteBatch.FontStyle.MonoBold, 24, _targetMap + (Game.TotalFixedUpdates % 40 > 20 ? "|" : " "), new Vector2(screenSize.X / 2 - measure.X / 2, 180), Color.White);

            string match  = FindClosestMatch();
            bool   exists = File.Exists(match);
            string msg    = match.Replace("\\", "/") + (Map.IsPreloaded(match) ? " (preloaded)" : "");

            if (!exists)
            {
                msg = "No map with name \"" + _targetMap + "\" found in any folder";
            }

            measure = Game.DefaultFonts.MonoBold.Measure(14, msg);
            batch.Text(SpriteBatch.FontStyle.MonoBold, 14, msg, new Vector2(screenSize.X / 2 - measure.X / 2, 210), exists ? Color.White * 0.7f : Color.Red * 0.7f);
        }
コード例 #5
0
        public override void Draw(SpriteBatch batch, Vector2 screenSize)
        {
            batch.Transform = Camera.Transform;

            int x, y;

            for (x = 0; x < Field.Width; x++)
            {
                for (y = 0; y < Field.Height; y++)
                {
                    string texture = "empty.png";

                    if (Field.FlagAt(x, y) == FlagType.Flag)
                    {
                        texture = "flag.png";
                    }
                    if (Field.FlagAt(x, y) == FlagType.FlagVisual)
                    {
                        texture = "flagvisual.png";
                    }

                    if (Field.IsRevealed(x, y))
                    {
                        texture = "revealed.png";
                    }

                    // TODO: när man förlorar revealas alla
                    if (Field.IsRevealed(x, y) && Field[x, y])
                    {
                        texture = "nuke.png";
                    }

                    Rectangle rect = new Rectangle(
                        x * (TILE_SIZE + 2), y * (TILE_SIZE + 2),
                        TILE_SIZE, TILE_SIZE);

                    batch.Texture(rect,
                                  Assets.Get <Texture2D>("placeholder/tiles/" + texture),
                                  Color.White);

                    if (Field.IsRevealed(x, y) && !Field[x, y] && Field.SurroundingNukesAt(x, y) > 0)
                    {
                        Vector2 measure = Game.DefaultFonts.Bold.Measure(32, Field.SurroundingNukesAt(x, y).ToString());
                        batch.Text(FontStyle.Bold, 32, Field.SurroundingNukesAt(x, y).ToString(), rect.Center.ToVector2() - measure / 2, Color.Red);
                    }
                }
            }

            if (MenuTile != new Point(-1, -1))
            {
                Rectangle rect = new Rectangle(MenuTile.X * (TILE_SIZE + 2), MenuTile.Y * (TILE_SIZE + 2), (TILE_SIZE + 2) * 2 + TILE_SIZE, TILE_SIZE);

                int oldX = rect.X;

                if (Vector2.Transform(new Vector2(rect.Right, 0), Camera.TransformWithoutScale).X >= screenSize.X)
                {
                    rect.X -= (TILE_SIZE + 2) * 2;
                }

                batch.Rectangle(rect, Color.Black);
                batch.Outline(rect, Color.White, 3, false);
                batch.Outline(new Rectangle(oldX, rect.Y, TILE_SIZE, TILE_SIZE), Color.White, 3, false);

                batch.Texture(new Rectangle(rect.X + 2, rect.Y + 2, TILE_SIZE - 4, TILE_SIZE - 4), Assets.Get <Texture2D>("icons/explode.png"),
                              Color.White * (Field.FlagAt(MenuTile.X, MenuTile.Y) == FlagType.Flag ? 0.6f : 1.0f));
                batch.Texture(new Rectangle(rect.X + 4 + TILE_SIZE, rect.Y + 2, TILE_SIZE - 4, TILE_SIZE - 4), Assets.Get <Texture2D>("icons/flag.png"),
                              Color.White * (Field.FlagsLeft == 0 && Field.FlagAt(MenuTile.X, MenuTile.Y) != FlagType.Flag ? 0.6f : 1.0f));
                batch.Texture(new Rectangle(rect.X + 6 + TILE_SIZE * 2, rect.Y + 2, TILE_SIZE - 4, TILE_SIZE - 4), Assets.Get <Texture2D>("icons/flagvisual.png"),
                              Color.White);
            }

            batch.Transform = Matrix.Identity;

            batch.Rectangle(new Rectangle(0, 0, (int)screenSize.X, 180), Color.DarkGray);
            batch.Outline(new Rectangle(0, 0, (int)screenSize.X, 180), Color.White, 2, false);

            batch.SamplerState = SamplerState.PointClamp;

            string reaction = "idle.png";

            switch (_currentFace)
            {
            case FaceReaction.Hover:
                reaction = "hover.png";
                break;

            case FaceReaction.Win:
                reaction = "win.png";
                break;

            case FaceReaction.Lose:
                reaction = "lose.png";
                break;
            }

            batch.Texture(new Rectangle((int)screenSize.X / 2 - 64 / 2, 40, 64, 64), Assets.Get <Texture2D>("placeholder/reactions/" + reaction), Color.White);
            batch.SamplerState = SamplerState.LinearClamp;
        }
コード例 #6
0
 public override void Draw(SpriteBatch batch, Vector2 screenSize)
 {
     batch.Rectangle(new Rectangle(0, 0, (int)screenSize.X, (int)screenSize.Y), Color.Black * 0.6f);
 }