Exemplo n.º 1
0
 public bool Remove(Position P)
 {
     if (P.X < 0 || P.X >= Ships.GetLength(0) || P.Y < 0 || P.Y >= Ships.GetLength(1) || Ships[P.X, P.Y] == null)
     {
         return(false);
     }
     if (Ships[P.X, P.Y] != null && Ships[P.X, P.Y].Type == 0)
     {
         return(false);
     }
     Ships[P.X, P.Y] = null; return(true);
 }
Exemplo n.º 2
0
        public Functions Function(Position P, byte User)
        {
            if (P.X < 0 || P.X >= Ships.GetLength(0) || P.Y < 0 || P.Y >= Ships.GetLength(1))
            {
                return(null);
            }
            if (Ships[P.X, P.Y] == null || Ships[P.X, P.Y].User != User)
            {
                return(null);
            }

            Functions Result = new Functions();

            Result.Route = Ships[P.X, P.Y].Rotation;
            Result.Step  = new bool[3, 3];

            bool Flag = false;

            for (int i = 0; i < 3; ++i)
            {
                for (int j = 0; j < 3; ++j)
                {
                    Result.Step[i, j] = CheckStep(P, new Position {
                        X = i - 1, Y = j - 1
                    }, User);
                    if (Result.Step[i, j] == true)
                    {
                        Flag = true;
                    }
                }
            }

            if (!Flag)
            {
                Result.Step = null;
            }

            return(Result);
        }
Exemplo n.º 3
0
        public int Win()
        {
            int count = 0; int user = 0;

            for (int i = 0; i < Ships.GetLength(0); ++i)
            {
                for (int j = 0; j < Ships.GetLength(1); ++j)
                {
                    if (Ships[i, j] != null && Ships[i, j].Type == 1)
                    {
                        count++; user = Ships[i, j].User;
                    }
                }
            }

            if (count == 2)
            {
                return(0);
            }
            else
            {
                return(user);
            }
        }