예제 #1
0
 public Whereabouts( int floor, Point location, Direction direction )
 {
     Floor = floor;
     Location = location;
     Direction = direction;
     Fraction = 0;
 }
예제 #2
0
 private int getDistance(int floor, Point fromLoc, Direction direction)
 {
     var toLoc = fromLoc.Add(direction.DirectionAsPoint());
     return PlayingField.CanMoveHere(ref floor, fromLoc, toLoc, true)
         ? Distance[floor, toLoc.Y, toLoc.X]
         : int.MaxValue;
 }
예제 #3
0
 public void SetPosition(Vector3 position, Direction direction)
 {
     CaveWorld = Matrix.Scaling(0.9f, 0.7f, 0.5f)
                 *Matrix.Translation(5, 0.3f, -0.5f)
                 *Matrix.RotationY(MathUtil.PiOverTwo)
                 *Matrix.Translation(position);
     _gratingPart3 = Matrix.Translation(0.41f, 0.2f, -4.7f) * Matrix.Translation(position);
 }
예제 #4
0
 private void testDistance(int floor, Point fromLoc, ref Direction bestDirection, ref int bestDistance, Direction direction)
 {
     var here = getDistance(floor, fromLoc, direction);
     if (here >= bestDistance)
         return;
     bestDirection = direction;
     bestDistance = here;
 }
예제 #5
0
 static Direction()
 {
     None = new Direction(DirectionValue.None);
     South = new Direction(DirectionValue.South);
     West = new Direction(DirectionValue.West);
     North = new Direction(DirectionValue.North);
     East = new Direction(DirectionValue.East);
     AllDirections = new[] {South, West, North, East};
 }
예제 #6
0
        public void Explore(int floor, Point fromLoc, int distance, Direction direction)
        {
            var toLoc = fromLoc.Add(direction.DirectionAsPoint());
            if (!PlayingField.CanMoveHere(ref floor, fromLoc, toLoc, true))
                return;

            var here = Distance[floor, toLoc.Y, toLoc.X];
            if (here != 0 && here < distance)
                return; // already know shorter path

            Distance[floor, toLoc.Y, toLoc.X] = distance;

            foreach (var newDirection in Direction.AllDirections)
                Explore(floor, toLoc, distance + 1, newDirection);
        }
예제 #7
0
        public static void Draw(
            IVEffect effect,
            Texture2D skin,
            Vector4 diffuseColor,
            IVDrawable sphere,
            Matrix translation,
            Direction direction)
        {
            var t = direction.IsNorthSouth ? NorthSouthScale : EastWestScale;
            var off = direction.DirectionAsVector3()*-0.3f;
            t *= Matrix.Translation(off);

            effect.World = t*translation;
            effect.Texture = skin;
            effect.DiffuseColor = diffuseColor;
            sphere.Draw(effect);
        }
예제 #8
0
 public static Point Add(this Point p1, Direction dir)
 {
     return p1.Add(dir.DirectionAsPoint());
 }
예제 #9
0
 protected bool TryMove(Direction dir, bool ignoreRestriction = false)
 {
     if (dir == Direction.None)
     {
         _whereabouts.Direction = Direction.None;
         return true;
     }
     var possibleLocationTo = _whereabouts.Location.Add(dir);
     if (!PlayingField.CanMoveHere(ref _whereabouts.Floor, _whereabouts.Location, possibleLocationTo, ignoreRestriction))
         return false;
     _whereabouts.Direction = dir;
     _tail.AddPathToWalk(_whereabouts);
     return true;
 }
예제 #10
0
 public RelativeDirection GetRelativeDirection(Direction goingTo)
 {
     if(goingTo==None)
         return RelativeDirection.None;
     if (this == goingTo)
         return RelativeDirection.Forward;
     if (Turn(RelativeDirection.Left) == goingTo)
         return RelativeDirection.Left;
     if (Turn(RelativeDirection.Right) == goingTo)
         return RelativeDirection.Right;
     return RelativeDirection.Backward;
 }