Exemplo n.º 1
0
 public Plane(Coordinates topLeft, int difficulty)
     : base(topLeft, new char[,] { { '<' } }, new Coordinates(0, -1))
 {
     this.HasToDropBombs = false;
     this.difficulty = difficulty;
     this.bombRand = new Random();
 }
Exemplo n.º 2
0
 public PlaneProducer(Coordinates worldEnd, int difficulty)
 {
     this.ScoreMultiplier = 1;
     this.worldEnd = worldEnd;
     this.difficulty = difficulty;
     CalculateChances();
 }
Exemplo n.º 3
0
        public override IEnumerable<GameObject> ProduceObjects()
        {
            List<GameObject> produced = new List<GameObject>();

            if (this.HasToShoot)
            {
                Coordinates missileCoordinates1 = new Coordinates(this.topLeft.Row - 1, this.topLeft.Colum);
                Coordinates missileCoordinates2 = new Coordinates(this.topLeft.Row - 1, this.topLeft.Colum + 1);
                Coordinates missileCoordinates3 = new Coordinates(this.topLeft.Row - 1, this.topLeft.Colum - 1);

                if( this.shootingLevel == 1 ) produced.Add(new Missile(missileCoordinates1));
                if (this.shootingLevel == 2)
                {
                    produced.Add(new Missile(missileCoordinates2));
                    produced.Add(new Missile(missileCoordinates3));
                }
                if (this.shootingLevel > 2)
                {
                    produced.Add(new Missile(missileCoordinates1));
                    produced.Add(new Missile(missileCoordinates2));
                    produced.Add(new Missile(missileCoordinates3));
                }
            }

            this.HasToShoot = false;
            return produced;
        }
Exemplo n.º 4
0
        public override IEnumerable<GameObject> ProduceObjects()
        {
            List<GameObject> produced = new List<GameObject>();

            if (HasToDropBombs)
            {
                HasToDropBombs = false;
                Coordinates bombCoords = new Coordinates(this.topLeft.Row + 1, this.topLeft.Colum);

                produced.Add(new Bomb(bombCoords));
            }
            return produced;
        }
Exemplo n.º 5
0
        static void Main()
        {
            int worldRows = Coordinates.worldRows;
            int worldColums = Coordinates.worldColums;
            Coordinates endOfWorld = new Coordinates(worldRows, worldColums);

            IUserInterface userInterface = new KeyboardUserInterface();
            ICollisionDispatcher collisionDispatcher = new CollisionDispatcher();
            IRenderer renderer = new ConsoleRenderer(worldRows, worldColums);
            Tank theTank = new Tank(new Coordinates(worldRows - 1, worldColums / 2));
            IEnemyFactory enemy = new PlaneProducer(endOfWorld, 8);

            Engine gameEngine  = new Engine(userInterface, collisionDispatcher, renderer, theTank, enemy, 100);

            gameEngine.Run();
        }
Exemplo n.º 6
0
        public IEnumerable<GameObject> ProduceObjects()
        {
            List<GameObject> produced = new List<GameObject>();

            int firstRowRandom = planeRand.Next(0, 100);
            int secondRowRandom = planeRand.Next(0, 100);
            int thirdRowRandom = planeRand.Next(0, 100);
            int giftPlaneRandom;

            Coordinates firstRow = new Coordinates(0, worldEnd.Colum - 1);
            Coordinates secondRow = new Coordinates(1, worldEnd.Colum - 1);
            Coordinates thirdRow = new Coordinates(2, worldEnd.Colum - 1);

            if (firstRowRandom <= firstRowChance)
            {
                giftPlaneRandom = planeRand.Next(0, 100);

                if (giftPlaneRandom < giftPlaneChance) produced.Add(new GiftPlane(firstRow, 1));
                else produced.Add(new Plane(firstRow, 1));
            }
            if (secondRowRandom <= secondRowChance)
            {
                giftPlaneRandom = planeRand.Next(0, 100);

                if (giftPlaneRandom < giftPlaneChance) produced.Add(new GiftPlane(secondRow, 1));
                else produced.Add(new Plane(secondRow, 1));
            }

            if (thirdRowRandom <= thirdRowChance)
            {
                giftPlaneRandom = planeRand.Next(0, 100);

                if (giftPlaneRandom < giftPlaneChance) produced.Add(new GiftPlane(thirdRow, 1));
                else produced.Add(new Plane(thirdRow, 1));
            }

            return produced;
        }
Exemplo n.º 7
0
 public GameObject(Coordinates topLeft, char[,] body)
 {
     this.topLeft = topLeft;
     this.body = body;
     this.IsDestroyed = false;
 }
Exemplo n.º 8
0
 public void MoveTankRight()
 {
     Coordinates newTankCoords = new Coordinates(theTank.topLeft.Row, theTank.topLeft.Colum + 1);
     if( newTankCoords.IsInRange() ) this.theTank.topLeft.Colum++;
 }
Exemplo n.º 9
0
 public Missile(Coordinates topLeft)
     : base(topLeft, new char[,] { { '|' } }, new Coordinates(-1, 0))
 {
 }
Exemplo n.º 10
0
 public Gift(Coordinates topLeft)
     : base(topLeft, new char[,] { { '+' } }, new Coordinates(1, 0))
 {
 }
Exemplo n.º 11
0
 public MovingObject(Coordinates topLeft, char[,] body, Coordinates speed)
     : base(topLeft, body)
 {
     this.speed = speed;
 }
Exemplo n.º 12
0
 public Tank(Coordinates topLeft)
     : base(topLeft, new char[,] { { '^' } })
 {
     shootingLevel = 1;
 }
Exemplo n.º 13
0
 public Bomb(Coordinates topLeft)
     : base(topLeft, new char[,] { { '@' } }, new Coordinates(1, 0))
 {
 }
Exemplo n.º 14
0
 public GiftPlane(Coordinates topLeft, int difficulty)
     : base(topLeft, difficulty)
 {
     this.dropGift = false;
     this.body = new char[,] { { '«' } };
 }