Пример #1
0
        public TestRendering(IoCContainer container)
        {
            camera = new Camera2D();

            RenderDelegateChainStep renderStep = new RenderDelegateChainStep("TestRendering", Render);

            container.Resolve<IUIRenderChain>().RegisterStep(renderStep);

            IInput input = container.Resolve<IInput>();

            input.AddBinding(string.Empty, false, false, false, System.Windows.Forms.Keys.Up, null, (s, e) => { camera.Position += Vector3.UnitY; });
            input.AddBinding(string.Empty, false, false, false, System.Windows.Forms.Keys.Down, null, (s, e) => { camera.Position -= Vector3.UnitY; });
            input.AddBinding(string.Empty, false, false, false, System.Windows.Forms.Keys.Left, null, (s, e) => { camera.Position += Vector3.UnitX; });
            input.AddBinding(string.Empty, false, false, false, System.Windows.Forms.Keys.Right, null, (s, e) => { camera.Position -= Vector3.UnitX; });

            IDeviceContextService deviceContextService = container.Resolve<IDeviceContextService>();
            DeviceContext context = deviceContextService.Context;

            deviceContextService.Form.ResizeEnd += new EventHandler(Form_ResizeEnd);

            _texture = Texture2D.FromFile(context, "Resources\\Helix.jpg", Usage.None, Pool.Managed);
            _elements = new TexturedElement[250];

            for (int i = 0; i < _elements.Length; i++)
            {
                _elements[i] = new TexturedElement(new SharpDX.Vector2(50, 50));
                _elements[i].Position = new Vector2(i * 20, i * 20);
            }

            _vertices = new Vertices<VertexPositionTexture>(context,
                new VertexPositionTexture() { Position = new Vector3(-0.5f, -0.5f, 0), TextureCoordinate = new Vector2(0, 0) },
                new VertexPositionTexture() { Position = new Vector3(-0.5f,  0.5f, 0), TextureCoordinate = new Vector2(1, 0) },
                new VertexPositionTexture() { Position = new Vector3( 0.5f, -0.5f, 0), TextureCoordinate = new Vector2(0, 1) },
                new VertexPositionTexture() { Position = new Vector3( 0.5f,  0.5f, 0), TextureCoordinate = new Vector2(1, 1) });
        }
Пример #2
0
        public World(IoCContainer container)
        {
            IConfiguration config = container.Resolve<IConfiguration>();

            _container = container;
            _install = config.GetValue<InstallLocation>(ConfigSections.Client, ConfigKeys.InstallLocation);

            _camera = new Camera2D();
            _facets = new List<Facet>();
        }
Пример #3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            GDevice = GraphicsDevice;
#if LOCALHOST
            Network = new Network.NetworkClient("localhost", 9000);
#endif
#if EC2
            Network = new Network.NetworkClient("sobriety.dyndns.org", 9000);
#endif
            UIManager.Init(GDevice);
            Terrain = new World.TerrainManager();
            Character = new PlayerController();
            Camera = new Camera2D();
            // TODO: use this.Content to load your game content here
        }
Пример #4
0
        private void Initialize()
        {
            _camera = new Camera2D(this);
            _camera.NearClip = -1000;
            _camera.FarClip = 1000;
            _camera.Position = new Vector2(1496, 1624);

            _inputService = (IInputService)Services.GetService(typeof(IInputService));
            _inputService.MouseMove += _inputService_MouseMove;
            _inputService.KeyDown += _inputService_KeyDown;

            _textureFactory = new TextureFactory(this);
            _maps = new Maps(this);

            _shader = new DiffuseShader(this);
            _renderer = new DeferredRenderer(this);

            Tracer.Info("Loading Content...");
            LoadContent();
        }
Пример #5
0
        private void Initialize()
        {
            _camera = new Camera2D(this);
            _camera.NearClip = -1000;
            _camera.FarClip = 1000;
            _camera.Position = new Vector2(1496, 1624);

            _renderer = _kernel.Get<IRenderer>();

            IUserInterfaceManager userInterface = _kernel.Get<IUserInterfaceManager>();
            ITextureFactory textureFactory = _kernel.Get<ITextureFactory>();
            IUserInterfaceRenderer userInterfaceRenderer = _kernel.Get<IUserInterfaceRenderer>();
            IInputService inputService = _kernel.Get<IInputService>();

            BackgroundElement element = new BackgroundElement(userInterface, 5054);
            element.Position = new Vector2(50, 50);
            element.Size = new Vector2(300, 300);

            TextElement t = new TextElement(userInterface, 0, "This is a test.");
            t.Position = new Vector2(60, 60);

            userInterface.Add(element);
            userInterface.Add(t);

            Bind(_renderer);
            Bind(inputService);
            Bind(textureFactory);
            Bind(userInterface);
            Bind(userInterfaceRenderer);

            Tracer.Info("Initializing Resources...");

            foreach (IResourceContainer resource in _resouces)
                resource.CreateResources();
        }