Ejemplo n.º 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()
        {
            gameConfiguration = GameConfig.LoadConfigOrDefault();

            // Create default white texture
            WhiteTexture = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
            Color[] colorData = new Color[1];
            colorData[0] = Color.White;
            WhiteTexture.SetData(colorData);

            sim = new Simulation();

            modules.Add(sim);

            simRenderer = new SimulationRenderer(sim);


            inputManager = new InputManager();
            inputManager.Initialize(this);

            modules.Add(inputManager);

            Fonts.FontArial = Content.Load <SpriteFont>("Arial");

            lastSerializationTime = DateTime.UtcNow;


            base.Initialize();
        }
Ejemplo n.º 2
0
 public static TrackWriter AcquireWrite(
     ResourceSync sync,
     Track track,
     SimulationRenderer renderer,
     UndoManager undo,
     Timeline timeline,
     EditorGrid cells)
 {
     return(new TrackWriter(sync.AcquireWrite(), track)
     {
         _undo = undo,
         _renderer = renderer,
         _timeline = timeline,
         _editorcells = cells
     });
 }
Ejemplo n.º 3
0
        public void Initialize(GameConfig config, Simulation sim, SimulationRenderer renderer)
        {
            gameConfiguration = config;
            Initialize(sim);
            camera        = renderer.Camera;
            this.renderer = renderer;

            float viewportWidth  = renderer.GraphicsDevice.Viewport.Width;
            float tileMapWidth   = sim.TileMap.GetWorldWidth();
            float viewportHeight = renderer.GraphicsDevice.Viewport.Height;
            float tileMapHeight  = sim.TileMap.GetWorldHeight();

            renderer.Camera.Scale       = Mathf.Min(viewportWidth / tileMapWidth, viewportHeight / tileMapHeight);
            renderer.Camera.MinScale    = renderer.Camera.Scale;
            renderer.Camera.Translation = new Vector2(tileMapWidth / 2, 0);
        }