Example #1
0
        public GameOverState(IAnarkanoidGame arkanoidGame, IKeysConfiguration keysConfiguration) : base(arkanoidGame, keysConfiguration)
        {
            _text = new ShowText(Configuration, new Size(Configuration.ScreenSize.Width, Configuration.ScreenSize.Height));
            AnarkanoidGame.ComponentManager.AddText(_text, DIE_TEXT);

            CommandPerKey.Add(Keys.Left, CommandsFactory.GetActionCommand(NewMatch));
        }
Example #2
0
        public IntroMatchState(IAnarkanoidGame arkanoidGame, IKeysConfiguration keysConfiguration) : base(arkanoidGame, keysConfiguration)
        {
            KeyDelay = 300;

            _text = new ShowText(Configuration, new Size(Configuration.ScreenSize.Width, Configuration.ScreenSize.Height))
            {
                Position = new Microsoft.Xna.Framework.Vector2(30, 200)
            };
            AnarkanoidGame.ComponentManager.AddText(_text, TEXT);

            KeysEnabled = false;
            CommandPerKey.Add(Keys.Enter, CommandsFactory.GetActionCommand(FirstJoke));
            CommandsFactory.GetDelayedActionCommand(() => KeysEnabled = true, 100).Execute();
        }
Example #3
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();
        }
Example #4
0
 void FirstJoke()
 {
     if (_jokeStep == TOTAL_STEPS)
     {
         if (!CommandPerKey.ContainsKey(Keys.Shoot))
         {
             CommandPerKey.Add(Keys.Shoot, CommandsFactory.GetActionCommand(NewMatch));
         }
     }
     else
     {
         AnarkanoidGame.ComponentManager.AddText(_text, TEXT + "\r\n" + JOKE_TEXTS[_jokeStep]);
         _jokeStep++;
         CommandsFactory.GetDelayedActionCommand(FirstJoke, 1000).Execute();
     }
 }
Example #5
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));
        }
Example #6
0
        public ConfigureControlsState(IAnarkanoidGame arkanoidGame, IKeysConfiguration keys) : base(arkanoidGame, keys)
        {
            KeyDelay      = KEY_DELAY;
            TOTAL_OPTIONS = OPTIONS_TEXTS.Length;
            _texts        = new List <IGameComponent>();
            KEYS          = new List <Keys>()
            {
                Keys.Left,
                Keys.Right,
                Keys.Shoot
            };

            KEYS_ACTIONS = new List <ChangeKey>()
            {
                ChangeLeftControl,
                ChangeRightControl,
                ChangeShootControl
            };

            var textTopPosition = FIRST_OPTION_TEXT_POSITION.Y;

            for (int i = 0; i < OPTIONS_TEXTS.Length; i++)
            {
                string optionText = OPTIONS_TEXTS[i];
                var    text       = new ShowText(AnarkanoidGame.ComponentManager.Configuration, OPTION_TEXT_SIZE)
                {
                    Position    = new Microsoft.Xna.Framework.Vector2(FIRST_OPTION_TEXT_POSITION.X, textTopPosition),
                    SpriteColor = i == 0 ? SELECTED_TEXT_COLOR : TEXT_COLOR
                };

                if (i == OPTIONS_TEXTS.Length - 1)
                {
                    AnarkanoidGame.ComponentManager.AddText(text, optionText);
                }
                else
                {
                    AnarkanoidGame.ComponentManager.AddText(text, string.Format(TEXT_KEY_TEXT_FORMAT, optionText.PadRight(15), KEYS[i].ToString().PadLeft(15)));
                }

                _texts.Add(text);
                textTopPosition += text.Size.Height;
            }

            CommandPerKey.Add(Keys.Down, CommandsFactory.GetActionCommand(NextKeyConfiguration));
            CommandPerKey.Add(Keys.Up, CommandsFactory.GetActionCommand(PreviousKeyConfiguration));
            CommandPerKey.Add(Keys.Enter, CommandsFactory.GetActionCommand(SelectedOption));
        }
