Esempio 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;
                }
            }
        }
Esempio 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;
        }
Esempio n. 3
0
File: Maze.cs Progetto: 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;
 }
Esempio n. 4
0
File: Maze.cs Progetto: ZwodahS/LD25
 public Tile GetTile(Grid grid)
 {
     if (!InRange(grid))
     {
         return null;
     }
     return Tiles[grid.Row, grid.Col];
 }
Esempio n. 5
0
File: Maze.cs Progetto: 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;
 }
Esempio n. 6
0
File: Maze.cs Progetto: ZwodahS/LD25
 public void PlaceTile(Tile NextTile, Grid g)
 {
     NextTile.CurrentGrid = g;
     Tiles[g.Row, g.Col] = NextTile;
 }
Esempio n. 7
0
File: Maze.cs Progetto: 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);
 }
Esempio n. 8
0
 public Grid PointToGrid(Point p)
 {
     Grid g = new Grid((int)p.Y / MazeMaster.TileSize, (int)p.X / MazeMaster.TileSize);
     return g;
 }
Esempio n. 9
0
 public void PlaceTile(Grid g)
 {
     if (CurrentMaze.CanPlace(g))
     {
         CurrentMaze.PlaceTile(NextTile, g);
         RandomNext();
     }
 }