Exemplo n.º 1
0
        public static bool ValidateMovement(Globals.Directions dir, int row, int column)
        {
            int rowInc = 0;
            int colInc = 0;

            switch (dir)
            {
            case Globals.Directions.Up:
                rowInc--;
                break;

            case Globals.Directions.Right:
                colInc++;
                break;

            case Globals.Directions.Down:
                rowInc++;
                break;

            case Globals.Directions.Left:
                colInc--;
                break;
            }
            return(Globals.GameBoard[row + rowInc, column + colInc] != (int)Globals.BlockTypes.Wall &&
                   Globals.GameBoard[row + rowInc, column + colInc] != (int)Globals.BlockTypes.Exterior);
        }
        /// <summary>
        /// Gets the opposite direction than the direction enum
        /// </summary>
        /// <param name="value">Enumeration reference</param>
        /// <returns>Returns a string name of the reverse direction</returns>
        public static string GetOpposite(this Globals.Directions value)
        {
            switch (value)
            {
            case Globals.Directions.Down:
                return("up");

            case Globals.Directions.Up:
                return("down");

            case Globals.Directions.West:
                return("east");

            case Globals.Directions.East:
                return("west");

            case Globals.Directions.North:
                return("south");

            case Globals.Directions.South:
                return("north");

            case Globals.Directions.Northeast:
                return("southwest");

            case Globals.Directions.Southwest:
                return("northeast");

            case Globals.Directions.Northwest:
                return("southeast");

            case Globals.Directions.Southeast:
                return("northwest");

            default:
                return("none");
            }
        }