예제 #1
0
 // On vérifie si on peut ajouter un ship (et non pas shit)
 public bool CanAddShip(Ship s)
 {
     for (int i = 0; i < s.GetSize(); i++)
     {
         if (s.GetOrientation() == Orientations.Horizontal)
         {
             if (!(s.GetCoordinateX() + i < 10))
                 return false;
             else
             {
                 if (!(States[i + s.GetCoordinateX(), s.GetCoordinateY()] == GridStates.Water))
                     return false;
             }
         }
         else
             if (!(s.GetCoordinateY() + i < 10))
                 return false;
             else
             {
                 if (!(States[s.GetCoordinateX(), i + s.GetCoordinateY()] == GridStates.Water))
                     return false;
             }
     }
     return true;
 }
예제 #2
0
 // On vérifie si on peut ajouter un ship (et non pas shit)
 public bool CanAddShip(Ship s)
 {
     for (int i = 0; i < s.GetSize(); i++)
     {
         if (s.GetOrientation() == Orientations.Horizontal)
         {
             if (!(s.GetCoordinateX() + i < 10))
             {
                 return(false);
             }
             else
             {
                 if (!(States[i + s.GetCoordinateX(), s.GetCoordinateY()] == GridStates.Water))
                 {
                     return(false);
                 }
             }
         }
         else
         if (!(s.GetCoordinateY() + i < 10))
         {
             return(false);
         }
         else
         {
             if (!(States[s.GetCoordinateX(), i + s.GetCoordinateY()] == GridStates.Water))
             {
                 return(false);
             }
         }
     }
     return(true);
 }
예제 #3
0
 // On ajoute un bateau
 public void AddShip(Ship s)
 {
     ships.Add(s);
     for(int i=0; i<s.GetSize(); i++)
     {
         if (s.GetOrientation() == Orientations.Horizontal)
             States[i+s.GetCoordinateX(), s.GetCoordinateY()] = GridStates.Ship;
         else
             States[s.GetCoordinateX(), i + s.GetCoordinateY()] = GridStates.Ship;
     }
 }
예제 #4
0
 // On ajoute un bateau
 public void AddShip(Ship s)
 {
     ships.Add(s);
     for (int i = 0; i < s.GetSize(); i++)
     {
         if (s.GetOrientation() == Orientations.Horizontal)
         {
             States[i + s.GetCoordinateX(), s.GetCoordinateY()] = GridStates.Ship;
         }
         else
         {
             States[s.GetCoordinateX(), i + s.GetCoordinateY()] = GridStates.Ship;
         }
     }
 }