コード例 #1
0
ファイル: TrailObject.cs プロジェクト: PetarPenev/Telerik
 // The new constructor
 public TrailObject(MatrixCoords matrixCoord, uint turns)
     : base(matrixCoord, new char[,] { {Symbol} })
 {
     if (turns == 0)
         throw new ArgumentException("Turns of the trailing object must be a positive integer number.");
     this.turns = turns;
 }
コード例 #2
0
 public GiftBlock(MatrixCoords topLeft, Gift gift)
     : base(topLeft)
 {
     this.CurrentGift = gift;
     this.CurrentGift.SetTopLeft(topLeft);
     this.body = new char[,] { { GiftBlock.Symbol } };
 }
コード例 #3
0
        private int shotsLeft; // Bullet Racket has limmited number of shots

        #endregion Fields

        #region Constructors

        public BulletRacket(MatrixCoords topLeft, int width)
            : base(topLeft, width)
        {
            this.body[0, 0] = '!'; // draw left gun
            this.body[0, this.body.GetLength(1)-1] = '!'; // draw right gun
            this.shotsLeft = 10; // Bullet Racket has only 10 shots loaded
            hasShooted = false;
        }
コード例 #4
0
 public void Print(List<dynamic> infoBar, MatrixCoords topLeft)
 {
     for (int line = 0; line < infoBar.Count; line++)
     {
         Console.SetCursorPosition(topLeft.Col, topLeft.Row + line);
         Console.WriteLine(infoBar[line]);
     }
 }
コード例 #5
0
ファイル: TrailObject.cs プロジェクト: KirilToshev/Projects
 public TrailObject(MatrixCoords topLeft, char[,] body, int lifeTime)
     : base(topLeft, body, new MatrixCoords(0,0))
 {
     if (lifeTime <= 0)
     {
         throw new IndexOutOfRangeException("The life time can not be negative");
     }
     this.lifeTime = lifeTime;
 }
コード例 #6
0
 public void Update(MatrixCoords coords)
 {
     this.Lifetime--;
     if (this.Lifetime <= 0)
     {
         this.IsDestroyed = true;
     }
     this.topLeft = coords;
 }
コード例 #7
0
        public TrailObject(MatrixCoords topLeft, char[,] body, int lifetime)
            : base(topLeft, body)
        {
            if (lifetime < 1)
            {
                throw new ArgumentOutOfRangeException("Life time can not be less then 1.");
            }

            this.lifetime = lifetime;
        }
コード例 #8
0
 public TrailObject(MatrixCoords topLeft, char[,] body, int lifeTime)
     : base(topLeft, body)
 {
     this.TopLeft = topLeft;
     int imageRows = body.GetLength(0);
     int imageCols = body.GetLength(1);
     this.body = body;
     this.IsDestroyed = false;
     this.LifeTime = lifeTime;
 }
コード例 #9
0
ファイル: Gift.cs プロジェクト: Varbanov/TelerikAcademy
 public override IEnumerable<GameObject> ProduceObjects()
 {
     List<GameObject> produced = new List<GameObject>();
     if (this.IsDestroyed)
     {
         MatrixCoords newRacketCoords = new MatrixCoords(this.TopLeft.Row + 1, this.TopLeft.Col);
         produced.Add(new ShootingRacket(newRacketCoords, 6));
     }
     return produced;
 }
コード例 #10
0
        protected GameObject(MatrixCoords topLeft, char[,] body)
        {
            this.TopLeft = topLeft;

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

            this.body = this.CopyBodyMatrix(body);

            this.IsDestroyed = false;
        }
コード例 #11
0
ファイル: CollisionData.cs プロジェクト: PetarPenev/Telerik
        public CollisionData(MatrixCoords collisionForceDirection, List<string> hitObjectsCollisionGroupStrings)
        {
            this.CollisionForceDirection = collisionForceDirection;

            this.hitObjectsCollisionGroupStrings = new List<string>();

            foreach (var str in hitObjectsCollisionGroupStrings)
            {
                this.hitObjectsCollisionGroupStrings.Add(str);
            }
        }
コード例 #12
0
ファイル: GameObject.cs プロジェクト: naturalna/OOPPrinciples
        // construktor na obektite
        protected GameObject(MatrixCoords topLeft, char[,] body)
        {
            // wytre6na matrica rawna na podadenta
            this.TopLeft = topLeft;

            int imageRows = body.GetLength(0);
            int imageCols = body.GetLength(1);
            // kopirame w body
            this.body = this.CopyBodyMatrix(body);
            // ne e uni6tojena
            this.IsDestroyed = false;
        }
