Question: c# help with this method i have this... public Game(int numPlayers, int numRounds) { if ((numPlayers >=1 && numPlayers = 1 && numRounds
c# help with this method
i have this...
public Game(int numPlayers, int numRounds) { if ((numPlayers >=1 && numPlayers <= 8) && (numRounds >= 1 && numRounds <= 100)) { this.players = new TankController[numPlayers]; List
public int GetNumPlayers() { return players.Length; }// end GetNumPlayers
NEED HELP WITH THE METHOD BELOW...
public static int[] GetPlayerLocations(int numPlayers) {
-Given a number of players, this static method returns an array giving the horizontal positions of those players on the map. For example, if GetPlayerLocations(2) was called, it would return something like {39, 119}. Note that the total width of the map (160) is stored in the Terrain.WIDTH constant so use this in your calculations.
-Player positions in the array are to be strictly from left to right: e.g. {40, 120} is okay, but {120, 40} is not okay.
-The array size must equal numPlayers; GetPlayerLocations(4) must return an array of length 4, for example.
-Each player is to be placed equally close to its neighbours- for four players, if the first player is 40 tiles away from the second player, the second player should be (approximately) 40 tiles away from the third player and the third player should be (approximately) 40 tiles away from the last player.
-The leftmost and rightmost players should be placed a distance away from their respective horizontal border that is half the size of the distance between players.
-To ensure that tanks are attractively positioned, take into account that a Tank is 4 x 3 and these locations are based on the leftmost position of the tank.
-Because this method returns integers, it is not necessary that the distances described be exact as in many situations this may be impossible. It may be preferable to work with floats, then round them with Math.Round and cast them to ints before putting them in the array. This is not necessary, however.
-numPlayers will never be less than 2; however, it won't necessarily be limited to the maximum number of players. As a result you should calculate these positions rather than having predefined arrays for each player count. That said, if your method works for up to 8 players and doesn't work for a greater number of players you should still receive most of the marks for this method.
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
