Esempio n. 1
0
        public void NewGame(GraphicsDevice device, Size numTilesScreen, int nLayers, Size mapSize, string saveFileName, string worldName)
        {
            bool newWorld = true;

            m_worldName = saveFileName;
            foreach (string folder in Directory.GetDirectories(GetWorldFolder()))
            {
                if (Directory.Exists(folder + "\\Maps"))
                {
                    DirectoryInfo folderInfo = new DirectoryInfo(folder);
                    if (folderInfo.Name == worldName)
                    {
                        newWorld    = false;
                        m_worldName = worldName;
                    }
                }
            }
            if (newWorld)
            {
                worldMap = new Map(mapSize.Width, mapSize.Height, device, tileMaps.TilePixSize(), numTilesScreen, nLayers);
            }
            else
            {
                LoadTileMaps(device, nLayers);
                worldMap = LoadMap(device, numTilesScreen, tileMaps.TilePixSize(), nLayers);
            }
            m_nameSaveFile = saveFileName;
        }
Esempio n. 2
0
 void HandleInputTileMapSelecter(TileMaps tileMaps)
 {
     m_tileMapSelecter.HandleInput();
     if (m_nActiveTileMap != m_tileMapSelecter.GetValue())
     {
         m_nActiveTileMap = m_tileMapSelecter.GetValue();
         Texture2D tileMap = tileMaps.GetTileMap(m_nActiveTileMap);
         m_activeTileMapSize = new Size(tileMap.Width, tileMap.Height);
         CalculateCropBounds(tileMap);
         ConfigurateScrollBars(tileMaps.TilePixSize());
     }
 }
Esempio n. 3
0
        void DrawTileBox(SpriteBatch spriteBatch, TileMaps tileMaps)
        {
            spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, SamplerState.PointWrap, DepthStencilState.Default, RasterizerState.CullNone);
            Texture2D tileMap = tileMaps.GetTileMap(m_nActiveTileMap);
            Rectangle boxRec  = new Rectangle(m_toolBarLocation.X + m_tileBoxLocation.X - m_tileBoxBorderSize, m_toolBarLocation.Y + m_tileBoxLocation.Y - m_tileBoxBorderSize, m_tileBoxSize.Width + m_tileBoxBorderSize * 2, m_tileBoxSize.Height + m_tileBoxBorderSize * 2);

            spriteBatch.Draw(m_tileBoxTexture, boxRec, null, Color.White, 0.0f, Vector2.Zero, SpriteEffects.None, 0.68f);
            Rectangle cropRec = new Rectangle(m_hScrollBarTileBox.GetValue() * tileMaps.TilePixSize(), m_vScrollBarTileBox.GetValue() * tileMaps.TilePixSize(), m_activeTileMapCropSize.Width, m_activeTileMapCropSize.Height);
            Rectangle drawRec = new Rectangle(m_toolBarLocation.X + m_tileBoxLocation.X, m_toolBarLocation.Y + m_tileBoxLocation.Y, m_activeTileMapCropSize.Width * m_tileZoom, m_activeTileMapCropSize.Height * m_tileZoom);

            spriteBatch.Draw(tileMap, drawRec, cropRec, Color.White, 0.0f, Vector2.Zero, SpriteEffects.None, 0.67f);
            spriteBatch.End();
        }
