protected override void Initialize() { this.IsMouseVisible = true; tower1 = new TowerButton(830, 220); //tower1.scale = 0.5f; Back1 = new sprite(); Back1.Scale = 2.0f; graphics.PreferredBackBufferWidth = 1000;//size of window graphics.PreferredBackBufferHeight = 600; graphics.ApplyChanges(); sidebar = new sprite(); topbar = new sprite(); title = new sprite(); map = new sprite(); lvl1Button = new Button(); start = new Button(); lvl1 = new Level1(); lvl2Button = new Button(); lvl2 = new Level2(); base.Initialize(); }
public void TestPlay() { Button play = new Button(); //new button created "play" play.addButton("Newgame"); //Newgame button is added to play button Assert.AreSame("Newgame", play.getButton()); //tesing that Newgame button has been created. play.addButton("Resume"); // Resume button is added to play button Assert.AreSame("Resume", play.getButton()); // testing that Resume button has been created. }
public void TestExit() { Button exit = new Button(); exit.IsClicked("exit"); // asserts that if exit is clicked it corresponds to the same "exit" button that is resposible for exiting the game. Assert.AreSame("exit", exit.getIsClicked()); }
public override void LoadContent() { MenuFont = Content.Load<SpriteFont>("gameFont"); Background = Content.Load<Texture2D>("1_bg-tree"); Button contGame = new Button(new Point(Settings.SCREEN_WIDTH / 2 - 100, 100), 200, 100, "", Content.Load<Texture2D>("continue_hl"), Content.Load<Texture2D>("continue")); contGame.ClickEvent += new Button.ClickHandler(ContinueGame); AddButton(contGame); Button exit = new Button(new Point(Settings.SCREEN_WIDTH / 2 - 100, 300), 200, 100, "", Content.Load<Texture2D>("exit_hl"), Content.Load<Texture2D>("exit")); exit.ClickEvent += new Button.ClickHandler(ExitGame); AddButton(exit); }
private void instatiniateButtons() { List<Texture2D> tutorialButtonTextures = new List<Texture2D>(); List<Texture2D> otherButtonTextures = new List<Texture2D>(); tutorialButtonTextures.Add(tutorialButtonSprite); otherButtonTextures.Add(buttonLowSprite); otherButtonTextures.Add(buttonHighSprite); DotNET.Point tutorialButtonLocation = new DotNET.Point(gameWidth - tutorialButtonSprite.Width, 0 + tutorialButtonSprite.Height); tutorialButton = new Button(tutorialButtonTextures, tutorialButtonLocation, 1150); tutorialButton.ButtonTriggered += button_TutorialButtonTriggered; DotNET.Point cohesionButtonLocation = new DotNET.Point(tutorialButtonLocation.X, (2 * (tutorialFont.LineSpacing + tutorialButtonSprite.Height))); cohesionButton = new Button(otherButtonTextures, cohesionButtonLocation, 100); cohesionButton.ButtonTriggered += button_CohesionButtonTriggered; DotNET.Point separationButtonLocation = new DotNET.Point(gameWidth - tutorialButtonSprite.Width, (3 * (tutorialFont.LineSpacing + tutorialButtonSprite.Height))); separationButton = new Button(otherButtonTextures, separationButtonLocation, 100); separationButton.ButtonTriggered += button_SeparationButtonTriggered; DotNET.Point alignmentButtonLocation = new DotNET.Point(gameWidth - tutorialButtonSprite.Width, (4 * (tutorialFont.LineSpacing + tutorialButtonSprite.Height))); alignmentButton = new Button(otherButtonTextures, alignmentButtonLocation, 100); alignmentButton.ButtonTriggered += button_AlignmentButtonTriggered; }
private void DrawButtonSprite(Button b) { Texture2D buttonSprite = b.getSprite(); DotNET.Point buttonLocation = b.getLocation(); Vector2 buttonVector = new Vector2((float) (buttonLocation.X - (buttonSprite.Width / 2)), (float)(buttonLocation.Y - (buttonSprite.Height / 2))); spriteBatch.Draw(buttonSprite, buttonVector, null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); }
public void AddButton(Button b) { if (_currentSelect == null) _currentSelect = b; _menuButtons.Add(b); }
public override void Update(GameTime gameTime) { if ((ScreenManager.KeyStateAfter.IsKeyDown(Keys.Down) && ScreenManager.KeyStateBefore.IsKeyUp(Keys.Down)) || (ScreenManager.GamePadAfter.IsButtonDown(GameControls.GMenuDown) && ScreenManager.GamePadBefore.IsButtonUp(GameControls.GMenuDown))) { int next = _menuButtons.IndexOf(_currentSelect)+1; if (next < _menuButtons.Count) _currentSelect = _menuButtons.ElementAt<Button>(next); else _currentSelect = _menuButtons.ElementAt<Button>(0); } else if ((ScreenManager.KeyStateAfter.IsKeyDown(Keys.Up) && ScreenManager.KeyStateBefore.IsKeyUp(Keys.Up)) || (ScreenManager.GamePadAfter.IsButtonDown(GameControls.GMenuUp) && ScreenManager.GamePadBefore.IsButtonUp(GameControls.GMenuUp))) { int next = _menuButtons.IndexOf(_currentSelect) - 1; if (next >= 0) _currentSelect = _menuButtons.ElementAt<Button>(next); else _currentSelect = _menuButtons.ElementAt<Button>(_menuButtons.Count-1); } else if (ScreenManager.KeyStateAfter.IsKeyDown(Keys.Enter) && ScreenManager.KeyStateBefore.IsKeyUp(Keys.Enter) || (ScreenManager.GamePadAfter.IsButtonDown(GameControls.GAction) && ScreenManager.GamePadBefore.IsButtonUp(GameControls.GAction))) { _currentSelect.Click(); } }
public void addButton(Button newButton) { buttonsCollection.Add(newButton); //tutorialButton = newButton; }
public void LoadContent() { Background = content.Load<Texture2D>("Background/Background"); damageStringFont = content.Load<SpriteFont>("font"); #region barAssets dmg0 = content.Load<Texture2D>("DamageBar/dmg0"); dmg1 = content.Load<Texture2D>("DamageBar/dmg1"); dmg2 = content.Load<Texture2D>("DamageBar/dmg2"); dmg3 = content.Load<Texture2D>("DamageBar/dmg3"); dmg4 = content.Load<Texture2D>("DamageBar/dmg4"); dmg5 = content.Load<Texture2D>("DamageBar/dmg5"); dmg6 = content.Load<Texture2D>("DamageBar/dmg6"); dmg7 = content.Load<Texture2D>("DamageBar/dmg7"); dmg8 = content.Load<Texture2D>("DamageBar/dmg8"); dmg9 = content.Load<Texture2D>("DamageBar/dmg9"); dmg10 = content.Load<Texture2D>("DamageBar/dmg1bl"); dmg11 = content.Load<Texture2D>("DamageBar/dmg2bl"); dmg12 = content.Load<Texture2D>("DamageBar/dmg3bl"); dmg13 = content.Load<Texture2D>("DamageBar/dmg4bl"); dmg14 = content.Load<Texture2D>("DamageBar/dmg5bl"); dmg15 = content.Load<Texture2D>("DamageBar/dmg6bl"); dmg16 = content.Load<Texture2D>("DamageBar/dmg7bl"); dmg17 = content.Load<Texture2D>("DamageBar/dmg8bl"); dmg18 = content.Load<Texture2D>("DamageBar/dmg9bl"); #endregion AttackButton = new Button(content, "Buttons/Button1", new Vector2(300, 0)); upDamage = new Button(content, "Buttons/ButtonDmg", new Vector2(0, 400)); currentDmg = dmg0; hero.LoadContent(1); //support1.LoadContent(2); //support2.LoadContent(3); monster1.LoadContent(); if (hero.numSup == 1) { support1.LoadContent(2); } else if(hero.numSup == 2) { support2.LoadContent(3); } }