Exemplo n.º 1
0
 public Ship(int healthPoint, int attackDamage, MatrixCoords position)
 {
     this.AttackDamage = attackDamage;
     this.HealthPoint = healthPoint;
     this.position = position;
     this.Inventory = new Inventory();
 }
Exemplo n.º 2
0
 public PlayerAircraft(MatrixCoords topLeft)
     : base(topLeft, new char[, ] {
     { ' ', ' ', ' ', ' ', ' ', ' ', '/', '\\', ' ', ' ', ' ', ' ', ' ' },
     { ' ', ' ', ' ', ' ', ' ', '|', '|', '|', '|', ' ', ' ', ' ', ' ' },
     { ' ', ' ', ' ', ' ', ' ', '|', '|', '|', '|', ' ', ' ', ' ', ' ' },
     { ' ', '/', '-', '-', '-', ' ', '/', '\\', '-', '-', '-', '\\', ' ' },
     { '/', '_', '_', '_', '_', ' ', '|', '|', '_', '_', '_', '_', '\\' },
     { ' ', ' ', ' ', ' ', ' ', '|', '|', '|', '|', ' ', ' ', ' ', ' ' },
     { ' ', ' ', ' ', ' ', ' ', '|', '|', '|', '|', ' ', ' ', ' ', ' ' },
     { ' ', ' ', ' ', ' ', '/', '/', '|', '|', '\\', '\\', ' ', ' ', ' ' },
     { ' ', ' ', ' ', '/', '_', '_', '/', '\\', '_', '_', '\\', ' ', ' ' },
 })
 {
 }
Exemplo n.º 3
0
        public void EnqueueForRendering(IRenderable obj)//vzema edin obekt i go palni v matricata
        {
            char[,] objImage = obj.GetImage();

            int imageRows = objImage.GetLength(0);
            int imageCols = objImage.GetLength(1);

            MatrixCoords objTopLeft = obj.GetTopLeft();

            int lastRow = Math.Min(objTopLeft.Row + imageRows, this.renderContextMatrixRows);
            int lastCol = Math.Min(objTopLeft.Col + imageCols, this.renderContextMatrixCols);

            for (int row = obj.GetTopLeft().Row; row < lastRow; row++)
            {
                for (int col = obj.GetTopLeft().Col; col < lastCol; col++)
                {
                    if (row >= 0 && row < renderContextMatrixRows &&
                        col >= 0 && col < renderContextMatrixCols)
                    {
                        renderContextMatrix[row, col] = objImage[row - obj.GetTopLeft().Row, col - obj.GetTopLeft().Col];
                    }
                }
            }
        }
Exemplo n.º 4
0
 public Bomb(MatrixCoords coords)
     : base(coords)
 {
 }
Exemplo n.º 5
0
 public SmallBomb(MatrixCoords topLeft, MatrixCoords speed) : base(topLeft, new char[, ] {
     { '*' }
 }, speed)
 {
 }
Exemplo n.º 6
0
 public EnemyShip(int healthPoint, int attackDamage , MatrixCoords position , Random rand)
     : base(healthPoint , attackDamage , position)
 {
     this.randomGenerator = rand;
 }
Exemplo n.º 7
0
 public Bullet(MatrixCoords coords)
     : base(coords)
 {
 }
        private static void HandleMovingWithStaticCollisions(List <MovingObject> movingObjects, List <GameObject> staticObjects)
        {
            foreach (var movingObject in movingObjects)
            {
                int verticalIndex   = VerticalCollisionIndex(movingObject, staticObjects);
                int horizontalIndex = HorizontalCollisionIndex(movingObject, staticObjects);

                MatrixCoords movingCollisionForceDirection = new MatrixCoords(0, 0);

                if (verticalIndex != -1)
                {
                    movingCollisionForceDirection.Row = -movingObject.Speed.Row;
                    staticObjects[verticalIndex].RespondToCollision(
                        new CollisionData(new MatrixCoords(movingObject.Speed.Row, 0),
                                          movingObject.GetCollisionGroupString())
                        );
                }

                if (horizontalIndex != -1)
                {
                    movingCollisionForceDirection.Col = -movingObject.Speed.Col;
                    staticObjects[horizontalIndex].RespondToCollision(
                        new CollisionData(new MatrixCoords(0, movingObject.Speed.Col),
                                          movingObject.GetCollisionGroupString())
                        );
                }

                int diagonalIndex = -1;
                if (horizontalIndex == -1 && verticalIndex == -1)
                {
                    diagonalIndex = DiagonalCollisionIndex(movingObject, staticObjects);
                    if (diagonalIndex != -1)
                    {
                        movingCollisionForceDirection.Row = -movingObject.Speed.Row;
                        movingCollisionForceDirection.Col = -movingObject.Speed.Col;

                        staticObjects[diagonalIndex].RespondToCollision(
                            new CollisionData(new MatrixCoords(movingObject.Speed.Row, 0),
                                              movingObject.GetCollisionGroupString())
                            );
                    }
                }

                List <string> hitByMovingCollisionGroups = new List <string>();

                if (verticalIndex != -1)
                {
                    hitByMovingCollisionGroups.Add(staticObjects[verticalIndex].GetCollisionGroupString());
                }

                if (horizontalIndex != -1)
                {
                    hitByMovingCollisionGroups.Add(staticObjects[horizontalIndex].GetCollisionGroupString());
                }

                if (diagonalIndex != -1)
                {
                    hitByMovingCollisionGroups.Add(staticObjects[diagonalIndex].GetCollisionGroupString());
                }

                if (verticalIndex != -1 || horizontalIndex != -1 || diagonalIndex != -1)
                {
                    movingObject.RespondToCollision(
                        new CollisionData(movingCollisionForceDirection,
                                          hitByMovingCollisionGroups)
                        );
                }
            }
        }
Exemplo n.º 9
0
 public MovingObject(MatrixCoords topLeft, char[,] body, MatrixCoords speed)
     : base(topLeft, body)
 {
     this.Speed = speed;
 }
Exemplo n.º 10
0
 public Shot(MatrixCoords topLeft, MatrixCoords speed) : base(topLeft, new char[, ] {
     { '|' }
 }, speed)
 {
 }
Exemplo n.º 11
0
 public Projectile(MatrixCoords position)
 {
     this.position = position;
 }
Exemplo n.º 12
0
 public Bomb(MatrixCoords topLeft, char[,] body, MatrixCoords speed) : base(topLeft, body, speed)
 {
 }
Exemplo n.º 13
0
 public Missile(MatrixCoords coords)
     : base(coords)
 {
 }
 public CollisionData(MatrixCoords collisionForceDirection, string objectCollisionGroupString)
 {
     this.CollisionForceDirection         = collisionForceDirection;
     this.hitObjectsCollisionGroupStrings = new List <string>();
     this.hitObjectsCollisionGroupStrings.Add(objectCollisionGroupString);
 }