public void AddObject(GameObject obj) { if (obj is Tank) { Tank newTank = obj as Tank; theTank.Destroy(); theTank = newTank; } allObjects.Add(obj); }
public Engine(IUserInterface userInterface, ICollisionDispatcher collisionDispatcher, IRenderer renderer, Tank theTank, IEnemyFactory enemy, int sleepTimeInMs) { this.userInterface = userInterface; this.collisionDispatcher = collisionDispatcher; this.renderer = renderer; this.theTank = theTank; this.sleepTime = sleepTimeInMs; this.enemy = enemy; this.score = 0; this.lastLevelScore = 0; allObjects = new List<GameObject>(); allObjects.Add(theTank); }
static void Main() { int worldRows = Coordinates.worldRows; int worldColums = Coordinates.worldColums; Coordinates endOfWorld = new Coordinates(worldRows, worldColums); IUserInterface userInterface = new KeyboardUserInterface(); ICollisionDispatcher collisionDispatcher = new CollisionDispatcher(); IRenderer renderer = new ConsoleRenderer(worldRows, worldColums); Tank theTank = new Tank(new Coordinates(worldRows - 1, worldColums / 2)); IEnemyFactory enemy = new PlaneProducer(endOfWorld, 8); Engine gameEngine = new Engine(userInterface, collisionDispatcher, renderer, theTank, enemy, 100); gameEngine.Run(); }
public Engine(IUserInterface userInterface, ICollisionDispatcher collisionDispatcher, IRenderer renderer, Tank theTank, IEnemyFactory enemy, int sleepTimeInMs) { this.userInterface = userInterface; this.collisionDispatcher = collisionDispatcher; this.renderer = renderer; this.theTank = theTank; this.sleepTime = sleepTimeInMs; this.enemy = enemy; this.score = 0; this.lastLevelScore = 0; allObjects = new List <GameObject>(); allObjects.Add(theTank); }