示例#1
0
        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);
        }
示例#2
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;
        }
示例#3
0
        public override void Draw(SpriteBatch batch, Vector2 screenSize)
        {
            batch.SamplerState = SamplerState.PointWrap;

            if (!BaseState.IsPointObscured(Input.MousePosition))
            {
                batch.Transform = BaseState.Camera.Transform;

                if (_tool == EditTool.PaintRadius)
                {
                    batch.Reset();
                    batch.Circle(Input.MousePosition, _radius * 4f * BaseState.Camera.Zoom, Color.White, 2);
                }
                else
                {
                    float alpha = Input.Mouse(MouseButton.Left) ? 1.0f : 0.6f;

                    if (Input.Mouse(MouseButton.Left))
                    {
                        alpha = MathHelper.Clamp(alpha + (float)Math.Sin(Game.Time * 10f) * 0.4f, 0, 1);
                    }

                    if (Input.Mouse(MouseButton.Left) && _tool == EditTool.PaintRectangle)
                    {
                        batch.Outline(new Rectangle(_rectangleToolRect.X * 16, _rectangleToolRect.Y * 16, _rectangleToolRect.Width * 16 + 16, _rectangleToolRect.Height * 16 + 16),
                                      !_eraseMode && !Game.Input.Key(Keys.E) ? Color.White * alpha : Color.DarkRed * alpha, 1, false);
                    }
                    else
                    {
                        batch.Outline(new Rectangle(SelectedTile.X * 16, SelectedTile.Y * 16, 16, 16),
                                      !_eraseMode && !Game.Input.Key(Keys.E) ? Color.White * alpha : Color.DarkRed * alpha, 1, false);
                    }

                    batch.Reset();

                    if (!(_tool == EditTool.PaintRectangle && _startingTile.X != -1))
                    {
                        string str = "(" + SelectedTile.X + ", " + SelectedTile.Y + ") ";
                        str += "[" + BaseState.Map[Layer, SelectedTile.X, SelectedTile.Y].Name(BaseState.Map.GetMetadata(Layer, SelectedTile.X, SelectedTile.Y), BaseState.Map.Info.Environment) + "]";

                        Vector2 pos = new Vector2(SelectedTile.X * 16, SelectedTile.Y * 16) * BaseState.Camera.Zoom + BaseState.Camera.Translation -
                                      new Vector2(0, 12 * BaseState.Camera.Zoom);

                        if (pos.X < 5 * BaseState.Camera.Zoom)
                        {
                            pos.X = 5 * BaseState.Camera.Zoom;
                        }

                        if (pos.Y < 5 * BaseState.Camera.Zoom)
                        {
                            pos.Y  = 5 * BaseState.Camera.Zoom;
                            pos.X += 3 * BaseState.Camera.Zoom;
                        }

                        batch.Text(
                            SpriteBatch.FontStyle.MonoBold,
                            (uint)(8 * BaseState.Camera.Zoom),
                            str,
                            pos,
                            Color.White * alpha);
                    }
                    else
                    {
                        string str = "(" + _startingTile.X + " -> " + SelectedTile.X + ", " + _startingTile.Y + " -> " + SelectedTile.Y + ")";

                        int tilesX = Math.Abs(SelectedTile.X - _startingTile.X) + 1;
                        int tilesY = Math.Abs(SelectedTile.Y - _startingTile.Y) + 1;
                        str += " [" + (tilesX * tilesY) + " tile(s)]";

                        Vector2 pos = new Vector2(Math.Min(_startingTile.X, SelectedTile.X) * 16, Math.Min(_startingTile.Y, SelectedTile.Y) * 16) * BaseState.Camera.Zoom + BaseState.Camera.Translation -
                                      new Vector2(0, 12 * BaseState.Camera.Zoom);

                        if (pos.X < 5 * BaseState.Camera.Zoom)
                        {
                            pos.X = 5 * BaseState.Camera.Zoom;
                        }

                        if (pos.Y < 5 * BaseState.Camera.Zoom)
                        {
                            pos.Y  = 5 * BaseState.Camera.Zoom;
                            pos.X += 3 * BaseState.Camera.Zoom;
                        }

                        batch.Text(
                            SpriteBatch.FontStyle.MonoBold,
                            (uint)(8 * BaseState.Camera.Zoom),
                            str,
                            pos,
                            Color.White * alpha);

                        Vector2 measure = Game.DefaultFonts.MonoBold.Measure(7, (_rectangleToolRect.Width + 1) + "x" + (_rectangleToolRect.Height + 1));
                        Vector2 sizePos = new Vector2((_rectangleToolRect.Width * 16 + 16) / 2 - measure.X / 2, (_rectangleToolRect.Height * 16 + 16) / 2 - measure.Y / 2);
                        sizePos += _rectangleToolRect.Location.ToVector2() * 16;
                        sizePos -= new Vector2(0, 1);
                        sizePos *= BaseState.Camera.Zoom;
                        sizePos += BaseState.Camera.Translation;

                        batch.Text(
                            SpriteBatch.FontStyle.MonoBold,
                            (uint)(7 * BaseState.Camera.Zoom),
                            (_rectangleToolRect.Width + 1) + "x" + (_rectangleToolRect.Height + 1),
                            sizePos,
                            Color.White * alpha * 0.6f);
                    }
                }
            }

            batch.Reset();
            batch.SamplerState = SamplerState.PointWrap;

            Menu.Draw(Game);
        }