Beispiel #1
0
        public void NextMovementStrategy()
        {
            pct += 0.05f;
            switch (rnd.Next(2))
            {
            case 0:
                currentMoveStrategy = new MovementStrategies.Down();
                break;

            default:
                currentMoveStrategy = new MovementStrategies.SpacyZigZag();
                break;
            }
            currentMoveStrategy.IncressSpeed(pct);
        }
Beispiel #2
0
        public Game()
        {
            win             = new Window("Mad man", 500, 500);
            gameTimer       = new GameTimer(60, 60);
            score           = new Score(new Vec2F(0.05f, 0.8f), new Vec2F(0.2f, 0.2f));
            gameState       = GameState.GamePlaying;
            GameOverDisPlay = new GameOverDisPlay();

            player = new Player(
                new DynamicShape(new Vec2F(0.45f, 0.1f), new Vec2F(0.1f, 0.1f)),
                new Image(System.IO.Path.Combine("Assets", "Images", "Player.png")), this);

            enemyStrides = ImageStride.CreateStrides(4, System.IO.Path.Combine("Assets", "Images",
                                                                               "BlueMonster.png"));

            enemies = new EntityContainer <Enemy>();
            AddEnemies(new Squadron.Formation(6));
            currentMoveStrategy = new MovementStrategies.NoMove();

            playerShots = new EntityContainer <PlayerShot>();

            explosionStrides = ImageStride.CreateStrides(8, System.IO.Path.Combine("Assets", "Images", "Explosion.png"));
            explosions       = new AnimationContainer(8);

            eventBus = new GameEventBus <object>();
            eventBus.InitializeEventBus(new List <GameEventType>()
            {
                GameEventType.InputEvent,
                GameEventType.WindowEvent,
                GameEventType.PlayerEvent,
            });
            win.RegisterEventBus(eventBus);
            eventBus.Subscribe(GameEventType.InputEvent, this);
            eventBus.Subscribe(GameEventType.WindowEvent, this);
            eventBus.Subscribe(GameEventType.PlayerEvent, player);
        }