Beispiel #1
0
        public void Update(GameTime gameTime, UpdateChanges changes)
        {
            if (changes.CurrentMouseState.LeftButton != ButtonState.Pressed)
            {
                return;
            }

            output = $"\r\nx:{camera.ViewSettings.Position.X} Y: {camera.ViewSettings.Position.Y} Z: {camera.ViewSettings.Position.Z}";

            var near = graphicsDevice.Viewport.Unproject(new Vector3(changes.CurrentMouseState.X, changes.CurrentMouseState.Y, 0f),
                                                         camera.ProjectionMatrix,
                                                         camera.ViewSettings.ViewMatrix, Matrix.Identity);
            var far = graphicsDevice.Viewport.Unproject(new Vector3(changes.CurrentMouseState.X, changes.CurrentMouseState.Y, 1f),
                                                        camera.ProjectionMatrix,
                                                        camera.ViewSettings.ViewMatrix, Matrix.Identity);
            var ray = new Ray(near, Vector3.Normalize(far - near));

            var groundPlane = new Plane(new Vector3(0, 1, 0), 0);

            float?result;

            ray.Intersects(ref groundPlane, out result);
            if (result != null)
            {
                Vector3 worldPoint = ray.Position + ray.Direction * result.Value;
            }
        }
Beispiel #2
0
        public override void Update(GameTime gameTime, UpdateChanges changes)
        {
            leftRightRotation += changes.LeftRightRotation * RotationSpeed;

            upDownRotation += changes.UpDownRotation * RotationSpeed;

            // Cap mouse up/down rotation to + Pi/2 and almost - Pi/2 (Almost because the rotation matrix is cyclical i.e. -Pi/2 = Pi/2)
            upDownRotation = upDownRotation > 0 ? Math.Min(upDownRotation, MathHelper.PiOver2) : Math.Max(upDownRotation, -MathHelper.PiOver2 + 0.01f);

            var positionRotation = Matrix.CreateRotationY(leftRightRotation);

            var targetRotation = Matrix.CreateRotationX(upDownRotation) * Matrix.CreateRotationY(leftRightRotation);

            var potentialPosition = ViewSettings.Position + Vector3.Transform(changes.ChangeVector, positionRotation) * MovementSpeed;

            if (changes.IsOccupied(potentialPosition - new Vector3(0, 6, 0)))
            {
                changes.MidJump = false;
            }
            else
            {
                ViewSettings.Position = potentialPosition;
            }

            ViewSettings.Target = Vector3.Transform(cameraReference, targetRotation) + ViewSettings.Position;
        }
Beispiel #3
0
        public void Update(GameTime gameTime, UpdateChanges changes)
        {
            leftRightRotation += changes.LeftRightRotation * RotationSpeed;

            var rotationMatrix = Matrix.CreateRotationY(leftRightRotation);

            Position += Vector3.Transform(changes.ChangeVector, rotationMatrix) * MovementSpeed;
        }
Beispiel #4
0
        public ActionResult GetChanges(
            [FromRoute(Name = "branch")] Branch updateBranch,
            [FromQuery(Name = "os")] OperatingSystem operatingSystem)
        {
            using (DogStatsd.StartTimer("controller.update.get_changes.time"))
            {
                DogStatsd.Increment("controller.update.get_changes.count");

                var updates = _database.UpdateEntities
                              .Include(x => x.UpdateFiles)
                              .Where(x => x.Branch == updateBranch && x.UpdateFiles.Any(u => u.OperatingSystem == operatingSystem))
                              .OrderByDescending(x => x.ReleaseDate)
                              .Take(5);

                var response = new List <UpdatePackage>();

                foreach (var update in updates)
                {
                    var updateFile = update.UpdateFiles.FirstOrDefault(u => u.OperatingSystem == operatingSystem);
                    if (updateFile == null)
                    {
                        continue;
                    }

                    UpdateChanges updateChanges = null;

                    if (update.New.Count != 0 || update.Fixed.Count != 0)
                    {
                        updateChanges = new UpdateChanges
                        {
                            New   = update.New,
                            Fixed = update.Fixed
                        };
                    }

                    response.Add(new UpdatePackage
                    {
                        Version     = update.Version,
                        ReleaseDate = update.ReleaseDate,
                        Filename    = updateFile.Filename,
                        Url         = updateFile.Url,
                        Changes     = updateChanges,
                        Hash        = updateFile.Hash,
                        Branch      = update.Branch.ToString().ToLower()
                    });
                }

                return(Ok(response));
            }
        }
