Exemplo n.º 1
0
        // Load content
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(Game.GraphicsDevice);
            font        = Game.Content.Load <SpriteFont>(@"myFont");
            dot         = Game.Content.Load <Texture2D>(@"images/dot");
            moveImage   = Game.Content.Load <Texture2D>(@"images/move");
            shootImage  = Game.Content.Load <Texture2D>(@"images/shoot");
            quitImage   = Game.Content.Load <Texture2D>(@"images/quit");

            // Get center of game window
            int x = Game.Window.ClientBounds.Width / 2 - 75 / 2;
            int y = Game.Window.ClientBounds.Height / 2 - 66 / 2;

            // Temporary initialization of array of positions
            Vector2[] temp =
            {
                new Vector2(x,                                         y + 75),
                new Vector2((float)(x - 75 * Math.Sin(.4 * Math.PI)),  (float)(y + 75 * Math.Cos(.4 * Math.PI))),
                new Vector2((float)(x - 75 * Math.Sin(.2 * Math.PI)),  (float)(y - 75 * Math.Cos(.2 * Math.PI))),
                new Vector2((float)(x + 75 * Math.Sin(.2 * Math.PI)),  (float)(y - 75 * Math.Cos(.2 * Math.PI))),
                new Vector2((float)(x + 75 * Math.Sin(.4 * Math.PI)),  (float)(y + 75 * Math.Cos(.4 * Math.PI))),
                new Vector2(x,                                         y - 150),
                new Vector2((float)(x + 150 * Math.Sin(.4 * Math.PI)), (float)(y - 150 * Math.Cos(.4 * Math.PI))),
                new Vector2((float)(x + 150 * Math.Sin(.2 * Math.PI)), (float)(y + 150 * Math.Cos(.2 * Math.PI))),
                new Vector2((float)(x - 150 * Math.Sin(.2 * Math.PI)), (float)(y + 150 * Math.Cos(.2 * Math.PI))),
                new Vector2((float)(x - 150 * Math.Sin(.4 * Math.PI)), (float)(y - 150 * Math.Cos(.4 * Math.PI))),
                new Vector2(x,                                         y - 255),
                new Vector2((float)(x + 255 * Math.Sin(.4 * Math.PI)), (float)(y - 255 * Math.Cos(.4 * Math.PI))),
                new Vector2((float)(x + 255 * Math.Sin(.2 * Math.PI)), (float)(y + 255 * Math.Cos(.2 * Math.PI))),
                new Vector2((float)(x - 255 * Math.Sin(.2 * Math.PI)), (float)(y + 255 * Math.Cos(.2 * Math.PI))),
                new Vector2((float)(x - 255 * Math.Sin(.4 * Math.PI)), (float)(y - 255 * Math.Cos(.4 * Math.PI))),
                new Vector2(x - 98,                                    y - 140),
                new Vector2(x + 98,                                    y - 140),
                new Vector2(x + 160,                                   y + 50),
                new Vector2(x - 160,                                   y + 50),
                new Vector2(x,                                         y + 160)
            };

            // Copy temp to positions
            positions = temp;

            // Add game pieces
            // Inner Pieces
            pieces.Add(new PieceSprite(
                           Game.Content.Load <Texture2D>(@"images/piece"),
                           positions[0],
                           new Point(75, 66),
                           10,
                           new Point(0, 0),
                           new Point(2, 5),
                           Vector2.Zero,
                           font,
                           Board.Map[1]
                           ));
            pieces.Add(new PieceSprite(
                           Game.Content.Load <Texture2D>(@"images/piece"),
                           positions[1],
                           new Point(75, 66),
                           10,
                           new Point(0, 0),
                           new Point(2, 5),
                           Vector2.Zero,
                           font,
                           Board.Map[2]
                           ));
            pieces.Add(new PieceSprite(
                           Game.Content.Load <Texture2D>(@"images/piece"),
                           positions[2],
                           new Point(75, 66),
                           10,
                           new Point(0, 0),
                           new Point(2, 5),
                           Vector2.Zero,
                           font,
                           Board.Map[3]
                           ));
            pieces.Add(new PieceSprite(
                           Game.Content.Load <Texture2D>(@"images/piece"),
                           positions[3],
                           new Point(75, 66),
                           10,
                           new Point(0, 0),
                           new Point(2, 5),
                           Vector2.Zero,
                           font,
                           Board.Map[4]
                           ));
            pieces.Add(new PieceSprite(
                           Game.Content.Load <Texture2D>(@"images/piece"),
                           positions[4],
                           new Point(75, 66),
                           10,
                           new Point(0, 0),
                           new Point(2, 5),
                           Vector2.Zero,
                           font,
                           Board.Map[5]
                           ));

            // Middle
            pieces.Add(new PieceSprite(
                           Game.Content.Load <Texture2D>(@"images/piece"),
                           positions[5],
                           new Point(75, 66),
                           10,
                           new Point(0, 0),
                           new Point(2, 5),
                           Vector2.Zero,
                           font,
                           Board.Map[6]
                           ));
            pieces.Add(new PieceSprite(
                           Game.Content.Load <Texture2D>(@"images/piece"),
                           positions[6],
                           new Point(75, 66),
                           10,
                           new Point(0, 0),
                           new Point(2, 5),
                           Vector2.Zero,
                           font,
                           Board.Map[7]
                           ));
            pieces.Add(new PieceSprite(
                           Game.Content.Load <Texture2D>(@"images/piece"),
                           positions[7],
                           new Point(75, 66),
                           10,
                           new Point(0, 0),
                           new Point(2, 5),
                           Vector2.Zero,
                           font,
                           Board.Map[8]
                           ));
            pieces.Add(new PieceSprite(
                           Game.Content.Load <Texture2D>(@"images/piece"),
                           positions[8],
                           new Point(75, 66),
                           10,
                           new Point(0, 0),
                           new Point(2, 5),
                           Vector2.Zero,
                           font,
                           Board.Map[9]
                           ));
            pieces.Add(new PieceSprite(
                           Game.Content.Load <Texture2D>(@"images/piece"),
                           positions[9],
                           new Point(75, 66),
                           10,
                           new Point(0, 0),
                           new Point(2, 5),
                           Vector2.Zero,
                           font,
                           Board.Map[10]
                           ));

            pieces.Add(new PieceSprite(
                           Game.Content.Load <Texture2D>(@"images/piece"),
                           positions[15],
                           new Point(75, 66),
                           10,
                           new Point(0, 0),
                           new Point(2, 5),
                           Vector2.Zero,
                           font,
                           Board.Map[16]
                           ));
            pieces.Add(new PieceSprite(
                           Game.Content.Load <Texture2D>(@"images/piece"),
                           positions[16],
                           new Point(75, 66),
                           10,
                           new Point(0, 0),
                           new Point(2, 5),
                           Vector2.Zero,
                           font,
                           Board.Map[17]
                           ));
            pieces.Add(new PieceSprite(
                           Game.Content.Load <Texture2D>(@"images/piece"),
                           positions[17],
                           new Point(75, 66),
                           10,
                           new Point(0, 0),
                           new Point(2, 5),
                           Vector2.Zero,
                           font,
                           Board.Map[18]
                           ));
            pieces.Add(new PieceSprite(
                           Game.Content.Load <Texture2D>(@"images/piece"),
                           positions[18],
                           new Point(75, 66),
                           10,
                           new Point(0, 0),
                           new Point(2, 5),
                           Vector2.Zero,
                           font,
                           Board.Map[19]
                           ));
            pieces.Add(new PieceSprite(
                           Game.Content.Load <Texture2D>(@"images/piece"),
                           positions[19],
                           new Point(75, 66),
                           10,
                           new Point(0, 0),
                           new Point(2, 5),
                           Vector2.Zero,
                           font,
                           Board.Map[20]
                           ));

            // Outer
            pieces.Add(new PieceSprite(
                           Game.Content.Load <Texture2D>(@"images/piece"),
                           positions[10],
                           new Point(75, 66),
                           10,
                           new Point(0, 0),
                           new Point(2, 5),
                           Vector2.Zero,
                           font,
                           Board.Map[11]
                           ));
            pieces.Add(new PieceSprite(
                           Game.Content.Load <Texture2D>(@"images/piece"),
                           positions[11],
                           new Point(75, 66),
                           10,
                           new Point(0, 0),
                           new Point(2, 5),
                           Vector2.Zero,
                           font,
                           Board.Map[12]
                           ));
            pieces.Add(new PieceSprite(
                           Game.Content.Load <Texture2D>(@"images/piece"),
                           positions[12],
                           new Point(75, 66),
                           10,
                           new Point(0, 0),
                           new Point(2, 5),
                           Vector2.Zero,
                           font,
                           Board.Map[13]
                           ));
            pieces.Add(new PieceSprite(
                           Game.Content.Load <Texture2D>(@"images/piece"),
                           positions[13],
                           new Point(75, 66),
                           10,
                           new Point(0, 0),
                           new Point(2, 5),
                           Vector2.Zero,
                           font,
                           Board.Map[14]
                           ));
            pieces.Add(new PieceSprite(
                           Game.Content.Load <Texture2D>(@"images/piece"),
                           positions[14],
                           new Point(75, 66),
                           10,
                           new Point(0, 0),
                           new Point(2, 5),
                           Vector2.Zero,
                           font,
                           Board.Map[15]
                           ));

            // Draw buttons
            int vPos = Game.Window.ClientBounds.Height - 80;

            move = new ButtonSprite(
                moveImage,
                new Vector2(0, vPos),
                new Point(80, 80),
                0,
                new Point(0, 0),
                new Point(1, 1),
                Vector2.Zero,
                font
                );

            shoot = new ButtonSprite(
                shootImage,
                new Vector2(90, vPos),
                new Point(80, 80),
                0,
                new Point(0, 0),
                new Point(1, 1),
                Vector2.Zero,
                font
                );

            quit = new ButtonSprite(
                quitImage,
                new Vector2(180, vPos),
                new Point(80, 80),
                0,
                new Point(0, 0),
                new Point(1, 1),
                Vector2.Zero,
                font
                );

            // Add text border
            border = new BorderSprite(
                Game.Content.Load <Texture2D>(@"images/border"),
                new Vector2(Game.Window.ClientBounds.Width - 500, Game.Window.ClientBounds.Height - 100),
                new Point(500, 100),
                0,
                new Point(0, 0),
                new Point(1, 1),
                Vector2.Zero,
                font
                );

            base.LoadContent();
        }
