예제 #1
0
        private static int[] wormHole_square  = { 2, 3, 5, 12, 16, 29, 40, 45 };    //Square of Worm Holes
        /// <summary>
        /// Parameterless Constructor
        /// Initialises a board consisting of a mix of Ordinary Squares,
        ///     Wormhole Squares and Blackhole Squares.
        ///
        /// Pre:  none
        /// Post: board is constructed
        /// </summary>
        public static void SetUpBoard()
        {
            // Create the 'start' square where all players will start.
            squares[START_SQUARE_NUMBER] = new Square("Start", START_SQUARE_NUMBER);

            for (int b = 1; b < NUMBER_OF_SQUARES - 1; b++)
            {
                if (!blackHole_square.Contains(b) || !wormHole_square.Contains(b))
                {
                    squares[b] = new Square(b.ToString(), b);
                }
            }
            //Create the BlackHoles Square
            for (int i = 0; i < blackHoles.GetLength(0); i++)
            {
                squares[blackHoles[i, 0]] = new BlackholeSquare(blackHoles[i, 0].ToString(), blackHoles[i, 0], blackHoles[i, 1], blackHoles[i, 2]);
            }
            //Create the WormHoles Square
            for (int a = 0; a < wormHoles.GetLength(0); a++)
            {
                squares[wormHoles[a, 0]] = new WormholeSquare(wormHoles[a, 0].ToString(), wormHoles[a, 0], wormHoles[a, 1], wormHoles[a, 2]);
            }

            // Create the 'finish' square.
            squares[FINISH_SQUARE_NUMBER] = new Square("Finish", FINISH_SQUARE_NUMBER);
        } // end SetUpBoard
예제 #2
0
        /// <summary>
        /// Parameterless Constructor
        /// Initialises a board consisting of a mix of Ordinary Squares,
        ///     Wormhole Squares and Blackhole Squares.
        ///
        /// Pre:  none
        /// Post: board is constructed
        /// </summary>
        public static void SetUpBoard()
        {
            // Create the 'start' square where all players will start.
            squares[START_SQUARE_NUMBER] = new Square("Start", START_SQUARE_NUMBER);

            // Populate array with normal squares.
            for (int i = 1; i < FINISH_SQUARE_NUMBER; i++)
            {
                squares[i] = new Square(string.Format("{0}", i), i);
            }

            int    number, next, fuel;
            string name;

            // Populate array with blackholes.
            for (int i = 0; i < blackHoles.GetLength(0); i++)
            {
                number = blackHoles[i, 0];
                name   = string.Format("{0}", number);
                FindDestSquare(blackHoles, number, out next, out fuel);
                Squares[number] = new BlackholeSquare(name, number, next, fuel);
            }

            // Populate array with wormholes.
            for (int i = 0; i < wormHoles.GetLength(0); i++)
            {
                number = wormHoles[i, 0];
                name   = string.Format("{0}", number);
                FindDestSquare(wormHoles, number, out next, out fuel);
                Squares[number] = new WormholeSquare(name, number, next, fuel);
            }

            // Create the 'finish' square.
            squares[FINISH_SQUARE_NUMBER] = new Square("Finish", FINISH_SQUARE_NUMBER);
        }         // end SetUpBoard
예제 #3
0
        /// <summary>
        /// Parameterless Constructor
        /// Initialises a board consisting of a mix of Ordinary Squares,
        ///     Wormhole Squares and Blackhole Squares.
        ///
        /// Pre:  none
        /// Post: board is constructed
        /// </summary>
        public static void SetUpBoard()
        {
            // Create the 'start' square where all players will start.
            squares[START_SQUARE_NUMBER] = new Square("Start", START_SQUARE_NUMBER);

            // Create the main part of the board, squares 1 .. 54

            for (int i = 1; i < NUMBER_OF_SQUARES - 1; i++)
            {
                for (int j = 0; j < 7; j++)
                {
                    if (i == blackHoles[j, 0])
                    {
                        squares[i] = new BlackholeSquare("Square " + i, blackHoles[j, 0], blackHoles[j, 1], blackHoles[j, 2]);
                    }
                    else if (i == wormHoles[j, 0])
                    {
                        squares[i] = new WormholeSquare("Square " + i, wormHoles[j, 0], wormHoles[j, 1], wormHoles[j, 2]);
                    }
                    else
                    {
                        squares[i] = new Square("Square " + i, i);
                    }
                }
            }
            //   Need to call the appropriate constructor for each square
            //       either new Square(...),  new WormholeSquare(...) or new BlackholeSquare(...)
            //

            // Create the 'finish' square.
            squares[FINISH_SQUARE_NUMBER] = new Square("Finish", FINISH_SQUARE_NUMBER);
        } // end SetUpBoard