Beispiel #5
0
        /// <summary>
        /// Bind all entities here.
        /// </summary>
        private void InitializeEntities()
        {
            var viewMatrixSettings = new ViewMatrixSettings(new Vector3(50, 50, 50), Vector3.Up, Vector3.Forward);
            var camera             = new FirstPersonCamera(this, GraphicsDevice, viewMatrixSettings);

            var telemetry = new Telemetry(this, GraphicsDevice, camera);

            var terrainGenerator = new HillBillyGenerator(100, 100, 50);
            var terrain          = new Terrain(this, GraphicsDevice, terrainGenerator, camera);

            entities = new IEntity[]
            {
                terrain,
                camera,
                telemetry
            };

            updateChanges = new UpdateChanges(entities, GraphicsDevice);
        }
Beispiel #6
0
        public ActionResult GetUpdates(
            [FromRoute(Name = "branch")] Branch updateBranch,
            [FromQuery(Name = "os")] OperatingSystem operatingSystem,
            [FromQuery(Name = "version")] string urlVersion)
        {
            // Check given version
            if (!Version.TryParse(urlVersion, out var version))
            {
                return(BadRequest(new
                {
                    ErrorMessage = "Invalid version number specified."
                }));
            }

            using (DogStatsd.StartTimer("controller.update.get_updates.time"))
            {
                DogStatsd.Increment("controller.update.get_updates.count");

                // Grab latest update based on branch and operatingsystem
                var update = _database.UpdateEntities
                             .Include(x => x.UpdateFiles)
                             .Where(x => x.Branch == updateBranch && x.UpdateFiles.Any(u => u.OperatingSystem == operatingSystem))
                             .OrderByDescending(x => x.ReleaseDate)
                             .FirstOrDefault();

                if (update == null)
                {
                    return(NotFound(new
                    {
                        ErrorMessage = "Latest update not found."
                    }));
                }

                // Check if update file is present
                var updateFile = update.UpdateFiles.FirstOrDefault(u => u.OperatingSystem == operatingSystem);
                if (updateFile == null)
                {
                    return(NotFound(new
                    {
                        ErrorMessage = "Latest update file not found."
                    }));
                }

                // Compare given version and update version
                var updateVersion = new Version(update.Version);
                if (updateVersion.CompareTo(version) <= 0)
                {
                    return(Ok(new UpdatePackageContainer
                    {
                        Available = false
                    }));
                }

                // Get the update changes
                UpdateChanges updateChanges = null;

                if (update.New.Count != 0 || update.Fixed.Count != 0)
                {
                    updateChanges = new UpdateChanges
                    {
                        New   = update.New,
                        Fixed = update.Fixed
                    };
                }

                return(Ok(new UpdatePackageContainer
                {
                    Available = true,
                    UpdatePackage = new UpdatePackage
                    {
                        Version = update.Version,
                        ReleaseDate = update.ReleaseDate,
                        Filename = updateFile.Filename,
                        Url = updateFile.Url,
                        Changes = updateChanges,
                        Hash = updateFile.Hash,
                        Branch = update.Branch.ToString().ToLower()
                    }
                }));
            }
        }
Beispiel #7
0
 public abstract void Update(GameTime gameTime, UpdateChanges changes);
Beispiel #8
0
 public void Update(GameTime gameTime, UpdateChanges changes)
 {
 }