private void AddQuitButton() { var quitButton = new InteractiveButton(menuTheme, new Rectangle(0.3f, 0.67f, 0.4f, 0.08f), "Quit Game"); quitButton.Clicked += TryInvokeQuit; Add(quitButton); }
private void AddHowToPlay() { var howToButton = new InteractiveButton(menuTheme, new Rectangle(0.3f, 0.57f, 0.4f, 0.08f), "How To Play"); howToButton.Clicked += ShowHowToPlaySubMenu; Add(howToButton); }
public void SetUp() { button = new InteractiveButton(Center, "Click Me"); InitializeMouse(); InitializeTouch(); AdvanceTimeAndUpdateEntities(); }
private void AddStartButton() { var startButton = new InteractiveButton(menuTheme, new Rectangle(0.3f, 0.47f, 0.4f, 0.08f), "Start Game"); startButton.Clicked += TryInvokeGameStart; Add(startButton); }
private void AddHowToPlay() { var howToButton = new InteractiveButton(howToPlayTheme, new Rectangle(0.3f, 0.44f, 0.4f, 0.15f)); howToButton.Clicked += ShowHowToPlaySubMenu; Add(howToButton); }
public void ChangeToInteractiveButton(UIEditorScene uiEditorScene) { if (uiEditorScene == null) return; //ncrunch: no coverage for (int i = 0; i < uiEditorScene.SelectedEntity2DList.Count; i++) { var selectedEntity2D = uiEditorScene.SelectedEntity2DList[i]; if (selectedEntity2D == null || (selectedEntity2D.GetType() != typeof(Button) && selectedEntity2D.GetType() != typeof(InteractiveButton))) return; var index = uiEditorScene.Scene.Controls.IndexOf(selectedEntity2D); var selectedIndex = uiEditorScene.SelectedEntity2DList.IndexOf(selectedEntity2D); uiEditorScene.Scene.Remove(selectedEntity2D); uiEditorScene.SelectedEntity2DList.RemoveAt(i); var renderLayer = selectedEntity2D.RenderLayer; var anchorState = selectedEntity2D.Get<AnchoringState>(); var controlName = (selectedEntity2D as Control).Name; if (IsInteractiveButton) selectedEntity2D = new InteractiveButton(selectedEntity2D.Get<Theme>(), selectedEntity2D.DrawArea, ((Button)selectedEntity2D).Text); else selectedEntity2D = new Button(selectedEntity2D.Get<Theme>(), selectedEntity2D.DrawArea, ((Button)selectedEntity2D).Text); selectedEntity2D.RenderLayer = renderLayer; selectedEntity2D.Set(anchorState); (selectedEntity2D as Control).Name = controlName; uiEditorScene.Scene.Controls.Insert(index, selectedEntity2D); uiEditorScene.SelectedEntity2DList.Insert(selectedIndex, selectedEntity2D); } }
private void AddContentSwitcherButton() { switchButton = new InteractiveButton(menuTheme, new Rectangle(0.76f, 0.24f, 0.2f, 0.08f), "Jewel Blocks"); switchButton.Clicked += TryInvokeSwitchContent; Add(switchButton); }
private void AddStartButton() { var startButton = new InteractiveButton(startGameTheme, new Rectangle(0.3f, 0.3f, 0.4f, 0.15f)); startButton.Clicked += TryInvokeGameStart; Add(startButton); }
private InteractiveButton CreateInteractiveButton(float angle, Color color, string towerName) { var drawArea = CalculateDrawArea(angle); var button = new InteractiveButton(drawArea, towerName); button.Color = color; button.AddTag(towerName); return button; }
private void AddClickEvent(InteractiveButton button, TowerType type, string towerName) { button.Clicked += () => { //ContentLoader.Load<Sound>(GameSounds.PressButton.ToString()).Play(); //game.Get<InGameCommands>().HideTowerPanel(); //game.CreateTower(game.Get<InGameCommands>().PositionInGrid, type, towerName); }; }
protected Game(Logic logic) { this.logic = logic; buttonShader = ContentLoader.Create<Shader>(new ShaderCreationData(ShaderFlags.Position2DColoredTextured)); buttonImage = new Theme().Button.DiffuseMap; buttons = new InteractiveButton[logic.Board.Width, logic.Board.Height]; ArrangeScene(); ScreenSpace.Current.ViewportSizeChanged += ArrangeScene; }
private void CreateButton(int x, int y) { if (buttons[x, y] != null) buttons[x, y].Dispose(); var theme = GetCachedButtonThemeOrCreateNewButtonTheme(x, y); var drawArea = new Rectangle(buttonsLeft + x * buttonWidth, buttonsTop + y * buttonHeight, buttonWidth, buttonHeight); buttons[x, y] = new InteractiveButton(theme, drawArea); buttons[x, y].Clicked = () => ButtonClicked(x, y); }
private void AddShowEulaButton() { var launchEulaMenu = new InteractiveButton(new Rectangle(0.3f, 0.5f, 0.2f, 0.1f), "Read EULA") { RenderLayer = 1 }; launchEulaMenu.Clicked += () => //ncrunch: no coverage start { eulaMenu.Show(); mainMenu.ToBackground(); }; //ncrunch: no coverage end mainMenu.Add(launchEulaMenu); }
private void AddShowOptionsMenuButton() { var launchOptionsMenu = new InteractiveButton(new Rectangle(0.3f, 0.35f, 0.2f, 0.1f), "Set Options") { RenderLayer = 1 }; launchOptionsMenu.Clicked += () => //ncrunch: no coverage start { optionsMenu.Show(); mainMenu.ToBackground(); }; //ncrunch: no coverage end mainMenu.Add(launchOptionsMenu); }
//ncrunch: no coverage start private void AddColorsButton() { var colorButton = new InteractiveButton(menuTheme, new Rectangle(0.3f, 0.3f, 0.4f, 0.15f), "ChooseColours"); colorButton.Clicked += () => { Hide(); colorOptions.Show(); }; Add(colorButton); CreateColorOptions(); }
public static void PlaySpecialAttackSound(InteractiveButton buttonSpecialAttack) { if (buttonSpecialAttack.Material.Name == GameHud.DragonAttackBreathMat.ToString()) PlayAttackSound(GameSounds.DragonBreathOfFire); else if (buttonSpecialAttack.Material.Name == GameHud.PenguinAttackBigFireworkMat.ToString()) PlayAttackSound(GameSounds.PenguinFireworks); else if (buttonSpecialAttack.Material.Name == GameHud.PiggyAttackCoinRainMat.ToString()) PlayAttackSound(GameSounds.PiggyCoinsRain); else if (buttonSpecialAttack.Material.Name == GameHud.DragonAttackCannonMat.ToString()) PlayAttackSound(GameSounds.DragonAuraCannon); else if (buttonSpecialAttack.Material.Name == GameHud.PenguinAttackCarpetBombingMat.ToString()) PlayAttackSound(GameSounds.PenguinSnowball); else if (buttonSpecialAttack.Material.Name == GameHud.PiggyAttackPaydayMat.ToString()) PlayAttackSound(GameSounds.PiggyPayDay); }
public void AddControlToScene(Control control) { Control newControl = null; if (control.GetType() == typeof(Picture)) newControl = new Picture(control.Get<Theme>(), control.Get<Material>(), control.DrawArea); else if (control.GetType() == typeof(Label)) { newControl = new Label(control.Get<Theme>(), control.DrawArea, (control as Label).Text); newControl.Set(control.Get<BlendMode>()); newControl.Set(control.Get<Material>()); } else if (control.GetType() == typeof(Button)) newControl = new Button(control.Get<Theme>(), control.DrawArea, (control as Button).Text); else if (control.GetType() == typeof(InteractiveButton)) newControl = new InteractiveButton(control.Get<Theme>(), control.DrawArea, (control as Button).Text); else if (control.GetType() == typeof(Slider)) newControl = new Slider(control.Get<Theme>(), control.DrawArea); newControl.RenderLayer = control.RenderLayer; if (!newControl.Contains<AnchoringState>()) newControl.Add(new AnchoringState()); //ncrunch: no coverage CheckIfAnyMaterialIsCorrupt(newControl); Scene.Add(newControl); }
private void CreateErrorWindow() { var exit = new InteractiveButton(new Rectangle(0.55f, 0.3f, 0.4f, 0.3f), "Must read the EULA to the end!") { RenderLayer = 9 }; exit.Clicked += () => //ncrunch: no coverage start { errorWindow.Hide(); eulaMenu.ToForeground(); }; //ncrunch: no coverage end errorWindow.Add(exit); errorWindow.Hide(); }
private void AddExitButtonToEulaMenu(Eula eula) { var exit = new InteractiveButton(new Rectangle(0.5f, 0.575f, 0.2f, 0.05f), "Exit") { RenderLayer = 4 }; exit.Clicked += () => //ncrunch: no coverage start { if (eula.WasRead) { eulaMenu.Hide(); mainMenu.ToForeground(); } else { eulaMenu.ToBackground(); errorWindow.Show(); } }; //ncrunch: no coverage end eulaMenu.Add(exit); }
public void SelectControlWithHighestRenderlayerWhenSelectingNewControl() { CreateNewButtons(); var button = new InteractiveButton(Rectangle.One); button.AddTag("New Button"); button.RenderLayer = 6; uiEditorScene.Scene.Controls.Insert(1, button); uiEditorScene.FindEntity2DOnPosition(new Vector2D(0.5f, 0.5f)); Assert.AreEqual(6, uiEditorScene.SelectedEntity2DList[0].RenderLayer); }
private void ChangeToInteractiveButton() { if (SelectedEntity2D == null || uiEditorScene == null || (SelectedEntity2D.GetType() != typeof(Button) && SelectedEntity2D.GetType() != typeof(InteractiveButton))) return; uiEditorScene.Scene.Remove(SelectedEntity2D); var renderLayer = SelectedEntity2D.RenderLayer; var controlName = SelectedEntity2D.GetTags()[0]; if (isInteractiveButton) SelectedEntity2D = new InteractiveButton(SelectedEntity2D.Get<Theme>(), SelectedEntity2D.DrawArea, ((Button)SelectedEntity2D).Text); else SelectedEntity2D = new Button(SelectedEntity2D.Get<Theme>(), SelectedEntity2D.DrawArea, ((Button)SelectedEntity2D).Text); SelectedEntity2D.RenderLayer = renderLayer; SelectedEntity2D.AddTag(controlName); uiEditorScene.Scene.Add(SelectedEntity2D); }
private void AddBackButton() { var backButton = new InteractiveButton(backTheme, new Rectangle(0.3f, ScreenSpace.Current.Bottom - 0.2f, 0.4f, 0.15f)); backButton.Clicked += () => { Hide(); parent.Show(); if(!parent.BackSound.IsAnyInstancePlaying) parent.BackSound.Play(); }; Add(backButton); }
private void AddBackButton() { var backButton = new InteractiveButton(menuTheme, new Rectangle(0.3f, ScreenSpace.Current.Bottom - 0.15f, 0.4f, 0.1f), "Back"); backButton.Clicked += () => { Hide(); parent.Show(); }; Add(backButton); }
private void AddQuitButton() { var quitButton = new InteractiveButton(exitTheme, new Rectangle(0.3f, 0.72f, 0.4f, 0.15f)); quitButton.Clicked += TryInvokeQuit; Add(quitButton); }
//ncrunch: no coverage end private void AddOptions() { var optionsButton = new InteractiveButton(optionsTheme, new Rectangle(0.3f, 0.58f, 0.4f, 0.15f)); optionsButton.Clicked += ShowOptionsSubmenu; Add(optionsButton); }
public void SelectAnInterActiveButton() { var button = new InteractiveButton(Rectangle.One); button.AddTag("New Button"); uiEditorScene.Scene.Add(button); uiEditorScene.SetEntity2D(button); Assert.AreEqual(button, uiEditorScene.SelectedEntity2DList[0]); }
//ncrunch: no coverage start private void AddGameElementSelection() { var backgroundButton = new InteractiveButton(parentMenu.menuTheme, new Rectangle(0.2f, 0.2f, 0.12f, 0.07f), "Background") { RenderLayer = 5 }; backgroundButton.Clicked += () => { currentColorIndex = 0; UpdateColorDisplay(); UpdateSliderValues(); }; Add(backgroundButton); var borderButton = new InteractiveButton(parentMenu.menuTheme, new Rectangle(0.35f, 0.2f, 0.12f, 0.07f), "Border") { RenderLayer = 5 }; borderButton.Clicked += () => { currentColorIndex = 1; UpdateColorDisplay(); UpdateSliderValues(); }; Add(borderButton); var snakeButton = new InteractiveButton(parentMenu.menuTheme, new Rectangle(0.5f, 0.2f, 0.12f, 0.07f), "Snake") { RenderLayer = 5 }; snakeButton.Clicked += () => { currentColorIndex = 2; UpdateColorDisplay(); UpdateSliderValues(); }; Add(snakeButton); var chunkButton = new InteractiveButton(parentMenu.menuTheme, new Rectangle(0.65f, 0.2f, 0.12f, 0.07f), "Chunk") { RenderLayer = 5 }; chunkButton.Clicked += () => { currentColorIndex = 3; UpdateColorDisplay(); UpdateSliderValues(); }; Add(chunkButton); }
private void AddButton(Theme theme, Action clicked, string text) { var button = new InteractiveButton(theme, new Rectangle(Vector2D.Zero, ButtonSize), text); button.Clicked += clicked; buttons.Add(button); Add(button); }
private void AddExitButtonToOptionsMenu() { var exit = new InteractiveButton(new Rectangle(0.6f, 0.575f, 0.1f, 0.05f), "Exit") { RenderLayer = 4 }; exit.Clicked += () => //ncrunch: no coverage start { optionsMenu.Hide(); mainMenu.ToForeground(); }; //ncrunch: no coverage end optionsMenu.Add(exit); }
private void AddBackButton() { var backButton = new InteractiveButton(menuTheme, new Rectangle(0.3f, 0.67f, 0.4f, 0.08f), "Back"); backButton.Clicked += () => { Hide(); parent.Show(); }; Add(backButton); }