Example #1
0
        protected override void BuildEntity(EntityWorld entityWorld, Entity entity, ParameterCollection parameters)
        {
            entity.Transform.Position = parameters.Get<Vector2>(0);
            entity.Add(new CPlayerInfo(2));
            entity.Add<CCamera2D>(new CPlayerCamera2D());
            entity.Add<CWeapon>().Weapon = WeaponFactory.CreateDefaultWeapon();

            entity.Tag = EntityTags.Player;
        }
Example #2
0
	public static void Attach(Entity result, Property<Vector3> property)
	{
		AkGameObjectTracker tracker = result.Get<AkGameObjectTracker>();
		if (tracker == null)
		{
			tracker = new AkGameObjectTracker();
			result.Add(tracker);
			tracker.Add(new Binding<Matrix, Vector3>(tracker.Matrix, x => Microsoft.Xna.Framework.Matrix.CreateTranslation(x), property));
		}
	}
Example #3
0
	public static void Attach(Entity result, Property<Matrix> property = null)
	{
		AkGameObjectTracker tracker = result.Get<AkGameObjectTracker>();
		if (tracker == null)
		{
			tracker = new AkGameObjectTracker();
			result.Add(tracker);
			if (property == null)
				property = result.Get<Transform>().Matrix;
			tracker.Add(new Binding<Matrix>(tracker.Matrix, property));
		}
	}
Example #4
0
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            Window.AllowUserResizing = true;

            // Instantiate a scene with a single entity and model component
            var scene = new Scene();

            // Create a cube entity
            cubeEntity = new Entity();

            // Create a procedural model with a diffuse material
            var model = new Model();
            var material = Material.New(GraphicsDevice, new MaterialDescriptor
            {
                Attributes =
                {
                    Diffuse = new MaterialDiffuseMapFeature(new ComputeColor(Color.White)),
                    DiffuseModel = new MaterialDiffuseLambertModelFeature()
                }
            });
            model.Materials.Add(material);
            cubeEntity.Add(new ModelComponent(model));

            var modelDescriptor = new ProceduralModelDescriptor(new CubeProceduralModel());
            modelDescriptor.GenerateModel(Services, model);

            // Add the cube to the scene
            scene.Entities.Add(cubeEntity);

            // Create a camera entity and add it to the scene
            var cameraEntity = new Entity { new CameraComponent() };
            cameraEntity.Transform.Position = new Vector3(0, 0, 5);
            scene.Entities.Add(cameraEntity);

            // Create a light
            var lightEntity = new Entity()
            {
                new LightComponent()
            };

            lightEntity.Transform.Position = new Vector3(0, 0, 1);
            lightEntity.Transform.Rotation = Quaternion.RotationY(MathUtil.DegreesToRadians(45));
            scene.Entities.Add(lightEntity);

            // Create a graphics compositor
            var compositor = new SceneGraphicsCompositorLayers();

            bool isLDR = false;
            if (isLDR)
            {
                compositor.Master.Renderers.Add(new ClearRenderFrameRenderer());
                compositor.Master.Renderers.Add(new SceneCameraRenderer() {});
            }
            else
            {
                var layer = new SceneGraphicsLayer();
                var renderHDROutput = new LocalRenderFrameProvider { Descriptor = { Format = RenderFrameFormat.HDR, DepthFormat = RenderFrameDepthFormat.Shared} };
                layer.Output = renderHDROutput;
                layer.Renderers.Add(new ClearRenderFrameRenderer());
                layer.Renderers.Add(new SceneCameraRenderer());
                compositor.Layers.Add(layer);
                compositor.Master.Renderers.Add(new SceneEffectRenderer()
                {
                    Effect = new PostProcessingEffects()
                });
            }
            compositor.Cameras.Add(cameraEntity.Get<CameraComponent>());

            SceneSystem.SceneInstance = new SceneInstance(Services, scene);

            // Use this graphics compositor
            scene.Settings.GraphicsCompositor = compositor;

            // Create a scene instance
            SceneSystem.SceneInstance = new SceneInstance(Services, scene);
        }
Example #5
0
        protected  Entity GetUIEntity(SpriteFont font, bool fixedSize, Vector3 position)
        {
            // Create and initialize "Touch Screen to Start"
            var touchStartLabel = new ContentDecorator
            {
                Content = new TextBlock
                {
                    Font = font,
                    TextSize = 32,
                    Text = (fixedSize) ? "Fixed Size UI" : "Regular UI",
                    TextColor = Color.White
                },
                Padding = new Thickness(30, 20, 30, 25),
                HorizontalAlignment = HorizontalAlignment.Center
            };

            //touchStartLabel.SetPanelZIndex(1);

            var grid = new Grid
            {
                BackgroundColor = (fixedSize) ? new Color(255, 0, 255) : new Color(255, 255, 0),
                MaximumWidth = 100,
                MaximumHeight = 100,
                MinimumWidth = 100,
                MinimumHeight = 100,
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
            };

            grid.RowDefinitions.Add(new StripDefinition(StripType.Auto));
            grid.ColumnDefinitions.Add(new StripDefinition());
            grid.LayerDefinitions.Add(new StripDefinition());

            grid.Children.Add(touchStartLabel);

            // Add the background
            var background = new ImageElement { StretchType = StretchType.Fill };
            background.SetPanelZIndex(-1);

            var uiEntity = new Entity();

            // Create a procedural model with a diffuse material
            var uiComponent = new UIComponent();
            uiComponent.RootElement = new UniformGrid { Children = { background, grid } };

            uiComponent.Resolution = new Vector3(100, 100, 100);    // Same size as the inner grid
            uiComponent.IsFullScreen = false;
//            uiComponent.IsBillboard = true;
            uiComponent.IsFixedSize = fixedSize;
            uiComponent.Size = new Vector3(0.1f);   // 10% of the vertical resolution

            uiEntity.Add(uiComponent);

            uiEntity.Transform.Position = position;

            return uiEntity;
        }
 protected override void BuildEntity(EntityWorld entityWorld, Entity entity, ParameterCollection parameters)
 {
     entity.Add(new CVirtualThumbstick(parameters.Get<VirtualThumbstick>(0)));
     entity.Tag = EntityTags.VirtualThumbStick;
 }