public Pear(Position position) : base(position, new char[,] {{'P'}}) { }
public PlayerTwo(Position position) : base(position, new char[,] {{'2'}}) { }
public Apple(Position position) : base(position, new char[,] {{'A'}}) { }
public PlayerOne(Position position) : base(position, new char[,] { { '1' } }) { }
public GameObject(Position initialPosition, char[,] objectBody, ConsoleColor color = ConsoleColor.DarkGray) { this.position = initialPosition; this.body = this.CopyGridBody(objectBody); }
public Warrior(Position position, char[,] body) : base(position, body) { }
public void GeneratePlayersOnField() { Random randomGen = new Random(); var map = new bool[,] { {true, true, true, true, true, true, true, true}, {true, true, true, true, true, true, true, true}, {true, true, true, true, true, true, true, true}, {true, true, true, true, true, true, true, true}, {true, true, true, true, true, true, true, true}, {true, true, true, true, true, true, true, true}, {true, true, true, true, true, true, true, true}, {true, true, true, true, true, true, true, true} }; Warrior playerOne = new PlayerOne(new Position( randomGen.Next(startRow, endRow), randomGen.Next(startCol, endCol))); this.AddPlayers(playerOne); map[playerOne.Position.Col - 3, playerOne.Position.Row - 3] = false; var position = new Position( randomGen.Next(0, 8), randomGen.Next(0, 8)); while (!IsPositionAvailable(position, map, 3)) { position = new Position( randomGen.Next(0, 8), randomGen.Next(0, 8)); } Warrior playerTwo = new PlayerTwo(new Position( position.Row + 3, position.Col + 3)); this.AddPlayers(playerTwo); }
private bool IsPositionAvailable(Position position, bool[,] map, int distance) { var result = true; for (int i = position.Col - distance; i < position.Col + distance; i++) { if (i < 0) { i++; continue; } else if (i >= 8) { break; } for (int j = position.Row - distance; j < position.Row + distance; j++) { if (j < 0) { j++; continue; } else if (j >= 8) { break; } result &= map[i, j]; } } return result; }
public void GeneratePears(Random randomGen, int numbers, bool[,] availabilityMap) { for (int i = 0; i < numbers; i++) { var position = new Position( randomGen.Next(0, 8), randomGen.Next(0, 8)); if (IsPositionAvailable(position, availabilityMap, 2)) { pears = new Pear(new Position(position.Row + 3, position.Col + 3)); while ((pears.Position.Row >= playerOne.Position.Row && pears.Position.Row <= playerOne.Position.Row) && (pears.Position.Col >= playerOne.Position.Col && pears.Position.Col <= playerOne.Position.Col) || (pears.Position.Row >= playerTwo.Position.Row && pears.Position.Row <= playerTwo.Position.Row) && (pears.Position.Col >= playerTwo.Position.Col && pears.Position.Col <= playerTwo.Position.Col)) { pears = new Pear(new Position(position.Row + 3, position.Col + 3)); } this.AddStaticObject(pears); availabilityMap[position.Col, position.Row] = false; } else { i--; } } }
public Grid(Position position) : base(position, new char[,] {{'-'}}) { }
public Fruit(Position position, char[,] body) : base(position, body) { }