Exemplo n.º 2
0
        // Load content
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(Game.GraphicsDevice);
            font = Game.Content.Load<SpriteFont>(@"myFont");
            dot = Game.Content.Load<Texture2D>(@"images/dot");
            moveImage = Game.Content.Load<Texture2D>(@"images/move");
            shootImage = Game.Content.Load<Texture2D>(@"images/shoot");
            quitImage = Game.Content.Load<Texture2D>(@"images/quit");

            // Get center of game window
            int x = Game.Window.ClientBounds.Width / 2 - 75 / 2;
            int y = Game.Window.ClientBounds.Height / 2 - 66 / 2;

            // Temporary initialization of array of positions
            Vector2[] temp = {
                new Vector2(x, y + 75),
                new Vector2((float)(x - 75 * Math.Sin(.4 * Math.PI)), (float)(y + 75 * Math.Cos(.4 * Math.PI))),
                new Vector2((float)(x - 75 * Math.Sin(.2 * Math.PI)), (float)(y - 75 * Math.Cos(.2 * Math.PI))),
                new Vector2((float)(x + 75 * Math.Sin(.2 * Math.PI)), (float)(y - 75 * Math.Cos(.2 * Math.PI))),
                new Vector2((float)(x + 75 * Math.Sin(.4 * Math.PI)), (float)(y + 75 * Math.Cos(.4 * Math.PI))),
                new Vector2(x, y - 150),
                new Vector2((float)(x + 150 * Math.Sin(.4 * Math.PI)), (float)(y - 150 * Math.Cos(.4 * Math.PI))),
                new Vector2((float)(x + 150 * Math.Sin(.2 * Math.PI)), (float)(y + 150 * Math.Cos(.2 * Math.PI))),
                new Vector2((float)(x - 150 * Math.Sin(.2 * Math.PI)), (float)(y + 150 * Math.Cos(.2 * Math.PI))),
                new Vector2((float)(x - 150 * Math.Sin(.4 * Math.PI)), (float)(y - 150 * Math.Cos(.4 * Math.PI))),
                new Vector2(x, y - 255),
                new Vector2((float)(x + 255 * Math.Sin(.4 * Math.PI)), (float)(y - 255 * Math.Cos(.4 * Math.PI))),
                new Vector2((float)(x + 255 * Math.Sin(.2 * Math.PI)), (float)(y + 255 * Math.Cos(.2 * Math.PI))),
                new Vector2((float)(x - 255 * Math.Sin(.2 * Math.PI)), (float)(y + 255 * Math.Cos(.2 * Math.PI))),
                new Vector2((float)(x - 255 * Math.Sin(.4 * Math.PI)), (float)(y - 255 * Math.Cos(.4 * Math.PI))),
                new Vector2(x - 98, y - 140),
                new Vector2(x + 98, y - 140),
                new Vector2(x + 160, y + 50),
                new Vector2(x - 160, y + 50),
                new Vector2(x, y + 160)
            };

            // Copy temp to positions
            positions = temp;

            // Add game pieces
            // Inner Pieces
            pieces.Add(new PieceSprite(
                    Game.Content.Load<Texture2D>(@"images/piece"),
                    positions[0],
                    new Point(75,66),
                    10,
                    new Point(0, 0),
                    new Point(2, 5),
                    Vector2.Zero,
                    font,
                    Board.Map[1]
                ));
            pieces.Add(new PieceSprite(
                    Game.Content.Load<Texture2D>(@"images/piece"),
                    positions[1],
                    new Point(75, 66),
                    10,
                    new Point(0, 0),
                    new Point(2, 5),
                    Vector2.Zero,
                    font,
                    Board.Map[2]
                ));
            pieces.Add(new PieceSprite(
                    Game.Content.Load<Texture2D>(@"images/piece"),
                    positions[2],
                    new Point(75, 66),
                    10,
                    new Point(0, 0),
                    new Point(2, 5),
                    Vector2.Zero,
                    font,
                    Board.Map[3]
                ));
            pieces.Add(new PieceSprite(
                    Game.Content.Load<Texture2D>(@"images/piece"),
                    positions[3],
                    new Point(75, 66),
                    10,
                    new Point(0, 0),
                    new Point(2, 5),
                    Vector2.Zero,
                    font,
                    Board.Map[4]
                ));
            pieces.Add(new PieceSprite(
                    Game.Content.Load<Texture2D>(@"images/piece"),
                    positions[4],
                    new Point(75, 66),
                    10,
                    new Point(0, 0),
                    new Point(2, 5),
                    Vector2.Zero,
                    font,
                    Board.Map[5]
                ));

            // Middle
            pieces.Add(new PieceSprite(
                    Game.Content.Load<Texture2D>(@"images/piece"),
                    positions[5],
                    new Point(75, 66),
                    10,
                    new Point(0, 0),
                    new Point(2, 5),
                    Vector2.Zero,
                    font,
                    Board.Map[6]
                ));
            pieces.Add(new PieceSprite(
                    Game.Content.Load<Texture2D>(@"images/piece"),
                    positions[6],
                    new Point(75, 66),
                    10,
                    new Point(0, 0),
                    new Point(2, 5),
                    Vector2.Zero,
                    font,
                    Board.Map[7]
                ));
            pieces.Add(new PieceSprite(
                    Game.Content.Load<Texture2D>(@"images/piece"),
                    positions[7],
                    new Point(75, 66),
                    10,
                    new Point(0, 0),
                    new Point(2, 5),
                    Vector2.Zero,
                    font,
                    Board.Map[8]
                ));
            pieces.Add(new PieceSprite(
                    Game.Content.Load<Texture2D>(@"images/piece"),
                    positions[8],
                    new Point(75, 66),
                    10,
                    new Point(0, 0),
                    new Point(2, 5),
                    Vector2.Zero,
                    font,
                    Board.Map[9]
                ));
            pieces.Add(new PieceSprite(
                    Game.Content.Load<Texture2D>(@"images/piece"),
                    positions[9],
                    new Point(75, 66),
                    10,
                    new Point(0, 0),
                    new Point(2, 5),
                    Vector2.Zero,
                    font,
                    Board.Map[10]
                ));

            pieces.Add(new PieceSprite(
                    Game.Content.Load<Texture2D>(@"images/piece"),
                    positions[15],
                    new Point(75, 66),
                    10,
                    new Point(0, 0),
                    new Point(2, 5),
                    Vector2.Zero,
                    font,
                    Board.Map[16]
                ));
            pieces.Add(new PieceSprite(
                    Game.Content.Load<Texture2D>(@"images/piece"),
                    positions[16],
                    new Point(75, 66),
                    10,
                    new Point(0, 0),
                    new Point(2, 5),
                    Vector2.Zero,
                    font,
                    Board.Map[17]
                ));
            pieces.Add(new PieceSprite(
                    Game.Content.Load<Texture2D>(@"images/piece"),
                    positions[17],
                    new Point(75, 66),
                    10,
                    new Point(0, 0),
                    new Point(2, 5),
                    Vector2.Zero,
                    font,
                    Board.Map[18]
                ));
            pieces.Add(new PieceSprite(
                    Game.Content.Load<Texture2D>(@"images/piece"),
                    positions[18],
                    new Point(75, 66),
                    10,
                    new Point(0, 0),
                    new Point(2, 5),
                    Vector2.Zero,
                    font,
                    Board.Map[19]
                ));
            pieces.Add(new PieceSprite(
                    Game.Content.Load<Texture2D>(@"images/piece"),
                    positions[19],
                    new Point(75, 66),
                    10,
                    new Point(0, 0),
                    new Point(2, 5),
                    Vector2.Zero,
                    font,
                    Board.Map[20]
                ));

            // Outer
            pieces.Add(new PieceSprite(
                    Game.Content.Load<Texture2D>(@"images/piece"),
                    positions[10],
                    new Point(75, 66),
                    10,
                    new Point(0, 0),
                    new Point(2, 5),
                    Vector2.Zero,
                    font,
                    Board.Map[11]
                ));
            pieces.Add(new PieceSprite(
                    Game.Content.Load<Texture2D>(@"images/piece"),
                    positions[11],
                    new Point(75, 66),
                    10,
                    new Point(0, 0),
                    new Point(2, 5),
                    Vector2.Zero,
                    font,
                    Board.Map[12]
                ));
            pieces.Add(new PieceSprite(
                    Game.Content.Load<Texture2D>(@"images/piece"),
                    positions[12],
                    new Point(75, 66),
                    10,
                    new Point(0, 0),
                    new Point(2, 5),
                    Vector2.Zero,
                    font,
                    Board.Map[13]
                ));
            pieces.Add(new PieceSprite(
                    Game.Content.Load<Texture2D>(@"images/piece"),
                    positions[13],
                    new Point(75, 66),
                    10,
                    new Point(0, 0),
                    new Point(2, 5),
                    Vector2.Zero,
                    font,
                    Board.Map[14]
                ));
            pieces.Add(new PieceSprite(
                    Game.Content.Load<Texture2D>(@"images/piece"),
                    positions[14],
                    new Point(75, 66),
                    10,
                    new Point(0, 0),
                    new Point(2, 5),
                    Vector2.Zero,
                    font,
                    Board.Map[15]
                ));

            // Draw buttons
            int vPos = Game.Window.ClientBounds.Height - 80;
            move = new ButtonSprite(
                moveImage,
                new Vector2(0, vPos),
                new Point(80,80),
                0,
                new Point(0, 0),
                new Point(1,1),
                Vector2.Zero,
                font
            );

            shoot = new ButtonSprite(
                shootImage,
                new Vector2(90, vPos),
                new Point(80, 80),
                0,
                new Point(0, 0),
                new Point(1, 1),
                Vector2.Zero,
                font
            );

            quit = new ButtonSprite(
                quitImage,
                new Vector2(180, vPos),
                new Point(80, 80),
                0,
                new Point(0, 0),
                new Point(1, 1),
                Vector2.Zero,
                font
            );

            // Add text border
            border = new BorderSprite(
                Game.Content.Load<Texture2D>(@"images/border"),
                new Vector2(Game.Window.ClientBounds.Width - 500, Game.Window.ClientBounds.Height - 100),
                new Point(500, 100),
                0,
                new Point(0, 0),
                new Point(1, 1),
                Vector2.Zero,
                font
            );

            base.LoadContent();
        }