Ejemplo n.º 1
0
 private void ResetRobot()
 {
     while (true)
     {
         var pos = RandomPos();
         if (!InPlaypen(pos) &&
             (this[pos].CurrentStatus == CellStatus.Empty || this[pos].CurrentStatus == CellStatus.Dirt) &&
             AdjacentCells(pos, x => !this[x].IsObstacled() && !this[x].IsPlaypen()).Count > 0)
         {
             Robot.Reset(pos);
             this[pos].SetMobileObject(CellStatus.Robot, Robot);
             break;
         }
     }
 }
Ejemplo n.º 2
0
        //Crea el robot y lo ubica aleatoriamente en una casilla del ambiente
        private void SetRobot(HomeRobot robot)
        {
            Point pos;

            while (Robot == null)
            {
                pos = RandomPos();
                if (!InPlaypen(pos) &&
                    (this[pos].CurrentStatus == CellStatus.Empty || this[pos].CurrentStatus == CellStatus.Dirt) &&
                    AdjacentCells(pos, x => !this[x].IsObstacled() && !this[x].IsPlaypen()).Count > 0)
                {
                    Robot = robot;
                    Robot.Reset(pos);
                    this[pos].SetMobileObject(CellStatus.Robot, Robot);
                }
            }
        }