Example #7
0
        public MatchState(IAnarkanoidGame arkanoidGame, IKeysConfiguration keys)
        {
            AnarkanoidGame  = arkanoidGame;
            Keys            = keys;
            CommandsFactory = new CommandsFactory(AnarkanoidGame);
            CommandPerKey   = new Dictionary <Keys, ICommand>();

            CommandPerKey.Add(Microsoft.Xna.Framework.Input.Keys.None, new VoidCommand(AnarkanoidGame));
            CommandPerKey.Add(keys.Exit, CommandsFactory.GetActionCommand(ExitGame));

            KeysEnabled = true;
            KeyDelay    = 1;

            CurrentKeyPressed = Microsoft.Xna.Framework.Input.Keys.Enter;
            _timer            = new Timer(1000);
            _timer.Elapsed   += (e, s) =>
            {
                CurrentKeyPressed = Microsoft.Xna.Framework.Input.Keys.None;
                _timer.Stop();
            };
            _timer.Start();
        }
Example #8
0
        public IntroGameState(IAnarkanoidGame anarkanoidGame, IKeysConfiguration keys) : base(anarkanoidGame, keys)
        {
            KeyDelay      = KEY_DELAY;
            TOTAL_OPTIONS = OPTIONS_TEXTS.Length;
            AnarkanoidGame.CurrentStage = 0;

            var backgroundSize = new Size(
                AnarkanoidGame.ComponentManager.Configuration.ScreenSize.Width,
                AnarkanoidGame.ComponentManager.Configuration.ScreenSize.Height
                );

            _background = new CustomElement(AnarkanoidGame.ComponentManager.Configuration, backgroundSize)
            {
                Scale = new Vector2(BACKGROUND_SCALE, BACKGROUND_SCALE)
            };
            AnarkanoidGame.ComponentManager.AddComponentByAssetName(_background, "Title");

            var spaceInvaderSize = new Size(
                AnarkanoidGame.ComponentManager.Configuration.ScreenSize.Width / SPACE_INVADER_PERCENT_SCALE,
                AnarkanoidGame.ComponentManager.Configuration.ScreenSize.Height / SPACE_INVADER_PERCENT_SCALE
                );

            _spaceInvader = new CustomElement(AnarkanoidGame.ComponentManager.Configuration, spaceInvaderSize)
            {
                Position = SPACE_INVADER_POSITION
            };
            AnarkanoidGame.ComponentManager.AddComponentByAssetName(_spaceInvader, "SpaceInvader");

            var subtitle = new ShowText(AnarkanoidGame.ComponentManager.Configuration, OPTION_TEXT_SIZE)
            {
                Position    = SUBTITLE_POSITION,
                SpriteColor = Color.Red,
                Scale       = new Vector2(1.5f, 1.5f)
            };

            AnarkanoidGame.ComponentManager.AddText(subtitle, SUBTITLE_TEXT);

            //SUBTITLE_TEXT

            var textTopPosition = FIRST_OPTION_TEXT_POSITION.Y;

            _optionsText = new List <ShowText>();
            foreach (string optionText in OPTIONS_TEXTS)
            {
                var text = new ShowText(AnarkanoidGame.ComponentManager.Configuration, OPTION_TEXT_SIZE)
                {
                    Position    = new Vector2(FIRST_OPTION_TEXT_POSITION.X, textTopPosition),
                    SpriteColor = Color.Black
                };
                AnarkanoidGame.ComponentManager.AddText(text, optionText);
                _optionsText.Add(text);
                textTopPosition += text.Size.Height;
            }

            ACTIONS = new System.Action[]
            {
                NewGameSelected, ConfigureControlsSelected, ToggleFullScreenSelected, ExitGameSelected
            };

            AnarkanoidGame.ComponentManager.SpaceShip.Scale    = new Vector2(.8f, .8f);
            AnarkanoidGame.ComponentManager.SpaceShip.Position = new Vector2(
                _optionsText[0].Position.X - AnarkanoidGame.ComponentManager.SpaceShip.Size.Width,
                _optionsText[0].Position.Y + 10
                );
            AnarkanoidGame.ComponentManager.AddSpaceShip(AnarkanoidGame.ComponentManager.SpaceShip);

            CommandsFactory.GetDelayedActionCommand(ToggleSpceInvaderPosition, 1000).Execute();

            CommandPerKey.Add(Keys.Up, CommandsFactory.GetActionCommand(MoveUpOption));
            CommandPerKey.Add(Keys.Down, CommandsFactory.GetActionCommand(MoveDownOption));
            CommandPerKey.Add(Microsoft.Xna.Framework.Input.Keys.Enter, CommandsFactory.GetActionCommand(EnterPressed));

            _returnState = this;

            AnarkanoidGame.ComponentManager.PlaySound("Anarky");
        }