コード例 #13
0
        public override IEnumerable<GameObject> ProduceObjects()
        {
            if (this.IsDestroyedByRacket)
            {
                // TODO create fire racket
                var racketTopLeft = new MatrixCoords(this.topLeft.Row + 1, this.topLeft.Col);
                var racket = new ShootingRacket(racketTopLeft, 6);

                return new GameObject[] { racket };
            }

            return base.ProduceObjects();
        }
コード例 #14
0
        public override IEnumerable <GameObject> ProduceObjects()
        {
            List <GameObject> obj = new List <GameObject>();

            if (this.isLoaded == true)
            {
                MatrixCoords bul = this.GetTopLeft();
                bul.Col += this.Width / 2;
                Bullet bullet = new Bullet(bul);
                obj.Add(bullet);
                this.isLoaded = false;
            }
            return(obj);
        }
コード例 #15
0
ファイル: Engine.cs プロジェクト: Termininja/TelerikAcademy
        public virtual void Run(List<dynamic> list, MatrixCoords topLeft)
        {
            while (true)
            {
                // Print every object over the screen
                this.renderer.RenderAll();

                // Set game speed
                System.Threading.Thread.Sleep(520 - 5 * Speed);

                // Check for user input
                this.userInterface.ProcessInput();

                // Clear all objects from the screen
                this.renderer.ClearQueue();

                // For each objects the new position is updated
                foreach (var obj in this.allObjects)
                {
                    obj.Update();
                    this.renderer.EnqueueForRendering(obj);
                }

                // Check for collisions
                CollisionDispatcher.HandleCollisions(this.movingObjects, this.staticObjects);

                // Check for produced objects
                List<GameObject> producedObjects = new List<GameObject>();
                foreach (var obj in this.allObjects)
                {
                    producedObjects.AddRange(obj.ProduceObjects(playerRacket.TopLeft.Col));
                }

                // Delete all dead objects
                this.allObjects.RemoveAll(obj => obj.IsDestroyed);
                this.movingObjects.RemoveAll(obj => obj.IsDestroyed);
                this.staticObjects.RemoveAll(obj => obj.IsDestroyed);

                // Add all produced objects in the list
                foreach (var obj in producedObjects)
                {
                    this.AddObject(obj);
                }

                // Print the information field
                Infofield infoField = new Infofield();
                infoField.Print(list, topLeft);
            }
        }
コード例 #16
0
        public override IEnumerable<GameObject> ProduceObjects()
        {
            if (this.CanShoot)
            {
                this.CanShoot = false;

                int col = this.topLeft.Col + (this.Width / 2);
                var bulletTopLeft = new MatrixCoords(this.topLeft.Row, col);
                var bullet = new Bullet(bulletTopLeft);

                return new GameObject[] { bullet };
            }

            return base.ProduceObjects();
        }
コード例 #17
0
        public override IEnumerable <GameObject> ProduceObjects()
        {
            if (this.CanShoot)
            {
                this.CanShoot = false;

                int col           = this.topLeft.Col + (this.Width / 2);
                var bulletTopLeft = new MatrixCoords(this.topLeft.Row, col);
                var bullet        = new Bullet(bulletTopLeft);

                return(new GameObject[] { bullet });
            }

            return(base.ProduceObjects());
        }
コード例 #18
0
 public static Block GetBlock(int type, MatrixCoords coords)
 {
     switch (type)
     {
         case 1:
         case 2:
         case 3:
         case 4:
         case 5:
         case 6:
             return new Block(coords);
         case 7:
             return new UnpassableBlock(coords);
         case 8:
             return new GiftBlock(coords);
         case 9:
             return new ExplodingBlock(coords);
         default:
             return new Block(coords);
     }
 }
コード例 #19
0
         public override IEnumerable<GameObject> ProduceObjects()
        {
            List<GameObject> produced = new List<GameObject>();
            MatrixCoords speed = new MatrixCoords(0, 0);

            if (this.IsDestroyed)
            {
                //upper
                for (int col = -1; col <= 1; col++)
                {
                    MatrixCoords tempTopLeft = new MatrixCoords(this.topLeft.Row - 1, this.topLeft.Col + col);
                    ExplosionUnit unit = new ExplosionUnit(tempTopLeft, speed);
                    produced.Add(unit);
                }

                //lower
                for (int col = -1; col <= 1; col++)
                {
                    MatrixCoords tempTopLeft = new MatrixCoords(this.topLeft.Row + 1, this.topLeft.Col + col);
                    ExplosionUnit unit = new ExplosionUnit(tempTopLeft, speed);
                    produced.Add(unit);
                }

                //left
                MatrixCoords leftTopLeft = new MatrixCoords(this.topLeft.Row, this.topLeft.Col - 1);
                ExplosionUnit leftUnit = new ExplosionUnit(leftTopLeft, speed);
                produced.Add(leftUnit);

                //right
                MatrixCoords rightTopLeft = new MatrixCoords(this.topLeft.Row, this.topLeft.Col + 1);
                ExplosionUnit rightUnit = new ExplosionUnit(rightTopLeft, speed);
                produced.Add(rightUnit);
            }

            return produced;
        }
