Esempio n. 1
0
        public void InitializeButtons(Rectangle sceneRectangle)
        {
            this.sceneRectangle = sceneRectangle;

            //move camera to its initial location
            this.Camera.Position = Vector2.Zero;

            DrawProperties     button        = new DrawProperties(Content.Load <Texture2D>(@"Textures/PlatformTilesTemp"), Scene.DisplayLayer.Tile, 1.0f, 0.0f, Color.White);
            DrawProperties     buttonActor   = new DrawProperties(Content.Load <Texture2D>(@"Textures/ActorsTemp"), Scene.DisplayLayer.Tile, 1.0f, 0.0f, Color.White);
            DrawProperties     frame         = new DrawProperties(Content.Load <Texture2D>(@"Buttons/tileFrame"), Scene.DisplayLayer.TileFrame, 1.0f, 0.0f, Color.White);
            DrawTextProperties passableText  = new DrawTextProperties("x", 11, Content.Load <SpriteFont>(@"Fonts/menuButtonFont"), Color.Black, Scene.DisplayLayer.TileFrame + 0.01f, 1.0f);
            DrawTextProperties codeValueText = new DrawTextProperties("", 11, Content.Load <SpriteFont>(@"Fonts/menuButtonFont"), Color.Black, Scene.DisplayLayer.TileFrame + 0.01f, 1.0f);
            Texture2D          background    = Content.Load <Texture2D>(@"Textures/whiteRectangle");

            editorMapSquares = new EditorMapSquare[MapWidth, MapHeight];
            for (int x = 0; x < MapWidth; x++)
            {
                for (int y = 0; y < MapHeight; y++)
                {
                    editorMapSquares[x, y]                      = new EditorMapSquare(passableText, codeValueText, background, button, buttonActor, frame, new Vector2(x * TileWidth, y * TileHeight), new Vector2(TileWidth, TileHeight), TileSourceRectangle(mapCells[x, y].LayerTile), this.Camera, sceneRectangle, mapCells[x, y].LayerTile);
                    editorMapSquares[x, y].MapSquare            = mapCells[x, y];
                    editorMapSquares[x, y].ActorSourceRectangle = actorTileSheet.TileSourceRectangle(mapCells[x, y].ActorID);
                    editorMapSquares[x, y].StoreAndExecuteOnMouseDown(new Actions.SetEditorMapSquare(editorMapSquares[x, y]));
                    editorMapSquares[x, y].StoreAndExecuteOnMouseRelease(new Actions.SetEditorSelectedTileAction(editorMapSquares[x, y]));
                }
            }
        }
Esempio n. 2
0
        void DrawMinimap(SpriteBatch spriteBatch, string map)
        {
            if (miniMaps.ContainsKey(map))
            {
                return;
            }

            RenderTarget2D miniMapRenderTarget = new RenderTarget2D(graphicsDevice, (int)TileWidth * MapWidth, (int)TileHeight * MapHeight);

            spriteBatch.End();
            graphicsDevice.SetRenderTarget(miniMapRenderTarget);
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);

            for (int x = 0; x < MapWidth; x++)
            {
                for (int y = 0; y < MapHeight; y++)
                {
                    spriteBatch.Draw(tileSheet, CellScreenRectangle(x, y), TileSourceRectangle(mapCells[x, y].LayerTile),
                                     GetColor(CellScreenRectangle(x, y)), 0.0f, Vector2.Zero, SpriteEffects.None, 1.0f);

                    if (mapCells[x, y].ActorID > -1)
                    {
                        spriteBatch.Draw(actorTileSheet.TileSheet, CellScreenRectangle(x, y), actorTileSheet.TileSourceRectangle(mapCells[x, y].ActorID),
                                         GetColor(CellScreenRectangle(x, y)), 0.0f, Vector2.Zero, SpriteEffects.None, 1.0f);
                    }
                    DrawCodeBased(spriteBatch, x, y);
                }
            }
            spriteBatch.End();

            miniMaps.Add(map, (Texture2D)miniMapRenderTarget);
            activeMiniMap = map;
        }