Ejemplo n.º 1
0
 public bool move(int x, int y)       //Move the pawn to a new square. Fails if can't do that, star fox. Doesn't check for movement blocks or valid move distance.
 {
     if (x >= 0 && x < grid.Width() && y >= 0 && y < grid.Height())
     {
         if (grid [x, y].occupied == 0 && grid [x, y].occupant == null)
         {
             grid [gridX, gridY].occupied = 0;
             grid [gridX, gridY].occupant = null;
             grid [x, y].occupied         = team;
             grid [x, y].occupant         = this;
             gridX = x;
             gridY = y;
             transform.position = grid.worldPos(gridX, gridY);
             active             = false;
             return(true);
         }
         else
         {
             Debug.LogError("Pawn Movement Failed. Space already occupied");
             return(false);
         }
     }
     else
     {
         Debug.LogError("Pawn Movement Out of Bounds");
         return(false);
     }
 }
Ejemplo n.º 2
0
 public void addToGrid(movementGrid Grid)
 {
     grid = Grid;
     if (gridX >= 0 && gridY >= 0 && gridX < grid.Width() && gridY < grid.Height())
     {
         grid [gridX, gridY].restricted = Blocked;
         grid [gridX, gridY].slow       = Slowed;
         transform.position             = grid.worldPos(gridX, gridY);
     }
     else
     {
         Debug.LogError("Invalid grid obstacle position");
     }
 }