Esempio n. 1
0
        public PlayingState(IAnarkanoidGame arkanoidGame, IKeysConfiguration keysConfiguration) : base(arkanoidGame, keysConfiguration)
        {
            _currentLivesText = new ShowText(Configuration, new Size(Configuration.ScreenSize.Width, Configuration.ScreenSize.Height));
            AnarkanoidGame.ComponentManager.AddText(_currentLivesText, string.Format(CURRENT_LIVES_TEXT_FORMAT, AnarkanoidGame.CurrentLives));
            //AnarkanoidGame.ComponentManager.SpaceShip.Shooter = new Shooters.BasicShooter(AnarkanoidGame.ComponentManager.Configuration, new Size(30, 20), AnarkanoidGame.ComponentManager.SpaceShip);

            CommandPerKey.Add(Keys.Left, CommandsFactory.GetMoveSpaceShipToLeftCommand());
            CommandPerKey.Add(Keys.Right, CommandsFactory.GetMoveSpaceShipToRightCommand());
            CommandPerKey.Add(Keys.Shoot, CommandsFactory.GetActionCommand(Shoot));

            _collisionDetector           = new BallSpaceShipCollisionDetector(Components.SpaceShip);
            _prizeCollisionDetector      = new SpaceShipPrizeCollisionDetector(AnarkanoidGame.ComponentManager.SpaceShip);
            _shootBlockCollisionDetector = new ShootBlockCollisionDetector();
        }
Esempio n. 2
0
        public WinGameState(IAnarkanoidGame arkanoidGame, IKeysConfiguration keysConfiguration) : base(arkanoidGame, keysConfiguration)
        {
            var textComponent = new ShowText(Configuration, new Size(Configuration.ScreenSize.Width, Configuration.ScreenSize.Height))
            {
                Position = new Vector2(200, 200)
            };

            AnarkanoidGame.ComponentManager.AddText(textComponent, YOU_DID_IT_TEXT);

            Components.SpaceShip.Reset();
            AnarkanoidGame.ComponentManager.AddSpaceShip(AnarkanoidGame.ComponentManager.SpaceShip);

            CommandPerKey.Add(Keys.Left, CommandsFactory.GetMoveSpaceShipToLeftCommand());
            CommandPerKey.Add(Keys.Right, CommandsFactory.GetMoveSpaceShipToRightCommand());
            CommandPerKey.Add(Keys.Shoot, CommandsFactory.GetActionCommand(UserWantsMore));
        }
Esempio n. 3
0
        public NewMatchState(IAnarkanoidGame arkanoidGame, IKeysConfiguration keysConfiguration) : base(arkanoidGame, keysConfiguration)
        {
            AnarkanoidGame.ComponentManager.Clear();
            AnarkanoidGame.CurrentLives = Configuration.InitialLives;

            _levelText = new ShowText(Configuration, new Size(Configuration.ScreenSize.Width, Configuration.ScreenSize.Height))
            {
                Position = new Microsoft.Xna.Framework.Vector2(150, 120)
            };
            AnarkanoidGame.ComponentManager.AddText(_levelText, string.Format(LEVEL_TEXT, AnarkanoidGame.CurrentStage + 1));

            _text = new ShowText(Configuration, new Size(Configuration.ScreenSize.Width, Configuration.ScreenSize.Height))
            {
                Position = new Microsoft.Xna.Framework.Vector2(150, 150)
            };
            AnarkanoidGame.ComponentManager.AddText(_text, string.Format(TEXT_FORMAT, 3 - _totalTicks));

            Components.SpaceShip.Reset();
            AnarkanoidGame.ComponentManager.AddSpaceShip(AnarkanoidGame.ComponentManager.SpaceShip);

            var ball = AnarkanoidGame.ComponentManager.BallRepository.GetBasicBall();

            ball.Reset();
            AnarkanoidGame.ComponentManager.AddBall(ball);

            var boardFileName   = Environment.CurrentDirectory + "\\Boards\\" + AnarkanoidGame.ComponentManager.Configuration.Boards[AnarkanoidGame.CurrentStage] + ".stage";
            var boardDefinition = new BoardDefinition(boardFileName);

            AnarkanoidGame.ComponentManager.LoadBoard(boardDefinition);

            _timer          = new Timer(1000);
            _timer.Elapsed += _timer_Elapsed;
            _timer.Start();
            _returnState = this;

            CommandPerKey.Add(Keys.Left, CommandsFactory.GetMoveSpaceShipToLeftCommand());
            CommandPerKey.Add(Keys.Right, CommandsFactory.GetMoveSpaceShipToRightCommand());
        }
Esempio n. 4
0
        public InitialMatchState(IAnarkanoidGame arkanoidGame, IKeysConfiguration keysConfiguration) : base(arkanoidGame, keysConfiguration)
        {
            //Components.SpaceShip.Reset();
            //Components.Ball.Reset();

            //BORRAR PREMIOS
            AnarkanoidGame.ComponentManager.RemovePrizes();

            _timer          = new Timer(Configuration.BallInitialHookedMiliseconds);
            _timer.Elapsed += (sender, e) =>
            {
                foreach (IBall currentBall in Components.Balls)
                {
                    currentBall.Unhook();
                }
                _timer.Stop();
                _timer.Dispose();
            };
            _timer.Start();

            CommandPerKey.Add(Keys.Left, CommandsFactory.GetMoveSpaceShipToLeftCommand());
            CommandPerKey.Add(Keys.Right, CommandsFactory.GetMoveSpaceShipToRightCommand());
            CommandPerKey.Add(Keys.Shoot, CommandsFactory.GetUnhookBallCommand());
        }