Exemplo n.º 1
0
 private static Vector2i NextField(Directories dir, Vector2i vect)
 {
     if (dir == Directories.Right)
         vect.X++;
     else if (dir == Directories.Left)
         vect.X--;
     else if (dir == Directories.Up)
         vect.Y--;
     else if (dir == Directories.Down)
         vect.Y++;
     else if (dir == Directories.LeftUp)
     {
         vect.X--;
         vect.Y--;
     }
     else if (dir == Directories.LeftDown)
     {
         vect.X--;
         vect.Y++;
     }
     else if (dir == Directories.RightUp)
     {
         vect.X++;
         vect.Y--;
     }
     else if (dir == Directories.RightDown)
     {
         vect.X++;
         vect.Y++;
     }
     return vect;
 }
Exemplo n.º 2
0
 public override void SetField(Vector2i vect, char value)
 {
     for (int y = 0; y < Height; y++)
     {
         if (IsFieldEmpty(new Vector2i(vect.X, y)))
         {
             _varField[vect.X, y] = value;
             break;
         }
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="field">Das Spielfeld</param>
 /// <param name="dir">Die Richtung, in die überprüft werden soll.</param>
 /// <param name="player"></param>
 /// <param name="from">Der inklusive untere Vector der Startposition.</param>
 /// <returns></returns>
 private static int DoCheck(Fields.Field field, Directories dir, char player, Vector2i from)
 {
     int counter = 0;
     for (int a = 0; a < GewinnBedingung; a++)
     {
         if (field.GetField(from) == player)
             counter++;
         else break;
         from = NextField(dir, from);
     }
     return counter;
 }
Exemplo n.º 4
0
        public static Vector2i FromIndex(int index, int width, int height)
        {
            if (index < 0)
            {
                throw new ArgumentException("index is to low", "index");
            }

            Vector2i vect = null;
            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    if (x * width + y == index)
                        vect = new Vector2i(x, y);
                }
            }

            return vect;
        }
Exemplo n.º 5
0
 public static int ToIndex(Vector2i vect, int width)
 {
     return vect.X * width + vect.Y;
 }
Exemplo n.º 6
0
 public override bool IsFieldEmpty(Vector2i vect)
 {
     return _varField[vect.X, 0] == ' ';
 }
Exemplo n.º 7
0
 public override char GetField(Vector2i vect)
 {
     return _varField[vect.X, vect.Y];
 }