public MainMenuState(Game game) : base(game) { //Re-initialize score and lives for a new game. GUIVariables.score = 0; GUIVariables.lives = 3; input = ContentStorageManager.Get<InputController>("input"); //Create and set buttons Dictionary<string, ImageButton.Callback> menuButtons = new Dictionary<string, ImageButton.Callback>(); menuButtons.Add("MainMenuStart", startButton); menuButtons.Add("MainMenuQuit", quitButton); //initialize menu MainMenu = new Menu(game, menuButtons, HLayout.Left, VLayout.Bottom, new Vector2(0, 0), 10); // HLayout is CENTER for PC titleLogo = game.Content.Load<Texture2D>("ParasiteTitle"); Position.X -= 658 / 2 - game.GraphicsDevice.PresentationParameters.BackBufferWidth / 2; Position.Y = 150; Position.Width = 658; Position.Height = 206; //Start a new level to scroll in the background level = new Level(1); level.GenerateLevel(level.current_level); AudioManager.QueueSound("music", true); }
public ControllableShip(Vector2 position, Vector2 velocity) { Me = this; this.velocity = velocity; s = new Sprite(ContentStorageManager.Get<Texture2D>("Ship01")); s.CenterOriginOnTexture(); s.position = position; ic = ContentStorageManager.Get<InputController>("input"); }
public ImageButton(string BackgroundImageName,Vector2 Position, Callback ClickMethod) { Game1 g = ContentStorageManager.Get<Game1>("game"); input = ContentStorageManager.Get<InputController>("input"); BackgroundImage = g.Content.Load<Texture2D>(BackgroundImageName); this.Position = Position; CollisionRect = BackgroundImage.Bounds; CollisionRect.X = (int)Position.X; CollisionRect.Y = (int)Position.Y; this.ClickMethod = ClickMethod; }
public TextButton(string BackgroundImageName, string FontName, string Text, Vector2 Position, Vector2 TextOffset, Callback ClickMethod) { Game1 g =ContentStorageManager.Get<Game1>("game"); input=ContentStorageManager.Get<InputController>("input"); this.Text = Text; Font=g.Content.Load<SpriteFont>(FontName); BackgroundImage=g.Content.Load<Texture2D>(BackgroundImageName); this.Position = Position; CollisionRect = BackgroundImage.Bounds; CollisionRect.X += (int)Position.X; CollisionRect.Y += (int)Position.Y; this.TextOffset = TextOffset; this.ClickMethod = ClickMethod; }
public Menu(Game game,Dictionary<string,ImageButton.Callback> NameMethods,HLayout HorizonalLayout,VLayout VerticalLayout,Vector2 Offset, int VerticalPadding) { //Need to move Mouse visability and mouse nav to state manager. game.IsMouseVisible = true; input = ContentStorageManager.Get<InputController>("input"); int TotalHeight = -1 * VerticalPadding; foreach (string item in NameMethods.Keys) { ImageButton b = new ImageButton(item, Vector2.Zero, NameMethods[item]); Buttons.Add(b); b.Position.Y = TotalHeight + Offset.Y; TotalHeight += b.CollisionRect.Height + VerticalPadding; if (HorizonalLayout == HLayout.Left) b.Position.X = Offset.X; if (HorizonalLayout == HLayout.Center) b.Position.X -=b.CollisionRect.Width / 2 - game.GraphicsDevice.PresentationParameters.BackBufferWidth / 2; if (HorizonalLayout == HLayout.Right) b.Position.X -= b.CollisionRect.Width - game.GraphicsDevice.PresentationParameters.BackBufferWidth+(int)Offset.X; } switch (VerticalLayout) { case VLayout.Top: break; case VLayout.Middle: int mid = TotalHeight / 2 - game.GraphicsDevice.PresentationParameters.BackBufferHeight / 2; foreach (ImageButton item in Buttons) { item.Position.Y -= mid; } break; case VLayout.Bottom: int mid1 = TotalHeight - game.GraphicsDevice.PresentationParameters.BackBufferHeight+ (int)Offset.Y; foreach (ImageButton item in Buttons) { item.Position.Y -= mid1; } break; default: break; } }
ScreenText st; //used to display PAUSE while paused #endregion Fields #region Constructors public GameplayState(Game game) : base(game) { Game1 g = (Game1)game; input = ContentStorageManager.Get<InputController>("input"); st = new ScreenText("Courier", "PAUSE", new Vector2(2, 2), new Vector2(300, 300));//initialize the PAUSE text //Create and set pause buttons Dictionary<string, ImageButton.Callback> menuButtons = new Dictionary<string, ImageButton.Callback>(); menuButtons.Add("PauseResume", resumeButton); menuButtons.Add("MainMenuQuit", quitButton); //initialize menu pauseMenu = new Menu(g, menuButtons, HLayout.Center, VLayout.Bottom, new Vector2(300, 300), 10); player = new ControllableShip(new Vector2(Game1.ScreenSize.X / 2, Game1.ScreenSize.Y / 2), new Vector2(10, 10)); parasite = new Parasite(player.Position, new Vector2(8,8)); parasite.controlShip = player; level = new Level(1); // this method (level.Generate()) will be called when the level is needed to change. For now, its here. level.GenerateLevel(level.current_level); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); input = new InputController(this); input.UseMouseNav = false; ContentStorageManager.Store<InputController>("input", input); ContentStorageManager.Store<Game1>("game", this); ContentStorageManager.Store<Texture2D>("Bullet00", Content.Load<Texture2D>("Bullet00")); ContentStorageManager.Store<Texture2D>("Ship00", Content.Load<Texture2D>("Ship00")); ContentStorageManager.Store<Texture2D>("Ship01", Content.Load<Texture2D>("Ship01")); ContentStorageManager.Store<Texture2D>("Ship02", Content.Load<Texture2D>("Ship02")); ContentStorageManager.Store<Texture2D>("Enemy01", Content.Load<Texture2D>("Enemy01")); ContentStorageManager.Store<Texture2D>("Enemy02", Content.Load<Texture2D>("Enemy02")); ContentStorageManager.Store<Texture2D>("Background00", Content.Load<Texture2D>("Background00")); ContentStorageManager.Store<Texture2D>("Shape00", Content.Load<Texture2D>("Shape00")); ContentStorageManager.Store<Texture2D>("Shape01", Content.Load<Texture2D>("Shape01")); ContentStorageManager.Store<Texture2D>("Shape02", Content.Load<Texture2D>("Shape02")); ContentStorageManager.Store<Texture2D>("parasite", Content.Load<Texture2D>("Parasite00")); ContentStorageManager.Store<SoundEffect>("music", Content.Load<SoundEffect>("music")); ContentStorageManager.Store<SoundEffect>("explosion", Content.Load<SoundEffect>("Explosion00")); ContentStorageManager.Store<SoundEffect>("hithurt", Content.Load<SoundEffect>("HitHurt00")); ContentStorageManager.Store<SoundEffect>("lasershoot", Content.Load<SoundEffect>("LaserShoot00")); ContentStorageManager.Store<SoundEffect>("powerup", Content.Load<SoundEffect>("PowerUp00")); StateManager.InitalizeStateManager<MainMenuState>(this); }
private void CheckMoveInput(InputController ic) { Vector2 tempVect = new Vector2(0, 0); if (ic.UpDown) { tempVect.Y -= velocity.Y; } else if (ic.DownDown) { tempVect.Y += velocity.Y; } if (ic.LeftDown) { tempVect.X -= velocity.X; } else if (ic.RightDown) { tempVect.X += velocity.X; } if (tempVect.LengthSquared() != 0) tempVect.Normalize(); Position += tempVect * velocity; }
public GameOverState(Game game) : base(game) { credits = game.Content.Load<Texture2D>("GameOverScreen"); input = ContentStorageManager.Get<InputController>("input"); }
private void CheckFireInput(InputController ic) { if (isDying) return; if (ic.FireDown && lastFired > fireDelay) { lastFired = 0; if (bulletTypeFlag == 3) { bulletType.Add(new SinBullet(Position, new Vector2(0, -12), 0, null)); bulletType.Add(new SinBullet(Position, new Vector2(0, -12), 3.14f, null)); } else if (bulletTypeFlag == 2) { bulletType.Add(new SprayBullet(Position, new Vector2(0, -12), 4, null)); } else { bulletType.Add(new StraitBullet(Position, new Vector2(0, -12))); } //bulletType.Add(new StraitBullet(Position, new Vector2(0, -12))); //AudioManager.QueueSound("lasershoot", false); foreach (Bullet b in bulletType) { ObjectManager.AddBullet(b, true); } } lastFired++; }