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()
		{
            // reset mouse, so we don't suddenly pan off to the sides
			Form.Activated += (sender, args) => RecenterMouse();
            
			IsMouseVisible = true;
			_graphics.PreferredBackBufferWidth = 1024;
			_graphics.PreferredBackBufferHeight = 768;
			_graphics.IsFullScreen = false;

			_graphics.GraphicsDevice.RasterizerState = solidRasterizerState;
            _graphics.GraphicsDevice.DepthStencilState = defaultStencilState;
		    _graphics.GraphicsDevice.BlendState = BlendState.Opaque;
			_graphics.ApplyChanges();

			effect = new BasicEffect(_graphics.GraphicsDevice);
            InitializeEffect();


			Components.Add(AxisRenderer = new AxisRenderer(this));
            Components.Add(TriangleSelectionRenderer = new GenericRenderer(this));
			Components.Add(LineSelectionRenderer = new GenericRenderer(this));

		    var tileRenderer = new TileRenderer(this, ActiveTile);
            TileRenderers.Add(ActiveTile.TileId, tileRenderer);
            Components.Add(tileRenderer);

			InitGUI();

            base.Initialize();
		}
Example #2
0
        public void DisplayTile(TerrainTile tile)
        {
            if (TileRenderers.ContainsKey(tile.TileId)) return;		// already loaded

            var renderer = new TileRenderer(this, tile);
            renderer.LiquidEnabled = liquidRenderingEnabled;
            renderer.NavMeshEnabled = navMeshRenderingEnabled;
            TileRenderers.Add(tile.TileId, renderer);
            Tiles.Add(tile);
            Components.Add(renderer);

            if (tile.Map != activeTerrain.MapId)
            {
                activeTerrain = tile.Terrain;
                tileOverview.InitImage(tile.Map);
            }
        }
Example #3
0
        private void AddTileToDisplay(TileIdentifier tileId)
        {
            var terrain = world.GetOrLoadSimpleWDTTerrain(tileId.MapId);
            var tile = terrain.GetOrCreateTile(tileId);
            if (tile == null) return;

            var renderer = new TileRenderer(this, tile);
            renderer.LiquidEnabled = liquidRenderingEnabled;
            renderer.NavMeshEnabled = navMeshRenderingEnabled;
            TileRenderers.Add(tileId, renderer);
            Tiles.Add(tile);
            Components.Add(renderer);
        }