using LvivPK01GameEngine;
public class Bullet :TangibleGameObject
public Bullet(Point location, DirectionEnum direction1, DirectionEnum? direction2 = null)
public override void Update()
var location = Location.Move(Direction1);
if (Direction2 != null) location = location.Move(Direction2.Value);
if (!location.Violations.IsInViolation) Location = location;
foreach (var gameObject in RobotronGame.Current!.GameObjects)
var grunt = (Grunt)gameObject;
if (grunt.Body.IsCollidingAtLocation(grunt.Location, Location))
RobotronGame.Current.ScoreKeeper.Score += 10;
if (!AnyAnimateEnemiesAlive()) levelDone = true;
else if (gameObject is Hulk)
var hulk = (Hulk)gameObject;
if (hulk.Body.IsCollidingAtLocation(hulk.Location, Location))
RobotronGame.Current.ScoreKeeper.Score += 5;
hulk.Location = hulk.Location.Move(Direction1, 2);
if (Direction2 != null) hulk.Location.Move(Direction1, 2);
else if (gameObject is Electrode)
var electrode = (Electrode)gameObject;
if (electrode.Body.IsCollidingAtLocation(electrode.Location, Location))
RobotronGame.Current.ScoreKeeper.Score += 5;
electrode.ToDelete = true;
RobotronGame.Current.CurrentLevel++;
if (RobotronGame.Current.LevelManifests.Count == RobotronGame.Current.CurrentLevel) throw new GameOverException("You won!");
RobotronGame.Current.ResetLevel();
public override void Draw()
Console.BackgroundColor = ConsoleColor.Black;
Console.ForegroundColor = ConsoleColor.White;
if (!Location.Violations.IsInViolation)
Location.SetCursorPosition();
public override void Erase()
Console.BackgroundColor = ConsoleColor.Black;
if (!Location.Violations.IsInViolation)
Location.SetCursorPosition();
protected bool AnyAnimateEnemiesAlive()
foreach (var gameObject in RobotronGame.Current!.GameObjects)
if (gameObject is AnimateEnemy && !gameObject.ToDelete) return true;
public Point Location { get; set; }
public DirectionEnum Direction1 { get; set; }
public DirectionEnum? Direction2 { get; set; }