Example #1
0
 /// <summary>
 /// Allows the game to perform any initialization it needs to before starting to run.
 /// This is where it can query for any required services and load any non-graphic
 /// related content.  Calling base.Initialize will enumerate through any components
 /// and initialize them as well.
 /// </summary>
 protected override void Initialize()
 {
     level = new Level(Services, graphics);
     base.Initialize();
     level.Initialize();
     viewPortAdapter = new ScalingViewportAdapter(GraphicsDevice, (int)viewPort.X, (int)viewPort.Y);
 }
Example #2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            tileState = TileState.Tile1;
            toolState = ExternalToolState.MainTool;


            this.IsMouseVisible = true;
            texturePosition     = new Rectangle();
            //Mouse.WindowHandle = Window.Handle;
            //Mouse.SetPosition(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height/2);
            viewportAdapter = new ScalingViewportAdapter(GraphicsDevice, 2560, 1440);
            mousePosition   = ms.Position.ToVector2();
            mapGrid         = new string[20, 11];

            for (int i = 0; i < mapGrid.GetLength(0); i++)
            {
                for (int j = 0; j < mapGrid.GetLength(1); j++)
                {
                    mapGrid[i, j] = "0";
                }
            }

            tile1Positions = new List <Vector2>();
            texture        = new Dictionary <string, Texture2D>();

            saveCounter = 1;



            base.Initialize();
        }
Example #3
0
        public Scene(string name, AvocadoGame game)
        {
            Game            = game;
            Name            = name;
            graphicsDevice  = game.GraphicsDevice;
            Content         = new ContentManager(game.Services);
            BackgroundColor = Color.Black;

            var             settings = Game.GameSettings;
            ViewportAdapter adapter  = null;

            switch (settings.ViewportType)
            {
            case ViewportType.Default:
                adapter = new DefaultViewportAdapter(Game.GraphicsDevice);
                break;

            case ViewportType.Scaling:
                adapter = new ScalingViewportAdapter(game.GraphicsDevice, settings.VirtualResolution.X, settings.VirtualResolution.Y);
                break;

            case ViewportType.Window:
                adapter = new WindowViewportAdapter(game.Window, graphicsDevice);
                break;
            }
            Camera = new Camera(adapter);

            EntityManager    = new EntityManager(this);
            CollisionManager = new CollisionManager(this);
            BehaviorManager  = new BehaviorManager(this);
            RenderManager    = new RenderManager(this, graphicsDevice);
        }
Example #4
0
        public WorldView(World world, CameraClampMode cameraClampMode, InputHandler input)
        {
            _gameConfigCache = CallContext <GameConfigCache> .GetData("GameConfigCache");

            World             = world;
            GameStatusHandler = new GameStatusHandler(GameStatus.OverlandMap);

            Input = input;

            Camera = new Camera(this, new Rectangle(0, 0, 1680, 1080), cameraClampMode, Input);
            var globalContextPresentation = CallContext <GlobalContextPresentation> .GetData("GlobalContextPresentation");

            globalContextPresentation.Camera = Camera;

            OverlandMapView         = new OverlandMapView(this, World.OverlandMap, Input);
            OverlandSettlementViews = new OverlandSettlementViews(this, World.Settlements, Input);
            StackViews     = new StackViews(this, World.Stacks, Input);
            SettlementView = new SettlementView(this, World.Settlements.Count > 0 ? World.Settlements[0] : new Settlement("Test", 1, PointI.Zero, 1, World.OverlandMap.CellGrid, new int[0]), Input);
            HudView        = new HudView(this, StackViews, Input);
            //Tooltip = new Tooltip(Vector2.Zero, Alignment.TopLeft, new Vector2(200.0f, 300.0f), "GUI_Textures_1.sp_frame", 25, 25, 25, 25, "tooltip") { Enabled = false };

            var context = CallContext <GlobalContextPresentation> .GetData("GlobalContextPresentation");

            Viewport        = new Viewport(0, 0, Camera.GetViewport.Width, Camera.GetViewport.Height, 0.0f, 1.0f);
            ViewportAdapter = new ScalingViewportAdapter(context.GraphicsDevice, Camera.GetViewport.Width, Camera.GetViewport.Height);

            MovementTypeImages = InitializeMovementTypeImages();
            ActionButtons      = InitializeActionButtons();
        }
