public override void Collide(GameObject obj) { this.HitPoints--; if (this.HitPoints <= 0) { this.IsDestroyed = true; } }
public virtual void AddObject(GameObject obj) { if (obj is EnemySpaceCraftProtoOne || obj is Asteroid || obj is Meteor || obj is Gift) { this.movingObjects.Add(obj as MovingObject); } else if (obj is Bullet) { this.bullets.Add(obj as Bullet); } this.allObjects.Add(obj); }
public void EnqueObject(GameObject obj) { char[,] objectImage = obj.GetImage(); int objectHeight = objectImage.GetLength(0); int objectWidth = objectImage.GetLength(1); Position objectPosition = obj.GetPosition; for (int rows = obj.GetPosition.Row; rows < objectPosition.Row + objectHeight; rows++) { for (int cols = obj.GetPosition.Col; cols < objectPosition.Col + objectWidth; cols++) { if(rows >= 0 && rows < gameFieldRows && cols >= 0 && cols < gameFieldCols) { objectBody[rows, cols] = objectImage[rows - objectPosition.Row, cols - objectPosition.Col]; } } } }
public override void Collide(GameObject obj) { if (obj is LifeGift) { Console.ForegroundColor = ConsoleColor.Green; if (this.HitPoints < 4) { this.HitPoints++; } } else { this.HitPoints--; Console.ForegroundColor = ConsoleColor.Red; if (this.HitPoints <= 0) { this.IsDestroyed = true; this.position = new Position(0, 0); } } }
public override void Collide(GameObject obj) { this.IsDestroyed = true; }
public void AddCruiser(GameObject obj) { this.cruiser = obj as PlayerSpaceCraft; this.allObjects.Add(obj); }
public virtual void Collide(GameObject obj) { this.IsDestroyed = true; }