예제 #4
0
        /// <summary>
        /// Parameterless Constructor
        /// Initialises a board consisting of a mix of Ordinary Squares,
        ///     Wormhole Squares and Blackhole Squares.
        ///
        /// Pre:  none
        /// Post: board is constructed
        /// </summary>
        public static void SetUpBoard()
        {
            // Create the 'start' square where all players will start.
            squares[START_SQUARE_NUMBER] = new Square("Start", START_SQUARE_NUMBER);

            // Create the main part of the board, squares 1 .. 54
            //  CODE NEEDS TO BE ADDED HERE

            //
            //   Need to call the appropriate constructor for each square
            //       either new Square(...),  new WormholeSquare(...) or new BlackholeSquare(...)
            // Square for Wormhole
            for (int i = 0; i < wormHoles.GetLength(0); i++)
            {
                //string name = i.ToString();
                squares[wormHoles[i, 0]] = new WormholeSquare(wormHoles[i, 0].ToString(), wormHoles[i, 0], wormHoles[i, 1], wormHoles[i, 2]);
            }

            // Square for Blackhole
            for (int i = 0; i < blackHoles.GetLength(0); i++)
            {
                // string name = i.ToString();
                squares[blackHoles[i, 0]] = new BlackholeSquare(blackHoles[i, 0].ToString(), blackHoles[i, 0], blackHoles[i, 1], blackHoles[i, 2]);
            }

            // Square for holes
            for (int i = 0; i < oHoles.GetLength(0); i++)
            {
                //string name = i.ToString();
                squares[oHoles[i]] = new Square(oHoles[i].ToString(), oHoles[i]);
            }

            // Create the 'finish' square.
            squares[FINISH_SQUARE_NUMBER] = new Square("Finish", FINISH_SQUARE_NUMBER);
        } // end SetUpBoard
예제 #5
0
        /// <summary>
        /// Parameterless Constructor
        /// Initialises a board consisting of a mix of Ordinary Squares,
        ///     Wormhole Squares and Blackhole Squares.
        ///
        /// Pre:  none
        /// Post: board is constructed
        /// </summary>
        public static void SetUpBoard()
        {
            // Create the 'start' square where all players will start.
            squares[START_SQUARE_NUMBER] = new Square("Start", START_SQUARE_NUMBER);

            // Fill the board with ordinary squares
            for (int i = 1; i < FINISH_SQUARE_NUMBER; i++)
            {
                squares[i] = new Square(i.ToString(), i);
            }

            //Replace ordinary squares with wormholes or blackholes at the target element position
            //using wormHoles.GetLength(0) as both arrays are of the same length in the first dimension
            for (int iterator = 0; iterator < wormHoles.GetLength(0); iterator++)
            {
                squares[wormHoles[iterator, 0]] = new WormholeSquare
                                                  (
                    wormHoles[iterator, 0].ToString(),
                    wormHoles[iterator, 0],
                    wormHoles[iterator, 1],
                    wormHoles[iterator, 2]
                                                  );

                squares[blackHoles[iterator, 0]] = new BlackholeSquare
                                                   (
                    blackHoles[iterator, 0].ToString(),
                    blackHoles[iterator, 0],
                    blackHoles[iterator, 1],
                    blackHoles[iterator, 2]
                                                   );
            }

            // Create the 'finish' square.
            squares[FINISH_SQUARE_NUMBER] = new Square("Finish", FINISH_SQUARE_NUMBER);
        } // end SetUpBoard