コード例 #20
0
        public override IEnumerable <GameObject> ProduceObjects()
        {
            List <GameObject> produced = new List <GameObject>();
            MatrixCoords      speed    = new MatrixCoords(0, 0);

            if (this.IsDestroyed)
            {
                //upper
                for (int col = -1; col <= 1; col++)
                {
                    MatrixCoords  tempTopLeft = new MatrixCoords(this.topLeft.Row - 1, this.topLeft.Col + col);
                    ExplosionUnit unit        = new ExplosionUnit(tempTopLeft, speed);
                    produced.Add(unit);
                }

                //lower
                for (int col = -1; col <= 1; col++)
                {
                    MatrixCoords  tempTopLeft = new MatrixCoords(this.topLeft.Row + 1, this.topLeft.Col + col);
                    ExplosionUnit unit        = new ExplosionUnit(tempTopLeft, speed);
                    produced.Add(unit);
                }

                //left
                MatrixCoords  leftTopLeft = new MatrixCoords(this.topLeft.Row, this.topLeft.Col - 1);
                ExplosionUnit leftUnit    = new ExplosionUnit(leftTopLeft, speed);
                produced.Add(leftUnit);

                //right
                MatrixCoords  rightTopLeft = new MatrixCoords(this.topLeft.Row, this.topLeft.Col + 1);
                ExplosionUnit rightUnit    = new ExplosionUnit(rightTopLeft, speed);
                produced.Add(rightUnit);
            }

            return(produced);
        }
コード例 #21
0
ファイル: ConsoleRenderer.cs プロジェクト: AniSoft/Telerik
        public void EnqueueForRendering(IRenderable obj)
        {
            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];
                    }
                }
            }
        }
コード例 #22
0
 public IndestructibleBlock(MatrixCoords upperLeft)
     : base(upperLeft)
 {
     this.body[0, 0] = IndestructibleBlock.Symbol;
 }
コード例 #23
0
 public MeteoriteBall(MatrixCoords topLeft, MatrixCoords speed, int trailObjectLifeTime)
     : base(topLeft, speed)
 {
     this.trailObjectLifeTime = trailObjectLifeTime;
 }
コード例 #24
0
ファイル: 8.UnpassableBlock.cs プロジェクト: pecsi1009/CSarp
 public UnpassableBlock(MatrixCoords upperLeft)
     : base(upperLeft)
 {
     this.body[0, 0] = UnpassableBlock.Symbol;
 }
コード例 #25
0
ファイル: Gift.cs プロジェクト: nzhul/TelerikAcademy
 public Gift(MatrixCoords topLeft, char[,] body, MatrixCoords speed)
     : base(topLeft, body, speed)
 { 
     
 }
コード例 #26
0
ファイル: 10.ExplodingBlock.cs プロジェクト: pecsi1009/CSarp
 public ExplodingBlock(MatrixCoords topLeft)
     : base(topLeft)
 {
 }
コード例 #27
0
 public Block(MatrixCoords topLeft, char[,] symbols)
     : base(topLeft, symbols)
 {
 }
コード例 #28
0
 public UnstoppableBall(MatrixCoords topLeft, MatrixCoords speed)
     : base(topLeft, speed)
 {
     this.body[0, 0] = Symbol;
 }
コード例 #29
0
 public ImpassableBlock(MatrixCoords topLeft)
     : base(topLeft)
 {
     this.body[0, 0] = ImpassableBlock.Symbol;
 }
コード例 #30
0
 public Explosion(MatrixCoords topLeft, char[,] image, MatrixCoords speed)
     : base(topLeft, image, speed)
 {
     this.IsDestroyed = true;
 }
コード例 #31
0
 public UnpassableBlock(MatrixCoords topLeft)
     : base(topLeft)
 {
 }
コード例 #32
0
 public TrailObject(MatrixCoords topLeft, int lifetime)
     : base(topLeft,new char[,]{{'.'}})
 {
     this.Lifetime = lifetime;
 }
コード例 #33
0
 public ExplodingBlock(MatrixCoords topLeft)
     : base(topLeft)
 {
     this.body[0, 0] = ExplodingBlock.Body;
 }
コード例 #34
0
 public GiftBlock(MatrixCoords topLeft)
     : base(topLeft)
 {
 }
コード例 #35
0
 public TrailObject(MatrixCoords topLeft, char[,] body, int lifetime)
     : base(topLeft, body)
 {
     this.Lifetime = lifetime;
 }
