예제 #1
0
파일: World.cs 프로젝트: nerdshark/voxeliq
        /// <summary>
        /// Creates a new world.
        /// </summary>
        /// <param name="game"> </param>
        /// <param name="chunkStorage"> </param>
        /// <param name="chunkCache"> </param>
        public World(Game game, ChunkStorage chunkStorage, ChunkCache chunkCache)
            : base(game)
        {
            this.Chunks = chunkStorage;
            this._chunkCache = chunkCache;

            // export services.
            this.Game.Services.AddService(typeof (IWorld), this);
        }
예제 #2
0
        public void Init()
        {
            _game = new SampleGame();
            this._config = new EngineConfig();

            if(Engine.Instance!=null) // if there exists already an engine instance, dispose it first.
                Engine.Instance.Dispose();

            this._engine = new Engine(this._game, this._config);
            this._chunkStorage = new ChunkStorage(_game);
            this._chunk = new Chunk(new Vector2Int(0, 0));
        }
예제 #3
0
        /// <summary>
        /// Adds game-components.
        /// </summary>
        private void AddComponents()
        {
            this.Components.Add(new InputManager(this));

            this.Components.Add(new AssetManager(this));

            #if XNA
            this.Components.Add(new Sky(this));
            #endif

            this.Components.Add(new Fogger(this));

            var chunkStorage = new ChunkStorage(this);
            this.Components.Add(chunkStorage);

            var vertexBuilder = new VertexBuilder(this);
            this.Components.Add(vertexBuilder);

            var chunkCache = new ChunkCache(this);
            this.Components.Add(chunkCache);

            var world = new World(this, chunkStorage, chunkCache);
            this.Components.Add(world);

            this.Components.Add(new Player(this, world));

            #if XNA
            bloom = new BloomComponent(this);
            this.Components.Add(bloom);
            #endif

            this.Components.Add(new Camera(this));
            this.Components.Add(new UserInterface(this));

            this.Components.Add(new InGameDebugger(this));
            this.Components.Add(new Statistics(this));
            this.Components.Add(new GraphManager(this));

            #if XNA
            this.Components.Add(new AudioManager(this));
            #endif

            this._timeRuler = new TimeRuler(this);
            this._timeRuler.Visible = true;
            this._timeRuler.ShowLog = true;
            this.Components.Add(this._timeRuler);
        }
예제 #4
0
 public ChunkStorage(Game game)
     : base(game)
 {
     _instance = this;
     this.Game.Services.AddService(typeof (IChunkStorage), this); // export service.
 }
예제 #5
0
파일: Engine.cs 프로젝트: hach-que/voxeliq
        /// <summary>
        /// Adds game-components.
        /// </summary>
        private void AddComponents()
        {
            this.Rasterizer = new Rasterizer();

            this.Game.Components.Add(new InputManager(this.Game));

            this.Game.Components.Add(new AssetManager(this.Game));

            #if XNA
            //this.Game.Components.Add(new Sky(this.Game));
            #endif

            this.Game.Components.Add(new NewSky(this.Game));

            this.Game.Components.Add(new Fogger(this.Game));

            var chunkStorage = new ChunkStorage(this.Game);
            this.Game.Components.Add(chunkStorage);

            var vertexBuilder = new VertexBuilder(this.Game);
            this.Game.Components.Add(vertexBuilder);

            var chunkCache = new ChunkCache(this.Game);
            this.Game.Components.Add(chunkCache);

            var world = new World(this.Game, chunkStorage, chunkCache);
            this.Game.Components.Add(world);

            this.Game.Components.Add(new Player(this.Game, world));

            this.Game.Components.Add(new Camera(this.Game));
            this.Game.Components.Add(new UserInterface(this.Game));

            this.Game.Components.Add(new InGameDebugger(this.Game));
            this.Game.Components.Add(new DebugBar(this.Game));
            this.Game.Components.Add(new GraphManager(this.Game));

            #if XNA
            this.Game.Components.Add(new AudioManager(this.Game));
            #endif

            var spriteBatch = new SpriteBatch(this.Game.GraphicsDevice);
            Console = new GameConsole(this.Game, spriteBatch,  new GameConsoleOptions
                                                             {
                                                                 Font = Game.Content.Load<SpriteFont>(@"Fonts/Verdana"),
                                                                 FontColor = Color.LawnGreen,
                                                                 Prompt = ">",
                                                                 PromptColor = Color.Crimson,
                                                                 CursorColor = Color.OrangeRed,
                                                                 BackgroundColor = Color.Black*0.8f,
                                                                 PastCommandOutputColor = Color.Aqua,
                                                                 BufferColor = Color.Gold
                                                             });
        }
예제 #6
0
 public ChunkStorage(Game game)
     : base(game)
 {
     _instance = this;
     this.Game.Services.AddService(typeof(IChunkStorage), this);  // export service.
 }