예제 #6
0
        /// <summary>
        /// Parameterless Constructor
        /// Initialises a board consisting of a mix of Ordinary Squares,
        ///     Wormhole Squares and Blackhole Squares.
        ///
        /// Pre:  none
        /// Post: board is constructed
        /// </summary>
        public static void SetUpBoard()
        {
            // Create the 'start' square where all players will start.
            squares[START_SQUARE_NUMBER] = new Square("Start", START_SQUARE_NUMBER);

            // Create the main part of the board, squares 1 .. 54
            //  CODE NEEDS TO BE ADDED HERE
            for (int i = START_SQUARE_NUMBER + 1; i < FINISH_SQUARE_NUMBER; i++)
            {
                for (int f = 0; f < 8; f++)
                {
                    if (wormHoles[f, 0] == i)
                    {
                        squares[i] = new WormholeSquare(i.ToString(), wormHoles[f, 0], wormHoles[f, 1], wormHoles[f, 2]);
                    }
                    else if (blackHoles[f, 0] == i)
                    {
                        squares[i] = new BlackholeSquare(i.ToString(), blackHoles[f, 0], blackHoles[f, 1], blackHoles[f, 2]);
                    }
                }
                if (squares[i] == null)
                {
                    squares[i] = new Square(i.ToString(), i);
                }
            }
            //
            //   Need to call the appropriate constructor for each square
            //       either new Square(...),  new WormholeSquare(...) or new BlackholeSquare(...)
            //

            // Create the 'finish' square.
            squares[FINISH_SQUARE_NUMBER] = new Square("Finish", FINISH_SQUARE_NUMBER);
        } // end SetUpBoard
예제 #7
0
        /// <summary>
        /// Parameterless Constructor
        /// Initialises a board consisting of a mix of Ordinary Squares,
        ///     Wormhole Squares and Blackhole Squares.
        ///
        /// Pre:  none
        /// Post: board is constructed
        /// </summary>
        public static void SetUpBoard()
        {
            // Create the 'start' square where all players will start.
            squares[START_SQUARE_NUMBER] = new Square("Start", START_SQUARE_NUMBER);

            //Loop through every square on the board apart from the start and finish
            for (int i = START_SQUARE_NUMBER + 1; i < FINISH_SQUARE_NUMBER; i++)
            {
                //loop through the blackhole and wormhole arrays
                for (int x = 0; x < 8; x++)
                {
                    //if the square isn't a blackhole or wormhole
                    if (i != blackHoles[x, 0] && i != wormHoles[x, 0])
                    {
                        //Create the normal square
                        squares[i] = new Square(i.ToString(), i);
                    }
                }
            }

            //Create wormhole and blackhole squares
            for (int i = 0; i < 8; i++)
            {
                squares[wormHoles[i, 0]]  = new WormholeSquare(wormHoles[i, 0].ToString(), wormHoles[i, 0], wormHoles[i, 1], wormHoles[i, 2]);
                squares[blackHoles[i, 0]] = new BlackholeSquare(blackHoles[i, 0].ToString(), blackHoles[i, 0], blackHoles[i, 1], blackHoles[i, 2]);
            }

            // Create the 'finish' square.
            squares[FINISH_SQUARE_NUMBER] = new Square("Finish", FINISH_SQUARE_NUMBER);
        } // end SetUpBoard
