Пример #1
0
        public static void Render(ContentManager content, GraphicsDevice graphicsDevice, TransformComponent transform, CameraComponent camera, BasicEffect effect)
        {
            if(_quad == null) {
                _texture = content.Load<Texture2D>("Images/OryxChar");
                TextureFrame textureFrame = new TextureFrame(0.292f, 0.031f, 0.042f, 0.031f);

                Vector3 normal = camera.Rotation.Forward * -1;
                Vector3 up = camera.Rotation.Up;

                _quad = new QuadShape(transform.Position, normal, up, textureFrame, 0.5f, 0.5f);
            }

            _quad.Origin = transform.Position + new Vector3(0, _quad.Height / 2.0f, 0);
            _quad.UpdateVertexData();

            effect.Texture = _texture;

            graphicsDevice.DrawUserIndexedPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, _quad.Vertices, 0, 4, _quad.Indexes, 0, 2);
        }
Пример #2
0
        protected override void Initialize()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            _netAgent = new NetworkAgent(AgentRole.Client, "Umbra");

            EntitySystem.BlackBoard.SetEntry("Game", this);
            EntitySystem.BlackBoard.SetEntry("ContentManager", Content);
            EntitySystem.BlackBoard.SetEntry("SpriteBatch", spriteBatch);
            EntitySystem.BlackBoard.SetEntry("GraphicsDevice", GraphicsDevice);
            EntitySystem.BlackBoard.SetEntry("ContentManager", Content);
            EntitySystem.BlackBoard.SetEntry("NetworkAgent", _netAgent);

            _entityWorld = new EntityWorld();

            // create camera
            Vector3 camPosition = new Vector3(0, 10, 5);
            Matrix camRotation = Matrix.CreateFromAxisAngle(new Vector3(1, 0, 0), MathHelper.ToRadians(-65.0f));
            float aspectRatio = (float)GraphicsDevice.Viewport.Width / GraphicsDevice.Viewport.Height;

            CameraComponent cameraComponent = new CameraComponent(camPosition, camRotation, aspectRatio);

            Entity cameraEntity = _entityWorld.CreateEntity();
            cameraEntity.AddComponent(cameraComponent);

            EntitySystem.BlackBoard.SetEntry("Camera", cameraComponent);

            //// TEMP ////
            Map map = new Map(100, 100);
            Entity mapEntity = _entityWorld.CreateEntity();
            mapEntity.AddComponent(new TileMapComponent(map));

            EntitySystem.BlackBoard.SetEntry("Map", map);
            //// TEMP ////

            _entityWorld.InitializeAll(new[] { GetType().Assembly });

            CrawEntityManager.Instance.Initialize(_entityWorld, new ClientEntityFactory(_entityWorld));

            _netAgent.Connect("127.0.0.1");

            base.Initialize();
        }
Пример #3
0
 public override void LoadContent()
 {
     _netAgent = BlackBoard.GetEntry<NetworkAgent>("NetworkAgent");
     _camera = BlackBoard.GetEntry<CameraComponent>("Camera");
 }