// 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; }
public GiftBlock(MatrixCoords topLeft, Gift gift) : base(topLeft) { this.CurrentGift = gift; this.CurrentGift.SetTopLeft(topLeft); this.body = new char[,] { { GiftBlock.Symbol } }; }
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; }
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]); } }
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; }
public void Update(MatrixCoords coords) { this.Lifetime--; if (this.Lifetime <= 0) { this.IsDestroyed = true; } this.topLeft = coords; }
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; }
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; }
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; }
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; }
public CollisionData(MatrixCoords collisionForceDirection, List<string> hitObjectsCollisionGroupStrings) { this.CollisionForceDirection = collisionForceDirection; this.hitObjectsCollisionGroupStrings = new List<string>(); foreach (var str in hitObjectsCollisionGroupStrings) { this.hitObjectsCollisionGroupStrings.Add(str); } }
// 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; }
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(); }
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); }
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); } }
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(); }
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()); }
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); } }
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; }
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); }
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]; } } } }
public IndestructibleBlock(MatrixCoords upperLeft) : base(upperLeft) { this.body[0, 0] = IndestructibleBlock.Symbol; }
public MeteoriteBall(MatrixCoords topLeft, MatrixCoords speed, int trailObjectLifeTime) : base(topLeft, speed) { this.trailObjectLifeTime = trailObjectLifeTime; }
public UnpassableBlock(MatrixCoords upperLeft) : base(upperLeft) { this.body[0, 0] = UnpassableBlock.Symbol; }
public Gift(MatrixCoords topLeft, char[,] body, MatrixCoords speed) : base(topLeft, body, speed) { }
public ExplodingBlock(MatrixCoords topLeft) : base(topLeft) { }
public Block(MatrixCoords topLeft, char[,] symbols) : base(topLeft, symbols) { }
public UnstoppableBall(MatrixCoords topLeft, MatrixCoords speed) : base(topLeft, speed) { this.body[0, 0] = Symbol; }
public ImpassableBlock(MatrixCoords topLeft) : base(topLeft) { this.body[0, 0] = ImpassableBlock.Symbol; }
public Explosion(MatrixCoords topLeft, char[,] image, MatrixCoords speed) : base(topLeft, image, speed) { this.IsDestroyed = true; }
public UnpassableBlock(MatrixCoords topLeft) : base(topLeft) { }
public TrailObject(MatrixCoords topLeft, int lifetime) : base(topLeft,new char[,]{{'.'}}) { this.Lifetime = lifetime; }
public ExplodingBlock(MatrixCoords topLeft) : base(topLeft) { this.body[0, 0] = ExplodingBlock.Body; }
public GiftBlock(MatrixCoords topLeft) : base(topLeft) { }
public TrailObject(MatrixCoords topLeft, char[,] body, int lifetime) : base(topLeft, body) { this.Lifetime = lifetime; }
public ExplodingPart(MatrixCoords topLeft, MatrixCoords speed) : base(topLeft, new char[, ] { { 'e' } }, speed) { }
public MeteoriteBall(MatrixCoords topLeft, MatrixCoords speed) : base(topLeft, speed) { }
public ExplodingBlock(MatrixCoords upperLeft) : base(upperLeft) { this.body[0, 0] = ExplodingBlock.Symbol; }
// Constructor public Explosion(MatrixCoords topLeft, char[,] body, MatrixCoords speed) : base(topLeft, body, speed) { }
public Bullet(MatrixCoords topLeft, MatrixCoords speed) : base(topLeft, new char[, ] { { '^' } }, speed) { }
public ShootingRacket(MatrixCoords topLeft, int width) : base(topLeft, width) { }
public UnpassableBlock(MatrixCoords topLeft) : base(topLeft) { this.body[0, 0] = UnpassableBlock.symbol; }
public GiftBlock(MatrixCoords topLeft) : base(topLeft) { this.body[0, 0] = GiftBlock.Body; }
public Gift(MatrixCoords topLeft, char[,] body) : base(topLeft, body, new MatrixCoords(1, 0)) { }
public Bullet(MatrixCoords topLeft) : base(topLeft, new char[, ] { { '1' } }, new MatrixCoords(-1, 0)) { }
public Fragment(MatrixCoords topLeft, MatrixCoords speed, int lifetime) : base(topLeft, new char[,] { { '"' } }, speed) { }
public Gift(MatrixCoords topLeft) : base(topLeft, new char[, ] { { 'G' } }, new MatrixCoords(1, 0)) { }
public MeteoriteBall(MatrixCoords topLeft, MatrixCoords speed) : base(topLeft ,speed) { }
public UnstoppableBall(MatrixCoords topLeft, MatrixCoords speed) : base(topLeft, new char[,] { { '@' } }, speed) { }
public UnpassableBlock(MatrixCoords topLeft) : base(topLeft) { base.body[0, 0] = UnpassableBlock.Symbol; }
public Block(MatrixCoords topLeft) : base(topLeft, new char[, ] { { '#' } }) { }
public Bullet(MatrixCoords topLeft) : base(topLeft, new char[,] {{'.'}}, new MatrixCoords(-1,0)) { }
public CollisionData(MatrixCoords collisionForceDirection, string objectCollisionGroupString) { this.CollisionForceDirection = collisionForceDirection; this.HitObjectsCollisionGroupStrings = new List <string>(); this.HitObjectsCollisionGroupStrings.Add(objectCollisionGroupString); }
public ShootingRacket(MatrixCoords topLeft, int width) : base(topLeft,width) { }
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) ); } } }
public Shrapnel(MatrixCoords topLeft, MatrixCoords speed) : base(topLeft,new char[,] {{'^'}}, speed) { }
public UnstoppableBall(MatrixCoords topleft, MatrixCoords direction) : base(topleft, direction) { }