Пример #1
0
        public void MoveBoatDown()
        {
            int    size             = BoardDimentions.GetColumns().Count;
            string lastColumn       = BoardDimentions.GetColumns()[size - 1];
            string firstColumn      = BoardDimentions.GetColumns()[0];
            string secondlastColumn = BoardDimentions.GetColumns()[size - 3];

            if (personalBoatLocation.GetColumn() == lastColumn && personalBoatLocation.GetOrientation() == Orientation.X)
            {
                personalBoatLocation.SetColumn(firstColumn);
            }
            else if (personalBoatLocation.GetColumn() == secondlastColumn && personalBoatLocation.GetOrientation() == Orientation.Y)
            {
                personalBoatLocation.SetColumn(firstColumn);
            }
            else
            {
                int columnIndex = BoardDimentions.GetColumns().IndexOf(personalBoatLocation.GetColumn());
                personalBoatLocation.SetColumn(BoardDimentions.GetColumns()[columnIndex + 1]);
            }
        }
Пример #2
0
        public void PlaceItem(BoatLocation location, string item)
        {
            string      row         = location.GetRow();
            string      column      = location.GetColumn();
            Orientation orientation = location.GetOrientation();
            int         rowIndex    = BoardDimentions.GetRows().IndexOf(row);
            int         columnIndex = BoardDimentions.GetColumns().IndexOf(column);

            if (orientation == Orientation.X)
            {
                this.boardValue[row][column] = item;
                this.boardValue[BoardDimentions.GetRows()[rowIndex + 1]][column] = item;
                this.boardValue[BoardDimentions.GetRows()[rowIndex + 2]][column] = item;
            }
            if (orientation == Orientation.Y)
            {
                this.boardValue[row][column] = item;
                this.boardValue[row][BoardDimentions.GetColumns()[columnIndex + 1]] = item;
                this.boardValue[row][BoardDimentions.GetColumns()[columnIndex + 2]] = item;
            }
        }