예제 #8
0
        /// <summary>
        /// Parameterless Constructor
        /// Initialises a board consisting of a mix of Ordinary Squares,
        ///     Wormhole Squares and Blackhole Squares.
        ///
        /// Pre:  none
        /// Post: board is constructed
        /// </summary>
        public static void SetUpBoard()
        {
            // Create the 'start' square where all players will start.
            squares[START_SQUARE_NUMBER] = new Square("Start", START_SQUARE_NUMBER);

            // Create the main part of the board, squares 1 .. 54
            //   Need to call the appropriate constructor for each square
            //       either new Square(...),  new WormholeSquare(...) or new BlackholeSquare(...)
            //

            string typeOfSquare = "";


            for (int LIVE_SQUARE = (START_SQUARE_NUMBER + 1); LIVE_SQUARE < FINISH_SQUARE_NUMBER; LIVE_SQUARE++)
            {
                //WHERE live_square is the current square player is positioned on
                //Check type of square; regular, blackhole, wormhole

                /* To do this:
                 * get live square value as string
                 * use FindDestSquare & set vars for the irregular square types
                 * use earlier square class for regular square type
                 * if statement to check square based on fuel
                 */
                typeOfSquare = string.Format("{0}", LIVE_SQUARE);

                int blackhole_destNum;
                int blackhole_fuelAmount;

                int wormhole_destNum;
                int wormhole_fuelAmount;


                FindDestSquare(blackHoles, LIVE_SQUARE, out blackhole_destNum, out blackhole_fuelAmount);
                FindDestSquare(wormHoles, LIVE_SQUARE, out wormhole_destNum, out wormhole_fuelAmount);

                if (blackhole_fuelAmount > 0)
                {
                    squares[LIVE_SQUARE] = new BlackholeSquare(typeOfSquare, LIVE_SQUARE, blackhole_destNum, blackhole_fuelAmount);
                }
                else if (wormhole_fuelAmount > 0)
                {
                    squares[LIVE_SQUARE] = new WormholeSquare(typeOfSquare, LIVE_SQUARE, wormhole_destNum, wormhole_fuelAmount);
                }
                else
                {
                    squares[LIVE_SQUARE] = new Square(typeOfSquare, LIVE_SQUARE);
                }
            }
            // Create the 'finish' square.
            squares[FINISH_SQUARE_NUMBER] = new Square("Finish", FINISH_SQUARE_NUMBER);
        } // end SetUpBoard
예제 #9
0
        /// <summary>
        /// Parameterless Constructor
        /// Initialises a board consisting of a mix of Ordinary Squares,
        ///     Wormhole Squares and Blackhole Squares.
        ///
        /// Pre:  none
        /// Post: board is constructed
        /// </summary>
        public static void SetUpBoard()
        {
            // Create the 'start' square where all players will start.
            squares[START_SQUARE_NUMBER] = new Square("Start", START_SQUARE_NUMBER);

            int wormCounter = 0, counter = 0;
            int fuel = 0, destSquare = 0, currentSquare = 0;

            //iterate through Squares array
            for (int position = 1; position < (squares.Length - 1); position++)
            {
                //create BlackHole square if current position in Squares array matches
                //the first index of any of BlackHole array's elements
                if (counter < blackHoles.GetLength(0) && position == blackHoles[counter, 0])
                {
                    //set blackHole elements to appropriate identifier
                    currentSquare = blackHoles[counter, 0];
                    destSquare    = blackHoles[counter, 1];
                    fuel          = blackHoles[counter, 2];

                    //create new BlackHole Square with values specified in arrays
                    squares[position] = new BlackholeSquare(position.ToString(), currentSquare, destSquare, fuel);
                    //determine values for next destination square and fuel consumption
                    FindDestSquare(blackHoles, currentSquare, out destSquare, out fuel);

                    counter++;
                }//end creation of blackHole square

                //create wormHole square if current position matches
                //first index of any wormHole array elements
                else if (wormCounter < wormHoles.GetLength(0) && position == wormHoles[wormCounter, 0])
                {
                    currentSquare = wormHoles[counter, 0];
                    destSquare    = wormHoles[counter, 1];
                    fuel          = wormHoles[counter, 2];

                    squares[position] = new WormholeSquare(position.ToString(),
                                                           (wormHoles[wormCounter, 0]), (wormHoles[wormCounter, 1]), (wormHoles[wormCounter, 2]));
                    FindDestSquare(wormHoles, position, out destSquare, out fuel);

                    wormCounter++;
                }//end creation of wormHole square
                else
                {
                    //if current position doesn't match elements in array, create an ordinary square
                    squares[position] = new Square(position.ToString(), position);
                } //end creation of ordinary squares
            }     //end iteration
            // Create the 'finish' square.
            squares[FINISH_SQUARE_NUMBER] = new Square("Finish", FINISH_SQUARE_NUMBER);
        } // end SetUpBoard
