Exemple #1
0
 public Pear(Position position)
     : base(position, new char[,] {{'P'}})
 {
 }
Exemple #2
0
 public PlayerTwo(Position position)
     : base(position, new char[,] {{'2'}})
 {
 }
Exemple #3
0
 public Apple(Position position)
     : base(position, new char[,] {{'A'}})
 {
 }
Exemple #4
0
 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);
 }
Exemple #6
0
 public Warrior(Position position, char[,] body)
     : base(position, body)
 {
 }
Exemple #7
0
        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);
        }
Exemple #8
0
        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;
        }
Exemple #9
0
        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--;
                }
            }
        }
Exemple #10
0
 public Grid(Position position)
     : base(position, new char[,] {{'-'}})
 {      
 }
Exemple #11
0
 public Fruit(Position position, char[,] body)
     : base(position, body)
 {            
 }