예제 #1
0
        public override void Draw(GameTime gameTime, Camera camera)
        {
            if (!IsActive)
            {
                return;
            }

            ScreenManager.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, ScreenManager.viewMatrix);

            ScreenManager.SpriteBatch.Draw(Default, Sky, WorldColor);
            background.Draw(gameTime, camera);


            for (int i = ScreenManager.Point_Y1; i < ScreenManager.Point_Y2; i++)
            {
                for (int j = ScreenManager.Point_X1; j < ScreenManager.Point_X2; j++)
                {
                    map[i, j].Draw(gameTime, WorldColor);
                }
            }

            foreach (Item item in Items)
            {
                item.Draw(gameTime, WorldColor);
            }

            ScreenManager.SpriteBatch.End();

            UInterface.Draw(gameTime, camera);

            mapEditorMenu.Draw(gameTime, camera);
        }
예제 #2
0
        public override void ProcessingOfClicks(GameTime gameTime, Camera camera)
        {
            if (!IsActive)
            {
                return;
            }

            UInterface.ProcessingOfClicks(gameTime, camera);

            if (UInterface.ClickDetected)
            {
                return;
            }

            if (InputManager.IsNewPressed(Keys.Escape))
            {
                mapEditorMenu.IsActive = true;
            }

            mapEditorMenu.ProcessingOfClicks(gameTime, camera);

            if (mapEditorMenu.Save)
            {
                mapEditorMenu.Save = false;
                SaveMap();
            }

            //тыкнули за границы окна - выводим меню
            if (!ScreenManager.SpriteBatch.GraphicsDevice.Viewport.Bounds.Contains(new Point(InputManager.MouseStates.Position.X, InputManager.MouseStates.Position.Y)) &&
                InputManager.IsPressedAnyMouseButton())
            {
                mapEditorMenu.IsActive = true;
            }

            if (InputManager.MouseStates.LeftButton == ButtonState.Pressed)
            {
                int     y   = (int)((camera.Position.Y + InputManager.MouseStates.Y / camera.CameraMultiplier) / TextureManager.TileSize);
                int     x   = (int)((camera.Position.X + InputManager.MouseStates.X / camera.CameraMultiplier) / TextureManager.TileSize);
                Vector2 pos = CellPosition(x, y);
                y = (int)pos.Y / TextureManager.TileSize;
                x = (int)pos.X / TextureManager.TileSize;

                SetTexture(UInterface.BuildingStocks.CurrentTextureType(), x, y);
                ClickDetected = true;
            }

            base.ProcessingOfClicks(gameTime, camera);
        }
예제 #3
0
        /// <summary>
        /// Обновляем карту. Ищем ячейки, которые нужно обновить и обновляем, соседние ячейки так же обновляются
        /// </summary>
        /// <param name="gameTime">Время</param>
        public override void Update(GameTime gameTime, Camera camera)
        {
            if (!IsActive)
            {
                return;
            }

            if (gameMenu.IsActive)
            {
                gameMenu.Update(gameTime, camera);
                return;
            }

            Sky = new Rectangle(0, 0, Width * TextureManager.TileSize, Height * TextureManager.TileSize);
            Player.Update(gameTime, map);
            Player.Color = WorldColor;
            background.Update(gameTime, camera);
            background.Color  = WorldColor;
            background.Width  = Width * TextureManager.TileSize;
            background.Height = Height * TextureManager.TileSize;
            UInterface.Update(gameTime, camera);

            for (int i = ScreenManager.Point_Y1; i < ScreenManager.Point_Y2; i++)
            {
                for (int j = ScreenManager.Point_X1; j < ScreenManager.Point_X2; j++)
                {
                    if (map[i, j].Refresh)
                    {
                        map[i, j].Refresh = false;
                        UpdateTile(i, j);
                        UpdateTile(i - 1, j);
                        UpdateTile(i, j - 1);
                        UpdateTile(i + 1, j);
                        UpdateTile(i, j + 1);
                    }
                }
            }
            foreach (Item item in Items)
            {
                item.Update(gameTime);
            }

            base.Update(gameTime, camera);
        }
        public static void Main(string[] args)
        {
            var uInterface = new UInterface();

            uInterface.ReadCommand();
        }