예제 #10
0
        /// <summary>
        /// Parameterless Constructor
        /// Initialises a board consisting of a mix of Ordinary Squares,
        ///     Wormhole Squares and Blackhole Squares.
        ///
        /// Pre:  none
        /// Post: board is constructed
        /// </summary>
        public static void SetUpBoard()
        {
            // Create the 'start' square where all players will start.
            squares[START_SQUARE_NUMBER] = new Square("Start", START_SQUARE_NUMBER);

            // Count how many times a wormhole/blackhole has been added & check out many holes there are.
            int  countWormHoles  = 0;
            int  countBlackHoles = 0;
            long numOfWormHoles  = wormHoles.GetLongLength(0);
            long numOfBlackHoles = blackHoles.GetLongLength(0);

            // Add a square depending on the square number on the board.
            for (int i = 1; i < FINISH_SQUARE_NUMBER; i++)
            {
                string nameOfSquare = i.ToString();

                // If there hasnt been all the wormholes yet,
                // and the square number is equal to an element in
                // the hole array, then add the appropriate square
                // and count up the number of holes been.
                if (countWormHoles < numOfWormHoles && i == wormHoles[countWormHoles, 0])
                {
                    int nextSquare   = wormHoles[countWormHoles, 1];
                    int fuelConsumed = wormHoles[countWormHoles, 2];
                    squares[i] = new WormholeSquare(nameOfSquare, i, nextSquare, fuelConsumed);

                    countWormHoles++;
                }
                // If it's not a wormhole, check if it's a black hole.
                else if (countBlackHoles < numOfBlackHoles && i == blackHoles[countBlackHoles, 0])
                {
                    int nextSquare   = blackHoles[countBlackHoles, 1];
                    int fuelConsumed = blackHoles[countBlackHoles, 2];
                    squares[i] = new BlackholeSquare(nameOfSquare, i, nextSquare, fuelConsumed);

                    countBlackHoles++;
                }
                // If the position (square number) is not a wormhole/blackhole add a regular square.
                else
                {
                    squares[i] = new Square(nameOfSquare, i);
                }
            }
            // Create the 'finish' square.
            squares[FINISH_SQUARE_NUMBER] = new Square("Finish", FINISH_SQUARE_NUMBER);
        } // end SetUpBoard
예제 #11
0
        /// <summary>
        /// Parameterless Constructor
        /// Initialises a board consisting of a mix of Ordinary Squares,
        ///     Wormhole Squares and Blackhole Squares.
        ///
        /// Pre:  none
        /// Post: board is constructed
        /// </summary>
        public static void SetUpBoard()
        {
            // Create the 'start' square where all players will start.
            squares[START_SQUARE_NUMBER] = new Square("Start", START_SQUARE_NUMBER);

            // Create the main part of the board, squares 1 .. 54
            //  CODE NEEDS TO BE ADDED HERE
            //
            //   Need to call the appropriate constructor for each square
            //       either new Square(...),  new WormholeSquare(...) or new BlackholeSquare(...)


            int whichWormHole  = START_SQUARE_NUMBER;
            int whichBlackHole = 0;

            for (int i = 1; i < (squares.Length - 1); i++)
            {
                string squareName = "" + i;

                // code for the wormholes
                if (i == 2 || i == 3 || i == 5 || i == 12 || i == 16 || i == 29 || i == 40 || i == 45)
                {
                    //squares[i] = new WormholeSquare(squareName, i, wormHoles[whichWormHole, 1], wormHoles[whichWormHole, 2]);
                    squares[i] = new WormholeSquare(squareName, i, wormHoles[whichWormHole, 1], wormHoles[whichWormHole, 2]);
                    whichWormHole++;
                }

                // code for the blackholes
                else if (i == 10 || i == 26 || i == 30 || i == 35 || i == 36 || i == 49 || i == 52 || i == 53)
                {
                    squares[i] = new BlackholeSquare(squareName, i, blackHoles[whichBlackHole, 1], blackHoles[whichBlackHole, 2]);
                    whichBlackHole++;
                }

                else
                {
                    squares[i] = new Square(squareName, i);
                }

                Squares[i] = squares[i]; // adds the values to a public array?
            }

            // Create the 'finish' square.
            squares[FINISH_SQUARE_NUMBER] = new Square("Finish", FINISH_SQUARE_NUMBER);
        } // end SetUpBoard