コード例 #36
0
 public ExplodingPart(MatrixCoords topLeft, MatrixCoords speed)
     : base(topLeft, new char[, ] {
     { 'e' }
 }, speed)
 {
 }
コード例 #37
0
 public MeteoriteBall(MatrixCoords topLeft, MatrixCoords speed)
     : base(topLeft, speed)
 {
 }
コード例 #38
0
 public ExplodingBlock(MatrixCoords upperLeft)
     : base(upperLeft)
 {
     this.body[0, 0] = ExplodingBlock.Symbol;
 }
コード例 #39
0
 // Constructor
 public Explosion(MatrixCoords topLeft, char[,] body, MatrixCoords speed)
     : base(topLeft, body, speed)
 {
 }
コード例 #40
0
 public Bullet(MatrixCoords topLeft, MatrixCoords speed)
     : base(topLeft, new char[, ] {
     { '^' }
 }, speed)
 {
 }
コード例 #41
0
 public ShootingRacket(MatrixCoords topLeft, int width)
     : base(topLeft, width)
 {
 }
コード例 #42
0
 public UnpassableBlock(MatrixCoords topLeft)
     : base(topLeft)
 {
     this.body[0, 0] = UnpassableBlock.symbol;
 }
コード例 #43
0
ファイル: GiftBlock.cs プロジェクト: klimentt/Telerik-Academy
 public GiftBlock(MatrixCoords topLeft) : base(topLeft)
 {
     this.body[0, 0] = GiftBlock.Body;
 }
コード例 #44
0
ファイル: Gift.cs プロジェクト: petyob/TelerikAcademy
 public Gift(MatrixCoords topLeft, char[,] body)
     : base(topLeft, body, new MatrixCoords(1, 0))
 {
 }
コード例 #45
0
 public Bullet(MatrixCoords topLeft)
     : base(topLeft, new char[, ] {
     { '1' }
 }, new MatrixCoords(-1, 0))
 {
 }
コード例 #46
0
 public Fragment(MatrixCoords topLeft, MatrixCoords speed, int lifetime)
     : base(topLeft, new char[,] { { '"' } }, speed)
 {
 }
コード例 #47
0
ファイル: Gift.cs プロジェクト: n-kostov/TelerikAcademy-2
 public Gift(MatrixCoords topLeft)
     : base(topLeft, new char[, ] {
     { 'G' }
 }, new MatrixCoords(1, 0))
 {
 }
コード例 #48
0
 public MeteoriteBall(MatrixCoords topLeft, MatrixCoords speed)
     : base(topLeft ,speed)
 {
 }
コード例 #49
0
ファイル: ExplodingBlock.cs プロジェクト: AniSoft/Telerik
 public ExplodingBlock(MatrixCoords topLeft)
     : base(topLeft)
 {
 }
コード例 #50
0
 public UnstoppableBall(MatrixCoords topLeft, MatrixCoords speed)
     : base(topLeft, new char[,] { { '@' } }, speed)
 {
 }
コード例 #51
0
ファイル: Gift.cs プロジェクト: wIksS/TelerikAcademy
 public Gift(MatrixCoords topLeft, char[,] body, MatrixCoords speed)
     : base(topLeft, body, speed)
 {
 }
コード例 #52
0
 public UnpassableBlock(MatrixCoords topLeft)
     : base(topLeft)
 {
     base.body[0, 0] = UnpassableBlock.Symbol;
 }
コード例 #53
0
 public Block(MatrixCoords topLeft)
     : base(topLeft, new char[, ] {
     { '#' }
 })
 {
 }
コード例 #54
0
 public Bullet(MatrixCoords topLeft)
     : base(topLeft, new char[,] {{'.'}}, new MatrixCoords(-1,0))
 {
 }
コード例 #55
0
 public CollisionData(MatrixCoords collisionForceDirection, string objectCollisionGroupString)
 {
     this.CollisionForceDirection         = collisionForceDirection;
     this.HitObjectsCollisionGroupStrings = new List <string>();
     this.HitObjectsCollisionGroupStrings.Add(objectCollisionGroupString);
 }
コード例 #56
0
 public ShootingRacket(MatrixCoords topLeft, int width)
     : base(topLeft,width)
 {
 }
コード例 #57
0
        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)
                        );
                }
            }
        }
コード例 #58
0
 public Shrapnel(MatrixCoords topLeft, MatrixCoords speed)
     : base(topLeft,new char[,] {{'^'}}, speed)
 {
 }
コード例 #59
0
 public UnstoppableBall(MatrixCoords topleft, MatrixCoords direction)
     : base(topleft, direction)
 {
 }