예제 #1
0
        public void AddObject(GameObject obj)
        {
            if (obj is Tank)
            {
                Tank newTank = obj as Tank;
                theTank.Destroy();
                theTank = newTank;
            }

            allObjects.Add(obj);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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();
        }
예제 #4
0
        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);
        }