예제 #12
0
        /// <summary>
        /// Parameterless Constructor
        /// Initialises a board consisting of a mix of Ordinary Squares,
        ///     Wormhole Squares and Blackhole Squares.
        ///
        /// Pre:  none
        /// Post: board is constructed
        /// </summary>
        public static void SetUpBoard()
        {
            bool foundState = false;

            // Create the 'start' square where all players will start.
            squares[START_SQUARE_NUMBER] = new Square("Start", START_SQUARE_NUMBER);

            // Create the main part of the board, squares 1 .. 54
            //  CODE NEEDS TO BE ADDED HERE
            //
            //   Need to call the appropriate constructor for each square
            //       either new Square(...),  new WormholeSquare(...) or new BlackholeSquare(...)

            for (int i = START_SQUARE_NUMBER + 1; i <= FINISH_SQUARE_NUMBER - 1; i++) // board iteration
            {
                foundState = false;                                                   // intialise foundState to be false for each new board iteration

                for (int j = 0; j <= WORM_HOLES_LENGTH - 1; j++)                      // b.hole and w.hole iteration
                {
                    if (i == wormHoles[j, 0])                                         // match the board coord with the w.hole coord
                    {
                        squares[i] = new WormholeSquare(i.ToString(), i, wormHoles[j, 1], wormHoles[j, 2]);
                        foundState = true; // set Foundstate to be true
                        break;
                    }
                    else if (i == blackHoles[j, 0]) // match the board coord with the b.hole coord
                    {
                        squares[i] = new BlackholeSquare(i.ToString(), i, blackHoles[j, 1], blackHoles[j, 2]);
                        foundState = true; // set foundState to be true
                        break;
                    }
                }

                if (foundState == false)
                {
                    squares[i] = new Square(i.ToString(), i);
                }
            }

            //

            // Create the 'finish' square.
            squares[FINISH_SQUARE_NUMBER] = new Square("Finish", FINISH_SQUARE_NUMBER);
        } // end SetUpBoard
예제 #13
0
        /// <summary>
        /// Parameterless Constructor
        /// Initialises a board consisting of a mix of Ordinary Squares,
        ///     Wormhole Squares and Blackhole Squares.
        ///
        /// Pre:  none
        /// Post: board is constructed
        /// </summary>
        public static void SetUpBoard()
        {
            Class1 prestn    = null;
            var    firstname = prestn?.Name ?? "und";

            Console.WriteLine(firstname);
            // Create the 'start' square where all players will start.
            squares[StartSquareNumber] = new Square("Start", StartSquareNumber);

            // Create blockholes.
            for (var i = 0; i < blackHoles.Length / 3; i++)
            {
                var number = blackHoles[i, 0];
                var name   = $"{number}";
                var next   = blackHoles[i, 1];
                var fuel   = blackHoles[i, 2];
                squares[number] = new BlackholeSquare(name, number, next, fuel);
            }
            // Create wormholes.
            for (var i = 0; i < wormHoles.Length / 3; i++)
            {
                var number = wormHoles[i, 0];
                var name   = $"{number}";
                var next   = wormHoles[i, 1];
                var fuel   = wormHoles[i, 2];
                squares[number] = new WormholeSquare(name, number, next, fuel);
            }
            // Create ordinary squares.
            for (var i = 1; i < FinishSquareNumber; i++)
            {
                var name   = $"{i}";
                var number = i;
                if (squares[i] == null)
                {
                    squares[i] = new Square(name, number);
                }
            }


            // Create the 'finish' square.
            squares[FinishSquareNumber] = new Square("Finish", FinishSquareNumber);
        } // end SetUpBoard
예제 #14
0
        /// <summary>
        /// Parameterless Constructor
        /// Initialises a board consisting of a mix of Ordinary Squares,
        ///     Wormhole Squares and Blackhole Squares.
        ///
        /// Pre:  none
        /// Post: board is constructed
        /// </summary>
        public static void SetUpBoard()
        {
            bool foundState = false;

            // Create the 'start' square where all players will start.
            squares[START_SQUARE_NUMBER] = new Square("Start", START_SQUARE_NUMBER);

            // Create the main part of the board, squares 1 .. 54
            // Checks if Square is a Black Hole, Worm Hole or neither
            // and creates a square of either Black Hole, Worm Hole or
            // default square type.
            for (int i = START_SQUARE_NUMBER + 1; i <= FINISH_SQUARE_NUMBER - 1; i++)
            {
                foundState = false;

                for (int j = 0; j <= WORM_HOLES_LENGTH - 1; j++) // b.hole and w.hole iteration
                {
                    if (i == wormHoles[j, 0])                    // match the board coord with the w.hole coord
                    {
                        squares[i] = new WormholeSquare(i.ToString(), i, wormHoles[j, 1], wormHoles[j, 2]);
                        foundState = true;
                        break;
                    }
                    else if (i == blackHoles[j, 0]) // match the board coord with the b.hole coord
                    {
                        squares[i] = new BlackholeSquare(i.ToString(), i, blackHoles[j, 1], blackHoles[j, 2]);
                        foundState = true;
                        break;
                    }
                }

                if (foundState == false) // match board coord with a normal square
                {
                    squares[i] = new Square(i.ToString(), i);
                }
            }

            // Create the 'finish' square.
            squares[FINISH_SQUARE_NUMBER] = new Square("Finish", FINISH_SQUARE_NUMBER);
        } // end SetUpBoard
