void ToggleSpceInvaderPosition() { if (_spaceInvader.Position.X == SPACE_INVADER_POSITION.X) { _spaceInvader.Position = new Vector2(_spaceInvader.Position.X + 150, _spaceInvader.Position.Y); } else { _spaceInvader.Position = new Vector2(_spaceInvader.Position.X - 150, _spaceInvader.Position.Y); } CommandsFactory.GetDelayedActionCommand(ToggleSpceInvaderPosition, 1000).Execute(); }
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(); }
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 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"); }