Example #5
0
        protected void SetupViewport(int x, int y, int width, int height)
        {
            var context = CallContext <GlobalContextPresentation> .GetData("GlobalContextPresentation");

            Viewport        = new Viewport(x, y, width, height, 0.0f, 1.0f);
            ViewportAdapter = new ScalingViewportAdapter(context.GraphicsDevice, width, height);
        }
Example #6
0
        public RenderHudSystem(GameApp gameApp) : base(Aspect
                                                       .All(typeof(TagHUDComponent), typeof(RenderFormComponent)))
        {
            _gameApp = gameApp;
            _sb      = new SpriteBatch(_gameApp.GraphicsDevice);

            _viewportAdapter = new ScalingViewportAdapter(_gameApp.GraphicsDevice, GameApp.DefaultWidth, GameApp.DefaultHeight);
        }
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            this.spriteBatch.Begin(SpriteSortMode.FrontToBack, transformMatrix: ScalingViewportAdapter.GetScaleMatrix(this.GraphicsDevice));

            SceneManager.Draw(this.spriteBatch);

            this.spriteBatch.End();
        }
Example #8
0
        public void LoadContent()
        {
            // EntityFactory
            _entityFactory = new EntityFactory(_gameApp);
            _gameApp.Services.AddService <EntityFactory>(_entityFactory);

            // Map
            var mapInfo = new MapInfo(0, 0, GameApp.DefaultWidth, GameApp.DefaultHeight);

            _gameApp.Services.AddService <MapInfo>(mapInfo);

            // Camera
            var viewportAdapter = new ScalingViewportAdapter(_gameApp.GraphicsDevice, GameApp.DefaultWidth, GameApp.DefaultHeight);

            var camera = new OrthographicCamera(viewportAdapter);

            _gameApp.Services.AddService <OrthographicCamera>(camera);

            // Event Manager
            _eventManager = new EventManager();
            _gameApp.Services.AddService(_eventManager);

            // World
            _world = new WorldBuilder()
                     .AddSystem(new ChickenSpawnSystem(_gameApp))
                     .AddSystem(new ChickenDestroySystem(_gameApp))
                     .AddSystem(new ChickenHitSystem(_gameApp))
                     .AddSystem(new PlayerControlSystem(_gameApp))
                     .AddSystem(new PhysicsSystem())
                     .AddSystem(new AnimatedSpriteSystem())

                     .AddSystem(new RendererSystem(_gameApp))
                     .AddSystem(new RenderHudSystem(_gameApp))

                     .Build();

            _entityFactory.LoadContent(_world);

            // Background
            BuildBackground();

            // Cursor
            Mouse.SetCursor(MouseCursor.FromTexture2D(Assets.TextureAimCursor, 18, 18));
        }
        protected override void Initialize()
        {
            base.Initialize();

            // the default viewport adapater is the simplest, it doesn't do any scaling at all
            // but is used by a Camera2D if no other adapter is specified.
            // this is often useful if you have a game with a large map and you want the player to see
            // more of the map on a bigger screen.
            _defaultViewportAdapter = new DefaultViewportAdapter(GraphicsDevice);

            // the scaling viewport adapter stretches the output to fit in the viewport, ignoring the aspect ratio
            // this works well if the aspect ratio doesn't change a lot between devices
            // or you don't like the black bars of the boxing adapter
            _scalingViewportAdapter = new ScalingViewportAdapter(GraphicsDevice, 800, 480);

            // the boxing viewport adapter uses letterboxing or pillarboxing to maintain aspect ratio
            // it's a little more complicated and needs to listen to the window client size changing event
            _boxingViewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480);//, 88, 70);

            // typically you'll only ever want to use one viewport adapter for a game, but in this sample we'll be
            // switching between them.
            _currentViewportAdapter = _boxingViewportAdapter;
        }
Example #10
0
 protected override void Initialize()
 {
     viewportAdapter = new ScalingViewportAdapter(GraphicsDevice, VirtualWidth, VirtualHeight);
     base.Initialize();
 }