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)); }
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(); }
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(); }
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(); } }
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)); }
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)); }
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()); }
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()); }
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"); }