Esempio n. 4
0
        public void Draw(SpriteBatch spriteBatch, Size numTilesScreen, Point camPos, TileMaps tileMaps, Point screenOffset, Size tileScreenSize)
        {
            int tilePixelSize = tileMaps.TilePixSize();

            RenderLayerMaps(tilePixelSize, camPos, numTilesScreen, tileMaps);

            Rectangle drawRec = new Rectangle(screenOffset.X, screenOffset.Y, tileScreenSize.Width * numTilesScreen.Width, tileScreenSize.Height * numTilesScreen.Height);
            Rectangle sRec    = new Rectangle(camPos.X % tilePixelSize, camPos.Y % tilePixelSize, numTilesScreen.Width * tilePixelSize, numTilesScreen.Height * tilePixelSize);

            for (int l = 0; l < m_layerMap.Length; l++)
            {
                spriteBatch.Draw(m_layerMap[l], drawRec, sRec, Color.White, 0.0f, Vector2.Zero, SpriteEffects.None, 1.0f - (0.01f * l));
            }
        }
        public TileToolBar(Texture2D background, Texture2D floorTex, Texture2D roofTex, Texture2D tileBoxTex, Texture2D arrowLeft, Texture2D arrowRight, Texture2D openTex, Texture2D deleteTex, Texture2D openFileBGTex, Texture2D closeButtonTex, Texture2D folderTex, Texture2D fileTex, Texture2D backButtonTex, Texture2D hScrollBarBGTex, Texture2D hScrollBarButtonTex, Texture2D vScrollBarBGTex, Texture2D vScrollBarButtonTex, SpriteFont numberFont, SpriteFont fileFont, GraphicsDeviceManager graphics, int nLayers, TileMaps tileMaps, Network network)
        {
            if (tileMaps.GetTileMapCount() > 0)
            {
                m_Ready = true;
            }

            m_tileMaps = tileMaps;
            m_network  = network;

            m_backGroundTexture = background;
            m_tileBoxTexture    = tileBoxTex;

            m_toolBarSize     = new Size(graphics.PreferredBackBufferWidth, 320);
            m_toolBarLocation = new Point(0, graphics.PreferredBackBufferHeight - m_toolBarSize.Height);

            m_layerDrawDistance = 17;
            m_layerBoxLocation  = new Point(8, 48);
            m_layerButtonWidth  = 48;
            InitializeFloorLayerButtons(floorTex, nLayers);
            InitializeRoofLayerButtons(roofTex, nLayers);

            m_tileBoxSize       = new Size(640, 256);
            m_activeTileMapSize = m_tileBoxSize;
            m_nActiveTileMap    = 0;
            m_tileBoxLocation   = new Point(m_layerBoxLocation.X + 8 + m_layerButtonWidth, 48);
            m_tileZoom          = 2;
            m_tileBoxBorderSize = 5;

            m_tileMapSelecterLoc  = new Point(0, 14);
            m_tileMapSelecterSize = new Size(96, 32);
            InitializeTileMapSelecter(arrowLeft, arrowRight, numberFont);

            m_openTileMapButtonLoc    = new Point(m_tileBoxLocation.X + m_tileBoxSize.Width + 17, m_tileBoxLocation.Y);
            m_openTileMapButtonSize   = new Size(32, 32);
            m_deleteTileMapButtonLoc  = new Point(m_openTileMapButtonLoc.X, m_openTileMapButtonLoc.Y + m_openTileMapButtonSize.Height + 5);
            m_deleteTileMapButtonSize = new Size(32, 32);
            InitializeTileMapButtons(openTex, deleteTex);
            m_prevMouseState = Mouse.GetState();

            Size          openFileWindowSize = new Size(768, 512);
            List <string> fileTypes          = new List <string>();

            fileTypes.Add(".png");
            Point openFileWindowLocation = new Point(graphics.PreferredBackBufferWidth / 2 - openFileWindowSize.Width / 2, graphics.PreferredBackBufferHeight / 2 - openFileWindowSize.Height / 2);

            m_openFileWindow = new OpenFileWindow(openFileWindowLocation, openFileWindowSize,
                                                  openFileBGTex, closeButtonTex, backButtonTex, folderTex, fileTex, hScrollBarBGTex,
                                                  hScrollBarButtonTex, fileFont, System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyPictures), fileTypes);
            m_openFileWindow.WindowOkEvent += new OkHandler(OpenFileWindowOk);

            m_hScrollBarTileBoxSize = new Size(m_tileBoxSize.Width + m_tileBoxBorderSize * 2, 16);
            m_hScrollBarTileBoxLoc  = new Point(m_tileBoxLocation.X - m_tileBoxBorderSize, m_tileBoxLocation.Y + m_tileBoxSize.Height);
            m_vScrollBarTileBoxSize = new Size(16, m_tileBoxSize.Height + m_tileBoxBorderSize * 2);
            m_vScrollBarTileBoxLoc  = new Point(m_tileBoxLocation.X + m_tileBoxSize.Width, m_tileBoxLocation.Y - m_tileBoxBorderSize);
            InitializeScrollBars(hScrollBarBGTex, hScrollBarButtonTex, vScrollBarBGTex, vScrollBarButtonTex);

            Texture2D tileMap = tileMaps.GetTileMap(m_nActiveTileMap);

            CalculateCropBounds(tileMap);
            ConfigurateScrollBars(tileMaps.TilePixSize());
        }