예제 #1
0
 protected override void Initialize()
 {
     Interfaces = new List<IGameInterface>();
     SpriteBatch = new SpriteBatch(GraphicsDevice);
     base.Initialize(); // (calls LoadContent)
     ChunkConverter = new ChunkRenderer(this, Client.World.World.BlockRepository);
     Client.ChunkLoaded += (sender, e) => ChunkConverter.Enqueue(e.Chunk);
     //Client.ChunkModified += (sender, e) => ChunkConverter.Enqueue(e.Chunk, true);
     ChunkConverter.MeshCompleted += ChunkConverter_MeshGenerated;
     ChunkConverter.Start();
     Client.PropertyChanged += HandleClientPropertyChanged;
     Client.Connect(EndPoint);
     var centerX = GraphicsDevice.Viewport.Width / 2;
     var centerY = GraphicsDevice.Viewport.Height / 2;
     Mouse.SetPosition(centerX, centerY);
     Camera = new Camera(GraphicsDevice.Viewport.AspectRatio, 70.0f, 0.25f, 1000.0f);
     UpdateCamera();
     Window.ClientSizeChanged += (sender, e) => CreateRenderTarget();
     MouseComponent.Move += OnMouseComponentMove;
     KeyboardComponent.KeyDown += OnKeyboardKeyDown;
     KeyboardComponent.KeyUp += OnKeyboardKeyUp;
     CreateRenderTarget();
 }
예제 #2
0
        protected override void Initialize()
        {
            InputModules = new List<IGameplayModule>();
            GraphicalModules = new List<IGameplayModule>();

            base.Initialize(); // (calls LoadContent)

            White1x1 = new Texture2D(GraphicsDevice, 1, 1);
            White1x1.SetData<Color>(new[] { Color.White });

            Audio = new AudioManager();
            Audio.LoadDefaultPacks(Content);

            ChunkModule = new ChunkModule(this);
            DebugInfoModule = new DebugInfoModule(this, Pixel);
            ChatModule = new ChatModule(this, Pixel);
            var hud = new HUDModule(this, Pixel);
            var windowModule = new WindowModule(this, Pixel);

            GraphicalModules.Add(ChunkModule);
            GraphicalModules.Add(new HighlightModule(this));
            GraphicalModules.Add(hud);
            GraphicalModules.Add(ChatModule);
            GraphicalModules.Add(windowModule);
            GraphicalModules.Add(DebugInfoModule);

            InputModules.Add(windowModule);
            InputModules.Add(DebugInfoModule);
            InputModules.Add(ChatModule);
            InputModules.Add(new HUDModule(this, Pixel));
            InputModules.Add(new PlayerControlModule(this));

            Client.PropertyChanged += HandleClientPropertyChanged;
            Client.Connect(EndPoint);

            BlockProvider.BlockRepository = BlockRepository;
            var itemRepository = new ItemRepository();
            itemRepository.DiscoverItemProviders();
            ItemRepository = itemRepository;
            BlockProvider.ItemRepository = ItemRepository;

            IconRenderer.CreateBlocks(this, BlockRepository);

            var centerX = GraphicsDevice.Viewport.Width / 2;
            var centerY = GraphicsDevice.Viewport.Height / 2;
            Mouse.SetPosition(centerX, centerY);

            Camera = new Camera(GraphicsDevice.Viewport.AspectRatio, 70.0f, 0.1f, 1000.0f);
            UpdateCamera();

            MouseComponent.Scroll += OnMouseComponentScroll;
            MouseComponent.Move += OnMouseComponentMove;
            MouseComponent.ButtonDown += OnMouseComponentButtonDown;
            MouseComponent.ButtonUp += OnMouseComponentButtonUp;
            KeyboardComponent.KeyDown += OnKeyboardKeyDown;
            KeyboardComponent.KeyUp += OnKeyboardKeyUp;
            GamePadComponent.ButtonDown += OnGamePadButtonDown;
            GamePadComponent.ButtonUp += OnGamePadButtonUp;

            CreateRenderTarget();
            SpriteBatch = new SpriteBatch(GraphicsDevice);
            ThreadID = Thread.CurrentThread.ManagedThreadId;
        }