Ejemplo n.º 1
0
        // assuming that we are always either in the same row or column
        public static Direction GetDirection(Grid source, Grid destination)
        {
            if (source.Col == destination.Col && source.Row == destination.Row)
            {
                return Direction.None;
            }
            if (source.Col == destination.Col)
            {
                if (source.Row < destination.Row)
                {
                    return Direction.Down;
                }
                else
                {
                    return Direction.Up;
                }

            }
            else
            {
                if (source.Col < destination.Col)
                {
                    return Direction.Right;
                }
                else
                {
                    return Direction.Left;
                }
            }
        }
Ejemplo n.º 2
0
        public static Grid GetBackOf(Grid currentGrid, Direction facingDirection)
        {
            Grid targetGrid = currentGrid;
            if (facingDirection == Direction.Up)
            {
                targetGrid.Row += 1;
            }
            else if (facingDirection == Direction.Down)
            {
                targetGrid.Row -= 1;
            }
            else if (facingDirection == Direction.Left)
            {
                targetGrid.Col += 1;
            }
            else if (facingDirection == Direction.Right)
            {
                targetGrid.Col -= 1;
            }
            else // None
            {

            }
            return targetGrid;
        }
Ejemplo n.º 3
0
Archivo: Maze.cs Proyecto: ZwodahS/LD25
 public bool InRange(Grid grid)
 {
     if (grid.Row < 0 || grid.Col < 0 || grid.Row >= Tiles.GetLength(0) || grid.Col >= Tiles.GetLength(1))
     {
         return false;
     }
     return true;
 }
Ejemplo n.º 4
0
Archivo: Maze.cs Proyecto: ZwodahS/LD25
 public Tile GetTile(Grid grid)
 {
     if (!InRange(grid))
     {
         return null;
     }
     return Tiles[grid.Row, grid.Col];
 }
Ejemplo n.º 5
0
Archivo: Maze.cs Proyecto: ZwodahS/LD25
 public bool CanPlace(Grid g)
 {
     if (!InRange(g))
     {
         return false;
     }
     if (Tiles[g.Row, g.Col].IsExit)
     {
         return false;
     }
     foreach (Unit u in Humans)
     {
         if (u.TargetGrid == g || u.CurrentGrid == g)
         {
             return false;
         }
     }
     return true;
 }
Ejemplo n.º 6
0
Archivo: Maze.cs Proyecto: ZwodahS/LD25
 public void PlaceTile(Tile NextTile, Grid g)
 {
     NextTile.CurrentGrid = g;
     Tiles[g.Row, g.Col] = NextTile;
 }
Ejemplo n.º 7
0
Archivo: Maze.cs Proyecto: ZwodahS/LD25
 public void Kidnap(Unit unit)
 {
     Grid grid = new Grid(rng.Next(4,8),rng.Next(4,8));
     unit.SetGrid(grid);
     unit.ContainingMaze = this;
     Humans.Add(unit);
 }
Ejemplo n.º 8
0
 public Grid PointToGrid(Point p)
 {
     Grid g = new Grid((int)p.Y / MazeMaster.TileSize, (int)p.X / MazeMaster.TileSize);
     return g;
 }
Ejemplo n.º 9
0
 public void PlaceTile(Grid g)
 {
     if (CurrentMaze.CanPlace(g))
     {
         CurrentMaze.PlaceTile(NextTile, g);
         RandomNext();
     }
 }