X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fcarfire;a=blobdiff_plain;f=CarFire%2FCarFire%2FCarFire%2FPlayer.cs;fp=CarFire%2FCarFire%2FCarFire%2FPlayer.cs;h=124851cac0b1e55a356362823a5d6afe9fb8cfae;hp=b84b04846158bd63d4f04830a4759c6cd7bc61c2;hb=198cb6056e93fecd69e65351ca8d0b34a077523f;hpb=08f41ef45f3c41ca6302150bc6d5270c8e7143db diff --git a/CarFire/CarFire/CarFire/Player.cs b/CarFire/CarFire/CarFire/Player.cs index b84b048..124851c 100644 --- a/CarFire/CarFire/CarFire/Player.cs +++ b/CarFire/CarFire/CarFire/Player.cs @@ -88,22 +88,23 @@ namespace CarFire bool moveRight = keysPressed.Contains(Keys.Right); bool moveUp = keysPressed.Contains(Keys.Up); bool moveDown = keysPressed.Contains(Keys.Down); - Point destination = MovementManager.GetNeighborCell(mMotion.Coordinates, moveLeft, moveRight, moveUp, moveDown); - if (!keysPressed.Contains(Keys.LeftControl)) + + List possibleDestinations = new List(); + possibleDestinations.Add(MovementManager.GetNeighbor(mMotion.Coordinates, moveLeft, moveRight, moveUp, moveDown)); + possibleDestinations.AddRange(MovementManager.GetNeighbors(mMotion.Coordinates, possibleDestinations[0])); + + Direction direction = Direction.None; + foreach (Point destination in possibleDestinations) { if (game.IsCellOpen(destination)) { - mMotion.Update(timeSpan, moveLeft, moveRight, moveUp, moveDown); - } - else - { - mMotion.Update(timeSpan); + direction = MovementManager.GetDirection(mMotion.Coordinates, destination); + break; } } - else - { - mMotion.LockUpdate(timeSpan, moveLeft, moveRight, moveUp, moveDown); - } + + if (direction != Direction.None && !keysPressed.Contains(Keys.LeftControl)) mMotion.Update(timeSpan, direction); + else mMotion.LockUpdate(timeSpan, moveLeft, moveRight, moveUp, moveDown); } public void powerUp(int amount)