예제 #15
0
        /// <summary>
        /// Parameterless Constructor
        /// Initialises a board consisting of a mix of Ordinary Squares,
        ///     Wormhole Squares and Blackhole Squares.
        ///
        /// Pre:  none
        /// Post: board is constructed
        /// </summary>
        public static void SetUpBoard()
        {
            // Out variables for FindDestSquare method
            int destNum;
            int amount;

            // Create the 'start' square where all players will start.
            squares[START_SQUARE_NUMBER] = new Square("Start", START_SQUARE_NUMBER);

            // Initialize all squares to base square class
            for (int i = 1; i < FINISH_SQUARE_NUMBER; i++)
            {
                string numString = i.ToString();
                squares[i] = new Square(numString, i);
            }

            // Loop to initialize black hole class on appropriate squares
            int numRowsBlackHoles = blackHoles.GetLength(0);

            for (int row = 0; row < numRowsBlackHoles; row++)
            {
                string numString = blackHoles[row, 0].ToString();
                FindDestSquare(blackHoles, blackHoles[row, 0], out destNum, out amount);
                squares[blackHoles[row, 0]] = new BlackholeSquare(numString, blackHoles[row, 0], destNum, amount);
            }

            // Loop to initialize worm hole class on appropriate squares
            int numRowsWormHoles = wormHoles.GetLength(0);

            for (int row = 0; row < numRowsWormHoles; row++)
            {
                string numString = wormHoles[row, 0].ToString();
                FindDestSquare(wormHoles, wormHoles[row, 0], out destNum, out amount);
                squares[wormHoles[row, 0]] = new WormholeSquare(numString, wormHoles[row, 0], destNum, amount);
            }

            // Create the 'finish' square.
            squares[FINISH_SQUARE_NUMBER] = new Square("Finish", FINISH_SQUARE_NUMBER);
        } // end SetUpBoard
예제 #16
0
파일: Board.cs 프로젝트: JessWill/SpaceRace
        /// <summary>
        /// Parameterless Constructor
        /// Initialises a board consisting of a mix of Ordinary Squares,
        ///     Wormhole Squares and Blackhole Squares.
        ///
        /// Pre:  none
        /// Post: board is constructed
        /// </summary>
        public static void SetUpBoard()
        {
            // Create the 'start' square where all players will start.
            squares[START_SQUARE_NUMBER] = new Square("Start", START_SQUARE_NUMBER);

            // Create the main part of the board, squares 1 .. 54
            //  CODE NEEDS TO BE ADDED HERE
            //
            //   Need to call the appropriate constructor for each square
            //       either new Square(...),  new WormholeSquare(...) or new BlackholeSquare(...)
            //
            //create ever square from 1 to 54
            for (int i = 1; i < FINISH_SQUARE_NUMBER; i++)
            {
                //for every subarray in the lists
                for (int y = 0; y < wormHoles.GetLength(0); y++)
                {
                    //if i is found in first position of array, create a blackhole square
                    if (blackHoles[y, 0] == i)
                    {
                        squares[i] = new BlackholeSquare(i.ToString(), i, blackHoles[y, 1], blackHoles[y, 2]);
                    }
                    //check for worm holes
                    //if i is found in first position of arrays, create a blackhole square
                    else if (wormHoles[y, 0] == i)
                    {
                        squares[i] = new WormholeSquare(i.ToString(), i, wormHoles[y, 1], wormHoles[y, 2]);
                    }
                }
                //if i is not found in array, create normal square
                if (squares[i] == null)
                {
                    Squares[i] = new Square(i.ToString(), i);
                }
            }
            // Create the 'finish' square.
            squares[FINISH_SQUARE_NUMBER] = new Square("Finish", FINISH_SQUARE_NUMBER);
        } // end SetUpBoard
예제 #17
0
        /// <summary>
        /// Parameterless Constructor
        /// Initialises a board consisting of a mix of Ordinary Squares,
        ///     Wormhole Squares and Blackhole Squares.
        ///
        /// Pre:  none
        /// Post: board is constructed
        /// </summary>
        public static void SetUpBoard()
        {
            // Create the 'start' square where all players will start.
            squares[START_SQUARE_NUMBER] = new Square("Start", START_SQUARE_NUMBER);
            // Create the main part of the board, squares 1 .. 54
            //  CODE NEEDS TO BE ADDED HERE // DONE
            int next, fuelConsumption;

            for (int i = 1; i < (NUMBER_OF_SQUARES - 1); i++)
            {
                for (int j = 0; j < blackHoles.GetLength(0); j++)
                {
                    if (i == blackHoles[j, 0])
                    {
                        FindDestSquare(blackHoles, i, out next, out fuelConsumption);
                        squares[i] = new BlackholeSquare(i.ToString(), i, next, fuelConsumption);
                        break;
                    }
                    else if (i == wormHoles[j, 0])
                    {
                        FindDestSquare(wormHoles, i, out next, out fuelConsumption);
                        squares[i] = new WormholeSquare(i.ToString(), i, next, fuelConsumption);
                        break;
                    }

                    else
                    {
                        squares[i] = new Square(i.ToString(), i);
                    }
                }
            }
            //   Need to call the appropriate constructor for each square
            //       either new Square(...),  new WormholeSquare(...) or new BlackholeSquare(...) //SOLVED
            //

            // Create the 'finish' square.
            squares[FINISH_SQUARE_NUMBER] = new Square("Finish", FINISH_SQUARE_NUMBER);
        } // end SetUpBoard
예제 #18
0
        /// <summary>
        /// Parameterless Constructor
        /// Initialises a board consisting of a mix of Ordinary Squares,
        ///     Wormhole Squares and Blackhole Squares.
        ///
        /// Pre:  none
        /// Post: board is constructed
        /// </summary>
        public static void SetUpBoard()
        {
            // Create the 'start' square where all players will start.
            squares[START_SQUARE_NUMBER] = new Square("Start", START_SQUARE_NUMBER);

            //  Create the main part of the board, squares 1 .. 54

            //Define two arrays whose elements represents the index of blackhole/wormhole square.
            int[] blkSquare = { 10, 26, 30, 35, 36, 49, 52, 53 }, wrmSquare = { 2, 3, 5, 12, 16, 29, 40, 45 };

            //Attribute each index positions as either Square, Blackhole Square or Wormhole Square.
            //If blackhole, the information of this particular blackhole is retrived by searching the blackHoles array.
            //Same with worm holes.
            //If index does not belong to either, then the square is a normal square with specific properties.
            for (int i = START_SQUARE_NUMBER + 1; i < FINISH_SQUARE_NUMBER; i++)
            {
                if (Array.IndexOf(blkSquare, i) > -1)                //checks if index falls in blkSquare array
                {
                    int index = Array.IndexOf(blkSquare, i);
                    squares[i] = new BlackholeSquare(i.ToString(), blackHoles[index, 0], blackHoles[index, 1], blackHoles[index, 2]);
                }
                else if (Array.IndexOf(wrmSquare, i) > -1)          //checks if index falls in wrmSquare array
                {
                    int index = Array.IndexOf(wrmSquare, i);
                    squares[i] = new WormholeSquare(i.ToString(), wormHoles[index, 0], wormHoles[index, 1], wormHoles[index, 2]);
                }
                else
                {
                    squares[i] = new Square(i.ToString(), i);
                }
            }

            //

            // Create the 'finish' square.
            squares[FINISH_SQUARE_NUMBER] = new Square("Finish", FINISH_SQUARE_NUMBER);
        } // end SetUpBoard